forked from KolibriOS/kolibrios
f3c6ba6e90
1) A small fix for OptionBox - removed unnecessary redrawing when processing mouse events. 2) Build.sh - script to compile Box_lib library under Linux git-svn-id: svn://kolibrios.org@1227 a494cfbc-eb01-0410-851d-a64ba20cac60
198 lines
6.8 KiB
Plaintext
198 lines
6.8 KiB
Plaintext
;ôàéë ñîçäàí 13.02.2009 <Lrz> Íà êîä ïðèìåíåíà GPL2 ëèöåíçèÿ
|
|
;Ìàêðîñ äëÿ ñèñòåìíîé áèáëèîòåêè box_lib.obj
|
|
;Optionbox
|
|
|
|
macro use_optionbox_driver ;ìàêðîñû êîòîðûå óïðàâëÿþò ðàáîòîé áîêñà )
|
|
{
|
|
option_box_draw:
|
|
pusha
|
|
|
|
mov eax,dword [esp+36]
|
|
@@: mov edi,dword [eax]
|
|
test edi,edi
|
|
je option_check
|
|
call option_box_draw_box
|
|
add eax,4
|
|
jmp @b
|
|
|
|
option_check:
|
|
mov eax,dword [esp+36]
|
|
@@: mov edi,dword [eax]
|
|
test edi,edi
|
|
je @f
|
|
|
|
mov ebx,dword [edi]
|
|
mov ebx,dword [ebx]
|
|
cmp edi,ebx
|
|
jne .clear_op
|
|
|
|
pusha
|
|
call option_box_draw_op
|
|
popa
|
|
add eax,4
|
|
jmp @b
|
|
|
|
.clear_op:
|
|
pusha
|
|
call option_box_clear_op
|
|
popa
|
|
add eax,4
|
|
jmp @b
|
|
|
|
|
|
@@: popa
|
|
ret 4
|
|
; exit âîîáùå :)
|
|
|
|
|
|
option_box_mouse:
|
|
pusha
|
|
mcall 37,2
|
|
test eax,eax
|
|
jnz @f
|
|
popa
|
|
ret 4
|
|
@@:
|
|
mov eax,dword [esp+36]
|
|
@@: mov edi,dword [eax]
|
|
test edi,edi
|
|
je option_check
|
|
call option_box_mouse_op
|
|
add eax,4
|
|
jmp @b
|
|
|
|
}
|
|
macro use_optionbox_draw
|
|
{
|
|
option_box_draw_box:
|
|
option_group equ [edi]
|
|
op_left equ [edi+4] ;êîîðäèíàòà íà÷àëà ðèñîâàíèÿ ïî õ
|
|
op_top equ [edi+6] ;êîîðäèíàòà íà÷àëà ðèñîâàíèÿ ïî ó
|
|
op_text_margin equ [edi+8] ;=4 ðàññòîÿíèå îò ïðÿìîóãîëüíèêà ÷åê áîêñà äî íàäïèñè
|
|
op_size equ [edi+12] ;12 ðàçìåð êâàäðàòà ÷åê áîêñà
|
|
op_color equ [edi+16]
|
|
op_border_color equ [edi+20] ; or [edi+4] ;öâåò ðàìêè checkbox åå ìîæíî çàäàòü ñàìîñòîÿòåëüíî
|
|
op_text_color equ [edi+24];[edi+4] ;öâåò òåêñòà
|
|
op_text_ptr equ [edi+28] ;óêàçàòåëü íà íà÷àëî òåêñòîâîé ñòðîêè
|
|
op_text_length equ [edi+32]
|
|
op_flags equ [edi+36] ;ôëàãè
|
|
|
|
pusha ;ñîõðàíèì âñå ðåãèñòðû
|
|
|
|
movzx ebx,word op_left
|
|
shl ebx,16
|
|
add ebx,dword op_size
|
|
movzx ecx,word op_top
|
|
shl ecx,16
|
|
add ecx,dword op_size
|
|
mov edx,dword op_border_color
|
|
mov eax,13
|
|
mcall ;ðèñóåì ðàìêó
|
|
|
|
mov edx,dword op_color
|
|
add ebx,1 shl 16 - 2
|
|
add ecx,1 shl 16 - 2
|
|
mcall ;çàêðàøèâàåì âíóòðåííîñòè ÷åêáîêñà
|
|
|
|
; mov eax,dword option_group
|
|
; mov dword eax,[eax]
|
|
; cmp eax,edi
|
|
; jne @f
|
|
; call option_box_draw_op ;íàðèñîâàòü âêëþ÷åííûé ÷åê áîêñ
|
|
|
|
|
|
;----------------------------
|
|
;ðàñ÷åò êóäà áóäåò ïðîèçâåäåí âûâîä òåêñòà
|
|
;----------------------------
|
|
@@: movzx ebx,word op_left ;çàãðóçèòü çíà÷åíèå õ äëÿ ÷åê áîêñà
|
|
add ebx,dword op_size
|
|
add ebx,dword op_text_margin;äîáàâèòü ðàçìåð ñòîðîíû è ðàññòîÿíèå íà êîòîðîì íà÷íåòñÿ âûâîä òåêñòà
|
|
shl ebx,16 ;ñäâèíåì íà 16 ðàçðÿäîâ â ëåâî (óìíîæèì íà 65536)
|
|
mov bx,word op_top ;çàãðóçèì çíà÷åíèå ïî y
|
|
add ebx,op_size
|
|
mov ecx,dword op_text_color ;çàãðóçèì öâåò íàäïèñè + flags
|
|
sub ebx,7 ;äîáàâèì çíà÷åíèå äëèíû ñòîðîíû -9+2
|
|
|
|
mov edx,dword op_text_ptr ;óêàæåì àäðåñ îò êóäà íóæíî âûâîäèòü ñòðîêó
|
|
mov esi,dword op_text_length
|
|
;âíåñåì â eax çíà÷åíèå âûâîäà íàäïèñè íà êàíâó
|
|
mov eax,4
|
|
mcall ;Âûâîä
|
|
popa ;âîññòàíîâèòü çíà÷åíèÿ ðåãèñòðîâ èç ñòåêà
|
|
ret ;âûéäåì èç ïðîöåäóðû
|
|
|
|
option_box_clear_op: ;î÷èñòêà ÷åê áîêñà
|
|
mov edx,dword op_color ;öâåò âíóòðè ÷åê áîêñà
|
|
jmp @f ;áåçóñëîâíûé ïðûæîê íà íèæíþþ ìåòêó @@
|
|
|
|
|
|
option_box_draw_op: ;íàðèñîâàòü âêëþ÷åííûé ÷åê áîêñ
|
|
mov edx,dword op_border_color ;çàãðóçèòü öâåò
|
|
@@:
|
|
movzx ebx,word op_left ;çàãðóçèòü êîîðäèíàòó ïî õ
|
|
mov eax,dword op_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 op_top ;çàãðóçèòü êîîðäèíàòó ïî ó
|
|
pop ax
|
|
add cx,ax
|
|
shl ecx,16 ;ñäâèíåì íà 16 ðàçðÿäîâ â ëåâî (óìíîæèì íà 65536)
|
|
mov cx,bp ;çàãðóçèì çíà÷åíèÿ ðåãèñòðà óêàçàòåëÿ áàçû â cx
|
|
mov eax,13 ;â eax - çíà÷åíèÿ ôóíêöèè äëÿ âûâîäà ïîëîñû ò.å. ïî ñóòè ïðÿìîóãîëüíèêà, êîòîðûé îòîáðàæàåò âêëþ÷åííûé êîìïîíåíò ÷åê áîêñ
|
|
mcall ;âûâîä
|
|
ret ;âûéòè èç ïðîöåäóðû
|
|
}
|
|
|
|
|
|
macro use_optionbox_mouse
|
|
{
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;Îáðàáîò÷èê mouse
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
option_box_mouse_op: ;îáðàáîòêà ìûøè
|
|
pusha
|
|
mov esi,dword op_text_length ;çàãðóçèòü êîë-âî ñèìâîëîâ â òåêñòîâîé ñòðîêå
|
|
;Óìíîæåíèå íà 6 Áûñòðîå óìíîæåíèå ìîæíî âîñïîëüçîâàòüñÿ ëþáûì ìç ìåòîäîâ, íî íà ñòàðûõ Ïðîöåññîðàõ (386,486,P1)áûñòðåå áóäåò ñ èíñòðóêöèåé Lea
|
|
; lea esi,[eax*2+eax]
|
|
; shl eax,1
|
|
imul esi,6 ; èëè ìîæíî è òàê óìíîæèòü íà 6
|
|
xor ebx,ebx
|
|
add esi,dword op_text_margin ;äîáàâèòü 3 - ðàññòîÿíèå îò ÷åê áîêñà äî íàäïèñè
|
|
|
|
mov eax,37 ;ïîëó÷èì êîîðäèíàòû ìûøêè
|
|
inc ebx ;äîáàâèòü 1
|
|
mcall ;ïîëó÷èòü êîîðäèíàòû êóðñîðà îòíîñèòåëüíî îêíà
|
|
|
|
movzx ebx,word op_top ;çàãðóçèòü â bx çíà÷åíèå êîîðäèíàòû ó
|
|
cmp ax,bx ;ñðàâíèòü ñ ñ êîîðäèíàòîé êóðñîðà
|
|
jl option_box_mouse_end ;SF <> OF åñëè ìåíüøå
|
|
add ebx,dword op_size ;äîáàâèòü ðàçìåð
|
|
cmp ax,bx ;ñðàâíèòü
|
|
jg option_box_mouse_end ;ZF = 0 è SF = OF åñëè áîëüøå
|
|
|
|
shr eax,16 ;ðàçäåëèì íà 65536 èëè ïðîñòî ñäâèíåì áèòû íà 16 çíà÷åíèé
|
|
movzx ebx,word op_left ;ïðîèçâåäåì àíàëîãè÷íîå ñðàâíåíèå
|
|
cmp ax,bx ;ñðàâíèòü ðåãèñòðû
|
|
jl option_box_mouse_end ;åñëè ìåíüøå
|
|
add ebx,dword op_size ;äîáàâèòü äëèíó ñòîðîíû ïðÿìîóãîëüíèêà
|
|
add ebx,esi ;Ó÷åñòü â çíà÷åíèè ïî õ åùå è äëèíó íàäïèñè ê ÷åêáîêñó
|
|
cmp ax,bx ;ñòðàâíèòü ðåãèñòðû
|
|
jg option_box_mouse_end ;åñëè áîëüøå
|
|
mov eax,dword option_group
|
|
mov [eax],edi
|
|
|
|
option_box_mouse_end:
|
|
popa ;âîññòàíîâèòü ðåãèñòðû èç ñòåêà
|
|
ret ;âûéòè
|
|
|
|
} |