Mods by vhanla:

- Window is grabbed to drag only if you CLICK on its grab area (ie. the title bar) 
- Button is selected only if it is clicked on its area

git-svn-id: svn://kolibrios.org@415 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
heavyiron 2007-03-12 21:54:24 +00:00
parent 2a81124ad8
commit 5efd9e7bcf
4 changed files with 2870 additions and 2792 deletions

View File

@ -59,225 +59,225 @@ incecx2:
drawbuttonframes: drawbuttonframes:
push esi push esi
push edi push edi
push eax push eax
push ebx push ebx
push ecx push ecx
push edx push edx
shr eax,16 shr eax,16
shr ebx,16 shr ebx,16
mov edx,[TASK_BASE] mov edx,[TASK_BASE]
add eax,[edx-twdw + WDATA.box.left] add eax,[edx-twdw + WDATA.box.left]
add ebx,[edx-twdw + WDATA.box.top] add ebx,[edx-twdw + WDATA.box.top]
mov cx,ax mov cx,ax
mov dx,bx mov dx,bx
shl eax,16 shl eax,16
shl ebx,16 shl ebx,16
mov ax,cx mov ax,cx
mov bx,dx mov bx,dx
add ax,word [esp+12] add ax,word [esp+12]
mov esi,ebx mov esi,ebx
mov edi,0 mov edi,0
mov ecx,[esp+0] mov ecx,[esp+0]
call incecx call incecx
call [draw_line] call [draw_line]
movzx edx,word [esp+8] movzx edx,word [esp+8]
add ebx,edx add ebx,edx
shl edx,16 shl edx,16
add ebx,edx add ebx,edx
mov ecx,[esp+0] mov ecx,[esp+0]
call dececx call dececx
call [draw_line] call [draw_line]
mov ebx,esi mov ebx,esi
push edx push edx
mov edx,eax mov edx,eax
shr edx,16 shr edx,16
mov ax,dx mov ax,dx
mov edx,ebx mov edx,ebx
shr edx,16 shr edx,16
mov bx,dx mov bx,dx
mov dx,[esp+8+4] mov dx,[esp+8+4]
add bx,dx add bx,dx
pop edx pop edx
mov edi,0 mov edi,0
mov ecx,[esp+0] mov ecx,[esp+0]
call incecx call incecx
call [draw_line] call [draw_line]
mov esi,edx mov esi,edx
mov dx,[esp+12] mov dx,[esp+12]
add ax,dx add ax,dx
shl edx,16 shl edx,16
add eax,edx add eax,edx
add ebx,1*65536 add ebx,1*65536
mov edx,esi mov edx,esi
mov ecx,[esp+0] mov ecx,[esp+0]
call dececx call dececx
call [draw_line] call [draw_line]
pop edx pop edx
pop ecx pop ecx
pop ebx pop ebx
pop eax pop eax
pop edi pop edi
pop esi pop esi
ret ret
button_dececx: button_dececx:
cmp [buttontype],dword 1 cmp [buttontype],dword 1
jne .finish jne .finish
; je bdece ; je bdece
; ret ; ret
; bdece: ; bdece:
push eax push eax
mov eax,0x01 mov eax,0x01
cmp edi,20 cmp edi,20
jg @f jg @f
mov eax,0x02 mov eax,0x02
@@: @@:
test ecx,0xff test ecx,0xff
jz @f jz @f
sub ecx,eax sub ecx,eax
@@: @@:
shl eax,8 shl eax,8
test ecx,0xff00 test ecx,0xff00
jz @f jz @f
sub ecx,eax sub ecx,eax
@@: @@:
shl eax,8 shl eax,8
test ecx,0xff0000 test ecx,0xff0000
jz @f jz @f
sub ecx,eax sub ecx,eax
@@: @@:
pop eax pop eax
.finish: .finish:
ret ret
sys_button: sys_button:
push edi push edi
mov edi,[CURRENT_TASK] mov edi,[CURRENT_TASK]
shl edi,8 shl edi,8
rol eax,16 rol eax,16
add ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] add ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left]
rol eax,16 rol eax,16
rol ebx,16 rol ebx,16
add bx,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] add bx,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top]
rol ebx,16 rol ebx,16
pop edi pop edi
.forced: .forced:
test ecx,0x80000000 test ecx,0x80000000
jnz remove_button jnz remove_button
push esi push esi
push edi push edi
push eax ; <x,xs> push eax ; <x,xs>
push ebx ; <y,ys> push ebx ; <y,ys>
push ecx ; <id> push ecx ; <id>
push edx push edx
or ax,ax or ax,ax
jle noaddbutt jle noaddbutt
or bx,bx or bx,bx
jle noaddbutt jle noaddbutt
test ecx,0x40000000 test ecx,0x40000000
jnz button_no_draw jnz button_no_draw
pushad ; button body pushad ; button body
push ebx push ebx
shr eax,16 shr eax,16
shr ebx,16 shr ebx,16
mov edx,[TASK_BASE] mov edx,[TASK_BASE]
mov esi,[edx-twdw + WDATA.box.left] mov esi,[edx-twdw + WDATA.box.left]
mov edi,[edx-twdw + WDATA.box.top] mov edi,[edx-twdw + WDATA.box.top]
add eax,esi add eax,esi
add ebx,edi add ebx,edi
mov cx,ax mov cx,ax
mov dx,bx mov dx,bx
shl eax,16 shl eax,16
shl ebx,16 shl ebx,16
mov ax,cx mov ax,cx
mov bx,dx mov bx,dx
movzx ecx,word [4+32+esp+12] movzx ecx,word [4+32+esp+12]
add eax,ecx add eax,ecx
mov ecx,[4+32+esp+0] mov ecx,[4+32+esp+0]
cmp [buttontype],dword 0 cmp [buttontype],dword 0
je @f je @f
call incecx2 call incecx2
@@: @@:
movzx edi,word [esp] movzx edi,word [esp]
pop edx pop edx
and edx, 0xFFFF and edx, 0xFFFF
.newline: .newline:
call button_dececx call button_dececx
push edi push edi
xor edi, edi xor edi, edi
call [draw_line] call [draw_line]
pop edi pop edi
add ebx,1*65536+1 ; [ y start | y end ] add ebx,1*65536+1 ; [ y start | y end ]
dec edx dec edx
jnz .newline jnz .newline
popad popad
call drawbuttonframes call drawbuttonframes
button_no_draw: button_no_draw:
and ecx,0xffff and ecx,0xffff
mov edi,[BTN_ADDR] mov edi,[BTN_ADDR]
movzx eax,word [edi] movzx eax,word [edi]
cmp eax,max_buttons cmp eax,max_buttons
jge noaddbutt jge noaddbutt
inc eax inc eax
mov [edi],ax mov [edi],ax
shl eax,4 shl eax,4
add eax,edi add eax,edi
mov bx,[CURRENT_TASK] mov bx,[CURRENT_TASK]
mov [eax],bx mov [eax],bx
add eax,2 ; save button id number add eax,2 ; save button id number
mov ebx,[esp+4] mov ebx,[esp+4]
mov [eax],bx ; bits 0-15 mov [eax],bx ; bits 0-15
shr ebx,16 shr ebx,16
mov [eax-2+0xc],bx; bits 16-31 mov [eax-2+0xc],bx; bits 16-31
add eax,2 ; x start add eax,2 ; x start
mov bx,[esp+12+2] mov bx,[esp+12+2]
mov [eax],bx mov [eax],bx
add eax,2 ; x size add eax,2 ; x size
mov bx,[esp+12+0] mov bx,[esp+12+0]
mov [eax],bx mov [eax],bx
add eax,2 ; y start add eax,2 ; y start
mov bx,[esp+8+2] mov bx,[esp+8+2]
mov [eax],bx mov [eax],bx
add eax,2 ; y size add eax,2 ; y size
mov bx,[esp+8+0] mov bx,[esp+8+0]
mov [eax],bx mov [eax],bx
noaddbutt: noaddbutt:
pop edx pop edx
pop ecx pop ecx
pop ebx pop ebx
pop eax pop eax
pop edi pop edi
pop esi pop esi
ret ret
remove_button: remove_button:
@ -294,7 +294,7 @@ remove_button:
rnewba: rnewba:
dec bx dec bx
jz rnmba jz rnmba
add eax,0x10 add eax,0x10
@ -323,44 +323,44 @@ remove_button:
find_pressed_button_frames: find_pressed_button_frames:
pushad pushad
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
add ebx,window_data add ebx,window_data
mov ecx, [ebx+ WDATA.box.left] ; window x start mov ecx, [ebx+ WDATA.box.left] ; window x start
movzx edx,word [eax+4] ; button x start movzx edx,word [eax+4] ; button x start
add ecx,edx add ecx,edx
push ecx push ecx
mov dx,[eax+6] ; button x size mov dx,[eax+6] ; button x size
add cx,dx add cx,dx
mov esi,ecx mov esi,ecx
inc esi inc esi
mov ecx, [ebx+WDATA.box.top] ; window y start mov ecx, [ebx+WDATA.box.top] ; window y start
mov dx,[eax+8] ; button y start mov dx,[eax+8] ; button y start
add ecx,edx add ecx,edx
mov ebx,ecx mov ebx,ecx
mov dx,[eax+10] ; button y size mov dx,[eax+10] ; button y size
add dx,cx add dx,cx
inc dx inc dx
pop eax pop eax
; eax x beginning ; eax x beginning
; ebx y beginning ; ebx y beginning
; esi x end ; esi x end
; edx y end ; edx y end
; ecx color ; ecx color
mov [pressed_button_eax],eax mov [pressed_button_eax],eax
mov [pressed_button_ebx],ebx mov [pressed_button_ebx],ebx
mov [pressed_button_ecx],ecx mov [pressed_button_ecx],ecx
mov [pressed_button_edx],edx mov [pressed_button_edx],edx
mov [pressed_button_esi],esi mov [pressed_button_esi],esi
popad popad
ret ret
uglobal uglobal
pressed_button_eax dd 0 pressed_button_eax dd 0
@ -373,70 +373,70 @@ endg
; negative button image ; negative button image
negativebutton: negativebutton:
; If requested, do not display button ; If requested, do not display button
; boarder on press. ; boarder on press.
test ebx,0x20000000 test ebx,0x20000000
jz draw_negative_button jz draw_negative_button
ret ret
draw_negative_button: draw_negative_button:
pushad pushad
mov eax,[pressed_button_eax] mov eax,[pressed_button_eax]
mov ebx,[pressed_button_ebx] mov ebx,[pressed_button_ebx]
mov ecx,[pressed_button_ecx] mov ecx,[pressed_button_ecx]
mov edx,[pressed_button_edx] mov edx,[pressed_button_edx]
mov esi,[pressed_button_esi] mov esi,[pressed_button_esi]
mov ecx,0x01000000 mov ecx,0x01000000
dec edx dec edx
push edx push edx
inc edx inc edx
dec esi dec esi
push esi push esi
inc esi inc esi
push eax push eax
push ebx push ebx
push ecx push ecx
push edx push edx
push edi push edi
call [disable_mouse] call [disable_mouse]
bdbnewline: bdbnewline:
mov edi,1 ; force mov edi,1 ; force
cmp eax,[esp+16] cmp eax,[esp+16]
jz bneg jz bneg
cmp eax,[esp+20] cmp eax,[esp+20]
jz bneg jz bneg
cmp ebx,[esp+12] cmp ebx,[esp+12]
jz bneg jz bneg
cmp ebx,[esp+24] cmp ebx,[esp+24]
jnz nbneg jnz nbneg
; jz bneg ; jz bneg
; jmp nbneg ; jmp nbneg
bneg: bneg:
;;;call [disable_mouse] ;;;call [disable_mouse]
call [putpixel] call [putpixel]
nbneg: nbneg:
inc eax inc eax
cmp eax,esi cmp eax,esi
jnz bdbnewline jnz bdbnewline
mov eax,[esp+16] mov eax,[esp+16]
inc ebx inc ebx
cmp ebx,edx cmp ebx,edx
jnz bdbnewline jnz bdbnewline
add esp,28 add esp,28
popad popad
ret ret
; check buttons ; check buttons
@ -458,9 +458,11 @@ checkbuttons:
cmp [BTN_DOWN],byte 0 ; mouse buttons pressed cmp [BTN_DOWN],byte 0 ; mouse buttons pressed
jnz @f jnz @f
;..................................... start 1/5 : modified by vhanla .............................
mov [bPressedMouseXY_B],0
;..................................... end 1/5 : modified by vhanla .............................
ret ret
@@: @@:
pushad pushad
xor esi, esi xor esi, esi
@ -472,6 +474,20 @@ checkbuttons:
ret ret
@@: @@:
;..................................... start 2/5 : modified by vhanla .............................
;here i catch the coordinates when the mouse's button is clicked
push ax
cmp [bPressedMouseXY_B],0;FALSE
jnz @f
mov [bPressedMouseXY_B],1;TRUE - it was already clicked
mov ax,[MOUSE_X]
mov [mx],ax
mov ax,[MOUSE_Y]
mov [my],ax
@@:
pop ax
;and it is only refreshed after the mouse's button release
;..................................... end 2/5 : modified by vhanla .............................
push esi push esi
inc edx inc edx
@ -485,7 +501,7 @@ checkbuttons:
cmp edx,esi cmp edx,esi
jge bch jge bch
popad ; no button pressed popad ; no button pressed
ret ret
bch: bch:
@ -496,10 +512,6 @@ checkbuttons:
shl eax,4 shl eax,4
add eax,edi add eax,edi
;......................start 1/2 : modified by vhanla .............................
mov [buttonid],eax
;......................end 1/2 : modified by vhanla .............................
; check that button is at top of windowing stack ; check that button is at top of windowing stack
movzx ebx,word [eax] movzx ebx,word [eax]
@ -512,8 +524,8 @@ checkbuttons:
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
test [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED test [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED
jnz buttonnewcheck jnz buttonnewcheck
; add ebx,window_data ; add ebx,window_data
; mov ecx,[window_data+ebx+8] ; window end X ; mov ecx,[window_data+ebx+8] ; window end X
@ -527,46 +539,50 @@ checkbuttons:
jge buttonnewcheck jge buttonnewcheck
; check coordinates ; check coordinates
; mouse x >= button x ? ; mouse x >= button x ?
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
add ebx,window_data add ebx,window_data
mov ecx, [ebx+WDATA.box.left] ; window x start mov ecx, [ebx+WDATA.box.left] ; window x start
movzx edx,word [eax+4] ; button x start movzx edx,word [eax+4] ; button x start
add edx,ecx add edx,ecx
mov cx,[MOUSE_X] ;..................................... start 3/5 : modified by vhanla .............................
mov cx,[mx] ;mov cx,[MOUSE_X]
;..................................... end 3/5 : modified by vhanla .............................
cmp edx,ecx cmp edx,ecx
jg buttonnewcheck jg buttonnewcheck
movzx ebx,word [eax+6] ; button x size movzx ebx,word [eax+6] ; button x size
add edx,ebx add edx,ebx
cmp ecx,edx cmp ecx,edx
jg buttonnewcheck jg buttonnewcheck
; mouse y >= button y ? ; mouse y >= button y ?
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
add ebx,window_data add ebx,window_data
mov ecx, [ebx+WDATA.box.top] ; window y start mov ecx, [ebx+WDATA.box.top] ; window y start
movzx edx,word [eax+8] ; button y start movzx edx,word [eax+8] ; button y start
add edx,ecx add edx,ecx
mov cx,[MOUSE_Y] ;..................................... start 4/5 : modified by vhanla .............................
mov cx,[my] ;mov cx,[MOUSE_Y]
;..................................... start 4/5 : modified by vhanla .............................
cmp edx,ecx cmp edx,ecx
jg buttonnewcheck jg buttonnewcheck
movzx ebx,word [eax+10] ; button y size movzx ebx,word [eax+10] ; button y size
add edx,ebx add edx,ebx
cmp ecx,edx cmp ecx,edx
jg buttonnewcheck jg buttonnewcheck
; mouse on button ; mouse on button
pop edx pop edx
pop esi pop esi
mov bx,[eax+0xc] ; button id : bits 16-31 mov bx,[eax+0xc] ; button id : bits 16-31
shl ebx,16 shl ebx,16
mov bx,[eax+2] ; button id : bits 00-16 mov bx,[eax+2] ; button id : bits 00-16
push ebx push ebx
mov [MOUSE_DOWN],byte 1 ; no mouse down checks mov [MOUSE_DOWN],byte 1 ; no mouse down checks
@ -591,58 +607,60 @@ checkbuttons:
call negativebutton call negativebutton
mov [MOUSE_BACKGROUND],byte 0 ; no mouse background mov [MOUSE_BACKGROUND],byte 0 ; no mouse background
mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse
;..................................... start 2/2 : modified by vhanla ............................. ;..................................... start 5/5 : modified by vhanla .............................
; check coordinates ; check coordinates
jmp afterbuttonid jmp @f
buttonid dd 0x0 ;here a will backup the eax value mx dw 0x0 ; keeps the x mouse's position when it was clicked
afterbuttonid: my dw 0x0 ; keeps the y mouse's position when it was clicked
bPressedMouseXY_B db 0x0
@@:
pusha pusha
; mouse x >= button x ? ; mouse x >= button x ?
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
add ebx,window_data add ebx,window_data
mov ecx, [ebx+WDATA.box.left] ; window x start mov ecx, [ebx+WDATA.box.left] ; window x start
movzx edx,word [eax+4] ; button x start movzx edx,word [eax+4] ; button x start
add edx,ecx add edx,ecx
mov cx,[MOUSE_X] mov cx,[MOUSE_X]
cmp edx,ecx cmp edx,ecx
jg no_on_button ;if we release the pointer out of the button area jg no_on_button ;if we release the pointer out of the button area
movzx ebx,word [eax+6] ; button x size movzx ebx,word [eax+6] ; button x size
add edx,ebx add edx,ebx
cmp ecx,edx cmp ecx,edx
jg no_on_button jg no_on_button
; mouse y >= button y ? ; mouse y >= button y ?
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
add ebx,window_data add ebx,window_data
mov ecx, [ebx+WDATA.box.top] ; window y start mov ecx, [ebx+WDATA.box.top] ; window y start
movzx edx,word [eax+8] ; button y start movzx edx,word [eax+8] ; button y start
add edx,ecx add edx,ecx
mov cx,[MOUSE_Y] mov cx,[MOUSE_Y]
cmp edx,ecx cmp edx,ecx
jg no_on_button jg no_on_button
movzx ebx,word [eax+10] ; button y size movzx ebx,word [eax+10] ; button y size
add edx,ebx add edx,ebx
cmp ecx,edx cmp ecx,edx
jg no_on_button jg no_on_button
popa popa
mov [BTN_COUNT],byte 1 ; no of buttons in buffer mov [BTN_COUNT],byte 1 ; no of buttons in buffer
pop ebx pop ebx
mov [BTN_BUFF],ebx ; lets put the button id in buffer mov [BTN_BUFF],ebx ; lets put the button id in buffer
push ebx push ebx
pusha pusha
jmp yes_on_button jmp yes_on_button
no_on_button: no_on_button:
mov [BTN_COUNT],byte 0 ; no of buttons in buffer mov [BTN_COUNT],byte 0 ; no of buttons in buffer
yes_on_button: yes_on_button:
mov [MOUSE_DOWN],byte 0 ; mouse down -> do not draw mov [MOUSE_DOWN],byte 0 ; mouse down -> do not draw
popa popa
pop ebx pop ebx
popa popa
ret ret
;..................................... end 2/2 : modified by vhanla ................................ ;..................................... end 5/5 : modified by vhanla ................................

File diff suppressed because it is too large Load Diff

View File

@ -59,225 +59,225 @@ incecx2:
drawbuttonframes: drawbuttonframes:
push esi push esi
push edi push edi
push eax push eax
push ebx push ebx
push ecx push ecx
push edx push edx
shr eax,16 shr eax,16
shr ebx,16 shr ebx,16
mov edx,[TASK_BASE] mov edx,[TASK_BASE]
add eax,[edx-twdw + WDATA.box.left] add eax,[edx-twdw + WDATA.box.left]
add ebx,[edx-twdw + WDATA.box.top] add ebx,[edx-twdw + WDATA.box.top]
mov cx,ax mov cx,ax
mov dx,bx mov dx,bx
shl eax,16 shl eax,16
shl ebx,16 shl ebx,16
mov ax,cx mov ax,cx
mov bx,dx mov bx,dx
add ax,word [esp+12] add ax,word [esp+12]
mov esi,ebx mov esi,ebx
mov edi,0 mov edi,0
mov ecx,[esp+0] mov ecx,[esp+0]
call incecx call incecx
call [draw_line] call [draw_line]
movzx edx,word [esp+8] movzx edx,word [esp+8]
add ebx,edx add ebx,edx
shl edx,16 shl edx,16
add ebx,edx add ebx,edx
mov ecx,[esp+0] mov ecx,[esp+0]
call dececx call dececx
call [draw_line] call [draw_line]
mov ebx,esi mov ebx,esi
push edx push edx
mov edx,eax mov edx,eax
shr edx,16 shr edx,16
mov ax,dx mov ax,dx
mov edx,ebx mov edx,ebx
shr edx,16 shr edx,16
mov bx,dx mov bx,dx
mov dx,[esp+8+4] mov dx,[esp+8+4]
add bx,dx add bx,dx
pop edx pop edx
mov edi,0 mov edi,0
mov ecx,[esp+0] mov ecx,[esp+0]
call incecx call incecx
call [draw_line] call [draw_line]
mov esi,edx mov esi,edx
mov dx,[esp+12] mov dx,[esp+12]
add ax,dx add ax,dx
shl edx,16 shl edx,16
add eax,edx add eax,edx
add ebx,1*65536 add ebx,1*65536
mov edx,esi mov edx,esi
mov ecx,[esp+0] mov ecx,[esp+0]
call dececx call dececx
call [draw_line] call [draw_line]
pop edx pop edx
pop ecx pop ecx
pop ebx pop ebx
pop eax pop eax
pop edi pop edi
pop esi pop esi
ret ret
button_dececx: button_dececx:
cmp [buttontype],dword 1 cmp [buttontype],dword 1
jne .finish jne .finish
; je bdece ; je bdece
; ret ; ret
; bdece: ; bdece:
push eax push eax
mov eax,0x01 mov eax,0x01
cmp edi,20 cmp edi,20
jg @f jg @f
mov eax,0x02 mov eax,0x02
@@: @@:
test ecx,0xff test ecx,0xff
jz @f jz @f
sub ecx,eax sub ecx,eax
@@: @@:
shl eax,8 shl eax,8
test ecx,0xff00 test ecx,0xff00
jz @f jz @f
sub ecx,eax sub ecx,eax
@@: @@:
shl eax,8 shl eax,8
test ecx,0xff0000 test ecx,0xff0000
jz @f jz @f
sub ecx,eax sub ecx,eax
@@: @@:
pop eax pop eax
.finish: .finish:
ret ret
sys_button: sys_button:
push edi push edi
mov edi,[CURRENT_TASK] mov edi,[CURRENT_TASK]
shl edi,8 shl edi,8
rol eax,16 rol eax,16
add ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left] add ax,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.left]
rol eax,16 rol eax,16
rol ebx,16 rol ebx,16
add bx,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top] add bx,word[edi+SLOT_BASE+APPDATA.wnd_clientbox.top]
rol ebx,16 rol ebx,16
pop edi pop edi
.forced: .forced:
test ecx,0x80000000 test ecx,0x80000000
jnz remove_button jnz remove_button
push esi push esi
push edi push edi
push eax ; <x,xs> push eax ; <x,xs>
push ebx ; <y,ys> push ebx ; <y,ys>
push ecx ; <id> push ecx ; <id>
push edx push edx
or ax,ax or ax,ax
jle noaddbutt jle noaddbutt
or bx,bx or bx,bx
jle noaddbutt jle noaddbutt
test ecx,0x40000000 test ecx,0x40000000
jnz button_no_draw jnz button_no_draw
pushad ; button body pushad ; button body
push ebx push ebx
shr eax,16 shr eax,16
shr ebx,16 shr ebx,16
mov edx,[TASK_BASE] mov edx,[TASK_BASE]
mov esi,[edx-twdw + WDATA.box.left] mov esi,[edx-twdw + WDATA.box.left]
mov edi,[edx-twdw + WDATA.box.top] mov edi,[edx-twdw + WDATA.box.top]
add eax,esi add eax,esi
add ebx,edi add ebx,edi
mov cx,ax mov cx,ax
mov dx,bx mov dx,bx
shl eax,16 shl eax,16
shl ebx,16 shl ebx,16
mov ax,cx mov ax,cx
mov bx,dx mov bx,dx
movzx ecx,word [4+32+esp+12] movzx ecx,word [4+32+esp+12]
add eax,ecx add eax,ecx
mov ecx,[4+32+esp+0] mov ecx,[4+32+esp+0]
cmp [buttontype],dword 0 cmp [buttontype],dword 0
je @f je @f
call incecx2 call incecx2
@@: @@:
movzx edi,word [esp] movzx edi,word [esp]
pop edx pop edx
and edx, 0xFFFF and edx, 0xFFFF
.newline: .newline:
call button_dececx call button_dececx
push edi push edi
xor edi, edi xor edi, edi
call [draw_line] call [draw_line]
pop edi pop edi
add ebx,1*65536+1 ; [ y start | y end ] add ebx,1*65536+1 ; [ y start | y end ]
dec edx dec edx
jnz .newline jnz .newline
popad popad
call drawbuttonframes call drawbuttonframes
button_no_draw: button_no_draw:
and ecx,0xffff and ecx,0xffff
mov edi,[BTN_ADDR] mov edi,[BTN_ADDR]
movzx eax,word [edi] movzx eax,word [edi]
cmp eax,max_buttons cmp eax,max_buttons
jge noaddbutt jge noaddbutt
inc eax inc eax
mov [edi],ax mov [edi],ax
shl eax,4 shl eax,4
add eax,edi add eax,edi
mov bx,[CURRENT_TASK] mov bx,[CURRENT_TASK]
mov [eax],bx mov [eax],bx
add eax,2 ; save button id number add eax,2 ; save button id number
mov ebx,[esp+4] mov ebx,[esp+4]
mov [eax],bx ; bits 0-15 mov [eax],bx ; bits 0-15
shr ebx,16 shr ebx,16
mov [eax-2+0xc],bx; bits 16-31 mov [eax-2+0xc],bx; bits 16-31
add eax,2 ; x start add eax,2 ; x start
mov bx,[esp+12+2] mov bx,[esp+12+2]
mov [eax],bx mov [eax],bx
add eax,2 ; x size add eax,2 ; x size
mov bx,[esp+12+0] mov bx,[esp+12+0]
mov [eax],bx mov [eax],bx
add eax,2 ; y start add eax,2 ; y start
mov bx,[esp+8+2] mov bx,[esp+8+2]
mov [eax],bx mov [eax],bx
add eax,2 ; y size add eax,2 ; y size
mov bx,[esp+8+0] mov bx,[esp+8+0]
mov [eax],bx mov [eax],bx
noaddbutt: noaddbutt:
pop edx pop edx
pop ecx pop ecx
pop ebx pop ebx
pop eax pop eax
pop edi pop edi
pop esi pop esi
ret ret
remove_button: remove_button:
@ -294,7 +294,7 @@ remove_button:
rnewba: rnewba:
dec bx dec bx
jz rnmba jz rnmba
add eax,0x10 add eax,0x10
@ -323,44 +323,44 @@ remove_button:
find_pressed_button_frames: find_pressed_button_frames:
pushad pushad
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
add ebx,window_data add ebx,window_data
mov ecx, [ebx+ WDATA.box.left] ; window x start mov ecx, [ebx+ WDATA.box.left] ; window x start
movzx edx,word [eax+4] ; button x start movzx edx,word [eax+4] ; button x start
add ecx,edx add ecx,edx
push ecx push ecx
mov dx,[eax+6] ; button x size mov dx,[eax+6] ; button x size
add cx,dx add cx,dx
mov esi,ecx mov esi,ecx
inc esi inc esi
mov ecx, [ebx+WDATA.box.top] ; window y start mov ecx, [ebx+WDATA.box.top] ; window y start
mov dx,[eax+8] ; button y start mov dx,[eax+8] ; button y start
add ecx,edx add ecx,edx
mov ebx,ecx mov ebx,ecx
mov dx,[eax+10] ; button y size mov dx,[eax+10] ; button y size
add dx,cx add dx,cx
inc dx inc dx
pop eax pop eax
; eax x beginning ; eax x beginning
; ebx y beginning ; ebx y beginning
; esi x end ; esi x end
; edx y end ; edx y end
; ecx color ; ecx color
mov [pressed_button_eax],eax mov [pressed_button_eax],eax
mov [pressed_button_ebx],ebx mov [pressed_button_ebx],ebx
mov [pressed_button_ecx],ecx mov [pressed_button_ecx],ecx
mov [pressed_button_edx],edx mov [pressed_button_edx],edx
mov [pressed_button_esi],esi mov [pressed_button_esi],esi
popad popad
ret ret
uglobal uglobal
pressed_button_eax dd 0 pressed_button_eax dd 0
@ -373,70 +373,70 @@ endg
; negative button image ; negative button image
negativebutton: negativebutton:
; If requested, do not display button ; If requested, do not display button
; boarder on press. ; boarder on press.
test ebx,0x20000000 test ebx,0x20000000
jz draw_negative_button jz draw_negative_button
ret ret
draw_negative_button: draw_negative_button:
pushad pushad
mov eax,[pressed_button_eax] mov eax,[pressed_button_eax]
mov ebx,[pressed_button_ebx] mov ebx,[pressed_button_ebx]
mov ecx,[pressed_button_ecx] mov ecx,[pressed_button_ecx]
mov edx,[pressed_button_edx] mov edx,[pressed_button_edx]
mov esi,[pressed_button_esi] mov esi,[pressed_button_esi]
mov ecx,0x01000000 mov ecx,0x01000000
dec edx dec edx
push edx push edx
inc edx inc edx
dec esi dec esi
push esi push esi
inc esi inc esi
push eax push eax
push ebx push ebx
push ecx push ecx
push edx push edx
push edi push edi
call [disable_mouse] call [disable_mouse]
bdbnewline: bdbnewline:
mov edi,1 ; force mov edi,1 ; force
cmp eax,[esp+16] cmp eax,[esp+16]
jz bneg jz bneg
cmp eax,[esp+20] cmp eax,[esp+20]
jz bneg jz bneg
cmp ebx,[esp+12] cmp ebx,[esp+12]
jz bneg jz bneg
cmp ebx,[esp+24] cmp ebx,[esp+24]
jnz nbneg jnz nbneg
; jz bneg ; jz bneg
; jmp nbneg ; jmp nbneg
bneg: bneg:
;;;call [disable_mouse] ;;;call [disable_mouse]
call [putpixel] call [putpixel]
nbneg: nbneg:
inc eax inc eax
cmp eax,esi cmp eax,esi
jnz bdbnewline jnz bdbnewline
mov eax,[esp+16] mov eax,[esp+16]
inc ebx inc ebx
cmp ebx,edx cmp ebx,edx
jnz bdbnewline jnz bdbnewline
add esp,28 add esp,28
popad popad
ret ret
; check buttons ; check buttons
@ -458,9 +458,11 @@ checkbuttons:
cmp [BTN_DOWN],byte 0 ; mouse buttons pressed cmp [BTN_DOWN],byte 0 ; mouse buttons pressed
jnz @f jnz @f
;..................................... start 1/5 : modified by vhanla .............................
mov [bPressedMouseXY_B],0
;..................................... end 1/5 : modified by vhanla .............................
ret ret
@@: @@:
pushad pushad
xor esi, esi xor esi, esi
@ -472,6 +474,20 @@ checkbuttons:
ret ret
@@: @@:
;..................................... start 2/5 : modified by vhanla .............................
;here i catch the coordinates when the mouse's button is clicked
push ax
cmp [bPressedMouseXY_B],0;FALSE
jnz @f
mov [bPressedMouseXY_B],1;TRUE - it was already clicked
mov ax,[MOUSE_X]
mov [mx],ax
mov ax,[MOUSE_Y]
mov [my],ax
@@:
pop ax
;and it is only refreshed after the mouse's button release
;..................................... end 2/5 : modified by vhanla .............................
push esi push esi
inc edx inc edx
@ -485,7 +501,7 @@ checkbuttons:
cmp edx,esi cmp edx,esi
jge bch jge bch
popad ; no button pressed popad ; no button pressed
ret ret
bch: bch:
@ -496,10 +512,6 @@ checkbuttons:
shl eax,4 shl eax,4
add eax,edi add eax,edi
;......................start 1/2 : modified by vhanla .............................
mov [buttonid],eax
;......................end 1/2 : modified by vhanla .............................
; check that button is at top of windowing stack ; check that button is at top of windowing stack
movzx ebx,word [eax] movzx ebx,word [eax]
@ -512,8 +524,8 @@ checkbuttons:
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
test [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED test [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED
jnz buttonnewcheck jnz buttonnewcheck
; add ebx,window_data ; add ebx,window_data
; mov ecx,[window_data+ebx+8] ; window end X ; mov ecx,[window_data+ebx+8] ; window end X
@ -527,46 +539,50 @@ checkbuttons:
jge buttonnewcheck jge buttonnewcheck
; check coordinates ; check coordinates
; mouse x >= button x ? ; mouse x >= button x ?
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
add ebx,window_data add ebx,window_data
mov ecx, [ebx+WDATA.box.left] ; window x start mov ecx, [ebx+WDATA.box.left] ; window x start
movzx edx,word [eax+4] ; button x start movzx edx,word [eax+4] ; button x start
add edx,ecx add edx,ecx
mov cx,[MOUSE_X] ;..................................... start 3/5 : modified by vhanla .............................
mov cx,[mx] ;mov cx,[MOUSE_X]
;..................................... end 3/5 : modified by vhanla .............................
cmp edx,ecx cmp edx,ecx
jg buttonnewcheck jg buttonnewcheck
movzx ebx,word [eax+6] ; button x size movzx ebx,word [eax+6] ; button x size
add edx,ebx add edx,ebx
cmp ecx,edx cmp ecx,edx
jg buttonnewcheck jg buttonnewcheck
; mouse y >= button y ? ; mouse y >= button y ?
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
add ebx,window_data add ebx,window_data
mov ecx, [ebx+WDATA.box.top] ; window y start mov ecx, [ebx+WDATA.box.top] ; window y start
movzx edx,word [eax+8] ; button y start movzx edx,word [eax+8] ; button y start
add edx,ecx add edx,ecx
mov cx,[MOUSE_Y] ;..................................... start 4/5 : modified by vhanla .............................
mov cx,[my] ;mov cx,[MOUSE_Y]
;..................................... start 4/5 : modified by vhanla .............................
cmp edx,ecx cmp edx,ecx
jg buttonnewcheck jg buttonnewcheck
movzx ebx,word [eax+10] ; button y size movzx ebx,word [eax+10] ; button y size
add edx,ebx add edx,ebx
cmp ecx,edx cmp ecx,edx
jg buttonnewcheck jg buttonnewcheck
; mouse on button ; mouse on button
pop edx pop edx
pop esi pop esi
mov bx,[eax+0xc] ; button id : bits 16-31 mov bx,[eax+0xc] ; button id : bits 16-31
shl ebx,16 shl ebx,16
mov bx,[eax+2] ; button id : bits 00-16 mov bx,[eax+2] ; button id : bits 00-16
push ebx push ebx
mov [MOUSE_DOWN],byte 1 ; no mouse down checks mov [MOUSE_DOWN],byte 1 ; no mouse down checks
@ -591,58 +607,60 @@ checkbuttons:
call negativebutton call negativebutton
mov [MOUSE_BACKGROUND],byte 0 ; no mouse background mov [MOUSE_BACKGROUND],byte 0 ; no mouse background
mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse
;..................................... start 2/2 : modified by vhanla ............................. ;..................................... start 5/5 : modified by vhanla .............................
; check coordinates ; check coordinates
jmp afterbuttonid jmp @f
buttonid dd 0x0 ;here a will backup the eax value mx dw 0x0 ; keeps the x mouse's position when it was clicked
afterbuttonid: my dw 0x0 ; keeps the y mouse's position when it was clicked
bPressedMouseXY_B db 0x0
@@:
pusha pusha
; mouse x >= button x ? ; mouse x >= button x ?
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
add ebx,window_data add ebx,window_data
mov ecx, [ebx+WDATA.box.left] ; window x start mov ecx, [ebx+WDATA.box.left] ; window x start
movzx edx,word [eax+4] ; button x start movzx edx,word [eax+4] ; button x start
add edx,ecx add edx,ecx
mov cx,[MOUSE_X] mov cx,[MOUSE_X]
cmp edx,ecx cmp edx,ecx
jg no_on_button ;if we release the pointer out of the button area jg no_on_button ;if we release the pointer out of the button area
movzx ebx,word [eax+6] ; button x size movzx ebx,word [eax+6] ; button x size
add edx,ebx add edx,ebx
cmp ecx,edx cmp ecx,edx
jg no_on_button jg no_on_button
; mouse y >= button y ? ; mouse y >= button y ?
movzx ebx,word [eax+0] movzx ebx,word [eax+0]
shl ebx,5 shl ebx,5
add ebx,window_data add ebx,window_data
mov ecx, [ebx+WDATA.box.top] ; window y start mov ecx, [ebx+WDATA.box.top] ; window y start
movzx edx,word [eax+8] ; button y start movzx edx,word [eax+8] ; button y start
add edx,ecx add edx,ecx
mov cx,[MOUSE_Y] mov cx,[MOUSE_Y]
cmp edx,ecx cmp edx,ecx
jg no_on_button jg no_on_button
movzx ebx,word [eax+10] ; button y size movzx ebx,word [eax+10] ; button y size
add edx,ebx add edx,ebx
cmp ecx,edx cmp ecx,edx
jg no_on_button jg no_on_button
popa popa
mov [BTN_COUNT],byte 1 ; no of buttons in buffer mov [BTN_COUNT],byte 1 ; no of buttons in buffer
pop ebx pop ebx
mov [BTN_BUFF],ebx ; lets put the button id in buffer mov [BTN_BUFF],ebx ; lets put the button id in buffer
push ebx push ebx
pusha pusha
jmp yes_on_button jmp yes_on_button
no_on_button: no_on_button:
mov [BTN_COUNT],byte 0 ; no of buttons in buffer mov [BTN_COUNT],byte 0 ; no of buttons in buffer
yes_on_button: yes_on_button:
mov [MOUSE_DOWN],byte 0 ; mouse down -> do not draw mov [MOUSE_DOWN],byte 0 ; mouse down -> do not draw
popa popa
pop ebx pop ebx
popa popa
ret ret
;..................................... end 2/2 : modified by vhanla ................................ ;..................................... end 5/5 : modified by vhanla ................................

File diff suppressed because it is too large Load Diff