Subversion Repositories Kolibri OS

Rev

Rev 1433 | Rev 1585 | 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
 
1435 mario79 31
	use32
32
	org 0x0
1101 Lrz 33
 
1435 mario79 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
1101 Lrz 42
 
43
include '../../../../../macros.inc'
1108 Lrz 44
include '../../load_lib.mac'
1219 mario79 45
;include 'macros.inc'
46
;include 'load_lib.mac'
1435 mario79 47
@use_library
1219 mario79 48
include 'opendial.mac'
1435 mario79 49
use_OpenDialog
1101 Lrz 50
;---------------------------------------------------------------------
1435 mario79 51
;--- Start of program ----------------------------------------------
1101 Lrz 52
;---------------------------------------------------------------------
53
START:
1435 mario79 54
	mcall	68,11
55
	mcall	66,1,1
56
	mcall	40,0x27
57
;---------------------------------------------------------------------
1219 mario79 58
 
1435 mario79 59
load_libraries	l_libs_start,end_l_libs
1101 Lrz 60
 
1435 mario79 61
	test	eax,eax
62
	jnz	button.exit
1101 Lrz 63
 
1219 mario79 64
; unpack deflate
1435 mario79 65
	mov	eax,[unpack_DeflateUnpack2]
66
	mov	[deflate_unpack],eax
1101 Lrz 67
 
1435 mario79 68
; OpenDialog initialisation
1219 mario79 69
init_OpenDialog	OpenDialog_data
1101 Lrz 70
 
1435 mario79 71
	mov	edi,filename_area
72
	mov	esi,start_temp_file_name
73
	xor	eax,eax
74
	cld
75
@@:
76
	lodsb
77
	stosb
78
	test	eax,eax
79
	jnz	@b
80
 
81
 
82
;	mov	ebx,icons_file_name
83
;	mov	esi,path
84
;	mov	edi,file_name
1101 Lrz 85
 
1435 mario79 86
	copy_path	icons_file_name,path,library_path,0
87
 
88
	mcall	70,fileinfo
1219 mario79 89
 
1435 mario79 90
	mov	[fileinfo+0],dword 0
1101 Lrz 91
 
1435 mario79 92
	mov	ecx,[file_info+32]
93
	mov	[fileinfo+12],ecx
94
	mov	[img_size],ecx
95
 
1101 Lrz 96
 
1435 mario79 97
	mcall	68,12
1101 Lrz 98
 
99
 
1435 mario79 100
	mov	[fileinfo+16],eax
101
	mov	[image_file],eax
1101 Lrz 102
 
103
 
1435 mario79 104
	mcall	70,fileinfo
105
 
106
	xor	eax,eax
107
	mov	[return_code],eax
108
	mov	eax,image_file
1219 mario79 109
	call	[cnv_png_import.Start]
1435 mario79 110
 
111
	mov	ecx,[image_file]
112
	mcall	68,13,
113
 
114
	cmp	[return_code],dword 0
115
	jne	button.exit
116
 
117
	mov	ebx,[raw_pointer]
118
	mov	eax,[ebx+4]
119
; set of button size
120
	mov	[dinamic_button_data_1.size_x],ax
121
	mov	[dinamic_button_data_1.size_y],ax
122
	mov	[dinamic_button_data_2.size_x],ax
123
	mov	[dinamic_button_data_2.size_y],ax
124
	mov	eax,[ebx+12]
125
; set of RAW resolution to pixel
126
	mov	[dinamic_button_data_1.resolution_raw],eax
127
	mov	[dinamic_button_data_2.resolution_raw],eax
128
	mov	eax,[ebx+20]
129
	add	eax,ebx
130
; set RAW palette, use else resolution 8bit or less
131
	mov	[dinamic_button_data_1.palette_raw],eax
132
	mov	[dinamic_button_data_2.palette_raw],eax
133
	mov	eax,[ebx+28]
134
	add	eax,ebx
135
; set RAW area for passive button
136
	mov	[dinamic_button_data_1.passive_raw],eax
137
	mov	[dinamic_button_data_2.passive_raw],eax
138
	mov	ecx,[ebx+4]
139
	imul	ecx,[ebx+4]
140
	imul	ecx,[ebx+12]
141
	shr	ecx,3
142
	add	eax,ecx
143
; set RAW area for active button
144
	mov	[dinamic_button_data_1.active_raw],eax
145
	mov	[dinamic_button_data_2.active_raw],eax
146
	add	eax,ecx
147
; RAW area for click button
148
	mov	[dinamic_button_data_1.click_raw],eax
149
	mov	[dinamic_button_data_2.click_raw],eax
150
;---------------------------------------------------------------------
1101 Lrz 151
red:
1435 mario79 152
	call	draw_window
1101 Lrz 153
still:
1435 mario79 154
	mcall	10
1101 Lrz 155
 
1435 mario79 156
	cmp	eax,1
157
	je	red
158
	cmp	eax,2
159
	je	key
160
	cmp	eax,3
161
	je	button
162
	cmp	eax,6
163
	je	mouse
164
	jmp	still
1101 Lrz 165
;---------------------------------------------------------------------
1435 mario79 166
	key:
167
	mcall	2
168
	jmp	still
1101 Lrz 169
;---------------------------------------------------------------------
1435 mario79 170
	button:
171
	mcall	17
172
	cmp	ah,1
173
	jne	still
174
	.exit:
175
	mcall	-1
1101 Lrz 176
;---------------------------------------------------------------------
177
mouse:
178
;-----------------------------------------------
1435 mario79 179
	cmp	[scroll_bar_data_horizontal.delta2],0
180
	jne	.horizontal
1101 Lrz 181
.vertical:
1435 mario79 182
	mov	eax,[scroll_bar_data_vertical.max_area]
183
	cmp	eax,[scroll_bar_data_vertical.cur_area]
184
	jbe	.horizontal
1101 Lrz 185
; mouse event for Vertical ScrollBar
1435 mario79 186
	push	dword scroll_bar_data_vertical
187
	call	[scrollbar_ver_mouse]
188
	mov	eax,scroll_bar_data_vertical.redraw
189
	xor	ebx,ebx
190
	cmp	[eax],ebx
191
	je	@f
192
	mov	[eax],ebx
193
	jmp	.draw_cube
1101 Lrz 194
@@:
1435 mario79 195
	cmp	[scroll_bar_data_vertical.delta2],0
196
	jne	still
1101 Lrz 197
.horizontal:
1435 mario79 198
	mov	eax,[scroll_bar_data_horizontal.max_area]
199
	cmp	eax,[scroll_bar_data_horizontal.cur_area]
200
	jbe	.other
1101 Lrz 201
; mouse event for Horizontal ScrollBar
1435 mario79 202
	push	dword scroll_bar_data_horizontal
203
	call	[scrollbar_hor_mouse]
204
	mov	eax,scroll_bar_data_horizontal.redraw
205
	xor	ebx,ebx
206
	cmp	[eax],ebx
207
	je	.other
208
	mov	[eax],ebx
1101 Lrz 209
.draw_cube:
1435 mario79 210
	call	draw_cube
211
	jmp	still
1101 Lrz 212
.other:
1435 mario79 213
	cmp	[scroll_bar_data_vertical.delta2],0
214
	jne	still
215
	cmp	[scroll_bar_data_horizontal.delta2],0
216
	jne	still
1101 Lrz 217
;-----------------------------------------------
218
.menu_bar_1:
1435 mario79 219
	call	.set_mouse_flag
1101 Lrz 220
@@:
221
; mouse event for Menu 1
1435 mario79 222
	push	dword menu_data_1
223
	call	[menu_bar_mouse]
224
	cmp	[menu_data_1.click],dword 1
225
	jne	.menu_bar_2
226
	cmp	[menu_data_1.cursor_out],dword 0
227
	jne	analyse_out_menu_1
228
	jmp	.menu_bar_1
1101 Lrz 229
;--------------------------------------------
230
.menu_bar_2:
231
; mouse event for Menu 2
1435 mario79 232
	push	dword menu_data_2
233
	call	[menu_bar_mouse]
234
	cmp	[menu_data_2.click],dword 1
235
	jne	.mouse_dinamic_button
236
	cmp	[menu_data_2.cursor_out],dword 0
237
	jne	analyse_out_menu_2
238
	jmp	.menu_bar_1
1101 Lrz 239
;--------------------------------------------
240
.mouse_dinamic_button:
241
; mouse event for Dinamic Button 1
1435 mario79 242
	push	dword dinamic_button_data_1
243
	call	[dinamic_button_mouse]
244
	mov	eax,dinamic_button_data_1.click
245
	cmp	[eax],dword 1
246
	jne	@f
247
	mov	[eax],dword 0
248
	jmp	about
1101 Lrz 249
@@:
250
; mouse event for Dinamic Button 2
1435 mario79 251
	push	dword dinamic_button_data_2
252
	call	[dinamic_button_mouse]
253
	mov	eax,dinamic_button_data_2.click
254
	cmp	[eax],dword 1
255
	jne	still	;@f
256
	mov	[eax],dword 0
257
	jmp	button.exit
1101 Lrz 258
;---------------------------------------------------------------------
1435 mario79 259
.set_mouse_flag:
260
	xor	eax,eax
261
	inc	eax
262
	mov	[menu_data_1.get_mouse_flag],eax
263
	mov	[menu_data_2.get_mouse_flag],eax
264
	ret
1101 Lrz 265
;---------------------------------------------------------------------
266
analyse_out_menu_1:
267
; analyse result of Menu 1
1219 mario79 268
	mov	eax,[menu_data_1.cursor_out]
269
	cmp	eax,dword 1
1417 mario79 270
	je	OpenDialog_start_0
271
	cmp	eax,dword 2
272
	je	OpenDialog_start_1
273
	cmp	eax,dword 3
274
	je	OpenDialog_start_2
1435 mario79 275
	cmp	eax,dword 4
276
	je	button.exit
277
	jmp	still
278
;---------------------------------------------------------------------
1101 Lrz 279
analyse_out_menu_2:
280
; analyse result of Menu 2
1435 mario79 281
	cmp	[menu_data_2.cursor_out],dword 2
282
	je	about
283
	jmp	still
1101 Lrz 284
;---------------------------------------------------------------------
1435 mario79 285
	about:
286
	mcall	51,1,thread3,thread
287
	jmp	still
1101 Lrz 288
;---------------------------------------------------------------------
1417 mario79 289
OpenDialog_start_0:
290
	mov	[OpenDialog_data.type],0
291
	jmp	OpenDialog_start
292
OpenDialog_start_1:
293
	mov	[OpenDialog_data.type],1
294
	jmp	OpenDialog_start
295
OpenDialog_start_2:
296
	mov	[OpenDialog_data.type],2
1219 mario79 297
OpenDialog_start:
298
;	mov	ebx,open_dialog_name
299
;	mov	esi,path
300
;	mov	edi,library_path
301
;	call	copy_file_path
302
 
303
	copy_path	open_dialog_name,path,library_path,0
304
 
305
 
306
start_OpenDialog	OpenDialog_data
307
 
1435 mario79 308
	cmp	[OpenDialog_data.status],2	; OpenDialog does not start
309
	je	still	; some kind of alternative, instead OpenDialog
1219 mario79 310
	cmp	[OpenDialog_data.status],1
1435 mario79 311
	jne	still	; OpenDialog user say cancel
312
; copy path
313
; prepare path - PathShow
314
	push	dword PathShow_data_1
315
	call	[PathShow_prepare]
1433 mario79 316
 
1219 mario79 317
	call	draw_window
1435 mario79 318
	jmp	still	; OpenDialog user selected the target file
319
;	[OpenDialog_data.openfile_pach] pointer of area the target file
1219 mario79 320
;---------------------------------------------------------------------
321
;---------------------------------------------------------------------
1101 Lrz 322
draw_window:
1435 mario79 323
	mcall	12,1
324
	mcall	0,<0,400>,<0,400>,0x03AABBCC,0x805080D0,0x005080D0
325
	mcall	71,1,header_1
1101 Lrz 326
;---------------------------------------------
327
; draw for Menu 1
1435 mario79 328
	push	dword menu_data_1
329
	call	[menu_bar_draw]
1101 Lrz 330
; draw for Menu 2
1435 mario79 331
	push	dword menu_data_2
332
	call	[menu_bar_draw]
1101 Lrz 333
;---------------------------------------------
1435 mario79 334
; draw for Dinamic Button	1
335
	push	dword dinamic_button_data_1
336
	call	[dinamic_button_draw]
1101 Lrz 337
; draw for Dinamic Button 2
1435 mario79 338
	push	dword dinamic_button_data_2
339
	call	[dinamic_button_draw]
1101 Lrz 340
;---------------------------------------------
1219 mario79 341
	mcall	13,<170,200>,<25,15>,0xffffb0
1433 mario79 342
;	mov	bx,28
343
;	add	ebx,2 shl 16
344
;	mcall	4,,0xC0000000,text_work_area,,0xffffb0
345
; draw for PathShow
1435 mario79 346
	push	dword PathShow_data_1
347
	call	[PathShow_draw]
1219 mario79 348
;---------------------------------------------
1101 Lrz 349
; set all_redraw flag for draw all ScrollBar
350
; In some cases it is necessity to draw only the area
1435 mario79 351
; of moving of a "runner", for acceleration of output -
1101 Lrz 352
; in this case the flag needs to be reset to 0 (zero).
1435 mario79 353
	xor	eax,eax
354
	inc	eax
355
	mov	[scroll_bar_data_vertical.all_redraw],eax
356
	mov	[scroll_bar_data_horizontal.all_redraw],eax
357
 
1101 Lrz 358
; draw for Vertical ScrollBar
1435 mario79 359
	push	dword scroll_bar_data_vertical
360
	call	[scrollbar_ver_draw]
1101 Lrz 361
; draw for Horizontal ScrollBar
1435 mario79 362
	push	dword scroll_bar_data_horizontal
363
	call	[scrollbar_hor_draw]
364
; reset all_redraw flag
365
	xor	eax,eax
366
	mov	[scroll_bar_data_vertical.all_redraw],eax
367
	mov	[scroll_bar_data_horizontal.all_redraw],eax
1101 Lrz 368
;---------------------------------------------
1435 mario79 369
	call	draw_cube
370
	mcall	12,2
371
	ret
1101 Lrz 372
;---------------------------------------------------------------------
373
draw_cube:
1435 mario79 374
	mcall	13,<30,301>,<50,301>,0xafafaf
375
	mov	ecx,[scroll_bar_data_vertical.position]
376
	add	ecx,50
377
	shl	ecx,16
378
	mov	cx,30
379
	mov	ebx,[scroll_bar_data_horizontal.position]
380
	add	ebx,30
381
	shl	ebx,16
382
	mov	bx,30
383
	mcall	13,,,0x0
384
	ret
1219 mario79 385
;---------------------------------------------------------------------
1101 Lrz 386
include 'data.inc'
387
include 'w_about.inc'
1219 mario79 388
;---------------------------------------------------------------------
1101 Lrz 389
IM_END:
1435 mario79 390
	rb 1024
1101 Lrz 391
thread:
1219 mario79 392
;---------------------------------------------------------------------
1435 mario79 393
	rb 1024
1101 Lrz 394
stacktop:
1219 mario79 395
;---------------------------------------------------------------------
1101 Lrz 396
path:
1435 mario79 397
	rb 4096
1219 mario79 398
;---------------------------------------------------------------------
399
openfile_pach:
1435 mario79 400
	rb 4096
1219 mario79 401
;---------------------------------------------------------------------
1101 Lrz 402
file_name:
1219 mario79 403
library_path:
1435 mario79 404
	rb 4096
1219 mario79 405
;---------------------------------------------------------------------
406
plugin_pach:
1435 mario79 407
	rb 4096
1219 mario79 408
;---------------------------------------------------------------------
1433 mario79 409
text_work_area:
1435 mario79 410
	rb 4096
1433 mario79 411
;---------------------------------------------------------------------
1435 mario79 412
filename_area:
413
	rb 256
414
;---------------------------------------------------------------------
1101 Lrz 415
file_info:
1435 mario79 416
	rb 40
1219 mario79 417
;---------------------------------------------------------------------
418
procinfo:
1435 mario79 419
	rb 1024
1219 mario79 420
;---------------------------------------------------------------------
1101 Lrz 421
I_END:
422