Rev 1108 | Rev 1417 | 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 |
||
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 |
||
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 |
||
262 | je OpenDialog_start |
||
263 | cmp eax,dword 3 |
||
1101 | Lrz | 264 | je button.exit |
265 | jmp still |
||
266 | |||
267 | analyse_out_menu_2: |
||
268 | ; analyse result of Menu 2 |
||
269 | cmp [menu_data_2.cursor_out],dword 2 |
||
270 | je about |
||
271 | jmp still |
||
272 | ;--------------------------------------------------------------------- |
||
273 | about: |
||
274 | mcall 51,1,thread3,thread |
||
275 | jmp still |
||
276 | ;--------------------------------------------------------------------- |
||
1219 | mario79 | 277 | OpenDialog_start: |
278 | ; mov ebx,open_dialog_name |
||
279 | ; mov esi,path |
||
280 | ; mov edi,library_path |
||
281 | ; call copy_file_path |
||
282 | call get_filter_data |
||
283 | |||
284 | copy_path open_dialog_name,path,library_path,0 |
||
285 | |||
286 | |||
287 | start_OpenDialog OpenDialog_data |
||
288 | |||
289 | cmp [OpenDialog_data.status],2 ; OpenDialog does not start |
||
290 | je still ; some kind of alternative, instead OpenDialog |
||
291 | cmp [OpenDialog_data.status],1 |
||
292 | jne still ; OpenDialog user say cancel |
||
293 | ; copy path |
||
294 | call draw_window |
||
295 | jmp still ; OpenDialog user selected the target file |
||
296 | ; [OpenDialog_data.openfile_pach] pointer of area the target file |
||
297 | ;--------------------------------------------------------------------- |
||
298 | get_filter_data: |
||
299 | mov edi,[OpenDialog_data.com_area] |
||
300 | test edi,edi |
||
301 | jnz @f |
||
302 | add esp,4 |
||
303 | jmp still |
||
304 | @@: |
||
305 | add edi,4096+4 |
||
306 | mov esi,Filter |
||
307 | mov ecx,[esi] |
||
308 | inc ecx |
||
309 | cld |
||
310 | rep movsb |
||
311 | mov edi,[OpenDialog_data.com_area] |
||
312 | mov [edi+4096],dword 1 |
||
313 | ret |
||
314 | ;--------------------------------------------------------------------- |
||
1101 | Lrz | 315 | draw_window: |
316 | mcall 12, 1 |
||
317 | mcall 0, <0,400>, <0,400>, 0x03AABBCC, 0x805080D0, 0x005080D0 |
||
318 | mcall 71, 1, header_1 |
||
319 | ;--------------------------------------------- |
||
320 | ; draw for Menu 1 |
||
321 | push dword menu_data_1 |
||
322 | call [menu_bar_draw] |
||
323 | ; draw for Menu 2 |
||
324 | push dword menu_data_2 |
||
325 | call [menu_bar_draw] |
||
326 | ;--------------------------------------------- |
||
327 | ; draw for Dinamic Button 1 |
||
328 | push dword dinamic_button_data_1 |
||
329 | call [dinamic_button_draw] |
||
330 | ; draw for Dinamic Button 2 |
||
331 | push dword dinamic_button_data_2 |
||
332 | call [dinamic_button_draw] |
||
333 | ;--------------------------------------------- |
||
1219 | mario79 | 334 | mcall 13,<170,200>,<25,15>,0xffffb0 |
335 | mov bx,28 |
||
336 | add ebx,2 shl 16 |
||
337 | mcall 4,,0xC0000000,openfile_pach,,0xffffb0 |
||
338 | ;--------------------------------------------- |
||
1101 | Lrz | 339 | ; set all_redraw flag for draw all ScrollBar |
340 | ; In some cases it is necessity to draw only the area |
||
341 | ; of moving of a "runner", for acceleration of output - |
||
342 | ; in this case the flag needs to be reset to 0 (zero). |
||
343 | xor eax,eax |
||
344 | inc eax |
||
345 | mov [scroll_bar_data_vertical.all_redraw],eax |
||
346 | mov [scroll_bar_data_horizontal.all_redraw],eax |
||
347 | |||
348 | ; draw for Vertical ScrollBar |
||
349 | push dword scroll_bar_data_vertical |
||
350 | call [scrollbar_ver_draw] |
||
351 | ; draw for Horizontal ScrollBar |
||
352 | push dword scroll_bar_data_horizontal |
||
353 | call [scrollbar_hor_draw] |
||
354 | ; reset all_redraw flag |
||
355 | xor eax,eax |
||
356 | mov [scroll_bar_data_vertical.all_redraw],eax |
||
357 | mov [scroll_bar_data_horizontal.all_redraw],eax |
||
358 | ;--------------------------------------------- |
||
359 | call draw_cube |
||
360 | mcall 12, 2 |
||
361 | ret |
||
362 | ;--------------------------------------------------------------------- |
||
363 | draw_cube: |
||
364 | mcall 13,<30,301>,<50,301>,0xafafaf |
||
365 | mov ecx,[scroll_bar_data_vertical.position] |
||
366 | add ecx,50 |
||
367 | shl ecx,16 |
||
368 | mov cx,30 |
||
369 | mov ebx,[scroll_bar_data_horizontal.position] |
||
370 | add ebx,30 |
||
371 | shl ebx,16 |
||
372 | mov bx,30 |
||
373 | mcall 13, , , 0x0 |
||
374 | ret |
||
1219 | mario79 | 375 | ;--------------------------------------------------------------------- |
1101 | Lrz | 376 | include 'data.inc' |
377 | include 'w_about.inc' |
||
1219 | mario79 | 378 | ;--------------------------------------------------------------------- |
1101 | Lrz | 379 | IM_END: |
380 | rb 1024 |
||
381 | thread: |
||
1219 | mario79 | 382 | ;--------------------------------------------------------------------- |
1101 | Lrz | 383 | rb 1024 |
384 | stacktop: |
||
1219 | mario79 | 385 | ;--------------------------------------------------------------------- |
1101 | Lrz | 386 | path: |
1219 | mario79 | 387 | rb 4096 |
388 | ;--------------------------------------------------------------------- |
||
389 | openfile_pach: |
||
390 | rb 4096 |
||
391 | ;--------------------------------------------------------------------- |
||
1101 | Lrz | 392 | file_name: |
1219 | mario79 | 393 | library_path: |
1101 | Lrz | 394 | rb 4096 |
1219 | mario79 | 395 | ;--------------------------------------------------------------------- |
396 | plugin_pach: |
||
397 | rb 4096 |
||
398 | ;--------------------------------------------------------------------- |
||
1101 | Lrz | 399 | file_info: |
400 | rb 40 |
||
1219 | mario79 | 401 | ;--------------------------------------------------------------------- |
402 | procinfo: |
||
403 | rb 1024 |
||
404 | ;--------------------------------------------------------------------- |
||
1101 | Lrz | 405 | I_END:50,301>30,301>25,15>170,200>0,400>0,400> |
406 |