Subversion Repositories Kolibri OS

Rev

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

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