Subversion Repositories Kolibri OS

Rev

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

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