Clipboard Example Applications.

git-svn-id: svn://kolibrios.org@4200 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79) 2013-11-10 04:17:20 +00:00
parent 9c4fa92828
commit 4f135529a5
4 changed files with 352 additions and 0 deletions

View File

@ -0,0 +1,7 @@
@echo lang fix en >lang.inc
@fasm.exe -m 16384 clip_put.asm clip_put
@fasm.exe -m 16384 clip_get.asm clip_get
@erase lang.inc
@kpack clip_put
@kpack clip_get
@pause

View File

@ -0,0 +1,182 @@
;*****************************************************************************
; Read the data from the clipboard
; Copyright (c) 2013, Marat Zakiyanov aka Mario79, aka Mario
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
; * Neither the name of the <organization> nor the
; names of its contributors may be used to endorse or promote products
; derived from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;******************************************************************************
use32
org 0x0
db 'MENUET01'
dd 0x01
dd START
dd IM_END
dd I_END
dd stacktop
dd 0x0
dd 0x0
;---------------------------------------------------------------------
include '../../../macros.inc'
;---------------------------------------------------------------------
START:
mcall 68,11
red:
call draw_window
still:
mcall 10
cmp eax,1
je red
cmp eax,2
je key
cmp eax,3
je button
jmp still
;---------------------------------------------------------------------
key:
mcall 2
jmp still
;---------------------------------------------------------------------
button:
mcall 17
cmp ah,2
je .read_button
cmp ah,1
jne still
.exit:
mcall -1
;--------------------------------------
.read_button:
call draw_clipboard
jmp still
;---------------------------------------------------------------------
draw_window:
mcall 12,1
xor esi,esi
mcall 0,<0,600>,<0,400>,0x13FFFFFF,,title
mcall 8,<20,150>,<40,20>,2,0xCCCCCC
mcall 4,<25,47>,0x90000000,read_button_text
mcall 12,2
ret
;---------------------------------------------------------------------
draw_clipboard:
mcall 54,0
cmp eax,-1
je .exit
test eax,eax
jz .exit
mov [slots_number],eax
xor eax,eax
mov [current_slot],eax
mov [text_coordinates],dword 10 shl 16+70
.start:
xor eax,eax
mov [current_slot_data],eax
mcall 54,1,[current_slot]
cmp eax,-1
je .no_relevant_data
cmp eax,1
jne @f
.no_relevant_data:
mov edx,no_relevant_data_text
mov esi,no_relevant_data_text.end-no_relevant_data_text
jmp .print
.no_relevant_data_1:
mov edx,no_relevant_data_text_1
mov esi,no_relevant_data_text_1.end-no_relevant_data_text_1
jmp .print
.no_relevant_data_2:
mov edx,no_relevant_data_text_2
mov esi,no_relevant_data_text_2.end-no_relevant_data_text_2
jmp .print
@@:
mov [current_slot_data],eax
mov eax,[current_slot_data]
mov esi,[eax]
sub esi,12
add eax,4
cmp [eax],dword 0
jne .no_relevant_data_1
add eax,4
cmp [eax],dword 866
jne .no_relevant_data_2
add eax,4
mov edx,eax
.print:
mcall 4,[text_coordinates],0x0
mov ecx,[current_slot_data]
test ecx,ecx
jz @f
mcall 68,13
@@:
add [text_coordinates],dword 15
inc dword [current_slot]
mov eax,[slots_number]
dec eax
mov [slots_number],eax
jnz .start
.exit:
ret
;---------------------------------------------------------------------
title:
db 'Read the data from the clipboard',0
read_button_text:
db 'Read from clipboard',0
no_relevant_data_text:
db '<NO RELEVANT DATA>',0
.end:
no_relevant_data_text_1:
db '<NO TEXT>',0
.end:
no_relevant_data_text_2:
db '<NO 866>',0
.end:
;---------------------------------------------------------------------
IM_END:
slots_number:
rd 1
text_coordinates:
rd 1
current_slot:
rd 1
current_slot_data:
rd 1
;--------------------------------------
rb 1024
stacktop:
rb 4
;---------------------------------------------------------------------
I_END:
;---------------------------------------------------------------------

View File

@ -0,0 +1,133 @@
;*****************************************************************************
; Write the data to the clipboard
; Copyright (c) 2013, Marat Zakiyanov aka Mario79, aka Mario
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
; * Redistributions of source code must retain the above copyright
; notice, this list of conditions and the following disclaimer.
; * Redistributions in binary form must reproduce the above copyright
; notice, this list of conditions and the following disclaimer in the
; documentation and/or other materials provided with the distribution.
; * Neither the name of the <organization> nor the
; names of its contributors may be used to endorse or promote products
; derived from this software without specific prior written permission.
;
; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;******************************************************************************
use32
org 0x0
db 'MENUET01'
dd 0x01
dd START
dd IM_END
dd I_END
dd stacktop
dd 0x0
dd 0x0
;---------------------------------------------------------------------
include '../../../macros.inc'
;---------------------------------------------------------------------
START:
red:
call draw_window
still:
mcall 10
cmp eax,1
je red
cmp eax,2
je key
cmp eax,3
je button
jmp still
;---------------------------------------------------------------------
key:
mcall 2
jmp still
;---------------------------------------------------------------------
button:
mcall 17
cmp ah,2
je .write_button
cmp ah,3
je .delete_button
cmp ah,1
jne still
.exit:
mcall -1
;--------------------------------------
.write_button:
mcall 54,2,buffer_data.end-buffer_data,buffer_data
mov [operation_result],eax
call redraw_operation_result
jmp still
;--------------------------------------
.delete_button:
mcall 54,3
mov [operation_result],eax
call redraw_operation_result
jmp still
;---------------------------------------------------------------------
draw_window:
mcall 12,1
xor esi,esi
mcall 0,<0,350>,<0,100>,0x13FFFFFF,,title
mcall 8,<20,130>,<40,20>,2,0xCCCCCC
mcall ,<160,155>,,3
mcall 4,<25,47>,0x90000000,write_button_text
mcall ,<165,47>,,delete_button_text
mcall ,<25,77>,,operation_result_text
call redraw_operation_result
mcall 12,2
ret
;---------------------------------------------------------------------
redraw_operation_result:
mcall 13,<200,100>,<77,8>,0xFFFFFF
mcall 47,0x80080100,[operation_result],<200,77>,0x10000000
ret
;---------------------------------------------------------------------
title:
db 'Write the data to the clipboard',0
write_button_text:
db 'Write to clipboard',0
delete_button_text:
db 'Delete from clipboard',0
operation_result_text:
db 'Result of the operation:',0
;---------------------------------------------------------------------
buffer_data:
dd buffer_data.end - buffer_data
dd 0 ; type 'text'
dd 866 ; text encoding
db 'Test message to the clipboard'
.end:
;---------------------------------------------------------------------
IM_END:
operation_result:
rd 1
;--------------------------------------
rb 1024
stacktop:
rb 4
;---------------------------------------------------------------------
I_END:
;---------------------------------------------------------------------

View File

@ -0,0 +1,30 @@
Содержимое контейнера буфера обмена
1. Первый dword содержит общую длину данных в контейнере
2. Второй dword указывает тип данныx:
0 = Текст
1 = Изображение
2 = RAW
4 и выше зарезервировано
2.1 Текст
Данные в третьем dword содержат тип:
0 = UTF
1 = 0866
2 = 1251
3 и выше зарезервировано
2.2 Изображение
Третий dword - размер по X
Четвертый dword - размер по Y
Пятый dword - глубина цвета в битах (8, 16, 24, 32, 48, 64)
Шестой dword - Указатель на палитру (смещение от начала файла).
Если палитры нет то значение 0
Седьмой dword - Размер области палитры, максимальное значение 256*4=1024байт.
Если палитры нет то значение 0
Восьмой dword - Указатель на данные пикселей для R, G, B.
Девятый dword - Размер области данных для пикселей.
2.3 RAW
Может содержать любые данные, т.к. содержимое на усмотрение программиста