Subversion Repositories Kolibri OS

Rev

Rev 1376 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1376 Rev 2382
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: 1376 $
-
 
10
 
-
 
11
 
-
 
12
button._.MAX_BUTTONS = 4095
-
 
Line 13... Line 9...
13
 
9
$Revision: 2382 $
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 ?
-
 
23
  .top    dw ?
25
  .top    dw ?
24
  .height dw ?
26
  .height dw ?
25
  .id_hi  dw ?
27
  .id_hi  dw ?
26
          dw ?
28
  .sizeof:
27
  .sizeof:
29
}
28
}
Line 30... Line -...
30
virtual at 0
-
 
31
  SYS_BUTTON SYS_BUTTON
-
 
32
end virtual
-
 
33
 
-
 
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
29
virtual at 0
38
  btn_down_determ   db 0x0
30
  SYS_BUTTON SYS_BUTTON
39
endg
31
end virtual
40
 
32
 
41
align 4
33
align 4
Line 64... Line 56...
64
        jnz     .remove_button
56
        jnz     .remove_button
Line 65... Line 57...
65
 
57
 
66
        ; do we have free button slots available?
58
        ; do we have free button slots available?
67
        mov     edi, [BTN_ADDR]
59
        mov     edi, [BTN_ADDR]
68
        mov     eax, [edi]
60
        mov     eax, [edi]
69
        cmp     eax, button._.MAX_BUTTONS
61
        cmp     eax, button.MAX_BUTTONS
Line 70... Line 62...
70
        jge     .exit
62
        jge     .exit
71
 
63
 
72
        ; does it have positive size? (otherwise it doesn't have sense)
64
        ; does it have positive size? (otherwise it doesn't have sense)
Line 137... Line 129...
137
        cmp     [buttontype], 0
129
        cmp     [buttontype], 0
138
        je      @f
130
        je      @f
139
        call    button._.incecx2
131
        call    button._.incecx2
Line 140... Line 132...
140
 
132
 
-
 
133
        ; set button height counter
141
        ; set button height counter
134
    @@:
Line 142... Line 135...
142
    @@: mov     edx, edi
135
        mov     edx, edi
143
 
136
 
144
  .next_line:
137
  .next_line:
145
        call    button._.button_dececx
138
        call    button._.button_dececx
Line 225... Line 218...
225
        inc     ebx
218
        inc     ebx
226
        imul    esi, ebx, SYS_BUTTON.sizeof
219
        imul    esi, ebx, SYS_BUTTON.sizeof
227
        add     esi, edi
220
        add     esi, edi
228
        xor     ecx, ecx
221
        xor     ecx, ecx
229
        add     ecx, -SYS_BUTTON.sizeof
222
        add     ecx, -SYS_BUTTON.sizeof
-
 
223
        add     esi, SYS_BUTTON.sizeof
Line 230... Line 224...
230
 
224
 
231
  .next_button:
225
  .next_button:
232
        dec     ebx
226
        dec     ebx
Line 260... Line 254...
260
  .exit:
254
  .exit:
261
        ret
255
        ret
Line 262... Line 256...
262
 
256
 
263
align 4
257
align 4
264
;------------------------------------------------------------------------------
258
;------------------------------------------------------------------------------
265
check_buttons: ;///////////////////////////////////////////////////////////////
259
sys_button_activate_handler: ;/////////////////////////////////////////////////
266
;------------------------------------------------------------------------------
260
;------------------------------------------------------------------------------
267
;? 
261
;? 
268
;------------------------------------------------------------------------------
262
;------------------------------------------------------------------------------
269
        cmp     byte[BTN_DOWN], 0    ; mouse buttons pressed
-
 
270
        jnz     @f
-
 
271
        mov     [bPressedMouseXY_B], 0
-
 
272
        ret
-
 
273
 
-
 
274
    @@: pushad
-
 
275
        xor     esi, esi
-
 
276
        mov     edi, [BTN_ADDR]
-
 
277
        mov     edx, [edi]
-
 
278
        test    edx, edx
-
 
279
        jne     @f
-
 
280
        popad
-
 
281
        ret
-
 
282
 
263
;> eax = pack[8(process slot), 24(button id)]
283
        ;here i catch the coordinates when the mouse's button is clicked
-
 
284
    @@: push    ax
264
;> ebx = pack[16(button x coord), 16(button y coord)]
285
        cmp     [bPressedMouseXY_B], 0 ; FALSE
-
 
286
        jnz     @f
265
;> cl = mouse button mask this system button was pressed with
287
        mov     [bPressedMouseXY_B], 1 ; TRUE - it was already clicked
-
 
288
        mov     ax, [MOUSE_X]
-
 
289
        mov     [mx], ax
266
;------------------------------------------------------------------------------
290
        mov     ax, [MOUSE_Y]
267
        call    button._.find_button
291
        mov     [my], ax
-
 
292
    @@: pop     ax
-
 
293
        ;and it is only refreshed after the mouse's button release
-
 
294
 
-
 
295
        push    esi
268
        or      eax, eax
296
        inc     edx
-
 
Line 297... Line -...
297
        push    edx
-
 
298
 
-
 
299
  .buttonnewcheck:
-
 
300
        pop     edx
-
 
301
        pop     esi
269
        jz      .exit
302
        inc     esi
270
 
Line 303... Line 271...
303
        cmp     edx, esi
271
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]
304
        jge     .bch
272
        call    button._.negative_button
Line 305... Line 273...
305
 
273
 
306
        popad
-
 
307
        ret
-
 
308
 
-
 
309
  .bch:
-
 
310
        push    esi
-
 
311
        push    edx
-
 
312
        mov     eax, esi
274
  .exit:
313
        shl     eax, 4
-
 
314
        add     eax, edi
-
 
315
 
-
 
316
        ; check that button is at top of windowing stack
-
 
317
        movzx   ebx, [eax + SYS_BUTTON.pslot]
-
 
318
        movzx   ecx, word[WIN_STACK + ebx * 2]
275
        ret
319
        cmp     ecx, [TASK_COUNT]
-
 
320
        jne     .buttonnewcheck
-
 
321
 
276
 
322
        ; check that button start is inside window x/y end
-
 
323
        shl     ebx, 5
-
 
324
 
-
 
325
        test    [ebx + window_data + WDATA.fl_wstate], WSTATE_MINIMIZED
-
 
326
        jnz     .buttonnewcheck
277
align 4
327
 
-
 
328
        movzx   edx, [eax + SYS_BUTTON.left]
-
 
329
        cmp     edx, [window_data + ebx + WDATA.box.width] ;ecx
278
;------------------------------------------------------------------------------
330
        jge     .buttonnewcheck
-
 
331
 
-
 
332
        movzx   edx, [eax + SYS_BUTTON.top]
-
 
333
        cmp     edx, [window_data + ebx + WDATA.box.height] ;ecx
-
 
334
        jge     .buttonnewcheck
279
sys_button_deactivate_handler: ;///////////////////////////////////////////////
335
 
-
 
336
        ; check coordinates
-
 
337
 
-
 
338
        ; mouse x >= button x ?
-
 
339
        add     ebx, window_data
-
 
340
        mov     ecx, [ebx + WDATA.box.left]
-
 
341
        movzx   edx, [eax + SYS_BUTTON.left]
-
 
342
        add     edx, ecx
-
 
343
        mov     cx, [mx]   ;mov cx,[MOUSE_X]
-
 
344
        cmp     edx, ecx
-
 
345
        jg      .buttonnewcheck
-
 
346
 
-
 
347
        movzx   ebx, [eax + SYS_BUTTON.width]
-
 
348
        add     edx, ebx
280
;------------------------------------------------------------------------------
349
        cmp     ecx, edx
281
;? 
350
        jg      .buttonnewcheck
-
 
351
 
-
 
352
        ; mouse y >= button y ?
-
 
353
        movzx   ebx, [eax + SYS_BUTTON.pslot]
-
 
354
        shl     ebx, 5
-
 
355
        add     ebx, window_data
282
;------------------------------------------------------------------------------
356
        mov     ecx, [ebx + WDATA.box.top]
-
 
357
        movzx   edx, [eax + SYS_BUTTON.top]
283
;> eax = pack[8(process slot), 24(button id)]
358
        add     edx, ecx
-
 
359
        mov     cx, [my]  ;mov cx,[MOUSE_Y]
-
 
360
        cmp     edx, ecx
284
;> ebx = pack[16(button x coord), 16(button y coord)]
361
        jg      .buttonnewcheck
285
;> cl = mouse button mask this system button was pressed with
362
 
-
 
Line -... Line 286...
-
 
286
;------------------------------------------------------------------------------
363
        movzx   ebx, [eax + SYS_BUTTON.height]
287
        call    button._.find_button
Line 364... Line 288...
364
        add     edx, ebx
288
        or      eax, eax
365
        cmp     ecx, edx
289
        jz      .exit
Line -... Line 290...
-
 
290
 
-
 
291
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]
-
 
292
        call    button._.negative_button
-
 
293
 
-
 
294
  .exit:
-
 
295
        ret
-
 
296
 
-
 
297
align 4
366
        jg      .buttonnewcheck
298
;------------------------------------------------------------------------------
-
 
299
sys_button_perform_handler: ;//////////////////////////////////////////////////
-
 
300
;------------------------------------------------------------------------------
-
 
301
;? 
-
 
302
;------------------------------------------------------------------------------
367
 
303
;> eax = pack[8(process slot), 24(button id)]
368
        ; mouse on button
304
;> ebx = pack[16(button x coord), 16(button y coord)]
-
 
305
;> cl = mouse button mask this system button was pressed with
-
 
306
;------------------------------------------------------------------------------
Line 369... Line 307...
369
 
307
        shl     eax, 8
370
        pop     edx
308
        mov     al, cl
-
 
309
        movzx   ebx, byte[BTN_COUNT]
Line -... Line 310...
-
 
310
        mov     [BTN_BUFF + ebx * 4], eax
-
 
311
        inc     bl
-
 
312
        mov     [BTN_COUNT], bl
371
        pop     esi
313
        ret
-
 
314
 
372
 
315
;==============================================================================
373
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]     ; button id : bits 16-31
316
;///// private functions //////////////////////////////////////////////////////
-
 
317
;==============================================================================
374
        mov     bx, [eax + SYS_BUTTON.id_lo]       ; button id : bits 00-16
318
 
-
 
319
;------------------------------------------------------------------------------
375
        push    ebx
320
button._.find_button: ;////////////////////////////////////////////////////////
Line 376... Line 321...
376
 
321
;------------------------------------------------------------------------------
377
        mov     byte[MOUSE_DOWN], 1  ; no mouse down checks
322
;? Find system button by specified process slot, id and coordinates
378
        call    button._.negative_button
323
;------------------------------------------------------------------------------
Line -... Line 324...
-
 
324
;> eax = pack[8(process slot), 24(button id)] or 0
379
 
325
;> ebx = pack[16(button x coord), 16(button y coord)]
-
 
326
;------------------------------------------------------------------------------
380
        pushad
327
;< eax = pointer to SYS_BUTTON struct or 0
381
        push    eax
328
;------------------------------------------------------------------------------
-
 
329
        push    ecx edx esi edi
Line 382... Line 330...
382
        mov     al, [BTN_DOWN]
330
 
383
        mov     byte[btn_down_determ], al
331
        mov     edx, eax
384
        pop     eax
332
        shr     edx, 24
Line 385... Line 333...
385
 
333
        and     eax, 0x0ffffff
386
  .cbwaitmouseup:
-
 
387
        call    checkidle
-
 
Line 388... Line 334...
388
        call    [draw_pointer]
334
 
-
 
335
        mov     edi, [BTN_ADDR]
389
 
336
        mov     ecx, [edi]
Line 390... Line -...
390
        pushad
-
 
391
        call    stack_handler
-
 
392
        popad
-
 
393
 
-
 
394
        cmp     byte[BTN_DOWN], 0  ; mouse buttons pressed ?
-
 
395
        jnz     .cbwaitmouseup
-
 
396
        popad
337
        imul    esi, ecx, SYS_BUTTON.sizeof
397
 
-
 
398
        call    button._.negative_button
-
 
399
        mov     byte[MOUSE_BACKGROUND], 0  ; no mouse background
-
 
400
        mov     byte[DONT_DRAW_MOUSE], 0  ; draw mouse
-
 
401
 
338
        add     esi, edi
402
        ; check coordinates
-
 
403
        pusha
-
 
404
 
-
 
405
        ; mouse x >= button x ?
-
 
406
        movzx   ebx, [eax + SYS_BUTTON.pslot]
-
 
407
        shl     ebx, 5
339
        inc     ecx
408
        add     ebx, window_data
-
 
409
        mov     ecx, [ebx + WDATA.box.left]
-
 
410
        movzx   edx, [eax + SYS_BUTTON.left]
-
 
411
        add     edx, ecx
-
 
412
        mov     cx, [MOUSE_X]
-
 
413
        cmp     edx, ecx
-
 
414
        jg      .no_on_button ;if we release the pointer out of the button area
-
 
415
 
-
 
416
        movzx   ebx, [eax + SYS_BUTTON.width]
-
 
417
        add     edx, ebx
-
 
418
        cmp     ecx, edx
340
        add     esi, SYS_BUTTON.sizeof
419
        jg      .no_on_button
341
 
420
 
342
  .next_button:
Line -... Line 343...
-
 
343
        dec     ecx
-
 
344
        jz      .not_found
-
 
345
 
421
        ; mouse y >= button y ?
346
        add     esi, -SYS_BUTTON.sizeof
-
 
347
 
Line 422... Line -...
422
        movzx   ebx, [eax + SYS_BUTTON.pslot]
-
 
423
        shl     ebx, 5
348
        ; does it belong to our process?
424
        add     ebx, window_data
-
 
425
        mov     ecx, [ebx + WDATA.box.top]
349
        cmp     dx, [esi + SYS_BUTTON.pslot]
426
        movzx   edx, [eax + SYS_BUTTON.top]
-
 
427
        add     edx, ecx
350
        jne     .next_button
Line 428... Line 351...
428
        mov     cx, [MOUSE_Y]
351
 
429
        cmp     edx, ecx
352
        ; does id match?
Line 430... Line 353...
430
        jg      .no_on_button
353
        mov     edi, dword[esi + SYS_BUTTON.id_hi - 2]
431
 
-
 
432
        movzx   ebx, [eax + SYS_BUTTON.height]
-
 
433
        add     edx, ebx
354
        mov     di, [esi + SYS_BUTTON.id_lo]
434
        cmp     ecx, edx
-
 
435
        jg      .no_on_button
355
        and     edi, 0x0ffffff
Line 436... Line -...
436
 
-
 
437
        popa
-
 
438
 
-
 
439
        mov     byte[BTN_COUNT], 1 ; no of buttons in buffer
-
 
440
        pop     ebx
356
        cmp     eax, edi
441
        mov     [BTN_BUFF], ebx   ; lets put the button id in buffer
357
        jne     .next_button
442
        push    ebx
358
 
443
        pusha
359
        ; does coordinates match?
444
        jmp     .yes_on_button
360
        mov     edi, dword[esi + SYS_BUTTON.left - 2]
445
 
361
        mov     di, [esi + SYS_BUTTON.top]
446
  .no_on_button:
362
        cmp     ebx, edi
447
        mov     byte[BTN_COUNT], 0 ; no of buttons in buffer
363
        jne     .next_button
-
 
364
 
448
 
365
        ; okay, return it
449
  .yes_on_button:
366
        mov     eax, esi
450
        mov     byte[MOUSE_DOWN], 0 ; mouse down -> do not draw
367
        jmp     .exit
-
 
368
 
451
        popa
369
  .not_found:
452
        pop     ebx
370
        xor     eax, eax
453
        popa
371
 
454
        ret
372
  .exit:
-
 
373
        pop     edi esi edx ecx
455
 
374
        ret
456
;==============================================================================
375
 
Line 457... Line 376...
457
;///// private functions //////////////////////////////////////////////////////
376
;------------------------------------------------------------------------------
458
;==============================================================================
377
button._.dececx: ;/////////////////////////////////////////////////////////////
459
 
378
;------------------------------------------------------------------------------
460
;------------------------------------------------------------------------------
379
;? 
461
button._.dececx: ;/////////////////////////////////////////////////////////////
380
;------------------------------------------------------------------------------
462
;------------------------------------------------------------------------------
381
        sub     cl, 0x20
463
;? 
382
        jnc     @f
464
;------------------------------------------------------------------------------
383
        xor     cl, cl
-
 
384
    @@:
465
        sub     cl, 0x20
385
        sub     ch, 0x20
466
        jnc     @f
386
        jnc     @f
467
        xor     cl, cl
387
        xor     ch, ch
-
 
388
    @@:
468
    @@: sub     ch, 0x20
389
        rol     ecx, 16
469
        jnc     @f
390
        sub     cl, 0x20
470
        xor     ch, ch
391
        jnc     @f
471
    @@: rol     ecx, 16
392
        xor     cl, cl
-
 
393
    @@:
472
        sub     cl, 0x20
394
        rol     ecx, 16
473
        jnc     @f
395
        ret
Line 474... Line 396...
474
        xor     cl, cl
396
 
475
    @@: rol     ecx, 16
397
;------------------------------------------------------------------------------
476
        ret
398
button._.incecx: ;/////////////////////////////////////////////////////////////
477
 
399
;------------------------------------------------------------------------------
478
;------------------------------------------------------------------------------
400
;? 
479
button._.incecx: ;/////////////////////////////////////////////////////////////
401
;------------------------------------------------------------------------------
480
;------------------------------------------------------------------------------
402
        add     cl, 0x20
481
;? 
403
        jnc     @f
-
 
404
        or      cl, -1
482
;------------------------------------------------------------------------------
405
    @@:
483
        add     cl, 0x20
406
        add     ch, 0x20
484
        jnc     @f
407
        jnc     @f
-
 
408
        or      ch, -1
485
        or      cl, -1
409
    @@:
486
    @@: add     ch, 0x20
410
        rol     ecx, 16
487
        jnc     @f
411
        add     cl, 0x20
488
        or      ch, -1
412
        jnc     @f
-
 
413
        or      cl, -1
489
    @@: rol     ecx, 16
414
    @@:
490
        add     cl, 0x20
415
        rol     ecx, 16
Line 491... Line 416...
491
        jnc     @f
416
        ret
492
        or      cl, -1
417
 
493
    @@: rol     ecx, 16
418
;------------------------------------------------------------------------------
Line 523... Line 448...
523
        mov     al, 1
448
        mov     al, 1
524
        cmp     edi, 20
449
        cmp     edi, 20
525
        jg      @f
450
        jg      @f
526
        mov     al, 2
451
        mov     al, 2
Line -... Line 452...
-
 
452
 
527
 
453
    @@:
528
    @@: sub     cl, al
454
        sub     cl, al
529
        jnc     @f
455
        jnc     @f
-
 
456
        xor     cl, cl
530
        xor     cl, cl
457
    @@:
531
    @@: sub     ch, al
458
        sub     ch, al
532
        jnc     @f
459
        jnc     @f
-
 
460
        xor     ch, ch
533
        xor     ch, ch
461
    @@:
534
    @@: rol     ecx, 16
462
        rol     ecx, 16
535
        sub     cl, al
463
        sub     cl, al
536
        jnc     @f
464
        jnc     @f
-
 
465
        xor     cl, cl
537
        xor     cl, cl
466
    @@:
Line 538... Line 467...
538
    @@: rol     ecx, 16
467
        rol     ecx, 16
Line 539... Line 468...
539
 
468
 
540
        pop     eax
469
        pop     eax
Line 541... Line 470...
541
 
470
 
542
  .finish:
471
  .finish:
543
        ret
472
        ret
544
 
473
 
545
;------------------------------------------------------------------------------
474
;------------------------------------------------------------------------------
546
button._.negative_button: ;////////////////////////////////////////////////////
475
button._.negative_button: ;////////////////////////////////////////////////////
547
;------------------------------------------------------------------------------
476
;------------------------------------------------------------------------------
548
;? 
477
;? Invert system button border