Rev 1300 | Rev 1341 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1300 | Rev 1334 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
4 | ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; Distributed under terms of the GNU General Public License ;; |
- | 6 | ;; ;; |
|
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
7 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 8... | ||
7 | 8 | ||
Line 8... | Line 9... | ||
8 | $Revision: 1300 $ |
9 | $Revision: 1334 $ |
9 | - | ||
10 | - | ||
11 | max_buttons=4095 |
- | |
Line 12... | Line -... | ||
12 | dececx: |
- | |
13 | push edx |
- | |
Line -... | Line 10... | ||
- | 10 | ||
- | 11 | ||
- | 12 | button._.MAX_BUTTONS = 4095 |
|
- | 13 | ||
- | 14 | ||
- | 15 | ;============================================================================== |
|
14 | push ecx |
16 | ;///// public functions /////////////////////////////////////////////////////// |
- | 17 | ;============================================================================== |
|
15 | 18 | ||
- | 19 | struc SYS_BUTTON |
|
16 | mov edx,2 |
20 | { |
- | 21 | .pslot dw ? |
|
- | 22 | .id_lo dw ? |
|
17 | .loop: |
23 | .left dw ? |
- | 24 | .width dw ? |
|
- | 25 | .top dw ? |
|
18 | 26 | .height dw ? |
|
- | 27 | .id_hi dw ? |
|
Line -... | Line 28... | ||
- | 28 | .sizeof: |
|
- | 29 | } |
|
- | 30 | virtual at 0 |
|
19 | cmp byte [esp+edx],0x20 |
31 | SYS_BUTTON SYS_BUTTON |
20 | jae @f |
32 | end virtual |
- | 33 | ||
Line -... | Line 34... | ||
- | 34 | iglobal |
|
- | 35 | mx dw 0x0 ; keeps the x mouse's position when it was clicked |
|
- | 36 | my dw 0x0 ; keeps the y mouse's position when it was clicked |
|
- | 37 | bPressedMouseXY_B db 0x0 |
|
- | 38 | btn_down_determ db 0x0 |
|
- | 39 | endg |
|
- | 40 | ||
- | 41 | align 4 |
|
- | 42 | ;------------------------------------------------------------------------------ |
|
- | 43 | syscall_button: ;///// system function 8 ////////////////////////////////////// |
|
21 | mov [esp+edx],byte 0x20 |
44 | ;------------------------------------------------------------------------------ |
22 | @@: |
45 | ; Define/undefine GUI button object |
- | 46 | ;------------------------------------------------------------------------------ |
|
- | 47 | ; Define button arguments: |
|
- | 48 | ; ebx = pack[16(x), 16(width)] |
|
- | 49 | ; ecx = pack[16(y), 16(height)] |
|
- | 50 | ; edx = pack[8(flags), 24(button identifier)] |
|
- | 51 | ; flags bits: |
|
23 | sub [esp+edx],byte 0x20 |
52 | ; 7 (31) = 0 |
- | 53 | ; 6 (30) = don't draw button |
|
- | 54 | ; 5 (29) = don't draw button frame when pressed |
|
- | 55 | ; esi = button color |
|
- | 56 | ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
- | 57 | ; Undefine button arguments: |
|
Line -... | Line 58... | ||
- | 58 | ; edx = pack[8(flags), 24(button identifier)] |
|
24 | 59 | ; flags bits: |
|
25 | dec edx |
60 | ; 7 (31) = 1 |
- | 61 | ;------------------------------------------------------------------------------ |
|
26 | jns .loop |
62 | ; do we actually need to undefine the button? |
Line -... | Line 63... | ||
- | 63 | test edx, 0x80000000 |
|
- | 64 | jnz .remove_button |
|
- | 65 | ||
27 | 66 | ; do we have free button slots available? |
|
28 | pop ecx |
67 | mov edi, [BTN_ADDR] |
Line -... | Line 68... | ||
- | 68 | mov eax, [edi] |
|
- | 69 | cmp eax, button._.MAX_BUTTONS |
|
- | 70 | jge .exit |
|
29 | pop edx |
71 | |
- | 72 | ; does it have positive size? (otherwise it doesn't have sense) |
|
30 | ret |
73 | or bx, bx |
31 | 74 | jle .exit |
|
- | 75 | or cx, cx |
|
32 | incecx: |
76 | jle .exit |
33 | push edx |
77 | |
Line -... | Line 78... | ||
- | 78 | ; make coordinates clientbox-relative |
|
- | 79 | push eax |
|
34 | push ecx |
80 | mov eax, [current_slot] |
- | 81 | rol ebx, 16 |
|
- | 82 | add bx, word[eax + APPDATA.wnd_clientbox.left] |
|
- | 83 | rol ebx, 16 |
|
- | 84 | rol ecx, 16 |
|
- | 85 | add cx, word[eax + APPDATA.wnd_clientbox.top] |
|
- | 86 | rol ecx, 16 |
|
35 | 87 | pop eax |
|
- | 88 | ||
- | 89 | ; basic checks passed, define the button |
|
- | 90 | push ebx ecx edx |
|
- | 91 | inc eax |
|
- | 92 | mov [edi], ax |
|
36 | mov edx,2 |
93 | shl eax, 4 |
- | 94 | add edi, eax |
|
- | 95 | ; NOTE: this code doesn't rely on SYS_BUTTON struct, please revise it |
|
37 | .loop: |
96 | ; if you change something |
38 | 97 | mov ax, [CURRENT_TASK] |
|
- | 98 | stosw |
|
- | 99 | mov ax, dx |
|
Line 39... | Line 100... | ||
39 | cmp byte [esp+edx],0xdf |
100 | stosw ; button id number: bits 0-15 |
40 | jbe @f |
101 | mov eax, ebx |
41 | mov [esp+edx],byte 0xdf |
102 | rol eax, 16 |
Line 42... | Line 103... | ||
42 | @@: |
103 | stosd ; x start | x size |
43 | add [esp+edx],byte 0x20 |
- | |
Line 44... | Line -... | ||
44 | - | ||
45 | dec edx |
104 | mov eax, ecx |
46 | jns .loop |
- | |
47 | pop ecx |
- | |
48 | pop edx |
- | |
Line -... | Line 105... | ||
- | 105 | rol eax, 16 |
|
49 | ret |
106 | stosd ; y start | y size |
50 | 107 | mov eax, edx |
|
51 | incecx2: |
108 | shr eax, 16 |
- | 109 | stosw ; button id number: bits 16-31 |
|
- | 110 | pop edx ecx ebx |
|
- | 111 | ||
- | 112 | ; do we also need to draw the button? |
|
- | 113 | test edx, 0x40000000 |
|
52 | push edx |
114 | jnz .exit |
- | 115 | ||
- | 116 | ; draw button body |
|
53 | push ecx |
117 | |
- | 118 | pushad |
|
Line -... | Line 119... | ||
- | 119 | ||
- | 120 | ; calculate window-relative coordinates |
|
- | 121 | movzx edi, cx |
|
- | 122 | shr ebx, 16 |
|
54 | 123 | shr ecx, 16 |
|
Line -... | Line 124... | ||
- | 124 | mov eax, [TASK_BASE] |
|
55 | mov edx,2 |
125 | add ebx, [eax - twdw + WDATA.box.left] |
- | 126 | add ecx, [eax - twdw + WDATA.box.top] |
|
- | 127 | mov eax, ebx |
|
- | 128 | shl eax, 16 |
|
56 | .loop: |
129 | mov ax, bx |
57 | 130 | add ax, word[esp + 16] |
|
- | 131 | mov ebx, ecx |
|
58 | cmp byte [esp+edx],0xeb |
132 | shl ebx, 16 |
- | 133 | mov bx, cx |
|
59 | jbe @f |
134 | |
60 | mov [esp+edx],byte 0xeb |
135 | ; calculate initial color |
Line -... | Line 136... | ||
- | 136 | mov ecx, esi |
|
- | 137 | cmp [buttontype], 0 |
|
- | 138 | je @f |
|
- | 139 | call button._.incecx2 |
|
- | 140 | ||
- | 141 | ; set button height counter |
|
- | 142 | @@: mov edx, edi |
|
61 | @@: |
143 | |
62 | add [esp+edx],byte 0x14 |
144 | .next_line: |
63 | 145 | call button._.button_dececx |
|
64 | dec edx |
- | |
65 | jns .loop |
146 | push edi |
66 | pop ecx |
147 | xor edi, edi |
- | 148 | call [draw_line] |
|
- | 149 | pop edi |
|
67 | pop edx |
150 | add ebx, 0x00010001 |
68 | ret |
151 | dec edx |
69 | 152 | jnz .next_line |
|
70 | drawbuttonframes: |
153 | |
71 | 154 | popad |
|
72 | push esi |
155 | |
73 | push edi |
156 | ; draw button frame |
74 | push eax |
157 | |
75 | push ebx |
158 | push ebx ecx |
76 | push ecx |
159 | |
77 | push edx |
160 | ; calculate window-relative coordinates |
78 | 161 | shr ebx, 16 |
|
Line -... | Line 162... | ||
- | 162 | shr ecx, 16 |
|
79 | shr ebx,16 |
163 | mov eax, [TASK_BASE] |
80 | shr ecx,16 |
164 | add ebx, [eax - twdw + WDATA.box.left] |
81 | mov eax,[TASK_BASE] |
165 | add ecx, [eax - twdw + WDATA.box.top] |
82 | 166 | ||
83 | add ebx,[eax-twdw + WDATA.box.left] |
167 | ; top border |
84 | add ecx,[eax-twdw + WDATA.box.top] |
168 | mov eax, ebx |
85 | mov eax, ebx |
169 | shl eax, 16 |
Line -... | Line 170... | ||
- | 170 | mov ax, bx |
|
86 | shl eax, 16 |
171 | add ax, [esp + 4] |
87 | mov ax, bx |
172 | mov ebx, ecx |
88 | add ax, word [esp+8] |
173 | shl ebx, 16 |
89 | mov ebx, ecx |
174 | mov bx, cx |
90 | shl ebx, 16 |
175 | push ebx |
91 | mov bx, cx |
176 | xor edi, edi |
92 | push ebx |
177 | mov ecx, esi |
93 | xor edi, edi |
178 | call button._.incecx |
94 | mov ecx, esi |
179 | call [draw_line] |
95 | call incecx |
- | |
96 | call [draw_line] |
180 | |
97 | 181 | ; bottom border |
|
98 | movzx edx,word [esp+4+4] |
182 | movzx edx, word[esp + 4 + 0] |
99 | add ebx,edx |
183 | add ebx, edx |
Line -... | Line 184... | ||
- | 184 | shl edx, 16 |
|
100 | shl edx,16 |
185 | add ebx, edx |
101 | add ebx,edx |
186 | mov ecx, esi |
102 | mov ecx,esi |
187 | call button._.dececx |
103 | call dececx |
188 | call [draw_line] |
104 | call [draw_line] |
189 | |
105 | 190 | ; left border |
|
106 | pop ebx |
191 | pop ebx |
107 | push edx |
192 | push edx |
Line 108... | Line -... | ||
108 | mov edx,eax |
- | |
109 | shr edx,16 |
- | |
110 | mov ax,dx |
193 | mov edx, eax |
111 | mov edx,ebx |
- | |
112 | shr edx,16 |
- | |
113 | mov bx,dx |
- | |
Line -... | Line 194... | ||
- | 194 | shr edx, 16 |
|
114 | mov dx,[esp+4+4] |
195 | mov ax, dx |
Line 115... | Line -... | ||
115 | add bx,dx |
- | |
116 | pop edx |
- | |
117 | mov ecx,esi |
- | |
118 | call incecx |
- | |
119 | call [draw_line] |
196 | mov edx, ebx |
120 | - | ||
121 | mov dx,[esp+8] |
- | |
122 | add ax,dx |
- | |
123 | shl edx,16 |
- | |
124 | add eax,edx |
- | |
125 | add ebx,1*65536 |
- | |
126 | mov ecx,esi |
- | |
127 | call dececx |
- | |
128 | call [draw_line] |
- | |
129 | - | ||
130 | pop edx |
- | |
131 | pop ecx |
- | |
132 | pop ebx |
- | |
133 | pop eax |
- | |
134 | pop edi |
- | |
135 | pop esi |
- | |
136 | - | ||
137 | ret |
- | |
138 | - | ||
139 | button_dececx: |
- | |
140 | - | ||
141 | cmp [buttontype],dword 1 |
- | |
142 | jne .finish |
- | |
143 | ; je bdece |
- | |
144 | ; ret |
- | |
145 | ; bdece: |
- | |
146 | push eax |
- | |
147 | mov eax,0x01 |
- | |
148 | cmp edi,20 |
- | |
149 | jg @f |
- | |
150 | mov eax,0x02 |
- | |
151 | @@: |
- | |
152 | test ecx,0xff |
- | |
153 | jz @f |
- | |
154 | sub ecx,eax |
- | |
155 | @@: |
- | |
156 | shl eax,8 |
- | |
157 | test ecx,0xff00 |
- | |
158 | jz @f |
- | |
159 | sub ecx,eax |
197 | shr edx, 16 |
160 | @@: |
- | |
161 | shl eax,8 |
- | |
162 | test ecx,0xff0000 |
- | |
163 | jz @f |
- | |
164 | sub ecx,eax |
- | |
165 | @@: |
- | |
166 | pop eax |
198 | mov bx, dx |
167 | .finish: |
- | |
168 | ret |
- | |
169 | - | ||
170 | - | ||
171 | sys_button: |
- | |
172 | - | ||
173 | mov eax, [current_slot] |
- | |
174 | rol ebx, 16 |
- | |
175 | add bx, word [eax+APPDATA.wnd_clientbox.left] |
- | |
176 | rol ebx, 16 |
- | |
177 | rol ecx, 16 |
- | |
178 | add cx, word [eax+APPDATA.wnd_clientbox.top] |
- | |
179 | rol ecx, 16 |
- | |
180 | .forced: |
- | |
181 | - | ||
182 | test edx, 0x80000000 |
- | |
183 | jnz remove_button |
- | |
184 | - | ||
185 | or bx, bx |
- | |
186 | jle noaddbutt |
- | |
187 | or cx, cx |
- | |
188 | jle noaddbutt |
- | |
189 | - | ||
190 | test edx, 0x40000000 |
- | |
191 | jnz button_no_draw |
- | |
192 | - | ||
193 | pushad ; button body |
- | |
194 | movzx edi, cx |
- | |
195 | shr ebx, 16 |
- | |
196 | shr ecx, 16 |
- | |
197 | mov eax, [TASK_BASE] |
- | |
198 | add ebx, [eax-twdw + WDATA.box.left] |
- | |
199 | add ecx, [eax-twdw + WDATA.box.top] |
- | |
200 | mov eax, ebx |
- | |
201 | shl eax, 16 |
- | |
202 | mov ax, bx |
- | |
203 | add ax, word [esp+16] |
- | |
204 | mov ebx, ecx |
- | |
205 | shl ebx, 16 |
199 | add bx, [esp + 4 + 0] |
206 | mov bx, cx |
- | |
207 | mov ecx, esi |
- | |
208 | cmp [buttontype], 0 |
- | |
209 | je @f |
- | |
210 | call incecx2 |
- | |
211 | @@: |
- | |
212 | mov edx, edi |
- | |
213 | - | ||
214 | .newline: |
- | |
215 | call button_dececx |
- | |
216 | push edi |
- | |
217 | xor edi, edi |
- | |
218 | call [draw_line] |
- | |
219 | pop edi |
- | |
220 | add ebx, 1*65536+1 ; [ y start | y end ] |
- | |
221 | dec edx |
- | |
222 | jnz .newline |
- | |
223 | popad |
- | |
224 | - | ||
225 | call drawbuttonframes |
- | |
226 | - | ||
227 | button_no_draw: |
- | |
228 | - | ||
229 | mov edi, [BTN_ADDR] |
- | |
230 | movzx eax, word [edi] |
- | |
231 | cmp eax, max_buttons |
- | |
232 | jge noaddbutt |
- | |
233 | inc eax |
- | |
234 | mov [edi], ax |
- | |
235 | - | ||
236 | shl eax, 4 |
- | |
237 | add edi, eax |
- | |
238 | - | ||
239 | mov ax, [CURRENT_TASK] |
- | |
240 | stosw |
- | |
241 | mov ax, dx |
200 | pop edx |
242 | stosw ; button id number: bits 0-15 |
- | |
243 | mov eax, ebx |
201 | mov ecx, esi |
- | 202 | call button._.incecx |
|
- | 203 | call [draw_line] |
|
- | 204 | ||
- | 205 | ; right border |
|
Line 244... | Line 206... | ||
244 | rol eax, 16 |
206 | mov dx, [esp + 4] |
245 | stosd ; x start | x size |
- | |
246 | mov eax, ecx |
207 | add ax, dx |
247 | rol eax, 16 |
208 | shl edx, 16 |
Line 248... | Line 209... | ||
248 | stosd ; y start | y size |
209 | add eax, edx |
- | 210 | add ebx, 0x00010000 |
|
Line -... | Line 211... | ||
- | 211 | mov ecx, esi |
|
249 | mov eax, edx |
212 | call button._.dececx |
250 | shr eax, 16 |
213 | call [draw_line] |
251 | stosw ; button id number: bits 16-31 |
214 | |
- | 215 | pop ecx ebx |
|
- | 216 | ||
- | 217 | .exit: |
|
- | 218 | ret |
|
- | 219 | ||
252 | 220 | ; FIXME: mutex needed |
|
253 | noaddbutt: |
221 | syscall_button.remove_button: |
254 | 222 | and edx, 0x00ffffff |
|
255 | ret |
- | |
256 | 223 | mov edi, [BTN_ADDR] |
|
257 | 224 | mov ebx, [edi] |
|
258 | remove_button: |
225 | inc ebx |
259 | 226 | imul esi, ebx, SYS_BUTTON.sizeof |
|
260 | and edx, 0x7fffffff |
227 | add esi, edi |
261 | - | ||
262 | rnewba2: |
- | |
263 | - | ||
264 | mov edi, [BTN_ADDR] |
- | |
265 | mov eax, edi |
- | |
266 | movzx ebx, word [edi] |
- | |
267 | inc ebx |
- | |
268 | - | ||
269 | rnewba: |
- | |
270 | - | ||
271 | dec ebx |
- | |
272 | jz rnmba |
- | |
273 | 228 | xor ecx, ecx |
|
274 | add eax, 0x10 |
- | |
275 | - | ||
276 | mov cx, [CURRENT_TASK] |
- | |
277 | cmp cx, [eax] |
- | |
278 | jnz rnewba |
- | |
279 | cmp dx, [eax+2] |
- | |
280 | jnz rnewba |
- | |
281 | - | ||
282 | lea ecx, [ebx+1] |
- | |
283 | shl ecx, 4 |
- | |
284 | mov ebx, eax |
- | |
285 | add eax, 0x10 |
- | |
286 | call memmove |
- | |
287 | dec dword [edi] |
- | |
288 | jmp rnewba2 |
- | |
289 | - | ||
290 | rnmba: |
- | |
291 | - | ||
292 | ret |
- | |
293 | - | ||
294 | find_pressed_button_frames: |
- | |
295 | - | ||
296 | pushad |
- | |
297 | - | ||
298 | movzx ebx,word [eax+0] |
- | |
299 | shl ebx,5 |
- | |
300 | add ebx,window_data |
- | |
301 | mov ecx, [ebx+ WDATA.box.left] ; window x start |
- | |
302 | movzx edx,word [eax+4] ; button x start |
- | |
303 | add ecx,edx |
- | |
304 | push ecx |
- | |
305 | - | ||
306 | mov dx,[eax+6] ; button x size |
- | |
307 | add cx,dx |
- | |
308 | mov esi,ecx |
- | |
309 | inc esi |
- | |
310 | mov ecx, [ebx+WDATA.box.top] ; window y start |
- | |
311 | mov dx,[eax+8] ; button y start |
- | |
312 | add ecx,edx |
- | |
313 | mov ebx,ecx |
- | |
314 | mov dx,[eax+10] ; button y size |
- | |
315 | add dx,cx |
- | |
316 | inc dx |
- | |
317 | - | ||
318 | pop eax |
- | |
319 | - | ||
320 | ; eax x beginning |
- | |
321 | ; ebx y beginning |
- | |
322 | ; esi x end |
229 | add ecx, -SYS_BUTTON.sizeof |
323 | ; edx y end |
- | |
324 | ; ecx color |
- | |
325 | - | ||
326 | mov [pressed_button_eax],eax |
- | |
327 | mov [pressed_button_ebx],ebx |
- | |
328 | mov [pressed_button_ecx],ecx |
- | |
329 | mov [pressed_button_edx],edx |
- | |
330 | mov [pressed_button_esi],esi |
- | |
331 | - | ||
332 | popad |
- | |
333 | ret |
- | |
334 | - | ||
335 | uglobal |
- | |
336 | pressed_button_eax dd 0 |
- | |
337 | pressed_button_ebx dd 0 |
- | |
338 | pressed_button_ecx dd 0 |
- | |
339 | pressed_button_edx dd 0 |
- | |
340 | pressed_button_esi dd 0 |
- | |
341 | endg |
- | |
342 | - | ||
343 | ; negative button image |
- | |
344 | - | ||
345 | negativebutton: |
- | |
346 | ; If requested, do not display button |
- | |
347 | ; boarder on press. |
- | |
348 | test ebx,0x20000000 |
- | |
349 | jz draw_negative_button |
- | |
350 | ret |
- | |
351 | draw_negative_button: |
- | |
352 | - | ||
353 | pushad |
- | |
354 | - | ||
355 | mov eax,[pressed_button_eax] |
- | |
356 | mov ebx,[pressed_button_ebx] |
- | |
357 | mov ecx,[pressed_button_ecx] |
- | |
358 | mov edx,[pressed_button_edx] |
- | |
359 | mov esi,[pressed_button_esi] |
- | |
360 | mov ecx,0x01000000 |
- | |
361 | - | ||
362 | dec edx |
- | |
363 | push edx |
- | |
364 | inc edx |
- | |
365 | dec esi |
- | |
366 | push esi |
- | |
367 | inc esi |
- | |
368 | - | ||
369 | push eax |
- | |
370 | push ebx |
- | |
371 | push ecx |
- | |
372 | push edx |
- | |
373 | push edi |
- | |
374 | - | ||
375 | call [_display.disable_mouse] |
- | |
376 | - | ||
377 | bdbnewline: |
- | |
378 | mov edi,1 ; force |
- | |
379 | cmp eax,[esp+16] |
- | |
Line -... | Line 230... | ||
- | 230 | ||
380 | jz bneg |
231 | .next_button: |
Line 381... | Line -... | ||
381 | cmp eax,[esp+20] |
- | |
382 | jz bneg |
- | |
383 | cmp ebx,[esp+12] |
- | |
384 | jz bneg |
- | |
385 | cmp ebx,[esp+24] |
- | |
386 | jnz nbneg |
- | |
387 | ; jz bneg |
- | |
388 | ; jmp nbneg |
- | |
389 | - | ||
390 | bneg: |
- | |
391 | - | ||
392 | call [putpixel] |
- | |
393 | - | ||
394 | nbneg: |
- | |
395 | - | ||
396 | inc eax |
232 | dec ebx |
- | 233 | jz .exit |
|
- | 234 | ||
- | 235 | add ecx, SYS_BUTTON.sizeof |
|
397 | cmp eax,esi |
236 | add esi, -SYS_BUTTON.sizeof |
398 | jnz bdbnewline |
- | |
- | 237 | ||
399 | mov eax,[esp+16] |
238 | ; does it belong to our process? |
400 | inc ebx |
239 | mov ax, [CURRENT_TASK] |
401 | cmp ebx,edx |
- | |
402 | jnz bdbnewline |
240 | cmp ax, [esi + SYS_BUTTON.pslot] |
403 | - | ||
404 | add esp,28 |
241 | jne .next_button |
405 | - | ||
406 | popad |
- | |
Line -... | Line 242... | ||
- | 242 | ||
407 | 243 | ; does the identifier match? |
|
408 | ret |
244 | mov eax, dword[esi + SYS_BUTTON.id_hi - 2] |
409 | 245 | mov ax, [esi + SYS_BUTTON.id_lo] |
|
410 | ; check buttons |
246 | and eax, 0x00ffffff |
411 | 247 | cmp edx, eax |
|
412 | 248 | jne .next_button |
|
413 | ; 0000 word process number |
249 | |
Line 414... | Line -... | ||
414 | ; 0002 word button id number : bits 0-15 |
- | |
415 | ; 0004 word x start |
- | |
416 | ; 0006 word x size |
250 | ; okay, undefine it |
417 | ; 0008 word y start |
251 | mov ebx, esi |
418 | ; 000A word y size |
252 | lea eax, [esi + SYS_BUTTON.sizeof] |
419 | ; 000C word button id number : bits 16-31 |
253 | call memmove |
420 | ; |
254 | dec dword[edi] |
421 | ; button table in 0x10 increments |
255 | add ecx, -SYS_BUTTON.sizeof |
422 | ; |
256 | jmp .next_button |
423 | ; first at 0x10 |
257 | |
424 | 258 | .exit: |
|
425 | align 4 |
- | |
426 | checkbuttons: |
259 | ret |
427 | 260 | ||
428 | cmp [BTN_DOWN],byte 0 ; mouse buttons pressed |
- | |
Line 429... | Line 261... | ||
429 | jnz @f |
261 | align 4 |
430 | ;..................................... start 1/5 : modified by vhanla ............................. |
262 | ;------------------------------------------------------------------------------ |
431 | mov [bPressedMouseXY_B],0 |
263 | check_buttons: ;/////////////////////////////////////////////////////////////// |
Line 432... | Line 264... | ||
432 | ;..................................... end 1/5 : modified by vhanla ............................. |
264 | ;------------------------------------------------------------------------------ |
433 | ret |
- | |
434 | @@: |
265 | ; |
435 | pushad |
266 | ;------------------------------------------------------------------------------ |
436 | 267 | cmp byte[BTN_DOWN], 0 ; mouse buttons pressed |
|
437 | xor esi, esi |
268 | jnz @f |
438 | mov edi, [BTN_ADDR] |
269 | mov [bPressedMouseXY_B], 0 |
Line 439... | Line 270... | ||
439 | movzx edx, word [edi] |
270 | ret |
440 | test edx, edx |
271 | |
Line 441... | Line 272... | ||
441 | jne @f |
272 | @@: pushad |
442 | popad |
- | |
443 | ret |
273 | xor esi, esi |
444 | 274 | mov edi, [BTN_ADDR] |
|
445 | @@: |
275 | mov edx, [edi] |
446 | ;..................................... start 2/5 : modified by vhanla ............................. |
276 | test edx, edx |
447 | ;here i catch the coordinates when the mouse's button is clicked |
277 | jne @f |
Line 448... | Line 278... | ||
448 | push ax |
278 | popad |
449 | cmp [bPressedMouseXY_B],0;FALSE |
- | |
450 | jnz @f |
279 | ret |
451 | mov [bPressedMouseXY_B],1;TRUE - it was already clicked |
280 | |
452 | mov ax,[MOUSE_X] |
281 | ;here i catch the coordinates when the mouse's button is clicked |
453 | mov [mx],ax |
282 | @@: push ax |
Line 454... | Line 283... | ||
454 | mov ax,[MOUSE_Y] |
283 | cmp [bPressedMouseXY_B], 0 ; FALSE |
455 | mov [my],ax |
- | |
456 | @@: |
- | |
457 | pop ax |
284 | jnz @f |
Line 458... | Line 285... | ||
458 | ;and it is only refreshed after the mouse's button release |
285 | mov [bPressedMouseXY_B], 1 ; TRUE - it was already clicked |
459 | ;..................................... end 2/5 : modified by vhanla ............................. |
286 | mov ax, [MOUSE_X] |
Line 460... | Line -... | ||
460 | - | ||
461 | push esi |
- | |
462 | inc edx |
287 | mov [mx], ax |
463 | push edx |
288 | mov ax, [MOUSE_Y] |
464 | 289 | mov [my], ax |
|
Line 465... | Line -... | ||
465 | buttonnewcheck: |
- | |
466 | 290 | @@: pop ax |
|
467 | pop edx |
291 | ;and it is only refreshed after the mouse's button release |
468 | pop esi |
292 | |
Line 469... | Line 293... | ||
469 | inc esi |
293 | push esi |
- | 294 | inc edx |
|
470 | cmp edx,esi |
295 | push edx |
471 | jge bch |
- | |
472 | - | ||
473 | popad ; no button pressed |
296 | |
474 | ret |
297 | .buttonnewcheck: |
475 | 298 | pop edx |
|
476 | bch: |
299 | pop esi |
477 | - | ||
478 | push esi |
300 | inc esi |
479 | push edx |
- | |
480 | mov eax,esi |
301 | cmp edx, esi |
481 | shl eax,4 |
302 | jge .bch |
Line 482... | Line 303... | ||
482 | add eax,edi |
303 | |
483 | 304 | popad |
|
484 | ; check that button is at top of windowing stack |
305 | ret |
485 | 306 | ||
Line 486... | Line 307... | ||
486 | movzx ebx,word [eax] |
307 | .bch: |
487 | movzx ecx,word [WIN_STACK + ebx * 2] |
308 | push esi |
488 | cmp ecx,[TASK_COUNT] |
309 | push edx |
489 | jne buttonnewcheck |
310 | mov eax, esi |
490 | 311 | shl eax, 4 |
|
491 | ; check that button start is inside window x/y end |
312 | add eax, edi |
492 | 313 | ||
493 | movzx ebx,word [eax+0] |
- | |
494 | shl ebx,5 |
314 | ; check that button is at top of windowing stack |
495 | - | ||
496 | test [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED |
315 | movzx ebx, [eax + SYS_BUTTON.pslot] |
497 | jnz buttonnewcheck |
316 | movzx ecx, word[WIN_STACK + ebx * 2] |
Line 498... | Line 317... | ||
498 | 317 | cmp ecx, [TASK_COUNT] |
|
499 | ; add ebx,window_data |
318 | jne .buttonnewcheck |
500 | ; mov ecx,[window_data+ebx+8] ; window end X |
319 | |
501 | movzx edx,word [eax+4] ; button start X |
320 | ; check that button start is inside window x/y end |
Line 502... | Line 321... | ||
502 | cmp edx, [window_data+ebx+WDATA.box.width] ;ecx |
321 | shl ebx, 5 |
Line 503... | Line 322... | ||
503 | jge buttonnewcheck |
322 | |
504 | 323 | test [ebx + window_data + WDATA.fl_wstate], WSTATE_MINIMIZED |
|
Line 505... | Line 324... | ||
505 | ; mov ecx,[window_data+ebx+12] ; window end Y |
324 | jnz .buttonnewcheck |
506 | movzx edx, word [eax+8] ; button start Y |
- | |
507 | cmp edx, [window_data+ebx+WDATA.box.height] ;ecx |
325 | |
508 | jge buttonnewcheck |
326 | movzx edx, [eax + SYS_BUTTON.left] |
Line 509... | Line 327... | ||
509 | 327 | cmp edx, [window_data + ebx + WDATA.box.width] ;ecx |
|
510 | ; check coordinates |
- | |
511 | ; mouse x >= button x ? |
328 | jge .buttonnewcheck |
Line 512... | Line 329... | ||
512 | movzx ebx,word [eax+0] |
329 | |
513 | shl ebx,5 |
- | |
514 | add ebx,window_data |
330 | movzx edx, [eax + SYS_BUTTON.top] |
515 | mov ecx, [ebx+WDATA.box.left] ; window x start |
331 | cmp edx, [window_data + ebx + WDATA.box.height] ;ecx |
516 | movzx edx,word [eax+4] ; button x start |
332 | jge .buttonnewcheck |
517 | add edx,ecx |
333 | |
518 | ;..................................... start 3/5 : modified by vhanla ............................. |
- | |
519 | mov cx,[mx] ;mov cx,[MOUSE_X] |
- | |
520 | ;..................................... end 3/5 : modified by vhanla ............................. |
- | |
Line -... | Line 334... | ||
- | 334 | ; check coordinates |
|
521 | cmp edx,ecx |
335 | |
522 | jg buttonnewcheck |
- | |
523 | 336 | ; mouse x >= button x ? |
|
Line 524... | Line 337... | ||
524 | movzx ebx,word [eax+6] ; button x size |
337 | add ebx, window_data |
525 | add edx,ebx |
338 | mov ecx, [ebx + WDATA.box.left] |
526 | cmp ecx,edx |
339 | movzx edx, [eax + SYS_BUTTON.left] |
Line 527... | Line 340... | ||
527 | jg buttonnewcheck |
340 | add edx, ecx |
528 | 341 | mov cx, [mx] ;mov cx,[MOUSE_X] |
|
529 | ; mouse y >= button y ? |
342 | cmp edx, ecx |
Line 530... | Line 343... | ||
530 | movzx ebx,word [eax+0] |
343 | jg .buttonnewcheck |
531 | shl ebx,5 |
344 | |
532 | add ebx,window_data |
345 | movzx ebx, [eax + SYS_BUTTON.width] |
533 | mov ecx, [ebx+WDATA.box.top] ; window y start |
- | |
534 | movzx edx,word [eax+8] ; button y start |
- | |
535 | add edx,ecx |
- | |
536 | ;..................................... start 4/5 : modified by vhanla ............................. |
- | |
537 | mov cx,[my] ;mov cx,[MOUSE_Y] |
- | |
538 | ;..................................... start 4/5 : modified by vhanla ............................. |
- | |
539 | cmp edx,ecx |
- | |
540 | jg buttonnewcheck |
- | |
Line -... | Line 346... | ||
- | 346 | add edx, ebx |
|
541 | 347 | cmp ecx, edx |
|
- | 348 | jg .buttonnewcheck |
|
542 | movzx ebx,word [eax+10] ; button y size |
349 | |
543 | add edx,ebx |
350 | ; mouse y >= button y ? |
544 | cmp ecx,edx |
351 | movzx ebx, [eax + SYS_BUTTON.pslot] |
545 | jg buttonnewcheck |
352 | shl ebx, 5 |
546 | 353 | add ebx, window_data |
|
547 | ; mouse on button |
354 | mov ecx, [ebx + WDATA.box.top] |
548 | 355 | movzx edx, [eax + SYS_BUTTON.top] |
|
549 | pop edx |
356 | add edx, ecx |
550 | pop esi |
357 | mov cx, [my] ;mov cx,[MOUSE_Y] |
551 | 358 | cmp edx, ecx |
|
Line 552... | Line 359... | ||
552 | mov bx,[eax+0xc] ; button id : bits 16-31 |
359 | jg .buttonnewcheck |
553 | shl ebx,16 |
360 | |
554 | mov bx,[eax+2] ; button id : bits 00-16 |
361 | movzx ebx, [eax + SYS_BUTTON.height] |
555 | push ebx |
362 | add edx, ebx |
Line 556... | Line 363... | ||
556 | 363 | cmp ecx, edx |
|
557 | mov [MOUSE_DOWN],byte 1 ; no mouse down checks |
364 | jg .buttonnewcheck |
558 | call find_pressed_button_frames |
365 | |
559 | call negativebutton |
366 | ; mouse on button |
560 | 367 | ||
561 | pushad |
368 | pop edx |
562 | ; // Alver 22.06.2008 // { |
369 | pop esi |
563 | push eax |
370 | |
564 | mov al, byte [BTN_DOWN] |
371 | mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] ; button id : bits 16-31 |
565 | mov byte [btn_down_determ], al |
372 | mov bx, [eax + SYS_BUTTON.id_lo] ; button id : bits 00-16 |
Line 566... | Line 373... | ||
566 | pop eax |
373 | push ebx |
567 | ; } \\ Alver \\ |
374 | |
568 | 375 | mov byte[MOUSE_DOWN], 1 ; no mouse down checks |
|
569 | cbwaitmouseup: |
376 | call button._.negative_button |
- | 377 | ||
570 | 378 | pushad |
|
- | 379 | push eax |
|
571 | call checkidle |
380 | mov al, [BTN_DOWN] |
572 | 381 | mov byte[btn_down_determ], al |
|
573 | call [draw_pointer] |
382 | pop eax |
574 | 383 | ||
575 | pushad |
384 | .cbwaitmouseup: |
576 | call stack_handler |
385 | call checkidle |
- | 386 | call [draw_pointer] |
|
577 | popad |
387 | |
578 | 388 | pushad |
|
- | 389 | call stack_handler |
|
579 | cmp [BTN_DOWN],byte 0 ; mouse buttons pressed ? |
390 | popad |
580 | jnz cbwaitmouseup |
391 | |
581 | popad |
392 | cmp byte[BTN_DOWN], 0 ; mouse buttons pressed ? |
582 | 393 | jnz .cbwaitmouseup |
|
583 | call negativebutton |
394 | popad |
584 | mov [MOUSE_BACKGROUND],byte 0 ; no mouse background |
395 | |
Line -... | Line 396... | ||
- | 396 | call button._.negative_button |
|
- | 397 | mov byte[MOUSE_BACKGROUND], 0 ; no mouse background |
|
- | 398 | mov byte[DONT_DRAW_MOUSE], 0 ; draw mouse |
|
- | 399 | ||
- | 400 | ; check coordinates |
|
- | 401 | pusha |
|
- | 402 | ||
- | 403 | ; mouse x >= button x ? |
|
- | 404 | movzx ebx, [eax + SYS_BUTTON.pslot] |
|
- | 405 | shl ebx, 5 |
|
- | 406 | add ebx, window_data |
|
- | 407 | mov ecx, [ebx + WDATA.box.left] |
|
- | 408 | movzx edx, [eax + SYS_BUTTON.left] |
|
- | 409 | add edx, ecx |
|
- | 410 | mov cx, [MOUSE_X] |
|
- | 411 | cmp edx, ecx |
|
- | 412 | jg .no_on_button ;if we release the pointer out of the button area |
|
- | 413 | ||
- | 414 | movzx ebx, [eax + SYS_BUTTON.width] |
|
- | 415 | add edx, ebx |
|
- | 416 | cmp ecx, edx |
|
- | 417 | jg .no_on_button |
|
- | 418 | ||
- | 419 | ; mouse y >= button y ? |
|
- | 420 | movzx ebx, [eax + SYS_BUTTON.pslot] |
|
- | 421 | shl ebx, 5 |
|
- | 422 | add ebx, window_data |
|
- | 423 | mov ecx, [ebx + WDATA.box.top] |
|
- | 424 | movzx edx, [eax + SYS_BUTTON.top] |
|
- | 425 | add edx, ecx |
|
- | 426 | mov cx, [MOUSE_Y] |
|
- | 427 | cmp edx, ecx |
|
- | 428 | jg .no_on_button |
|
- | 429 | ||
- | 430 | movzx ebx, [eax + SYS_BUTTON.height] |
|
- | 431 | add edx, ebx |
|
- | 432 | cmp ecx, edx |
|
- | 433 | jg .no_on_button |
|
- | 434 | ||
- | 435 | popa |
|
- | 436 | ||
- | 437 | mov byte[BTN_COUNT], 1 ; no of buttons in buffer |
|
- | 438 | pop ebx |
|
- | 439 | mov [BTN_BUFF], ebx ; lets put the button id in buffer |
|
- | 440 | push ebx |
|
- | 441 | pusha |
|
- | 442 | jmp .yes_on_button |
|
- | 443 | ||
- | 444 | .no_on_button: |
|
- | 445 | mov byte[BTN_COUNT], 0 ; no of buttons in buffer |
|
- | 446 | ||
- | 447 | .yes_on_button: |
|
- | 448 | mov byte[MOUSE_DOWN], 0 ; mouse down -> do not draw |
|
- | 449 | popa |
|
- | 450 | pop ebx |
|
- | 451 | popa |
|
- | 452 | ret |
|
- | 453 | ||
- | 454 | ;============================================================================== |
|
- | 455 | ;///// private functions ////////////////////////////////////////////////////// |
|
- | 456 | ;============================================================================== |
|
- | 457 | ||
- | 458 | ;------------------------------------------------------------------------------ |
|
- | 459 | button._.dececx: ;///////////////////////////////////////////////////////////// |
|
- | 460 | ;------------------------------------------------------------------------------ |
|
- | 461 | ; |
|
- | 462 | ;------------------------------------------------------------------------------ |
|
- | 463 | sub cl, 0x20 |
|
- | 464 | jnc @f |
|
- | 465 | xor cl, cl |
|
- | 466 | @@: sub ch, 0x20 |
|
- | 467 | jnc @f |
|
- | 468 | xor ch, ch |
|
- | 469 | @@: rol ecx, 16 |
|
- | 470 | sub cl, 0x20 |
|
- | 471 | jnc @f |
|
- | 472 | xor cl, cl |
|
- | 473 | @@: rol ecx, 16 |
|
- | 474 | ret |
|
- | 475 | ||
- | 476 | ;------------------------------------------------------------------------------ |
|
- | 477 | button._.incecx: ;///////////////////////////////////////////////////////////// |
|
- | 478 | ;------------------------------------------------------------------------------ |
|
- | 479 | ; |
|
- | 480 | ;------------------------------------------------------------------------------ |
|
- | 481 | add cl, 0x20 |
|
- | 482 | jnc @f |
|
- | 483 | or cl, -1 |
|
- | 484 | @@: add ch, 0x20 |
|
- | 485 | jnc @f |
|
585 | mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse |
486 | or ch, -1 |
- | 487 | @@: rol ecx, 16 |
|
- | 488 | add cl, 0x20 |
|
- | 489 | jnc @f |
|
- | 490 | or cl, -1 |
|
- | 491 | @@: rol ecx, 16 |
|
- | 492 | ret |
|
- | 493 | ||
- | 494 | ;------------------------------------------------------------------------------ |
|
- | 495 | button._.incecx2: ;//////////////////////////////////////////////////////////// |
|
- | 496 | ;------------------------------------------------------------------------------ |
|
- | 497 | ; |
|
- | 498 | ;------------------------------------------------------------------------------ |
|
- | 499 | add cl, 0x14 |
|
- | 500 | jnc @f |
|
- | 501 | or cl, -1 |
|
- | 502 | @@: add ch, 0x14 |
|
- | 503 | jnc @f |
|
- | 504 | or ch, -1 |
|
- | 505 | @@: rol ecx, 16 |
|
- | 506 | add cl, 0x14 |
|
- | 507 | jnc @f |
|
- | 508 | or cl, -1 |
|
- | 509 | @@: rol ecx, 16 |
|
- | 510 | ret |
|
- | 511 | ||
- | 512 | ;------------------------------------------------------------------------------ |
|
- | 513 | button._.button_dececx: ;////////////////////////////////////////////////////// |
|
- | 514 | ;------------------------------------------------------------------------------ |
|
- | 515 | ; |
|
- | 516 | ;------------------------------------------------------------------------------ |
|
- | 517 | cmp [buttontype], 1 |
|
- | 518 | jne .finish |
|
- | 519 | ||
- | 520 | push eax |
|
- | 521 | mov al, 1 |
|
- | 522 | cmp edi, 20 |
|
- | 523 | jg @f |
|
- | 524 | mov al, 2 |
|
- | 525 | ||
- | 526 | @@: sub cl, al |
|
- | 527 | jnc @f |
|
- | 528 | xor cl, cl |
|
- | 529 | @@: sub ch, al |
|
- | 530 | jnc @f |
|
- | 531 | xor ch, ch |
|
- | 532 | @@: rol ecx, 16 |
|
- | 533 | sub cl, al |
|
- | 534 | jnc @f |
|
- | 535 | xor cl, cl |
|
- | 536 | @@: rol ecx, 16 |
|
- | 537 | ||
- | 538 | pop eax |
|
- | 539 | ||
- | 540 | .finish: |
|
- | 541 | ret |
|
- | 542 | ||
- | 543 | ;------------------------------------------------------------------------------ |
|
- | 544 | button._.negative_button: ;//////////////////////////////////////////////////// |
|
- | 545 | ;------------------------------------------------------------------------------ |
|
- | 546 | ; |
|
- | 547 | ;------------------------------------------------------------------------------ |
|
- | 548 | ; If requested, do not display button border on press. |
|
- | 549 | test ebx, 0x20000000 |
|
- | 550 | jz .draw_negative_button |
|
- | 551 | ret |
|
- | 552 | ||
- | 553 | .draw_negative_button: |
|
- | 554 | pushad |
|
- | 555 | ||
- | 556 | mov ebx, dword[eax + SYS_BUTTON.left] |
|
- | 557 | mov ecx, dword[eax + SYS_BUTTON.top] |
|
- | 558 | rol ebx, 16 |
|
- | 559 | rol ecx, 16 |
|
- | 560 | push ebx ecx |