Rev 1381 | Rev 2288 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1381 | Rev 1391 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2010. 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 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
7 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 8... | Line 8... | ||
8 | 8 | ||
9 | $Revision: 1381 $ |
- | |
10 | - | ||
11 | - | ||
12 | button._.MAX_BUTTONS = 4095 |
- | |
Line 13... | Line 9... | ||
13 | 9 | $Revision: 1391 $ |
|
14 | 10 | ||
15 | ;============================================================================== |
11 | ;============================================================================== |
Line -... | Line 12... | ||
- | 12 | ;///// public functions /////////////////////////////////////////////////////// |
|
- | 13 | ;============================================================================== |
|
16 | ;///// public functions /////////////////////////////////////////////////////// |
14 | |
17 | ;============================================================================== |
15 | button.MAX_BUTTONS = 4095 |
18 | 16 | ||
19 | struc SYS_BUTTON |
17 | struc SYS_BUTTON |
20 | { |
18 | { |
21 | .pslot dw ? |
19 | .pslot dw ? |
22 | .id_lo dw ? |
20 | .id_lo dw ? |
23 | .left dw ? |
21 | .left dw ? |
24 | .width dw ? |
22 | .width dw ? |
25 | .top dw ? |
23 | .top dw ? |
26 | .height dw ? |
24 | .height dw ? |
27 | .id_hi dw ? |
25 | .id_hi dw ? |
28 | .align dw ? |
26 | dw ? |
29 | .sizeof: |
27 | .sizeof: |
30 | } |
28 | } |
Line 31... | Line -... | ||
31 | virtual at 0 |
- | |
32 | SYS_BUTTON SYS_BUTTON |
- | |
33 | end virtual |
- | |
34 | - | ||
35 | iglobal |
- | |
36 | mx dw 0x0 ; keeps the x mouse's position when it was clicked |
- | |
37 | my dw 0x0 ; keeps the y mouse's position when it was clicked |
- | |
38 | bPressedMouseXY_B db 0x0 |
29 | virtual at 0 |
39 | btn_down_determ db 0x0 |
30 | SYS_BUTTON SYS_BUTTON |
40 | endg |
31 | end virtual |
41 | 32 | ||
42 | align 4 |
33 | align 4 |
Line 65... | Line 56... | ||
65 | jnz .remove_button |
56 | jnz .remove_button |
Line 66... | Line 57... | ||
66 | 57 | ||
67 | ; do we have free button slots available? |
58 | ; do we have free button slots available? |
68 | mov edi, [BTN_ADDR] |
59 | mov edi, [BTN_ADDR] |
69 | mov eax, [edi] |
60 | mov eax, [edi] |
70 | cmp eax, button._.MAX_BUTTONS |
61 | cmp eax, button.MAX_BUTTONS |
Line 71... | Line 62... | ||
71 | jge .exit |
62 | jge .exit |
72 | 63 | ||
73 | ; does it have positive size? (otherwise it doesn't have sense) |
64 | ; does it have positive size? (otherwise it doesn't have sense) |
Line 226... | Line 217... | ||
226 | inc ebx |
217 | inc ebx |
227 | imul esi, ebx, SYS_BUTTON.sizeof |
218 | imul esi, ebx, SYS_BUTTON.sizeof |
228 | add esi, edi |
219 | add esi, edi |
229 | xor ecx, ecx |
220 | xor ecx, ecx |
230 | add ecx, -SYS_BUTTON.sizeof |
221 | add ecx, -SYS_BUTTON.sizeof |
- | 222 | add esi, SYS_BUTTON.sizeof |
|
Line 231... | Line 223... | ||
231 | 223 | ||
232 | .next_button: |
224 | .next_button: |
233 | dec ebx |
225 | dec ebx |
Line 261... | Line 253... | ||
261 | .exit: |
253 | .exit: |
262 | ret |
254 | ret |
Line 263... | Line 255... | ||
263 | 255 | ||
264 | align 4 |
256 | align 4 |
265 | ;------------------------------------------------------------------------------ |
257 | ;------------------------------------------------------------------------------ |
266 | check_buttons: ;/////////////////////////////////////////////////////////////// |
258 | sys_button_activate_handler: ;///////////////////////////////////////////////// |
267 | ;------------------------------------------------------------------------------ |
259 | ;------------------------------------------------------------------------------ |
268 | ;? |
260 | ;? |
269 | ;------------------------------------------------------------------------------ |
261 | ;------------------------------------------------------------------------------ |
270 | cmp byte[BTN_DOWN], 0 ; mouse buttons pressed |
- | |
271 | jnz @f |
- | |
272 | mov [bPressedMouseXY_B], 0 |
- | |
273 | ret |
- | |
274 | - | ||
275 | @@: pushad |
- | |
276 | xor esi, esi |
- | |
277 | mov edi, [BTN_ADDR] |
- | |
278 | mov edx, [edi] |
- | |
279 | test edx, edx |
- | |
280 | jne @f |
- | |
281 | popad |
- | |
282 | ret |
- | |
283 | 262 | ;> eax = pack[8(process slot), 24(button id)] |
|
284 | ;here i catch the coordinates when the mouse's button is clicked |
- | |
285 | @@: push ax |
263 | ;> ebx = pack[16(button x coord), 16(button y coord)] |
286 | cmp [bPressedMouseXY_B], 0 ; FALSE |
- | |
287 | jnz @f |
264 | ;> cl = mouse button mask this system button was pressed with |
288 | mov [bPressedMouseXY_B], 1 ; TRUE - it was already clicked |
- | |
289 | mov ax, [MOUSE_X] |
- | |
290 | mov [mx], ax |
265 | ;------------------------------------------------------------------------------ |
291 | mov ax, [MOUSE_Y] |
266 | call button._.find_button |
292 | mov [my], ax |
- | |
293 | @@: pop ax |
- | |
294 | ;and it is only refreshed after the mouse's button release |
- | |
295 | - | ||
296 | push esi |
267 | or eax, eax |
297 | inc edx |
- | |
Line 298... | Line -... | ||
298 | push edx |
- | |
299 | - | ||
300 | .buttonnewcheck: |
- | |
301 | pop edx |
- | |
302 | pop esi |
268 | jz .exit |
303 | inc esi |
269 | |
Line 304... | Line 270... | ||
304 | cmp edx, esi |
270 | mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] |
305 | jge .bch |
271 | call button._.negative_button |
Line 306... | Line 272... | ||
306 | 272 | ||
307 | popad |
- | |
308 | ret |
- | |
309 | - | ||
310 | .bch: |
- | |
311 | push esi |
- | |
312 | push edx |
- | |
313 | mov eax, esi |
273 | .exit: |
314 | shl eax, 4 |
- | |
315 | add eax, edi |
- | |
316 | - | ||
317 | ; check that button is at top of windowing stack |
- | |
318 | movzx ebx, [eax + SYS_BUTTON.pslot] |
- | |
319 | movzx ecx, word[WIN_STACK + ebx * 2] |
274 | ret |
320 | cmp ecx, [TASK_COUNT] |
- | |
321 | jne .buttonnewcheck |
- | |
322 | 275 | ||
323 | ; check that button start is inside window x/y end |
- | |
324 | shl ebx, 5 |
- | |
325 | - | ||
326 | test [ebx + window_data + WDATA.fl_wstate], WSTATE_MINIMIZED |
- | |
327 | jnz .buttonnewcheck |
276 | align 4 |
328 | - | ||
329 | movzx edx, [eax + SYS_BUTTON.left] |
- | |
330 | cmp edx, [window_data + ebx + WDATA.box.width] ;ecx |
277 | ;------------------------------------------------------------------------------ |
331 | jge .buttonnewcheck |
- | |
332 | - | ||
333 | movzx edx, [eax + SYS_BUTTON.top] |
- | |
334 | cmp edx, [window_data + ebx + WDATA.box.height] ;ecx |
- | |
335 | jge .buttonnewcheck |
278 | sys_button_deactivate_handler: ;/////////////////////////////////////////////// |
336 | - | ||
337 | ; check coordinates |
- | |
338 | - | ||
339 | ; mouse x >= button x ? |
- | |
340 | add ebx, window_data |
- | |
341 | mov ecx, [ebx + WDATA.box.left] |
- | |
342 | movzx edx, [eax + SYS_BUTTON.left] |
- | |
343 | add edx, ecx |
- | |
344 | mov cx, [mx] ;mov cx,[MOUSE_X] |
- | |
345 | cmp edx, ecx |
- | |
346 | jg .buttonnewcheck |
- | |
347 | - | ||
348 | movzx ebx, [eax + SYS_BUTTON.width] |
- | |
349 | add edx, ebx |
279 | ;------------------------------------------------------------------------------ |
350 | cmp ecx, edx |
280 | ;? |
351 | jg .buttonnewcheck |
- | |
352 | - | ||
353 | ; mouse y >= button y ? |
- | |
354 | movzx ebx, [eax + SYS_BUTTON.pslot] |
- | |
355 | shl ebx, 5 |
- | |
356 | add ebx, window_data |
281 | ;------------------------------------------------------------------------------ |
357 | mov ecx, [ebx + WDATA.box.top] |
- | |
358 | movzx edx, [eax + SYS_BUTTON.top] |
282 | ;> eax = pack[8(process slot), 24(button id)] |
359 | add edx, ecx |
- | |
360 | mov cx, [my] ;mov cx,[MOUSE_Y] |
- | |
361 | cmp edx, ecx |
283 | ;> ebx = pack[16(button x coord), 16(button y coord)] |
362 | jg .buttonnewcheck |
284 | ;> cl = mouse button mask this system button was pressed with |
363 | - | ||
Line -... | Line 285... | ||
- | 285 | ;------------------------------------------------------------------------------ |
|
364 | movzx ebx, [eax + SYS_BUTTON.height] |
286 | call button._.find_button |
Line 365... | Line 287... | ||
365 | add edx, ebx |
287 | or eax, eax |
366 | cmp ecx, edx |
288 | jz .exit |
Line -... | Line 289... | ||
- | 289 | ||
- | 290 | mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] |
|
- | 291 | call button._.negative_button |
|
- | 292 | ||
- | 293 | .exit: |
|
- | 294 | ret |
|
- | 295 | ||
- | 296 | align 4 |
|
367 | jg .buttonnewcheck |
297 | ;------------------------------------------------------------------------------ |
- | 298 | sys_button_perform_handler: ;////////////////////////////////////////////////// |
|
- | 299 | ;------------------------------------------------------------------------------ |
|
- | 300 | ;? |
|
- | 301 | ;------------------------------------------------------------------------------ |
|
368 | 302 | ;> eax = pack[8(process slot), 24(button id)] |
|
369 | ; mouse on button |
303 | ;> ebx = pack[16(button x coord), 16(button y coord)] |
- | 304 | ;> cl = mouse button mask this system button was pressed with |
|
- | 305 | ;------------------------------------------------------------------------------ |
|
Line 370... | Line 306... | ||
370 | 306 | shl eax, 8 |
|
371 | pop edx |
307 | mov al, cl |
- | 308 | movzx ebx, byte[BTN_COUNT] |
|
Line -... | Line 309... | ||
- | 309 | mov [BTN_BUFF + ebx * 4], eax |
|
- | 310 | inc bl |
|
- | 311 | mov [BTN_COUNT], bl |
|
372 | pop esi |
312 | ret |
- | 313 | ||
373 | 314 | ;============================================================================== |
|
374 | mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] ; button id : bits 16-31 |
315 | ;///// private functions ////////////////////////////////////////////////////// |
- | 316 | ;============================================================================== |
|
375 | mov bx, [eax + SYS_BUTTON.id_lo] ; button id : bits 00-16 |
317 | |
- | 318 | ;------------------------------------------------------------------------------ |
|
376 | push ebx |
319 | button._.find_button: ;//////////////////////////////////////////////////////// |
Line 377... | Line 320... | ||
377 | 320 | ;------------------------------------------------------------------------------ |
|
378 | mov byte[MOUSE_DOWN], 1 ; no mouse down checks |
321 | ;? Find system button by specified process slot, id and coordinates |
379 | call button._.negative_button |
322 | ;------------------------------------------------------------------------------ |
Line -... | Line 323... | ||
- | 323 | ;> eax = pack[8(process slot), 24(button id)] or 0 |
|
380 | 324 | ;> ebx = pack[16(button x coord), 16(button y coord)] |
|
- | 325 | ;------------------------------------------------------------------------------ |
|
381 | pushad |
326 | ;< eax = pointer to SYS_BUTTON struct or 0 |
382 | push eax |
327 | ;------------------------------------------------------------------------------ |
- | 328 | push ecx edx esi edi |
|
Line 383... | Line 329... | ||
383 | mov al, [BTN_DOWN] |
329 | |
384 | mov byte[btn_down_determ], al |
330 | mov edx, eax |
385 | pop eax |
331 | shr edx, 24 |
Line 386... | Line 332... | ||
386 | 332 | and eax, 0x0ffffff |
|
387 | .cbwaitmouseup: |
- | |
388 | call checkidle |
- | |
Line 389... | Line 333... | ||
389 | call [draw_pointer] |
333 | |
- | 334 | mov edi, [BTN_ADDR] |
|
390 | 335 | mov ecx, [edi] |
|
Line 391... | Line -... | ||
391 | pushad |
- | |
392 | call stack_handler |
- | |
393 | popad |
- | |
394 | - | ||
395 | cmp byte[BTN_DOWN], 0 ; mouse buttons pressed ? |
- | |
396 | jnz .cbwaitmouseup |
- | |
397 | popad |
336 | imul esi, ecx, SYS_BUTTON.sizeof |
398 | - | ||
399 | call button._.negative_button |
- | |
400 | mov byte[MOUSE_BACKGROUND], 0 ; no mouse background |
- | |
401 | mov byte[DONT_DRAW_MOUSE], 0 ; draw mouse |
- | |
402 | 337 | add esi, edi |
|
403 | ; check coordinates |
- | |
404 | pusha |
- | |
405 | - | ||
406 | ; mouse x >= button x ? |
- | |
407 | movzx ebx, [eax + SYS_BUTTON.pslot] |
- | |
408 | shl ebx, 5 |
338 | inc ecx |
409 | add ebx, window_data |
- | |
410 | mov ecx, [ebx + WDATA.box.left] |
- | |
411 | movzx edx, [eax + SYS_BUTTON.left] |
- | |
412 | add edx, ecx |
- | |
413 | mov cx, [MOUSE_X] |
- | |
414 | cmp edx, ecx |
- | |
415 | jg .no_on_button ;if we release the pointer out of the button area |
- | |
416 | - | ||
417 | movzx ebx, [eax + SYS_BUTTON.width] |
- | |
418 | add edx, ebx |
- | |
419 | cmp ecx, edx |
339 | add esi, SYS_BUTTON.sizeof |
420 | jg .no_on_button |
340 | |
421 | 341 | .next_button: |
|
Line -... | Line 342... | ||
- | 342 | dec ecx |
|
- | 343 | jz .not_found |
|
- | 344 | ||
422 | ; mouse y >= button y ? |
345 | add esi, -SYS_BUTTON.sizeof |
- | 346 | ||
Line 423... | Line -... | ||
423 | movzx ebx, [eax + SYS_BUTTON.pslot] |
- | |
424 | shl ebx, 5 |
347 | ; does it belong to our process? |
425 | add ebx, window_data |
- | |
426 | mov ecx, [ebx + WDATA.box.top] |
348 | cmp dx, [esi + SYS_BUTTON.pslot] |
427 | movzx edx, [eax + SYS_BUTTON.top] |
- | |
428 | add edx, ecx |
349 | jne .next_button |
Line 429... | Line 350... | ||
429 | mov cx, [MOUSE_Y] |
350 | |
430 | cmp edx, ecx |
351 | ; does id match? |
Line 431... | Line 352... | ||
431 | jg .no_on_button |
352 | mov edi, dword[esi + SYS_BUTTON.id_hi - 2] |
432 | - | ||
433 | movzx ebx, [eax + SYS_BUTTON.height] |
- | |
434 | add edx, ebx |
353 | mov di, [esi + SYS_BUTTON.id_lo] |
435 | cmp ecx, edx |
- | |
436 | jg .no_on_button |
354 | and edi, 0x0ffffff |
Line 437... | Line -... | ||
437 | - | ||
438 | popa |
- | |
439 | - | ||
440 | mov byte[BTN_COUNT], 1 ; no of buttons in buffer |
- | |
441 | pop ebx |
355 | cmp eax, edi |
442 | mov [BTN_BUFF], ebx ; lets put the button id in buffer |
356 | jne .next_button |
443 | push ebx |
357 | |
444 | pusha |
358 | ; does coordinates match? |
445 | jmp .yes_on_button |
359 | mov edi, dword[esi + SYS_BUTTON.left - 2] |
Line 544... | Line 458... | ||
544 | ret |
458 | ret |
Line 545... | Line 459... | ||
545 | 459 | ||
546 | ;------------------------------------------------------------------------------ |
460 | ;------------------------------------------------------------------------------ |
547 | button._.negative_button: ;//////////////////////////////////////////////////// |
461 | button._.negative_button: ;//////////////////////////////////////////////////// |
548 | ;------------------------------------------------------------------------------ |
462 | ;------------------------------------------------------------------------------ |
549 | ;? |
463 | ;? Invert system button border |
550 | ;------------------------------------------------------------------------------ |
464 | ;------------------------------------------------------------------------------ |
551 | ; if requested, do not display button border on press. |
465 | ; if requested, do not display button border on press. |
552 | test ebx, 0x20000000 |
466 | test ebx, 0x20000000 |