Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1219 mario79 1
;*****************************************************************************
1101 Lrz 2
; Example for Box_lib: scrollbar, menubar, dinamic_button
1219 mario79 3
; Copyright (c) 2009, Marat Zakiyanov aka Mario79, aka Mario
1101 Lrz 4
; All rights reserved.
5
;
6
; Redistribution and use in source and binary forms, with or without
7
; modification, are permitted provided that the following conditions are met:
1219 mario79 8
;	 * Redistributions of source code must retain the above copyright
9
;	   notice, this list of conditions and the following disclaimer.
10
;	 * Redistributions in binary form must reproduce the above copyright
11
;	   notice, this list of conditions and the following disclaimer in the
12
;	   documentation and/or other materials provided with the distribution.
13
;	 * Neither the name of the  nor the
14
;	   names of its contributors may be used to endorse or promote products
15
;	   derived from this software without specific prior written permission.
1101 Lrz 16
;
1219 mario79 17
; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
1101 Lrz 18
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
; DISCLAIMED. IN NO EVENT SHALL  BE LIABLE FOR ANY
21
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1219 mario79 27
;******************************************************************************
1101 Lrz 28
; import_boxlib procedure written by 
29
;---------------------------------------------------------------------
30
 
31
        use32
32
        org     0x0
33
 
34
        db      'MENUET01'
35
        dd      0x01
36
        dd      START
37
        dd      IM_END
38
        dd      I_END
39
        dd      stacktop
40
        dd      0x0
41
        dd      path
42
 
43
include '../../../../../macros.inc'
1108 Lrz 44
include '../../load_lib.mac'
1219 mario79 45
;include 'macros.inc'
46
;include 'load_lib.mac'
47
	@use_library
48
include 'opendial.mac'
49
	use_OpenDialog
1101 Lrz 50
;---------------------------------------------------------------------
51
;---    Start of program        ----------------------------------------------
52
;---------------------------------------------------------------------
53
START:
54
        mcall 68, 11
55
        mcall 66, 1, 1
56
        mcall 40, 0x27
57
;---------------------------------------------------------------------
1219 mario79 58
 
1101 Lrz 59
load_libraries l_libs_start,end_l_libs
60
 
1219 mario79 61
	test  eax,eax
62
	jnz    button.exit
1101 Lrz 63
 
1219 mario79 64
; unpack deflate
65
	mov   eax,[unpack_DeflateUnpack2]
66
	mov  [deflate_unpack],eax
1101 Lrz 67
 
1219 mario79 68
;OpenDialog initialisation
69
init_OpenDialog	OpenDialog_data
1101 Lrz 70
 
71
 
72
;        mov     ebx,icons_file_name
73
;        mov     esi,path
74
;        mov     edi,file_name
1219 mario79 75
 
76
        copy_path    icons_file_name,path,library_path,0
1101 Lrz 77
 
78
        mcall 70, fileinfo
79
 
80
        mov     [fileinfo+0],dword 0
81
 
82
        mov     ecx,[file_info+32]
83
        mov     [fileinfo+12],ecx
84
        mov [img_size],ecx
85
 
86
 
87
        mcall 68, 12
88
 
89
 
90
        mov     [fileinfo+16],eax
91
        mov     [image_file],eax
92
 
93
 
94
        mcall 70, fileinfo
95
 
96
        xor     eax,eax
97
        mov     [return_code],eax
98
        mov     eax,image_file
1219 mario79 99
	call	[cnv_png_import.Start]
1101 Lrz 100
 
101
        mov     ecx,[image_file]
102
        mcall 68, 13,
103
 
104
        cmp     [return_code],dword 0
105
        jne     button.exit
106
 
107
        mov     ebx,[raw_pointer]
108
        mov     eax,[ebx+4]
109
        ; set of button size
110
        mov     [dinamic_button_data_1.size_x],ax
111
        mov     [dinamic_button_data_1.size_y],ax
112
        mov     [dinamic_button_data_2.size_x],ax
113
        mov     [dinamic_button_data_2.size_y],ax
114
        mov     eax,[ebx+12]
115
        ; set of RAW resolution to pixel
116
        mov     [dinamic_button_data_1.resolution_raw],eax
117
        mov     [dinamic_button_data_2.resolution_raw],eax
118
        mov     eax,[ebx+20]
119
        add     eax,ebx
120
        ; set RAW palette, use else resolution 8bit or less
121
        mov     [dinamic_button_data_1.palette_raw],eax
122
        mov     [dinamic_button_data_2.palette_raw],eax
123
        mov     eax,[ebx+28]
124
        add     eax,ebx
125
        ; set RAW area for passive button
126
        mov     [dinamic_button_data_1.passive_raw],eax
127
        mov     [dinamic_button_data_2.passive_raw],eax
128
        mov     ecx,[ebx+4]
129
        imul ecx,[ebx+4]
130
        imul ecx,[ebx+12]
131
        shr     ecx,3
132
        add     eax,ecx
133
        ; set  RAW area for active button
134
        mov     [dinamic_button_data_1.active_raw],eax
135
        mov     [dinamic_button_data_2.active_raw],eax
136
        add     eax,ecx
137
        ; RAW area for click button
138
        mov     [dinamic_button_data_1.click_raw],eax
139
        mov     [dinamic_button_data_2.click_raw],eax
140
;---------------------------------------------------------------------
141
red:
142
        call draw_window
143
still:
144
        mcall 10
145
 
146
        cmp     eax,1
147
        je      red
148
        cmp     eax,2
149
        je      key
150
        cmp     eax,3
151
        je      button
152
        cmp     eax,6
153
        je      mouse
154
        jmp     still
155
 
156
 
157
;---------------------------------------------------------------------
158
        key:
159
        mcall 2
160
        jmp     still
161
;---------------------------------------------------------------------
162
        button:
163
        mcall 17
164
        cmp     ah, 1
165
        jne     still
166
        .exit:
167
        mcall -1
168
;---------------------------------------------------------------------
169
mouse:
170
;-----------------------------------------------
171
        cmp     [scroll_bar_data_horizontal.delta2],0
172
        jne     .horizontal
173
.vertical:
174
    mov   eax,[scroll_bar_data_vertical.max_area]
175
    cmp   eax,[scroll_bar_data_vertical.cur_area]
176
    jbe   .horizontal
177
; mouse event for Vertical ScrollBar
178
        push dword scroll_bar_data_vertical
179
        call [scrollbar_ver_mouse]
180
        mov  eax,scroll_bar_data_vertical.redraw
181
        xor  ebx,ebx
182
        cmp     [eax],ebx
183
        je      @f
184
        mov     [eax],ebx
185
        jmp     .draw_cube
186
@@:
187
        cmp     [scroll_bar_data_vertical.delta2],0
188
        jne     still
189
.horizontal:
190
    mov   eax,[scroll_bar_data_horizontal.max_area]
191
    cmp   eax,[scroll_bar_data_horizontal.cur_area]
192
    jbe   .other
193
; mouse event for Horizontal ScrollBar
194
        push dword scroll_bar_data_horizontal
195
        call [scrollbar_hor_mouse]
196
        mov  eax,scroll_bar_data_horizontal.redraw
197
        xor  ebx,ebx
198
        cmp     [eax],ebx
199
        je      .other
200
        mov     [eax],ebx
201
.draw_cube:
202
        call draw_cube
203
        jmp     still
204
.other:
205
        cmp  [scroll_bar_data_vertical.delta2],0
206
        jne   still
207
        cmp  [scroll_bar_data_horizontal.delta2],0
208
        jne   still
209
;-----------------------------------------------
210
.menu_bar_1:
211
        call   .set_mouse_flag
212
@@:
213
; mouse event for Menu 1
214
        push    dword menu_data_1
215
        call    [menu_bar_mouse]
216
    cmp   [menu_data_1.click],dword 1
217
        jne   .menu_bar_2
218
        cmp   [menu_data_1.cursor_out],dword 0
219
        jne    analyse_out_menu_1
220
        jmp    .menu_bar_1
221
;--------------------------------------------
222
.menu_bar_2:
223
; mouse event for Menu 2
224
        push    dword menu_data_2
225
        call    [menu_bar_mouse]
226
    cmp   [menu_data_2.click],dword 1
227
        jne   .mouse_dinamic_button
228
        cmp   [menu_data_2.cursor_out],dword 0
229
        jne    analyse_out_menu_2
230
    jmp    .menu_bar_1
231
;--------------------------------------------
232
.mouse_dinamic_button:
233
; mouse event for Dinamic Button 1
234
        push    dword dinamic_button_data_1
235
        call    [dinamic_button_mouse]
236
        mov   eax,dinamic_button_data_1.click
237
    cmp   [eax],dword 1
238
        jne   @f
239
    mov   [eax],dword 0
240
        jmp   about
241
@@:
242
; mouse event for Dinamic Button 2
243
        push    dword dinamic_button_data_2
244
        call    [dinamic_button_mouse]
245
        mov   eax,dinamic_button_data_2.click
246
    cmp   [eax],dword 1
247
        jne   still  ;@f
248
    mov   [eax],dword 0
249
        jmp   button.exit
250
;---------------------------------------------------------------------
251
.set_mouse_flag:
252
        xor   eax,eax
253
        inc   eax
254
        mov   [menu_data_1.get_mouse_flag],eax
255
        mov   [menu_data_2.get_mouse_flag],eax
256
        ret
257
;---------------------------------------------------------------------
258
analyse_out_menu_1:
259
; analyse result of Menu 1
1219 mario79 260
	mov	eax,[menu_data_1.cursor_out]
261
	cmp	eax,dword 1
1417 mario79 262
	je	OpenDialog_start_0
263
	cmp	eax,dword 2
264
	je	OpenDialog_start_1
265
	cmp	eax,dword 3
266
	je	OpenDialog_start_2
267
    cmp	eax,dword 4
268
    je      button.exit
269
    jmp     still
1101 Lrz 270
 
271
analyse_out_menu_2:
272
; analyse result of Menu 2
273
        cmp [menu_data_2.cursor_out],dword 2
274
        je      about
275
        jmp     still
276
;---------------------------------------------------------------------
277
        about:
278
        mcall 51,1,thread3,thread
279
        jmp     still
280
;---------------------------------------------------------------------
1417 mario79 281
OpenDialog_start_0:
282
	mov	[OpenDialog_data.type],0
283
	jmp	OpenDialog_start
284
OpenDialog_start_1:
285
	mov	[OpenDialog_data.type],1
286
	jmp	OpenDialog_start
287
OpenDialog_start_2:
288
	mov	[OpenDialog_data.type],2
1219 mario79 289
OpenDialog_start:
290
;	mov	ebx,open_dialog_name
291
;	mov	esi,path
292
;	mov	edi,library_path
293
;	call	copy_file_path
294
	call	get_filter_data
295
 
296
	copy_path	open_dialog_name,path,library_path,0
297
 
298
 
299
start_OpenDialog	OpenDialog_data
300
 
301
	cmp	[OpenDialog_data.status],2 ; OpenDialog does not start
302
	je	still  ; 	some kind of alternative, instead OpenDialog
303
	cmp	[OpenDialog_data.status],1
304
	jne	still ; OpenDialog user say cancel
305
;	copy path
1433 mario79 306
;	prepare path - PathShow
307
	push    dword PathShow_data_1
308
	call    [PathShow_prepare]
309
 
1219 mario79 310
	call	draw_window
311
	jmp	still ; OpenDialog user selected the target file
312
	; [OpenDialog_data.openfile_pach] pointer of area the target file
313
;---------------------------------------------------------------------
314
get_filter_data:
315
	mov	edi,[OpenDialog_data.com_area]
316
	test	edi,edi
317
	jnz	@f
318
	add	esp,4
319
	jmp	still
320
@@:
321
	add	edi,4096+4
322
	mov	esi,Filter
323
	mov	ecx,[esi]
324
	inc	ecx
325
	cld
326
	rep	movsb
327
	mov	edi,[OpenDialog_data.com_area]
328
	mov	[edi+4096],dword 1
329
	ret
330
;---------------------------------------------------------------------
1101 Lrz 331
draw_window:
332
        mcall 12, 1
333
        mcall 0, <0,400>, <0,400>, 0x03AABBCC, 0x805080D0, 0x005080D0
334
        mcall 71, 1, header_1
335
;---------------------------------------------
336
; draw for Menu 1
337
        push    dword menu_data_1
338
        call    [menu_bar_draw]
339
; draw for Menu 2
340
        push    dword menu_data_2
341
        call    [menu_bar_draw]
342
;---------------------------------------------
343
; draw for Dinamic Button 1
344
        push    dword dinamic_button_data_1
345
        call    [dinamic_button_draw]
346
; draw for Dinamic Button 2
347
        push    dword dinamic_button_data_2
348
        call    [dinamic_button_draw]
349
;---------------------------------------------
1219 mario79 350
	mcall	13,<170,200>,<25,15>,0xffffb0
1433 mario79 351
;	mov	bx,28
352
;	add	ebx,2 shl 16
353
;	mcall	4,,0xC0000000,text_work_area,,0xffffb0
354
; draw for PathShow
355
        push    dword PathShow_data_1
356
        call    [PathShow_draw]
1219 mario79 357
;---------------------------------------------
1101 Lrz 358
; set all_redraw flag for draw all ScrollBar
359
; In some cases it is necessity to draw only the area
360
; of moving of a "runner", for acceleration of output -
361
; in this case the flag needs to be reset to 0 (zero).
362
        xor     eax,eax
363
        inc     eax
364
        mov     [scroll_bar_data_vertical.all_redraw],eax
365
        mov     [scroll_bar_data_horizontal.all_redraw],eax
366
 
367
; draw for Vertical ScrollBar
368
        push     dword scroll_bar_data_vertical
369
        call     [scrollbar_ver_draw]
370
; draw for Horizontal ScrollBar
371
        push     dword scroll_bar_data_horizontal
372
        call     [scrollbar_hor_draw]
373
; reset all_redraw flag
374
        xor     eax,eax
375
        mov     [scroll_bar_data_vertical.all_redraw],eax
376
        mov     [scroll_bar_data_horizontal.all_redraw],eax
377
;---------------------------------------------
378
        call draw_cube
379
        mcall 12, 2
380
        ret
381
;---------------------------------------------------------------------
382
draw_cube:
383
        mcall 13,<30,301>,<50,301>,0xafafaf
384
        mov     ecx,[scroll_bar_data_vertical.position]
385
        add     ecx,50
386
        shl     ecx,16
387
        mov     cx,30
388
        mov     ebx,[scroll_bar_data_horizontal.position]
389
        add     ebx,30
390
        shl     ebx,16
391
        mov     bx,30
392
        mcall 13, , , 0x0
393
        ret
1219 mario79 394
;---------------------------------------------------------------------
1101 Lrz 395
include 'data.inc'
396
include 'w_about.inc'
1219 mario79 397
;---------------------------------------------------------------------
1101 Lrz 398
IM_END:
399
        rb 1024
400
thread:
1219 mario79 401
;---------------------------------------------------------------------
1101 Lrz 402
        rb 1024
403
stacktop:
1219 mario79 404
;---------------------------------------------------------------------
1101 Lrz 405
path:
1219 mario79 406
        rb 4096
407
;---------------------------------------------------------------------
408
openfile_pach:
409
        rb 4096
410
;---------------------------------------------------------------------
1101 Lrz 411
file_name:
1219 mario79 412
library_path:
1101 Lrz 413
        rb 4096
1219 mario79 414
;---------------------------------------------------------------------
415
plugin_pach:
416
        rb 4096
417
;---------------------------------------------------------------------
1433 mario79 418
text_work_area:
419
        rb 4096
420
;---------------------------------------------------------------------
1101 Lrz 421
file_info:
422
        rb 40
1219 mario79 423
;---------------------------------------------------------------------
424
procinfo:
425
        rb 1024
426
;---------------------------------------------------------------------
1101 Lrz 427
I_END:
428