Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1159 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
1206 hidnplayr 8
$Revision: 1206 $
1159 hidnplayr 9
 
10
 
11
max_buttons=4095
12
dececx:
13
    push edx
14
    push ecx
15
 
16
    mov  edx,2
17
  .loop:
18
 
19
    cmp   byte [esp+edx],0x20
20
    jae   @f
21
    mov   [esp+edx],byte 0x20
22
   @@:
23
    sub   [esp+edx],byte 0x20
24
 
25
    dec  edx
26
    jns  .loop
27
 
28
    pop  ecx
29
    pop  edx
30
    ret
31
 
32
incecx:
33
    push edx
34
    push ecx
35
 
36
    mov  edx,2
37
  .loop:
38
 
39
    cmp  byte [esp+edx],0xdf
40
    jbe  @f
41
    mov  [esp+edx],byte 0xdf
42
   @@:
43
    add  [esp+edx],byte 0x20
44
 
45
    dec  edx
46
    jns  .loop
47
    pop  ecx
48
    pop  edx
49
    ret
50
 
51
incecx2:
52
    push edx
53
    push ecx
54
 
55
    mov  edx,2
56
  .loop:
57
 
58
    cmp  byte [esp+edx],0xeb
59
    jbe  @f
60
    mov  [esp+edx],byte 0xeb
61
   @@:
62
    add  [esp+edx],byte 0x14
63
 
64
    dec  edx
65
    jns  .loop
66
    pop  ecx
67
    pop  edx
68
    ret
69
 
70
drawbuttonframes:
71
 
1198 clevermous 72
        push  esi
73
        push  edi
74
        push  eax
75
        push  ebx
76
        push  ecx
77
        push  edx
1159 hidnplayr 78
 
1198 clevermous 79
        shr   ebx,16
80
        shr   ecx,16
81
        mov   eax,[TASK_BASE]
1159 hidnplayr 82
 
1198 clevermous 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]
1159 hidnplayr 97
 
1198 clevermous 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]
1159 hidnplayr 105
 
1198 clevermous 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]
1159 hidnplayr 120
 
1198 clevermous 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]
1159 hidnplayr 129
 
1198 clevermous 130
        pop   edx
131
        pop   ecx
132
        pop   ebx
133
        pop   eax
134
        pop   edi
135
        pop   esi
1159 hidnplayr 136
 
1198 clevermous 137
        ret
1159 hidnplayr 138
 
139
button_dececx:
140
 
1198 clevermous 141
        cmp   [buttontype],dword 1
142
        jne   .finish
1159 hidnplayr 143
;        je    bdece
144
;        ret
145
;      bdece:
1198 clevermous 146
        push  eax
147
        mov   eax,0x01
148
        cmp   edi,20
149
        jg    @f
150
        mov   eax,0x02
1159 hidnplayr 151
      @@:
1198 clevermous 152
        test  ecx,0xff
153
        jz    @f
154
        sub   ecx,eax
1159 hidnplayr 155
      @@:
1198 clevermous 156
        shl   eax,8
157
        test  ecx,0xff00
158
        jz    @f
159
        sub   ecx,eax
1159 hidnplayr 160
      @@:
1198 clevermous 161
        shl   eax,8
162
        test  ecx,0xff0000
163
        jz    @f
164
        sub   ecx,eax
1159 hidnplayr 165
      @@:
1198 clevermous 166
        pop    eax
1159 hidnplayr 167
      .finish:
1198 clevermous 168
        ret
1159 hidnplayr 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
 
1198 clevermous 193
        pushad                       ; button body
1159 hidnplayr 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
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
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
252
 
253
noaddbutt:
254
 
255
        ret
256
 
257
 
258
remove_button:
259
 
260
        and     edx, 0x7fffffff
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
 
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
 
1198 clevermous 296
        pushad
1159 hidnplayr 297
 
1198 clevermous 298
        movzx ebx,word [eax+0]
299
        shl   ebx,5
300
        add   ebx,window_data
1159 hidnplayr 301
        mov   ecx, [ebx+ WDATA.box.left]     ; window x start
1198 clevermous 302
        movzx edx,word [eax+4]     ; button x start
303
        add   ecx,edx
304
        push  ecx
1159 hidnplayr 305
 
306
        mov   dx,[eax+6]                 ; button x size
1198 clevermous 307
        add   cx,dx
308
        mov   esi,ecx
309
        inc   esi
1159 hidnplayr 310
        mov   ecx, [ebx+WDATA.box.top]   ; window y start
311
        mov   dx,[eax+8]                 ; button y start
1198 clevermous 312
        add   ecx,edx
313
        mov   ebx,ecx
314
                mov   dx,[eax+10]                ; button y size
315
        add   dx,cx
316
        inc   dx
1159 hidnplayr 317
 
1198 clevermous 318
        pop   eax
1159 hidnplayr 319
 
1198 clevermous 320
        ; eax x beginning
321
        ; ebx y beginning
322
        ; esi x end
323
        ; edx y end
324
        ; ecx color
1159 hidnplayr 325
 
1198 clevermous 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
1159 hidnplayr 331
 
1198 clevermous 332
        popad
333
        ret
1159 hidnplayr 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:
1198 clevermous 346
        ; If requested, do not display button
347
        ; boarder on press.
348
        test  ebx,0x20000000
349
        jz    draw_negative_button
350
        ret
1159 hidnplayr 351
      draw_negative_button:
352
 
1198 clevermous 353
        pushad
1159 hidnplayr 354
 
1198 clevermous 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
1159 hidnplayr 361
 
1198 clevermous 362
        dec   edx
363
        push  edx
364
        inc   edx
365
        dec   esi
366
        push  esi
367
        inc   esi
1159 hidnplayr 368
 
1198 clevermous 369
        push  eax
370
        push  ebx
371
        push  ecx
372
        push  edx
373
        push  edi
1159 hidnplayr 374
 
1198 clevermous 375
        call  [disable_mouse]
1159 hidnplayr 376
 
377
      bdbnewline:
1198 clevermous 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
1159 hidnplayr 387
;        jz    bneg
388
;        jmp   nbneg
389
 
390
      bneg:
391
 
1198 clevermous 392
        ;;;call  [disable_mouse]
393
        call  [putpixel]
1159 hidnplayr 394
 
395
      nbneg:
396
 
1198 clevermous 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
1159 hidnplayr 404
 
1198 clevermous 405
        add   esp,28
1159 hidnplayr 406
 
1198 clevermous 407
        popad
1159 hidnplayr 408
 
1198 clevermous 409
        ret
1159 hidnplayr 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
 
1198 clevermous 426
align 4
1159 hidnplayr 427
checkbuttons:
428
 
429
    cmp   [BTN_DOWN],byte 0    ; mouse buttons pressed
430
    jnz   @f
431
;..................................... start 1/5 : modified by vhanla .............................
432
    mov [bPressedMouseXY_B],0
433
;..................................... end 1/5 : modified by vhanla .............................
434
    ret
435
  @@:
436
    pushad
437
 
438
    xor    esi, esi
439
    mov    edi, [BTN_ADDR]
440
    movzx  edx, word [edi]
441
    test   edx, edx
442
    jne    @f
443
    popad
444
    ret
445
 
446
  @@:
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
   @@:
1198 clevermous 458
   pop  ax
1159 hidnplayr 459
   ;and it is only refreshed after the mouse's button release
460
;..................................... end 2/5 : modified by vhanla .............................
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
 
1198 clevermous 474
    popad                 ; no button pressed
1159 hidnplayr 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]
488
    movzx ecx,word [WIN_STACK + ebx * 2]
489
    cmp   ecx,[TASK_COUNT]
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
496
 
1198 clevermous 497
        test    [ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED
498
        jnz     buttonnewcheck
1159 hidnplayr 499
 
500
;    add   ebx,window_data
501
;    mov   ecx,[window_data+ebx+8]          ; window end X
502
    movzx edx,word [eax+4]     ; button start X
503
    cmp   edx, [window_data+ebx+WDATA.box.width] ;ecx
504
    jge   buttonnewcheck
505
 
506
;    mov   ecx,[window_data+ebx+12]         ; window end Y
507
    movzx edx, word [eax+8]    ; button start Y
508
    cmp   edx, [window_data+ebx+WDATA.box.height] ;ecx
509
    jge   buttonnewcheck
510
 
511
    ; check coordinates
1198 clevermous 512
                               ; mouse x >= button x ?
1159 hidnplayr 513
    movzx ebx,word [eax+0]
514
    shl   ebx,5
515
    add   ebx,window_data
1198 clevermous 516
        mov   ecx, [ebx+WDATA.box.left]     ; window x start
1159 hidnplayr 517
    movzx edx,word [eax+4]     ; button x start
518
    add   edx,ecx
519
;..................................... start 3/5 : modified by vhanla .............................
520
    mov   cx,[mx]   ;mov cx,[MOUSE_X]
521
;..................................... end 3/5 : modified by vhanla .............................
522
    cmp   edx,ecx
1198 clevermous 523
    jg    buttonnewcheck
1159 hidnplayr 524
 
525
    movzx ebx,word [eax+6]     ; button x size
526
    add   edx,ebx
527
    cmp   ecx,edx
1198 clevermous 528
    jg    buttonnewcheck
1159 hidnplayr 529
 
1198 clevermous 530
                               ; mouse y >= button y ?
1159 hidnplayr 531
    movzx ebx,word [eax+0]
532
    shl   ebx,5
533
    add   ebx,window_data
1198 clevermous 534
        mov   ecx, [ebx+WDATA.box.top]     ; window y start
1159 hidnplayr 535
    movzx edx,word [eax+8]     ; button y start
536
    add   edx,ecx
537
;..................................... start 4/5 : modified by vhanla .............................
538
    mov   cx,[my]  ;mov cx,[MOUSE_Y]
539
;..................................... start 4/5 : modified by vhanla .............................
540
    cmp   edx,ecx
1198 clevermous 541
    jg    buttonnewcheck
1159 hidnplayr 542
 
543
    movzx ebx,word [eax+10]    ; button y size
544
    add   edx,ebx
545
    cmp   ecx,edx
1198 clevermous 546
    jg    buttonnewcheck
1159 hidnplayr 547
 
548
    ; mouse on button
549
 
550
    pop   edx
551
    pop   esi
552
 
1198 clevermous 553
    mov   bx,[eax+0xc]     ; button id : bits 16-31
1159 hidnplayr 554
    shl   ebx,16
1198 clevermous 555
    mov   bx,[eax+2]       ; button id : bits 00-16
1159 hidnplayr 556
    push  ebx
557
 
558
    mov   [MOUSE_DOWN],byte 1  ; no mouse down checks
559
    call find_pressed_button_frames
560
    call negativebutton
561
 
562
    pushad
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
 
570
  cbwaitmouseup:
571
 
572
    call  checkidle
573
 
574
    call  [draw_pointer]
575
 
576
    pushad
577
    call  stack_handler
578
    popad
579
 
580
    cmp   [BTN_DOWN],byte 0  ; mouse buttons pressed ?
581
    jnz   cbwaitmouseup
582
    popad
583
 
584
    call  negativebutton
585
    mov   [MOUSE_BACKGROUND],byte 0  ; no mouse background
586
    mov   [DONT_DRAW_MOUSE],byte 0  ; draw mouse
587
;..................................... start 5/5 : modified by vhanla .............................
588
    ; check coordinates
589
iglobal
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
593
    btn_down_determ     db 0x0        ; << // Alver 22.06.2008// <<
594
endg
595
 
596
   pusha
597
  ; mouse x >= button x ?
598
   movzx ebx,word [eax+0]
1198 clevermous 599
   shl   ebx,5
600
   add   ebx,window_data
601
   mov   ecx, [ebx+WDATA.box.left]    ; window x start
1159 hidnplayr 602
   movzx edx,word [eax+4]    ; button x start
1198 clevermous 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
1159 hidnplayr 607
 
608
   movzx ebx,word [eax+6]    ; button x size
1198 clevermous 609
   add   edx,ebx
610
   cmp   ecx,edx
611
   jg   no_on_button
1159 hidnplayr 612
 
1198 clevermous 613
        ; mouse y >= button y ?
1159 hidnplayr 614
   movzx ebx,word [eax+0]
1198 clevermous 615
   shl   ebx,5
616
   add   ebx,window_data
617
   mov   ecx, [ebx+WDATA.box.top]    ; window y start
1159 hidnplayr 618
   movzx edx,word [eax+8]    ; button y start
1198 clevermous 619
   add   edx,ecx
620
   mov   cx,[MOUSE_Y]
621
   cmp   edx,ecx
622
   jg   no_on_button
1159 hidnplayr 623
 
624
   movzx ebx,word [eax+10]   ; button y size
1198 clevermous 625
   add   edx,ebx
626
   cmp   ecx,edx
627
   jg   no_on_button
1159 hidnplayr 628
   popa
1198 clevermous 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
1159 hidnplayr 632
   push  ebx
633
   pusha
634
   jmp yes_on_button
635
no_on_button:
1198 clevermous 636
   mov   [BTN_COUNT],byte 0 ; no of buttons in buffer
1159 hidnplayr 637
yes_on_button:
1198 clevermous 638
   mov   [MOUSE_DOWN],byte 0 ; mouse down -> do not draw
1159 hidnplayr 639
   popa
640
   pop ebx
641
   popa
642
   ret
643
 
644
;..................................... end 5/5 : modified by vhanla ................................