Subversion Repositories Kolibri OS

Rev

Rev 1581 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1509 mario79 1
;*****************************************************************************
2
; Macro for use Open Dialog - for Kolibri OS
3
; Copyright (c) 2009 2010, Marat Zakiyanov aka Mario79, aka Mario
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:
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.
16
;
17
; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
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.
27
;*****************************************************************************
28
;*****************************************************************************
29
macro	OpenDialog_exit
30
{
31
popa
32
ret 4
33
}
34
;*****************************************************************************
35
macro	use_OpenDialog
36
{
37
OpenDialog:
38
od_type			equ dword [ebp]	; 0-Open, 1-Save, 2-Dir
39
od_procinfo		equ dword [ebp+4] ; Process info area for function 9
40
od_com_area_name	equ dword [ebp+8] ; Name for shared area
41
od_com_area		equ dword [ebp+12] ; Adress of shared area
42
od_opendir_pach		equ dword [ebp+16] ; Temp area the directory for show
43
od_dir_default_pach	equ dword [ebp+20] ; Default path of directory,
44
od_start_path		equ dword [ebp+24] ; Location path to OpenDialog
45
od_draw_window		equ dword [ebp+28] ; Adress of procedure - draw_window
46
od_status		equ dword [ebp+32] ; 0-Cancel, 1-Get path OK, 2-Use alternatives
47
od_openfile_pach	equ dword [ebp+36] ; Getting path to file
48
od_filename_area	equ dword [ebp+40] ; Adress of file name area
49
od_filter_area		equ dword [ebp+44] ; Adress of filter area
50
;*****************************************************************************
51
.init:
52
	pusha
53
	mov   ebp,dword [esp+36]
54
	mcall	9,od_procinfo,-1
55
	mov	ebx,[ebx+30]
56
	mov	edi,od_com_area_name
57
	add	edi,7
58
	std
59
	mov	ecx,4
60
@@:
61
	mov	al,bl
62
	and	al,1111b
63
	add	al,0x30
64
	stosb
65
	mov	al,bl
66
	shr	al,4
67
	and	al,1111b
68
	add	al,0x30
69
	stosb
70
	shr	ebx,8
71
	dec	ecx
72
	jnz	@r
73
	cld
74
 
75
	mcall	68,22,od_com_area_name,8192,0x09
76
	mov	od_com_area,eax
77
 
78
	mov	esi,od_openfile_pach
79
	mov	edi,od_opendir_pach
80
	call	.copy_dir_path
81
 
82
OpenDialog_exit
83
;*****************************************************************************
84
;*****************************************************************************
85
.start:
86
	pusha
87
	mov   ebp,dword [esp+36]
88
	mov	eax,od_com_area
89
	test	eax,eax
90
	jz	.1
91
	mov	ebx,od_type
92
	mov	[eax+2],bx
93
 
94
	mov	[eax],word 2	; folder for open
95
	mov	edi,eax
96
	add	edi,4
97
 
98
	mov	esi,od_opendir_pach
99
	xor	eax,eax
100
	mov	al,[esi]
101
	test	eax,eax
102
	jnz	@f
103
	mov	esi,od_dir_default_pach	;communication_area_default_pach
104
@@:
105
	call	.copy
106
;----------------------------------------------
107
; copy file name to shared area
108
	cmp	od_type,dword 2
109
	je	.4
110
	mov	edi,od_com_area
111
	add	edi,4096-256
112
 
113
	mov	esi,od_filename_area
114
	test	esi,esi
115
	jnz	@f
116
	xor	eax,eax
117
	mov	[edi],eax
118
	jmp	.4
119
@@:
120
	call	.copy
121
.4:
122
;----------------------------------------------
123
	cmp	od_type,dword 2
124
	je	@f
125
	call	.get_filter_data
126
@@:
127
;----------------------------------------------
128
	mov	eax,od_com_area_name
129
	mov	[start_open_dialog.parameter],eax
130
 
131
	mov	eax,od_start_path
132
	mov	[start_open_dialog.name],eax
133
 
134
	mcall	70,dword start_open_dialog
135
	shr	eax,31
136
	test	eax,eax
137
	jnz	.1
138
.still:
139
	mcall	23,50
140
	cmp	eax,1
141
	jne	@f
142
	pusha
143
	call	od_draw_window
144
	popa
145
@@:
146
	mov	eax,od_com_area
147
	movzx	ebx,word [eax]
148
	test	ebx,ebx
149
	jz	.still
150
	cmp	ebx,3
151
	je	.2
152
	cmp	ebx,1
153
	jne	.still
154
 
155
	mov	esi,od_com_area
156
	add	esi,4
157
	mov	edi,od_openfile_pach
158
	call	.copy
159
	mov	od_status,1
160
	mov	esi,od_openfile_pach
161
	mov	edi,od_opendir_pach
162
	call	.copy_dir_path
163
;----------------------------------------------
164
; copy file name from shared area
165
	cmp	od_type,dword 2
166
	je	@f
167
	mov	esi,od_com_area
168
	add	esi,4096-256
169
	mov	edi,od_filename_area
170
	test	edi,edi
171
	jz	@f
172
	call	.copy
173
@@:
174
;----------------------------------------------
175
	jmp	.3
176
.2:
177
	mov	od_status,0
178
	jmp	.3
179
.1:
180
	mov	od_status,2
181
.3:
182
OpenDialog_exit
183
;----------------------------------------------
184
.get_filter_data:
185
	mov	edi,od_com_area
186
	test	edi,edi
187
	jnz	@f
188
;	add	esp,4
189
;	jmp	still
190
	ret
191
@@:
192
	add	edi,4096+4
193
	mov	esi,od_filter_area
194
	mov	ecx,[esi]
195
	test	ecx,ecx
196
	jnz	@f
197
	mov	edi,od_com_area
198
	mov	[edi+4096],dword 0
199
	ret
200
@@:
201
	inc	ecx
202
	cld
203
	rep	movsb
204
	mov	edi,od_com_area
205
	mov	[edi+4096],dword 1
206
	ret
207
;----------------------------------------------
208
.copy:
209
	xor	eax,eax
210
	cld
211
@@:
212
	lodsb
213
	stosb
214
	test	eax,eax
215
	jnz	@b
216
	ret
217
;----------------------------------------------
218
.copy_dir_path:
219
	xor	eax,eax
220
	cmp	[esi],al
221
	jne	@f
222
	mov	[edi],al
223
	mov	[ebx],al
224
	xor	ebx,ebx
225
	inc	ebx
226
	ret
227
@@:
228
	cld
229
	lodsb
230
	stosb
231
	test	eax,eax
232
	jnz	@b
233
	cmp	od_type,dword 2
234
	jne	@f
235
	ret
236
@@:
237
	mov	esi,edi
238
	dec	esi
239
@@:
240
	std
241
	lodsb
242
	cmp	al,'/'
243
	jnz	@b
244
 
245
	mov	[esi+1],byte 0
246
	cld
247
	ret
248
;----------------------------------------------
249
align	4
250
start_open_dialog:
251
.subfunction	dd 7
252
.flags		dd 0
253
.parameter	dd 0	;od_com_area_name
254
.reserved1	dd 0
255
.reserved2	dd 0
256
		db 0
257
.name:		dd 0	;od_start_path
258
}
259
;*****************************************************************************