2009-10-17 21:26:18 +02:00
|
|
|
;*****************************************************************************
|
|
|
|
; Macro for use Open Dialog - for Kolibri OS
|
2010-02-16 14:39:24 +01:00
|
|
|
; Copyright (c) 2009 2010, Marat Zakiyanov aka Mario79, aka Mario
|
2009-10-17 21:26:18 +02:00
|
|
|
; All rights reserved.
|
|
|
|
;
|
|
|
|
; Redistribution and use in source and binary forms, with or without
|
|
|
|
; modification, are permitted provided that the following conditions are met:
|
|
|
|
; * Redistributions of source code must retain the above copyright
|
|
|
|
; notice, this list of conditions and the following disclaimer.
|
|
|
|
; * Redistributions in binary form must reproduce the above copyright
|
|
|
|
; notice, this list of conditions and the following disclaimer in the
|
|
|
|
; documentation and/or other materials provided with the distribution.
|
|
|
|
; * Neither the name of the <organization> nor the
|
|
|
|
; names of its contributors may be used to endorse or promote products
|
|
|
|
; derived from this software without specific prior written permission.
|
|
|
|
;
|
|
|
|
; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
|
|
|
|
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
; DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
|
|
|
|
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
;*****************************************************************************
|
|
|
|
;*****************************************************************************
|
2010-03-18 21:58:05 +01:00
|
|
|
macro OpenDialog_exit
|
2009-10-17 21:26:18 +02:00
|
|
|
{
|
2010-03-18 21:58:05 +01:00
|
|
|
popa
|
2009-10-17 21:26:18 +02:00
|
|
|
ret
|
|
|
|
}
|
|
|
|
;*****************************************************************************
|
|
|
|
macro use_OpenDialog
|
|
|
|
{
|
|
|
|
OpenDialog:
|
2010-03-18 21:58:05 +01:00
|
|
|
od_type equ dword [ebp] ; 0-Open, 1-Save, 2-Dir
|
2010-02-16 14:39:24 +01:00
|
|
|
od_procinfo equ dword [ebp+4] ; Process info area for function 9
|
|
|
|
od_com_area_name equ dword [ebp+8] ; Name for shared area
|
|
|
|
od_com_area equ dword [ebp+12] ; Adress of shared area
|
|
|
|
od_opendir_pach equ dword [ebp+16] ; Temp area the directory for show
|
2010-03-18 21:58:05 +01:00
|
|
|
od_dir_default_pach equ dword [ebp+20] ; Default path of directory,
|
2010-02-16 14:39:24 +01:00
|
|
|
od_start_path equ dword [ebp+24] ; Location path to OpenDialog
|
2010-03-18 21:58:05 +01:00
|
|
|
od_draw_window equ dword [ebp+28] ; Adress of procedure - draw_window
|
2010-02-16 14:39:24 +01:00
|
|
|
od_status equ dword [ebp+32] ; 0-Cancel, 1-Get path OK, 2-Use alternatives
|
|
|
|
od_openfile_pach equ dword [ebp+36] ; Getting path to file
|
2010-03-18 21:58:05 +01:00
|
|
|
od_filename_area equ dword [ebp+40] ; Adress of file name area
|
|
|
|
od_filter_area equ dword [ebp+44] ; Adress of filter area
|
2009-10-17 21:26:18 +02:00
|
|
|
;*****************************************************************************
|
|
|
|
.init:
|
|
|
|
pusha
|
2010-03-18 21:58:05 +01:00
|
|
|
mcall 9,od_procinfo,-1
|
2009-10-17 21:26:18 +02:00
|
|
|
mov ebx,[ebx+30]
|
|
|
|
mov edi,od_com_area_name
|
|
|
|
add edi,7
|
|
|
|
std
|
|
|
|
mov ecx,4
|
|
|
|
@@:
|
|
|
|
mov al,bl
|
|
|
|
and al,1111b
|
|
|
|
add al,0x30
|
|
|
|
stosb
|
|
|
|
mov al,bl
|
|
|
|
shr al,4
|
|
|
|
and al,1111b
|
|
|
|
add al,0x30
|
|
|
|
stosb
|
|
|
|
shr ebx,8
|
|
|
|
dec ecx
|
|
|
|
jnz @r
|
|
|
|
cld
|
|
|
|
|
|
|
|
mcall 68,22,od_com_area_name,8192,0x09
|
|
|
|
mov od_com_area,eax
|
2010-02-17 16:15:50 +01:00
|
|
|
|
2010-03-18 21:58:05 +01:00
|
|
|
mov esi,od_openfile_pach
|
|
|
|
mov edi,od_opendir_pach
|
2010-02-17 16:15:50 +01:00
|
|
|
call .copy_dir_path
|
|
|
|
|
2009-10-17 21:26:18 +02:00
|
|
|
OpenDialog_exit
|
|
|
|
;*****************************************************************************
|
|
|
|
;*****************************************************************************
|
|
|
|
.start:
|
|
|
|
pusha
|
|
|
|
mov eax,od_com_area
|
|
|
|
test eax,eax
|
|
|
|
jz .1
|
2010-03-18 21:58:05 +01:00
|
|
|
mov ebx,od_type
|
|
|
|
mov [eax+2],bx
|
2010-02-16 14:39:24 +01:00
|
|
|
|
2010-03-18 21:58:05 +01:00
|
|
|
mov [eax],word 2 ; folder for open
|
2009-10-17 21:26:18 +02:00
|
|
|
mov edi,eax
|
|
|
|
add edi,4
|
|
|
|
|
|
|
|
mov esi,od_opendir_pach
|
|
|
|
xor eax,eax
|
|
|
|
mov al,[esi]
|
|
|
|
test eax,eax
|
|
|
|
jnz @f
|
2010-03-18 21:58:05 +01:00
|
|
|
mov esi,od_dir_default_pach ;communication_area_default_pach
|
2009-10-17 21:26:18 +02:00
|
|
|
@@:
|
|
|
|
call .copy
|
2010-03-18 21:58:05 +01:00
|
|
|
;----------------------------------------------
|
|
|
|
; copy file name to shared area
|
|
|
|
cmp od_type,dword 1
|
|
|
|
jne .4
|
|
|
|
mov edi,od_com_area
|
|
|
|
add edi,4096-256
|
2009-10-17 21:26:18 +02:00
|
|
|
|
2010-03-18 21:58:05 +01:00
|
|
|
mov esi,od_filename_area
|
|
|
|
; xor eax,eax
|
|
|
|
; mov al,[esi]
|
|
|
|
; test eax,eax
|
|
|
|
test esi,esi
|
|
|
|
jnz @f
|
|
|
|
mov esi,.null
|
|
|
|
@@:
|
|
|
|
call .copy
|
|
|
|
.4:
|
|
|
|
;----------------------------------------------
|
|
|
|
cmp od_type,dword 2
|
|
|
|
je @f
|
|
|
|
call .get_filter_data
|
|
|
|
@@:
|
|
|
|
;----------------------------------------------
|
2009-10-17 21:26:18 +02:00
|
|
|
mov eax,od_com_area_name
|
|
|
|
mov [start_open_dialog.parameter],eax
|
|
|
|
|
|
|
|
mov eax,od_start_path
|
|
|
|
mov [start_open_dialog.name],eax
|
|
|
|
|
2010-03-18 21:58:05 +01:00
|
|
|
mcall 70,start_open_dialog
|
2009-10-17 21:26:18 +02:00
|
|
|
shr eax,31
|
|
|
|
test eax,eax
|
|
|
|
jnz .1
|
|
|
|
jmp .still
|
|
|
|
.red:
|
|
|
|
pusha
|
|
|
|
call od_draw_window
|
|
|
|
popa
|
|
|
|
.still:
|
2010-03-18 21:58:05 +01:00
|
|
|
mcall 23,50
|
2009-10-17 21:26:18 +02:00
|
|
|
cmp eax,1
|
|
|
|
je .red
|
|
|
|
mov eax,od_com_area
|
2010-02-16 14:39:24 +01:00
|
|
|
movzx ebx,word [eax]
|
2009-10-17 21:26:18 +02:00
|
|
|
test ebx,ebx
|
|
|
|
jz .still
|
|
|
|
cmp ebx,3
|
2010-03-18 21:58:05 +01:00
|
|
|
je .2
|
2009-10-17 21:26:18 +02:00
|
|
|
cmp ebx,1
|
|
|
|
jne .still
|
|
|
|
|
|
|
|
mov esi,od_com_area
|
|
|
|
add esi,4
|
2010-03-18 21:58:05 +01:00
|
|
|
mov edi,od_openfile_pach
|
2009-10-17 21:26:18 +02:00
|
|
|
call .copy
|
|
|
|
mov od_status,1
|
2010-03-18 21:58:05 +01:00
|
|
|
mov esi,od_openfile_pach
|
|
|
|
mov edi,od_opendir_pach
|
2010-02-17 16:15:50 +01:00
|
|
|
call .copy_dir_path
|
2010-03-18 21:58:05 +01:00
|
|
|
;----------------------------------------------
|
|
|
|
; copy file name from shared area
|
|
|
|
cmp od_type,dword 1
|
|
|
|
jne @f
|
|
|
|
mov esi,od_com_area
|
|
|
|
add esi,4096-256
|
|
|
|
mov edi,od_filename_area
|
|
|
|
; xor eax,eax
|
|
|
|
; mov al,[edi]
|
|
|
|
; test eax,eax
|
|
|
|
test edi,edi
|
|
|
|
jz @f
|
|
|
|
call .copy
|
|
|
|
@@:
|
|
|
|
;----------------------------------------------
|
|
|
|
jmp .3
|
2009-10-17 21:26:18 +02:00
|
|
|
.2:
|
|
|
|
mov od_status,0
|
2010-03-18 21:58:05 +01:00
|
|
|
jmp .3
|
2009-10-17 21:26:18 +02:00
|
|
|
.1:
|
2010-03-18 21:58:05 +01:00
|
|
|
mov od_status,2
|
2009-10-17 21:26:18 +02:00
|
|
|
.3:
|
|
|
|
OpenDialog_exit
|
|
|
|
;----------------------------------------------
|
2010-03-18 21:58:05 +01:00
|
|
|
.null:
|
|
|
|
dd 0
|
|
|
|
;----------------------------------------------
|
|
|
|
.get_filter_data:
|
|
|
|
mov edi,od_com_area
|
|
|
|
test edi,edi
|
|
|
|
jnz @f
|
|
|
|
; add esp,4
|
|
|
|
; jmp still
|
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
add edi,4096+4
|
|
|
|
mov esi,od_filter_area
|
|
|
|
mov ecx,[esi]
|
|
|
|
test ecx,ecx
|
|
|
|
jnz @f
|
|
|
|
mov edi,od_com_area
|
|
|
|
mov [edi+4096],dword 0
|
|
|
|
ret
|
|
|
|
@@:
|
|
|
|
inc ecx
|
|
|
|
cld
|
|
|
|
rep movsb
|
|
|
|
mov edi,od_com_area
|
|
|
|
mov [edi+4096],dword 1
|
|
|
|
ret
|
|
|
|
;----------------------------------------------
|
2009-10-17 21:26:18 +02:00
|
|
|
.copy:
|
|
|
|
xor eax,eax
|
|
|
|
cld
|
|
|
|
@@:
|
|
|
|
lodsb
|
|
|
|
stosb
|
|
|
|
test eax,eax
|
|
|
|
jnz @b
|
|
|
|
ret
|
|
|
|
;----------------------------------------------
|
2010-02-17 16:15:50 +01:00
|
|
|
.copy_dir_path:
|
2010-03-18 21:58:05 +01:00
|
|
|
xor eax,eax
|
|
|
|
cmp [esi],al
|
|
|
|
jne @f
|
|
|
|
mov [edi],al
|
|
|
|
mov [ebx],al
|
|
|
|
xor ebx,ebx
|
|
|
|
inc ebx
|
2010-02-17 16:15:50 +01:00
|
|
|
ret
|
|
|
|
@@:
|
2010-03-18 21:58:05 +01:00
|
|
|
cld
|
|
|
|
lodsb
|
|
|
|
stosb
|
|
|
|
test eax,eax
|
|
|
|
jnz @b
|
|
|
|
cmp od_type,dword 2
|
|
|
|
jne @f
|
|
|
|
ret
|
2010-02-17 16:15:50 +01:00
|
|
|
@@:
|
2010-03-18 21:58:05 +01:00
|
|
|
mov esi,edi
|
|
|
|
dec esi
|
|
|
|
@@:
|
|
|
|
std
|
|
|
|
lodsb
|
|
|
|
cmp al,'/'
|
|
|
|
jnz @b
|
2010-02-17 16:15:50 +01:00
|
|
|
|
2010-03-18 21:58:05 +01:00
|
|
|
mov [esi+1],byte 0
|
|
|
|
cld
|
2010-02-17 16:15:50 +01:00
|
|
|
ret
|
|
|
|
;----------------------------------------------
|
2010-03-18 21:58:05 +01:00
|
|
|
align 4
|
2009-10-17 21:26:18 +02:00
|
|
|
start_open_dialog:
|
|
|
|
.subfunction dd 7
|
|
|
|
.flags dd 0
|
2010-03-18 21:58:05 +01:00
|
|
|
.parameter dd 0 ;od_com_area_name
|
2009-10-17 21:26:18 +02:00
|
|
|
.reserved1 dd 0
|
|
|
|
.reserved2 dd 0
|
|
|
|
db 0
|
2010-03-18 21:58:05 +01:00
|
|
|
.name: dd 0 ;od_start_path
|
2009-10-17 21:26:18 +02:00
|
|
|
}
|
|
|
|
;*****************************************************************************
|
|
|
|
macro init_OpenDialog od_ptr
|
|
|
|
{
|
|
|
|
mov ebp,od_ptr
|
|
|
|
call OpenDialog.init
|
|
|
|
}
|
|
|
|
;*****************************************************************************
|
|
|
|
macro start_OpenDialog od_ptr
|
|
|
|
{
|
|
|
|
mov ebp,od_ptr
|
|
|
|
call OpenDialog.start
|
|
|
|
}
|
|
|
|
;*****************************************************************************
|