Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1334 mikedld 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
1391 mikedld 3
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
1334 mikedld 4
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa      ;;
5
;; Distributed under terms of the GNU General Public License    ;;
6
;;                                                              ;;
7
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
 
9
$Revision: 2453 $
10
 
11
;==============================================================================
12
;///// public functions ///////////////////////////////////////////////////////
13
;==============================================================================
14
 
1391 mikedld 15
button.MAX_BUTTONS = 4095
16
 
2384 hidnplayr 17
struct  SYS_BUTTON
18
        pslot           dw ?
19
        id_lo           dw ?
20
        left            dw ?
21
        width           dw ?
22
        top             dw ?
23
        height          dw ?
24
        id_hi           dw ?
25
                        dw ?
26
ends
1334 mikedld 27
 
28
align 4
29
;------------------------------------------------------------------------------
30
syscall_button: ;///// system function 8 //////////////////////////////////////
31
;------------------------------------------------------------------------------
1362 mikedld 32
;? Define/undefine GUI button object
1334 mikedld 33
;------------------------------------------------------------------------------
1362 mikedld 34
;; Define button:
35
;> ebx = pack[16(x), 16(width)]
36
;> ecx = pack[16(y), 16(height)]
37
;> edx = pack[8(flags), 24(button identifier)]
38
;>       flags bits:
39
;>          7 (31) = 0
40
;>          6 (30) = don't draw button
41
;>          5 (29) = don't draw button frame when pressed
42
;> esi = button color
1334 mikedld 43
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1362 mikedld 44
;; Undefine button:
45
;> edx = pack[8(flags), 24(button identifier)]
46
;>       flags bits:
47
;>          7 (31) = 1
1334 mikedld 48
;------------------------------------------------------------------------------
49
        ; do we actually need to undefine the button?
50
        test    edx, 0x80000000
51
        jnz     .remove_button
52
 
53
        ; do we have free button slots available?
54
        mov     edi, [BTN_ADDR]
55
        mov     eax, [edi]
1391 mikedld 56
        cmp     eax, button.MAX_BUTTONS
1334 mikedld 57
        jge     .exit
58
 
59
        ; does it have positive size? (otherwise it doesn't have sense)
60
        or      bx, bx
61
        jle     .exit
62
        or      cx, cx
63
        jle     .exit
64
 
65
        ; make coordinates clientbox-relative
66
        push    eax
67
        mov     eax, [current_slot]
68
        rol     ebx, 16
69
        add     bx, word[eax + APPDATA.wnd_clientbox.left]
70
        rol     ebx, 16
71
        rol     ecx, 16
72
        add     cx, word[eax + APPDATA.wnd_clientbox.top]
73
        rol     ecx, 16
74
        pop     eax
75
 
76
        ; basic checks passed, define the button
77
        push    ebx ecx edx
78
        inc     eax
79
        mov     [edi], ax
80
        shl     eax, 4
81
        add     edi, eax
82
        ; NOTE: this code doesn't rely on SYS_BUTTON struct, please revise it
83
        ;       if you change something
84
        mov     ax, [CURRENT_TASK]
85
        stosw
86
        mov     ax, dx
87
        stosw               ; button id number: bits 0-15
88
        mov     eax, ebx
89
        rol     eax, 16
90
        stosd               ; x start | x size
91
        mov     eax, ecx
92
        rol     eax, 16
93
        stosd               ; y start | y size
94
        mov     eax, edx
95
        shr     eax, 16
96
        stosw               ; button id number: bits 16-31
97
        pop     edx ecx ebx
98
 
99
        ; do we also need to draw the button?
100
        test    edx, 0x40000000
101
        jnz     .exit
102
 
103
        ; draw button body
104
 
105
        pushad
106
 
107
        ; calculate window-relative coordinates
108
        movzx   edi, cx
109
        shr     ebx, 16
110
        shr     ecx, 16
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
119
        shl     ebx, 16
120
        mov     bx, cx
121
 
122
        ; calculate initial color
123
        mov     ecx, esi
124
        cmp     [buttontype], 0
125
        je      @f
126
        call    button._.incecx2
127
 
128
        ; set button height counter
2288 clevermous 129
    @@:
130
        mov     edx, edi
1334 mikedld 131
 
132
  .next_line:
133
        call    button._.button_dececx
134
        push    edi
135
        xor     edi, edi
2453 mario79 136
;        call    [draw_line]
137
        call    __sys_draw_line
1334 mikedld 138
        pop     edi
139
        add     ebx, 0x00010001
140
        dec     edx
141
        jnz     .next_line
142
 
143
        popad
144
 
145
        ; draw button frame
146
 
147
        push    ebx ecx
148
 
149
        ; calculate window-relative coordinates
150
        shr     ebx, 16
151
        shr     ecx, 16
152
        mov     eax, [TASK_BASE]
153
        add     ebx, [eax - twdw + WDATA.box.left]
154
        add     ecx, [eax - twdw + WDATA.box.top]
155
 
156
        ; top border
157
        mov     eax, ebx
158
        shl     eax, 16
159
        mov     ax, bx
160
        add     ax, [esp + 4]
161
        mov     ebx, ecx
162
        shl     ebx, 16
163
        mov     bx, cx
164
        push    ebx
165
        xor     edi, edi
166
        mov     ecx, esi
167
        call    button._.incecx
2453 mario79 168
;        call    [draw_line]
169
        call    __sys_draw_line
1334 mikedld 170
 
171
        ; bottom border
172
        movzx   edx, word[esp + 4 + 0]
173
        add     ebx, edx
174
        shl     edx, 16
175
        add     ebx, edx
176
        mov     ecx, esi
177
        call    button._.dececx
2453 mario79 178
;        call    [draw_line]
179
        call    __sys_draw_line
1334 mikedld 180
 
181
        ; left border
182
        pop     ebx
183
        push    edx
184
        mov     edx, eax
185
        shr     edx, 16
186
        mov     ax, dx
187
        mov     edx, ebx
188
        shr     edx, 16
189
        mov     bx, dx
190
        add     bx, [esp + 4 + 0]
191
        pop     edx
192
        mov     ecx, esi
193
        call    button._.incecx
2453 mario79 194
;        call    [draw_line]
195
        call    __sys_draw_line
1334 mikedld 196
 
197
        ; right border
198
        mov     dx, [esp + 4]
199
        add     ax, dx
200
        shl     edx, 16
201
        add     eax, edx
202
        add     ebx, 0x00010000
203
        mov     ecx, esi
204
        call    button._.dececx
2453 mario79 205
;        call    [draw_line]
206
        call    __sys_draw_line
1334 mikedld 207
 
208
        pop     ecx ebx
209
 
210
  .exit:
211
        ret
212
 
213
; FIXME: mutex needed
214
syscall_button.remove_button:
215
        and     edx, 0x00ffffff
216
        mov     edi, [BTN_ADDR]
217
        mov     ebx, [edi]
218
        inc     ebx
2384 hidnplayr 219
        imul    esi, ebx, sizeof.SYS_BUTTON
1334 mikedld 220
        add     esi, edi
221
        xor     ecx, ecx
2384 hidnplayr 222
        add     ecx, -sizeof.SYS_BUTTON
223
        add     esi, sizeof.SYS_BUTTON
1334 mikedld 224
 
225
  .next_button:
226
        dec     ebx
227
        jz      .exit
228
 
2384 hidnplayr 229
        add     ecx, sizeof.SYS_BUTTON
230
        add     esi, -sizeof.SYS_BUTTON
1334 mikedld 231
 
232
        ; does it belong to our process?
233
        mov     ax, [CURRENT_TASK]
234
        cmp     ax, [esi + SYS_BUTTON.pslot]
235
        jne     .next_button
236
 
237
        ; does the identifier match?
238
        mov     eax, dword[esi + SYS_BUTTON.id_hi - 2]
239
        mov     ax, [esi + SYS_BUTTON.id_lo]
240
        and     eax, 0x00ffffff
241
        cmp     edx, eax
242
        jne     .next_button
243
 
244
        ; okay, undefine it