Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
648 andrew_pro 1
;
2
;
3
; This is example using GUI component Text from libGUI.
4
;
5
;
6
 
7
include 'macros.inc'
8
use32
9
        db      'MENUET01'
10
        dd      1
11
        dd      start
12
        dd      i_end
13
        dd      1600
14
        dd      1600
15
        dd      0
16
        dd      path
17
 
18
start:
19
        ;init hepe of memory
20
        mcall   68,11
21
 
22
        ;set current dir as ./
23
        call GetPath
24
 
25
        ;load dll
26
        mcall   68,19,path
27
 
28
        test    eax,eax
29
        jnz    libGUI_loaded
30
 
31
        mcall 68,19,sys_libGUI_path
32
 
33
           test eax,eax
34
           jnz libGUI_loaded
35
 
36
             mcall -1
37
 
38
        libGUI_loaded:
39
 
40
        mov [myexport],eax
41
 
42
        ;load dll functions
43
 
44
        push fnDestroyControl
45
        push [myexport]
46
        call _ksys_cofflib_getproc
47
        mov [destroy_control],eax
48
 
49
        push fnSendMessage
50
        push [myexport]
51
        call _ksys_cofflib_getproc
52
        mov [send_message],eax
53
 
54
        push fnCraeteButton
55
        push [myexport]
56
        call _ksys_cofflib_getproc
57
        mov [craete_button],eax
58
 
59
        push fnCraeteText
60
        push [myexport]
61
        call _ksys_cofflib_getproc
62
        mov [craete_text],eax
63
 
64
        ;set events mask
65
        mcall   40,1100111b
66
 
67
        ;get standart colors table
68
        mcall   48,3,ColorsTable,40
69
 
70
        ;*********************************************
71
        ;****************Init Butttons****************
72
        ;*********************************************
73
 
74
        mov ecx,[ColorsTable+8]
75
        and ecx,0xffffff
76
 
77
        mov [Button1.type],byte 10010001b
78
        mov [Button1.x],80
79
        mov [Button1.y],50
80
        mov [Button1.width],word 70
81
        mov [Button1.height],word 20
82
        mov [Button1.color1],dword ecx
83
        mov [Button1.color2],dword 0xffffff
84
        mov [Button1.text],text1
85
 
86
        push Button1
87
        push Parend
88
        call [craete_button]
89
        mov [PointerToControlForButtonExit],eax
90
 
91
        mov ecx,[ColorsTable+8]
92
        and ecx,0xffffff
93
 
94
 
95
        ;********************************************
96
        ;******************Init Text*****************
97
        ;********************************************
98
 
676 andrew_pro 99
        mov [Text.type],byte 10000010b
648 andrew_pro 100
        mov [Text.color],0xffffff
676 andrew_pro 101
        mov [Text.background_color],0xff
648 andrew_pro 102
        mov [Text.x],5
103
        mov [Text.y],10
104
        mov [Text.length],36
105
        mov [Text.pointer],text_for_text
106
 
107
 
108
        push Text
109
        push Parend
110
        call [craete_text]
111
        mov [PointerToControlForText],eax
112
 
113
        call draw_window
114
 
115
 
116
        ;send message 1 for redrawing ALL controls
117
        mov [Message],dword 1
118
 
119
        push Message
120
        push Parend
121
        call [send_message]
122
 
123
still:
124
        mcall   10
125
 
126
        ;check for redraw window
127
        cmp eax,1
128
        jne no_window
129
 
130
          call draw_window
131
 
132
          mov [Message],dword 1
133
          push Message
134
          push Parend
135
          call [send_message]
136
 
137
        jmp still
138
        no_window:
139
 
140
        ;check for keys events
141
        cmp eax,2
142
        jne no_keys
143
 
144
          mcall   2
145
          shr eax,8
146
 
147
          mov [Message],dword 2
148
          mov [Message+4],eax
149
 
150
          push Message
151
          push Parend
152
          call [send_message]
153
 
154
          mov eax,[Message+4]
155
 
156
          cmp al,27
157
          je exit
158
 
159
        jmp still
160
        no_keys:
161
 
162
        ;check for pressed butons
163
        cmp eax,3
164
        jne no_buttons
165
 
166
          mcall   17
167
          shr eax,8
168
 
169
        jmp still
170
        no_buttons:
171
 
172
        ;check for mouse events
173
        cmp eax,6
174
        jne no_mouse
175
 
176
         mov [Message],dword 6
177
 
178
         mcall   37,1
179
         mov ebx,eax
180
         shr eax,16 ;x
181
         and ebx,0xffff ;y
182
 
183
         mov [Message+4],eax
184
         mov [Message+8],ebx
185
 
186
         mcall   37,2
187
         mov [Message+12],eax
188
 
189
         ;send system events to control
190
         push Message
191
         push Parend
192
         call [send_message]
193
 
194
         mov eax,[PointerToControlForButtonExit]
195
 
196
         xor ebx,ebx
197
         mov bl,byte[eax+45]
198
         cmp bl,11b
199
         jne no_crossing_pressing_button
200
 
201
           mov [button_pressed],1
202
 
203
         no_crossing_pressing_button:
204
 
205
         xor ebx,ebx
206
         mov bl,byte[eax+45]
207
         cmp bl,1b
208
         jne no_crossing_button
209
 
210
           cmp [button_pressed],1
211
           jne no_crossing_button
212
 
213
              jmp exit
214
 
215
         no_crossing_button:
216
 
217
         jmp still
218
         no_mouse:
219
 
220
        jmp still
221
 
222
exit:
223
 
224
        push [PointerToControlForButtonExit]
225
        call [destroy_control]
226
 
227
        push [PointerToControlForText]
228
        call [destroy_control]
229
 
230
        mcall   -1
231
 
232
 
233
;**********************************************
234
;*******************Draw window****************
235
;**********************************************
236
 
237
draw_window:
238
 
239
        mcall   12,1
240
 
241
        xor eax,eax
242
        mov ebx,50
243
        mov ecx,50
244
        shl ebx,16
245
        shl ecx,16
246
        add ebx,250
247
        add ecx,100
248
        mov edx,0x03aabbcc
249
        mov esi,0x805080d0
250
        mov edi,0x005080d0
251
        mcall
252
 
253
        ;call print_controls_information
254
 
255
        mcall   12,2
256
        ret
257
 
258
 
259
GetPath:
260
 
261
        mov ebx,255
262
        mov ecx,path
263
 
264
        next_symvol:
265
        mov edx,ecx
266
        add edx,ebx
267
 
268
        xor eax,eax
269
        mov al,[edx]
270
        cmp eax,'/'
271
        je exit_path
272
 
273
        dec ebx
274
        jnz next_symvol
275
 
276
        exit_path:
277
 
278
        inc edx
279
        mov esi,dll_name
280
        mov edi,edx
281
        mov ecx,10
282
        rep movsb
283
 
284
        ret
285
 
286
include 'getproc.asm'
287
 
288
;************************************************************
289
;***************************DATA*****************************
290
;************************************************************
291
 
292
align 4
293
 
294
dll_name        db 'libGUI.obj',0
295
sys_libGUI_path db '/sys/lib/libGUI.obj',0
296
 
297
text1    db 'Exit',0
298
 
299
text_for_text db 'Example of using GUI component text.',0
300
 
301
fnDestroyControl                     db 'DestroyControl',0
302
fnSendMessage                        db 'SendMessage',0
303
fnCraeteButton                       db 'CraeteButton',0
304
fnCraeteText                         db 'CraeteText',0
305
 
306
myexport                             dd 0
307
 
308
destroy_control                      dd 0
309
send_message                         dd 0
310
craete_button                         dd 0
311
craete_text                           dd 0
312
 
313
PointerToControlForButtonExit        dd 0
314
 
315
PointerToControlForText              dd 0
316
 
317
button_pressed                       dd 0
318
 
319
 
320
path                                 rb 256
321
 
322
Parend:        dd 0,0,0,0,0,0,0,0,0,0,0,0   ;44 bytes
323
Message                               rd 4
324
 
325
ColorsTable  rd 10
326
 
327
struc BUTTON
328
{
329
 .type             db 1
330
 .flag             db 1
331
 .x                dw 1
332
 .y                dw 1
333
 .width            dw 1
334
 .height           dw 1
335
 .image            dd 1
336
 .imageX           dw 1
337
 .imageY           dw 1
338
 .imageSizeX       dw 1
339
 .imageSizeY       dw 1
340
 .transparentColor dd 1
341
 .text             dd 1
342
 .textX            dw 1
343
 .textY            dw 1
344
 .textcolor        dd 1
345
 .color1           dd 1
346
 .color2           dd 1
347
 .mouseX           dw 1
348
 .mouseY           dw 1
349
}
350
 
351
struc TEXT
352
{
353
 .type             rb 1
354
 .flag             rb 1
355
 .color            rd 1
356
 .x                rd 1
357
 .y                rd 1
358
 .length           rd 1
359
 .pointer          rd 1
676 andrew_pro 360
 .background_color rd 1
648 andrew_pro 361
}
362
 
363
Button1             BUTTON
364
Text                TEXT
365
 
366
i_end: