Subversion Repositories Kolibri OS

Rev

Rev 1362 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1362 Rev 1376
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
 
8
 
9
$Revision: 1362 $
9
$Revision: 1376 $
10
 
10
 
11
 
11
 
12
button._.MAX_BUTTONS = 4095
12
button._.MAX_BUTTONS = 4095
13
 
13
 
14
 
14
 
15
;==============================================================================
15
;==============================================================================
16
;///// public functions ///////////////////////////////////////////////////////
16
;///// public functions ///////////////////////////////////////////////////////
17
;==============================================================================
17
;==============================================================================
18
 
18
 
19
struc SYS_BUTTON
19
struc SYS_BUTTON
20
{
20
{
21
  .pslot  dw ?
21
  .pslot  dw ?
22
  .id_lo  dw ?
22
  .id_lo  dw ?
23
  .left   dw ?
23
  .left   dw ?
24
  .width  dw ?
24
  .width  dw ?
25
  .top    dw ?
25
  .top    dw ?
26
  .height dw ?
26
  .height dw ?
27
  .id_hi  dw ?
27
  .id_hi  dw ?
28
  .sizeof:
28
  .sizeof:
29
}
29
}
30
virtual at 0
30
virtual at 0
31
  SYS_BUTTON SYS_BUTTON
31
  SYS_BUTTON SYS_BUTTON
32
end virtual
32
end virtual
33
 
33
 
34
iglobal
34
iglobal
35
  mx                dw 0x0 ; keeps the x mouse's position when it was clicked
35
  mx                dw 0x0 ; keeps the x mouse's position when it was clicked
36
  my                dw 0x0 ; keeps the y mouse's position when it was clicked
36
  my                dw 0x0 ; keeps the y mouse's position when it was clicked
37
  bPressedMouseXY_B db 0x0
37
  bPressedMouseXY_B db 0x0
38
  btn_down_determ   db 0x0
38
  btn_down_determ   db 0x0
39
endg
39
endg
40
 
40
 
41
align 4
41
align 4
42
;------------------------------------------------------------------------------
42
;------------------------------------------------------------------------------
43
syscall_button: ;///// system function 8 //////////////////////////////////////
43
syscall_button: ;///// system function 8 //////////////////////////////////////
44
;------------------------------------------------------------------------------
44
;------------------------------------------------------------------------------
45
;? Define/undefine GUI button object
45
;? Define/undefine GUI button object
46
;------------------------------------------------------------------------------
46
;------------------------------------------------------------------------------
47
;; Define button:
47
;; Define button:
48
;> ebx = pack[16(x), 16(width)]
48
;> ebx = pack[16(x), 16(width)]
49
;> ecx = pack[16(y), 16(height)]
49
;> ecx = pack[16(y), 16(height)]
50
;> edx = pack[8(flags), 24(button identifier)]
50
;> edx = pack[8(flags), 24(button identifier)]
51
;>       flags bits:
51
;>       flags bits:
52
;>          7 (31) = 0
52
;>          7 (31) = 0
53
;>          6 (30) = don't draw button
53
;>          6 (30) = don't draw button
54
;>          5 (29) = don't draw button frame when pressed
54
;>          5 (29) = don't draw button frame when pressed
55
;> esi = button color
55
;> esi = button color
56
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
57
;; Undefine button:
57
;; Undefine button:
58
;> edx = pack[8(flags), 24(button identifier)]
58
;> edx = pack[8(flags), 24(button identifier)]
59
;>       flags bits:
59
;>       flags bits:
60
;>          7 (31) = 1
60
;>          7 (31) = 1
61
;------------------------------------------------------------------------------
61
;------------------------------------------------------------------------------
62
        ; do we actually need to undefine the button?
62
        ; do we actually need to undefine the button?
63
        test    edx, 0x80000000
63
        test    edx, 0x80000000
64
        jnz     .remove_button
64
        jnz     .remove_button
65
 
65
 
66
        ; do we have free button slots available?
66
        ; do we have free button slots available?
67
        mov     edi, [BTN_ADDR]
67
        mov     edi, [BTN_ADDR]
68
        mov     eax, [edi]
68
        mov     eax, [edi]
69
        cmp     eax, button._.MAX_BUTTONS
69
        cmp     eax, button._.MAX_BUTTONS
70
        jge     .exit
70
        jge     .exit
71
 
71
 
72
        ; does it have positive size? (otherwise it doesn't have sense)
72
        ; does it have positive size? (otherwise it doesn't have sense)
73
        or      bx, bx
73
        or      bx, bx
74
        jle     .exit
74
        jle     .exit
75
        or      cx, cx
75
        or      cx, cx
76
        jle     .exit
76
        jle     .exit
77
 
77
 
78
        ; make coordinates clientbox-relative
78
        ; make coordinates clientbox-relative
79
        push    eax
79
        push    eax
80
        mov     eax, [current_slot]
80
        mov     eax, [current_slot]
81
        rol     ebx, 16
81
        rol     ebx, 16
82
        add     bx, word[eax + APPDATA.wnd_clientbox.left]
82
        add     bx, word[eax + APPDATA.wnd_clientbox.left]
83
        rol     ebx, 16
83
        rol     ebx, 16
84
        rol     ecx, 16
84
        rol     ecx, 16
85
        add     cx, word[eax + APPDATA.wnd_clientbox.top]
85
        add     cx, word[eax + APPDATA.wnd_clientbox.top]
86
        rol     ecx, 16
86
        rol     ecx, 16
87
        pop     eax
87
        pop     eax
88
 
88
 
89
        ; basic checks passed, define the button
89
        ; basic checks passed, define the button
90
        push    ebx ecx edx
90
        push    ebx ecx edx
91
        inc     eax
91
        inc     eax
92
        mov     [edi], ax
92
        mov     [edi], ax
93
        shl     eax, 4
93
        shl     eax, 4
94
        add     edi, eax
94
        add     edi, eax
95
        ; NOTE: this code doesn't rely on SYS_BUTTON struct, please revise it
95
        ; NOTE: this code doesn't rely on SYS_BUTTON struct, please revise it
96
        ;       if you change something
96
        ;       if you change something
97
        mov     ax, [CURRENT_TASK]
97
        mov     ax, [CURRENT_TASK]
98
        stosw
98
        stosw
99
        mov     ax, dx
99
        mov     ax, dx
100
        stosw               ; button id number: bits 0-15
100
        stosw               ; button id number: bits 0-15
101
        mov     eax, ebx
101
        mov     eax, ebx
102
        rol     eax, 16
102
        rol     eax, 16
103
        stosd               ; x start | x size
103
        stosd               ; x start | x size
104
        mov     eax, ecx
104
        mov     eax, ecx
105
        rol     eax, 16
105
        rol     eax, 16
106
        stosd               ; y start | y size
106
        stosd               ; y start | y size
107
        mov     eax, edx
107
        mov     eax, edx
108
        shr     eax, 16
108
        shr     eax, 16
109
        stosw               ; button id number: bits 16-31
109
        stosw               ; button id number: bits 16-31
110
        pop     edx ecx ebx
110
        pop     edx ecx ebx
111
 
111
 
112
        ; do we also need to draw the button?
112
        ; do we also need to draw the button?
113
        test    edx, 0x40000000
113
        test    edx, 0x40000000
114
        jnz     .exit
114
        jnz     .exit
115
 
115
 
116
        ; draw button body
116
        ; draw button body
117
 
117
 
118
        pushad
118
        pushad
119
 
119
 
120
        ; calculate window-relative coordinates
120
        ; calculate window-relative coordinates
121
        movzx   edi, cx
121
        movzx   edi, cx
122
        shr     ebx, 16
122
        shr     ebx, 16
123
        shr     ecx, 16
123
        shr     ecx, 16
124
        mov     eax, [TASK_BASE]
124
        mov     eax, [TASK_BASE]
125
        add     ebx, [eax - twdw + WDATA.box.left]
125
        add     ebx, [eax - twdw + WDATA.box.left]
126
        add     ecx, [eax - twdw + WDATA.box.top]
126
        add     ecx, [eax - twdw + WDATA.box.top]
127
        mov     eax, ebx
127
        mov     eax, ebx
128
        shl     eax, 16
128
        shl     eax, 16
129
        mov     ax, bx
129
        mov     ax, bx
130
        add     ax, word[esp + 16]
130
        add     ax, word[esp + 16]
131
        mov     ebx, ecx
131
        mov     ebx, ecx
132
        shl     ebx, 16
132
        shl     ebx, 16
133
        mov     bx, cx
133
        mov     bx, cx
134
 
134
 
135
        ; calculate initial color
135
        ; calculate initial color
136
        mov     ecx, esi
136
        mov     ecx, esi
137
        cmp     [buttontype], 0
137
        cmp     [buttontype], 0
138
        je      @f
138
        je      @f
139
        call    button._.incecx2
139
        call    button._.incecx2
140
 
140
 
141
        ; set button height counter
141
        ; set button height counter
142
    @@: mov     edx, edi
142
    @@: mov     edx, edi
143
 
143
 
144
  .next_line:
144
  .next_line:
145
        call    button._.button_dececx
145
        call    button._.button_dececx
146
        push    edi
146
        push    edi
147
        xor     edi, edi
147
        xor     edi, edi
148
        call    [draw_line]
148
        call    [draw_line]
149
        pop     edi
149
        pop     edi
150
        add     ebx, 0x00010001
150
        add     ebx, 0x00010001
151
        dec     edx
151
        dec     edx
152
        jnz     .next_line
152
        jnz     .next_line
153
 
153
 
154
        popad
154
        popad
155
 
155
 
156
        ; draw button frame
156
        ; draw button frame
157
 
157
 
158
        push    ebx ecx
158
        push    ebx ecx
159
 
159
 
160
        ; calculate window-relative coordinates
160
        ; calculate window-relative coordinates
161
        shr     ebx, 16
161
        shr     ebx, 16
162
        shr     ecx, 16
162
        shr     ecx, 16
163
        mov     eax, [TASK_BASE]
163
        mov     eax, [TASK_BASE]
164
        add     ebx, [eax - twdw + WDATA.box.left]
164
        add     ebx, [eax - twdw + WDATA.box.left]
165
        add     ecx, [eax - twdw + WDATA.box.top]
165
        add     ecx, [eax - twdw + WDATA.box.top]
166
 
166
 
167
        ; top border
167
        ; top border
168
        mov     eax, ebx
168
        mov     eax, ebx
169
        shl     eax, 16
169
        shl     eax, 16
170
        mov     ax, bx
170
        mov     ax, bx
171
        add     ax, [esp + 4]
171
        add     ax, [esp + 4]
172
        mov     ebx, ecx
172
        mov     ebx, ecx
173
        shl     ebx, 16
173
        shl     ebx, 16
174
        mov     bx, cx
174
        mov     bx, cx
175
        push    ebx
175
        push    ebx
176
        xor     edi, edi
176
        xor     edi, edi
177
        mov     ecx, esi
177
        mov     ecx, esi
178
        call    button._.incecx
178
        call    button._.incecx
179
        call    [draw_line]
179
        call    [draw_line]
180
 
180
 
181
        ; bottom border
181
        ; bottom border
182
        movzx   edx, word[esp + 4 + 0]
182
        movzx   edx, word[esp + 4 + 0]
183
        add     ebx, edx
183
        add     ebx, edx
184
        shl     edx, 16
184
        shl     edx, 16
185
        add     ebx, edx
185
        add     ebx, edx
186
        mov     ecx, esi
186
        mov     ecx, esi
187
        call    button._.dececx
187
        call    button._.dececx
188
        call    [draw_line]
188
        call    [draw_line]
189
 
189
 
190
        ; left border
190
        ; left border
191
        pop     ebx
191
        pop     ebx
192
        push    edx
192
        push    edx
193
        mov     edx, eax
193
        mov     edx, eax
194
        shr     edx, 16
194
        shr     edx, 16
195
        mov     ax, dx
195
        mov     ax, dx
196
        mov     edx, ebx
196
        mov     edx, ebx
197
        shr     edx, 16
197
        shr     edx, 16
198
        mov     bx, dx
198
        mov     bx, dx
199
        add     bx, [esp + 4 + 0]
199
        add     bx, [esp + 4 + 0]
200
        pop     edx
200
        pop     edx
201
        mov     ecx, esi
201
        mov     ecx, esi
202
        call    button._.incecx
202
        call    button._.incecx
203
        call    [draw_line]
203
        call    [draw_line]
204
 
204
 
205
        ; right border
205
        ; right border
206
        mov     dx, [esp + 4]
206
        mov     dx, [esp + 4]
207
        add     ax, dx
207
        add     ax, dx
208
        shl     edx, 16
208
        shl     edx, 16
209
        add     eax, edx
209
        add     eax, edx
210
        add     ebx, 0x00010000
210
        add     ebx, 0x00010000
211
        mov     ecx, esi
211
        mov     ecx, esi
212
        call    button._.dececx
212
        call    button._.dececx
213
        call    [draw_line]
213
        call    [draw_line]
214
 
214
 
215
        pop     ecx ebx
215
        pop     ecx ebx
216
 
216
 
217
  .exit:
217
  .exit:
218
        ret
218
        ret
219
 
219
 
220
; FIXME: mutex needed
220
; FIXME: mutex needed
221
syscall_button.remove_button:
221
syscall_button.remove_button:
222
        and     edx, 0x00ffffff
222
        and     edx, 0x00ffffff
223
        mov     edi, [BTN_ADDR]
223
        mov     edi, [BTN_ADDR]
224
        mov     ebx, [edi]
224
        mov     ebx, [edi]
225
        inc     ebx
225
        inc     ebx
226
        imul    esi, ebx, SYS_BUTTON.sizeof
226
        imul    esi, ebx, SYS_BUTTON.sizeof
227
        add     esi, edi
227
        add     esi, edi
228
        xor     ecx, ecx
228
        xor     ecx, ecx
229
        add     ecx, -SYS_BUTTON.sizeof
229
        add     ecx, -SYS_BUTTON.sizeof
230
 
230
 
231
  .next_button:
231
  .next_button:
232
        dec     ebx
232
        dec     ebx
233
        jz      .exit
233
        jz      .exit
234
 
234
 
235
        add     ecx, SYS_BUTTON.sizeof
235
        add     ecx, SYS_BUTTON.sizeof
236
        add     esi, -SYS_BUTTON.sizeof
236
        add     esi, -SYS_BUTTON.sizeof
237
 
237
 
238
        ; does it belong to our process?
238
        ; does it belong to our process?
239
        mov     ax, [CURRENT_TASK]
239
        mov     ax, [CURRENT_TASK]
240
        cmp     ax, [esi + SYS_BUTTON.pslot]
240
        cmp     ax, [esi + SYS_BUTTON.pslot]
241
        jne     .next_button
241
        jne     .next_button
242
 
242
 
243
        ; does the identifier match?
243
        ; does the identifier match?
244
        mov     eax, dword[esi + SYS_BUTTON.id_hi - 2]
244
        mov     eax, dword[esi + SYS_BUTTON.id_hi - 2]
245
        mov     ax, [esi + SYS_BUTTON.id_lo]
245
        mov     ax, [esi + SYS_BUTTON.id_lo]
246
        and     eax, 0x00ffffff
246
        and     eax, 0x00ffffff
247
        cmp     edx, eax
247
        cmp     edx, eax
248
        jne     .next_button
248
        jne     .next_button
249
 
249
 
250
        ; okay, undefine it
250
        ; okay, undefine it
251
        push    ebx
251
        push    ebx
252
        mov     ebx, esi
252
        mov     ebx, esi
253
        lea     eax, [esi + SYS_BUTTON.sizeof]
253
        lea     eax, [esi + SYS_BUTTON.sizeof]
254
        call    memmove
254
        call    memmove
255
        dec     dword[edi]
255
        dec     dword[edi]
256
        add     ecx, -SYS_BUTTON.sizeof
256
        add     ecx, -SYS_BUTTON.sizeof
257
        pop     ebx
257
        pop     ebx
258
        jmp     .next_button
258
        jmp     .next_button
259
 
259
 
260
  .exit:
260
  .exit:
261
        ret
261
        ret
262
 
262
 
263
align 4
263
align 4
264
;------------------------------------------------------------------------------
264
;------------------------------------------------------------------------------
265
check_buttons: ;///////////////////////////////////////////////////////////////
265
check_buttons: ;///////////////////////////////////////////////////////////////
266
;------------------------------------------------------------------------------
266
;------------------------------------------------------------------------------
267
;? 
267
;? 
268
;------------------------------------------------------------------------------
268
;------------------------------------------------------------------------------
269
        cmp     byte[BTN_DOWN], 0    ; mouse buttons pressed
269
        cmp     byte[BTN_DOWN], 0    ; mouse buttons pressed
270
        jnz     @f
270
        jnz     @f
271
        mov     [bPressedMouseXY_B], 0
271
        mov     [bPressedMouseXY_B], 0
272
        ret
272
        ret
273
 
273
 
274
    @@: pushad
274
    @@: pushad
275
        xor     esi, esi
275
        xor     esi, esi
276
        mov     edi, [BTN_ADDR]
276
        mov     edi, [BTN_ADDR]
277
        mov     edx, [edi]
277
        mov     edx, [edi]
278
        test    edx, edx
278
        test    edx, edx
279
        jne     @f
279
        jne     @f
280
        popad
280
        popad
281
        ret
281
        ret
282
 
282
 
283
        ;here i catch the coordinates when the mouse's button is clicked
283
        ;here i catch the coordinates when the mouse's button is clicked
284
    @@: push    ax
284
    @@: push    ax
285
        cmp     [bPressedMouseXY_B], 0 ; FALSE
285
        cmp     [bPressedMouseXY_B], 0 ; FALSE
286
        jnz     @f
286
        jnz     @f
287
        mov     [bPressedMouseXY_B], 1 ; TRUE - it was already clicked
287
        mov     [bPressedMouseXY_B], 1 ; TRUE - it was already clicked
288
        mov     ax, [MOUSE_X]
288
        mov     ax, [MOUSE_X]
289
        mov     [mx], ax
289
        mov     [mx], ax
290
        mov     ax, [MOUSE_Y]
290
        mov     ax, [MOUSE_Y]
291
        mov     [my], ax
291
        mov     [my], ax
292
    @@: pop     ax
292
    @@: pop     ax
293
        ;and it is only refreshed after the mouse's button release
293
        ;and it is only refreshed after the mouse's button release
294
 
294
 
295
        push    esi
295
        push    esi
296
        inc     edx
296
        inc     edx
297
        push    edx
297
        push    edx
298
 
298
 
299
  .buttonnewcheck:
299
  .buttonnewcheck:
300
        pop     edx
300
        pop     edx
301
        pop     esi
301
        pop     esi
302
        inc     esi
302
        inc     esi
303
        cmp     edx, esi
303
        cmp     edx, esi
304
        jge     .bch
304
        jge     .bch
305
 
305
 
306
        popad
306
        popad
307
        ret
307
        ret
308
 
308
 
309
  .bch:
309
  .bch:
310
        push    esi
310
        push    esi
311
        push    edx
311
        push    edx
312
        mov     eax, esi
312
        mov     eax, esi
313
        shl     eax, 4
313
        shl     eax, 4
314
        add     eax, edi
314
        add     eax, edi
315
 
315
 
316
        ; check that button is at top of windowing stack
316
        ; check that button is at top of windowing stack
317
        movzx   ebx, [eax + SYS_BUTTON.pslot]
317
        movzx   ebx, [eax + SYS_BUTTON.pslot]
318
        movzx   ecx, word[WIN_STACK + ebx * 2]
318
        movzx   ecx, word[WIN_STACK + ebx * 2]
319
        cmp     ecx, [TASK_COUNT]
319
        cmp     ecx, [TASK_COUNT]
320
        jne     .buttonnewcheck
320
        jne     .buttonnewcheck
321
 
321
 
322
        ; check that button start is inside window x/y end
322
        ; check that button start is inside window x/y end
323
        shl     ebx, 5
323
        shl     ebx, 5
324
 
324
 
325
        test    [ebx + window_data + WDATA.fl_wstate], WSTATE_MINIMIZED
325
        test    [ebx + window_data + WDATA.fl_wstate], WSTATE_MINIMIZED
326
        jnz     .buttonnewcheck
326
        jnz     .buttonnewcheck
327
 
327
 
328
        movzx   edx, [eax + SYS_BUTTON.left]
328
        movzx   edx, [eax + SYS_BUTTON.left]
329
        cmp     edx, [window_data + ebx + WDATA.box.width] ;ecx
329
        cmp     edx, [window_data + ebx + WDATA.box.width] ;ecx
330
        jge     .buttonnewcheck
330
        jge     .buttonnewcheck
331
 
331
 
332
        movzx   edx, [eax + SYS_BUTTON.top]
332
        movzx   edx, [eax + SYS_BUTTON.top]
333
        cmp     edx, [window_data + ebx + WDATA.box.height] ;ecx
333
        cmp     edx, [window_data + ebx + WDATA.box.height] ;ecx
334
        jge     .buttonnewcheck
334
        jge     .buttonnewcheck
335
 
335
 
336
        ; check coordinates
336
        ; check coordinates
337
 
337
 
338
        ; mouse x >= button x ?
338
        ; mouse x >= button x ?
339
        add     ebx, window_data
339
        add     ebx, window_data
340
        mov     ecx, [ebx + WDATA.box.left]
340
        mov     ecx, [ebx + WDATA.box.left]
341
        movzx   edx, [eax + SYS_BUTTON.left]
341
        movzx   edx, [eax + SYS_BUTTON.left]
342
        add     edx, ecx
342
        add     edx, ecx
343
        mov     cx, [mx]   ;mov cx,[MOUSE_X]
343
        mov     cx, [mx]   ;mov cx,[MOUSE_X]
344
        cmp     edx, ecx
344
        cmp     edx, ecx
345
        jg      .buttonnewcheck
345
        jg      .buttonnewcheck
346
 
346
 
347
        movzx   ebx, [eax + SYS_BUTTON.width]
347
        movzx   ebx, [eax + SYS_BUTTON.width]
348
        add     edx, ebx
348
        add     edx, ebx
349
        cmp     ecx, edx
349
        cmp     ecx, edx
350
        jg      .buttonnewcheck
350
        jg      .buttonnewcheck
351
 
351
 
352
        ; mouse y >= button y ?
352
        ; mouse y >= button y ?
353
        movzx   ebx, [eax + SYS_BUTTON.pslot]
353
        movzx   ebx, [eax + SYS_BUTTON.pslot]
354
        shl     ebx, 5
354
        shl     ebx, 5
355
        add     ebx, window_data
355
        add     ebx, window_data
356
        mov     ecx, [ebx + WDATA.box.top]
356
        mov     ecx, [ebx + WDATA.box.top]
357
        movzx   edx, [eax + SYS_BUTTON.top]
357
        movzx   edx, [eax + SYS_BUTTON.top]
358
        add     edx, ecx
358
        add     edx, ecx
359
        mov     cx, [my]  ;mov cx,[MOUSE_Y]
359
        mov     cx, [my]  ;mov cx,[MOUSE_Y]
360
        cmp     edx, ecx
360
        cmp     edx, ecx
361
        jg      .buttonnewcheck
361
        jg      .buttonnewcheck
362
 
362
 
363
        movzx   ebx, [eax + SYS_BUTTON.height]
363
        movzx   ebx, [eax + SYS_BUTTON.height]
364
        add     edx, ebx
364
        add     edx, ebx
365
        cmp     ecx, edx
365
        cmp     ecx, edx
366
        jg      .buttonnewcheck
366
        jg      .buttonnewcheck
367
 
367
 
368
        ; mouse on button
368
        ; mouse on button
369
 
369
 
370
        pop     edx
370
        pop     edx
371
        pop     esi
371
        pop     esi
372
 
372
 
373
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]     ; button id : bits 16-31
373
        mov     ebx, dword[eax + SYS_BUTTON.id_hi - 2]     ; button id : bits 16-31
374
        mov     bx, [eax + SYS_BUTTON.id_lo]       ; button id : bits 00-16
374
        mov     bx, [eax + SYS_BUTTON.id_lo]       ; button id : bits 00-16
375
        push    ebx
375
        push    ebx
376
 
376
 
377
        mov     byte[MOUSE_DOWN], 1  ; no mouse down checks
377
        mov     byte[MOUSE_DOWN], 1  ; no mouse down checks
378
        call    button._.negative_button
378
        call    button._.negative_button
379
 
379
 
380
        pushad
380
        pushad
381
        push    eax
381
        push    eax
382
        mov     al, [BTN_DOWN]
382
        mov     al, [BTN_DOWN]
383
        mov     byte[btn_down_determ], al
383
        mov     byte[btn_down_determ], al
384
        pop     eax
384
        pop     eax
385
 
385
 
386
  .cbwaitmouseup:
386
  .cbwaitmouseup:
387
        call    checkidle
387
        call    checkidle
388
        call    [draw_pointer]
388
        call    [draw_pointer]
389
 
389
 
390
        pushad
390
        pushad
391
        call    stack_handler
391
        call    stack_handler
392
        popad
392
        popad
393
 
393
 
394
        cmp     byte[BTN_DOWN], 0  ; mouse buttons pressed ?
394
        cmp     byte[BTN_DOWN], 0  ; mouse buttons pressed ?
395
        jnz     .cbwaitmouseup
395
        jnz     .cbwaitmouseup
396
        popad
396
        popad
397
 
397
 
398
        call    button._.negative_button
398
        call    button._.negative_button
399
        mov     byte[MOUSE_BACKGROUND], 0  ; no mouse background
399
        mov     byte[MOUSE_BACKGROUND], 0  ; no mouse background
400
        mov     byte[DONT_DRAW_MOUSE], 0  ; draw mouse
400
        mov     byte[DONT_DRAW_MOUSE], 0  ; draw mouse
401
 
401
 
402
        ; check coordinates
402
        ; check coordinates
403
        pusha
403
        pusha
404
 
404
 
405
        ; mouse x >= button x ?
405
        ; mouse x >= button x ?
406
        movzx   ebx, [eax + SYS_BUTTON.pslot]
406
        movzx   ebx, [eax + SYS_BUTTON.pslot]
407
        shl     ebx, 5
407
        shl     ebx, 5
408
        add     ebx, window_data
408
        add     ebx, window_data
409
        mov     ecx, [ebx + WDATA.box.left]
409
        mov     ecx, [ebx + WDATA.box.left]
410
        movzx   edx, [eax + SYS_BUTTON.left]
410
        movzx   edx, [eax + SYS_BUTTON.left]
411
        add     edx, ecx
411
        add     edx, ecx
412
        mov     cx, [MOUSE_X]
412
        mov     cx, [MOUSE_X]
413
        cmp     edx, ecx
413
        cmp     edx, ecx
414
        jg      .no_on_button ;if we release the pointer out of the button area
414
        jg      .no_on_button ;if we release the pointer out of the button area
415
 
415
 
416
        movzx   ebx, [eax + SYS_BUTTON.width]
416
        movzx   ebx, [eax + SYS_BUTTON.width]
417
        add     edx, ebx
417
        add     edx, ebx
418
        cmp     ecx, edx
418
        cmp     ecx, edx
419
        jg      .no_on_button
419
        jg      .no_on_button
420
 
420
 
421
        ; mouse y >= button y ?
421
        ; mouse y >= button y ?
422
        movzx   ebx, [eax + SYS_BUTTON.pslot]
422
        movzx   ebx, [eax + SYS_BUTTON.pslot]
423
        shl     ebx, 5
423
        shl     ebx, 5
424
        add     ebx, window_data
424
        add     ebx, window_data
425
        mov     ecx, [ebx + WDATA.box.top]
425
        mov     ecx, [ebx + WDATA.box.top]
426
        movzx   edx, [eax + SYS_BUTTON.top]
426
        movzx   edx, [eax + SYS_BUTTON.top]
427
        add     edx, ecx
427
        add     edx, ecx
428
        mov     cx, [MOUSE_Y]
428
        mov     cx, [MOUSE_Y]
429
        cmp     edx, ecx
429
        cmp     edx, ecx
430
        jg      .no_on_button
430
        jg      .no_on_button
431
 
431
 
432
        movzx   ebx, [eax + SYS_BUTTON.height]
432
        movzx   ebx, [eax + SYS_BUTTON.height]
433
        add     edx, ebx
433
        add     edx, ebx
434
        cmp     ecx, edx
434
        cmp     ecx, edx
435
        jg      .no_on_button
435
        jg      .no_on_button
436
 
436
 
437
        popa
437
        popa
438
 
438
 
439
        mov     byte[BTN_COUNT], 1 ; no of buttons in buffer
439
        mov     byte[BTN_COUNT], 1 ; no of buttons in buffer
440
        pop     ebx
440
        pop     ebx
441
        mov     [BTN_BUFF], ebx   ; lets put the button id in buffer
441
        mov     [BTN_BUFF], ebx   ; lets put the button id in buffer
442
        push    ebx
442
        push    ebx
443
        pusha
443
        pusha
444
        jmp     .yes_on_button
444
        jmp     .yes_on_button
445
 
445
 
446
  .no_on_button:
446
  .no_on_button:
447
        mov     byte[BTN_COUNT], 0 ; no of buttons in buffer
447
        mov     byte[BTN_COUNT], 0 ; no of buttons in buffer
448
 
448
 
449
  .yes_on_button:
449
  .yes_on_button:
450
        mov     byte[MOUSE_DOWN], 0 ; mouse down -> do not draw
450
        mov     byte[MOUSE_DOWN], 0 ; mouse down -> do not draw
451
        popa
451
        popa
452
        pop     ebx
452
        pop     ebx
453
        popa
453
        popa
454
        ret
454
        ret
455
 
455
 
456
;==============================================================================
456
;==============================================================================
457
;///// private functions //////////////////////////////////////////////////////
457
;///// private functions //////////////////////////////////////////////////////
458
;==============================================================================
458
;==============================================================================
459
 
459
 
460
;------------------------------------------------------------------------------
460
;------------------------------------------------------------------------------
461
button._.dececx: ;/////////////////////////////////////////////////////////////
461
button._.dececx: ;/////////////////////////////////////////////////////////////
462
;------------------------------------------------------------------------------
462
;------------------------------------------------------------------------------
463
;? 
463
;? 
464
;------------------------------------------------------------------------------
464
;------------------------------------------------------------------------------
465
        sub     cl, 0x20
465
        sub     cl, 0x20
466
        jnc     @f
466
        jnc     @f
467
        xor     cl, cl
467
        xor     cl, cl
468
    @@: sub     ch, 0x20
468
    @@: sub     ch, 0x20
469
        jnc     @f
469
        jnc     @f
470
        xor     ch, ch
470
        xor     ch, ch
471
    @@: rol     ecx, 16
471
    @@: rol     ecx, 16
472
        sub     cl, 0x20
472
        sub     cl, 0x20
473
        jnc     @f
473
        jnc     @f
474
        xor     cl, cl
474
        xor     cl, cl
475
    @@: rol     ecx, 16
475
    @@: rol     ecx, 16
476
        ret
476
        ret
477
 
477
 
478
;------------------------------------------------------------------------------
478
;------------------------------------------------------------------------------
479
button._.incecx: ;/////////////////////////////////////////////////////////////
479
button._.incecx: ;/////////////////////////////////////////////////////////////
480
;------------------------------------------------------------------------------
480
;------------------------------------------------------------------------------
481
;? 
481
;? 
482
;------------------------------------------------------------------------------
482
;------------------------------------------------------------------------------
483
        add     cl, 0x20
483
        add     cl, 0x20
484
        jnc     @f
484
        jnc     @f
485
        or      cl, -1
485
        or      cl, -1
486
    @@: add     ch, 0x20
486
    @@: add     ch, 0x20
487
        jnc     @f
487
        jnc     @f
488
        or      ch, -1
488
        or      ch, -1
489
    @@: rol     ecx, 16
489
    @@: rol     ecx, 16
490
        add     cl, 0x20
490
        add     cl, 0x20
491
        jnc     @f
491
        jnc     @f
492
        or      cl, -1
492
        or      cl, -1
493
    @@: rol     ecx, 16
493
    @@: rol     ecx, 16
494
        ret
494
        ret
495
 
495
 
496
;------------------------------------------------------------------------------
496
;------------------------------------------------------------------------------
497
button._.incecx2: ;////////////////////////////////////////////////////////////
497
button._.incecx2: ;////////////////////////////////////////////////////////////
498
;------------------------------------------------------------------------------
498
;------------------------------------------------------------------------------
499
;? 
499
;? 
500
;------------------------------------------------------------------------------
500
;------------------------------------------------------------------------------
501
        add     cl, 0x14
501
        add     cl, 0x14
502
        jnc     @f
502
        jnc     @f
503
        or      cl, -1
503
        or      cl, -1
504
    @@: add     ch, 0x14
504
    @@: add     ch, 0x14
505
        jnc     @f
505
        jnc     @f
506
        or      ch, -1
506
        or      ch, -1
507
    @@: rol     ecx, 16
507
    @@: rol     ecx, 16
508
        add     cl, 0x14
508
        add     cl, 0x14
509
        jnc     @f
509
        jnc     @f
510
        or      cl, -1
510
        or      cl, -1
511
    @@: rol     ecx, 16
511
    @@: rol     ecx, 16
512
        ret
512
        ret
513
 
513
 
514
;------------------------------------------------------------------------------
514
;------------------------------------------------------------------------------
515
button._.button_dececx: ;//////////////////////////////////////////////////////
515
button._.button_dececx: ;//////////////////////////////////////////////////////
516
;------------------------------------------------------------------------------
516
;------------------------------------------------------------------------------
517
;? 
517
;? 
518
;------------------------------------------------------------------------------
518
;------------------------------------------------------------------------------
519
        cmp     [buttontype], 1
519
        cmp     [buttontype], 1
520
        jne     .finish
520
        jne     .finish
521
 
521
 
522
        push    eax
522
        push    eax
523
        mov     al, 1
523
        mov     al, 1
524
        cmp     edi, 20
524
        cmp     edi, 20
525
        jg      @f
525
        jg      @f
526
        mov     al, 2
526
        mov     al, 2
527
 
527
 
528
    @@: sub     cl, al
528
    @@: sub     cl, al
529
        jnc     @f
529
        jnc     @f
530
        xor     cl, cl
530
        xor     cl, cl
531
    @@: sub     ch, al
531
    @@: sub     ch, al
532
        jnc     @f
532
        jnc     @f
533
        xor     ch, ch
533
        xor     ch, ch
534
    @@: rol     ecx, 16
534
    @@: rol     ecx, 16
535
        sub     cl, al
535
        sub     cl, al
536
        jnc     @f
536
        jnc     @f
537
        xor     cl, cl
537
        xor     cl, cl
538
    @@: rol     ecx, 16
538
    @@: rol     ecx, 16
539
 
539
 
540
        pop     eax
540
        pop     eax
541
 
541
 
542
  .finish:
542
  .finish:
543
        ret
543
        ret
544
 
544
 
545
;------------------------------------------------------------------------------
545
;------------------------------------------------------------------------------
546
button._.negative_button: ;////////////////////////////////////////////////////
546
button._.negative_button: ;////////////////////////////////////////////////////
547
;------------------------------------------------------------------------------
547
;------------------------------------------------------------------------------
548
;? 
548
;? 
549
;------------------------------------------------------------------------------
549
;------------------------------------------------------------------------------
550
        ; if requested, do not display button border on press.
550
        ; if requested, do not display button border on press.
551
        test    ebx, 0x20000000
551
        test    ebx, 0x20000000
552
        jnz     .exit
552
        jnz     .exit
553
 
553
 
554
        pushad
554
        pushad
555
 
555
 
556
        xchg    esi, eax
556
        xchg    esi, eax
557
 
557
 
558
        movzx   ecx, [esi + SYS_BUTTON.pslot]
558
        movzx   ecx, [esi + SYS_BUTTON.pslot]
559
        shl     ecx, 5
559
        shl     ecx, 5
560
        add     ecx, window_data
560
        add     ecx, window_data
561
 
561
 
562
        mov     eax, dword[esi + SYS_BUTTON.left]
562
        mov     eax, dword[esi + SYS_BUTTON.left]
563
        mov     ebx, dword[esi + SYS_BUTTON.top]
563
        mov     ebx, dword[esi + SYS_BUTTON.top]
564
        add     eax, [ecx + WDATA.box.left]
564
        add     eax, [ecx + WDATA.box.left]
565
        add     ebx, [ecx + WDATA.box.top]
565
        add     ebx, [ecx + WDATA.box.top]
566
        push    eax ebx
566
        push    eax ebx
567
        pop     edx ecx
567
        pop     edx ecx
568
        rol     eax, 16
568
        rol     eax, 16
569
        rol     ebx, 16
569
        rol     ebx, 16
570
        add     ax, cx
570
        add     ax, cx
571
        add     bx, dx
571
        add     bx, dx
572
 
572
 
573
        mov     esi, 0x01000000
573
        mov     esi, 0x01000000
574
        call    draw_rectangle.forced
574
        call    draw_rectangle.forced
575
 
575
 
576
        popad
576
        popad
577
 
577
 
578
  .exit:
578
  .exit:
579
        ret
579
        ret