Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
431 serge 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
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: 803 $
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
 
415 heavyiron 72
	push  esi
73
	push  edi
74
	push  eax
75
	push  ebx
76
	push  ecx
77
	push  edx
1 ha 78
 
415 heavyiron 79
	shr   ebx,16
684 diamond 80
	shr   ecx,16
81
	mov   eax,[TASK_BASE]
1 ha 82
 
684 diamond 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
 
684 diamond 98
	movzx edx,word [esp+4+4]
415 heavyiron 99
	add   ebx,edx
100
	shl   edx,16
101
	add   ebx,edx
684 diamond 102
	mov   ecx,esi
415 heavyiron 103
	call  dececx
104
	call  [draw_line]
1 ha 105
 
684 diamond 106
	pop     ebx
415 heavyiron 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
684 diamond 114
	mov   dx,[esp+4+4]
415 heavyiron 115
	add   bx,dx
116
	pop   edx
684 diamond 117
	mov   ecx,esi
415 heavyiron 118
	call  incecx
119
	call  [draw_line]
1 ha 120
 
684 diamond 121
	mov   dx,[esp+8]
415 heavyiron 122
	add   ax,dx
123
	shl   edx,16
124
	add   eax,edx
125
	add   ebx,1*65536
684 diamond 126
	mov   ecx,esi
415 heavyiron 127
	call  dececx
128
	call  [draw_line]
1 ha 129
 
415 heavyiron 130
	pop   edx
131
	pop   ecx
132
	pop   ebx
133
	pop   eax
134
	pop   edi
135
	pop   esi
1 ha 136
 
415 heavyiron 137
	ret
1 ha 138
 
139
button_dececx:
140
 
415 heavyiron 141
	cmp   [buttontype],dword 1
142
	jne   .finish
1 ha 143
;        je    bdece
144
;        ret
145
;      bdece:
415 heavyiron 146
	push  eax
147
	mov   eax,0x01
148
	cmp   edi,20
149
	jg    @f
150
	mov   eax,0x02
1 ha 151
      @@:
415 heavyiron 152
	test  ecx,0xff
153
	jz    @f
154
	sub   ecx,eax
1 ha 155
      @@:
415 heavyiron 156
	shl   eax,8
157
	test  ecx,0xff00
158
	jz    @f
159
	sub   ecx,eax
1 ha 160
      @@:
415 heavyiron 161
	shl   eax,8
162
	test  ecx,0xff0000
163
	jz    @f
164
	sub   ecx,eax
1 ha 165
      @@:
415 heavyiron 166
	pop    eax
1 ha 167
      .finish:
415 heavyiron 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
 
684 diamond 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
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
        push    edi
230
        mov     edi, [BTN_ADDR]
231
        movzx   eax, word [edi]
232
        cmp     eax, max_buttons
233
        jge     noaddbutt
234
        inc     eax
235
        mov     [edi], ax
1 ha 236
 
684 diamond 237
        shl     eax, 4
238
        add     edi, eax
1 ha 239
 
684 diamond 240
        mov     ax, [CURRENT_TASK]
241
        stosw
242
        mov     ax, dx
243
        stosw               ; button id number: bits 0-15
244
        mov     eax, ebx
245
        rol     eax, 16
246
        stosd               ; x start | x size
247
        mov     eax, ecx
248
        rol     eax, 16
249
        stosd               ; y start | y size
250
        mov     eax, edx
251
        shr     eax, 16
252
        stosw               ; button id number: bits 16-31
1 ha 253
 
684 diamond 254
        pop     edi
1 ha 255
 
465 serge 256
noaddbutt:
1 ha 257
 
684 diamond 258
        ret
1 ha 259
 
260
 
261
remove_button:
262
 
684 diamond 263
        and     edx, 0x7fffffff
1 ha 264
 
465 serge 265
rnewba2:
1 ha 266
 
684 diamond 267
        mov     edi, [BTN_ADDR]
268
        mov     eax, edi
269
        movzx   ebx, word [edi]
270
        inc     ebx
1 ha 271
 
465 serge 272
rnewba:
1 ha 273
 
684 diamond 274
        dec     ebx
275
        jz      rnmba
1 ha 276
 
684 diamond 277
        add     eax, 0x10
1 ha 278
 
684 diamond 279
        mov     cx, [CURRENT_TASK]
280
        cmp     cx, [eax]
281
        jnz     rnewba
282
        cmp     dx, [eax+2]
283
        jnz     rnewba
1 ha 284
 
684 diamond 285
        lea     ecx, [ebx+1]
286
        shl     ecx, 4
287
        mov     ebx, eax
288
        add     eax, 0x10
289
        call    memmove
290
        dec     dword [edi]
291
        jmp     rnewba2
1 ha 292
 
465 serge 293
rnmba:
1 ha 294
 
684 diamond 295
        ret
1 ha 296
 
297
find_pressed_button_frames:
298
 
415 heavyiron 299
	pushad
1 ha 300
 
415 heavyiron 301
	movzx ebx,word [eax+0]
302
	shl   ebx,5
303
	add   ebx,window_data
465 serge 304
        mov   ecx, [ebx+ WDATA.box.left]     ; window x start
415 heavyiron 305
	movzx edx,word [eax+4]	   ; button x start
306
	add   ecx,edx
307
	push  ecx
1 ha 308
 
465 serge 309
        mov   dx,[eax+6]                 ; button x size
415 heavyiron 310
	add   cx,dx
311
	mov   esi,ecx
312
	inc   esi
465 serge 313
        mov   ecx, [ebx+WDATA.box.top]   ; window y start
314
        mov   dx,[eax+8]                 ; button y start
415 heavyiron 315
	add   ecx,edx
316
	mov   ebx,ecx
317
		mov   dx,[eax+10]		 ; button y size
318
	add   dx,cx
319
	inc   dx
1 ha 320
 
415 heavyiron 321
	pop   eax
1 ha 322
 
415 heavyiron 323
	; eax x beginning
324
	; ebx y beginning
325
	; esi x end
326
	; edx y end
327
	; ecx color
1 ha 328
 
415 heavyiron 329
	mov   [pressed_button_eax],eax
330
	mov   [pressed_button_ebx],ebx
331
	mov   [pressed_button_ecx],ecx
332
	mov   [pressed_button_edx],edx
333
	mov   [pressed_button_esi],esi
1 ha 334
 
415 heavyiron 335
	popad
336
	ret
1 ha 337
 
338
uglobal
339
  pressed_button_eax  dd  0
340
  pressed_button_ebx  dd  0
341
  pressed_button_ecx  dd  0
342
  pressed_button_edx  dd  0
343
  pressed_button_esi  dd  0
344
endg
345
 
346
; negative button image
347
 
348
negativebutton:
415 heavyiron 349
	; If requested, do not display button
350
	; boarder on press.
351
	test  ebx,0x20000000
352
	jz    draw_negative_button
353
	ret
1 ha 354
      draw_negative_button:
355
 
415 heavyiron 356
	pushad
1 ha 357
 
415 heavyiron 358
	mov   eax,[pressed_button_eax]
359
	mov   ebx,[pressed_button_ebx]
360
	mov   ecx,[pressed_button_ecx]
361
	mov   edx,[pressed_button_edx]
362
	mov   esi,[pressed_button_esi]
363
	mov   ecx,0x01000000
1 ha 364
 
415 heavyiron 365
	dec   edx
366
	push  edx
367
	inc   edx
368
	dec   esi
369
	push  esi
370
	inc   esi
1 ha 371
 
415 heavyiron 372
	push  eax
373
	push  ebx
374
	push  ecx
375
	push  edx
376
	push  edi
1 ha 377
 
415 heavyiron 378
	call  [disable_mouse]
1 ha 379
 
380
      bdbnewline:
415 heavyiron 381
	mov   edi,1    ; force
382
	cmp   eax,[esp+16]
383
	jz    bneg
384
	cmp   eax,[esp+20]
385
	jz    bneg
386
	cmp   ebx,[esp+12]
387
	jz    bneg
388
	cmp   ebx,[esp+24]
389
	jnz   nbneg
1 ha 390
;        jz    bneg
391
;        jmp   nbneg
392
 
393
      bneg:
394
 
415 heavyiron 395
	;;;call  [disable_mouse]
396
	call  [putpixel]
1 ha 397
 
398
      nbneg:
399
 
415 heavyiron 400
	inc   eax
401
	cmp   eax,esi
402
	jnz   bdbnewline
403
	mov   eax,[esp+16]
404
	inc   ebx
405
	cmp   ebx,edx
406
	jnz   bdbnewline
1 ha 407
 
415 heavyiron 408
	add   esp,28
1 ha 409
 
415 heavyiron 410
	popad
1 ha 411
 
415 heavyiron 412
	ret
1 ha 413
 
414
; check buttons
415
 
416
 
417
; 0000 word process number
418
; 0002 word button id number : bits 0-15
419
; 0004 word x start
420
; 0006 word x size
421
; 0008 word y start
422
; 000A word y size
423
; 000C word button id number : bits 16-31
424
;
425
; button table in 0x10 increments
426
;
427
; first at 0x10
428
 
429
 
430
checkbuttons:
431
 
381 serge 432
    cmp   [BTN_DOWN],byte 0    ; mouse buttons pressed
1 ha 433
    jnz   @f
415 heavyiron 434
;..................................... start 1/5 : modified by vhanla .............................
435
    mov [bPressedMouseXY_B],0
436
;..................................... end 1/5 : modified by vhanla .............................
1 ha 437
    ret
438
  @@:
439
    pushad
440
 
441
    xor    esi, esi
381 serge 442
    mov    edi, [BTN_ADDR]
1 ha 443
    movzx  edx, word [edi]
444
    test   edx, edx
445
    jne    @f
446
    popad
447
    ret
448
 
449
  @@:
415 heavyiron 450
;..................................... start 2/5 : modified by vhanla .............................
451
  ;here i catch the coordinates when the mouse's button is clicked
452
   push ax
453
   cmp [bPressedMouseXY_B],0;FALSE
454
   jnz @f
455
   mov [bPressedMouseXY_B],1;TRUE - it was already clicked
456
   mov ax,[MOUSE_X]
457
   mov [mx],ax
458
   mov ax,[MOUSE_Y]
459
   mov [my],ax
460
   @@:
461
   pop	ax
462
   ;and it is only refreshed after the mouse's button release
463
;..................................... end 2/5 : modified by vhanla .............................
1 ha 464
 
465
    push  esi
466
    inc   edx
467
    push  edx
468
 
469
  buttonnewcheck:
470
 
471
    pop   edx
472
    pop   esi
473
    inc   esi
474
    cmp   edx,esi
475
    jge   bch
476
 
415 heavyiron 477
    popad		  ; no button pressed
1 ha 478
    ret
479
 
480
  bch:
481
 
482
    push  esi
483
    push  edx
484
    mov   eax,esi
485
    shl   eax,4
486
    add   eax,edi
487
 
488
    ; check that button is at top of windowing stack
489
 
490
    movzx ebx,word [eax]
380 serge 491
    movzx ecx,word [WIN_STACK + ebx * 2]
379 serge 492
    cmp   ecx,[TASK_COUNT]
1 ha 493
    jne   buttonnewcheck
494
 
495
    ; check that button start is inside window x/y end
496
 
497
    movzx ebx,word [eax+0]
498
    shl   ebx,5
41 mikedld 499
 
415 heavyiron 500
	test	[ebx+window_data+WDATA.fl_wstate],WSTATE_MINIMIZED
501
	jnz	buttonnewcheck
41 mikedld 502
 
1 ha 503
;    add   ebx,window_data
504
;    mov   ecx,[window_data+ebx+8]          ; window end X
505
    movzx edx,word [eax+4]     ; button start X
115 poddubny 506
    cmp   edx, [window_data+ebx+WDATA.box.width] ;ecx
1 ha 507
    jge   buttonnewcheck
508
 
509
;    mov   ecx,[window_data+ebx+12]         ; window end Y
510
    movzx edx, word [eax+8]    ; button start Y
115 poddubny 511
    cmp   edx, [window_data+ebx+WDATA.box.height] ;ecx
1 ha 512
    jge   buttonnewcheck
513
 
514
    ; check coordinates
415 heavyiron 515
			       ; mouse x >= button x ?
1 ha 516
    movzx ebx,word [eax+0]
517
    shl   ebx,5
518
    add   ebx,window_data
115 poddubny 519
	mov   ecx, [ebx+WDATA.box.left]     ; window x start
1 ha 520
    movzx edx,word [eax+4]     ; button x start
521
    add   edx,ecx
415 heavyiron 522
;..................................... start 3/5 : modified by vhanla .............................
523
    mov   cx,[mx]   ;mov cx,[MOUSE_X]
524
;..................................... end 3/5 : modified by vhanla .............................
1 ha 525
    cmp   edx,ecx
415 heavyiron 526
    jg	  buttonnewcheck
1 ha 527
 
528
    movzx ebx,word [eax+6]     ; button x size
529
    add   edx,ebx
530
    cmp   ecx,edx
415 heavyiron 531
    jg	  buttonnewcheck
1 ha 532
 
415 heavyiron 533
			       ; mouse y >= button y ?
1 ha 534
    movzx ebx,word [eax+0]
535
    shl   ebx,5
536
    add   ebx,window_data
415 heavyiron 537
	mov   ecx, [ebx+WDATA.box.top]	   ; window y start
1 ha 538
    movzx edx,word [eax+8]     ; button y start
539
    add   edx,ecx
415 heavyiron 540
;..................................... start 4/5 : modified by vhanla .............................
541
    mov   cx,[my]  ;mov cx,[MOUSE_Y]
542
;..................................... start 4/5 : modified by vhanla .............................
1 ha 543
    cmp   edx,ecx
415 heavyiron 544
    jg	  buttonnewcheck
1 ha 545
 
546
    movzx ebx,word [eax+10]    ; button y size
547
    add   edx,ebx
548
    cmp   ecx,edx
415 heavyiron 549
    jg	  buttonnewcheck
1 ha 550
 
551
    ; mouse on button
552
 
553
    pop   edx
554
    pop   esi
555
 
415 heavyiron 556
    mov   bx,[eax+0xc]	   ; button id : bits 16-31
1 ha 557
    shl   ebx,16
415 heavyiron 558
    mov   bx,[eax+2]	   ; button id : bits 00-16
1 ha 559
    push  ebx
560
 
381 serge 561
    mov   [MOUSE_DOWN],byte 1  ; no mouse down checks
1 ha 562
    call find_pressed_button_frames
563
    call negativebutton
564
 
565
    pushad
803 alver 566
; // Alver 22.06.2008 // {
567
    push  eax
568
    mov  al, byte [BTN_DOWN]
569
    mov  byte [btn_down_determ], al
570
    pop  eax
571
; } \\ Alver \\
572
 
1 ha 573
  cbwaitmouseup:
574
 
575
    call  checkidle
576
 
577
    call  [draw_pointer]
578
 
579
    pushad
580
    call  stack_handler
581
    popad
582
 
381 serge 583
    cmp   [BTN_DOWN],byte 0  ; mouse buttons pressed ?
1 ha 584
    jnz   cbwaitmouseup
585
    popad
586
 
587
    call  negativebutton
381 serge 588
    mov   [MOUSE_BACKGROUND],byte 0  ; no mouse background
589
    mov   [DONT_DRAW_MOUSE],byte 0  ; draw mouse
415 heavyiron 590
;..................................... start 5/5 : modified by vhanla .............................
28 mario79 591
    ; check coordinates
684 diamond 592
iglobal
415 heavyiron 593
    mx dw 0x0 ; keeps the x mouse's position when it was clicked
594
    my dw 0x0 ; keeps the y mouse's position when it was clicked
595
    bPressedMouseXY_B db 0x0
803 alver 596
    btn_down_determ     db 0x0        ; << // Alver 22.06.2008// <<
684 diamond 597
endg
28 mario79 598
 
33 mario79 599
   pusha
600
  ; mouse x >= button x ?
601
   movzx ebx,word [eax+0]
415 heavyiron 602
   shl	 ebx,5
603
   add	 ebx,window_data
604
   mov	 ecx, [ebx+WDATA.box.left]    ; window x start
33 mario79 605
   movzx edx,word [eax+4]    ; button x start
415 heavyiron 606
   add	 edx,ecx
607
   mov	 cx,[MOUSE_X]
608
   cmp	 edx,ecx
609
   jg	no_on_button ;if we release the pointer out of the button area
28 mario79 610
 
33 mario79 611
   movzx ebx,word [eax+6]    ; button x size
415 heavyiron 612
   add	 edx,ebx
613
   cmp	 ecx,edx
614
   jg	no_on_button
28 mario79 615
 
415 heavyiron 616
	; mouse y >= button y ?
33 mario79 617
   movzx ebx,word [eax+0]
415 heavyiron 618
   shl	 ebx,5
619
   add	 ebx,window_data
620
   mov	 ecx, [ebx+WDATA.box.top]    ; window y start
33 mario79 621
   movzx edx,word [eax+8]    ; button y start
415 heavyiron 622
   add	 edx,ecx
623
   mov	 cx,[MOUSE_Y]
624
   cmp	 edx,ecx
625
   jg	no_on_button
28 mario79 626
 
33 mario79 627
   movzx ebx,word [eax+10]   ; button y size
415 heavyiron 628
   add	 edx,ebx
629
   cmp	 ecx,edx
630
   jg	no_on_button
33 mario79 631
   popa
415 heavyiron 632
   mov	 [BTN_COUNT],byte 1 ; no of buttons in buffer
633
   pop	 ebx
634
   mov	 [BTN_BUFF],ebx   ; lets put the button id in buffer
33 mario79 635
   push  ebx
636
   pusha
637
   jmp yes_on_button
28 mario79 638
no_on_button:
415 heavyiron 639
   mov	 [BTN_COUNT],byte 0 ; no of buttons in buffer
28 mario79 640
yes_on_button:
415 heavyiron 641
   mov	 [MOUSE_DOWN],byte 0 ; mouse down -> do not draw
33 mario79 642
   popa
643
   pop ebx
644
   popa
645
   ret
646
 
415 heavyiron 647
;..................................... end 5/5 : modified by vhanla ................................