Subversion Repositories Kolibri OS

Rev

Rev 983 | Rev 1300 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
431 serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
983 diamond 3
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
431 serge 4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
593 mikedld 8
$Revision: 1168 $
9
 
10
 
1 ha 11
max_buttons=4095
12
dececx:
13
    push edx
14
    push ecx
15
 
38 halyavin 16
    mov  edx,2
17
  .loop:
1 ha 18
 
38 halyavin 19
    cmp   byte [esp+edx],0x20
20
    jae   @f
1 ha 21
    mov   [esp+edx],byte 0x20
22
   @@:
23
    sub   [esp+edx],byte 0x20
24
 
38 halyavin 25
    dec  edx
26
    jns  .loop
1 ha 27
 
28
    pop  ecx
29
    pop  edx
30
    ret
379 serge 31
 
38 halyavin 32
incecx:
33
    push edx
34
    push ecx
379 serge 35
 
38 halyavin 36
    mov  edx,2
37
  .loop:
379 serge 38
 
38 halyavin 39
    cmp  byte [esp+edx],0xdf
40
    jbe  @f
41
    mov  [esp+edx],byte 0xdf
42
   @@:
43
    add  [esp+edx],byte 0x20
379 serge 44
 
38 halyavin 45
    dec  edx
46
    jns  .loop
47
    pop  ecx
48
    pop  edx
49
    ret
379 serge 50
 
38 halyavin 51
incecx2:
52
    push edx
53
    push ecx
379 serge 54
 
38 halyavin 55
    mov  edx,2
56
  .loop:
379 serge 57
 
38 halyavin 58
    cmp  byte [esp+edx],0xeb
59
    jbe  @f
60
    mov  [esp+edx],byte 0xeb
61
   @@:
62
    add  [esp+edx],byte 0x14
379 serge 63
 
38 halyavin 64
    dec  edx
65
    jns  .loop
66
    pop  ecx
67
    pop  edx
68
    ret
1 ha 69
 
70
drawbuttonframes:
71
 
1168 Lrz 72
        push  esi
73
        push  edi
74
        push  eax
75
        push  ebx
76
        push  ecx
77
        push  edx
1 ha 78
 
1168 Lrz 79
        shr   ebx,16
80
        shr   ecx,16
81
        mov   eax,[TASK_BASE]
1 ha 82
 
1168 Lrz 83
        add   ebx,[eax-twdw + WDATA.box.left]
84
        add   ecx,[eax-twdw + WDATA.box.top]
85
        mov     eax, ebx
86
        shl     eax, 16
87
        mov     ax, bx
88
        add     ax, word [esp+8]
89
        mov     ebx, ecx
90
        shl     ebx, 16
91
        mov     bx, cx
92
        push    ebx
93
        xor     edi, edi
94
        mov     ecx, esi
95
        call    incecx
96
        call    [draw_line]
1 ha 97
 
1168 Lrz 98
        movzx edx,word [esp+4+4]
99
        add   ebx,edx
100
        shl   edx,16
101
        add   ebx,edx
102
        mov   ecx,esi
103
        call  dececx
104
        call  [draw_line]
1 ha 105
 
1168 Lrz 106
        pop     ebx
107
        push  edx
108
        mov   edx,eax
109
        shr   edx,16
110
        mov   ax,dx
111
        mov   edx,ebx
112
        shr   edx,16
113
        mov   bx,dx
114
        mov   dx,[esp+4+4]
115
        add   bx,dx
116
        pop   edx
117
        mov   ecx,esi
118
        call  incecx
119
        call  [draw_line]
1 ha 120
 
1168 Lrz 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]
1 ha 129
 
1168 Lrz 130
        pop   edx
131
        pop   ecx
132
        pop   ebx
133
        pop   eax
134
        pop   edi
135
        pop   esi
1 ha 136
 
1168 Lrz 137
        ret
1 ha 138
 
139
button_dececx:
140
 
1168 Lrz 141
        cmp   [buttontype],dword 1
142
        jne   .finish
1 ha 143
;        je    bdece
144
;        ret
145
;      bdece:
1168 Lrz 146
        push  eax
147
        mov   eax,0x01
148
        cmp   edi,20
149
        jg    @f
150
        mov   eax,0x02
1 ha 151
      @@:
1168 Lrz 152
        test  ecx,0xff
153
        jz    @f
154
        sub   ecx,eax
1 ha 155
      @@:
1168 Lrz 156
        shl   eax,8
157
        test  ecx,0xff00
158
        jz    @f
159
        sub   ecx,eax
1 ha 160
      @@:
1168 Lrz 161
        shl   eax,8
162
        test  ecx,0xff0000
163
        jz    @f
164
        sub   ecx,eax
1 ha 165
      @@:
1168 Lrz 166
        pop    eax
1 ha 167
      .finish:
1168 Lrz 168
        ret
1 ha 169
 
170
 
171
sys_button:
172
 
684 diamond 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
465 serge 180
.forced:
114 mikedld 181
 
684 diamond 182
        test    edx, 0x80000000
183
        jnz     remove_button
1 ha 184
 
684 diamond 185
        or      bx, bx
186
        jle     noaddbutt
187
        or      cx, cx
188
        jle     noaddbutt
1 ha 189
 
684 diamond 190
        test    edx, 0x40000000
191
        jnz     button_no_draw
54 mikedld 192
 
1168 Lrz 193
        pushad                       ; button body
684 diamond 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
206
        mov     bx, cx
207
        mov     ecx, esi
208
        cmp     [buttontype], 0
209
        je      @f
210
        call    incecx2
211
@@:
212
        mov     edx, edi
1 ha 213
 
465 serge 214
.newline:
684 diamond 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
1 ha 224
 
684 diamond 225
        call    drawbuttonframes
1 ha 226
 
465 serge 227
button_no_draw:
1 ha 228
 
684 diamond 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
1 ha 235
 
684 diamond 236
        shl     eax, 4
237
        add     edi, eax
1 ha 238
 
684 diamond 239
        mov     ax, [CURRENT_TASK]
240
        stosw
241
        mov     ax, dx
242
        stosw               ; button id number: bits 0-15
243
        mov     eax, ebx
244
        rol     eax, 16
245
        stosd               ; x start | x size
246
        mov     eax, ecx
247
        rol     eax, 16
248
        stosd               ; y start | y size
249
        mov     eax, edx
250
        shr     eax, 16
251
        stosw               ; button id number: bits 16-31
1 ha 252
 
465 serge 253
noaddbutt:
1 ha 254
 
684 diamond 255
        ret
1 ha 256
 
257
 
258
remove_button:
259
 
684 diamond 260
        and     edx, 0x7fffffff
1 ha 261
 
465 serge 262
rnewba2:
1 ha 263
 
684 diamond 264
        mov     edi, [BTN_ADDR]
265
        mov     eax, edi
266
        movzx   ebx, word [edi]
267
        inc     ebx
1 ha 268
 
465 serge 269
rnewba:
1 ha 270
 
684 diamond 271
        dec     ebx
272
        jz      rnmba
1 ha 273
 
684 diamond 274
        add     eax, 0x10
1 ha 275
 
684 diamond 276
        mov     cx, [CURRENT_TASK]
277
        cmp     cx, [eax]
278
        jnz     rnewba
279
        cmp     dx, [eax+2]
280
        jnz     rnewba
1 ha 281
 
684 diamond 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
1 ha 289
 
465 serge 290
rnmba:
1 ha 291
 
684 diamond 292
        ret
1 ha 293
 
294
find_pressed_button_frames:
295
 
1168 Lrz 296
        pushad
1 ha 297
 
1168 Lrz 298
        movzx ebx,word [eax+0]
299
        shl   ebx,5
300
        add   ebx,window_data
465 serge 301
        mov   ecx, [ebx+ WDATA.box.left]     ; window x start
1168 Lrz 302
        movzx edx,word [eax+4]     ; button x start
303
        add   ecx,edx
304
        push  ecx
1 ha 305
 
465 serge 306
        mov   dx,[eax+6]                 ; button x size
1168 Lrz 307
        add   cx,dx
308
        mov   esi,ecx
309
        inc   esi
465 serge 310
        mov   ecx, [ebx+WDATA.box.top]   ; window y start
311
        mov   dx,[eax+8]                 ; button y start
1168 Lrz 312
        add   ecx,edx
313
        mov   ebx,ecx
314
                mov   dx,[eax+10]                ; button y size
315
        add   dx,cx
316
        inc   dx
1 ha 317
 
1168 Lrz 318
        pop   eax
1 ha 319
 
1168 Lrz 320
        ; eax x beginning
321
        ; ebx y beginning
322
        ; esi x end
323
        ; edx y end
324
        ; ecx color
1 ha 325
 
1168 Lrz 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
1 ha 331
 
1168 Lrz 332
        popad
333
        ret
1 ha 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:
1168 Lrz 346
        ; If requested, do not display button
347
        ; boarder on press.
348
        test  ebx,0x20000000
349
        jz    draw_negative_button
350
        ret
1 ha 351
      draw_negative_button:
352
 
1168 Lrz 353
        pushad
1 ha 354
 
1168 Lrz 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
1 ha 361
 
1168 Lrz 362
        dec   edx
363
        push  edx
364
        inc   edx
365
        dec   esi
366
        push  esi
367
        inc   esi
1 ha 368
 
1168 Lrz 369
        push  eax
370
        push  ebx
371
        push  ecx
372
        push  edx
373
        push  edi
1 ha 374
 
1168 Lrz 375
        call  [disable_mouse]
1 ha 376
 
377
      bdbnewline:
1168 Lrz 378
        mov   edi,1    ; force
379
        cmp   eax,[esp+16]
380
        jz    bneg
381
        cmp   eax,[esp+20]
382
        jz    bneg
383
        cmp   ebx,[esp+12]
384
        jz    bneg
385
        cmp   ebx,[esp+24]
386
        jnz   nbneg
1 ha 387
;        jz    bneg
388
;        jmp   nbneg
389
 
390
      bneg:
391
 
1168 Lrz 392
        ;;;call  [disable_mouse]
393
        call  [putpixel]
1 ha 394
 
395
      nbneg:
396
 
1168 Lrz 397
        inc   eax
398
        cmp   eax,esi
399
        jnz   bdbnewline
400
        mov   eax,[esp+16]
401
        inc   ebx
402
        cmp   ebx,edx
403
        jnz   bdbnewline
1 ha 404
 
1168 Lrz 405
        add   esp,28
1 ha 406
 
1168 Lrz 407
        popad
1 ha 408
 
1168 Lrz 409
        ret
1 ha 410
 
411
; check buttons
412
 
413
 
414
; 0000 word process number
415
; 0002 word button id number : bits 0-15
416
; 0004 word x start
417
; 0006 word x size
418
; 0008 word y start
419
; 000A word y size
420
; 000C word button id number : bits 16-31
421
;
422
; button table in 0x10 increments
423
;
424
; first at 0x10
425
 
1168 Lrz 426
align 4
1 ha 427
checkbuttons:
428
 
381 serge 429
    cmp   [BTN_DOWN],byte 0    ; mouse buttons pressed
1 ha 430
    jnz   @f
415 heavyiron 431
;..................................... start 1/5 : modified by vhanla .............................
432
    mov [bPressedMouseXY_B],0
433
;..................................... end 1/5 : modified by vhanla .............................
1 ha 434
    ret
435
  @@:
436
    pushad
437
 
438
    xor    esi, esi
381 serge 439
    mov    edi, [BTN_ADDR]
1 ha 440
    movzx  edx, word [edi]
441
    test   edx, edx
442
    jne    @f
443
    popad
444
    ret
445
 
446
  @@:
415 heavyiron 447
;..................................... start 2/5 : modified by vhanla .............................
448
  ;here i catch the coordinates when the mouse's button is clicked
449
   push ax
450
   cmp [bPressedMouseXY_B],0;FALSE
451
   jnz @f
452
   mov [bPressedMouseXY_B],1;TRUE - it was already clicked
453
   mov ax,[MOUSE_X]
454
   mov [mx],ax
455
   mov ax,[MOUSE_Y]
456
   mov [my],ax
457
   @@:
1168 Lrz 458
   pop  ax
415 heavyiron 459
   ;and it is only refreshed after the mouse's button release
460
;..................................... end 2/5 : modified by vhanla .............................
1 ha 461
 
462
    push  esi
463
    inc   edx
464
    push  edx
465
 
466
  buttonnewcheck:
467
 
468
    pop   edx
469
    pop   esi
470
    inc   esi
471
    cmp   edx,esi
472
    jge   bch
473
 
1168 Lrz 474
    popad                 ; no button pressed
1 ha 475
    ret
476
 
477
  bch:
478
 
479
    push  esi
480
    push  edx
481
    mov   eax,esi
482
    shl   eax,4
483
    add   eax,edi
484
 
485
    ; check that button is at top of windowing stack
486
 
487
    movzx ebx,word [eax]
380 serge 488
    movzx ecx,word [WIN_STACK + ebx * 2]
379 serge 489
    cmp   ecx,[TASK_COUNT]
1 ha 490
    jne   buttonnewcheck
491
 
492
    ; check that button start is inside window x/y end
493
 
494
    movzx ebx,word [eax+0]
495
    shl   ebx,5
41 mikedld 496
 
1168 Lrz 497
        test    [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED
498
        jnz     buttonnewcheck
41 mikedld 499
 
1 ha 500
;    add   ebx,window_data
501
;    mov   ecx,[window_data+ebx+8]          ; window end X
502
    movzx edx,word [eax+4]     ; button start X
115 poddubny 503
    cmp   edx, [window_data+ebx+WDATA.box.width] ;ecx
1 ha 504
    jge   buttonnewcheck
505
 
506
;    mov   ecx,[window_data+ebx+12]         ; window end Y
507
    movzx edx, word [eax+8]    ; button start Y
115 poddubny 508
    cmp   edx, [window_data+ebx+WDATA.box.height] ;ecx
1 ha 509
    jge   buttonnewcheck
510
 
511
    ; check coordinates
1168 Lrz 512
                               ; mouse x >= button x ?
1 ha 513
    movzx ebx,word [eax+0]
514
    shl   ebx,5
515
    add   ebx,window_data
1168 Lrz 516
        mov   ecx, [ebx+WDATA.box.left]     ; window x start
1 ha 517
    movzx edx,word [eax+4]     ; button x start
518
    add   edx,ecx
415 heavyiron 519
;..................................... start 3/5 : modified by vhanla .............................
520
    mov   cx,[mx]   ;mov cx,[MOUSE_X]
521
;..................................... end 3/5 : modified by vhanla .............................
1 ha 522
    cmp   edx,ecx
1168 Lrz 523
    jg    buttonnewcheck
1 ha 524
 
525
    movzx ebx,word [eax+6]     ; button x size
526
    add   edx,ebx
527
    cmp   ecx,edx
1168 Lrz 528
    jg    buttonnewcheck
1 ha 529
 
1168 Lrz 530
                               ; mouse y >= button y ?
1 ha 531
    movzx ebx,word [eax+0]
532
    shl   ebx,5
533
    add   ebx,window_data
1168 Lrz 534
        mov   ecx, [ebx+WDATA.box.top]     ; window y start
1 ha 535
    movzx edx,word [eax+8]     ; button y start
536
    add   edx,ecx
415 heavyiron 537
;..................................... start 4/5 : modified by vhanla .............................
538
    mov   cx,[my]  ;mov cx,[MOUSE_Y]
539
;..................................... start 4/5 : modified by vhanla .............................
1 ha 540
    cmp   edx,ecx
1168 Lrz 541
    jg    buttonnewcheck
1 ha 542
 
543
    movzx ebx,word [eax+10]    ; button y size
544
    add   edx,ebx
545
    cmp   ecx,edx
1168 Lrz 546
    jg    buttonnewcheck
1 ha 547
 
548
    ; mouse on button
549
 
550
    pop   edx
551
    pop   esi
552
 
1168 Lrz 553
    mov   bx,[eax+0xc]     ; button id : bits 16-31
1 ha 554
    shl   ebx,16
1168 Lrz 555
    mov   bx,[eax+2]       ; button id : bits 00-16
1 ha 556
    push  ebx
557
 
381 serge 558
    mov   [MOUSE_DOWN],byte 1  ; no mouse down checks
1 ha 559
    call find_pressed_button_frames
560
    call negativebutton
561
 
562
    pushad
803 alver 563
; // Alver 22.06.2008 // {
564
    push  eax
565
    mov  al, byte [BTN_DOWN]
566
    mov  byte [btn_down_determ], al
567
    pop  eax
568
; } \\ Alver \\
569
 
1 ha 570
  cbwaitmouseup:
571
 
572
    call  checkidle
573
 
574
    call  [draw_pointer]
575
 
576
    pushad
577
    call  stack_handler
578
    popad
579
 
381 serge 580
    cmp   [BTN_DOWN],byte 0  ; mouse buttons pressed ?
1 ha 581
    jnz   cbwaitmouseup
582
    popad
583
 
584
    call  negativebutton
381 serge 585
    mov   [MOUSE_BACKGROUND],byte 0  ; no mouse background
586
    mov   [DONT_DRAW_MOUSE],byte 0  ; draw mouse
415 heavyiron 587
;..................................... start 5/5 : modified by vhanla .............................
28 mario79 588
    ; check coordinates
684 diamond 589
iglobal
415 heavyiron 590
    mx dw 0x0 ; keeps the x mouse's position when it was clicked
591
    my dw 0x0 ; keeps the y mouse's position when it was clicked
592
    bPressedMouseXY_B db 0x0
803 alver 593
    btn_down_determ     db 0x0        ; << // Alver 22.06.2008// <<
684 diamond 594
endg
28 mario79 595
 
33 mario79 596
   pusha
597
  ; mouse x >= button x ?
598
   movzx ebx,word [eax+0]
1168 Lrz 599
   shl   ebx,5
600
   add   ebx,window_data
601
   mov   ecx, [ebx+WDATA.box.left]    ; window x start
33 mario79 602
   movzx edx,word [eax+4]    ; button x start
1168 Lrz 603
   add   edx,ecx
604
   mov   cx,[MOUSE_X]
605
   cmp   edx,ecx
606
   jg   no_on_button ;if we release the pointer out of the button area
28 mario79 607
 
33 mario79 608
   movzx ebx,word [eax+6]    ; button x size
1168 Lrz 609
   add   edx,ebx
610
   cmp   ecx,edx
611
   jg   no_on_button
28 mario79 612
 
1168 Lrz 613
        ; mouse y >= button y ?
33 mario79 614
   movzx ebx,word [eax+0]
1168 Lrz 615
   shl   ebx,5
616
   add   ebx,window_data
617
   mov   ecx, [ebx+WDATA.box.top]    ; window y start
33 mario79 618
   movzx edx,word [eax+8]    ; button y start
1168 Lrz 619
   add   edx,ecx
620
   mov   cx,[MOUSE_Y]
621
   cmp   edx,ecx
622
   jg   no_on_button
28 mario79 623
 
33 mario79 624
   movzx ebx,word [eax+10]   ; button y size
1168 Lrz 625
   add   edx,ebx
626
   cmp   ecx,edx
627
   jg   no_on_button
33 mario79 628
   popa
1168 Lrz 629
   mov   [BTN_COUNT],byte 1 ; no of buttons in buffer
630
   pop   ebx
631
   mov   [BTN_BUFF],ebx   ; lets put the button id in buffer
33 mario79 632
   push  ebx
633
   pusha
634
   jmp yes_on_button
28 mario79 635
no_on_button:
1168 Lrz 636
   mov   [BTN_COUNT],byte 0 ; no of buttons in buffer
28 mario79 637
yes_on_button:
1168 Lrz 638
   mov   [MOUSE_DOWN],byte 0 ; mouse down -> do not draw
33 mario79 639
   popa
640
   pop ebx
641
   popa
642
   ret
643
 
415 heavyiron 644
;..................................... end 5/5 : modified by vhanla ................................