kolibrios/programs/develop/libraries/box_lib/trunk/checkbox.mac
IgorA 2aad33c4e5 deleted file 'editbox_ex.mac' all programs
git-svn-id: svn://kolibrios.org@1373 a494cfbc-eb01-0410-851d-a64ba20cac60
2010-01-09 22:01:26 +00:00

182 lines
8.2 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;ôàéë ñîçäàí 13.02.2009 <Lrz> Íà êîä ïðèìåíåíà GPL2 ëèöåíçèÿ
;Ìàêðîñ äëÿ ñèñòåìíîé áèáëèîòåêè box_lib.obj
;Checkbox
ch_struc_size=36
ch_flag_en=10b ;ýëåìåíò âûáðàí
ch_left equ [edi] ;ª®®à¤¨­ â  ­ ç «  à¨á®¢ ­¨ï ¯® å
ch_top equ [edi+2] ;ª®®à¤¨­ â  ­ ç «  à¨á®¢ ­¨ï ¯® ã
ch_text_margin equ [edi+4] ;=4 à ááâ®ï­¨¥ ®â ¯àאַ㣮«ì­¨ª  祪 ¡®ªá  ¤® ­ ¤¯¨á¨
ch_size equ [edi+8] ;12 à §¬¥à ª¢ ¤à â  祪 ¡®ªá 
ch_color equ [edi+12] ;梥⠢­ãâਠcheckbox
ch_border_color equ [edi+16] ; or [edi+4] ;梥â à ¬ª¨ checkbox ¥¥ ¬®¦­® § ¤ âì á ¬®áâ®ï⥫쭮
ch_text_color equ [edi+20] ;[edi+4] ;梥â ⥪áâ 
ch_text_ptr equ [edi+24] ;㪠§ â¥«ì ­  ­ ç «® ⥪á⮢®© áâப¨
ch_text_length equ [edi+28]
ch_flags equ [edi+32] ;ä« £¨
macro check_boxes_set_sys_color start,end,color_table
{
mov edi,start
mov ecx,((end-start)/ch_struc_size)
mov esi,color_table
@@:
; push dword [esi+20] ;梥â à ¡®ç¥© ®¡« á⨠®ª­ 
; pop dword ch_color
push dword [esi+32] ;梥â ⥪áâ  ¢ à ¡®ç¥© ®¡« á⨠®ª­ 
pop dword ch_text_color
push dword [esi+36] ;梥⠣à ä¨ª¨ ¢ ®ª­¥ (à §¤¥«¨â¥«ì­ë¥ «¨­¨¨ ¨ â.¯.)
pop dword ch_border_color
add edi,ch_struc_size
loop @b
}
struc check_box left,top,ch_text_margin,ch_size,color,border_color,text_color,text,ch_text_length,flags
{ ;áâàãªâãà  ¯ à ¬¥â஢ ¤«ï 祪 ¡®ªá 
.left: dw left ;+0 ¯®«®¦¥­¨¥ ¯® å
.top: dw top ;+2 ¯®«®¦¥­¨¥ ¯® ã
.ch_text_margin: dd ch_text_margin ;à ááâ®ï­¨¥ ®â ¯àאַ㣮«ì­¨ª  祪 ¡®ªá  ¤® ­ ¤¯¨á¨
.ch_size: dd ch_size ;à §¬¥à ª¢ ¤à â  祪 ¡®ªá , ¤«ï ¯à¨¬¥à  12
.color: dd color ;梥⠢­ãâਠ祪¡®ªá 
.border_color: dd border_color ;梥â à ¬ª¨
.text_color: dd text_color ;梥⠭ ¤¯¨á¨
.text: dd text ; ¤à¥á ¢ ª®¤¥ ¯à®£à ¬¬ë £¤¥ à á¯®«®¦¥­ ⥪áâ
.ch_text_length: dd ch_text_length ;¤«¨­­  áâப¨ á ᨬ¢®« ¬¨
.flags: dd flags+0 ; ä« £¨
}
macro use_checkbox_draw
{
check_box_draw:
pusha ;ñîõðàíèì âñå ðåãèñòðû
mov edi,dword [esp+36]
mov eax,13
movzx ebx,word ch_left
shl ebx,16
add ebx,ch_size
mov ecx,ch_top
shl ecx,16
add ecx,dword ch_size
mov edx,dword ch_border_color
mcall ;ðèñóåì ðàìêó
mov edx,dword ch_color
add ebx,1 shl 16 - 2
add ecx,1 shl 16 - 2
mcall ;çàêðàøèâàåì âíóòðåííîñòè ÷åêáîêñà
test dword ch_flags,2 ;äîñòàòü çíà÷åíèå áèòà èç ïåðåìåííîé è ïîìåñòèòü â ôëàã CF
jz @f ;â åñëè CF=1, òî âûïîëíèì ñëåäóþùóþ ïðîöåäóðó èíà÷å ïåðåéòè íà íèæíþþ @@
call check_box_draw_ch ;íàðèñîâàòü âêëþ÷åííûé ÷åê áîêñ
@@:
;----------------------------
;ðàñ÷åò êóäà áóäåò ïðîèçâåäåí âûâîä òåêñòà
;----------------------------
movzx ebx,word ch_left ;çàãðóçèòü çíà÷åíèå õ äëÿ ÷åê áîêñà
add ebx,dword ch_size
add ebx,dword ch_text_margin;äîáàâèòü ðàçìåð ñòîðîíû è ðàññòîÿíèå íà êîòîðîì íà÷íåòñÿ âûâîä òåêñòà
shl ebx,16 ;ñäâèíåì íà 16 ðàçðÿäîâ â ëåâî (óìíîæèì íà 65536)
mov bx,word ch_top ;çàãðóçèì çíà÷åíèå ïî y
add ebx,ch_size
mov ecx,dword ch_text_color ;çàãðóçèì öâåò íàäïèñè + flags
sub ebx,7 ;äîáàâèì çíà÷åíèå äëèíû ñòîðîíû -9+2
mov edx,dword ch_text_ptr ;óêàæåì àäðåñ îò êóäà íóæíî âûâîäèòü ñòðîêó
mov esi,dword ch_text_length
;âíåñåì â eax çíà÷åíèå âûâîäà íàäïèñè íà êàíâó
mov eax,4
mcall ;Âûâîä
popa ;âîññòàíîâèòü çíà÷åíèÿ ðåãèñòðîâ èç ñòåêà
ret 4 ;âûéäåì èç ïðîöåäóðû
check_box_clear_ch: ;î÷èñòêà ÷åê áîêñà
mov edx,dword ch_color ;öâåò âíóòðè ÷åê áîêñà
jmp @f ;áåçóñëîâíûé ïðûæîê íà íèæíþþ ìåòêó @@
check_box_draw_ch: ;íàðèñîâàòü âêëþ÷åííûé ÷åê áîêñ
mov edx,dword ch_border_color ;çàãðóçèòü öâåò
@@:
movzx ebx,word ch_left ;çàãðóçèòü êîîðäèíàòó ïî õ
mov eax,dword ch_size
mov bp,ax
shr eax,2
push ax
push ax
add ebx,eax
shl ebx,16 ;ñäâèíåì íà 16 ðàçðÿäîâ â ëåâî (óìíîæèì íà 65536)
pop ax
lea eax,[eax*2]
sub bp,ax ;ñîõðàíèì ðåãèñòð bx â ðåãèñòðå óêàçàòåëÿ áàçû
mov bx,bp
movzx ecx,word ch_top ;çàãðóçèòü êîîðäèíàòó ïî ó
pop ax
add cx,ax
shl ecx,16 ;ñäâèíåì íà 16 ðàçðÿäîâ â ëåâî (óìíîæèì íà 65536)
mov cx,bp ;çàãðóçèì çíà÷åíèÿ ðåãèñòðà óêàçàòåëÿ áàçû â cx
mov eax,13 ;â eax - çíà÷åíèÿ ôóíêöèè äëÿ âûâîäà ïîëîñû ò.å. ïî ñóòè ïðÿìîóãîëüíèêà, êîòîðûé îòîáðàæàåò âêëþ÷åííûé êîìïîíåíò ÷åê áîêñ
mcall ;âûâîä
ret ;âûéòè èç ïðîöåäóðû
}
macro use_checkbox_mouse
{
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Îáðàáîò÷èê mouse
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
check_box_mouse: ;îáðàáîòêà ìûøè
pusha
mov edi,dword [esp+36]
mov eax,37 ;áóäåì ÷òî òî äåëàòü åñëè ó íàñ ÷òî - íèòü íàæàòî
mov ebx,2 ;âíåñòè â ðåãèñòð çíà÷åíèå 2
mcall ;ïðîâåðêà íå íàæàë ëè ïîëüçîâàòåëü êíîïêó ìûøêè
test eax,eax ;ïðîâåðêà åñëè ó íàñ â eax=0, òî óñòàíîâèì ôëàã è âûéäåì
jnz @f ;ïåðåéòè íà íèæíþþ ìåòêó @@
btr dword ch_flags,2 ;èçâëå÷åíèå çíà÷åíèÿ çàäàííîãî áèòà â ôëàã cf è èçìåíåíèå åãî çíà÷åíèÿ íà íóëåâîå.
jmp check_box_mouse_end
@@:
bts dword ch_flags,2 ;ïðîâåðêà ôëàãà ò.å. ïåðåíîñ â cf çíà÷åíèå áèòà è óñòàíîâêà áèòà â ñîñòîÿíèå âêëþ÷åíî
jc check_box_mouse_end ;åñëè CF=1 òî ïåðåéòè â êîíåö ò.å. ýòî âûõîä
mov esi,dword ch_text_length ;çàãðóçèòü êîë-âî ñèìâîëîâ â òåêñòîâîé ñòðîêå
;Óìíîæåíèå íà 6 Áûñòðîå óìíîæåíèå ìîæíî âîñïîëüçîâàòüñÿ ëþáûì ìç ìåòîäîâ, íî íà ñòàðûõ Ïðîöåññîðàõ (386,486,P1)áûñòðåå áóäåò ñ èíñòðóêöèåé Lea
lea esi,[eax*3]
shl esi,1
; imul esi,6 ; èëè ìîæíî è òàê óìíîæèòü íà 6
add esi,dword ch_text_margin ;äîáàâèòü 3 - ðàññòîÿíèå îò ÷åê áîêñà äî íàäïèñè
mov eax,37 ;ïîëó÷èì êîîðäèíàòû ìûøêè
mov ebx,1 ;äîáàâèòü 1
mcall ;ïîëó÷èòü êîîðäèíàòû êóðñîðà îòíîñèòåëüíî îêíà
movzx ebx,word ch_top ;çàãðóçèòü â bx çíà÷åíèå êîîðäèíàòû ó
cmp ax,bx ;ñðàâíèòü ñ ñ êîîðäèíàòîé êóðñîðà
jl check_box_mouse_end ;SF <> OF åñëè ìåíüøå
add ebx,dword ch_size ;äîáàâèòü ðàçìåð
cmp ax,bx ;ñðàâíèòü
jg check_box_mouse_end ;ZF = 0 è SF = OF åñëè áîëüøå
shr eax,16 ;ðàçäåëèì íà 65536 èëè ïðîñòî ñäâèíåì áèòû íà 16 çíà÷åíèé
movzx ebx,word ch_left ;ïðîèçâåäåì àíàëîãè÷íîå ñðàâíåíèå
cmp ax,bx ;ñðàâíèòü ðåãèñòðû
jl check_box_mouse_end ;åñëè ìåíüøå
add ebx,dword ch_size ;äîáàâèòü äëèíó ñòîðîíû ïðÿìîóãîëüíèêà
add ebx,esi ;Ó÷åñòü â çíà÷åíèè ïî õ åùå è äëèíó íàäïèñè ê ÷åêáîêñó
cmp ax,bx ;ñòðàâíèòü ðåãèñòðû
jg check_box_mouse_end ;åñëè áîëüøå
bts dword ch_flags,1 ;èçâëå÷åíèå çíà÷åíèÿ çàäàííîãî áèòà â ôëàã cf è èçìåíåíèå åãî çíà÷åíèÿ íà 1.
jc @f ;CF=1 òî ïåðåéòè íà íèæíþþ @@
call check_box_draw_ch ;îòîáðàçèòü âêëþ÷åííûé ÷åê áîêñ
; mov dword [esp+24],1 ;äàëüíåéøàÿ ïðîâåðêà ÷åê áîêñîâ áåñìûñëåíà, ïî ýòîìó â ñòåê, ãäå ðàñïîëàãàåòñÿ ecx ïîìåñòèòì 0
jmp check_box_mouse_end ;âûéòè
@@:
btr word ch_flags,1 ;èçâëå÷åíèå çíà÷åíèÿ çàäàííîãî áèòà â ôëàã cf è èçìåíåíèå åãî çíà÷åíèÿ íà íóëåâîå.
call check_box_clear_ch ;âûêëþ÷èòü ÷åê áîêñ ò.å. íà ìåñòå çàêðàøåííîãî ïðÿìîóãîëüíèêà îòîáðàçèòü öâåò ôîíà.
check_box_mouse_end:
popa ;âîññòàíîâèòü ðåãèñòðû èç ñòåêà
ret 4 ;âûéòè
}