/kernel/branches/kolibri-process/gui/button.inc |
---|
0,0 → 1,508 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 2455 $ |
;============================================================================== |
;///// public functions /////////////////////////////////////////////////////// |
;============================================================================== |
button.MAX_BUTTONS = 4095 |
struct SYS_BUTTON |
pslot dw ? |
id_lo dw ? |
left dw ? |
width dw ? |
top dw ? |
height dw ? |
id_hi dw ? |
dw ? |
ends |
align 4 |
;------------------------------------------------------------------------------ |
syscall_button: ;///// system function 8 ////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Define/undefine GUI button object |
;------------------------------------------------------------------------------ |
;; 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 |
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
;; Undefine button: |
;> edx = pack[8(flags), 24(button identifier)] |
;> flags bits: |
;> 7 (31) = 1 |
;------------------------------------------------------------------------------ |
; 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 |
push ebx ecx edx |
inc eax |
mov [edi], ax |
shl eax, 4 |
add edi, eax |
; NOTE: this code doesn't rely on SYS_BUTTON struct, please revise it |
; if you change something |
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 |
pop edx ecx ebx |
; do we also need to draw the button? |
test edx, 0x40000000 |
jnz .exit |
; draw button body |
pushad |
; calculate window-relative coordinates |
movzx edi, cx |
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 |
shl eax, 16 |
mov ax, bx |
add ax, word[esp + 16] |
mov ebx, ecx |
shl ebx, 16 |
mov bx, cx |
; calculate initial color |
mov ecx, esi |
cmp [buttontype], 0 |
je @f |
call button._.incecx2 |
; set button height counter |
@@: |
mov edx, edi |
.next_line: |
call button._.button_dececx |
push edi |
xor edi, edi |
; call [draw_line] |
call __sys_draw_line |
pop edi |
add ebx, 0x00010001 |
dec edx |
jnz .next_line |
popad |
; draw button frame |
push ebx ecx |
; calculate window-relative coordinates |
shr ebx, 16 |
shr ecx, 16 |
mov eax, [TASK_BASE] |
add ebx, [eax - twdw + WDATA.box.left] |
add ecx, [eax - twdw + WDATA.box.top] |
; top border |
mov eax, ebx |
shl eax, 16 |
mov ax, bx |
add ax, [esp + 4] |
mov ebx, ecx |
shl ebx, 16 |
mov bx, cx |
push ebx |
xor edi, edi |
mov ecx, esi |
call button._.incecx |
; call [draw_line] |
call __sys_draw_line |
; bottom border |
movzx edx, word[esp + 4 + 0] |
add ebx, edx |
shl edx, 16 |
add ebx, edx |
mov ecx, esi |
call button._.dececx |
; call [draw_line] |
call __sys_draw_line |
; left border |
pop ebx |
push edx |
mov edx, eax |
shr edx, 16 |
mov ax, dx |
mov edx, ebx |
shr edx, 16 |
mov bx, dx |
add bx, [esp + 4 + 0] |
pop edx |
mov ecx, esi |
call button._.incecx |
; call [draw_line] |
call __sys_draw_line |
; right border |
mov dx, [esp + 4] |
add ax, dx |
shl edx, 16 |
add eax, edx |
add ebx, 0x00010000 |
mov ecx, esi |
call button._.dececx |
; call [draw_line] |
call __sys_draw_line |
pop ecx ebx |
.exit: |
ret |
; FIXME: mutex needed |
syscall_button.remove_button: |
and edx, 0x00ffffff |
mov edi, [BTN_ADDR] |
mov ebx, [edi] |
inc ebx |
imul esi, ebx, sizeof.SYS_BUTTON |
add esi, edi |
xor ecx, ecx |
add ecx, -sizeof.SYS_BUTTON |
add esi, sizeof.SYS_BUTTON |
.next_button: |
dec ebx |
jz .exit |
add ecx, sizeof.SYS_BUTTON |
add esi, -sizeof.SYS_BUTTON |
; 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 |
lea eax, [esi + sizeof.SYS_BUTTON] |
call memmove |
dec dword[edi] |
add ecx, -sizeof.SYS_BUTTON |
pop ebx |
jmp .next_button |
.exit: |
ret |
align 4 |
;------------------------------------------------------------------------------ |
sys_button_activate_handler: ;///////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> 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 |
;------------------------------------------------------------------------------ |
call button._.find_button |
or eax, eax |
jz .exit |
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] |
call button._.negative_button |
.exit: |
ret |
align 4 |
;------------------------------------------------------------------------------ |
sys_button_deactivate_handler: ;/////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> 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 |
;------------------------------------------------------------------------------ |
call button._.find_button |
or eax, eax |
jz .exit |
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] |
call button._.negative_button |
.exit: |
ret |
align 4 |
;------------------------------------------------------------------------------ |
sys_button_perform_handler: ;////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> 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 |
ret |
;============================================================================== |
;///// private functions ////////////////////////////////////////////////////// |
;============================================================================== |
;------------------------------------------------------------------------------ |
button._.find_button: ;//////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Find system button by specified process slot, id and coordinates |
;------------------------------------------------------------------------------ |
;> eax = pack[8(process slot), 24(button id)] or 0 |
;> ebx = pack[16(button x coord), 16(button y coord)] |
;------------------------------------------------------------------------------ |
;< eax = pointer to SYS_BUTTON struct or 0 |
;------------------------------------------------------------------------------ |
push ecx edx esi edi |
mov edx, eax |
shr edx, 24 |
and eax, 0x0ffffff |
mov edi, [BTN_ADDR] |
mov ecx, [edi] |
imul esi, ecx, sizeof.SYS_BUTTON |
add esi, edi |
inc ecx |
add esi, sizeof.SYS_BUTTON |
.next_button: |
dec ecx |
jz .not_found |
add esi, -sizeof.SYS_BUTTON |
; 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 |
; okay, return it |
mov eax, esi |
jmp .exit |
.not_found: |
xor eax, eax |
.exit: |
pop edi esi edx ecx |
ret |
;------------------------------------------------------------------------------ |
button._.dececx: ;///////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
sub cl, 0x20 |
jnc @f |
xor cl, cl |
@@: |
sub ch, 0x20 |
jnc @f |
xor ch, ch |
@@: |
rol ecx, 16 |
sub cl, 0x20 |
jnc @f |
xor cl, cl |
@@: |
rol ecx, 16 |
ret |
;------------------------------------------------------------------------------ |
button._.incecx: ;///////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
add cl, 0x20 |
jnc @f |
or cl, -1 |
@@: |
add ch, 0x20 |
jnc @f |
or ch, -1 |
@@: |
rol ecx, 16 |
add cl, 0x20 |
jnc @f |
or cl, -1 |
@@: |
rol ecx, 16 |
ret |
;------------------------------------------------------------------------------ |
button._.incecx2: ;//////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
add cl, 0x14 |
jnc @f |
or cl, -1 |
@@: |
add ch, 0x14 |
jnc @f |
or ch, -1 |
@@: |
rol ecx, 16 |
add cl, 0x14 |
jnc @f |
or cl, -1 |
@@: |
rol ecx, 16 |
ret |
;------------------------------------------------------------------------------ |
button._.button_dececx: ;////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
cmp [buttontype], 1 |
jne .finish |
push eax |
mov al, 1 |
cmp edi, 20 |
jg @f |
mov al, 2 |
@@: |
sub cl, al |
jnc @f |
xor cl, cl |
@@: |
sub ch, al |
jnc @f |
xor ch, ch |
@@: |
rol ecx, 16 |
sub cl, al |
jnc @f |
xor cl, cl |
@@: |
rol ecx, 16 |
pop eax |
.finish: |
ret |
;------------------------------------------------------------------------------ |
button._.negative_button: ;//////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Invert system button border |
;------------------------------------------------------------------------------ |
; if requested, do not display button border on press. |
test ebx, 0x20000000 |
jnz .exit |
pushad |
xchg esi, eax |
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] |
push eax ebx |
pop edx ecx |
rol eax, 16 |
rol ebx, 16 |
add ax, cx |
add bx, dx |
mov esi, 0x01000000 |
call draw_rectangle.forced |
popad |
.exit: |
ret |
/kernel/branches/kolibri-process/gui/char.mt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/kernel/branches/kolibri-process/gui/char2.mt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/kernel/branches/kolibri-process/gui/char2_et.mt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/kernel/branches/kolibri-process/gui/char2_sp.mt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/kernel/branches/kolibri-process/gui/char_et.mt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/kernel/branches/kolibri-process/gui/char_sp.mt |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/kernel/branches/kolibri-process/gui/event.inc |
---|
0,0 → 1,616 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
;; Distributed under terms of the GNU General Public License ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3565 $ |
WINDOW_MOVE_AND_RESIZE_FLAGS = \ |
mouse.WINDOW_RESIZE_N_FLAG + \ |
mouse.WINDOW_RESIZE_W_FLAG + \ |
mouse.WINDOW_RESIZE_S_FLAG + \ |
mouse.WINDOW_RESIZE_E_FLAG + \ |
mouse.WINDOW_MOVE_FLAG |
uglobal |
align 4 |
event_start dd ? |
event_end dd ? |
event_uid dd 0 |
endg |
EV_SPACE = 512 |
FreeEvents = event_start-EVENT.fd ; "виртуальный" event, используются только поля: |
; FreeEvents.fd=event_start и FreeEvents.bk=event_end |
;----------------------------------------------------------------------------- |
align 4 |
init_events: ;; used from kernel.asm |
stdcall kernel_alloc, EV_SPACE*sizeof.EVENT |
or eax, eax |
jz .fail |
; eax - current event, ebx - previos event below |
mov ecx, EV_SPACE ; current - in allocated space |
mov ebx, FreeEvents ; previos - начало списка |
push ebx ; оно же и конец потом будет |
;-------------------------------------- |
align 4 |
@@: |
mov [ebx+EVENT.fd], eax |
mov [eax+EVENT.bk], ebx |
mov ebx, eax ; previos <- current |
add eax, sizeof.EVENT ; new current |
loop @b |
pop eax ; вот оно концом и стало |
mov [ebx+EVENT.fd], eax |
mov [eax+EVENT.bk], ebx |
;-------------------------------------- |
align 4 |
.fail: |
ret |
;----------------------------------------------------------------------------- |
EVENT_WATCHED equ 0x10000000 ;бит 28 |
EVENT_SIGNALED equ 0x20000000 ;бит 29 |
MANUAL_RESET equ 0x40000000 ;бит 30 |
MANUAL_DESTROY equ 0x80000000 ;бит 31 |
;----------------------------------------------------------------------------- |
align 4 |
create_event: ;; EXPORT use |
;info: |
; Переносим EVENT из списка FreeEvents в список ObjList текущего слота |
; EVENT.state устанавливаем из ecx, EVENT.code косвенно из esi (если esi<>0) |
;param: |
; esi - event data |
; ecx - flags |
;retval: |
; eax - event (=0 => fail) |
; edx - uid |
;scratched: ebx,ecx,esi,edi |
mov ebx, [current_slot] |
add ebx, APP_OBJ_OFFSET |
mov edx, [TASK_BASE] |
mov edx, [edx+TASKDATA.pid] |
pushfd |
cli |
;-------------------------------------- |
align 4 |
set_event: ;; INTERNAL use !!! don't use for Call |
;info: |
; Берем новый event из FreeEvents, заполняем его поля, как указано в ecx,edx,esi |
; и устанавливаем в список, указанный в ebx. |
; Возвращаем сам event (в eax), и его uid (в edx) |
;param: |
; ebx - start-chain "virtual" event for entry new event Right of him |
; ecx - flags (copied to EVENT.state) |
; edx - pid (copied to EVENT.pid) |
; esi - event data (copied to EVENT.code indirect, =0 => skip) |
;retval: |
; eax - event (=0 => fail) |
; edx - uid |
;scratched: ebx,ecx,esi,edi |
mov eax, FreeEvents |
cmp eax, [eax+EVENT.fd] |
jne @f ; not empty ??? |
pushad |
call init_events |
popad |
jz RemoveEventTo.break ; POPF+RET |
;-------------------------------------- |
align 4 |
@@: |
mov eax, [eax+EVENT.fd] |
mov [eax+EVENT.magic], 'EVNT' |
mov [eax+EVENT.destroy], destroy_event.internal |
mov [eax+EVENT.state], ecx |
mov [eax+EVENT.pid], edx |
inc [event_uid] |
Mov [eax+EVENT.id],edx,[event_uid] |
or esi, esi |
jz RemoveEventTo |
lea edi, [eax+EVENT.code] |
mov ecx, (sizeof.EVENT -EVENT.code)/4 |
cld |
rep movsd |
;-------------------------------------- |
align 4 |
RemoveEventTo: ;; INTERNAL use !!! don't use for Call |
;param: |
; eax - указатель на event, КОТОРЫЙ вставляем |
; ebx - указатель на event, ПОСЛЕ которого вставляем |
;scratched: ebx,ecx |
mov ecx, eax ; ecx=eax=Self, ebx=NewLeft |
xchg ecx, [ebx+EVENT.fd] ; NewLeft.fd=Self, ecx=NewRight |
cmp eax, ecx ; стоп, себе думаю... |
je .break ; - а не дурак ли я? |
mov [ecx+EVENT.bk], eax ; NewRight.bk=Self |
xchg ebx, [eax+EVENT.bk] ; Self.bk=NewLeft, ebx=OldLeft |
xchg ecx, [eax+EVENT.fd] ; Self.fd=NewRight, ecx=OldRight |
mov [ebx+EVENT.fd], ecx ; OldLeft.fd=OldRight |
mov [ecx+EVENT.bk], ebx ; OldRight.bk=OldLeft |
;-------------------------------------- |
align 4 |
.break: |
popfd |
ret |
;----------------------------------------------------------------------------- |
align 4 |
NotDummyTest: ;; INTERNAL use (not returned for fail !!!) |
pop edi |
call DummyTest ; not returned for fail !!! |
mov ebx, eax |
mov eax, [ebx+EVENT.pid] |
push edi |
;-------------------------------------- |
align 4 |
.small: ; криво как-то... |
pop edi |
pushfd |
cli |
call pid_to_slot ; saved all registers (eax - retval) |
shl eax, 8 |
jz RemoveEventTo.break ; POPF+RET |
jmp edi ; штатный возврат |
;----------------------------------------------------------------------------- |
align 4 |
raise_event: ;; EXPORT use |
;info: |
; Устанавливаем данные EVENT.code |
; Если там флаг EVENT_SIGNALED уже активен - больше ничего |
; Иначе: этот флаг взводится, за исключением случая наличия флага EVENT_WATCHED в edx |
; В этом случае EVENT_SIGNALED взводится лишь при наличие EVENT_WATCHED в самом событии |
;param: |
; eax - event |
; ebx - uid (for Dummy testing) |
; edx - flags |
; esi - event data (=0 => skip) |
;scratched: ebx,ecx,esi,edi |
call NotDummyTest ; not returned for fail !!! |
or esi, esi |
jz @f |
lea edi, [ebx+EVENT.code] |
mov ecx, (sizeof.EVENT -EVENT.code)/4 |
cld |
rep movsd |
;-------------------------------------- |
align 4 |
@@: |
test byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24 |
jnz RemoveEventTo.break ; POPF+RET |
bt edx, 28 ;EVENT_WATCHED |
jnc @f |
test byte[ebx+EVENT.state+3], EVENT_WATCHED shr 24 |
jz RemoveEventTo.break ; POPF+RET |
;-------------------------------------- |
align 4 |
@@: |
or byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24 |
add eax, SLOT_BASE+APP_EV_OFFSET |
xchg eax, ebx |
jmp RemoveEventTo |
;----------------------------------------------------------------------------- |
align 4 |
clear_event: ;; EXPORT use |
;info: |
; |
;param: |
; eax - event |
; ebx - uid (for Dummy testing) |
;scratched: ebx,ecx |
call NotDummyTest ; not returned for fail !!! |
add eax, SLOT_BASE+APP_OBJ_OFFSET |
and byte[ebx+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24) |
xchg eax, ebx |
jmp RemoveEventTo |
;----------------------------------------------------------------------------- |
align 4 |
send_event: ;; EXPORT use |
;info: |
; Создает новый EVENT (вытаскивает из списка FreeEvents) в списке EventList |
; целевого слота (eax=pid), с данными из esi косвенно, и state=EVENT_SIGNALED |
;param: |
; eax - slots pid, to sending new event |
; esi - pointer to sending data (in code field of new event) |
;retval: |
; eax - event (=0 => fail) |
; edx - uid |
;warning: |
; may be used as CDECL with such prefix... |
; mov esi,[esp+8] |
; mov eax,[esp+4] |
; but not as STDCALL :( |
;scratched: ebx,ecx,esi,edi |
mov edx, eax |
call NotDummyTest.small ; not returned for fail !!! |
lea ebx, [eax+SLOT_BASE+APP_EV_OFFSET] |
mov ecx, EVENT_SIGNALED |
jmp set_event |
;----------------------------------------------------------------------------- |
align 4 |
DummyTest: ;; INTERNAL use (not returned for fail !!!) |
;param: |
; eax - event |
; ebx - uid (for Dummy testing) |
cmp [eax+EVENT.magic], 'EVNT' |
jne @f |
cmp [eax+EVENT.id], ebx |
je .ret |
;-------------------------------------- |
align 4 |
@@: |
pop eax |
xor eax, eax |
;-------------------------------------- |
align 4 |
.ret: |
ret |
;----------------------------------------------------------------------------- |
align 4 |
Wait_events: |
or ebx, -1; infinite timeout |
;-------------------------------------- |
align 4 |
Wait_events_ex: |
;info: |
; Ожидание "абстрактного" события через перевод слота в 5-ю позицию. |
; Абстрактность заключена в том, что факт события определяется функцией APPDATA.wait_test, |
; которая задается клиентом и может быть фактически любой. |
; Это позволяет shed-у надежно определить факт события, и не совершать "холостых" переключений, |
; предназначенных для разборок типа "свой/чужой" внутри задачи. |
;param: |
; edx - wait_test, клиентская ф-я тестирования (адрес кода) |
; ecx - wait_param, дополнительный параметр, возможно необходимый для [wait_test] |
; ebx - wait_timeout |
;retval: |
; eax - результат вызова [wait_test] (=0 => timeout) |
;scratched: esi |
mov esi, [current_slot] |
mov [esi+APPDATA.wait_param], ecx |
pushad |
mov ebx, esi;пока это вопрос, чего куды сувать.......... |
pushfd ; это следствие общей концепции: пусть ф-я тестирования имеет |
cli ; право рассчитывать на закрытые прерывания, как при вызове из shed |
call edx |
popfd |
mov [esp+28], eax |
popad |
or eax, eax |
jnz @f ;RET |
mov [esi+APPDATA.wait_test], edx |
mov [esi+APPDATA.wait_timeout], ebx |
Mov [esi+APPDATA.wait_begin],eax,[timer_ticks] |
mov eax, [TASK_BASE] |
mov [eax+TASKDATA.state], 5 |
call change_task |
mov eax, [esi+APPDATA.wait_param] |
;-------------------------------------- |
align 4 |
@@: |
ret |
;----------------------------------------------------------------------------- |
align 4 |
wait_event: ;; EXPORT use |
;info: |
; Ожидание флага EVENT_SIGNALED в совершенно конкретном Event |
; (устанавливаемого, надо полагать, через raise_event) |
; При активном флаге MANUAL_RESET - больше ничего |
; Иначе: флаги EVENT_SIGNALED и EVENT_WATCHED у полученного события сбрасываются, |
; и, при активном MANUAL_DESTROY - перемещается в список ObjList текущего слота, |
; а при не активном - уничтожается штатно (destroy_event.internal) |
;param: |
; eax - event |
; ebx - uid (for Dummy testing) |
;scratched: ecx,edx,esi |
call DummyTest |
mov ecx, eax ; wait_param |
mov edx, get_event_alone ; wait_test |
call Wait_events ; timeout ignored |
jmp wait_finish |
;----------------------------------------------------------------------------- |
align 4 |
wait_event_timeout: |
;param: |
; eax - event |
; ebx - uid (for Dummy testing) |
; ecx - timeout in timer ticks |
;retval: |
; eax - EVENT handle or 0 if timeout |
call DummyTest |
mov ebx, ecx |
mov ecx, eax ; wait_param |
mov edx, get_event_alone ; wait_test |
call Wait_events_ex |
test eax, eax |
jnz wait_finish |
ret |
;----------------------------------------------------------------------------- |
align 4 |
get_event_ex: ;; f68:14 |
;info: |
; Ожидание любого события в очереди EventList текущего слота |
; Данные события code - копируются в память приложения (косвенно по edi) |
; При активном флаге MANUAL_RESET - больше ничего |
; Иначе: флаги EVENT_SIGNALED и EVENT_WATCHED у полученного события сбрасываются, |
; и, при активном MANUAL_DESTROY - перемещается в список ObjList текущего слота, |
; а при не активном - уничтожается штатно (destroy_event.internal) |
;param: |
; edi - адрес в коде приложения для копирования данных из EVENT.code |
;retval: |
; eax - собственно EVENT (будем называть это его хэндлом) |
;scratched: ebx,ecx,edx,esi,edi |
mov edx, get_event_queue ; wait_test |
call Wait_events ; timeout ignored |
lea esi, [eax+EVENT.code] |
mov ecx, (sizeof.EVENT-EVENT.code)/4 |
cld |
rep movsd |
mov byte[edi-(sizeof.EVENT-EVENT.code)+2], cl;clear priority field |
;-------------------------------------- |
align 4 |
wait_finish: |
test byte[eax+EVENT.state+3], MANUAL_RESET shr 24 |
jnz get_event_queue.ret ; RET |
and byte[eax+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24) |
test byte[eax+EVENT.state+3], MANUAL_DESTROY shr 24 |
jz destroy_event.internal |
mov ebx, [current_slot] |
add ebx, APP_OBJ_OFFSET |
pushfd |
cli |
jmp RemoveEventTo |
;----------------------------------------------------------------------------- |
align 4 |
destroy_event: ;; EXPORT use |
;info: |
; Переносим EVENT в список FreeEvents, чистим поля magic,destroy,pid,id |
;param: |
; eax - event |
; ebx - uid (for Dummy testing) |
;retval: |
; eax - адрес объекта EVENT (=0 => fail) |
;scratched: ebx,ecx |
call DummyTest ; not returned for fail !!! |
;-------------------------------------- |
align 4 |
.internal: |
xor ecx, ecx ; clear common header |
pushfd |
cli |
mov [eax+EVENT.magic], ecx |
mov [eax+EVENT.destroy], ecx |
mov [eax+EVENT.pid], ecx |
mov [eax+EVENT.id], ecx |
mov ebx, FreeEvents |
jmp RemoveEventTo |
;----------------------------------------------------------------------------- |
align 4 |
get_event_queue: |
;info: |
; клиентская ф-я тестирования для get_event_ex |
;warning: |
; -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot |
; -may be assumed, that interrupt are disabled |
; -it is not restriction for scratched registers |
;param: |
; ebx - адрес APPDATA слота тестирования |
;retval: |
; eax - адрес объекта EVENT (=0 => fail) |
add ebx, APP_EV_OFFSET |
mov eax, [ebx+APPOBJ.bk] ; выбираем с конца, по принципу FIFO |
cmp eax, ebx ; empty ??? |
je get_event_alone.ret0 |
;-------------------------------------- |
align 4 |
.ret: |
ret |
;----------------------------------------------------------------------------- |
align 4 |
get_event_alone: |
;info: |
; клиентская ф-я тестирования для wait_event |
;warning: |
; -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot |
; -may be assumed, that interrupt are disabled |
; -it is not restriction for scratched registers |
;param: |
; ebx - адрес APPDATA слота тестирования |
;retval: |
; eax - адрес объекта EVENT (=0 => fail) |
mov eax, [ebx+APPDATA.wait_param] |
test byte[eax+EVENT.state+3], EVENT_SIGNALED shr 24 |
jnz .ret |
or byte[eax+EVENT.state+3], EVENT_WATCHED shr 24 |
;-------------------------------------- |
align 4 |
.ret0: |
xor eax, eax; NO event!!! |
;-------------------------------------- |
align 4 |
.ret: |
ret |
;----------------------------------------------------------------------------- |
align 4 |
sys_sendwindowmsg: ;; f72 |
dec ebx |
jnz .ret ;subfunction==1 ? |
pushfd |
cli |
sub ecx, 2 |
je .sendkey |
dec ecx |
jnz .retf |
;-------------------------------------- |
align 4 |
.sendbtn: |
cmp byte[BTN_COUNT], 1 |
jae .result ;overflow |
inc byte[BTN_COUNT] |
shl edx, 8 |
mov [BTN_BUFF], edx |
jmp .result |
;-------------------------------------- |
align 4 |
.sendkey: |
movzx eax, byte[KEY_COUNT] |
cmp al, 120 |
jae .result ;overflow |
inc byte[KEY_COUNT] |
mov [KEY_COUNT+1+eax], dl |
;-------------------------------------- |
align 4 |
.result: |
setae byte[esp+32+4] ;считаем, что исходно: dword[esp+32+4]==72 |
;-------------------------------------- |
align 4 |
.retf: |
popfd |
;-------------------------------------- |
align 4 |
.ret: |
ret |
;----------------------------------------------------------------------------- |
align 4 |
sys_getevent: ;; f11 |
mov ebx, [current_slot];пока это вопрос, чего куды сувать.......... |
pushfd ; это следствие общей концепции: пусть ф-я тестирования имеет |
cli ; право рассчитывать на закрытые прерывания, как при вызове из shed |
call get_event_for_app |
popfd |
mov [esp+32], eax |
ret |
;----------------------------------------------------------------------------- |
align 4 |
sys_waitforevent: ;; f10 |
or ebx, -1; infinite timeout |
;-------------------------------------- |
align 4 |
sys_wait_event_timeout: ;; f23 |
call unprotect_from_terminate |
mov edx, get_event_for_app; wait_test |
call Wait_events_ex ; ebx - timeout |
mov [esp+32], eax |
call protect_from_terminate |
ret |
;----------------------------------------------------------------------------- |
align 4 |
get_event_for_app: ;; used from f10,f11,f23 |
;info: |
; клиентская ф-я тестирования для приложений (f10,f23) |
;warning: |
; -don't use [TASK_BASE],[current_slot],[CURRENT_TASK] - it is not for your slot |
; -may be assumed, that interrupt are disabled |
; -it is not restriction for scratched registers |
;param: |
; ebx - адрес APPDATA слота тестирования |
;retval: |
; eax - номер события (=0 => no events) |
movzx edi, bh ; bh is assumed as [CURRENT_TASK] |
shl edi, 5 |
add edi, CURRENT_TASK ; edi is assumed as [TASK_BASE] |
mov ecx, [edi+TASKDATA.event_mask] |
and ecx, 0x7FFFFFFF |
;-------------------------------------- |
align 4 |
.loop: ; пока не исчерпаем все биты маски |
bsr eax, ecx ; находим ненулевой бит маски (31 -> 0) |
jz .no_events ; исчерпали все биты маски, но ничего не нашли ??? |
btr ecx, eax ; сбрасываем проверяемый бит маски |
; переходим на обработчик этого (eax) бита |
cmp eax, 10 |
jae .loop ; eax=[10..31], ignored (event 11...32) |
cmp eax, 3 |
je .loop ; eax=3, ignored (event 4) |
cmp eax, 4 |
je .FlagAutoReset ; eax=4, retvals=eax+1 (event 5) |
cmp eax, 5 |
je .mouse_check ; eax=5, retvals=eax+1 (event 6) |
ja .FlagAutoReset ; eax=[6..9], retvals=eax+1 (event 7...10) |
cmp eax, 1 |
jae .BtKy ; eax=[1,2], retvals=eax+1 (event 2,3) |
;-------------------------------------- |
align 4 |
.WndRedraw: ; eax=0, retval WndRedraw=1 |
cmp [edi-twdw+WDATA.fl_redraw], al;al==0 |
jne .result |
jmp .loop |
;-------------------------------------- |
align 4 |
.no_events: |
xor eax, eax |
ret |
;-------------------------------------- |
align 4 |
.mouse_check: ; Mouse 5+1=6 |
push eax |
mov eax, [TASK_BASE] |
mov eax, [eax + TASKDATA.event_mask] |
test eax, 0x80000000 ; bit 31: active/inactive filter f.40 |
jz @f |
pop eax |
jmp .FlagAutoReset |
;-------------------------------------- |
align 4 |
@@: |
; If the window is captured and moved by the user, then no mouse events!!! |
mov al, [mouse.active_sys_window.action] |
and al, WINDOW_MOVE_AND_RESIZE_FLAGS |
test al, al |
pop eax |
jnz .loop |
;-------------------------------------- |
align 4 |
.FlagAutoReset: ; retvals: BgrRedraw=5, IPC=7, Stack=8, Debug=9 |
btr [ebx+APPDATA.event_mask], eax |
jnc .loop |
;-------------------------------------- |
align 4 |
.result: ; retval = eax+1 |
inc eax |
ret |
;-------------------------------------- |
align 4 |
.BtKy: |
movzx edx, bh |
movzx edx, word[WIN_STACK+edx*2] |
je .Keys ; eax=1, retval Keys=2 |
;-------------------------------------- |
align 4 |
.Buttons: ; eax=2, retval Buttons=3 |
cmp byte[BTN_COUNT], 0 |
je .loop ; empty ??? |
cmp edx, [TASK_COUNT] |
jne .loop ; not Top ??? |
mov edx, [BTN_BUFF] |
shr edx, 8 |
cmp edx, 0xFFFF ;-ID for Minimize-Button of Form |
jne .result |
mov [window_minimize], 1 |
call wakeup_osloop |
dec byte[BTN_COUNT] |
jmp .loop |
;-------------------------------------- |
align 4 |
.Keys: ; eax==1 |
cmp edx, [TASK_COUNT] |
jne @f ; not Top ??? |
cmp [KEY_COUNT], al; al==1 |
jae .result ; not empty ??? |
;-------------------------------------- |
align 4 |
@@: |
mov edx, hotkey_buffer |
;-------------------------------------- |
align 4 |
@@: |
cmp [edx], bh ; bh - slot for testing |
je .result |
add edx, 8 |
cmp edx, hotkey_buffer+120*8 |
jb @b |
jmp .loop |
;end. |
;----------------------------------------------------------------------------- |
/kernel/branches/kolibri-process/gui/font.inc |
---|
0,0 → 1,251 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3927 $ |
;------------------------------------------------------------------------------ |
align 4 |
dtext_asciiz_esi: ; for skins title out |
push eax |
xor eax, eax |
inc eax |
jmp dtext.1 |
;------------------------------------------------------------------------------ |
align 4 |
dtext: |
; ebx x & y |
; ecx style ( 0xX0000000 ) & color ( 0x00RRGGBB ) |
; X = ABnnb: |
; nn = font |
; A = 0 <=> output esi characters; otherwise output ASCIIZ string |
; B = 1 <=> fill background with color eax |
; edx start of text |
; edi 1 force or user area for redirect |
push eax |
xor eax, eax |
;-------------------------------------- |
align 4 |
.1: |
pushad |
movsx eax, bx ; eax=y |
sar ebx, 16 ; ebx=x |
xchg eax, ebx ; eax=x, ebx=y |
cmp esi, 255 |
jb .loop |
mov esi, 255 |
;-------------------------------------- |
align 4 |
.loop: |
test ecx, ecx |
js .test_asciiz |
dec esi |
js .end |
jmp @f |
;-------------------------------------- |
align 4 |
.test_asciiz: |
cmp byte [edx], 0 |
jz .end |
cmp byte [esp+28], 1 |
jne @f |
dec esi |
js .end |
;-------------------------------------- |
align 4 |
@@: |
inc edx |
pushad |
movzx edx, byte [edx-1] |
test ecx, 0x10000000 |
jnz .font2 |
mov esi, 9 |
lea ebp, [FONT_I+8*edx+edx] |
;-------------------------------------- |
align 4 |
.symloop1: |
mov dl, byte [ebp] |
or dl, 1 shl 6 |
;-------------------------------------- |
align 4 |
.pixloop1: |
shr dl, 1 |
jz .pixloop1end |
jnc .nopix |
test ecx, 0x08000000 ; redirect the output to the user area |
jz @f |
call draw_text_to_user_area |
jmp .pixloop1cont |
;-------------------------------------- |
align 4 |
@@: |
and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
; call [putpixel] |
call __sys_putpixel |
jmp .pixloop1cont |
;-------------------------------------- |
align 4 |
.nopix: |
test ecx, 0x40000000 |
jz .pixloop1cont |
push ecx |
mov ecx, [esp+4+20h+20h] |
test ecx, 0x08000000 ; redirect the output to the user area |
jz @f |
call draw_text_to_user_area |
pop ecx |
jmp .pixloop1cont |
;-------------------------------------- |
align 4 |
@@: |
and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
; call [putpixel] |
call __sys_putpixel |
pop ecx |
;-------------------------------------- |
align 4 |
.pixloop1cont: |
inc eax |
jmp .pixloop1 |
;-------------------------------------- |
align 4 |
.pixloop1end: |
sub eax, 6 |
inc ebx |
inc ebp |
dec esi |
jnz .symloop1 |
popad |
add eax, 6 |
jmp .loop |
;-------------------------------------- |
align 4 |
.font2: |
add edx, edx |
lea ebp, [FONT_II+4*edx+edx+1] |
push 9 |
movzx esi, byte [ebp-1] |
;-------------------------------------- |
align 4 |
.symloop2: |
mov dl, byte [ebp] |
push esi |
;-------------------------------------- |
align 4 |
.pixloop2: |
shr dl, 1 |
jnc .nopix2 |
test ecx, 0x08000000 ; redirect the output to the user area |
jz @f |
call draw_text_to_user_area |
jmp .pixloop2cont |
;-------------------------------------- |
align 4 |
@@: |
and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
; call [putpixel] |
call __sys_putpixel |
jmp .pixloop2cont |
;-------------------------------------- |
align 4 |
.nopix2: |
test ecx, 0x40000000 |
jz .pixloop2cont |
push ecx |
mov ecx, [esp+12+20h+20h] |
test ecx, 0x08000000 ; redirect the output to the user area |
jz @f |
call draw_text_to_user_area |
pop ecx |
jmp .pixloop2cont |
;-------------------------------------- |
align 4 |
@@: |
and ecx, 0xFBFFFFFF ;negate 0x04000000 save to mouseunder area |
; call [putpixel] |
call __sys_putpixel |
pop ecx |
;-------------------------------------- |
align 4 |
.pixloop2cont: |
inc eax |
dec esi |
jnz .pixloop2 |
pop esi |
sub eax, esi |
inc ebx |
inc ebp |
dec dword [esp] |
jnz .symloop2 |
pop eax |
add dword [esp+28], esi |
popad |
jmp .loop |
;-------------------------------------- |
align 4 |
.end: |
popad |
pop eax |
ret |
;------------------------------------------------------------------------------ |
; eax = x coordinate |
; ebx = y coordinate |
; ecx = ?? RR GG BB |
; edi = user area |
align 4 |
draw_text_to_user_area: |
pushad |
imul ebx, [edi+0] |
add eax, ebx |
shl eax, 2 |
add eax, edi |
add eax, 8 |
and ecx, 0xffffff |
or ecx, 0xff000000 ; not transparent |
mov [eax], ecx ; store pixel |
popad |
ret |
;------------------------------------------------------------------------------ |
align 4 |
FONT_I: |
if lang eq sp |
file 'char_sp.mt' |
else if lang eq et |
file 'char_et.mt' |
else |
file 'char.mt' |
end if |
;------------------------------------------------------------------------------ |
align 4 |
FONT_II: |
if lang eq sp |
file 'char2_sp.mt' |
else if lang eq et |
file 'char2_et.mt' |
else |
file 'char2.mt' |
end if |
;------------------------------------------------------------------------------ |
/kernel/branches/kolibri-process/gui/mouse.inc |
---|
0,0 → 1,711 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2010-2012. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 4424 $ |
include 'mousepointer.inc' |
;============================================================================== |
;///// public functions /////////////////////////////////////////////////////// |
;============================================================================== |
mouse.LEFT_BUTTON_FLAG = 0001b |
mouse.RIGHT_BUTTON_FLAG = 0010b |
mouse.MIDDLE_BUTTON_FLAG = 0100b |
mouse.BUTTONS_MASK = \ |
mouse.LEFT_BUTTON_FLAG or \ |
mouse.RIGHT_BUTTON_FLAG or \ |
mouse.MIDDLE_BUTTON_FLAG |
mouse.WINDOW_RESIZE_N_FLAG = 000001b |
mouse.WINDOW_RESIZE_W_FLAG = 000010b |
mouse.WINDOW_RESIZE_S_FLAG = 000100b |
mouse.WINDOW_RESIZE_E_FLAG = 001000b |
mouse.WINDOW_MOVE_FLAG = 010000b |
mouse.WINDOW_RESIZE_SW_FLAG = \ |
mouse.WINDOW_RESIZE_S_FLAG or \ |
mouse.WINDOW_RESIZE_W_FLAG |
mouse.WINDOW_RESIZE_SE_FLAG = \ |
mouse.WINDOW_RESIZE_S_FLAG or \ |
mouse.WINDOW_RESIZE_E_FLAG |
align 4 |
;------------------------------------------------------------------------------ |
mouse_check_events: ;////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Check if mouse buttons state or cursor position has changed and call |
;? appropriate handlers |
;------------------------------------------------------------------------------ |
push eax ebx |
mov al, [BTN_DOWN] |
mov bl, [mouse.state.buttons] |
and al, mouse.BUTTONS_MASK |
mov cl, al |
xchg cl, [mouse.state.buttons] |
xor bl, al |
push eax ebx |
; did any mouse button changed its state? |
or bl, bl |
jz .check_position |
; yes it did, is that the first button of all pressed down? |
or cl, cl |
jnz .check_buttons_released |
; yes it is, activate window user is pointing at, if needed |
call mouse._.activate_sys_window_under_cursor |
; NOTE: this code wouldn't be necessary if we knew window did |
; already redraw itself after call above |
or eax, eax |
jnz .exit |
; is there any system button under cursor? |
call mouse._.find_sys_button_under_cursor |
or eax, eax |
jz .check_buttons_released |
; yes there is, activate it and exit |
mov [mouse.active_sys_button.pbid], eax |
mov [mouse.active_sys_button.coord], ebx |
mov cl, [mouse.state.buttons] |
mov [mouse.active_sys_button.buttons], cl |
call sys_button_activate_handler |
jmp .exit |
.check_buttons_released: |
cmp [mouse.state.buttons], 0 |
jnz .buttons_changed |
; did we press some button earlier? |
cmp [mouse.active_sys_button.pbid], 0 |
je .buttons_changed |
; yes we did, deactivate it |
xor eax, eax |
xchg eax, [mouse.active_sys_button.pbid] |
mov ebx, [mouse.active_sys_button.coord] |
mov cl, [mouse.active_sys_button.buttons] |
push eax ebx |
call sys_button_deactivate_handler |
pop edx ecx |
; is the button under cursor the one we deactivated? |
call mouse._.find_sys_button_under_cursor |
cmp eax, ecx |
jne .exit |
cmp ebx, edx |
jne .exit |
; yes it is, perform associated action |
mov cl, [mouse.active_sys_button.buttons] |
call sys_button_perform_handler |
jmp .exit |
.buttons_changed: |
test byte[esp], mouse.LEFT_BUTTON_FLAG |
jz @f |
mov eax, [esp + 4] |
call .call_left_button_handler |
@@: |
test byte[esp], mouse.RIGHT_BUTTON_FLAG |
jz @f |
mov eax, [esp + 4] |
call .call_right_button_handler |
@@: |
test byte[esp], mouse.MIDDLE_BUTTON_FLAG |
jz .check_position |
mov eax, [esp + 4] |
call .call_middle_button_handler |
.check_position: |
movzx eax, word[MOUSE_X] |
movzx ebx, word[MOUSE_Y] |
cmp eax, [mouse.state.pos.x] |
jne .position_changed |
cmp ebx, [mouse.state.pos.y] |
je .exit |
.position_changed: |
xchg eax, [mouse.state.pos.x] |
xchg ebx, [mouse.state.pos.y] |
call mouse._.move_handler |
.exit: |
add esp, 8 |
pop ebx eax |
ret |
.call_left_button_handler: |
test eax, mouse.LEFT_BUTTON_FLAG |
jnz mouse._.left_button_press_handler |
jmp mouse._.left_button_release_handler |
.call_right_button_handler: |
test eax, mouse.RIGHT_BUTTON_FLAG |
jnz mouse._.right_button_press_handler |
jmp mouse._.right_button_release_handler |
.call_middle_button_handler: |
test eax, mouse.MIDDLE_BUTTON_FLAG |
jnz mouse._.middle_button_press_handler |
jmp mouse._.middle_button_release_handler |
;============================================================================== |
;///// private functions ////////////////////////////////////////////////////// |
;============================================================================== |
uglobal |
mouse.state: |
.pos POINT |
.buttons db ? |
; NOTE: since there's no unique and lifetime-constant button identifiers, |
; we're using two dwords to identify each of them: |
; * pbid - process slot (high 8 bits) and button id (low 24 bits) pack |
; * coord - left (high 16 bits) and top (low 16 bits) coordinates pack |
align 4 |
mouse.active_sys_button: |
.pbid dd ? |
.coord dd ? |
.buttons db ? |
align 4 |
mouse.active_sys_window: |
.pslot dd ? |
.old_box BOX |
.new_box BOX |
.delta POINT |
.last_ticks dd ? |
.action db ? |
endg |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.left_button_press_handler: ;/////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when left mouse button has been pressed down |
;------------------------------------------------------------------------------ |
test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG |
jnz .exit |
call mouse._.find_sys_window_under_cursor |
call mouse._.check_sys_window_actions |
mov [mouse.active_sys_window.action], al |
or eax, eax |
jz .exit |
xchg eax, edx |
test dl, mouse.WINDOW_MOVE_FLAG |
jz @f |
mov eax, [timer_ticks] |
mov ebx, eax |
xchg ebx, [mouse.active_sys_window.last_ticks] |
sub eax, ebx |
cmp eax, 50 |
jg @f |
mov [mouse.active_sys_window.last_ticks], 0 |
call sys_window_maximize_handler |
jmp .exit |
@@: |
test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED |
jnz .exit |
mov [mouse.active_sys_window.pslot], esi |
lea eax, [edi + WDATA.box] |
mov ebx, mouse.active_sys_window.old_box |
mov ecx, sizeof.BOX |
call memmove |
mov ebx, mouse.active_sys_window.new_box |
call memmove |
test edx, mouse.WINDOW_MOVE_FLAG |
jz @f |
call .calculate_n_delta |
call .calculate_w_delta |
jmp .call_window_handler |
@@: |
test dl, mouse.WINDOW_RESIZE_W_FLAG |
jz @f |
call .calculate_w_delta |
@@: |
test dl, mouse.WINDOW_RESIZE_S_FLAG |
jz @f |
call .calculate_s_delta |
@@: |
test dl, mouse.WINDOW_RESIZE_E_FLAG |
jz .call_window_handler |
call .calculate_e_delta |
.call_window_handler: |
; mov eax, mouse.active_sys_window.old_box |
; call sys_window_start_moving_handler |
.exit: |
ret |
.calculate_n_delta: |
mov eax, [mouse.state.pos.y] |
sub eax, [mouse.active_sys_window.old_box.top] |
mov [mouse.active_sys_window.delta.y], eax |
ret |
.calculate_w_delta: |
mov eax, [mouse.state.pos.x] |
sub eax, [mouse.active_sys_window.old_box.left] |
mov [mouse.active_sys_window.delta.x], eax |
ret |
.calculate_s_delta: |
mov eax, [mouse.active_sys_window.old_box.top] |
add eax, [mouse.active_sys_window.old_box.height] |
sub eax, [mouse.state.pos.y] |
mov [mouse.active_sys_window.delta.y], eax |
ret |
.calculate_e_delta: |
mov eax, [mouse.active_sys_window.old_box.left] |
add eax, [mouse.active_sys_window.old_box.width] |
sub eax, [mouse.state.pos.x] |
mov [mouse.active_sys_window.delta.x], eax |
ret |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.left_button_release_handler: ;///////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when left mouse button has been released |
;------------------------------------------------------------------------------ |
xor esi, esi |
xchg esi, [mouse.active_sys_window.pslot] |
or esi, esi |
jz .exit |
mov eax, esi |
shl eax, 5 |
add eax, window_data + WDATA.box |
mov ebx, mouse.active_sys_window.old_box |
mov ecx, sizeof.BOX |
call memmove |
mov eax, mouse.active_sys_window.old_box |
mov ebx, mouse.active_sys_window.new_box |
call sys_window_end_moving_handler |
.exit: |
and [mouse.active_sys_window.action], 0 |
ret |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.right_button_press_handler: ;////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when right mouse button has been pressed down |
;------------------------------------------------------------------------------ |
test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG |
jnz .exit |
call mouse._.find_sys_window_under_cursor |
call mouse._.check_sys_window_actions |
test al, mouse.WINDOW_MOVE_FLAG |
jz .exit |
call sys_window_rollup_handler |
.exit: |
ret |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.right_button_release_handler: ;//////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when right mouse button has been released |
;------------------------------------------------------------------------------ |
ret |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.middle_button_press_handler: ;///////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when middle mouse button has been pressed down |
;------------------------------------------------------------------------------ |
ret |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.middle_button_release_handler: ;/////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when middle mouse button has been released |
;------------------------------------------------------------------------------ |
ret |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.move_handler: ;//////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Called when cursor has been moved |
;------------------------------------------------------------------------------ |
;> eax = old x coord |
;> ebx = old y coord |
;------------------------------------------------------------------------------ |
cmp [mouse.active_sys_button.pbid], 0 |
jnz .exit |
mov esi, [mouse.active_sys_window.pslot] |
or esi, esi |
jz .exit |
mov eax, mouse.active_sys_window.new_box |
mov ebx, mouse.active_sys_window.old_box |
mov ecx, sizeof.BOX |
call memmove |
mov dl, [mouse.active_sys_window.action] |
test dl, mouse.WINDOW_MOVE_FLAG |
jz .check_resize_w |
mov eax, [mouse.state.pos.x] |
sub eax, [mouse.active_sys_window.delta.x] |
mov [mouse.active_sys_window.new_box.left], eax |
mov eax, [mouse.state.pos.y] |
sub eax, [mouse.active_sys_window.delta.y] |
mov [mouse.active_sys_window.new_box.top], eax |
mov eax, [mouse.active_sys_window.new_box.left] |
or eax, eax |
jge @f |
xor eax, eax |
mov [mouse.active_sys_window.new_box.left], eax |
@@: |
add eax, [mouse.active_sys_window.new_box.width] |
cmp eax, [Screen_Max_X] |
jl @f |
sub eax, [Screen_Max_X] |
sub [mouse.active_sys_window.new_box.left], eax |
@@: |
mov eax, [mouse.active_sys_window.new_box.top] |
or eax, eax |
jge @f |
xor eax, eax |
mov [mouse.active_sys_window.new_box.top], eax |
@@: |
add eax, [mouse.active_sys_window.new_box.height] |
cmp eax, [Screen_Max_Y] |
jle .call_window_handler |
sub eax, [Screen_Max_Y] |
sub [mouse.active_sys_window.new_box.top], eax |
jmp .call_window_handler |
.check_resize_w: |
test dl, mouse.WINDOW_RESIZE_W_FLAG |
jz .check_resize_s |
mov eax, [mouse.state.pos.x] |
sub eax, [mouse.active_sys_window.delta.x] |
mov [mouse.active_sys_window.new_box.left], eax |
sub eax, [mouse.active_sys_window.old_box.left] |
sub [mouse.active_sys_window.new_box.width], eax |
mov eax, [mouse.active_sys_window.new_box.width] |
sub eax, 127 |
jge @f |
add [mouse.active_sys_window.new_box.left], eax |
mov [mouse.active_sys_window.new_box.width], 127 |
@@: |
mov eax, [mouse.active_sys_window.new_box.left] |
or eax, eax |
jge .check_resize_s |
add [mouse.active_sys_window.new_box.width], eax |
xor eax, eax |
mov [mouse.active_sys_window.new_box.left], eax |
.check_resize_s: |
test dl, mouse.WINDOW_RESIZE_S_FLAG |
jz .check_resize_e |
mov eax, [mouse.state.pos.y] |
add eax, [mouse.active_sys_window.delta.y] |
sub eax, [mouse.active_sys_window.old_box.top] |
mov [mouse.active_sys_window.new_box.height], eax |
push eax |
mov edi, esi |
shl edi, 5 |
add edi, window_data |
call window._.get_rolledup_height |
mov ecx, eax |
pop eax |
mov eax, [mouse.active_sys_window.new_box.height] |
cmp eax, ecx |
jge @f |
mov eax, ecx |
mov [mouse.active_sys_window.new_box.height], eax |
@@: |
add eax, [mouse.active_sys_window.new_box.top] |
cmp eax, [Screen_Max_Y] |
jle .check_resize_e |
sub eax, [Screen_Max_Y] |
neg eax |
add [mouse.active_sys_window.new_box.height], eax |
mov ecx, [Screen_Max_Y] |
cmp ecx, eax |
jge .check_resize_e |
mov [mouse.active_sys_window.new_box.height], ecx |
.check_resize_e: |
test dl, mouse.WINDOW_RESIZE_E_FLAG |
jz .call_window_handler |
mov eax, [mouse.state.pos.x] |
add eax, [mouse.active_sys_window.delta.x] |
sub eax, [mouse.active_sys_window.old_box.left] |
mov [mouse.active_sys_window.new_box.width], eax |
mov eax, [mouse.active_sys_window.new_box.width] |
cmp eax, 127 |
jge @f |
mov eax, 127 |
mov [mouse.active_sys_window.new_box.width], eax |
@@: |
add eax, [mouse.active_sys_window.new_box.left] |
cmp eax, [Screen_Max_X] |
jle .call_window_handler |
sub eax, [Screen_Max_X] |
neg eax |
add [mouse.active_sys_window.new_box.width], eax |
mov ecx, [Screen_Max_X] |
cmp ecx, eax |
jge .call_window_handler |
mov [mouse.active_sys_window.new_box.width], ecx |
.call_window_handler: |
mov eax, mouse.active_sys_window.old_box |
mov ebx, mouse.active_sys_window.new_box |
push esi |
mov esi, mouse.active_sys_window.old_box |
mov edi, mouse.active_sys_window.new_box |
mov ecx, sizeof.BOX / 4 |
repe |
cmpsd |
pop esi |
je .exit |
mov [mouse.active_sys_window.last_ticks], 0 |
call sys_window_moving_handler |
.exit: |
ret |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.find_sys_window_under_cursor: ;//////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Find system window object which is currently visible on screen and has |
;? mouse cursor within its bounds |
;------------------------------------------------------------------------------ |
;< esi = process slot |
;< edi = pointer to WDATA struct |
;------------------------------------------------------------------------------ |
mov esi, [mouse.state.pos.y] |
mov esi, [d_width_calc_area + esi*4] |
add esi, [_WinMapAddress] |
add esi, [mouse.state.pos.x] |
movzx esi, byte[esi] |
mov edi, esi |
shl edi, 5 |
add edi, window_data |
ret |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.activate_sys_window_under_cursor: ;//////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
; activate and redraw window under cursor (if necessary) |
call mouse._.find_sys_window_under_cursor |
movzx esi, word[WIN_STACK + esi * 2] |
lea esi, [WIN_POS + esi * 2] |
jmp waredraw |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.find_sys_button_under_cursor: ;//////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Find system button object which is currently visible on screen and has |
;? mouse cursor within its bounds |
;------------------------------------------------------------------------------ |
;< eax = pack[8(process slot), 24(button id)] or 0 |
;< ebx = pack[16(button x coord), 16(button y coord)] |
;------------------------------------------------------------------------------ |
push ecx edx esi edi |
call mouse._.find_sys_window_under_cursor |
mov edx, esi |
; check if any process button contains cursor |
mov eax, [BTN_ADDR] |
mov ecx, [eax] |
imul esi, ecx, sizeof.SYS_BUTTON |
add esi, eax |
inc ecx |
add esi, sizeof.SYS_BUTTON |
.next_button: |
dec ecx |
jz .not_found |
add esi, -sizeof.SYS_BUTTON |
; does it belong to our process? |
cmp dx, [esi + SYS_BUTTON.pslot] |
jne .next_button |
; does it contain cursor coordinates? |
mov eax, [mouse.state.pos.x] |
sub eax, [edi + WDATA.box.left] |
sub ax, [esi + SYS_BUTTON.left] |
jl .next_button |
sub ax, [esi + SYS_BUTTON.width] |
jge .next_button |
mov eax, [mouse.state.pos.y] |
sub eax, [edi + WDATA.box.top] |
sub ax, [esi + SYS_BUTTON.top] |
jl .next_button |
sub ax, [esi + SYS_BUTTON.height] |
jge .next_button |
; okay, return it |
shl edx, 24 |
mov eax, dword[esi + SYS_BUTTON.id_hi - 2] |
mov ax, [esi + SYS_BUTTON.id_lo] |
and eax, 0x0ffffff |
or eax, edx |
mov ebx, dword[esi + SYS_BUTTON.left - 2] |
mov bx, [esi + SYS_BUTTON.top] |
jmp .exit |
.not_found: |
xor eax, eax |
xor ebx, ebx |
.exit: |
pop edi esi edx ecx |
ret |
align 4 |
;------------------------------------------------------------------------------ |
mouse._.check_sys_window_actions: ;//////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;< eax = action flags or 0 |
;------------------------------------------------------------------------------ |
; is window movable? |
test byte[edi + WDATA.cl_titlebar + 3], 0x01 |
jnz .no_action |
mov eax, [mouse.state.pos.x] |
mov ebx, [mouse.state.pos.y] |
sub eax, [edi + WDATA.box.left] |
sub ebx, [edi + WDATA.box.top] |
; is there a window titlebar under cursor? |
push eax |
call window._.get_titlebar_height |
cmp ebx, eax |
pop eax |
jl .move_action |
; no there isn't, can it be resized then? |
mov dl, [edi + WDATA.fl_wstyle] |
and dl, 0x0f |
; NOTE: dangerous optimization, revise if window types changed; |
; this currently implies only types 2 and 3 could be resized |
test dl, 2 |
jz .no_action |
mov ecx, [edi + WDATA.box.width] |
add ecx, -window.BORDER_SIZE |
mov edx, [edi + WDATA.box.height] |
add edx, -window.BORDER_SIZE |
; is it rolled up? |
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP |
jnz .resize_w_or_e_action |
cmp eax, window.BORDER_SIZE |
jl .resize_w_action |
cmp eax, ecx |
jg .resize_e_action |
cmp ebx, edx |
jle .no_action |
.resize_s_action: |
cmp eax, window.BORDER_SIZE + 10 |
jl .resize_sw_action |
add ecx, -10 |
cmp eax, ecx |
jge .resize_se_action |
mov eax, mouse.WINDOW_RESIZE_S_FLAG |
jmp .exit |
.resize_w_or_e_action: |
cmp eax, window.BORDER_SIZE + 10 |
jl .resize_w_action.direct |
add ecx, -10 |
cmp eax, ecx |
jg .resize_e_action.direct |
jmp .no_action |
.resize_w_action: |
add edx, -10 |
cmp ebx, edx |
jge .resize_sw_action |
.resize_w_action.direct: |
mov eax, mouse.WINDOW_RESIZE_W_FLAG |
jmp .exit |
.resize_e_action: |
add edx, -10 |
cmp ebx, edx |
jge .resize_se_action |
.resize_e_action.direct: |
mov eax, mouse.WINDOW_RESIZE_E_FLAG |
jmp .exit |
.resize_sw_action: |
mov eax, mouse.WINDOW_RESIZE_SW_FLAG |
jmp .exit |
.resize_se_action: |
mov eax, mouse.WINDOW_RESIZE_SE_FLAG |
jmp .exit |
.move_action: |
mov eax, mouse.WINDOW_MOVE_FLAG |
jmp .exit |
.no_action: |
xor eax, eax |
.exit: |
ret |
/kernel/branches/kolibri-process/gui/mousepointer.inc |
---|
0,0 → 1,250 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;; |
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
;; Distributed under terms of the GNU General Public License ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 2455 $ |
iglobal |
align 4 |
mousepointer: |
db 0x00,0x00,0x00,0x74,0x74,0x74,0x6e,0x6e,0x6e,0x6f |
db 0x6f,0x6f,0x71,0x71,0x71,0x75,0x75,0x75,0x79,0x79 |
db 0x79,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80,0x80 |
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 |
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 |
db 0x80,0x00,0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63 |
db 0x66,0x66,0x66,0x6c,0x6c,0x6c,0x72,0x72,0x72,0x78 |
db 0x78,0x78,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80 |
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 |
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0 |
db 0xc0,0xc0,0x00,0x00,0x00,0x54,0x54,0x54,0x57,0x57 |
db 0x57,0x5f,0x5f,0x5f,0x68,0x68,0x68,0x71,0x71,0x71 |
db 0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80 |
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 |
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0xc0,0xc0 |
db 0xc0,0xc0,0xc0,0x00,0x00,0x00,0x47,0x47,0x47,0x50 |
db 0x50,0x50,0x5b,0x5b,0x5b,0x67,0x67,0x67,0x70,0x70 |
db 0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e |
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 |
db 0x80,0x80,0x80,0x80,0x80,0xff,0xff,0xff,0xc0,0xc0 |
db 0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x3f,0x3f,0x3f |
db 0x4b,0x4b,0x4b,0x59,0x59,0x59,0x66,0x66,0x66,0x70 |
db 0x70,0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e |
db 0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 |
db 0x80,0x80,0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0 |
db 0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x3a,0x3a |
db 0x3a,0x49,0x49,0x49,0x59,0x59,0x59,0x66,0x66,0x66 |
db 0x70,0x70,0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e |
db 0x7e,0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 |
db 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0 |
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x39 |
db 0x39,0x39,0x49,0x49,0x49,0x59,0x59,0x59,0x66,0x66 |
db 0x66,0x71,0x71,0x71,0x78,0x78,0x78,0x7c,0x7c,0x7c |
db 0x7e,0x7e,0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0 |
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00 |
db 0x39,0x39,0x39,0x4a,0x4a,0x4a,0x5a,0x5a,0x5a,0x68 |
db 0x68,0x68,0x72,0x72,0x72,0x79,0x79,0x79,0x7d,0x7d |
db 0x7d,0x7f,0x7f,0x7f,0x80,0x80,0x80,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0 |
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00 |
db 0x00,0x3c,0x3c,0x3c,0x4e,0x4e,0x4e,0x5e,0x5e,0x5e |
db 0x6b,0x6b,0x6b,0x75,0x75,0x75,0x7a,0x7a,0x7a,0x7e |
db 0x7e,0x7e,0x80,0x80,0x80,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0 |
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00 |
db 0x00,0x00,0x43,0x43,0x43,0x55,0x55,0x55,0x64,0x64 |
db 0x64,0x70,0x70,0x70,0x78,0x78,0x78,0x7d,0x7d,0x7d |
db 0x80,0x80,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xc0 |
db 0xc0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x4e,0x4e,0x4e,0x5f,0x5f,0x5f,0x6d |
db 0x6d,0x6d,0x76,0x76,0x76,0x7c,0x7c,0x7c,0x80,0x80 |
db 0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00 |
db 0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x14 |
db 0x14,0x14,0x1b,0x1b,0x1b,0x29,0x29,0x29,0x3a,0x3a |
db 0x3a,0x4c,0x4c,0x4c,0x5d,0x5d,0x5d,0x6c,0x6c,0x6c |
db 0x75,0x75,0x75,0x7b,0x7b,0x7b,0x80,0x80,0x80,0xc0 |
db 0xc0,0xc0,0x00,0x00,0x00,0x2f,0x2f,0x2f,0x80,0x80 |
db 0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00 |
db 0x21,0x21,0x21,0x2e,0x2e,0x2e,0x40,0x40,0x40,0x52 |
db 0x52,0x52,0x62,0x62,0x62,0x6f,0x6f,0x6f,0x77,0x77 |
db 0x77,0x7c,0x7c,0x7c,0x80,0x80,0x80,0x00,0x00,0x00 |
db 0x47,0x47,0x47,0x3b,0x3b,0x3b,0x80,0x80,0x80,0xff |
db 0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x25,0x25 |
db 0x25,0x30,0x30,0x30,0x42,0x42,0x42,0x54,0x54,0x54 |
db 0x64,0x64,0x64,0x70,0x70,0x70,0x78,0x78,0x78,0x7d |
db 0x7d,0x7d,0x00,0x00,0x00,0x62,0x62,0x62,0x52,0x52 |
db 0x52,0x4a,0x4a,0x4a,0x43,0x43,0x43,0x80,0x80,0x80 |
db 0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x33 |
db 0x33,0x33,0x42,0x42,0x42,0x54,0x54,0x54,0x64,0x64 |
db 0x64,0x71,0x71,0x71,0x79,0x79,0x79,0x7d,0x7d,0x7d |
db 0x72,0x72,0x72,0x6b,0x6b,0x6b,0x5f,0x5f,0x5f,0x5a |
db 0x5a,0x5a,0x54,0x54,0x54,0x80,0x80,0x80,0xff,0xff |
db 0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x35,0x35,0x35 |
db 0x41,0x41,0x41,0x53,0x53,0x53,0x63,0x63,0x63,0x70 |
db 0x70,0x70,0x78,0x78,0x78,0x7d,0x7d,0x7d,0x77,0x77 |
db 0x77,0x73,0x73,0x73,0x6c,0x6c,0x6c,0x68,0x68,0x68 |
db 0x62,0x62,0x62,0x5a,0x5a,0x5a,0x80,0x80,0x80,0xff |
db 0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x41,0x41 |
db 0x41,0x52,0x52,0x52,0x62,0x62,0x62,0x6f,0x6f,0x6f |
db 0x78,0x78,0x78,0x7d,0x7d,0x7d,0x7b,0x7b,0x7b,0x79 |
db 0x79,0x79,0x74,0x74,0x74,0x72,0x72,0x72,0x6e,0x6e |
db 0x6e,0x66,0x66,0x66,0x80,0x80,0x80,0xc0,0xc0,0xc0 |
db 0xc0,0xc0,0xc0,0x00,0x00,0x00,0x44,0x44,0x44,0x52 |
db 0x52,0x52,0x62,0x62,0x62,0x6e,0x6e,0x6e,0x77,0x77 |
db 0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x7c,0x7c,0x7c |
db 0x7a,0x7a,0x7a,0x79,0x79,0x79,0x75,0x75,0x75,0x6f |
db 0x6f,0x6f,0x65,0x65,0x65,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x48,0x48,0x48,0x4b,0x4b,0x4b,0x56,0x56,0x56 |
db 0x65,0x65,0x65,0x70,0x70,0x70,0x78,0x78,0x78,0x7d |
db 0x7d,0x7d,0x80,0x80,0x80,0x7f,0x7f,0x7f,0x7e,0x7e |
db 0x7e,0x7d,0x7d,0x7d,0x7a,0x7a,0x7a,0x76,0x76,0x76 |
db 0x6f,0x6f,0x6f,0x65,0x65,0x65,0x5c,0x5c,0x5c,0x56 |
db 0x56,0x56,0x58,0x58,0x58,0x60,0x60,0x60,0x6b,0x6b |
db 0x6b,0x73,0x73,0x73,0x7a,0x7a,0x7a,0x7d,0x7d,0x7d |
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x7f |
db 0x7f,0x7f,0x7d,0x7d,0x7d,0x7a,0x7a,0x7a,0x76,0x76 |
db 0x76,0x70,0x70,0x70,0x6a,0x6a,0x6a,0x66,0x66,0x66 |
db 0x66,0x66,0x66,0x6c,0x6c,0x6c,0x72,0x72,0x72,0x78 |
db 0x78,0x78,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80 |
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 |
db 0x7f,0x7f,0x7f,0x7d,0x7d,0x7d,0x7b,0x7b,0x7b,0x77 |
db 0x77,0x77,0x73,0x73,0x73,0x71,0x71,0x71,0x71,0x71 |
db 0x71,0x74,0x74,0x74,0x78,0x78,0x78,0x7b,0x7b,0x7b |
db 0x7d,0x7d,0x7d,0x7f,0x7f,0x7f,0x80,0x80,0x80,0x80 |
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 |
db 0x80,0x7f,0x7f,0x7f,0x7d,0x7d,0x7d,0x7c,0x7c,0x7c |
db 0x7a,0x7a,0x7a,0x78,0x78,0x78,0x78,0x78,0x78,0x7a |
db 0x7a,0x7a,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x7f,0x7f |
db 0x7f,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 |
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 |
db 0x80,0x80,0x7f,0x7f,0x7f,0x7e,0x7e,0x7e,0x7e,0x7e |
db 0x7e,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e |
db 0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x80,0x80,0x80,0x80 |
db 0x80,0x80 |
mousepointer1: |
db 0xff,0xff,0xff,0x06,0x06,0x06,0x0a,0x0a |
db 0x0a,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0xff,0xff,0xff,0xff,0xff,0xff,0x19,0x19,0x19,0x16 |
db 0x16,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x2e,0x2e,0x2e |
db 0x23,0x23,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f |
db 0x3f,0x29,0x29,0x29,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x47 |
db 0x47,0x47,0x2c,0x2c,0x2c,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0x48,0x48,0x48,0x2c,0x2c,0x2c,0x16,0x16,0x16,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x16,0x16,0x16 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0x47,0x47,0x47,0x29,0x29,0x29 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0x40,0x40,0x40,0x23,0x23 |
db 0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xaa,0xaa,0xaa,0x9f,0x9f,0x9f,0x8c,0x8c,0x8c |
db 0x70,0x70,0x70,0x4f,0x4f,0x4f,0x30,0x30,0x30,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x8f,0x8f,0x8f |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0xff,0x9c,0x9c,0x9c,0x87,0x87,0x87,0x6c,0x6c |
db 0x6c,0x4f,0x4f,0x4f,0x32,0x32,0x32,0x19,0x19,0x19 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff |
db 0xff,0xff,0x69,0x69,0x69,0x84,0x84,0x84,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0x92,0x92,0x92,0x79,0x79,0x79,0x59,0x59,0x59,0x3c |
db 0x3c,0x3c,0x24,0x24,0x24,0x11,0x11,0x11,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x37,0x37,0x37 |
db 0x5d,0x5d,0x5d,0x70,0x70,0x70,0x76,0x76,0x76,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0xff,0x75,0x75,0x75,0x51,0x51,0x51,0x31,0x31,0x31 |
db 0x19,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x16,0x16,0x16,0x2d,0x2d,0x2d,0x49,0x49 |
db 0x49,0x53,0x53,0x53,0x54,0x54,0x54,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x78 |
db 0x78,0x78,0x54,0x54,0x54,0x30,0x30,0x30,0x16,0x16 |
db 0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x0f,0x0f,0x0f,0x1f,0x1f,0x1f,0x30,0x30,0x30,0x33 |
db 0x33,0x33,0x33,0x33,0x33,0x3b,0x3b,0x3b,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff |
db 0x62,0x62,0x62,0x3b,0x3b,0x3b,0x1c,0x1c,0x1c,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08 |
db 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x24,0x24,0x24,0xff,0xff,0xff,0xff |
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x6e,0x6e |
db 0x6e,0x48,0x48,0x48,0x25,0x25,0x25,0x0e,0x0e,0x0e |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00 |
db 0x00,0x00,0x0a,0x0a,0x0a,0x09,0x09,0x09,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x29,0x29,0x29,0xff,0xff,0xff |
db 0xff,0xff,0xff,0x7c,0x7c,0x7c,0x71,0x71,0x71,0x50 |
db 0x50,0x50,0x2b,0x2b,0x2b,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x02,0x02,0x02,0x04,0x04,0x04,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x36,0x56,0x56 |
db 0x56,0x69,0x69,0x69,0x64,0x64,0x64,0x4a,0x4a,0x4a |
db 0x28,0x28,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x05,0x05,0x05 |
db 0x00,0x00,0x00,0x21,0x21,0x21,0x39,0x39,0x39,0x49 |
db 0x49,0x49,0x48,0x48,0x48,0x35,0x35,0x35,0x1d,0x1d |
db 0x1d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x1d,0x1d,0x1d,0x27,0x27,0x27 |
db 0x27,0x27,0x27,0x1d,0x1d,0x1d,0x0f,0x0f,0x0f,0x06 |
db 0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 |
db 0x00,0x00,0x00,0x00 |
endg |
/kernel/branches/kolibri-process/gui/skincode.inc |
---|
0,0 → 1,525 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 3711 $ |
include "skindata.inc" |
;skin_data = 0x00778000 |
;------------------------------------------------------------------------------ |
align 4 |
read_skin_file: |
stdcall load_file, ebx |
test eax, eax |
jz .notfound |
cmp dword [eax], 'SKIN' |
jnz .noskin |
xchg eax, [skin_data] |
test eax, eax |
jz @f |
stdcall kernel_free, eax |
@@: |
call parse_skin_data |
xor eax, eax |
ret |
;-------------------------------------- |
align 4 |
.notfound: |
xor eax, eax |
inc eax |
ret |
;-------------------------------------- |
align 4 |
.noskin: |
stdcall kernel_free, eax |
mov eax, 2 |
ret |
;------------------------------------------------------------------------------ |
struct SKIN_HEADER |
ident dd ? |
version dd ? |
params dd ? |
buttons dd ? |
bitmaps dd ? |
ends |
struct SKIN_PARAMS |
skin_height dd ? |
margin.right dw ? |
margin.left dw ? |
margin.bottom dw ? |
margin.top dw ? |
colors.inner dd ? |
colors.outer dd ? |
colors.frame dd ? |
colors_1.inner dd ? |
colors_1.outer dd ? |
colors_1.frame dd ? |
dtp.size dd ? |
dtp.data rb 40 |
ends |
struct SKIN_BUTTONS |
type dd ? |
; position |
left dw ? |
top dw ? |
; size |
width dw ? |
height dw ? |
ends |
struct SKIN_BITMAPS |
kind dw ? |
type dw ? |
data dd ? |
ends |
;------------------------------------------------------------------------------ |
align 4 |
load_default_skin: |
mov [_skinh], 22 |
mov ebx, _skin_file_default |
call read_skin_file |
ret |
;------------------------------------------------------------------------------ |
align 4 |
parse_skin_data: |
mov ebp, [skin_data] |
cmp [ebp+SKIN_HEADER.ident], 'SKIN' |
jne .exit |
mov edi, skin_udata |
mov ecx, (skin_udata.end-skin_udata)/4 |
xor eax, eax |
cld |
rep stosd |
mov ebx, [ebp+SKIN_HEADER.params] |
add ebx, [skin_data] |
mov eax, [ebx+SKIN_PARAMS.skin_height] |
mov [_skinh], eax |
mov eax, [ebx+SKIN_PARAMS.colors.inner] |
mov [skin_active.colors.inner], eax |
mov eax, [ebx+SKIN_PARAMS.colors.outer] |
mov [skin_active.colors.outer], eax |
mov eax, [ebx+SKIN_PARAMS.colors.frame] |
mov [skin_active.colors.frame], eax |
mov eax, [ebx+SKIN_PARAMS.colors_1.inner] |
mov [skin_inactive.colors.inner], eax |
mov eax, [ebx+SKIN_PARAMS.colors_1.outer] |
mov [skin_inactive.colors.outer], eax |
mov eax, [ebx+SKIN_PARAMS.colors_1.frame] |
mov [skin_inactive.colors.frame], eax |
lea esi, [ebx+SKIN_PARAMS.dtp.data] |
mov edi, common_colours |
mov ecx, [ebx+SKIN_PARAMS.dtp.size] |
and ecx, 127 |
rep movsb |
mov eax, dword[ebx+SKIN_PARAMS.margin.right] |
mov dword[_skinmargins+0], eax |
mov eax, dword[ebx+SKIN_PARAMS.margin.bottom] |
mov dword[_skinmargins+4], eax |
mov ebx, [ebp+SKIN_HEADER.bitmaps] |
add ebx, [skin_data] |
;-------------------------------------- |
align 4 |
.lp1: |
cmp dword[ebx], 0 |
je .end_bitmaps |
movzx eax, [ebx+SKIN_BITMAPS.kind] |
movzx ecx, [ebx+SKIN_BITMAPS.type] |
dec eax |
jnz .not_left |
xor eax, eax |
mov edx, skin_active.left.data |
or ecx, ecx |
jnz @f |
mov edx, skin_inactive.left.data |
;-------------------------------------- |
align 4 |
@@: |
jmp .next_bitmap |
;-------------------------------------- |
align 4 |
.not_left: |
dec eax |
jnz .not_oper |
mov esi, [ebx+SKIN_BITMAPS.data] |
add esi, [skin_data] |
mov eax, [esi+0] |
neg eax |
mov edx, skin_active.oper.data |
or ecx, ecx |
jnz @f |
mov edx, skin_inactive.oper.data |
;-------------------------------------- |
align 4 |
@@: |
jmp .next_bitmap |
;-------------------------------------- |
align 4 |
.not_oper: |
dec eax |
jnz .not_base |
mov eax, [skin_active.left.width] |
mov edx, skin_active.base.data |
or ecx, ecx |
jnz @f |
mov eax, [skin_inactive.left.width] |
mov edx, skin_inactive.base.data |
;-------------------------------------- |
align 4 |
@@: |
jmp .next_bitmap |
;-------------------------------------- |
align 4 |
.not_base: |
add ebx, 8 |
jmp .lp1 |
;-------------------------------------- |
align 4 |
.next_bitmap: |
mov ecx, [ebx+SKIN_BITMAPS.data] |
add ecx, [skin_data] |
mov [edx+4], eax |
mov eax, [ecx+0] |
mov [edx+8], eax |
add ecx, 8 |
mov [edx+0], ecx |
add ebx, 8 |
jmp .lp1 |
;-------------------------------------- |
align 4 |
.end_bitmaps: |
mov ebx, [ebp+SKIN_HEADER.buttons] |
add ebx, [skin_data] |
;-------------------------------------- |
align 4 |
.lp2: |
cmp dword[ebx], 0 |
je .end_buttons |
mov eax, [ebx+SKIN_BUTTONS.type] |
dec eax |
jnz .not_close |
mov edx, skin_btn_close |
jmp .next_button |
;-------------------------------------- |
align 4 |
.not_close: |
dec eax |
jnz .not_minimize |
mov edx, skin_btn_minimize |
jmp .next_button |
;-------------------------------------- |
align 4 |
.not_minimize: |
add ebx, 12 |
jmp .lp2 |
;-------------------------------------- |
align 4 |
.next_button: |
movsx eax, [ebx+SKIN_BUTTONS.left] |
mov [edx+SKIN_BUTTON.left], eax |
movsx eax, [ebx+SKIN_BUTTONS.top] |
mov [edx+SKIN_BUTTON.top], eax |
movsx eax, [ebx+SKIN_BUTTONS.width] |
mov [edx+SKIN_BUTTON.width], eax |
movsx eax, [ebx+SKIN_BUTTONS.height] |
mov [edx+SKIN_BUTTON.height], eax |
add ebx, 12 |
jmp .lp2 |
;-------------------------------------- |
align 4 |
.end_buttons: |
.exit: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
drawwindow_IV_caption: |
mov ebp, skin_active |
or al, al |
jnz @f |
mov ebp, skin_inactive |
;-------------------------------------- |
align 4 |
@@: |
mov esi, [esp+4] |
mov eax, [esi+WDATA.box.width] ; window width |
mov edx, [ebp+SKIN_DATA.left.left] |
shl edx, 16 |
mov ecx, [ebp+SKIN_DATA.left.width] |
shl ecx, 16 |
add ecx, [_skinh] |
mov ebx, [ebp+SKIN_DATA.left.data] |
or ebx, ebx |
jz @f |
call sys_putimage.forced |
;-------------------------------------- |
align 4 |
@@: |
mov esi, [esp+4] |
mov eax, [esi+WDATA.box.width] |
sub eax, [ebp+SKIN_DATA.left.width] |
sub eax, [ebp+SKIN_DATA.oper.width] |
cmp eax, [ebp+SKIN_DATA.base.left] |
jng .non_base |
xor edx, edx |
mov ecx, [ebp+SKIN_DATA.base.width] |
jecxz .non_base |
div ecx |
inc eax |
mov ebx, [ebp+SKIN_DATA.base.data] |
mov ecx, [ebp+SKIN_DATA.base.width] |
shl ecx, 16 |
add ecx, [_skinh] |
mov edx, [ebp+SKIN_DATA.base.left] |
sub edx, [ebp+SKIN_DATA.base.width] |
shl edx, 16 |
;-------------------------------------- |
align 4 |
.baseskinloop: |
shr edx, 16 |
add edx, [ebp+SKIN_DATA.base.width] |
shl edx, 16 |
push eax ebx ecx edx |
or ebx, ebx |
jz @f |
call sys_putimage.forced |
;-------------------------------------- |
align 4 |
@@: |
pop edx ecx ebx eax |
dec eax |
jnz .baseskinloop |
;-------------------------------------- |
align 4 |
.non_base: |
mov esi, [esp+4] |
mov edx, [esi+WDATA.box.width] |
sub edx, [ebp+SKIN_DATA.oper.width] |
inc edx |
shl edx, 16 |
mov ebx, [ebp+SKIN_DATA.oper.data] |
mov ecx, [ebp+SKIN_DATA.oper.width] |
shl ecx, 16 |
add ecx, [_skinh] |
or ebx, ebx |
jz @f |
call sys_putimage.forced |
;-------------------------------------- |
align 4 |
@@: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
drawwindow_IV: |
;param1 - aw_yes |
pusha |
push edx |
mov edi, edx |
mov ebp, skin_active |
cmp byte [esp+32+4+4], 0 |
jne @f |
mov ebp, skin_inactive |
;-------------------------------------- |
align 4 |
@@: |
mov eax, [edi+WDATA.box.left] |
shl eax, 16 |
mov ax, word [edi+WDATA.box.left] |
add ax, word [edi+WDATA.box.width] |
mov ebx, [edi+WDATA.box.top] |
shl ebx, 16 |
mov bx, word [edi+WDATA.box.top] |
add bx, word [edi+WDATA.box.height] |
mov esi, [ebp+SKIN_DATA.colors.outer] |
or esi, 1 shl 25 ; 0x02000000 used for draw_rectangle without top line |
ror ebx, 16 |
add ebx, [_skinh] |
sub bx, 1 |
rol ebx, 16 |
call draw_rectangle |
mov ecx, 3 |
;-------------------------------------- |
align 4 |
_dw3l: |
add eax, 1*65536-1 |
add ebx, 0*65536-1 |
test ax, ax |
js no_skin_add_button |
test bx, bx |
js no_skin_add_button |
mov esi, [ebp+SKIN_DATA.colors.frame];[edi+24] |
or esi, 1 shl 25; 0x02000000 used for draw_rectangle without top line |
call draw_rectangle |
dec ecx |
jnz _dw3l |
mov esi, [ebp+SKIN_DATA.colors.inner] |
or esi, 1 shl 25; 0x02000000 used for draw_rectangle without top line |
add eax, 1*65536-1 |
add ebx, 0*65536-1 |
test ax, ax |
js no_skin_add_button |
test bx, bx |
js no_skin_add_button |
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP |
jnz @f |
call draw_rectangle |
;-------------------------------------- |
align 4 |
@@: |
mov eax, [skin_data] |
cmp [eax], dword 'SKIN' |
je @f |
xor eax, eax |
xor ebx, ebx |
mov esi, [esp] |
mov ecx, [esi+WDATA.box.width] |
inc ecx |
mov edx, [_skinh] |
mov edi, [common_colours+4]; standard grab color |
; call [drawbar] |
call vesa20_drawbar |
jmp draw_clientbar |
;-------------------------------------- |
align 4 |
@@: |
mov al, [esp+32+4+4] |
call drawwindow_IV_caption |
;-------------------------------------- |
align 4 |
draw_clientbar: |
mov esi, [esp] |
mov edx, [esi+WDATA.box.top] ; WORK AREA |
add edx, 21+5 |
mov ebx, [esi+WDATA.box.top] |
add ebx, [esi+WDATA.box.height] |
cmp edx, ebx |
jg _noinside2 |
mov eax, 5 |
mov ebx, [_skinh] |
mov ecx, [esi+WDATA.box.width] |
mov edx, [esi+WDATA.box.height] |
sub ecx, 4 |
sub edx, 4 |
mov edi, [esi+WDATA.cl_workarea] |
test edi, 0x40000000 |
jnz _noinside2 |
; call [drawbar] |
call vesa20_drawbar |
;-------------------------------------- |
align 4 |
_noinside2: |
mov eax, [skin_data] |
cmp [eax], dword 'SKIN' |
jne no_skin_add_button |
;* close button |
mov edi, [BTN_ADDR] |
movzx eax, word [edi] |
cmp eax, 1000 |
jge no_skin_add_button |
inc eax |
mov [edi], ax |
shl eax, 4 |
add eax, edi |
mov bx, [CURRENT_TASK] |
mov [eax], bx |
add eax, 2 ; save button id number |
mov bx, 1 |
mov [eax], bx |
add eax, 2 ; x start |
xor ebx, ebx |
cmp [skin_btn_close.left], 0 |
jge _bCx_at_right |
mov ebx, [esp] |
mov ebx, [ebx+WDATA.box.width] |
inc ebx |
;-------------------------------------- |
align 4 |
_bCx_at_right: |
add ebx, [skin_btn_close.left] |
mov [eax], bx |
add eax, 2 ; x size |
mov ebx, [skin_btn_close.width] |
dec ebx |
mov [eax], bx |
add eax, 2 ; y start |
mov ebx, [skin_btn_close.top] |
mov [eax], bx |
add eax, 2 ; y size |
mov ebx, [skin_btn_close.height] |
dec ebx |
mov [eax], bx |
;* minimize button |
mov edi, [BTN_ADDR] |
movzx eax, word [edi] |
cmp eax, 1000 |
jge no_skin_add_button |
inc eax |
mov [edi], ax |
shl eax, 4 |
add eax, edi |
mov bx, [CURRENT_TASK] |
mov [eax], bx |
add eax, 2 ; save button id number |
mov bx, 65535;999 |
mov [eax], bx |
add eax, 2 ; x start |
xor ebx, ebx |
cmp [skin_btn_minimize.left], 0 |
jge _bMx_at_right |
mov ebx, [esp] |
mov ebx, [ebx+WDATA.box.width] |
inc ebx |
;-------------------------------------- |
align 4 |
_bMx_at_right: |
add ebx, [skin_btn_minimize.left] |
mov [eax], bx |
add eax, 2 ; x size |
mov ebx, [skin_btn_minimize.width] |
dec ebx |
mov [eax], bx |
add eax, 2 ; y start |
mov ebx, [skin_btn_minimize.top] |
mov [eax], bx |
add eax, 2 ; y size |
mov ebx, [skin_btn_minimize.height] |
dec ebx |
mov [eax], bx |
;-------------------------------------- |
align 4 |
no_skin_add_button: |
pop edi |
popa |
ret 4 |
;------------------------------------------------------------------------------ |
/kernel/branches/kolibri-process/gui/skindata.inc |
---|
0,0 → 1,64 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 2455 $ |
; |
; WINDOW SKIN DATA |
; |
iglobal |
_skin_file_default db '/sys/DEFAULT.SKN',0 |
endg |
struct SKIN_DATA |
colors.inner dd ? |
colors.outer dd ? |
colors.frame dd ? |
left.data dd ? |
left.left dd ? |
left.width dd ? |
oper.data dd ? |
oper.left dd ? |
oper.width dd ? |
base.data dd ? |
base.left dd ? |
base.width dd ? |
ends |
struct SKIN_BUTTON |
left dd ? |
top dd ? |
width dd ? |
height dd ? |
ends |
uglobal |
align 4 |
skin_udata: |
_skinh dd ? |
_skinmargins: ; rw 4 |
.right dw ? |
.left dw ? |
.bottom dw ? |
.top dw ? |
skin_btn_close SKIN_BUTTON |
skin_btn_minimize SKIN_BUTTON |
skin_active SKIN_DATA |
skin_inactive SKIN_DATA |
align 4 |
skin_udata.end: |
endg |
/kernel/branches/kolibri-process/gui/window.inc |
---|
0,0 → 1,2421 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
;; ;; |
;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;; |
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
;; Distributed under terms of the GNU General Public License ;; |
;; ;; |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
$Revision: 4424 $ |
;============================================================================== |
;///// public functions /////////////////////////////////////////////////////// |
;============================================================================== |
window.BORDER_SIZE = 5 |
macro FuncTable name, table_name, [label] |
{ |
common |
align 4 |
\label name#.#table_name dword |
forward |
dd name#.#label |
common |
name#.sizeof.#table_name = $ - name#.#table_name |
} |
uglobal |
common_colours rd 32 |
draw_limits RECT |
endg |
align 4 |
;------------------------------------------------------------------------------ |
syscall_draw_window: ;///// system function 0 ///////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
mov eax, edx |
shr eax, 24 |
and al, 0x0f |
cmp al, 5 |
jae .exit |
push eax |
call window._.sys_set_window |
pop eax |
or al, al |
jnz @f |
; type I - original style |
call drawwindow_I |
jmp window._.draw_window_caption.2 |
;-------------------------------------- |
align 4 |
@@: |
dec al |
jnz @f |
; type II - only reserve area, no draw |
; call sys_window_mouse |
; call [draw_pointer] |
call __sys_draw_pointer |
jmp .exit |
;-------------------------------------- |
align 4 |
@@: |
dec al |
jnz @f |
; type III - new style |
call drawwindow_III |
jmp window._.draw_window_caption.2 |
; type IV & V - skinned window (resizable & not) |
;-------------------------------------- |
align 4 |
@@: |
mov eax, [TASK_COUNT] |
movzx eax, word[WIN_POS + eax * 2] |
cmp eax, [CURRENT_TASK] |
setz al |
movzx eax, al |
push eax |
call drawwindow_IV |
jmp window._.draw_window_caption.2 |
;-------------------------------------- |
align 4 |
.exit: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
syscall_display_settings: ;///// system function 48 /////////////////////////// |
;------------------------------------------------------------------------------ |
;; Redraw screen: |
;< ebx = 0 |
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
;; Set button style: |
;< ebx = 1 |
;< ecx = 0 (flat) or 1 (with gradient) |
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
;; Set system color palette: |
;< ebx = 2 |
;< ecx = pointer to color table |
;< edx = size of color table |
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
;; Get system color palette: |
;< ebx = 3 |
;< ecx = pointer to color table buffer |
;< edx = size of color table buffer |
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
;; Get skinned caption height: |
;< ebx = 4 |
;> eax = height in pixels |
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
;; Get screen working area: |
;< ebx = 5 |
;> eax = pack[16(left), 16(right)] |
;> ebx = pack[16(top), 16(bottom)] |
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
;; Set screen working area: |
;< ebx = 6 |
;< ecx = pack[16(left), 16(right)] |
;< edx = pack[16(top), 16(bottom)] |
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
;; Get skin margins: |
;< ebx = 7 |
;> eax = pack[16(left), 16(right)] |
;> ebx = pack[16(top), 16(bottom)] |
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
;; Set skin: |
;< ebx = 8 |
;< ecx = pointer to FileInfoBlock struct |
;> eax = FS error code |
;------------------------------------------------------------------------------ |
cmp ebx, .sizeof.ftable / 4 |
ja @f |
jmp [.ftable + ebx * 4] |
;-------------------------------------- |
align 4 |
@@: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
syscall_display_settings.00: |
xor eax, eax |
inc ebx |
cmp [windowtypechanged], ebx |
jne .exit |
mov [windowtypechanged], eax |
jmp syscall_display_settings._.redraw_whole_screen |
;-------------------------------------- |
align 4 |
.exit: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
syscall_display_settings.01: |
and ecx, 1 |
cmp ecx, [buttontype] |
je .exit |
mov [buttontype], ecx |
mov [windowtypechanged], ebx |
;-------------------------------------- |
align 4 |
.exit: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
syscall_display_settings.02: |
dec ebx |
mov esi, ecx |
and edx, 127 |
mov edi, common_colours |
mov ecx, edx |
rep movsb |
mov [windowtypechanged], ebx |
ret |
;------------------------------------------------------------------------------ |
align 4 |
syscall_display_settings.03: |
mov edi, ecx |
and edx, 127 |
mov esi, common_colours |
mov ecx, edx |
rep movsb |
ret |
;------------------------------------------------------------------------------ |
align 4 |
syscall_display_settings.04: |
mov eax, [_skinh] |
mov [esp + 32], eax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
syscall_display_settings.05: |
mov eax, [screen_workarea.left - 2] |
mov ax, word[screen_workarea.right] |
mov [esp + 32], eax |
mov eax, [screen_workarea.top - 2] |
mov ax, word[screen_workarea.bottom] |
mov [esp + 20], eax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
syscall_display_settings.06: |
xor esi, esi |
mov edi, [Screen_Max_X] |
mov eax, ecx |
movsx ebx, ax |
sar eax, 16 |
cmp eax, ebx |
jge .check_horizontal |
inc esi |
or eax, eax |
jge @f |
xor eax, eax |
;-------------------------------------- |
align 4 |
@@: |
mov [screen_workarea.left], eax |
cmp ebx, edi |
jle @f |
mov ebx, edi |
;-------------------------------------- |
align 4 |
@@: |
mov [screen_workarea.right], ebx |
;-------------------------------------- |
align 4 |
.check_horizontal: |
mov edi, [Screen_Max_Y] |
mov eax, edx |
movsx ebx, ax |
sar eax, 16 |
cmp eax, ebx |
jge .check_if_redraw_needed |
inc esi |
or eax, eax |
jge @f |
xor eax, eax |
;-------------------------------------- |
align 4 |
@@: |
mov [screen_workarea.top], eax |
cmp ebx, edi |
jle @f |
mov ebx, edi |
;-------------------------------------- |
align 4 |
@@: |
mov [screen_workarea.bottom], ebx |
;-------------------------------------- |
align 4 |
.check_if_redraw_needed: |
or esi, esi |
jz .exit |
call repos_windows |
jmp syscall_display_settings._.calculate_whole_screen |
;-------------------------------------- |
align 4 |
.exit: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
syscall_display_settings.07: |
mov eax, [_skinmargins + 0] |
mov [esp + 32], eax |
mov eax, [_skinmargins + 4] |
mov [esp + 20], eax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
syscall_display_settings.08: |
mov ebx, ecx |
call read_skin_file |
mov [esp + 32], eax |
test eax, eax |
jnz .exit |
call syscall_display_settings._.calculate_whole_screen |
jmp syscall_display_settings._.redraw_whole_screen |
;-------------------------------------- |
align 4 |
.exit: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
syscall_display_settings._.calculate_whole_screen: |
xor eax, eax |
xor ebx, ebx |
mov ecx, [Screen_Max_X] |
mov edx, [Screen_Max_Y] |
jmp calculatescreen |
;------------------------------------------------------------------------------ |
align 4 |
syscall_display_settings._.redraw_whole_screen: |
xor eax, eax |
mov [draw_limits.left], eax |
mov [draw_limits.top], eax |
mov eax, [Screen_Max_X] |
mov [draw_limits.right], eax |
mov eax, [Screen_Max_Y] |
mov [draw_limits.bottom], eax |
mov eax, window_data |
jmp redrawscreen |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
syscall_set_window_shape: ;///// system function 50 /////////////////////////// |
;------------------------------------------------------------------------------ |
;; Set window shape address: |
;> ebx = 0 |
;> ecx = shape data address |
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
;; Set window shape scale: |
;> ebx = 1 |
;> ecx = scale power (resulting scale is 2^ebx) |
;------------------------------------------------------------------------------ |
mov edi, [current_slot] |
test ebx, ebx |
jne .shape_scale |
mov [edi + APPDATA.wnd_shape], ecx |
;-------------------------------------- |
align 4 |
.shape_scale: |
dec ebx |
jnz .exit |
mov [edi + APPDATA.wnd_shape_scale], ecx |
;-------------------------------------- |
align 4 |
.exit: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
syscall_move_window: ;///// system function 67 //////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
mov edi, [CURRENT_TASK] |
shl edi, 5 |
add edi, window_data |
test [edi + WDATA.fl_wdrawn], 1 |
jz .exit |
test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED |
jnz .exit |
cmp ebx, -1 |
jne @f |
mov ebx, [edi + WDATA.box.left] |
;-------------------------------------- |
align 4 |
@@: |
cmp ecx, -1 |
jne @f |
mov ecx, [edi + WDATA.box.top] |
;-------------------------------------- |
align 4 |
@@: |
cmp edx, -1 |
jne @f |
mov edx, [edi + WDATA.box.width] |
;-------------------------------------- |
align 4 |
@@: |
cmp esi, -1 |
jne @f |
mov esi, [edi + WDATA.box.height] |
;-------------------------------------- |
align 4 |
@@: |
push esi edx ecx ebx |
mov eax, esp |
mov bl, [edi + WDATA.fl_wstate] |
;-------------------------------------- |
align 4 |
@@: |
cmp [REDRAW_BACKGROUND], byte 0 |
jz @f |
call change_task |
jmp @b |
;-------------------------------------- |
align 4 |
@@: |
call window._.set_window_box |
add esp, sizeof.BOX |
; NOTE: do we really need this? to be reworked |
; mov byte[DONT_DRAW_MOUSE], 0 ; mouse pointer |
; mov byte[MOUSE_BACKGROUND], 0 ; no mouse under |
; mov byte[MOUSE_DOWN], 0 ; react to mouse up/down |
; NOTE: do we really need this? to be reworked |
; call [draw_pointer] |
;-------------------------------------- |
align 4 |
.exit: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
syscall_window_settings: ;///// system function 71 ///////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
dec ebx ; subfunction #1 - set window caption |
jnz .exit_fail |
; NOTE: only window owner thread can set its caption, |
; so there's no parameter for PID/TID |
mov edi, [CURRENT_TASK] |
shl edi, 5 |
mov [edi * 8 + SLOT_BASE + APPDATA.wnd_caption], ecx |
or [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION |
call window._.draw_window_caption |
xor eax, eax ; eax = 0 (success) |
ret |
; .get_window_caption: |
; dec eax ; subfunction #2 - get window caption |
; jnz .exit_fail |
; not implemented yet |
;-------------------------------------- |
align 4 |
.exit_fail: |
xor eax, eax |
inc eax ; eax = 1 (fail) |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
set_window_defaults: ;///////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
mov byte [window_data + 0x20 + WDATA.cl_titlebar + 3], 1 ; desktop is not movable |
push eax ecx |
xor eax, eax |
mov ecx, WIN_STACK |
;-------------------------------------- |
align 4 |
@@: |
inc eax |
add ecx, 2 |
; process no |
mov [ecx + 0x000], ax |
; positions in stack |
mov [ecx + 0x400], ax |
cmp ecx, WIN_POS - 2 |
jne @b |
pop ecx eax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
calculatescreen: ;///////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Scan all windows from bottom to top, calling `setscreen` for each one |
;? intersecting given screen area |
;------------------------------------------------------------------------------ |
;> eax = left |
;> ebx = top |
;> ecx = right |
;> edx = bottom |
;------------------------------------------------------------------------------ |
push esi |
pushfd |
cli |
mov esi, 1 |
call window._.set_screen |
push ebp |
mov ebp, [TASK_COUNT] |
cmp ebp, 1 |
jbe .exit |
push edx ecx ebx eax |
;-------------------------------------- |
align 4 |
.next_window: |
movzx edi, word[WIN_POS + esi * 2] |
shl edi, 5 |
cmp [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE |
je .skip_window |
add edi, window_data |
test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
jnz .skip_window |
mov eax, [edi + WDATA.box.left] |
cmp eax, [esp + RECT.right] |
jg .skip_window |
mov ebx, [edi + WDATA.box.top] |
cmp ebx, [esp + RECT.bottom] |
jg .skip_window |
mov ecx, [edi + WDATA.box.width] |
add ecx, eax |
cmp ecx, [esp + RECT.left] |
jl .skip_window |
mov edx, [edi + WDATA.box.height] |
add edx, ebx |
cmp edx, [esp + RECT.top] |
jl .skip_window |
cmp eax, [esp + RECT.left] |
jae @f |
mov eax, [esp + RECT.left] |
;-------------------------------------- |
align 4 |
@@: |
cmp ebx, [esp + RECT.top] |
jae @f |
mov ebx, [esp + RECT.top] |
;-------------------------------------- |
align 4 |
@@: |
cmp ecx, [esp + RECT.right] |
jbe @f |
mov ecx, [esp + RECT.right] |
;-------------------------------------- |
align 4 |
@@: |
cmp edx, [esp + RECT.bottom] |
jbe @f |
mov edx, [esp + RECT.bottom] |
;-------------------------------------- |
align 4 |
@@: |
push esi |
movzx esi, word[WIN_POS + esi * 2] |
call window._.set_screen |
pop esi |
;-------------------------------------- |
align 4 |
.skip_window: |
inc esi |
dec ebp |
jnz .next_window |
pop eax ebx ecx edx |
;-------------------------------------- |
align 4 |
.exit: |
pop ebp |
inc [_display.mask_seqno] |
popfd |
pop esi |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
repos_windows: ;/////////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
mov ecx, [TASK_COUNT] |
mov edi, window_data + sizeof.WDATA * 2 |
call force_redraw_background |
dec ecx |
jle .exit |
;-------------------------------------- |
align 4 |
.next_window: |
mov [edi + WDATA.fl_redraw], 1 |
test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED |
jnz .fix_maximized |
mov eax, [edi + WDATA.box.left] |
add eax, [edi + WDATA.box.width] |
mov ebx, [Screen_Max_X] |
cmp eax, ebx |
jle .fix_vertical |
mov eax, [edi + WDATA.box.width] |
sub eax, ebx |
jle @f |
mov [edi + WDATA.box.width], ebx |
;-------------------------------------- |
align 4 |
@@: |
sub ebx, [edi + WDATA.box.width] |
mov [edi + WDATA.box.left], ebx |
;-------------------------------------- |
align 4 |
.fix_vertical: |
mov eax, [edi + WDATA.box.top] |
add eax, [edi + WDATA.box.height] |
mov ebx, [Screen_Max_Y] |
cmp eax, ebx |
jle .fix_client_box |
mov eax, [edi + WDATA.box.height] |
sub eax, ebx |
jle @f |
mov [edi + WDATA.box.height], ebx |
;-------------------------------------- |
align 4 |
@@: |
sub ebx, [edi + WDATA.box.height] |
mov [edi + WDATA.box.top], ebx |
;-------------------------------------- |
align 4 |
.fix_client_box: |
call window._.set_window_clientbox |
add edi, sizeof.WDATA |
loop .next_window |
;-------------------------------------- |
align 4 |
.exit: |
ret |
;-------------------------------------- |
align 4 |
.fix_maximized: |
mov eax, [screen_workarea.left] |
mov [edi + WDATA.box.left], eax |
sub eax, [screen_workarea.right] |
neg eax |
mov [edi + WDATA.box.width], eax |
mov eax, [screen_workarea.top] |
mov [edi + WDATA.box.top], eax |
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP |
jnz .fix_client_box |
sub eax, [screen_workarea.bottom] |
neg eax |
mov [edi + WDATA.box.height], eax |
jmp .fix_client_box |
;------------------------------------------------------------------------------ |
;align 4 |
;------------------------------------------------------------------------------ |
;sys_window_mouse: ;//////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
; NOTE: commented out since doesn't provide necessary functionality |
; anyway, to be reworked |
; push eax |
; |
; mov eax, [timer_ticks] |
; cmp [new_window_starting], eax |
; jb .exit |
; |
; mov byte[MOUSE_BACKGROUND], 0 |
; mov byte[DONT_DRAW_MOUSE], 0 |
; |
; mov [new_window_starting], eax |
; |
; .exit: |
; pop eax |
; ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
draw_rectangle: ;////////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;> eax = pack[16(left), 16(right)] |
;> ebx = pack[16(top), 16(bottom)] |
;> esi = color |
; ?? RR GG BB ; 0x01000000 negation |
; ; 0x02000000 used for draw_rectangle without top line |
; ; for example drawwindow_III and drawwindow_IV |
;------------------------------------------------------------------------------ |
push eax ebx ecx edi |
xor edi, edi |
;-------------------------------------- |
align 4 |
.flags_set: |
push ebx |
; set line color |
mov ecx, esi |
; draw top border |
rol ebx, 16 |
push ebx |
rol ebx, 16 |
pop bx |
test ecx, 1 shl 25 |
jnz @f |
sub ecx, 1 shl 25 |
; call [draw_line] |
call __sys_draw_line |
;-------------------------------------- |
align 4 |
@@: |
; draw bottom border |
mov ebx, [esp - 2] |
pop bx |
; call [draw_line] |
call __sys_draw_line |
pop ebx |
add ebx, 1 * 65536 - 1 |
; draw left border |
rol eax, 16 |
push eax |
rol eax, 16 |
pop ax |
; call [draw_line] |
call __sys_draw_line |
; draw right border |
mov eax, [esp - 2] |
pop ax |
; call [draw_line] |
call __sys_draw_line |
pop edi ecx ebx eax |
ret |
;-------------------------------------- |
align 4 |
.forced: |
push eax ebx ecx edi |
xor edi, edi |
inc edi |
jmp .flags_set |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
drawwindow_I_caption: ;//////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
push [edx + WDATA.cl_titlebar] |
mov esi, edx |
mov edx, [esi + WDATA.box.top] |
mov eax, edx |
lea ebx, [edx + 21] |
inc edx |
add eax, [esi + WDATA.box.height] |
cmp ebx, eax |
jbe @f |
mov ebx, eax |
;-------------------------------------- |
align 4 |
@@: |
push ebx |
xor edi, edi |
;-------------------------------------- |
align 4 |
.next_line: |
mov ebx, edx |
shl ebx, 16 |
add ebx, edx |
mov eax, [esi + WDATA.box.left] |
inc eax |
shl eax, 16 |
add eax, [esi + WDATA.box.left] |
add eax, [esi + WDATA.box.width] |
dec eax |
mov ecx, [esi + WDATA.cl_titlebar] |
test ecx, 0x80000000 |
jz @f |
sub ecx, 0x00040404 |
mov [esi + WDATA.cl_titlebar], ecx |
;-------------------------------------- |
align 4 |
@@: |
and ecx, 0x00ffffff |
; call [draw_line] |
call __sys_draw_line |
inc edx |
cmp edx, [esp] |
jb .next_line |
add esp, 4 |
pop [esi + WDATA.cl_titlebar] |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
drawwindow_I: ;//////////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
pushad |
; window border |
mov eax, [edx + WDATA.box.left - 2] |
mov ax, word[edx + WDATA.box.left] |
add ax, word[edx + WDATA.box.width] |
mov ebx, [edx + WDATA.box.top - 2] |
mov bx, word[edx + WDATA.box.top] |
add bx, word[edx + WDATA.box.height] |
mov esi, [edx + WDATA.cl_frames] |
call draw_rectangle |
; window caption |
call drawwindow_I_caption |
; window client area |
; do we need to draw it? |
mov edi, [esi + WDATA.cl_workarea] |
test edi, 0x40000000 |
jnz .exit |
; does client area have a positive size on screen? |
mov edx, [esi + WDATA.box.top] |
add edx, 21 + 5 |
mov ebx, [esi + WDATA.box.top] |
add ebx, [esi + WDATA.box.height] |
cmp edx, ebx |
jg .exit |
; okay, let's draw it |
mov eax, 1 |
mov ebx, 21 |
mov ecx, [esi + WDATA.box.width] |
mov edx, [esi + WDATA.box.height] |
; call [drawbar] |
call vesa20_drawbar |
;-------------------------------------- |
align 4 |
.exit: |
popad |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
drawwindow_III_caption: ;///////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
mov ecx, [edx + WDATA.cl_titlebar] |
push ecx |
mov esi, edx |
mov edx, [esi + WDATA.box.top] |
add edx, 4 |
mov ebx, [esi + WDATA.box.top] |
add ebx, 20 |
mov eax, [esi + WDATA.box.top] |
add eax, [esi + WDATA.box.height] |
cmp ebx, eax |
jb @f |
mov ebx, eax |
;-------------------------------------- |
align 4 |
@@: |
push ebx |
xor edi, edi |
;-------------------------------------- |
align 4 |
.next_line: |
mov ebx, edx |
shl ebx, 16 |
add ebx, edx |
mov eax, [esi + WDATA.box.left] |
shl eax, 16 |
add eax, [esi + WDATA.box.left] |
add eax, [esi + WDATA.box.width] |
add eax, 4 * 65536 - 4 |
mov ecx, [esi + WDATA.cl_titlebar] |
test ecx, 0x40000000 |
jz @f |
add ecx, 0x00040404 |
;-------------------------------------- |
align 4 |
@@: |
test ecx, 0x80000000 |
jz @f |
sub ecx, 0x00040404 |
;-------------------------------------- |
align 4 |
@@: |
mov [esi + WDATA.cl_titlebar], ecx |
and ecx, 0x00ffffff |
; call [draw_line] |
call __sys_draw_line |
inc edx |
cmp edx, [esp] |
jb .next_line |
add esp, 4 |
pop [esi + WDATA.cl_titlebar] |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
drawwindow_III: ;////////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
pushad |
; window border |
mov eax, [edx + WDATA.box.left - 2] |
mov ax, word[edx + WDATA.box.left] |
add ax, word[edx + WDATA.box.width] |
mov ebx, [edx + WDATA.box.top - 2] |
mov bx, word[edx + WDATA.box.top] |
add bx, word[edx + WDATA.box.height] |
mov esi, [edx + WDATA.cl_frames] |
shr esi, 1 |
and esi, 0x007f7f7f |
call draw_rectangle |
push esi |
mov ecx, 3 |
mov esi, [edx + WDATA.cl_frames] |
;-------------------------------------- |
align 4 |
.next_frame: |
add eax, 1 * 65536 - 1 |
add ebx, 1 * 65536 - 1 |
call draw_rectangle |
dec ecx |
jnz .next_frame |
pop esi |
add eax, 1 * 65536 - 1 |
add ebx, 1 * 65536 - 1 |
call draw_rectangle |
; window caption |
call drawwindow_III_caption |
; window client area |
; do we need to draw it? |
mov edi, [esi + WDATA.cl_workarea] |
test edi, 0x40000000 |
jnz .exit |
; does client area have a positive size on screen? |
mov edx, [esi + WDATA.box.top] |
add edx, 21 + 5 |
mov ebx, [esi + WDATA.box.top] |
add ebx, [esi + WDATA.box.height] |
cmp edx, ebx |
jg .exit |
; okay, let's draw it |
mov eax, 5 |
mov ebx, 20 |
mov ecx, [esi + WDATA.box.width] |
mov edx, [esi + WDATA.box.height] |
sub ecx, 4 |
sub edx, 4 |
; call [drawbar] |
call vesa20_drawbar |
;-------------------------------------- |
align 4 |
.exit: |
popad |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
waredraw: ;//////////////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Activate window, redrawing if necessary |
;------------------------------------------------------------------------------ |
push -1 |
mov eax, [TASK_COUNT] |
lea eax, [WIN_POS + eax * 2] |
cmp eax, esi |
pop eax |
je .exit |
; is it overlapped by another window now? |
push ecx |
call window._.check_window_draw |
test ecx, ecx |
pop ecx |
jz .do_not_draw |
; yes it is, activate and update screen buffer |
call window._.window_activate |
pushad |
mov edi, [TASK_COUNT] |
movzx esi, word[WIN_POS + edi * 2] |
shl esi, 5 |
add esi, window_data |
mov eax, [esi + WDATA.box.left] |
mov ebx, [esi + WDATA.box.top] |
mov ecx, [esi + WDATA.box.width] |
mov edx, [esi + WDATA.box.height] |
add ecx, eax |
add edx, ebx |
mov edi, [TASK_COUNT] |
movzx esi, word[WIN_POS + edi * 2] |
call window._.set_screen |
inc [_display.mask_seqno] |
popad |
; tell application to redraw itself |
mov [edi + WDATA.fl_redraw], 1 |
xor eax, eax |
jmp .exit |
;-------------------------------------- |
align 4 |
.do_not_draw: |
; no it's not, just activate the window |
call window._.window_activate |
xor eax, eax |
ret |
;-------------------------------------- |
align 4 |
.exit: |
inc eax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
minimize_all_window: |
push ebx ecx edx esi edi |
pushfd |
cli |
xor edx, edx |
mov eax, 2 ; we do not minimize the kernel thread N1 |
mov ebx, [TASK_COUNT] |
;-------------------------------------- |
align 4 |
.loop: |
movzx edi, word[WIN_POS + eax * 2] |
shl edi, 5 |
; it is a unused slot? |
cmp dword [edi+CURRENT_TASK+TASKDATA.state], 9 |
je @f |
; it is a hidden thread? |
lea esi, [edi*8+SLOT_BASE+APPDATA.app_name] |
cmp [esi], byte '@' |
je @f |
; is it already minimized? |
test [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED |
jnz @f |
; no it's not, let's do that |
or [edi + window_data+WDATA.fl_wstate], WSTATE_MINIMIZED |
inc edx |
;-------------------------------------- |
align 4 |
@@: |
inc eax |
cmp eax, ebx |
jbe .loop |
; If nothing has changed |
test edx, edx |
jz @f |
push edx |
call syscall_display_settings._.calculate_whole_screen |
call syscall_display_settings._.redraw_whole_screen |
pop edx |
;-------------------------------------- |
align 4 |
@@: |
mov eax, edx |
popfd |
pop edi esi edx ecx ebx |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
minimize_window: ;///////////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;> eax = window number on screen |
;------------------------------------------------------------------------------ |
;# corrupts [dl*] |
;------------------------------------------------------------------------------ |
push edi |
pushfd |
cli |
; is it already minimized? |
movzx edi, word[WIN_POS + eax * 2] |
shl edi, 5 |
add edi, window_data |
test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
jnz .exit |
push eax ebx ecx edx esi |
; no it's not, let's do that |
or [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
; If the window width is 0, then the action is not needed. |
cmp [edi + WDATA.box.width], dword 0 |
je @f |
; If the window height is 0, then the action is not needed. |
cmp [edi + WDATA.box.height], dword 0 |
je @f |
mov eax, [edi + WDATA.box.left] |
mov [draw_limits.left], eax |
mov ecx, eax |
add ecx, [edi + WDATA.box.width] |
mov [draw_limits.right], ecx |
mov ebx, [edi + WDATA.box.top] |
mov [draw_limits.top], ebx |
mov edx, ebx |
add edx, [edi + WDATA.box.height] |
mov [draw_limits.bottom], edx |
; DEBUGF 1, "K : minimize_window\n" |
; DEBUGF 1, "K : dl_left %x\n",[draw_limits.left] |
; DEBUGF 1, "K : dl_right %x\n",[draw_limits.right] |
; DEBUGF 1, "K : dl_top %x\n",[draw_limits.top] |
; DEBUGF 1, "K : dl_bottom %x\n",[draw_limits.bottom] |
call calculatescreen |
; xor esi, esi |
; xor eax, eax |
mov eax, edi |
call redrawscreen |
;-------------------------------------- |
align 4 |
@@: |
pop esi edx ecx ebx eax |
;-------------------------------------- |
align 4 |
.exit: |
popfd |
pop edi |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
restore_minimized_window: ;//////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;> eax = window number on screen |
;------------------------------------------------------------------------------ |
;# corrupts [dl*] |
;------------------------------------------------------------------------------ |
pushad |
pushfd |
cli |
; is it already restored? |
movzx esi, word[WIN_POS + eax * 2] |
mov edi, esi |
shl edi, 5 |
add edi, window_data |
test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED |
jz .exit |
; no it's not, let's do that |
mov [edi + WDATA.fl_redraw], 1 |
and [edi + WDATA.fl_wstate], not WSTATE_MINIMIZED |
mov ebp, window._.set_screen |
cmp eax, [TASK_COUNT] |
jz @f |
mov ebp, calculatescreen |
;-------------------------------------- |
align 4 |
@@: |
mov eax, [edi + WDATA.box.left] |
mov ebx, [edi + WDATA.box.top] |
mov ecx, [edi + WDATA.box.width] |
mov edx, [edi + WDATA.box.height] |
add ecx, eax |
add edx, ebx |
call ebp |
inc [_display.mask_seqno] |
;-------------------------------------- |
align 4 |
.exit: |
popfd |
popad |
ret |
;------------------------------------------------------------------------------ |
align 4 |
; TODO: remove this proc |
;------------------------------------------------------------------------------ |
window_check_events: ;///////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
; do we have window minimize/restore request? |
cmp [window_minimize], 0 |
je .exit |
; okay, minimize or restore top-most window and exit |
mov eax, [TASK_COUNT] |
mov bl, 0 |
xchg [window_minimize], bl |
dec bl |
jnz @f |
call minimize_window |
jmp .exit |
;-------------------------------------- |
align 4 |
@@: |
call restore_minimized_window |
;-------------------------------------- |
align 4 |
.exit: |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
sys_window_maximize_handler: ;///////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> esi = process slot |
;------------------------------------------------------------------------------ |
mov edi, esi |
shl edi, 5 |
add edi, window_data |
; can window change its height? |
; only types 2 and 3 can be resized |
mov dl, [edi + WDATA.fl_wstyle] |
test dl, 2 |
jz .exit |
; toggle normal/maximized window state |
mov bl, [edi + WDATA.fl_wstate] |
xor bl, WSTATE_MAXIMIZED |
; calculate and set appropriate window bounds |
test bl, WSTATE_MAXIMIZED |
jz .restore_size |
mov eax, [screen_workarea.left] |
mov ecx, [screen_workarea.top] |
push [screen_workarea.bottom] \ |
[screen_workarea.right] \ |
ecx \ |
eax |
sub [esp + BOX.width], eax |
sub [esp + BOX.height], ecx |
mov eax, esp |
jmp .set_box |
;-------------------------------------- |
align 4 |
.restore_size: |
mov eax, esi |
shl eax, 8 |
add eax, SLOT_BASE + APPDATA.saved_box |
push [eax + BOX.height] \ |
[eax + BOX.width] \ |
[eax + BOX.top] \ |
[eax + BOX.left] |
mov eax, esp |
;-------------------------------------- |
align 4 |
.set_box: |
test bl, WSTATE_ROLLEDUP |
jz @f |
xchg eax, ecx |
call window._.get_rolledup_height |
mov [ecx + BOX.height], eax |
xchg eax, ecx |
;-------------------------------------- |
align 4 |
@@: |
call window._.set_window_box |
add esp, sizeof.BOX |
;-------------------------------------- |
align 4 |
.exit: |
inc [_display.mask_seqno] |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
sys_window_rollup_handler: ;/////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> esi = process slot |
;------------------------------------------------------------------------------ |
mov edx, esi |
shl edx, 8 |
add edx, SLOT_BASE |
; toggle normal/rolled up window state |
mov bl, [edi + WDATA.fl_wstate] |
xor bl, WSTATE_ROLLEDUP |
; calculate and set appropriate window bounds |
test bl, WSTATE_ROLLEDUP |
jz .restore_size |
call window._.get_rolledup_height |
push eax \ |
[edi + WDATA.box.width] \ |
[edi + WDATA.box.top] \ |
[edi + WDATA.box.left] |
mov eax, esp |
jmp .set_box |
;-------------------------------------- |
align 4 |
.restore_size: |
test bl, WSTATE_MAXIMIZED |
jnz @f |
add esp, -sizeof.BOX |
lea eax, [edx + APPDATA.saved_box] |
jmp .set_box |
;-------------------------------------- |
align 4 |
@@: |
mov eax, [screen_workarea.top] |
push [screen_workarea.bottom] \ |
[edi + WDATA.box.width] \ |
eax \ |
[edi + WDATA.box.left] |
sub [esp + BOX.height], eax |
mov eax, esp |
;-------------------------------------- |
align 4 |
.set_box: |
call window._.set_window_box |
add esp, sizeof.BOX |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
;sys_window_start_moving_handler: ;///////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> eax = old (original) window box |
;> esi = process slot |
;------------------------------------------------------------------------------ |
; mov edi, eax |
; call window._.draw_negative_box |
; ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
sys_window_end_moving_handler: ;/////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> eax = old (original) window box |
;> ebx = new (final) window box |
;> esi = process slot |
;------------------------------------------------------------------------------ |
; mov edi, ebx |
; call window._.end_moving__box |
mov edi, esi |
shl edi, 5 |
add edi, window_data |
mov eax, ebx |
mov bl, [edi + WDATA.fl_wstate] |
call window._.set_window_box |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
sys_window_moving_handler: ;/////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> eax = old (from previous call) window box |
;> ebx = new (current) window box |
;> esi = process_slot |
;------------------------------------------------------------------------------ |
mov edi, eax |
call window._.draw_negative_box |
mov edi, ebx |
call window._.draw_negative_box |
ret |
;============================================================================== |
;///// private functions ////////////////////////////////////////////////////// |
;============================================================================== |
iglobal |
FuncTable syscall_display_settings, ftable, \ |
00, 01, 02, 03, 04, 05, 06, 07, 08 |
align 4 |
window_topleft dd \ |
1, 21, \ ;type 0 |
0, 0, \ ;type 1 |
5, 20, \ ;type 2 |
5, ?, \ ;type 3 {set by skin} |
5, ? ;type 4 {set by skin} |
endg |
;uglobal |
; NOTE: commented out since doesn't provide necessary functionality anyway, |
; to be reworked |
; new_window_starting dd ? |
;endg |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.invalidate_screen: ;////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> eax = old (original) window box |
;> ebx = new (final) window box |
;> edi = pointer to WDATA struct |
;------------------------------------------------------------------------------ |
push eax ebx |
; TODO: do we really need `draw_limits`? |
; Yes, they are used by background drawing code. |
; we need only to restore the background windows at the old place! |
mov ecx, [ebx + BOX.left] |
mov [draw_limits.left], ecx |
add ecx, [ebx + BOX.width] |
mov [draw_limits.right], ecx |
mov ecx, [ebx + BOX.top] |
mov [draw_limits.top], ecx |
add ecx, [ebx + BOX.height] |
mov [draw_limits.bottom], ecx |
; recalculate screen buffer at old position |
push ebx |
mov edx, [eax + BOX.height] |
mov ecx, [eax + BOX.width] |
mov ebx, [eax + BOX.top] |
mov eax, [eax + BOX.left] |
add ecx, eax |
add edx, ebx |
call calculatescreen |
pop eax |
; recalculate screen buffer at new position |
mov edx, [eax + BOX.height] |
mov ecx, [eax + BOX.width] |
mov ebx, [eax + BOX.top] |
mov eax, [eax + BOX.left] |
add ecx, eax |
add edx, ebx |
call calculatescreen |
mov eax, edi |
call redrawscreen |
; tell window to redraw itself |
mov [edi + WDATA.fl_redraw], 1 |
pop ebx eax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.set_window_box: ;///////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> eax = pointer to BOX struct |
;> bl = new window state flags |
;> edi = pointer to WDATA struct |
;------------------------------------------------------------------------------ |
push eax ebx esi |
; don't do anything if the new box is identical to the old |
cmp bl, [edi + WDATA.fl_wstate] |
jnz @f |
mov esi, eax |
push edi |
if WDATA.box |
add edi, WDATA.box |
end if |
mov ecx, 4 |
repz cmpsd |
pop edi |
jz .exit |
;-------------------------------------- |
align 4 |
@@: |
add esp, -sizeof.BOX |
mov ebx, esp |
if WDATA.box |
lea esi, [edi + WDATA.box] |
else |
mov esi, edi ; optimization for WDATA.box = 0 |
end if |
xchg eax, esi |
mov ecx, sizeof.BOX |
call memmove |
xchg eax, esi |
xchg ebx, esi |
call memmove |
mov eax, ebx |
mov ebx, esi |
call window._.check_window_position |
call window._.set_window_clientbox |
call window._.invalidate_screen |
add esp, sizeof.BOX |
mov cl, [esp + 4] |
mov ch, cl |
xchg cl, [edi + WDATA.fl_wstate] |
or cl, ch |
test cl, WSTATE_MAXIMIZED |
jnz .exit |
mov eax, edi |
sub eax, window_data |
shl eax, 3 |
add eax, SLOT_BASE |
lea ebx, [edi + WDATA.box] |
xchg esp, ebx |
pop [eax + APPDATA.saved_box.left] \ |
[eax + APPDATA.saved_box.top] \ |
[eax + APPDATA.saved_box.width] \ |
edx |
xchg esp, ebx |
test ch, WSTATE_ROLLEDUP |
jnz .exit |
mov [eax + APPDATA.saved_box.height], edx |
;-------------------------------------- |
align 4 |
.exit: |
pop esi ebx eax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.set_window_clientbox: ;/////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> edi = pointer to WDATA struct |
;------------------------------------------------------------------------------ |
push eax ecx edi |
mov eax, [_skinh] |
mov [window_topleft + 8 * 3 + 4], eax |
mov [window_topleft + 8 * 4 + 4], eax |
mov ecx, edi |
sub edi, window_data |
shl edi, 3 |
test [ecx + WDATA.fl_wstyle], WSTYLE_CLIENTRELATIVE |
jz .whole_window |
movzx eax, [ecx + WDATA.fl_wstyle] |
and eax, 0x0F |
mov eax, [eax * 8 + window_topleft + 0] |
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax |
shl eax, 1 |
neg eax |
add eax, [ecx + WDATA.box.width] |
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax |
movzx eax, [ecx + WDATA.fl_wstyle] |
and eax, 0x0F |
push [eax * 8 + window_topleft + 0] |
mov eax, [eax * 8 + window_topleft + 4] |
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax |
neg eax |
sub eax, [esp] |
add eax, [ecx + WDATA.box.height] |
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax |
add esp, 4 |
jmp .exit |
;-------------------------------------- |
align 4 |
.whole_window: |
xor eax, eax |
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.left], eax |
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.top], eax |
mov eax, [ecx + WDATA.box.width] |
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.width], eax |
mov eax, [ecx + WDATA.box.height] |
mov [edi + SLOT_BASE + APPDATA.wnd_clientbox.height], eax |
;-------------------------------------- |
align 4 |
.exit: |
pop edi ecx eax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.sys_set_window: ;///////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;< edx = pointer to WDATA struct |
;------------------------------------------------------------------------------ |
mov eax, [CURRENT_TASK] |
shl eax, 5 |
add eax, window_data |
; save window colors |
mov [eax + WDATA.cl_workarea], edx |
mov [eax + WDATA.cl_titlebar], esi |
mov [eax + WDATA.cl_frames], edi |
mov edi, eax |
; was it already defined before? |
test [edi + WDATA.fl_wdrawn], 1 |
jnz .set_client_box |
or [edi + WDATA.fl_wdrawn], 1 |
; After first draw_window we need redraw mouse necessarily! |
; Otherwise the user can see cursor specified by f.37.5 from another window. |
; He will be really unhappy! He is terrible in rage - usually he throws stones! |
mov [redrawmouse_unconditional], 1 |
call wakeup_osloop |
; NOTE: commented out since doesn't provide necessary functionality |
; anyway, to be reworked |
; mov eax, [timer_ticks] ; [0xfdf0] |
; add eax, 100 |
; mov [new_window_starting], eax |
; no it wasn't, performing initial window definition |
movzx eax, bx |
mov [edi + WDATA.box.width], eax |
movzx eax, cx |
mov [edi + WDATA.box.height], eax |
sar ebx, 16 |
sar ecx, 16 |
mov [edi + WDATA.box.left], ebx |
mov [edi + WDATA.box.top], ecx |
call window._.check_window_position |
push ecx edi |
mov cl, [edi + WDATA.fl_wstyle] |
mov eax, [edi + WDATA.cl_frames] |
sub edi, window_data |
shl edi, 3 |
add edi, SLOT_BASE |
and cl, 0x0F |
cmp cl, 3 |
je @f |
cmp cl, 4 |
je @f |
xor eax, eax |
;-------------------------------------- |
align 4 |
@@: |
mov [edi + APPDATA.wnd_caption], eax |
mov esi, [esp] |
add edi, APPDATA.saved_box |
movsd |
movsd |
movsd |
movsd |
pop edi ecx |
mov esi, [CURRENT_TASK] |
movzx esi, word[WIN_STACK + esi * 2] |
lea esi, [WIN_POS + esi * 2] |
call waredraw |
mov eax, [edi + WDATA.box.left] |
mov ebx, [edi + WDATA.box.top] |
mov ecx, [edi + WDATA.box.width] |
mov edx, [edi + WDATA.box.height] |
add ecx, eax |
add edx, ebx |
call calculatescreen |
mov byte[KEY_COUNT], 0 ; empty keyboard buffer |
mov byte[BTN_COUNT], 0 ; empty button buffer |
;-------------------------------------- |
align 4 |
.set_client_box: |
; update window client box coordinates |
call window._.set_window_clientbox |
; reset window redraw flag and exit |
mov [edi + WDATA.fl_redraw], 0 |
mov edx, edi |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.check_window_position: ;////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Check if window is inside screen area |
;------------------------------------------------------------------------------ |
;> edi = pointer to WDATA |
;------------------------------------------------------------------------------ |
push eax ebx ecx edx esi |
mov eax, [edi + WDATA.box.left] |
mov ebx, [edi + WDATA.box.top] |
mov ecx, [edi + WDATA.box.width] |
mov edx, [edi + WDATA.box.height] |
mov esi, [Screen_Max_X] |
cmp ecx, esi |
ja .fix_width_high |
;-------------------------------------- |
align 4 |
.check_left: |
or eax, eax |
jl .fix_left_low |
add eax, ecx |
cmp eax, esi |
jg .fix_left_high |
;-------------------------------------- |
align 4 |
.check_height: |
mov esi, [Screen_Max_Y] |
cmp edx, esi |
ja .fix_height_high |
;-------------------------------------- |
align 4 |
.check_top: |
or ebx, ebx |
jl .fix_top_low |
add ebx, edx |
cmp ebx, esi |
jg .fix_top_high |
;-------------------------------------- |
align 4 |
.exit: |
pop esi edx ecx ebx eax |
ret |
;-------------------------------------- |
align 4 |
.fix_width_high: |
mov ecx, esi |
mov [edi + WDATA.box.width], esi |
jmp .check_left |
;-------------------------------------- |
align 4 |
.fix_left_low: |
xor eax, eax |
mov [edi + WDATA.box.left], eax |
jmp .check_height |
;-------------------------------------- |
align 4 |
.fix_left_high: |
mov eax, esi |
sub eax, ecx |
mov [edi + WDATA.box.left], eax |
jmp .check_height |
;-------------------------------------- |
align 4 |
.fix_height_high: |
mov edx, esi |
mov [edi + WDATA.box.height], esi |
jmp .check_top |
;-------------------------------------- |
align 4 |
.fix_top_low: |
xor ebx, ebx |
mov [edi + WDATA.box.top], ebx |
jmp .exit |
;-------------------------------------- |
align 4 |
.fix_top_high: |
mov ebx, esi |
sub ebx, edx |
mov [edi + WDATA.box.top], ebx |
jmp .exit |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.get_titlebar_height: ;//////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> edi = pointer to WDATA |
;------------------------------------------------------------------------------ |
mov al, [edi + WDATA.fl_wstyle] |
and al, 0x0f |
cmp al, 0x03 |
jne @f |
mov eax, [_skinh] |
ret |
;-------------------------------------- |
align 4 |
@@: |
mov eax, 21 |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.get_rolledup_height: ;//////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
;> edi = pointer to WDATA |
;------------------------------------------------------------------------------ |
mov al, [edi + WDATA.fl_wstyle] |
and al, 0x0f |
cmp al, 0x03 |
jb @f |
mov eax, [_skinh] |
add eax, 3 |
ret |
;-------------------------------------- |
align 4 |
@@: |
or al, al |
jnz @f |
mov eax, 21 |
ret |
;-------------------------------------- |
align 4 |
@@: |
mov eax, 21 + 2 |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.set_screen: ;///////////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Reserve window area in screen buffer |
;------------------------------------------------------------------------------ |
;> eax = left |
;> ebx = top |
;> ecx = right |
;> edx = bottom |
;> esi = process number |
;------------------------------------------------------------------------------ |
virtual at esp |
ff_x dd ? |
ff_y dd ? |
ff_width dd ? |
ff_xsz dd ? |
ff_ysz dd ? |
ff_scale dd ? |
end virtual |
pushad |
cmp esi, 1 |
jz .check_for_shaped_window |
mov edi, esi |
shl edi, 5 |
cmp [window_data + edi + WDATA.box.width], 0 |
jnz .check_for_shaped_window |
cmp [window_data + edi + WDATA.box.height], 0 |
jz .exit |
;-------------------------------------- |
align 4 |
.check_for_shaped_window: |
mov edi, esi |
shl edi, 8 |
add edi, SLOT_BASE |
cmp [edi + APPDATA.wnd_shape], 0 |
jne .shaped_window |
; get x&y size |
sub ecx, eax |
sub edx, ebx |
inc ecx |
inc edx |
; get WinMap start |
push esi |
mov esi, [_display.width] |
mov edi, [d_width_calc_area + ebx*4] |
add edi, eax |
add edi, [_WinMapAddress] |
pop eax |
mov ah, al |
push ax |
shl eax, 16 |
pop ax |
;-------------------------------------- |
align 4 |
.next_line: |
push ecx |
shr ecx, 2 |
rep stosd |
mov ecx, [esp] |
and ecx, 3 |
rep stosb |
pop ecx |
add edi, esi |
sub edi, ecx |
dec edx |
jnz .next_line |
jmp .exit |
;-------------------------------------- |
align 4 |
.shaped_window: |
; for (y=0; y <= x_size; y++) |
; for (x=0; x <= x_size; x++) |
; if (shape[coord(x,y,scale)]==1) |
; set_pixel(x, y, process_number); |
sub ecx, eax |
sub edx, ebx |
inc ecx |
inc edx |
push [edi + APPDATA.wnd_shape_scale] ; push scale first -> for loop |
; get WinMap start -> ebp |
push eax |
mov eax, [d_width_calc_area + ebx*4] |
add eax, [esp] |
add eax, [_WinMapAddress] |
mov ebp, eax |
mov edi, [edi + APPDATA.wnd_shape] |
pop eax |
; eax = x_start |
; ebx = y_start |
; ecx = x_size |
; edx = y_size |
; esi = process_number |
; edi = &shape |
; [scale] |
push edx ecx ; for loop - x,y size |
mov ecx, esi |
shl ecx, 5 |
mov edx, [window_data + ecx + WDATA.box.top] |
push [window_data + ecx + WDATA.box.width] ; for loop - width |
mov ecx, [window_data + ecx + WDATA.box.left] |
sub ebx, edx |
sub eax, ecx |
push ebx eax ; for loop - x,y |
add [ff_xsz], eax |
add [ff_ysz], ebx |
mov ebx, [ff_y] |
;-------------------------------------- |
align 4 |
.ff_new_y: |
mov edx, [ff_x] |
;-------------------------------------- |
align 4 |
.ff_new_x: |
; -- body -- |
mov ecx, [ff_scale] |
mov eax, [ff_width] |
inc eax |
shr eax, cl |
push ebx edx |
shr ebx, cl |
shr edx, cl |
imul eax, ebx |
add eax, edx |
pop edx ebx |
add eax, edi |
call .read_byte |
test al, al |
jz @f |
mov eax, esi |
mov [ebp], al |
; -- end body -- |
;-------------------------------------- |
align 4 |
@@: |
inc ebp |
inc edx |
cmp edx, [ff_xsz] |
jb .ff_new_x |
sub ebp, [ff_xsz] |
add ebp, [ff_x] |
add ebp, [Screen_Max_X] ; screen.x |
inc ebp |
inc ebx |
cmp ebx, [ff_ysz] |
jb .ff_new_y |
add esp, 24 |
;-------------------------------------- |
align 4 |
.exit: |
popad |
inc [_display.mask_seqno] |
ret |
;-------------------------------------- |
align 4 |
.read_byte: |
; eax - address |
; esi - slot |
push eax ecx edx esi |
xchg eax, esi |
lea ecx, [esp + 12] |
mov edx, 1 |
call read_process_memory |
pop esi edx ecx eax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.window_activate: ;//////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Activate window |
;------------------------------------------------------------------------------ |
;> esi = pointer to WIN_POS+ window data |
;------------------------------------------------------------------------------ |
push eax ebx |
; if type of current active window is 3 or 4, it must be redrawn |
mov ebx, [TASK_COUNT] |
; DEBUGF 1, "K : TASK_COUNT (0x%x)\n", ebx |
movzx ebx, word[WIN_POS + ebx * 2] |
shl ebx, 5 |
add eax, window_data |
mov al, [window_data + ebx + WDATA.fl_wstyle] |
and al, 0x0f |
cmp al, 0x03 |
je .set_window_redraw_flag |
cmp al, 0x04 |
jne .move_others_down |
;-------------------------------------- |
align 4 |
.set_window_redraw_flag: |
mov [window_data + ebx + WDATA.fl_redraw], 1 |
;-------------------------------------- |
align 4 |
.move_others_down: |
; ax <- process no |
movzx ebx, word[esi] |
; ax <- position in window stack |
movzx ebx, word[WIN_STACK + ebx * 2] |
; drop others |
xor eax, eax |
;-------------------------------------- |
align 4 |
.next_stack_window: |
cmp eax, [TASK_COUNT] |
jae .move_self_up |
inc eax |
; push ebx |
; xor ebx,ebx |
; mov bx,[WIN_STACK + eax * 2] |
; DEBUGF 1, "K : DEC WIN_STACK (0x%x)\n",ebx |
; pop ebx |
cmp [WIN_STACK + eax * 2], bx |
jbe .next_stack_window |
dec word[WIN_STACK + eax * 2] |
jmp .next_stack_window |
;-------------------------------------- |
align 4 |
.move_self_up: |
movzx ebx, word[esi] |
; number of processes |
mov ax, [TASK_COUNT] |
; this is the last (and the upper) |
mov [WIN_STACK + ebx * 2], ax |
; update on screen - window stack |
xor eax, eax |
;-------------------------------------- |
align 4 |
.next_window_pos: |
cmp eax, [TASK_COUNT] |
jae .reset_vars |
inc eax |
movzx ebx, word[WIN_STACK + eax * 2] |
mov [WIN_POS + ebx * 2], ax |
jmp .next_window_pos |
;-------------------------------------- |
align 4 |
.reset_vars: |
mov byte[KEY_COUNT], 0 |
mov byte[BTN_COUNT], 0 |
mov word[MOUSE_SCROLL_H], 0 |
mov word[MOUSE_SCROLL_V], 0 |
pop ebx eax |
ret |
;------------------------------------------------------------------------------ |
window._.window_deactivate: ;//////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Deactivate window |
;------------------------------------------------------------------------------ |
;> esi = pointer to WIN_POS+ window data |
;------------------------------------------------------------------------------ |
push eax ebx |
;-------------------------------------- |
align 4 |
.move_others_up: |
; ax <- process no |
movzx ebx, word[esi] |
; ax <- position in window stack |
movzx ebx, word[WIN_STACK + ebx * 2] |
; up others |
xor eax, eax |
;-------------------------------------- |
align 4 |
.next_stack_window: |
cmp eax, [TASK_COUNT] |
jae .move_self_down |
inc eax |
cmp [WIN_STACK + eax * 2], bx |
jae .next_stack_window |
inc word[WIN_STACK + eax * 2] |
jmp .next_stack_window |
;-------------------------------------- |
align 4 |
.move_self_down: |
movzx ebx, word[esi] |
; this is the last (and the low) |
mov [WIN_STACK + ebx * 2], word 1 |
; update on screen - window stack |
xor eax, eax |
;-------------------------------------- |
align 4 |
.next_window_pos: |
cmp eax, [TASK_COUNT] |
jae .reset_vars |
inc eax |
movzx ebx, word[WIN_STACK + eax * 2] |
mov [WIN_POS + ebx * 2], ax |
jmp .next_window_pos |
;-------------------------------------- |
align 4 |
.reset_vars: |
mov byte[KEY_COUNT], 0 |
mov byte[BTN_COUNT], 0 |
mov word[MOUSE_SCROLL_H], 0 |
mov word[MOUSE_SCROLL_V], 0 |
pop ebx eax |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.check_window_draw: ;////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Check if window is necessary to draw |
;------------------------------------------------------------------------------ |
;> edi = pointer to WDATA |
;------------------------------------------------------------------------------ |
mov cl, [edi + WDATA.fl_wstyle] |
and cl, 0x0f |
cmp cl, 3 |
je .exit.redraw ; window type 3 |
cmp cl, 4 |
je .exit.redraw ; window type 4 |
push eax ebx edx esi |
mov eax, edi |
sub eax, window_data |
shr eax, 5 |
movzx eax, word[WIN_STACK + eax * 2] ; get value of the curr process |
lea esi, [WIN_POS + eax * 2] ; get address of this process at 0xC400 |
;-------------------------------------- |
align 4 |
.next_window: |
add esi, 2 |
mov eax, [TASK_COUNT] |
lea eax, word[WIN_POS + eax * 2] ; number of the upper window |
cmp esi, eax |
ja .exit.no_redraw |
movzx edx, word[esi] |
shl edx, 5 |
cmp [CURRENT_TASK + edx + TASKDATA.state], TSTATE_FREE |
je .next_window |
mov eax, [edi + WDATA.box.top] |
mov ebx, [edi + WDATA.box.height] |
add ebx, eax |
mov ecx, [window_data + edx + WDATA.box.top] |
cmp ecx, ebx |
jge .next_window |
add ecx, [window_data + edx + WDATA.box.height] |
cmp eax, ecx |
jge .next_window |
mov eax, [edi + WDATA.box.left] |
mov ebx, [edi + WDATA.box.width] |
add ebx, eax |
mov ecx, [window_data + edx + WDATA.box.left] |
cmp ecx, ebx |
jge .next_window |
add ecx, [window_data + edx + WDATA.box.width] |
cmp eax, ecx |
jge .next_window |
pop esi edx ebx eax |
;-------------------------------------- |
align 4 |
.exit.redraw: |
xor ecx, ecx |
inc ecx |
ret |
;-------------------------------------- |
align 4 |
.exit.no_redraw: |
pop esi edx ebx eax |
xor ecx, ecx |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.draw_window_caption: ;//////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> |
;------------------------------------------------------------------------------ |
xor eax, eax |
mov edx, [TASK_COUNT] |
movzx edx, word[WIN_POS + edx * 2] |
cmp edx, [CURRENT_TASK] |
jne @f |
inc eax |
;-------------------------------------- |
align 4 |
@@: |
mov edx, [CURRENT_TASK] |
shl edx, 5 |
add edx, window_data |
movzx ebx, [edx + WDATA.fl_wstyle] |
and bl, 0x0F |
cmp bl, 3 |
je .draw_caption_style_3 |
cmp bl, 4 |
je .draw_caption_style_3 |
jmp .not_style_3 |
;-------------------------------------- |
align 4 |
.draw_caption_style_3: |
push edx |
call drawwindow_IV_caption |
add esp, 4 |
jmp .2 |
;-------------------------------------- |
align 4 |
.not_style_3: |
cmp bl, 2 |
jne .not_style_2 |
call drawwindow_III_caption |
jmp .2 |
;-------------------------------------- |
align 4 |
.not_style_2: |
cmp bl, 0 |
jne .2 |
call drawwindow_I_caption |
;-------------------------------------- |
align 4 |
.2: |
mov edi, [CURRENT_TASK] |
shl edi, 5 |
test [edi + window_data + WDATA.fl_wstyle], WSTYLE_HASCAPTION |
jz .exit |
mov edx, [edi * 8 + SLOT_BASE + APPDATA.wnd_caption] |
or edx, edx |
jz .exit |
movzx eax, [edi + window_data + WDATA.fl_wstyle] |
and al, 0x0F |
cmp al, 3 |
je .skinned |
cmp al, 4 |
je .skinned |
jmp .not_skinned |
;-------------------------------------- |
align 4 |
.skinned: |
mov ebp, [edi + window_data + WDATA.box.left - 2] |
mov bp, word[edi + window_data + WDATA.box.top] |
movzx eax, word[edi + window_data + WDATA.box.width] |
sub ax, [_skinmargins.left] |
sub ax, [_skinmargins.right] |
push edx |
cwde |
cdq |
mov ebx, 6 |
idiv ebx |
pop edx |
or eax, eax |
js .exit |
mov esi, eax |
mov ebx, dword[_skinmargins.left - 2] |
mov bx, word[_skinh] |
sub bx, [_skinmargins.bottom] |
sub bx, [_skinmargins.top] |
sar bx, 1 |
adc bx, 0 |
add bx, [_skinmargins.top] |
add bx, -3 |
add ebx, ebp |
jmp .dodraw |
;-------------------------------------- |
align 4 |
.not_skinned: |
cmp al, 1 |
je .exit |
mov ebp, [edi + window_data + WDATA.box.left - 2] |
mov bp, word[edi + window_data + WDATA.box.top] |
movzx eax, word[edi + window_data + WDATA.box.width] |
sub eax, 16 |
push edx |
cwde |
cdq |
mov ebx, 6 |
idiv ebx |
pop edx |
or eax, eax |
js .exit |
mov esi, eax |
mov ebx, 0x00080007 |
add ebx, ebp |
;-------------------------------------- |
align 4 |
.dodraw: |
mov ecx, [common_colours + 16] |
or ecx, 0x80000000 |
xor edi, edi |
call dtext_asciiz_esi |
;-------------------------------------- |
align 4 |
.exit: |
; call [draw_pointer] |
call __sys_draw_pointer |
ret |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.draw_negative_box: ;////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Draw negative box |
;------------------------------------------------------------------------------ |
;> edi = pointer to BOX struct |
;------------------------------------------------------------------------------ |
push eax ebx esi |
mov esi, 0x01000000 |
;-------------------------------------- |
align 4 |
.1: |
mov eax, [edi + BOX.left - 2] |
mov ax, word[edi + BOX.left] |
add ax, word[edi + BOX.width] |
mov ebx, [edi + BOX.top - 2] |
mov bx, word[edi + BOX.top] |
add bx, word[edi + BOX.height] |
call draw_rectangle.forced |
pop esi ebx eax |
ret |
;------------------------------------------------------------------------------ |
;align 4 |
;------------------------------------------------------------------------------ |
;window._.end_moving__box: ;////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? Draw positive box |
;------------------------------------------------------------------------------ |
;> edi = pointer to BOX struct |
;------------------------------------------------------------------------------ |
; push eax ebx esi |
; xor esi, esi |
; jmp window._.draw_negative_box.1 |
;------------------------------------------------------------------------------ |
align 4 |
;------------------------------------------------------------------------------ |
window._.get_rect: ;///////////////////////////////////////////////////// |
;------------------------------------------------------------------------------ |
;? <description> void __fastcall get_window_rect(struct RECT* rc); |
;------------------------------------------------------------------------------ |
;> ecx = pointer to RECT |
;------------------------------------------------------------------------------ |
mov eax, [TASK_BASE] |
mov edx, [eax-twdw + WDATA.box.left] |
mov [ecx+RECT.left], edx |
add edx, [eax-twdw + WDATA.box.width] |
mov [ecx+RECT.right], edx |
mov edx, [eax-twdw + WDATA.box.top] |
mov [ecx+RECT.top], edx |
add edx, [eax-twdw + WDATA.box.height] |
mov [ecx+RECT.bottom], edx |
ret |
;------------------------------------------------------------------------------ |