Subversion Repositories Kolibri OS

Rev

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