Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 1206 → Rev 1376

/kernel/branches/net/gui/button.inc
3,89 → 3,172
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
$Revision$
 
 
max_buttons=4095
dececx:
push edx
push ecx
button._.MAX_BUTTONS = 4095
 
mov edx,2
.loop:
 
cmp byte [esp+edx],0x20
jae @f
mov [esp+edx],byte 0x20
@@:
sub [esp+edx],byte 0x20
;==============================================================================
;///// public functions ///////////////////////////////////////////////////////
;==============================================================================
 
dec edx
jns .loop
struc SYS_BUTTON
{
.pslot dw ?
.id_lo dw ?
.left dw ?
.width dw ?
.top dw ?
.height dw ?
.id_hi dw ?
.sizeof:
}
virtual at 0
SYS_BUTTON SYS_BUTTON
end virtual
 
pop ecx
pop edx
ret
iglobal
mx dw 0x0 ; keeps the x mouse's position when it was clicked
my dw 0x0 ; keeps the y mouse's position when it was clicked
bPressedMouseXY_B db 0x0
btn_down_determ db 0x0
endg
 
incecx:
push edx
push ecx
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
 
mov edx,2
.loop:
; do we have free button slots available?
mov edi, [BTN_ADDR]
mov eax, [edi]
cmp eax, button._.MAX_BUTTONS
jge .exit
 
cmp byte [esp+edx],0xdf
jbe @f
mov [esp+edx],byte 0xdf
@@:
add [esp+edx],byte 0x20
; does it have positive size? (otherwise it doesn't have sense)
or bx, bx
jle .exit
or cx, cx
jle .exit
 
dec edx
jns .loop
pop ecx
pop edx
ret
; 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
 
incecx2:
push edx
push ecx
; 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
 
mov edx,2
.loop:
; do we also need to draw the button?
test edx, 0x40000000
jnz .exit
 
cmp byte [esp+edx],0xeb
jbe @f
mov [esp+edx],byte 0xeb
@@:
add [esp+edx],byte 0x14
; draw button body
 
dec edx
jns .loop
pop ecx
pop edx
ret
pushad
 
drawbuttonframes:
; 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
 
push esi
; 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
push eax
push ebx
push ecx
push edx
xor edi, edi
call [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, word [esp+8]
add ax, [esp + 4]
mov ebx, ecx
shl ebx, 16
mov bx, cx
92,17 → 175,19
push ebx
xor edi, edi
mov ecx, esi
call incecx
call button._.incecx
call [draw_line]
 
movzx edx,word [esp+4+4]
; bottom border
movzx edx, word[esp + 4 + 0]
add ebx,edx
shl edx,16
add ebx,edx
mov ecx,esi
call dececx
call button._.dececx
call [draw_line]
 
; left border
pop ebx
push edx
mov edx,eax
111,342 → 196,92
mov edx,ebx
shr edx,16
mov bx,dx
mov dx,[esp+4+4]
add bx,dx
add bx, [esp + 4 + 0]
pop edx
mov ecx,esi
call incecx
call button._.incecx
call [draw_line]
 
mov dx,[esp+8]
; right border
mov dx, [esp + 4]
add ax,dx
shl edx,16
add eax,edx
add ebx,1*65536
add ebx, 0x00010000
mov ecx,esi
call dececx
call button._.dececx
call [draw_line]
 
pop edx
pop ecx
pop ebx
pop eax
pop edi
pop esi
pop ecx ebx
 
.exit:
ret
 
button_dececx:
 
cmp [buttontype],dword 1
jne .finish
; je bdece
; ret
; bdece:
push eax
mov eax,0x01
cmp edi,20
jg @f
mov eax,0x02
@@:
test ecx,0xff
jz @f
sub ecx,eax
@@:
shl eax,8
test ecx,0xff00
jz @f
sub ecx,eax
@@:
shl eax,8
test ecx,0xff0000
jz @f
sub ecx,eax
@@:
pop eax
.finish:
ret
 
 
sys_button:
 
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
.forced:
 
test edx, 0x80000000
jnz remove_button
 
or bx, bx
jle noaddbutt
or cx, cx
jle noaddbutt
 
test edx, 0x40000000
jnz button_no_draw
 
pushad ; button body
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
mov ecx, esi
cmp [buttontype], 0
je @f
call incecx2
@@:
mov edx, edi
 
.newline:
call button_dececx
push edi
xor edi, edi
call [draw_line]
pop edi
add ebx, 1*65536+1 ; [ y start | y end ]
dec edx
jnz .newline
popad
 
call drawbuttonframes
 
button_no_draw:
 
; FIXME: mutex needed
syscall_button.remove_button:
and edx, 0x00ffffff
mov edi, [BTN_ADDR]
movzx eax, word [edi]
cmp eax, max_buttons
jge noaddbutt
inc eax
mov [edi], ax
 
shl eax, 4
add edi, eax
 
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
 
noaddbutt:
 
ret
 
 
remove_button:
 
and edx, 0x7fffffff
 
rnewba2:
 
mov edi, [BTN_ADDR]
mov eax, edi
movzx ebx, word [edi]
mov ebx, [edi]
inc ebx
imul esi, ebx, SYS_BUTTON.sizeof
add esi, edi
xor ecx, ecx
add ecx, -SYS_BUTTON.sizeof
 
rnewba:
 
.next_button:
dec ebx
jz rnmba
jz .exit
 
add eax, 0x10
add ecx, SYS_BUTTON.sizeof
add esi, -SYS_BUTTON.sizeof
 
mov cx, [CURRENT_TASK]
cmp cx, [eax]
jnz rnewba
cmp dx, [eax+2]
jnz rnewba
; does it belong to our process?
mov ax, [CURRENT_TASK]
cmp ax, [esi + SYS_BUTTON.pslot]
jne .next_button
 
lea ecx, [ebx+1]
shl ecx, 4
mov ebx, eax
add eax, 0x10
; 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 + SYS_BUTTON.sizeof]
call memmove
dec dword [edi]
jmp rnewba2
add ecx, -SYS_BUTTON.sizeof
pop ebx
jmp .next_button
 
rnmba:
 
.exit:
ret
 
find_pressed_button_frames:
 
pushad
 
movzx ebx,word [eax+0]
shl ebx,5
add ebx,window_data
mov ecx, [ebx+ WDATA.box.left] ; window x start
movzx edx,word [eax+4] ; button x start
add ecx,edx
push ecx
 
mov dx,[eax+6] ; button x size
add cx,dx
mov esi,ecx
inc esi
mov ecx, [ebx+WDATA.box.top] ; window y start
mov dx,[eax+8] ; button y start
add ecx,edx
mov ebx,ecx
mov dx,[eax+10] ; button y size
add dx,cx
inc dx
 
pop eax
 
; eax x beginning
; ebx y beginning
; esi x end
; edx y end
; ecx color
 
mov [pressed_button_eax],eax
mov [pressed_button_ebx],ebx
mov [pressed_button_ecx],ecx
mov [pressed_button_edx],edx
mov [pressed_button_esi],esi
 
popad
ret
 
uglobal
pressed_button_eax dd 0
pressed_button_ebx dd 0
pressed_button_ecx dd 0
pressed_button_edx dd 0
pressed_button_esi dd 0
endg
 
; negative button image
 
negativebutton:
; If requested, do not display button
; boarder on press.
test ebx,0x20000000
jz draw_negative_button
ret
draw_negative_button:
 
pushad
 
mov eax,[pressed_button_eax]
mov ebx,[pressed_button_ebx]
mov ecx,[pressed_button_ecx]
mov edx,[pressed_button_edx]
mov esi,[pressed_button_esi]
mov ecx,0x01000000
 
dec edx
push edx
inc edx
dec esi
push esi
inc esi
 
push eax
push ebx
push ecx
push edx
push edi
 
call [disable_mouse]
 
bdbnewline:
mov edi,1 ; force
cmp eax,[esp+16]
jz bneg
cmp eax,[esp+20]
jz bneg
cmp ebx,[esp+12]
jz bneg
cmp ebx,[esp+24]
jnz nbneg
; jz bneg
; jmp nbneg
 
bneg:
 
;;;call [disable_mouse]
call [putpixel]
 
nbneg:
 
inc eax
cmp eax,esi
jnz bdbnewline
mov eax,[esp+16]
inc ebx
cmp ebx,edx
jnz bdbnewline
 
add esp,28
 
popad
 
ret
 
; check buttons
 
 
; 0000 word process number
; 0002 word button id number : bits 0-15
; 0004 word x start
; 0006 word x size
; 0008 word y start
; 000A word y size
; 000C word button id number : bits 16-31
;
; button table in 0x10 increments
;
; first at 0x10
 
align 4
checkbuttons:
 
cmp [BTN_DOWN],byte 0 ; mouse buttons pressed
;------------------------------------------------------------------------------
check_buttons: ;///////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
cmp byte[BTN_DOWN], 0 ; mouse buttons pressed
jnz @f
;..................................... start 1/5 : modified by vhanla .............................
mov [bPressedMouseXY_B],0
;..................................... end 1/5 : modified by vhanla .............................
ret
@@:
pushad
 
@@: pushad
xor esi, esi
mov edi, [BTN_ADDR]
movzx edx, word [edi]
mov edx, [edi]
test edx, edx
jne @f
popad
ret
 
@@:
;..................................... start 2/5 : modified by vhanla .............................
;here i catch the coordinates when the mouse's button is clicked
push ax
@@: push ax
cmp [bPressedMouseXY_B],0;FALSE
jnz @f
mov [bPressedMouseXY_B],1;TRUE - it was already clicked
454,28 → 289,24
mov [mx],ax
mov ax,[MOUSE_Y]
mov [my],ax
@@:
pop ax
@@: pop ax
;and it is only refreshed after the mouse's button release
;..................................... end 2/5 : modified by vhanla .............................
 
push esi
inc edx
push edx
 
buttonnewcheck:
 
.buttonnewcheck:
pop edx
pop esi
inc esi
cmp edx,esi
jge bch
jge .bch
 
popad ; no button pressed
popad
ret
 
bch:
 
.bch:
push esi
push edx
mov eax,esi
483,67 → 314,56
add eax,edi
 
; check that button is at top of windowing stack
 
movzx ebx,word [eax]
movzx ebx, [eax + SYS_BUTTON.pslot]
movzx ecx,word [WIN_STACK + ebx * 2]
cmp ecx,[TASK_COUNT]
jne buttonnewcheck
jne .buttonnewcheck
 
; check that button start is inside window x/y end
 
movzx ebx,word [eax+0]
shl ebx,5
 
test [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED
jnz buttonnewcheck
jnz .buttonnewcheck
 
; add ebx,window_data
; mov ecx,[window_data+ebx+8] ; window end X
movzx edx,word [eax+4] ; button start X
movzx edx, [eax + SYS_BUTTON.left]
cmp edx, [window_data+ebx+WDATA.box.width] ;ecx
jge buttonnewcheck
jge .buttonnewcheck
 
; mov ecx,[window_data+ebx+12] ; window end Y
movzx edx, word [eax+8] ; button start Y
movzx edx, [eax + SYS_BUTTON.top]
cmp edx, [window_data+ebx+WDATA.box.height] ;ecx
jge buttonnewcheck
jge .buttonnewcheck
 
; check coordinates
 
; mouse x >= button x ?
movzx ebx,word [eax+0]
shl ebx,5
add ebx,window_data
mov ecx, [ebx+WDATA.box.left] ; window x start
movzx edx,word [eax+4] ; button x start
mov ecx, [ebx + WDATA.box.left]
movzx edx, [eax + SYS_BUTTON.left]
add edx,ecx
;..................................... start 3/5 : modified by vhanla .............................
mov cx,[mx] ;mov cx,[MOUSE_X]
;..................................... end 3/5 : modified by vhanla .............................
cmp edx,ecx
jg buttonnewcheck
jg .buttonnewcheck
 
movzx ebx,word [eax+6] ; button x size
movzx ebx, [eax + SYS_BUTTON.width]
add edx,ebx
cmp ecx,edx
jg buttonnewcheck
jg .buttonnewcheck
 
; mouse y >= button y ?
movzx ebx,word [eax+0]
movzx ebx, [eax + SYS_BUTTON.pslot]
shl ebx,5
add ebx,window_data
mov ecx, [ebx+WDATA.box.top] ; window y start
movzx edx,word [eax+8] ; button y start
mov ecx, [ebx + WDATA.box.top]
movzx edx, [eax + SYS_BUTTON.top]
add edx,ecx
;..................................... start 4/5 : modified by vhanla .............................
mov cx,[my] ;mov cx,[MOUSE_Y]
;..................................... start 4/5 : modified by vhanla .............................
cmp edx,ecx
jg buttonnewcheck
jg .buttonnewcheck
 
movzx ebx,word [eax+10] ; button y size
movzx ebx, [eax + SYS_BUTTON.height]
add edx,ebx
cmp ecx,edx
jg buttonnewcheck
jg .buttonnewcheck
 
; mouse on button
 
550,27 → 370,21
pop edx
pop esi
 
mov bx,[eax+0xc] ; button id : bits 16-31
shl ebx,16
mov bx,[eax+2] ; button id : bits 00-16
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] ; button id : bits 16-31
mov bx, [eax + SYS_BUTTON.id_lo] ; button id : bits 00-16
push ebx
 
mov [MOUSE_DOWN],byte 1 ; no mouse down checks
call find_pressed_button_frames
call negativebutton
mov byte[MOUSE_DOWN], 1 ; no mouse down checks
call button._.negative_button
 
pushad
; // Alver 22.06.2008 // {
push eax
mov al, byte [BTN_DOWN]
mov al, [BTN_DOWN]
mov byte [btn_down_determ], al
pop eax
; } \\ Alver \\
 
cbwaitmouseup:
 
.cbwaitmouseup:
call checkidle
 
call [draw_pointer]
 
pushad
577,68 → 391,189
call stack_handler
popad
 
cmp [BTN_DOWN],byte 0 ; mouse buttons pressed ?
jnz cbwaitmouseup
cmp byte[BTN_DOWN], 0 ; mouse buttons pressed ?
jnz .cbwaitmouseup
popad
 
call negativebutton
mov [MOUSE_BACKGROUND],byte 0 ; no mouse background
mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse
;..................................... start 5/5 : modified by vhanla .............................
call button._.negative_button
mov byte[MOUSE_BACKGROUND], 0 ; no mouse background
mov byte[DONT_DRAW_MOUSE], 0 ; draw mouse
 
; check coordinates
iglobal
mx dw 0x0 ; keeps the x mouse's position when it was clicked
my dw 0x0 ; keeps the y mouse's position when it was clicked
bPressedMouseXY_B db 0x0
btn_down_determ db 0x0 ; << // Alver 22.06.2008// <<
endg
pusha
 
pusha
; mouse x >= button x ?
movzx ebx,word [eax+0]
movzx ebx, [eax + SYS_BUTTON.pslot]
shl ebx,5
add ebx,window_data
mov ecx, [ebx+WDATA.box.left] ; window x start
movzx edx,word [eax+4] ; button x start
mov ecx, [ebx + WDATA.box.left]
movzx edx, [eax + SYS_BUTTON.left]
add edx,ecx
mov cx,[MOUSE_X]
cmp edx,ecx
jg no_on_button ;if we release the pointer out of the button area
jg .no_on_button ;if we release the pointer out of the button area
 
movzx ebx,word [eax+6] ; button x size
movzx ebx, [eax + SYS_BUTTON.width]
add edx,ebx
cmp ecx,edx
jg no_on_button
jg .no_on_button
 
; mouse y >= button y ?
movzx ebx,word [eax+0]
movzx ebx, [eax + SYS_BUTTON.pslot]
shl ebx,5
add ebx,window_data
mov ecx, [ebx+WDATA.box.top] ; window y start
movzx edx,word [eax+8] ; button y start
mov ecx, [ebx + WDATA.box.top]
movzx edx, [eax + SYS_BUTTON.top]
add edx,ecx
mov cx,[MOUSE_Y]
cmp edx,ecx
jg no_on_button
jg .no_on_button
 
movzx ebx,word [eax+10] ; button y size
movzx ebx, [eax + SYS_BUTTON.height]
add edx,ebx
cmp ecx,edx
jg no_on_button
jg .no_on_button
 
popa
mov [BTN_COUNT],byte 1 ; no of buttons in buffer
 
mov byte[BTN_COUNT], 1 ; no of buttons in buffer
pop ebx
mov [BTN_BUFF],ebx ; lets put the button id in buffer
push ebx
pusha
jmp yes_on_button
no_on_button:
mov [BTN_COUNT],byte 0 ; no of buttons in buffer
yes_on_button:
mov [MOUSE_DOWN],byte 0 ; mouse down -> do not draw
jmp .yes_on_button
 
.no_on_button:
mov byte[BTN_COUNT], 0 ; no of buttons in buffer
 
.yes_on_button:
mov byte[MOUSE_DOWN], 0 ; mouse down -> do not draw
popa
pop ebx
popa
ret
 
;..................................... end 5/5 : modified by vhanla ................................
;==============================================================================
;///// private functions //////////////////////////////////////////////////////
;==============================================================================
 
;------------------------------------------------------------------------------
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: ;////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
; 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
Property changes:
Added: svn:eol-style
+native
\ No newline at end of property
Modified: svn:keywords
-Revision
\ No newline at end of property
+Rev
\ No newline at end of property
Added: svn:mergeinfo
/kernel/branches/net/gui/event.inc
Property changes:
Modified: svn:keywords
-Revision
\ No newline at end of property
+Rev
\ No newline at end of property
Added: svn:mergeinfo
/kernel/branches/net/gui/font.inc
33,7 → 33,7
.1:
; } \\ Alver \\
pushad
call [disable_mouse]
call [_display.disable_mouse]
 
movsx eax, bx ; eax=y
sar ebx, 16 ; ebx=x
Property changes:
Modified: svn:keywords
-Revision
\ No newline at end of property
+Rev
\ No newline at end of property
Added: svn:mergeinfo
/kernel/branches/net/gui/mouse.inc
Property changes:
Modified: svn:keywords
-Revision
\ No newline at end of property
+Rev
\ No newline at end of property
Added: svn:mergeinfo
/kernel/branches/net/gui/skincode.inc
311,7 → 311,6
; shr esi,1
; and esi,0x007f7f7f
mov esi,[ebp+SKIN_DATA.colors.outer]
or [edi+WDATA.fl_wdrawn], 4
call draw_rectangle
mov ecx,3
_dw3l:
455,12 → 454,6
 
no_skin_add_button:
pop edi
and [edi+WDATA.fl_wdrawn], not 4
test [edi+WDATA.fl_wdrawn], 2
jz @f
call drawwindowframes2
@@:
 
popa
 
ret 4
Property changes:
Modified: svn:keywords
-Revision
\ No newline at end of property
+Rev
\ No newline at end of property
Added: svn:mergeinfo
/kernel/branches/net/gui/skindata.inc
Property changes:
Modified: svn:keywords
-Revision
\ No newline at end of property
+Rev
\ No newline at end of property
Added: svn:mergeinfo
/kernel/branches/net/gui/window.inc
9,658 → 9,606
$Revision$
 
 
get_titlebar_height: ; edi = window draw_data pointer
mov al,[edi+WDATA.fl_wstyle]
and al,0x0F
cmp al,0x03
jne @f
mov eax,[_skinh]
;==============================================================================
;///// public functions ///////////////////////////////////////////////////////
;==============================================================================
 
macro FuncTable name, [label]
{
common
align 4
\label name#.ftable dword
forward
dd name#.#label
common
name#.sizeof.ftable = $ - name#.ftable
}
 
iglobal
FuncTable syscall_display_settings, \
00, 01, 02, 03, 04, 05, 06, 07, 08
endg
 
uglobal
common_colours rd 32
new_window_starting dd ?
latest_window_touch dd ?
latest_window_touch_delta dd ?
old_window_pos BOX
new_window_pos BOX
draw_limits RECT
bPressedMouseXY_W db ?
do_resize db ?
do_resize_from_corner db ?
reposition db ?
endg
 
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]
@@: 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
 
.exit:
ret
@@: mov eax,21
 
align 4
syscall_display_settings.01:
and ecx, 1
cmp ecx, [buttontype]
je .exit
mov [buttontype], ecx
mov [windowtypechanged], ebx
 
.exit:
ret
 
get_rolledup_height: ; edi = window draw_data pointer
mov al,[edi+WDATA.fl_wstyle]
and al,0x0F
cmp al,0x03
jb @f
mov eax,[_skinh]
add eax,3
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
@@: or al,al
jnz @f
mov eax,21
 
align 4
syscall_display_settings.03:
mov edi, ecx
and edx, 127
mov esi, common_colours
mov ecx, edx
rep movsb
ret
@@: mov eax,21+2
 
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
 
setwindowdefaults:
pushad
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
mov ecx,WIN_STACK
@@:
inc eax
add ecx,2
mov [ecx+0x000],ax ; process no
mov [ecx+0x400],ax ; positions in stack
cmp ecx,WIN_POS-2 ; the more high, the more surface
jnz @b
@@: mov [screen_workarea.left], eax
cmp ebx, edi
jle @f
mov ebx, edi
@@: mov [screen_workarea.right], ebx
 
popad
.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
@@: mov [screen_workarea.top], eax
cmp ebx, edi
jle @f
mov ebx, edi
@@: mov [screen_workarea.bottom], ebx
 
.check_if_redraw_needed:
or esi, esi
jz .exit
 
call repos_windows
jmp syscall_display_settings._.calculate_whole_screen
 
.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
 
; eax = cx
; ebx = cy
; ecx = ex
; edx = ey
; èäåÿ: ïåðåáðàòü âñå îêíà, íà÷èíàÿ ñ ñàìîãî íèæíåãî,
; è äëÿ ïîïàâøèõ â çàäàííóþ îáëàñòü
; ÷àñòåé îêîí âûçâàòü setscreen
call syscall_display_settings._.calculate_whole_screen
jmp syscall_display_settings._.redraw_whole_screen
 
.exit:
ret
 
syscall_display_settings._.calculate_whole_screen:
xor eax, eax
xor ebx, ebx
mov ecx, [Screen_Max_X]
mov edx, [Screen_Max_Y]
jmp calculatescreen
 
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
calculatescreen:
pushad
;------------------------------------------------------------------------------
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
 
.shape_scale:
dec ebx
jnz .exit
mov [edi + APPDATA.wnd_shape_scale], ecx
 
.exit:
ret
 
align 4
;------------------------------------------------------------------------------
set_window_defaults: ;/////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
push eax ecx
xor eax, eax
mov ecx, WIN_STACK
@@: 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
 
push edx ecx ebx eax
 
mov esi, 1
call setscreen
call window._.set_screen
 
mov ebp, [TASK_COUNT] ; number of processes
push ebp
 
mov ebp, [TASK_COUNT]
cmp ebp, 1
jbe .finish
align 4
.new_wnd:
jbe .exit
 
push edx ecx ebx eax
 
.next_window:
movzx edi, word [WIN_POS + esi * 2]
shl edi, 5
 
cmp [CURRENT_TASK+edi+TASKDATA.state], byte 9
je .not_wnd
cmp [CURRENT_TASK + edi + TASKDATA.state], TSTATE_FREE
je .skip_window
 
add edi, window_data
test [edi+WDATA.fl_wstate], WSTATE_MINIMIZED
jnz .not_wnd
jnz .skip_window
 
mov eax,[edi+WDATA.box.left]
cmp eax, [esp+RECT.right]
ja .out_of_bounds
jg .skip_window
mov ebx,[edi+WDATA.box.top]
cmp ebx, [esp+RECT.bottom]
ja .out_of_bounds
jg .skip_window
mov ecx,[edi+WDATA.box.width]
add ecx, eax
cmp ecx, [esp+RECT.left]
jb .out_of_bounds
jl .skip_window
mov edx,[edi+WDATA.box.height]
add edx, ebx
cmp edx, [esp+RECT.top]
jb .out_of_bounds
jl .skip_window
 
cmp eax, [esp+RECT.left]
jae @f
mov eax, [esp+RECT.left]
@@:
cmp ebx, [esp+RECT.top]
@@: cmp ebx, [esp + RECT.top]
jae @f
mov ebx, [esp+RECT.top]
@@:
cmp ecx, [esp+RECT.right]
@@: cmp ecx, [esp + RECT.right]
jbe @f
mov ecx, [esp+RECT.right]
@@:
cmp edx, [esp+RECT.bottom]
@@: cmp edx, [esp + RECT.bottom]
jbe @f
mov edx, [esp+RECT.bottom]
@@:
 
push esi
@@: push esi
movzx esi, word [WIN_POS + esi * 2]
call setscreen
call window._.set_screen
pop esi
 
.not_wnd:
.out_of_bounds:
.skip_window:
inc esi
dec ebp
jnz .new_wnd
.finish:
jnz .next_window
 
pop eax ebx ecx edx
 
.exit:
pop ebp
popfd
popad
pop esi
ret
 
 
 
virtual at esp
ff_x dd ?
ff_y dd ?
ff_width dd ?
ff_xsz dd ?
ff_ysz dd ?
ff_scale dd ?
end virtual
 
align 4
; ðåçåðâèðóåò ìåñòî ïîä îêíî çàäàííîãî ïðîöåññà
setscreen:
; eax x start
; ebx y start
; ecx x end
; edx y end
; esi process number
pushad
; \begin{diamond}[29.08.2006]
cmp esi, 1
jz @f
mov edi, esi
shl edi, 5
cmp [edi+window_data+WDATA.box.width], 0
jnz @f
cmp [edi+window_data+WDATA.box.height], 0
jz .ret
@@:
; \end{diamond}[29.08.2006]
mov edi, esi ;;;word [esi*2+WIN_POS]
shl edi, 8
add edi, SLOT_BASE ; address of random shaped window area
cmp [edi+APPDATA.wnd_shape], dword 0
jne .free_form
 
; get x&y size
sub ecx, eax
sub edx, ebx
inc ecx
inc edx
 
; get WinMap start
mov edi, [Screen_Max_X] ; screen_sx
inc edi
imul edi, ebx
add edi, eax
add edi, WinMapAddress
 
.new_y:
push ecx ; sx
push edx
 
mov edx, esi
align 4
.new_x:
mov byte [edi], dl
inc edi
dec ecx
jnz .new_x
 
pop edx
pop ecx
add edi, [Screen_Max_X]
inc edi
sub edi, ecx
dec edx
jnz .new_y
.ret:
popad
ret
.read_byte:
;eax - address
;esi - slot
push eax
push ebx
push ecx
push edx
mov edx,eax
mov eax,esi
lea ebx,[esp+12]
mov ecx,1
call read_process_memory
pop edx
pop ecx
pop ebx
pop eax
ret
.free_form:
 
; 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 dword [edi+APPDATA.wnd_shape_scale] ; push scale first -> for loop
 
; get WinMap start -> ebp
push eax
mov eax, [Screen_Max_X] ; screen_sx
inc eax
imul eax, ebx
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]
 
.ff_new_y:
mov edx, [ff_x]
 
.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 --
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
popad
ret
 
 
display_settings:
 
; eax = 0 ; DISPLAY redraw
; ebx = 0 ; all
;
; eax = 1 ; BUTTON type
; ebx = 0 ; flat
; ebx = 1 ; 3D
; eax = 2 ; set WINDOW colours
; ebx = pointer to table
; ecx = number of bytes define
; eax = 3 ; get WINDOW colours
; ebx = pointer to table
; ecx = number of bytes wanted
; eax = 4 ; get skin height
; input : nothing
; output : eax = skin height in pixel
; eax = 5 ; get screen workarea
; input : nothing
; output : eax = [left]*65536+[right]
; ebx = [top]*65536+[bottom]
; eax = 6 ; set screen workarea
; input : ecx = [left]*65536+[right]
; edx = [top]*65536+[bottom]
; output : nothing
; eax = 7 ; get skin margins
; input : nothing
; output : eax = [left]*65536+[right]
; ebx = [top]*65536+[bottom]
; eax = 8 ; set window skin
; input : ecx = pointer to file info block
; output : eax = FS error code
 
 
pushad
 
test eax, eax ; redraw display
jnz dspl0
test ebx, ebx
jnz dspl0
cmp [windowtypechanged],dword 1
jne dspl00
mov [windowtypechanged],dword 0
redraw_screen_direct:
mov [dlx],dword 0
mov [dly],dword 0
mov eax,[Screen_Max_X]
mov [dlxe],eax
mov eax,[Screen_Max_Y]
mov [dlye],eax
mov eax,window_data
call redrawscreen
dspl00:
popad
ret
dspl0:
 
cmp eax,1 ; button type
jne dspl1
and ebx,1
cmp ebx,[buttontype]
je dspl9
mov [buttontype],ebx
mov [windowtypechanged],dword 1
dspl9:
popad
ret
dspl1:
 
cmp eax,2 ; set common window colours
jne no_com_colours
mov [windowtypechanged],dword 1
mov esi,[TASK_BASE]
add esi,TASKDATA.mem_start
add ebx,[esi]
mov esi,ebx
mov edi,common_colours
and ecx,127
cld
rep movsb
popad
ret
no_com_colours:
 
cmp eax,3 ; get common window colours
jne no_get_com
mov esi,[TASK_BASE]
add esi,TASKDATA.mem_start
add ebx,[esi]
mov edi,ebx
mov esi,common_colours
and ecx,127
cld
rep movsb
popad
ret
no_get_com:
 
cmp eax,4 ; get skin height
jne no_skin_height
popad
mov eax,[_skinh]
mov [esp+36],eax
ret
no_skin_height:
 
cmp eax,5 ; get screen workarea
jne no_get_workarea
popad
mov eax,[screen_workarea.left-2]
mov ax,word[screen_workarea.right]
mov [esp+36],eax
mov eax,[screen_workarea.top-2]
mov ax,word[screen_workarea.bottom]
mov [esp+24],eax
ret
no_get_workarea:
 
cmp eax,6 ; set screen workarea
jne no_set_workarea
movsx eax,word[esp+16+2]
movsx ebx,word[esp+16]
cmp eax,ebx
jge .lp1
or eax,eax;[Screen_Max_X]
jl @f
mov [screen_workarea.left],eax
@@: cmp ebx,[Screen_Max_X]
jg .lp1
mov [screen_workarea.right],ebx
.lp1: movsx eax,word[esp+24+2]
movsx ebx,word[esp+24]
cmp eax,ebx
jge .lp2
or eax,eax;[0xFE04]
jl @f
mov [screen_workarea.top],eax
@@: cmp ebx,[Screen_Max_Y]
jg .lp2
mov [screen_workarea.bottom],ebx
.lp2: call repos_windows
mov eax, 0
mov ebx, 0
mov ecx, [Screen_Max_X]
mov edx, [Screen_Max_Y]
call calculatescreen
; jmp redraw_screen_direct
.exit:
popad
ret
no_set_workarea:
 
cmp eax,7 ; get skin margins
jne no_get_skinmargins
popad
mov eax,dword[_skinmargins+0]
mov [esp+36],eax
mov eax,dword[_skinmargins+4]
mov [esp+24],eax
ret
no_get_skinmargins:
 
cmp eax,8 ; set window skin
jne no_set_skin
call read_skin_file
mov [esp+32+36], eax
test eax, eax
jnz .ret
xor eax, eax
xor ebx, ebx
mov ecx, [Screen_Max_X]
mov edx, [Screen_Max_Y]
call calculatescreen
jmp redraw_screen_direct
.ret:
popad
ret
no_set_skin:
 
popad
ret
 
 
repos_windows:
;------------------------------------------------------------------------------
repos_windows: ;///////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
mov ecx,[TASK_COUNT]
mov edi, OS_BASE+0x20*2
mov edi, window_data + WDATA.sizeof * 2
call force_redraw_background
dec ecx
jge @f
ret
@@: mov [edi+WDATA.fl_redraw],1
jle .exit
 
.next_window:
mov [edi + WDATA.fl_redraw], 1
test [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
jz .lp2
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 .lp1
sub eax,[screen_workarea.bottom]
neg eax
mov [edi+WDATA.box.height],eax
.lp1:
jnz .fix_maximized
 
call set_window_clientbox
add edi,0x20
loop @b
ret
.lp2: mov eax,[edi+WDATA.box.left]
mov eax, [edi + WDATA.box.left]
add eax,[edi+WDATA.box.width]
mov ebx,[Screen_Max_X]
; inc ebx
cmp eax,ebx
jle .lp4
jle .fix_vertical
mov eax,[edi+WDATA.box.width]
sub eax,ebx
jle .lp3
jle @f
mov [edi+WDATA.box.width],ebx
.lp3: sub ebx,[edi+WDATA.box.width]
@@: sub ebx, [edi + WDATA.box.width]
mov [edi+WDATA.box.left],ebx
.lp4: mov eax,[edi+WDATA.box.top]
 
.fix_vertical:
mov eax, [edi + WDATA.box.top]
add eax,[edi+WDATA.box.height]
mov ebx,[Screen_Max_Y]
; inc ebx
cmp eax,ebx
jle .lp6
jle .fix_client_box
mov eax,[edi+WDATA.box.height]
sub eax,ebx
jle .lp5
jle @f
mov [edi+WDATA.box.height],ebx
.lp5: sub ebx,[edi+WDATA.box.height]
@@: sub ebx, [edi + WDATA.box.height]
mov [edi+WDATA.box.top],ebx
.lp6: jmp .lp1
jmp .fix_client_box
 
uglobal
common_colours:
times 128 db 0x0
endg
.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
 
.fix_client_box:
call set_window_clientbox
 
add edi, WDATA.sizeof
loop .next_window
 
.exit:
ret
 
check_window_position:
align 4
;------------------------------------------------------------------------------
check_window_position: ;///////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Check if window is inside screen area
;------------------------------------------------------------------------------
;> edi = pointer to WDATA
;------------------------------------------------------------------------------
push eax ebx ecx edx esi
 
pushad ; window inside screen ?
 
mov eax, [edi+WDATA.box.left]
mov ebx, [edi+WDATA.box.top]
mov ecx, [edi+WDATA.box.width]
mov edx, [edi+WDATA.box.height]
 
cmp ecx,[Screen_Max_X] ; check x size
jbe x_size_ok
mov ecx,[Screen_Max_X]
mov [edi+WDATA.box.width],ecx
mov esi, [Screen_Max_X]
cmp ecx, esi
ja .fix_width
 
x_size_ok:
.check_left:
or eax, eax
jl .fix_left_low
add eax, ecx
cmp eax, esi
jg .fix_left_high
 
cmp edx,[Screen_Max_Y] ; check y size
jbe y_size_ok
mov edx,[Screen_Max_Y]
mov [edi+WDATA.box.height],edx
.check_height:
mov esi, [Screen_Max_Y]
cmp edx, esi
ja .fix_height
 
y_size_ok:
.check_top:
or ebx, ebx
jl .fix_top_low
add ebx, edx
cmp ebx, esi
jg .fix_top_high
 
cmp eax,0 ; check x pos
jnle @f
.exit:
pop esi edx ecx ebx eax
ret
 
.fix_width:
mov ecx, esi
mov [edi + WDATA.box.width], esi
jmp .check_left
 
.fix_left_low:
xor eax,eax
mov [edi+WDATA.box.left],eax
jmp x_pos_ok
@@:
add eax,ecx
cmp eax,[Screen_Max_X]
jbe x_pos_ok
mov eax,[Screen_Max_X]
jmp .check_height
 
.fix_left_high:
mov eax, esi
sub eax,ecx
mov [edi+WDATA.box.left],eax
jmp .check_height
 
x_pos_ok:
.fix_height:
mov edx, esi
mov [edi + WDATA.box.height], esi
jmp .check_top
 
cmp ebx,0 ; check x pos
jnle @f
.fix_top_low:
xor ebx,ebx
mov [edi+WDATA.box.top],ebx
jmp y_pos_ok
@@:
add ebx,edx
cmp ebx,[Screen_Max_Y]
jbe y_pos_ok
mov ebx,[Screen_Max_Y]
jmp .exit
 
.fix_top_high:
mov ebx, esi
sub ebx,edx
mov [edi+WDATA.box.top],ebx
jmp .exit
 
y_pos_ok:
align 4
;------------------------------------------------------------------------------
sys_window_mouse: ;////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
push eax
 
popad
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
;------------------------------------------------------------------------------
push eax ebx ecx edi
 
uglobal
new_window_starting dd 0
endg
xor edi, edi
 
.flags_set:
push ebx
 
sys_window_mouse:
; set line color
mov ecx, esi
 
push eax
; draw top border
rol ebx, 16
push ebx
rol ebx, 16
pop bx
call [draw_line]
 
mov eax,[timer_ticks]
cmp [new_window_starting],eax
jb swml1
; draw bottom border
mov ebx, [esp - 2]
pop bx
call [draw_line]
 
mov [MOUSE_BACKGROUND],byte 0 ; no mouse background
mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse
pop ebx
add ebx, 1 * 65536 - 1
 
mov [new_window_starting],eax
; draw left border
rol eax, 16
push eax
rol eax, 16
pop ax
call [draw_line]
 
swml1:
; draw right border
mov eax, [esp - 2]
pop ax
call [draw_line]
 
pop eax
 
pop edi ecx ebx eax
ret
 
.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
 
 
drawwindow_I_caption:
 
mov ecx,[edx+WDATA.cl_titlebar] ; grab bar
push ecx
mov esi,edx
mov edx,[esi+WDATA.box.top]
add edx,1
mov ebx,[esi+WDATA.box.top]
add ebx,21
mov eax,[esi+WDATA.box.top]
mov eax, edx
lea ebx, [edx + 21]
inc edx
add eax,[esi+WDATA.box.height]
 
cmp ebx,eax
jb .wdsizeok
jbe @f
mov ebx,eax
.wdsizeok:
push ebx
.drwi:
@@: push ebx
 
xor edi, edi
 
.next_line:
mov ebx,edx
shl ebx,16
add ebx,edx
669,126 → 617,79
shl eax,16
add eax,[esi+WDATA.box.left]
add eax,[esi+WDATA.box.width]
sub eax,1
push edx
mov edx,0x80000000
dec eax
mov ecx,[esi+WDATA.cl_titlebar]
and ecx,edx
cmp ecx,edx
jnz .nofa
mov ecx,[esi+WDATA.cl_titlebar]
test ecx, 0x80000000
jz @f
sub ecx,0x00040404
mov [esi+WDATA.cl_titlebar],ecx
and ecx,0x00ffffff
jmp .faj
.nofa:
mov ecx,[esi+WDATA.cl_titlebar]
and ecx,0x00ffffff
.faj:
pop edx
mov edi,0
@@: and ecx, 0x00ffffff
call [draw_line]
inc edx
cmp edx,[esp]
jb .drwi
jb .next_line
 
add esp,4
pop ecx
mov [esi+WDATA.cl_titlebar],ecx
 
pop [esi + WDATA.cl_titlebar]
ret
 
align 4
;------------------------------------------------------------------------------
drawwindow_I: ;////////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
pushad
 
drawwindow_I:
; window border
 
pushad
or [edx+WDATA.fl_wdrawn], 4
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] ; rectangle
mov eax,[edx+WDATA.box.left]
shl eax,16
add eax,[edx+WDATA.box.left]
add eax,[edx+WDATA.box.width]
mov ebx,[edx+WDATA.box.top]
shl ebx,16
add ebx,[edx+WDATA.box.top]
add ebx,[edx+WDATA.box.height]
mov esi, [edx + WDATA.cl_frames]
call draw_rectangle
 
and [edx+WDATA.fl_wdrawn], not 4
test [edx+WDATA.fl_wdrawn], 2
jz @f
call drawwindowframes2
@@:
; window caption
 
call drawwindow_I_caption
 
mov edx,[esi+WDATA.box.top] ; inside work area
; 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 noinside
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]
mov edi,[esi+WDATA.cl_workarea]
test edi,0x40000000
jnz noinside
call [drawbar]
noinside:
 
.exit:
popad
 
ret
 
 
draw_rectangle:
 
r_eax equ [esp+28] ; x start
r_ax equ [esp+30] ; x end
r_ebx equ [esp+16] ; y start
r_bx equ [esp+18] ; y end
;esi ; color
 
pushad
 
mov ecx,esi ; yb,xb -> yb,xe
mov eax, r_eax
rol eax, 16
mov ebx,r_ebx
shl ebx,16
mov bx,r_ebx
xor edi, edi
call [draw_line]
 
mov ebx,r_bx ; ye,xb -> ye,xe
shl ebx,16
mov bx,r_bx
call [draw_line]
 
mov ecx,esi ; ya,xa -> ye,xa
mov eax,r_eax
shl eax,16
mov ax,r_eax
mov ebx,r_ebx
shl ebx,16
mov bx,r_bx
mov edi,0
call [draw_line]
 
mov eax,r_ax ; ya,xe -> ye,xe
shl eax,16
mov ax,r_ax
call [draw_line]
 
popad
ret
 
 
drawwindow_III_caption:
 
mov ecx,[edx+WDATA.cl_titlebar] ; GRAB BAR
align 4
;------------------------------------------------------------------------------
drawwindow_III_caption: ;/////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
mov ecx, [edx + WDATA.cl_titlebar]
push ecx
mov esi,edx
mov edx,[esi+WDATA.box.top]
797,12 → 698,15
add ebx,20
mov eax,[esi+WDATA.box.top]
add eax,[esi+WDATA.box.height]
 
cmp ebx,eax
jb .wdsizeok
jb @f
mov ebx,eax
.wdsizeok:
push ebx
.drwi:
@@: push ebx
 
xor edi, edi
 
.next_line:
mov ebx,edx
shl ebx,16
add ebx,edx
813,72 → 717,80
add eax,4*65536-4
mov ecx,[esi+WDATA.cl_titlebar]
test ecx,0x40000000
jz .nofa
add ecx,0x040404
.nofa:
test ecx,0x80000000
jz .nofa2
sub ecx,0x040404
.nofa2:
mov [esi+WDATA.cl_titlebar],ecx
and ecx,0xffffff
xor edi, edi
jz @f
add ecx, 0x00040404
@@: test ecx, 0x80000000
jz @f
sub ecx, 0x00040404
@@: mov [esi + WDATA.cl_titlebar], ecx
and ecx, 0x00ffffff
call [draw_line]
inc edx
cmp edx,[esp]
jb .drwi
jb .next_line
 
add esp,4
pop ecx
mov [esi+WDATA.cl_titlebar],ecx
 
pop [esi + WDATA.cl_titlebar]
ret
 
align 4
;------------------------------------------------------------------------------
drawwindow_III: ;//////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
pushad
 
drawwindow_III:
; window border
 
pushad
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 edi,edx ; RECTANGLE
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,[edi+WDATA.cl_frames]
mov esi, [edx + WDATA.cl_frames]
shr esi,1
and esi,0x007f7f7f
call draw_rectangle
 
push esi
or [edi+WDATA.fl_wdrawn], 4
call draw_rectangle
and [edi+WDATA.fl_wdrawn], not 4
test [edi+WDATA.fl_wdrawn], 2
jz @f
call drawwindowframes2
@@:
mov ecx,3
dw3l:
mov esi, [edx + WDATA.cl_frames]
 
.next_frame:
add eax,1*65536-1
add ebx,1*65536-1
mov esi,[edi+WDATA.cl_frames]
call draw_rectangle
dec ecx
jnz dw3l
jnz .next_frame
 
pop esi
add eax,1*65536-1
add ebx,1*65536-1
call draw_rectangle
 
; window caption
 
call drawwindow_III_caption
 
mov edx,[esi+WDATA.box.top] ; WORK AREA
; 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 noinside2
jg .exit
 
; okay, let's draw it
mov eax,5
mov ebx,20
mov ecx,[esi+WDATA.box.width]
885,632 → 797,454
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]
noinside2:
 
.exit:
popad
 
ret
 
 
 
; activate window
align 4
windowactivate:
 
; esi = abs mem position in stack 0xC400+
 
pushad
 
; if type of current active window is 3,
; it must be redrawn
mov eax, [TASK_COUNT]
movzx eax, word [WIN_POS + eax*2]
shl eax, 5
add eax, window_data
mov ebx, [eax + WDATA.cl_workarea]
and ebx, 0x0f000000
cmp ebx, 0x03000000
je .set_WDATA_fl_redraw ; for 3 and 4 style
cmp ebx, 0x04000000
je .set_WDATA_fl_redraw
jmp @f
.set_WDATA_fl_redraw:
mov [eax + WDATA.fl_redraw], byte 1
@@:
 
push esi
movzx eax, word [esi] ; ax <- process no
movzx eax, word [WIN_STACK+eax*2] ; ax <- position in window stack
 
xor esi, esi ; drop others
waloop:
cmp esi, dword [TASK_COUNT]
jae wacont
inc esi
lea edi, [WIN_STACK + esi*2]
mov bx, [edi] ; position of the current process
cmp bx, ax
jbe @f
dec bx ; upper? => drop!
mov [edi], bx
@@:
jmp waloop
wacont:
; set to no 1
pop esi ; esi = pointer at 0xC400
 
movzx eax, word [esi]
mov bx, [TASK_COUNT] ; number of processes
mov [WIN_STACK+eax*2], bx ; this is the last (and the upper)
 
; update on screen -window stack
xor esi, esi
waloop2:
mov edi, [TASK_COUNT]
cmp esi, edi
jae wacont2
inc esi
movzx ebx, word [esi*2 + WIN_STACK]
mov [ebx*2 + WIN_POS], si
jmp waloop2
wacont2:
mov [KEY_COUNT], byte 0 ; empty keyboard buffer
mov [BTN_COUNT], byte 0 ; empty button buffer
mov [MOUSE_SCROLL_H], word 0 ; zero mouse z-index
mov [MOUSE_SCROLL_V], word 0 ; zero mouse z-index
popad
ret
 
 
; check if window is necessary to draw
 
checkwindowdraw:
 
; edi = position in window_data+
 
mov eax, [edi + WDATA.cl_workarea]
and eax, 0x0f000000
cmp eax, 0x03000000
je .return_yes ; window type 3
cmp eax, 0x04000000
je .return_yes ; window type 4
 
mov esi, edi
sub esi, window_data
shr esi, 5
 
; esi = process number
 
movzx eax, word [WIN_STACK + esi * 2] ; get value of the curr process
lea esi, [WIN_POS + eax * 2] ; get address of this process at 0xC400
 
push esi
 
.new_check:
 
pop esi
add esi, 2
push esi
 
mov eax, [TASK_COUNT]
lea eax, word [WIN_POS + eax * 2] ; number of the upper window
 
cmp esi, eax
ja .all_wnds_to_top
 
movzx eax, word [esi]
shl eax, 5
cmp [CURRENT_TASK + eax + TASKDATA.state], byte 9
je .new_check ; skip dead windows
 
lea esi, [eax+window_data]
 
mov ebx, [edi+WDATA.box.top] ; y0
mov edx, [edi+WDATA.box.height]
add edx, ebx ; y0e
 
mov ecx, [esi+WDATA.box.top] ; y ; y check
cmp ecx, edx
jae .new_check ; y < y0e
mov eax, [esi+WDATA.box.height]
add ecx, eax ; ye
cmp ebx, ecx ; y0 >= ye
ja .new_check
 
mov eax, [edi+WDATA.box.left] ; x0
mov ecx, [edi+WDATA.box.width]
add ecx, eax ; x0e
 
mov edx, [esi+WDATA.box.left] ; x ; x check
cmp edx, ecx
jae .new_check ; x < x0e
mov ecx, [esi+WDATA.box.width]
add edx, ecx
cmp eax, edx
ja .new_check
 
pop esi
.return_yes:
mov ecx,1 ; overlap some window
ret
 
.all_wnds_to_top:
 
pop esi
 
xor ecx, ecx ; passed all windows to top
ret
 
 
 
 
waredraw: ; if redraw necessary at activate
 
pushad
 
call checkwindowdraw ; draw window on activation ?
;------------------------------------------------------------------------------
waredraw: ;////////////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Activate window, redrawing if necessary
;------------------------------------------------------------------------------
; is it overlapped by another window now?
push ecx
call window._.check_window_draw
test ecx, ecx
pop ecx
jz .do_not_draw
 
popad
mov [MOUSE_DOWN], byte 1 ; do draw mouse
call windowactivate
; yes it is, activate and update screen buffer
mov byte[MOUSE_DOWN], 1
call window._.window_activate
 
; update screen info
pushad
mov edi, [TASK_COUNT] ; the last process (number)
mov edi, [TASK_COUNT]
movzx esi, word [WIN_POS + edi * 2]
shl esi, 5
add esi, window_data
 
; coordinates of the upper window
mov eax, [esi + WDATA.box.left] ; cx
mov ebx, [esi + WDATA.box.top] ; cy
mov ecx, [esi + WDATA.box.width] ; sx
mov edx, [esi + WDATA.box.height] ; sy
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 ; ecx = x_end
add edx, ebx ; edx = y_end
add ecx, eax
add edx, ebx
 
mov edi, [TASK_COUNT]
movzx esi, word [WIN_POS + edi * 2]
call setscreen
call window._.set_screen
popad
 
mov [edi + WDATA.fl_redraw], 1 ; redraw flag for app
mov [MOUSE_DOWN],byte 0 ; mouse down checks
 
; tell application to redraw itself
mov [edi + WDATA.fl_redraw], 1
mov byte[MOUSE_DOWN], 0
ret
 
.do_not_draw:
; no it's not, just activate the window
call window._.window_activate
mov byte[MOUSE_DOWN], 0
mov byte[MOUSE_BACKGROUND], 0
mov byte[DONT_DRAW_MOUSE], 0
ret
 
popad
align 4
;------------------------------------------------------------------------------
minimize_window: ;/////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;> eax = window number on screen
;------------------------------------------------------------------------------
;# corrupts [dl*]
;------------------------------------------------------------------------------
push edi
pushfd
cli
 
call windowactivate
mov [MOUSE_DOWN],byte 0 ; mouse down checks
mov [MOUSE_BACKGROUND],byte 0 ; no mouse background
mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse
ret
; 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
 
; eax = window number on screen
; corrupts registers and [dl*]
minimize_window:
movzx eax, word [WIN_POS+eax*2]
shl eax, 5
add eax, window_data
test [eax+WDATA.fl_wstate], WSTATE_MINIMIZED
jnz .skip_redrawings
pushfd
cli
or [eax+WDATA.fl_wstate], WSTATE_MINIMIZED
mov edi, eax
;call calculatescreen
; no it's not, let's do that
or [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
mov eax, [edi+WDATA.box.left]
mov [dlx], eax
mov [draw_limits.left], eax
mov ecx, eax
add ecx, [edi+WDATA.box.width]
mov [dlxe], ecx
mov [draw_limits.right], ecx
mov ebx, [edi+WDATA.box.top]
mov [dly], ebx
mov [draw_limits.top], ebx
mov edx, ebx
add edx, [edi+WDATA.box.height]
mov [dlye], edx
mov [draw_limits.bottom], edx
call calculatescreen
xor esi, esi
xor eax, eax
call redrawscreen
 
pop esi edx ecx ebx eax
 
.exit:
popfd
.skip_redrawings:
pop edi
ret
 
; eax = window number on screen
; corrupts registers and [dl*]
restore_minimized_window:
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 .skip_redrawings
jz .exit
 
; no it's not, let's do that
mov [edi+WDATA.fl_redraw], 1
and [edi+WDATA.fl_wstate], not WSTATE_MINIMIZED
cmp eax, [TASK_COUNT] ; the uppermost window
jnz .no_uppermost
mov eax, [edi+WDATA.box.left]
mov ebp, window._.set_screen
cmp eax, [TASK_COUNT]
jz @f
mov ebp, calculatescreen
@@: mov eax, [edi + WDATA.box.left]
mov ebx, [edi+WDATA.box.top]
mov ecx, eax
mov edx, ebx
add ecx, [edi+WDATA.box.width]
add edx, [edi+WDATA.box.height]
call setscreen
jmp .done
.no_uppermost:
mov eax, [edi+WDATA.box.left]
mov ebx, [edi+WDATA.box.top]
mov ecx, eax
mov edx, ebx
add ecx, [edi+WDATA.box.width]
add edx, [edi+WDATA.box.height]
call calculatescreen
.done:
mov [MOUSE_BACKGROUND],byte 0 ; no mouse under
.skip_redrawings:
mov ecx, [edi + WDATA.box.width]
mov edx, [edi + WDATA.box.height]
add ecx, eax
add edx, ebx
call ebp
 
mov byte[MOUSE_BACKGROUND], 0
 
.exit:
popfd
popad
ret
 
 
;iglobal
; window_moving db 'K : Window - move/resize',13,10,0
; window_moved db 'K : Window - done',13,10,0
;endg
 
; check window touch
align 4
checkwindows:
;------------------------------------------------------------------------------
checkwindows: ;////////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Check for user-initiated window operations
;------------------------------------------------------------------------------
pushad
 
; do we have window minimize/restore request?
cmp [window_minimize], 0
je .no_minimizing
mov eax, [TASK_COUNT] ; the uppermost window
je .check_for_mouse_buttons_state
 
; okay, minimize or restore top-most window and exit
mov eax, [TASK_COUNT]
mov bl, 0
xchg [window_minimize], bl
cmp bl, 1
jne .restore
dec bl
jnz @f
call minimize_window
jmp .continue
.restore:
call restore_minimized_window
.continue:
.no_minimizing:
jmp .check_for_mouse_buttons_state
@@: call restore_minimized_window
 
cmp [BTN_DOWN],byte 0 ; mouse buttons pressed ?
.check_for_mouse_buttons_state:
; do we have any mouse buttons pressed?
cmp byte[BTN_DOWN], 0
jne .mouse_buttons_pressed
;..................................... start 1/4 : modified by vhanla .................
 
mov [bPressedMouseXY_W],0
;..................................... end 1/4 : modified by vhanla ...................
popad
ret
jmp .exit
 
.mouse_buttons_pressed:
;..................................... start 2/4 : modified by vhanla .................
uglobal
bPressedMouseXY_W db 0x0
endg
;..................................... end 2/4 : modified by vhanla ...................
; yes we do, iterate and ...
mov esi,[TASK_COUNT]
inc esi
 
;..................................... start 3/4 : modified by vhanla .................
cmp [bPressedMouseXY_W],1
ja @f
ja .next_window
inc [bPressedMouseXY_W]
jnc @f
;mov ax,[MOUSE_X]
;mov [mx],ax
;mov ax,[MOUSE_Y]
;mov [my],ax
mov eax,dword[MOUSE_X]
mov dword[mx],eax
@@:
;..................................... end 3/4 : modified by vhanla ...................
jnc .next_window
push dword[MOUSE_X]
pop dword[mx]
 
cwloop:
.next_window:
cmp esi,2
jb .exit
 
dec esi
movzx edi, word [WIN_POS + esi * 2] ; ebx
 
; is that window not minimized?
movzx edi, word[WIN_POS + esi * 2]
shl edi, 5
add edi, window_data
; mov edi, ebx
test [edi + WDATA.fl_wstate], WSTATE_MINIMIZED
jnz .next_window
 
movzx eax, [mx]
movzx ebx, [my]
 
; is the cursor inside screen bounds of that window?
mov ecx, [edi + WDATA.box.left]
mov edx, [edi + WDATA.box.top]
 
mov eax,ecx
mov ebx,edx
test [edi+WDATA.fl_wstate],WSTATE_MINIMIZED
jnz cwloop
 
;..................................... start 4/4 : modified by vhanla .................
movzx eax, word [mx]; movzx eax,word[MOUSE_X]
movzx ebx, word [my]; movzx ebx,word[MOUSE_Y]
;..................................... endt 4/4 : modified by vhanla ..................
cmp ecx, eax
jae cwloop
cmp edx, ebx
jae cwloop
cmp eax, ecx
jl .next_window
cmp ebx, edx
jl .next_window
add ecx, [edi + WDATA.box.width]
add edx, [edi + WDATA.box.height]
cmp eax, ecx
jae cwloop
jge .next_window
cmp ebx, edx
jae cwloop
jge .next_window
 
pushad
mov eax, esi
mov ebx, [TASK_COUNT]
cmp eax, ebx ; is this window active?
jz .move_resize_window
; is that a top-most (which means active) window?
cmp esi, [TASK_COUNT]
je .check_for_moving_or_resizing
 
; no it's not, did we just press mouse button down above it or was it
; already pressed before?
cmp [bPressedMouseXY_W], 1
ja .exit_popa
ja .exit
 
; eax = position in windowing stack
; redraw must ?
; okay, we just pressed the button, activate this window and exit
lea esi, [WIN_POS + esi * 2]
call waredraw
.exit_popa:
add esp, 32
jmp .exit
 
.exit:
popad
ret
.check_for_moving_or_resizing:
; is that window movable?
test byte[edi + WDATA.cl_titlebar + 3], 0x01
jnz .exit
 
.move_resize_window: ; MOVE OR RESIZE WINDOW
popad
 
; Check for user enabled fixed window
mov edx, [edi + WDATA.cl_titlebar]
and edx, 0x0f000000
cmp edx, 0x01000000
jne .window_move_enabled_for_user
popad
ret
.window_move_enabled_for_user:
 
; yes it is, is it rolled up?
test [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
jnz .no_resize_2
jnz .check_for_cursor_on_caption
 
mov [do_resize_from_corner],byte 0 ; resize for skinned window
mov edx, [edi + WDATA.cl_workarea]
and edx, 0x0f000000
cmp edx, 0x00000000 ;{test for resized}
je .no_resize_2
cmp edx, 0x01000000 ;{test for resized}
je .no_resize_2
cmp edx, 0x04000000 ;{test for resized}
je .no_resize_2
; jb .no_resize_2 ; not type 2 wnd
; no it's not, can it be resized then?
mov [do_resize_from_corner], 0
mov dl, [edi + WDATA.fl_wstyle]
and dl, 0x0f
cmp dl, 0x00
je .check_for_cursor_on_caption
cmp dl, 0x01
je .check_for_cursor_on_caption
cmp dl, 0x04
je .check_for_cursor_on_caption
 
; are we going to resize it?
mov edx, [edi + WDATA.box.top]
add edx, [edi + WDATA.box.height]
sub edx, 6 ; edx = y_end - 6
cmp ebx, edx ; ebx = mouse_y
jb .no_resize_2
mov [do_resize_from_corner],byte 1
jmp .continue
.no_resize_2:
sub edx, 6
cmp ebx, edx
jl .check_for_cursor_on_caption
 
; yes we do, remember that
mov [do_resize_from_corner], 1
jmp .set_move_resize_flag
 
.check_for_cursor_on_caption:
; is the cursor inside window titlebar?
push eax
call get_titlebar_height
call window._.get_titlebar_height
add eax,[edi + WDATA.box.top]
cmp ebx,eax
pop eax
jae .exit
jge .exit
 
.continue:
 
; push esi
; mov esi, window_moving
; call sys_msg_board_str
; pop esi
 
mov ecx, [timer_ticks] ; double-click ?
; calculate duration between two clicks
mov ecx, [timer_ticks]
mov edx, ecx
sub edx, [latest_window_touch]
mov [latest_window_touch], ecx
mov [latest_window_touch_delta], edx
 
mov cl, [BTN_DOWN] ; save for shade check
.set_move_resize_flag:
mov cl, [BTN_DOWN]
mov [do_resize], cl
no_emulation_righ_button:
 
mov ecx, [edi + WDATA.box.left]
mov edx, [edi + WDATA.box.top]
 
push eax ecx edx
mov [dlx], ecx ; save for drawlimits
mov [dly], edx
mov eax, [edi + WDATA.box.width]
add ecx, eax
mov eax, [edi + WDATA.box.height]
add edx, eax
mov [dlxe], ecx
mov [dlye], edx
pop edx ecx eax
push ecx edx
mov [draw_limits.left], ecx
mov [draw_limits.top], edx
add ecx, [edi + WDATA.box.width]
add edx, [edi + WDATA.box.height]
mov [draw_limits.right], ecx
mov [draw_limits.bottom], edx
pop edx ecx
 
; calculate window-relative cursor coordinates
sub eax, ecx
sub ebx, edx
 
mov esi, [MOUSE_X]
mov [WIN_TEMP_XY], esi
push dword[MOUSE_X]
pop dword[WIN_TEMP_XY]
 
pushad ; wait for putimages to finish
; mov ebx,5
; call delay_hs
; save old window coordinates
push eax
mov eax,[edi + WDATA.box.left]
mov [npx],eax
mov [old_window_pos.left], eax
mov [new_window_pos.left], eax
mov eax,[edi + WDATA.box.top]
mov [npy],eax
popad
 
push eax ; save old coordinates
mov ax, word [edi + WDATA.box.left]
mov word [oldc+BOX.left],ax
mov ax, word [edi + WDATA.box.top]
mov word [oldc+BOX.top],ax
mov ax, word [edi + WDATA.box.width]
mov word [oldc+BOX.width],ax
mov word [npxe],ax
mov ax, word [edi + WDATA.box.height]
mov word [oldc+BOX.height],ax
mov word [npye],ax
mov [old_window_pos.top], eax
mov [new_window_pos.top], eax
mov eax, [edi + WDATA.box.width]
mov [old_window_pos.width], eax
mov [new_window_pos.width], eax
mov eax, [edi + WDATA.box.height]
mov [old_window_pos.height], eax
mov [new_window_pos.height], eax
pop eax
 
call drawwindowframes
; draw negative moving/sizing frame
call window._.draw_window_frames
 
mov [reposition],0
mov [MOUSE_DOWN],byte 1 ; no reaction to mouse up/down
mov byte[MOUSE_DOWN], 1
 
; move window
 
newchm:
 
mov [DONT_DRAW_MOUSE],byte 1
 
.next_mouse_state_check:
; process OS events
mov byte[DONT_DRAW_MOUSE], 1
call checkidle
 
call checkVga_N13
 
mov [MOUSE_BACKGROUND],byte 0
 
mov byte[MOUSE_BACKGROUND], 0
call [draw_pointer]
 
pushad
call stack_handler
popad
 
; did cursor position change?
mov esi,[WIN_TEMP_XY]
cmp esi,[MOUSE_X]
je cwb
je .check_for_new_mouse_buttons_state
 
mov cx,[MOUSE_X]
mov dx,[MOUSE_Y]
sub cx,ax
sub dx,bx
; yes it did, calculate window-relative cursor coordinates
movzx ecx, word[MOUSE_X]
movzx edx, word[MOUSE_Y]
sub ecx, eax
sub edx, ebx
 
push ax
push bx
push eax ebx
 
call drawwindowframes
; we're going to draw new frame, erasing the old one
call window._.draw_window_frames
 
mov ax,[Screen_Max_X]
mov bx,[Screen_Max_Y]
; are we moving it right now?
cmp [do_resize_from_corner], 0
jne .resize_window
 
cmp [do_resize_from_corner],1
je no_new_position
; yes we do, check if it's inside the screen area
mov eax, [Screen_Max_X]
mov ebx, [Screen_Max_Y]
 
mov word [npx],word 0 ; x repos ?
cmp ax,cx
jb noreposx
mov [new_window_pos.left], 0
or ecx, ecx
jle .check_for_new_vert_cursor_pos
mov [reposition],1
sub ax,word [npxe]
mov word [npx],ax
cmp ax,cx
jb noreposx
mov word [npx],cx
noreposx:
sub eax, [new_window_pos.width]
mov [new_window_pos.left], eax
cmp ecx, eax
jge .check_for_new_vert_cursor_pos
mov [new_window_pos.left], ecx
 
mov word [npy],word 0 ; y repos ?
cmp bx,dx
jb noreposy
.check_for_new_vert_cursor_pos:
mov [new_window_pos.top], 0
or edx, edx
jle .draw_new_window_frame
mov [reposition],1
sub bx,word [npye]
mov word [npy],bx
cmp bx,dx
jb noreposy
mov word [npy],dx
noreposy:
sub ebx, [new_window_pos.height]
mov [new_window_pos.top], ebx
cmp edx, ebx
jge .draw_new_window_frame
mov [new_window_pos.top], edx
jmp .draw_new_window_frame
 
no_new_position:
.resize_window:
push eax ebx edx
 
cmp [do_resize_from_corner],0 ; resize from right corner
je norepos_size
pushad
 
mov edx,edi
sub edx,window_data
;shr edx,5
;shl edx,8
;add edx,0x80000 ; process base at 0x80000+
lea edx, [SLOT_BASE + edx*8]
 
movzx eax,word [MOUSE_X]
cmp eax,[edi + WDATA.box.left]
jb nnepx
jb .fix_new_vert_size
sub eax,[edi + WDATA.box.left]
cmp eax,32 ; [edx+0x90+8]
jge nnepx2
mov eax,32 ; [edx+0x90+8]
nnepx2:
mov [npxe],eax
nnepx:
cmp eax, 32
jge @f
mov eax, 32
@@: mov [new_window_pos.width], eax
 
call get_rolledup_height
.fix_new_vert_size:
call window._.get_rolledup_height
mov ebx,eax
movzx eax,word [MOUSE_Y]
cmp eax,[edi + WDATA.box.top]
jb nnepy
jb .set_reposition_flag
sub eax,[edi + WDATA.box.top]
cmp eax,ebx ; [edx+0x90+12]
jge nnepy2
mov eax,ebx ; [edx+0x90+12]
nnepy2:
mov [npye],eax
nnepy:
cmp eax, ebx
jge @f
mov eax, ebx
@@: mov [new_window_pos.height], eax
 
.set_reposition_flag:
mov [reposition],1
 
popad
norepos_size:
pop edx ebx eax
 
pop bx
pop ax
call drawwindowframes
.draw_new_window_frame:
pop ebx eax
 
; draw new window moving/sizing frame
call window._.draw_window_frames
 
mov esi,[MOUSE_X]
mov [WIN_TEMP_XY],esi
 
cwb:
cmp [BTN_DOWN],byte 0
jne newchm
; new position done
mov [DONT_DRAW_MOUSE],byte 1
.check_for_new_mouse_buttons_state:
; did user release mouse button(s)?
cmp byte[BTN_DOWN], 0
jne .next_mouse_state_check
 
; yes he did, moving/sizing is over
mov byte[DONT_DRAW_MOUSE], 1
mov cl,0
test [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
jnz @f
jnz .check_other_actions
 
mov cl,[reposition]
call drawwindowframes
 
mov eax,[npx]
; draw negative frame once again to hide it
call window._.draw_window_frames
 
; save new window bounds
mov eax, [new_window_pos.left]
mov [edi + WDATA.box.left],eax
mov eax,[npy]
mov eax, [new_window_pos.top]
mov [edi + WDATA.box.top],eax
mov eax,[npxe]
mov eax, [new_window_pos.width]
mov [edi + WDATA.box.width],eax
mov eax,[npye]
mov eax, [new_window_pos.height]
mov [edi + WDATA.box.height],eax
call set_window_clientbox
 
@@: mov [reposition],cl
 
cmp [reposition],1 ; save new position and size
jne no_bounds_save
cmp cl, 1
jne .check_other_actions
push esi edi ecx
mov esi,edi
mov ecx,2
1524,44 → 1258,48
cld
rep movsd
pop ecx edi esi
no_bounds_save:
 
pushad ; WINDOW SHADE/FULLSCREEN
.check_other_actions:
mov [reposition], cl
 
;{doule click not worked for 4 type window}
mov edx, [edi + WDATA.cl_workarea]
and edx, 0x0f000000
cmp edx, 0x00000000
je no_fullscreen_restore
cmp edx, 0x01000000
je no_fullscreen_restore
pushad
 
cmp [reposition],1
je no_window_sizing
mov dl, [edi + WDATA.fl_wstyle]
and dl, 0x0f
cmp dl, 0x00
je .check_if_window_fits_screen
cmp dl, 0x01
je .check_if_window_fits_screen
 
cmp cl, 1
je .no_window_sizing
mov edx,edi
sub edx,window_data
shr edx,5
shl edx,8
add edx,SLOT_BASE ; process base at 0x80000+
add edx, SLOT_BASE
 
cmp [do_resize],2 ; window shade ?
jne no_window_shade
; did we right-click on titlebar?
cmp [do_resize], 2
jne .check_maximization_request
 
; yes we did, toggle normal/rolled up window state
xor [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
mov [reposition],1
 
; calculate and set appropriate window height
test [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
jnz wnd_rolldown
wnd_rollup:
or [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
call get_rolledup_height
jmp @f
wnd_rolldown:
and [edi+WDATA.fl_wstate],not WSTATE_ROLLEDUP
mov eax,[edx + APPDATA.saved_box.height] ; 0x90+BOX.height
jz @f
call window._.get_rolledup_height
jmp .set_new_window_height
@@: mov eax, [edx + APPDATA.saved_box.height]
test [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
jz @f
jz .set_new_window_height
mov eax,[screen_workarea.bottom]
sub eax,[screen_workarea.top]
@@: mov [edi+WDATA.box.height],eax
 
.set_new_window_height:
mov [edi + WDATA.box.height], eax
add eax, [edi+WDATA.box.top]
cmp eax, [Screen_Max_Y]
jbe @f
1571,23 → 1309,30
@@: call check_window_position
call set_window_clientbox
 
no_window_shade:
 
.check_maximization_request:
; can window change its height?
push edx
mov edx, [edi + WDATA.cl_workarea]
and edx, 0x0f000000
cmp edx, 0x04000000
mov dl, [edi + WDATA.fl_wstyle]
and dl, 0x0f
cmp dl, 0x04
pop edx
je no_fullscreen_restore
je .check_if_window_fits_screen
 
cmp [do_resize],1 ; fullscreen/restore ?
jne no_fullscreen_restore
cmp [latest_window_touch_delta],dword 50
jg no_fullscreen_restore
; was it really a maximize/restore request?
cmp [do_resize], 1
jne .check_if_window_fits_screen
cmp [do_resize_from_corner], 0
jne .check_if_window_fits_screen
cmp [latest_window_touch_delta], 50
jg .check_if_window_fits_screen
 
; yes is was, toggle normal/maximized window state
xor [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
mov [reposition],1
 
; calculate and set appropriate window bounds
test [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
jnz restore_from_fullscreen
or [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
jz .restore_normal_window_size
mov eax,[screen_workarea.left]
mov [edi+WDATA.box.left],eax
sub eax,[screen_workarea.right]
1596,16 → 1341,15
mov eax,[screen_workarea.top]
mov [edi+WDATA.box.top],eax
test [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
jnz @f
jnz .calculate_window_client_area
sub eax,[screen_workarea.bottom]
neg eax
mov [edi+WDATA.box.height],eax
@@:
jmp restore_from_fullscreen.clientbox
restore_from_fullscreen:
and [edi+WDATA.fl_wstate],not WSTATE_MAXIMIZED
jmp .calculate_window_client_area
 
.restore_normal_window_size:
push [edi+WDATA.box.height]
push edi ; restore
push edi
lea esi, [edx + APPDATA.saved_box]
mov ecx,4
cld
1613,22 → 1357,24
pop edi
pop eax
test [edi+WDATA.fl_wstate],WSTATE_ROLLEDUP
jz @f
jz .calculate_window_client_area
mov [edi+WDATA.box.height],eax
@@:
.clientbox:
 
.calculate_window_client_area:
call set_window_clientbox
 
no_fullscreen_restore:
 
mov eax,[edi+WDATA.box.top] ; check Y inside screen
.check_if_window_fits_screen:
; does window fit into screen area?
mov eax, [edi + WDATA.box.top]
add eax,[edi+WDATA.box.height]
cmp eax,[Screen_Max_Y]
jbe no_window_sizing
mov eax,[edi+WDATA.box.left] ; check X inside screen
jbe .no_window_sizing
mov eax, [edi + WDATA.box.left]
add eax,[edi+WDATA.box.width]
cmp eax,[Screen_Max_X]
jbe no_window_sizing
jbe .no_window_sizing
 
; no it doesn't, fix that
mov eax,[Screen_Max_X]
sub eax,[edi+WDATA.box.width]
mov [edi+WDATA.box.left],eax
1636,17 → 1382,19
sub eax,[edi+WDATA.box.height]
mov [edi+WDATA.box.top],eax
call set_window_clientbox
no_window_sizing:
 
.no_window_sizing:
popad
 
; did somethins actually change its place?
cmp [reposition],0
je retwm
je .reset_vars
 
mov [DONT_DRAW_MOUSE],byte 1 ; no mouse
mov byte[DONT_DRAW_MOUSE], 1
 
push eax ebx ecx edx
 
push eax ebx ecx edx
; recalculate screen buffer at new position
mov eax,[edi+WDATA.box.left]
mov ebx,[edi+WDATA.box.top]
mov ecx,[edi+WDATA.box.width]
1655,169 → 1403,444
add edx,ebx
call calculatescreen
 
mov eax,[oldc+BOX.left]
mov ebx,[oldc+BOX.top]
mov ecx,[oldc+BOX.width]
mov edx,[oldc+BOX.height]
; recalculate screen buffer at old position
mov eax, [old_window_pos.left]
mov ebx, [old_window_pos.top]
mov ecx, [old_window_pos.width]
mov edx, [old_window_pos.height]
add ecx,eax
add edx,ebx
call calculatescreen
 
pop edx ecx ebx eax
 
mov eax,edi
call redrawscreen
 
 
; tell window to redraw itself
mov [edi+WDATA.fl_redraw],1
 
mov ecx,100 ; wait to avoid mouse residuals
waitre2:
mov [DONT_DRAW_MOUSE],byte 1
; wait a bit for window to redraw itself
mov ecx, 100
 
.next_idle_cycle:
mov byte[DONT_DRAW_MOUSE], 1
call checkidle
cmp [edi+WDATA.fl_redraw],0
jz retwm
loop waitre2
jz .reset_vars
loop .next_idle_cycle
 
retwm:
.reset_vars:
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
 
mov [DONT_DRAW_MOUSE],byte 0 ; mouse pointer
mov [MOUSE_BACKGROUND],byte 0 ; no mouse under
mov [MOUSE_DOWN],byte 0 ; react to mouse up/down
.exit:
popad
ret
 
; mov esi,window_moved
; call sys_msg_board_str
;==============================================================================
;///// private functions //////////////////////////////////////////////////////
;==============================================================================
 
popad
align 4
;------------------------------------------------------------------------------
window._.get_titlebar_height: ;////////////////////////////////////////////////
;------------------------------------------------------------------------------
;> edi = pointer to WDATA
;------------------------------------------------------------------------------
mov al, [edi + WDATA.fl_wstyle]
and al, 0x0f
cmp al, 0x03
jne @f
mov eax, [_skinh]
ret
@@: mov eax, 21
ret
 
align 4
;------------------------------------------------------------------------------
window._.get_rolledup_height: ;////////////////////////////////////////////////
;------------------------------------------------------------------------------
;> 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
@@: or al, al
jnz @f
mov eax, 21
ret
@@: 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
 
uglobal
add_window_data dd 0
do_resize_from_corner db 0x0
reposition db 0x0
latest_window_touch dd 0x0
latest_window_touch_delta dd 0x0
pushad
 
do_resize db 0x0
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
 
oldc dd 0x0,0x0,0x0,0x0
.check_for_shaped_window:
mov edi, esi
shl edi, 8
add edi, SLOT_BASE
cmp [edi + APPDATA.wnd_shape], 0
jne .shaped_window
 
dlx dd 0x0
dly dd 0x0
dlxe dd 0x0
dlye dd 0x0
; get x&y size
sub ecx, eax
sub edx, ebx
inc ecx
inc edx
 
npx dd 0x0
npy dd 0x0
npxe dd 0x0
npye dd 0x0
; get WinMap start
push esi
mov edi, [Screen_Max_X]
inc edi
mov esi, edi
imul edi, ebx
add edi, eax
add edi, [_WinMapAddress]
pop eax
mov ah, al
push ax
shl eax, 16
pop ax
 
mpx dd 0x0
mpy dd 0x0
endg
.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
 
; draw negative window frames
drawwindowframes2:
pushad
cli
jmp drawwindowframes.do
drawwindowframes:
pushad
cli
.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);
 
test [edi+WDATA.fl_wstate],WSTATE_MAXIMIZED
jnz .ret
mov eax, [npx]
cmp eax, [edi+WDATA.box.left]
jnz .nowndframe
mov eax, [npxe]
cmp eax, [edi+WDATA.box.width]
jnz .nowndframe
mov eax, [npy]
cmp eax, [edi+WDATA.box.top]
jnz .nowndframe
mov eax, [npye]
cmp eax, [edi+WDATA.box.height]
jnz .nowndframe
xor [edi+WDATA.fl_wdrawn], 2
test [edi+WDATA.fl_wdrawn], 4
jnz .ret
sub ecx, eax
sub edx, ebx
inc ecx
inc edx
 
.nowndframe:
.do:
mov edi, 1
mov ecx, 0x01000000
mov eax,[npx]
shl eax,16
add eax,[npx]
add eax,[npxe]
add eax,65536*1-1
mov ebx,[npy]
shl ebx,16
add ebx,[npy]
call [draw_line]
push [edi + APPDATA.wnd_shape_scale] ; push scale first -> for loop
 
mov eax,[npx]
shl eax,16
add eax,[npx]
add eax,[npxe]
add eax,65536*1-1
mov ebx,[npy]
add ebx,[npye]
shl ebx,16
add ebx,[npy]
add ebx,[npye]
call [draw_line]
; get WinMap start -> ebp
push eax
mov eax, [Screen_Max_X] ; screen_sx
inc eax
imul eax, ebx
add eax, [esp]
add eax, [_WinMapAddress]
mov ebp, eax
 
mov eax,[npx]
shl eax,16
add eax,[npx]
mov ebx,[npy]
shl ebx,16
add ebx,[npy]
add ebx,[npye]
call [draw_line]
mov edi, [edi + APPDATA.wnd_shape]
pop eax
 
mov eax,[npx]
add eax,[npxe]
shl eax,16
add eax,[npx]
add eax,[npxe]
mov ebx,[npy]
shl ebx,16
add ebx,[npy]
add ebx,[npye]
call [draw_line]
; 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
 
.ret:
sti
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]
 
.ff_new_y:
mov edx, [ff_x]
 
.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 --
@@: 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
 
.exit:
popad
ret
 
.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
 
random_shaped_window:
; if type of current active window is 3 or 4, it must be redrawn
mov ebx, [TASK_COUNT]
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
 
;
; eax = 0 giving address of data area
; ebx address
; eax = 1 shape area scale
; ebx 2^ebx scale
.set_window_redraw_flag:
mov [window_data + ebx + WDATA.fl_redraw], 1
 
test eax, eax
jne rsw_no_address
mov eax,[current_slot]
mov [eax+APPDATA.wnd_shape],ebx
rsw_no_address:
.move_others_down:
; ax <- process no
movzx ebx, word[esi]
; ax <- position in window stack
movzx ebx, word[WIN_STACK + ebx * 2]
 
cmp eax,1
jne rsw_no_scale
mov eax,[current_slot]
mov byte [eax+APPDATA.wnd_shape_scale], bl
rsw_no_scale:
; drop others
xor eax, eax
 
.next_stack_window:
cmp eax, [TASK_COUNT]
jae .move_self_up
inc eax
cmp [WIN_STACK + eax * 2], bx
jbe .next_stack_window
dec word[WIN_STACK + eax * 2]
jmp .next_stack_window
 
.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
 
.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
 
.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, 0x03
je .exit.redraw ; window type 3
cmp cl, 0x04
je .exit.redraw ; window type 4
 
push eax ebx edx esi
 
mov eax, edi
sub eax, window_data
shr eax, 5
 
; esi = process number
 
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
 
.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
 
.exit.redraw:
xor ecx, ecx
inc ecx
ret
 
.exit.no_redraw:
pop esi edx ebx eax
xor ecx, ecx
ret
 
align 4
;------------------------------------------------------------------------------
window._.draw_window_frames: ;/////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Draw negative window frames
;------------------------------------------------------------------------------
;> edi = pointer to WDATA
;------------------------------------------------------------------------------
push eax
cli
 
test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
jnz .exit
mov eax, [new_window_pos.left]
cmp eax, [edi + WDATA.box.left]
jnz .draw
mov eax, [new_window_pos.width]
cmp eax, [edi + WDATA.box.width]
jnz .draw
mov eax, [new_window_pos.top]
cmp eax, [edi + WDATA.box.top]
jnz .draw
mov eax, [new_window_pos.height]
cmp eax, [edi + WDATA.box.height]
jnz .draw
xor [edi + WDATA.fl_wdrawn], 2
 
.draw:
push ebx esi
mov eax, [new_window_pos.left - 2]
mov ax, word[new_window_pos.left]
add ax, word[new_window_pos.width]
mov ebx, [new_window_pos.top - 2]
mov bx, word[new_window_pos.top]
add bx, word[new_window_pos.height]
mov esi, 0x01000000
call draw_rectangle.forced
pop esi ebx
 
.exit:
sti
pop eax
ret
 
.forced:
push eax
cli
jmp .draw
Property changes:
Modified: svn:keywords
-Revision
\ No newline at end of property
+Rev
\ No newline at end of property
Added: svn:mergeinfo