Subversion Repositories Kolibri OS

Rev

Rev 2455 | Rev 5185 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2455 Rev 4970
Line 4... Line 4...
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;                                                              ;;
6
;;                                                              ;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 8... Line 8...
8
 
8
 
Line 9... Line 9...
9
$Revision: 2455 $
9
$Revision: 4970 $
10
 
10
 
11
;==============================================================================
11
;==============================================================================
Line 37... Line 37...
37
;> edx = pack[8(flags), 24(button identifier)]
37
;> edx = pack[8(flags), 24(button identifier)]
38
;>       flags bits:
38
;>       flags bits:
39
;>          7 (31) = 0
39
;>          7 (31) = 0
40
;>          6 (30) = don't draw button
40
;>          6 (30) = don't draw button
41
;>          5 (29) = don't draw button frame when pressed
41
;>          5 (29) = don't draw button frame when pressed
-
 
42
;>          4 (28) = don't draw button 3d frame
42
;> esi = button color
43
;> esi = button color
43
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
44
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
44
;; Undefine button:
45
;; Undefine button:
45
;> edx = pack[8(flags), 24(button identifier)]
46
;> edx = pack[8(flags), 24(button identifier)]
46
;>       flags bits:
47
;>       flags bits:
Line 84... Line 85...
84
        mov     ax, [CURRENT_TASK]
85
        mov     ax, [CURRENT_TASK]
85
        stosw
86
        stosw
86
        mov     ax, dx
87
        mov     ax, dx
87
        stosw               ; button id number: bits 0-15
88
        stosw               ; button id number: bits 0-15
88
        mov     eax, ebx
89
        mov     eax, ebx
-
 
90
        dec     eax
89
        rol     eax, 16
91
        rol     eax, 16
90
        stosd               ; x start | x size
92
        stosd               ; x start | x size
91
        mov     eax, ecx
93
        mov     eax, ecx
-
 
94
        dec     eax
92
        rol     eax, 16
95
        rol     eax, 16
93
        stosd               ; y start | y size
96
        stosd               ; y start | y size
94
        mov     eax, edx
97
        mov     eax, edx
95
        shr     eax, 16
98
        shr     eax, 16
96
        stosw               ; button id number: bits 16-31
99
        stosw               ; button id number: bits 16-31
Line 98... Line 101...
98
 
101
 
99
        ; do we also need to draw the button?
102
        ; do we also need to draw the button?
100
        test    edx, 0x40000000
103
        test    edx, 0x40000000
Line 101... Line 104...
101
        jnz     .exit
104
        jnz     .exit
102
 
-
 
103
        ; draw button body
105
 
104
 
-
 
105
        pushad
106
        ; DRAW BODY -----------------------------
106
 
-
 
107
        ; calculate window-relative coordinates
-
 
108
        movzx   edi, cx
-
 
109
        shr     ebx, 16
-
 
110
        shr     ecx, 16
107
        pushad
111
        mov     eax, [TASK_BASE]
-
 
112
        add     ebx, [eax - twdw + WDATA.box.left]
-
 
113
        add     ecx, [eax - twdw + WDATA.box.top]
-
 
114
        mov     eax, ebx
-
 
115
        shl     eax, 16
-
 
116
        mov     ax, bx
-
 
117
        add     ax, word[esp + 16]
-
 
118
        mov     ebx, ecx
108
        call    button._.button_calc_relativ
119
        shl     ebx, 16
-
 
120
        mov     bx, cx
-
 
121
 
109
        xor     edi, edi ; for __sys_draw_line
-
 
110
        ; set color
-
 
111
        mov     ecx, esi
-
 
112
        ; set coordinate
122
        ; calculate initial color
113
        inc     edx
123
        mov     ecx, esi
114
        ; if gradient
124
        cmp     [buttontype], 0
115
        cmp     [buttontype], 0
125
        je      @f
-
 
126
        call    button._.incecx2
-
 
127
 
116
        je      .next_line
128
        ; set button height counter
-
 
129
    @@:
-
 
130
        mov     edx, edi
117
        call    button._.incecx
131
 
118
align 4
132
  .next_line:
-
 
133
        call    button._.button_dececx
-
 
134
        push    edi
-
 
135
        xor     edi, edi
119
.next_line:
136
;        call    [draw_line]
-
 
137
        call    __sys_draw_line
120
        call    button._.button_dececx
138
        pop     edi
121
        call    __sys_draw_line
139
        add     ebx, 0x00010001
122
        add     ebx, 0x00010001
140
        dec     edx
-
 
141
        jnz     .next_line
123
        dec     edx
Line -... Line 124...
-
 
124
        jnz     .next_line
-
 
125
        popad
-
 
126
 
142
 
127
        ; DRAW FRAME ----------------------------
Line -... Line 128...
-
 
128
        pushad
-
 
129
        call    button._.button_calc_relativ
-
 
130
        mov     esi, common_colours
-
 
131
 
-
 
132
        mov     edi, dword [esi+104]
-
 
133
        call    .top_border
-
 
134
        mov     edi, dword [esi+104]
143
        popad
135
        call    .bottom_border
-
 
136
        mov     edi, dword [esi+104]
Line 144... Line 137...
144
 
137
        call    .right_border
145
        ; draw button frame
138
        mov     edi, dword [esi+104]
146
 
139
        call    .left_border
147
        push    ebx ecx
-
 
148
 
-
 
149
        ; calculate window-relative coordinates
-
 
Line 150... Line 140...
150
        shr     ebx, 16
140
        popad
151
        shr     ecx, 16
141
 
-
 
142
        ; DRAW 3D SHADOW ------------------------
-
 
143
        test    edx, 0x10000000
-
 
144
        jnz     .exit
-
 
145
 
-
 
146
        pushad
-
 
147
        mov     edi, edx
152
        mov     eax, [TASK_BASE]
148
        call    button._.button_calc_relativ
-
 
149
        ; get color address
-
 
150
        mov     esi, common_colours
153
        add     ebx, [eax - twdw + WDATA.box.left]
151
        test    edi, 0x10000000
-
 
152
        jnz     @f
-
 
153
        add     eax, 0x10000
-
 
154
        dec     eax
-
 
155
        inc     ecx
-
 
156
        dec     edx
-
 
157
        dec     edx
-
 
158
align 4
-
 
159
@@:
154
        add     ecx, [eax - twdw + WDATA.box.top]
160
        mov     edi, dword [esi+12]
-
 
161
        call    .top_border
-
 
162
        mov     edi, dword [esi+8]
-
 
163
        call    .bottom_border
-
 
164
        mov     edi, dword [esi+8]
-
 
165
        call    .right_border
-
 
166
        mov     edi, dword [esi+12]
155
 
167
        call    .left_border
156
        ; top border
168
        popad
157
        mov     eax, ebx
169
        ret
158
        shl     eax, 16
170
 
159
        mov     ax, bx
171
align 4
160
        add     ax, [esp + 4]
-
 
161
        mov     ebx, ecx
-
 
162
        shl     ebx, 16
-
 
163
        mov     bx, cx
172
.top_border:
-
 
173
        mov     ebx, ecx
Line -... Line 174...
-
 
174
        shl     ebx, 16
164
        push    ebx
175
        mov     bx , cx
165
        xor     edi, edi
-
 
166
        mov     ecx, esi
176
        mov     ecx, edi
167
        call    button._.incecx
177
        xor     edi, edi
168
;        call    [draw_line]
178
        call    __sys_draw_line
169
        call    __sys_draw_line
179
        ret
170
 
-
 
171
        ; bottom border
180
 
172
        movzx   edx, word[esp + 4 + 0]
181
align 4
-
 
182
.bottom_border:
Line 173... Line 183...
173
        add     ebx, edx
183
        add     bx , dx
174
        shl     edx, 16
184
        rol     ebx, 16
175
        add     ebx, edx
185
        add     bx , dx
176
        mov     ecx, esi
-
 
177
        call    button._.dececx
-
 
178
;        call    [draw_line]
186
        mov     ecx, edi
179
        call    __sys_draw_line
187
        xor     edi, edi
180
 
188
        call    __sys_draw_line
181
        ; left border
189
        ret
182
        pop     ebx
-
 
183
        push    edx
190
 
184
        mov     edx, eax
191
align 4
185
        shr     edx, 16
-
 
186
        mov     ax, dx
-
 
187
        mov     edx, ebx
192
.right_border:
-
 
193
        push    eax
-
 
194
        sub     bx, dx
Line -... Line 195...
-
 
195
        mov     cx, ax
188
        shr     edx, 16
196
        shl     eax, 16
189
        mov     bx, dx
197
        mov     ax, cx
190
        add     bx, [esp + 4 + 0]
198
        mov     ecx, edi
191
        pop     edx
199
        xor     edi, edi
192
        mov     ecx, esi
200
        call    __sys_draw_line
193
        call    button._.incecx
-
 
194
;        call    [draw_line]
201
        pop     eax
195
        call    __sys_draw_line
-
 
196
 
202
        ret
197
        ; right border
203
 
198
        mov     dx, [esp + 4]
-
 
199
        add     ax, dx
204
align 4
200
        shl     edx, 16
205
.left_border:
201
        add     eax, edx
206
        shr     eax, 16
202
        add     ebx, 0x00010000
207
        mov     cx, ax
Line 203... Line 208...
203
        mov     ecx, esi
208
        shl     eax, 16
204
        call    button._.dececx
209
        mov     ax, cx
Line 267... Line 272...
267
        call    button._.find_button
272
        call    button._.find_button
268
        or      eax, eax
273
        or      eax, eax
269
        jz      .exit
274
        jz      .exit
Line 270... Line 275...
270
 
275
 
-
 
276
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]
-
 
277
        push    edi ; spam
271
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]
278
        xor     edi, edi
272
        call    button._.negative_button
-
 
-
 
279
        call    button._.negative_button
273
 
280
        pop     edi
274
  .exit:
281
  .exit:
Line 275... Line 282...
275
        ret
282
        ret
276
 
283
 
Line 287... Line 294...
287
        call    button._.find_button
294
        call    button._.find_button
288
        or      eax, eax
295
        or      eax, eax
289
        jz      .exit
296
        jz      .exit
Line 290... Line 297...
290
 
297
 
-
 
298
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]
-
 
299
        push    edi ; spam
-
 
300
        xor     edi, edi
291
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]
301
        inc     edi
292
        call    button._.negative_button
-
 
-
 
302
        call    button._.negative_button
293
 
303
        pop     edi
294
  .exit:
304
  .exit:
Line 295... Line 305...
295
        ret
305
        ret
296
 
306
 
Line 372... Line 382...
372
  .exit:
382
  .exit:
373
        pop     edi esi edx ecx
383
        pop     edi esi edx ecx
374
        ret
384
        ret
Line 375... Line 385...
375
 
385
 
376
;------------------------------------------------------------------------------
386
;------------------------------------------------------------------------------
377
button._.dececx: ;/////////////////////////////////////////////////////////////
387
button._.button_dececx: ;//////////////////////////////////////////////////////
378
;------------------------------------------------------------------------------
388
;------------------------------------------------------------------------------
379
;? 
389
;? 
-
 
390
;------------------------------------------------------------------------------
-
 
391
        cmp     [buttontype], 1
-
 
392
        jne     .finish
-
 
393
 
-
 
394
        push    eax
-
 
395
        mov     al, 1
-
 
396
        ;cmp     edi, 20
-
 
397
        ;jg      @f
-
 
398
        ;mov     al, 2
-
 
399
 
380
;------------------------------------------------------------------------------
400
    @@:
381
        sub     cl, 0x20
401
        sub     cl, al
382
        jnc     @f
402
        jnc     @f
383
        xor     cl, cl
403
        xor     cl, cl
384
    @@:
404
    @@:
385
        sub     ch, 0x20
405
        sub     ch, al
386
        jnc     @f
406
        jnc     @f
387
        xor     ch, ch
407
        xor     ch, ch
388
    @@:
408
    @@:
389
        rol     ecx, 16
409
        rol     ecx, 16
390
        sub     cl, 0x20
410
        sub     cl, al
391
        jnc     @f
411
        jnc     @f
392
        xor     cl, cl
412
        xor     cl, cl
393
    @@:
413
    @@:
394
        rol     ecx, 16
-
 
Line 395... Line -...
395
        ret
-
 
396
 
-
 
397
;------------------------------------------------------------------------------
-
 
398
button._.incecx: ;/////////////////////////////////////////////////////////////
-
 
399
;------------------------------------------------------------------------------
-
 
400
;? 
-
 
401
;------------------------------------------------------------------------------
414
        rol     ecx, 16
402
        add     cl, 0x20
-
 
403
        jnc     @f
-
 
404
        or      cl, -1
-
 
405
    @@:
-
 
406
        add     ch, 0x20
-
 
407
        jnc     @f
-
 
408
        or      ch, -1
-
 
409
    @@:
-
 
410
        rol     ecx, 16
-
 
411
        add     cl, 0x20
-
 
412
        jnc     @f
-
 
413
        or      cl, -1
-
 
414
    @@:
-
 
Line -... Line 415...
-
 
415
 
-
 
416
        pop     eax
415
        rol     ecx, 16
417
 
416
        ret
418
  .finish:
417
 
419
        ret
418
;------------------------------------------------------------------------------
420
;------------------------------------------------------------------------------
419
button._.incecx2: ;////////////////////////////////////////////////////////////
421
button._.incecx: ;////////////////////////////////////////////////////////////
420
;------------------------------------------------------------------------------
422
;------------------------------------------------------------------------------
421
;? 
423
;? 
Line 433... Line 435...
433
        jnc     @f
435
        jnc     @f
434
        or      cl, -1
436
        or      cl, -1
435
    @@:
437
    @@:
436
        rol     ecx, 16
438
        rol     ecx, 16
437
        ret
439
        ret
438
 
-
 
439
;------------------------------------------------------------------------------
440
;------------------------------------------------------------------------------
440
button._.button_dececx: ;//////////////////////////////////////////////////////
441
button._.button_calc_relativ: ;
441
;------------------------------------------------------------------------------
442
;------------------------------------------------------------------------------
442
;? 
443
;? 
443
;------------------------------------------------------------------------------
444
;------------------------------------------------------------------------------
444
        cmp     [buttontype], 1
-
 
445
        jne     .finish
445
        movzx   edx, cx
446
 
-
 
447
        push    eax
446
        dec     edx        ; get height
448
        mov     al, 1
447
        shr     ebx, 16
449
        cmp     edi, 20
448
        shr     ecx, 16
450
        jg      @f
-
 
451
        mov     al, 2
449
        mov     eax, [TASK_BASE]
452
 
-
 
453
    @@:
-
 
454
        sub     cl, al
450
        add     ebx, [eax - twdw + WDATA.box.left]
455
        jnc     @f
-
 
456
        xor     cl, cl
451
        add     ecx, [eax - twdw + WDATA.box.top]
457
    @@:
-
 
458
        sub     ch, al
452
        mov     eax, ebx
459
        jnc     @f
-
 
460
        xor     ch, ch
453
        shl     eax, 16
461
    @@:
-
 
462
        rol     ecx, 16
454
        mov     ax, bx
463
        sub     cl, al
455
        add     ax, word[esp + 20]
464
        jnc     @f
456
        dec     eax
465
        xor     cl, cl
457
        mov     bx, cx
466
    @@:
-
 
467
        rol     ecx, 16
458
        shl     ebx, 16
468
 
-
 
469
        pop     eax
459
        mov     bx, cx
470
 
-
 
471
  .finish:
-
 
472
        ret
460
        ret
Line 473... Line 461...
473
 
461
 
474
;------------------------------------------------------------------------------
462
;------------------------------------------------------------------------------
475
button._.negative_button: ;////////////////////////////////////////////////////
463
button._.negative_button: ;////////////////////////////////////////////////////
476
;------------------------------------------------------------------------------
464
;------------------------------------------------------------------------------
-
 
465
;? Invert system button border
477
;? Invert system button border
466
; edi - 0 activate, 1 - deactivate
478
;------------------------------------------------------------------------------
467
;------------------------------------------------------------------------------
479
        ; if requested, do not display button border on press.
468
        ; if requested, do not display button border on press.
480
        test    ebx, 0x20000000
469
        test    ebx, 0x20000000
Line 481... Line 470...
481
        jnz     .exit
470
        jnz     .exit
482
 
-
 
-
 
471
 
483
        pushad
472
        pushad
Line 484... Line 473...
484
 
473
        push    ebx
485
        xchg    esi, eax
474
        xchg    esi, eax
486
 
475
 
Line 497... Line 486...
497
        rol     eax, 16
486
        rol     eax, 16
498
        rol     ebx, 16
487
        rol     ebx, 16
499
        add     ax, cx
488
        add     ax, cx
500
        add     bx, dx
489
        add     bx, dx
Line -... Line 490...
-
 
490
 
-
 
491
        xor     edx, edx
-
 
492
        mov     dx, [esi + SYS_BUTTON.id_lo]
-
 
493
 
-
 
494
        cmp     dx, 1
-
 
495
        jne     .no_close
-
 
496
        sub     eax, 0x00010001
501
 
497
        dec     ebx
502
        mov     esi, 0x01000000
498
        mov     esi, 0x01000000
-
 
499
        call    draw_rectangle.forced
-
 
500
        jmp     .fade
-
 
501
align 4
-
 
502
.no_close:
-
 
503
        cmp     dx, 65535
-
 
504
        jne     .no_mini
-
 
505
        sub     eax, 0x00010001
-
 
506
        dec     ebx
-
 
507
        mov     esi, 0x01000000
-
 
508
        call    draw_rectangle.forced
-
 
509
        jmp     .fade
-
 
510
align 4
-
 
511
.no_mini:
-
 
512
        add     eax, 0x00010000
-
 
513
        add     ebx, 0x00010000
-
 
514
        pop     edx
-
 
515
        test    edx, 0x10000000
-
 
516
        jnz     .only_frame
-
 
517
        mov     edx, common_colours
-
 
518
        mov     esi, dword [edx+12]
-
 
519
        cmp     edi, 0
-
 
520
        jne     .shadow
-
 
521
        mov     esi, dword [edx+8]
-
 
522
align 4
-
 
523
.shadow:
-
 
524
        call    draw_rectangle.forced
-
 
525
align 4
-
 
526
.only_frame:
-
 
527
        mov     edx, common_colours
-
 
528
        sub     eax, 0x00010000
-
 
529
        sub     ebx, 0x00010000
-
 
530
        mov     esi, dword [edx+104]
-
 
531
        cmp     edi, 0
-
 
532
        jne     .draw
-
 
533
        mov     esi, dword [edx+112]
503
        call    draw_rectangle.forced
534
align 4
-
 
535
.draw:
504
 
536
        call    draw_rectangle.forced
-
 
537
        popad
-
 
538
        ret
505
        popad
539
align 4
-
 
540
.fade:
-
 
541
        pop     ebx
-
 
542
        popad
506
 
543
align 4
507
  .exit:
544
.exit: