2010-10-01 11:21:55 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2016-01-18 23:18:04 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
|
2010-10-01 11:21:55 +02:00
|
|
|
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
|
|
button.MAX_BUTTONS = 4095
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
struct SYS_BUTTON
|
|
|
|
pslot dw ?
|
|
|
|
id_lo dw ?
|
|
|
|
left dw ?
|
|
|
|
width dw ?
|
|
|
|
top dw ?
|
|
|
|
height dw ?
|
|
|
|
id_hi dw ?
|
|
|
|
dw ?
|
|
|
|
ends
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2016-01-18 23:18:04 +01:00
|
|
|
;---------------------------------------------------------------
|
|
|
|
syscall_button: ;////////////// system function 8 //////////////
|
|
|
|
;---------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
;? Define/undefine GUI button object
|
2016-01-18 23:18:04 +01:00
|
|
|
;---------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
;; Define button:
|
|
|
|
;> ebx = pack[16(x), 16(width)]
|
|
|
|
;> ecx = pack[16(y), 16(height)]
|
|
|
|
;> edx = pack[8(flags), 24(button identifier)]
|
|
|
|
;> flags bits:
|
|
|
|
;> 7 (31) = 0
|
|
|
|
;> 6 (30) = don't draw button
|
|
|
|
;> 5 (29) = don't draw button frame when pressed
|
|
|
|
;> esi = button color
|
2016-01-18 23:18:04 +01:00
|
|
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2010-10-01 11:21:55 +02:00
|
|
|
;; Undefine button:
|
|
|
|
;> edx = pack[8(flags), 24(button identifier)]
|
|
|
|
;> flags bits:
|
|
|
|
;> 7 (31) = 1
|
2016-01-18 23:18:04 +01:00
|
|
|
;---------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
; do we actually need to undefine the button?
|
|
|
|
test edx, 0x80000000
|
|
|
|
jnz .remove_button
|
|
|
|
|
|
|
|
; do we have free button slots available?
|
|
|
|
mov edi, [BTN_ADDR]
|
|
|
|
mov eax, [edi]
|
|
|
|
cmp eax, button.MAX_BUTTONS
|
|
|
|
jge .exit
|
|
|
|
|
|
|
|
; does it have positive size? (otherwise it doesn't have sense)
|
|
|
|
or bx, bx
|
|
|
|
jle .exit
|
|
|
|
or cx, cx
|
|
|
|
jle .exit
|
|
|
|
|
|
|
|
; make coordinates clientbox-relative
|
|
|
|
push eax
|
|
|
|
mov eax, [current_slot]
|
|
|
|
rol ebx, 16
|
|
|
|
add bx, word[eax + APPDATA.wnd_clientbox.left]
|
|
|
|
rol ebx, 16
|
|
|
|
rol ecx, 16
|
|
|
|
add cx, word[eax + APPDATA.wnd_clientbox.top]
|
|
|
|
rol ecx, 16
|
|
|
|
pop eax
|
|
|
|
|
|
|
|
; basic checks passed, define the button
|
|
|
|
inc eax
|
|
|
|
mov [edi], ax
|
|
|
|
shl eax, 4
|
|
|
|
add edi, eax
|
2016-01-18 23:18:04 +01:00
|
|
|
; NOTE: this code doesn't rely on SYS_BUTTON struct,
|
|
|
|
; please revise it, if you change something.
|
2010-10-01 11:21:55 +02:00
|
|
|
mov ax, [CURRENT_TASK]
|
|
|
|
stosw
|
|
|
|
mov ax, dx
|
|
|
|
stosw ; button id number: bits 0-15
|
|
|
|
mov eax, ebx
|
|
|
|
rol eax, 16
|
|
|
|
stosd ; x start | x size
|
|
|
|
mov eax, ecx
|
|
|
|
rol eax, 16
|
|
|
|
stosd ; y start | y size
|
|
|
|
mov eax, edx
|
|
|
|
shr eax, 16
|
|
|
|
stosw ; button id number: bits 16-31
|
|
|
|
|
|
|
|
; do we also need to draw the button?
|
|
|
|
test edx, 0x40000000
|
|
|
|
jnz .exit
|
|
|
|
|
2016-01-18 23:18:04 +01:00
|
|
|
and esi, 0xFFFFFF
|
|
|
|
xor edi, edi
|
|
|
|
push ebx ecx esi
|
|
|
|
dec cx
|
|
|
|
dec cx
|
|
|
|
cmp [buttontype], 1
|
|
|
|
jnz .draw
|
|
|
|
cmp cx, 65
|
|
|
|
jnc .draw
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2016-01-18 23:18:04 +01:00
|
|
|
; calculate gradient data
|
|
|
|
mov eax, esi
|
|
|
|
shl eax, 8
|
|
|
|
mov edx, 3
|
|
|
|
.calculate:
|
|
|
|
rol eax, 8
|
|
|
|
shl al, 1
|
|
|
|
jnc @f
|
|
|
|
neg al
|
|
|
|
jnz @f
|
|
|
|
mov al, 64
|
|
|
|
@@:
|
|
|
|
cmp al, 65
|
|
|
|
jc @f
|
|
|
|
mov al, 64
|
|
|
|
@@:
|
|
|
|
div cl
|
|
|
|
shl ax, 8
|
|
|
|
dec edx
|
|
|
|
jnz .calculate
|
|
|
|
mov dl, cl
|
|
|
|
dec edx
|
|
|
|
shr edx, 1
|
|
|
|
shr eax, 8
|
|
|
|
mov edi, eax
|
|
|
|
mul edx
|
|
|
|
add esi, eax
|
|
|
|
|
|
|
|
.draw: ; calculate window-relative coordinates
|
|
|
|
movzx ebp, cx
|
|
|
|
dec ebp
|
2010-10-01 11:21:55 +02:00
|
|
|
shr ebx, 16
|
|
|
|
shr ecx, 16
|
|
|
|
mov eax, [TASK_BASE]
|
|
|
|
add ebx, [eax - twdw + WDATA.box.left]
|
|
|
|
add ecx, [eax - twdw + WDATA.box.top]
|
|
|
|
mov eax, ebx
|
2015-07-22 08:58:10 +02:00
|
|
|
inc eax
|
2016-01-18 23:18:04 +01:00
|
|
|
mov edx, ebx
|
|
|
|
add dx, [esp+8]
|
|
|
|
dec edx
|
2010-10-01 11:21:55 +02:00
|
|
|
mov ebx, ecx
|
|
|
|
mov ecx, esi
|
2016-01-18 23:18:04 +01:00
|
|
|
shr ecx, 1
|
|
|
|
and cx, 7F7Fh
|
|
|
|
push esi
|
|
|
|
mov esi, edi
|
2010-10-01 11:21:55 +02:00
|
|
|
xor edi, edi
|
2016-01-18 23:18:04 +01:00
|
|
|
call hline ; top border
|
|
|
|
inc ebx
|
|
|
|
or ecx, 808080h
|
|
|
|
call hline ; top light line
|
|
|
|
pop ecx
|
|
|
|
inc ebx
|
|
|
|
.next_line:
|
|
|
|
call hline ; button body
|
|
|
|
inc ebx
|
|
|
|
sub ecx, esi
|
|
|
|
dec ebp
|
2010-10-01 11:21:55 +02:00
|
|
|
jnz .next_line
|
2016-01-18 23:18:04 +01:00
|
|
|
shr ecx, 2
|
|
|
|
and cx, 3F3Fh
|
|
|
|
mov ebp, ecx
|
|
|
|
shl ecx, 1
|
|
|
|
add ecx, ebp
|
|
|
|
call hline ; bottom dark line
|
|
|
|
inc ebx
|
|
|
|
sub ecx, ebp
|
|
|
|
call hline ; bottom border
|
|
|
|
pop ecx
|
|
|
|
shr ecx, 1
|
|
|
|
inc edx
|
2010-10-01 11:21:55 +02:00
|
|
|
push edx
|
|
|
|
mov edx, ebx
|
2016-01-18 23:18:04 +01:00
|
|
|
sub bx, [esp+4]
|
|
|
|
dec edx
|
|
|
|
inc ebx
|
|
|
|
cmp [buttontype], 0
|
|
|
|
jnz @f
|
|
|
|
dec edx
|
|
|
|
or ecx, 808080h
|
|
|
|
call vline ; left light line
|
|
|
|
inc edx
|
|
|
|
@@:
|
|
|
|
and ecx, 7F7F7Fh
|
|
|
|
dec eax
|
|
|
|
call vline ; left border
|
|
|
|
pop eax
|
|
|
|
call vline ; right border
|
|
|
|
cmp [buttontype], 0
|
|
|
|
jnz @f
|
|
|
|
mov ebp, ecx
|
|
|
|
shr ecx, 1
|
|
|
|
and cx, 7F7Fh
|
|
|
|
add ecx, ebp
|
|
|
|
dec eax
|
|
|
|
inc ebx
|
|
|
|
call vline ; right dark line
|
|
|
|
@@:
|
2010-10-01 11:21:55 +02:00
|
|
|
pop ecx ebx
|
2016-01-18 23:18:04 +01:00
|
|
|
.exit:
|
2010-10-01 11:21:55 +02:00
|
|
|
ret
|
|
|
|
|
|
|
|
; FIXME: mutex needed
|
2016-01-18 23:18:04 +01:00
|
|
|
.remove_button:
|
2010-10-01 11:21:55 +02:00
|
|
|
and edx, 0x00ffffff
|
|
|
|
mov edi, [BTN_ADDR]
|
|
|
|
mov ebx, [edi]
|
|
|
|
inc ebx
|
2012-03-08 09:33:38 +01:00
|
|
|
imul esi, ebx, sizeof.SYS_BUTTON
|
2010-10-01 11:21:55 +02:00
|
|
|
add esi, edi
|
|
|
|
xor ecx, ecx
|
2012-03-08 09:33:38 +01:00
|
|
|
add ecx, -sizeof.SYS_BUTTON
|
|
|
|
add esi, sizeof.SYS_BUTTON
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2016-01-18 23:18:04 +01:00
|
|
|
.next_button:
|
2010-10-01 11:21:55 +02:00
|
|
|
dec ebx
|
|
|
|
jz .exit
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
add ecx, sizeof.SYS_BUTTON
|
|
|
|
add esi, -sizeof.SYS_BUTTON
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
; does it belong to our process?
|
|
|
|
mov ax, [CURRENT_TASK]
|
|
|
|
cmp ax, [esi + SYS_BUTTON.pslot]
|
|
|
|
jne .next_button
|
|
|
|
|
|
|
|
; does the identifier match?
|
|
|
|
mov eax, dword[esi + SYS_BUTTON.id_hi - 2]
|
|
|
|
mov ax, [esi + SYS_BUTTON.id_lo]
|
|
|
|
and eax, 0x00ffffff
|
|
|
|
cmp edx, eax
|
|
|
|
jne .next_button
|
|
|
|
|
|
|
|
; okay, undefine it
|
|
|
|
push ebx
|
|
|
|
mov ebx, esi
|
2012-03-08 09:33:38 +01:00
|
|
|
lea eax, [esi + sizeof.SYS_BUTTON]
|
2010-10-01 11:21:55 +02:00
|
|
|
call memmove
|
|
|
|
dec dword[edi]
|
2012-03-08 09:33:38 +01:00
|
|
|
add ecx, -sizeof.SYS_BUTTON
|
2010-10-01 11:21:55 +02:00
|
|
|
pop ebx
|
|
|
|
jmp .next_button
|
|
|
|
|
2016-01-18 23:18:04 +01:00
|
|
|
;---------------------------------------------------------------
|
|
|
|
sys_button_activate_handler:
|
|
|
|
sys_button_deactivate_handler:
|
|
|
|
;---------------------------------------------------------------
|
2010-10-01 11:21:55 +02:00
|
|
|
;> eax = pack[8(process slot), 24(button id)]
|
|
|
|
;> ebx = pack[16(button x coord), 16(button y coord)]
|
|
|
|
;> cl = mouse button mask this system button was pressed with
|
2016-01-18 23:18:04 +01:00
|
|
|
;---------------------------------------------------------------
|
|
|
|
; find system button by specified process slot, id and coordinates
|
2010-10-01 11:21:55 +02:00
|
|
|
push ecx edx esi edi
|
|
|
|
mov edx, eax
|
|
|
|
shr edx, 24
|
|
|
|
and eax, 0x0ffffff
|
|
|
|
mov edi, [BTN_ADDR]
|
|
|
|
mov ecx, [edi]
|
2012-03-08 09:33:38 +01:00
|
|
|
imul esi, ecx, sizeof.SYS_BUTTON
|
2010-10-01 11:21:55 +02:00
|
|
|
add esi, edi
|
|
|
|
inc ecx
|
2012-03-08 09:33:38 +01:00
|
|
|
add esi, sizeof.SYS_BUTTON
|
2016-01-18 23:18:04 +01:00
|
|
|
.next_button:
|
2010-10-01 11:21:55 +02:00
|
|
|
dec ecx
|
2016-01-18 23:18:04 +01:00
|
|
|
jz .popexit
|
2012-03-08 09:33:38 +01:00
|
|
|
add esi, -sizeof.SYS_BUTTON
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
; does it belong to our process?
|
|
|
|
cmp dx, [esi + SYS_BUTTON.pslot]
|
|
|
|
jne .next_button
|
|
|
|
|
|
|
|
; does id match?
|
|
|
|
mov edi, dword[esi + SYS_BUTTON.id_hi - 2]
|
|
|
|
mov di, [esi + SYS_BUTTON.id_lo]
|
|
|
|
and edi, 0x0ffffff
|
|
|
|
cmp eax, edi
|
|
|
|
jne .next_button
|
|
|
|
|
|
|
|
; does coordinates match?
|
|
|
|
mov edi, dword[esi + SYS_BUTTON.left - 2]
|
|
|
|
mov di, [esi + SYS_BUTTON.top]
|
|
|
|
cmp ebx, edi
|
|
|
|
jne .next_button
|
|
|
|
|
|
|
|
mov eax, esi
|
|
|
|
pop edi esi edx ecx
|
2016-01-18 23:18:04 +01:00
|
|
|
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2016-01-18 23:18:04 +01:00
|
|
|
; display button border on press?
|
|
|
|
bt ebx, 29
|
|
|
|
jc .exit
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2016-01-18 23:18:04 +01:00
|
|
|
; invert system button border
|
2010-10-01 11:21:55 +02:00
|
|
|
pushad
|
2016-01-18 23:18:04 +01:00
|
|
|
mov esi, eax
|
|
|
|
mov edi, ebx
|
2010-10-01 11:21:55 +02:00
|
|
|
movzx ecx, [esi + SYS_BUTTON.pslot]
|
|
|
|
shl ecx, 5
|
|
|
|
add ecx, window_data
|
|
|
|
mov eax, dword[esi + SYS_BUTTON.left]
|
|
|
|
mov ebx, dword[esi + SYS_BUTTON.top]
|
|
|
|
add eax, [ecx + WDATA.box.left]
|
|
|
|
add ebx, [ecx + WDATA.box.top]
|
2016-01-18 23:18:04 +01:00
|
|
|
mov ecx, eax
|
|
|
|
mov edx, ebx
|
|
|
|
bt edi, 30
|
|
|
|
jc @f
|
|
|
|
inc ax
|
|
|
|
inc bx
|
|
|
|
dec cx
|
|
|
|
dec dx
|
|
|
|
@@:
|
2010-10-01 11:21:55 +02:00
|
|
|
rol eax, 16
|
|
|
|
rol ebx, 16
|
|
|
|
add ax, cx
|
|
|
|
add bx, dx
|
2016-01-18 23:18:04 +01:00
|
|
|
mov esi, 1000000h
|
2010-10-01 11:21:55 +02:00
|
|
|
call draw_rectangle.forced
|
|
|
|
popad
|
2016-01-18 23:18:04 +01:00
|
|
|
.exit:
|
|
|
|
ret
|
|
|
|
.popexit:
|
|
|
|
pop edi esi edx ecx
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
2016-01-18 23:18:04 +01:00
|
|
|
;---------------------------------------------------------------
|
|
|
|
sys_button_perform_handler:
|
|
|
|
;---------------------------------------------------------------
|
|
|
|
;> eax = pack[8(process slot), 24(button id)]
|
|
|
|
;> ebx = pack[16(button x coord), 16(button y coord)]
|
|
|
|
;> cl = mouse button mask this system button was pressed with
|
|
|
|
;---------------------------------------------------------------
|
|
|
|
shl eax, 8
|
|
|
|
mov al, cl
|
|
|
|
movzx ebx, byte[BTN_COUNT]
|
|
|
|
mov [BTN_BUFF + ebx * 4], eax
|
|
|
|
inc bl
|
|
|
|
mov [BTN_COUNT], bl
|
2010-10-01 11:21:55 +02:00
|
|
|
ret
|