OpenDialog extension:

1) Open file dialog
2) Save file dialog
3) Select directory dialog

git-svn-id: svn://kolibrios.org@1417 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79) 2010-02-16 13:39:24 +00:00
parent efabe7d047
commit fd97893dd7
4 changed files with 112 additions and 37 deletions

View File

@ -1,6 +1,6 @@
;*****************************************************************************
; Open Dialog - for Kolibri OS
; Copyright (c) 2009, Marat Zakiyanov aka Mario79, aka Mario
; Copyright (c) 2009, 2010, Marat Zakiyanov aka Mario79, aka Mario
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
@ -43,6 +43,7 @@ include '../../load_lib.mac'
include '../../trunk/box_lib.mac'
;include 'macros.inc'
;include 'load_lib.mac'
;include 'box_lib.mac'
@use_library
;---------------------------------------------------------------------
;---------------------------------------------------------------------
@ -323,12 +324,19 @@ key_ASCII:
cmp ah,9
je change_focus_area_Tab_key_ASCII
cmp ah,13
je .load_dir
je .13
cmp ah,27
je button.exit
push dword name_editboxes
call [edit_box_key]
jmp still
.13:
cmp [open_dialog_type],2 ; Select dir
je file_no_folder
cmp [open_dialog_type],1 ; Save file
jne .load_dir
inc [open_dialog_type]
jmp file_no_folder
.load_dir:
mov [file_browser_data_1.select_panel_counter],1
xor eax,eax
@ -513,9 +521,9 @@ button:
mov eax,[communication_area]
test eax,eax
jz @f
cmp [eax],dword 1
cmp [eax],word 1
je @f
mov [eax],dword 3
mov [eax],word 3
@@:
mov eax,[N_error]
test eax,eax
@ -535,6 +543,10 @@ button:
jmp still
;---------------------------------------------------------------------
.open_dir_or_file:
cmp [open_dialog_type],2 ;Select dir
je file_no_folder
; cmp [open_dialog_type],1 ;Save file
; je file_no_folder
xor ebx,ebx
jmp key.7
;---------------------------------------------------------------------
@ -608,7 +620,7 @@ thread_start:
draw_error_window:
mcall 12, 1
mcall 0,[error_window_x] ,[error_window_y], 0x03ff0000
mcall 71,1,title
call type_title
mcall 4,<10,30>,0x90ffffff,[N_error]
mov eax,[error_path]
test eax,eax
@ -886,6 +898,8 @@ get_communication_area:
jz @f
mcall 68,22,param,,0x01
mov [communication_area],eax
movzx eax,word [eax+2]
mov [open_dialog_type],eax
@@:
ret
;---------------------------------------------------------------------
@ -893,7 +907,7 @@ load_start_directory:
mov eax,[communication_area]
test eax,eax
jz @f
mov ebx,[eax]
movzx ebx,word [eax]
test eax,eax
jz @f
add eax,4
@ -1013,9 +1027,11 @@ file_no_folder:
mov edi,file_name
call copy_dir_name
cmp [open_dialog_type],2
je @f
mov esi,file_name
call copy_dir_path
@@:
mov eax,[communication_area]
test eax,eax
jnz @f
@ -1028,7 +1044,7 @@ file_no_folder:
mov esi,file_name
call copy_dir_name
mov eax,[communication_area]
mov [eax],dword 1
mov [eax],word 1
jmp button.exit
;---------------------------------------------------------------------
load_root_directory:
@ -1128,6 +1144,17 @@ memory_get_error:
mov [N_error],4
jmp button.exit
;---------------------------------------------------------------------
type_title:
mov ecx,[open_dialog_type]
shl ecx,2
add ecx,open_dialog_title_pointer
mov ecx,[ecx]
test ecx,ecx
jz @f
mcall 71,1, ; title ;;param ;file_name ;dir_pach
@@:
ret
;---------------------------------------------------------------------
draw_window:
mcall 12,1
@ -1136,9 +1163,7 @@ draw_window:
; mov ecx,[communication_area]
; add ecx,4096+4+4
mcall 71,1, title ;;param ;file_name ;dir_pach
call type_title
call get_window_param
mov eax,[window_high]
@ -1244,7 +1269,18 @@ draw_window:
shr ecx,16
mov bx,cx
add ebx,12 shl 16+ 4
mcall 4,,0x90000000,message_open_button
mov edx,[open_dialog_type]
shl edx,2
add edx,message_open_dialog_button
mov edx,[edx]
cmp [open_dialog_type],2 ; Select dir
jne @f
sub ebx,5 shl 16
@@:
mcall 4,,0x90000000 ;message_open_button
popa
@ -1686,7 +1722,10 @@ delete_unsupported_BDFE:
@@:
test [eax-40],byte 0x10
jnz .start
cmp [open_dialog_type],2 ; Select dir
je .delete
push eax ebx
mov esi,eax
call search_expansion
@ -2220,6 +2259,18 @@ root1_folder_block dd 0
temp_counter_1 dd 0
retrieved_devices_table_counter dd 0
communication_area dd 0
open_dialog_type dd 0
open_dialog_title_pointer:
dd title_0
dd title_1
dd title_2
dd 0
message_open_dialog_button:
dd message_0
dd message_1
dd message_2
dd 0
;---------------------------------------------------------------------
expansion_length dd 0
;---------------------------------------------------------------------
@ -2356,17 +2407,26 @@ message:
message_cancel_button:
db 'Cancel',0
message_open_button:
db 'Open',0
message_ReloadDir_button:
db 'Refresh',0
message_ExitDir_button:
db '^',0
title:
message_0:
db 'Open',0
message_1:
db 'Save',0
message_2:
db 'Select',0
title_0:
db 'Open Dialog',0
title_1:
db 'Save Dialog',0
title_2:
db 'Select Dir',0
;---------------------------------------------------------------------
align 4
menu_data_1:

View File

@ -259,10 +259,14 @@ analyse_out_menu_1:
; analyse result of Menu 1
mov eax,[menu_data_1.cursor_out]
cmp eax,dword 1
je OpenDialog_start
cmp eax,dword 3
je button.exit
jmp still
je OpenDialog_start_0
cmp eax,dword 2
je OpenDialog_start_1
cmp eax,dword 3
je OpenDialog_start_2
cmp eax,dword 4
je button.exit
jmp still
analyse_out_menu_2:
; analyse result of Menu 2
@ -274,6 +278,14 @@ analyse_out_menu_2:
mcall 51,1,thread3,thread
jmp still
;---------------------------------------------------------------------
OpenDialog_start_0:
mov [OpenDialog_data.type],0
jmp OpenDialog_start
OpenDialog_start_1:
mov [OpenDialog_data.type],1
jmp OpenDialog_start
OpenDialog_start_2:
mov [OpenDialog_data.type],2
OpenDialog_start:
; mov ebx,open_dialog_name
; mov esi,path

View File

@ -316,8 +316,9 @@ menu_data_1:
menu_text_area:
db 'File',0
.1:
db 'OpenDialog',0
db 'Test1',0
db 'Open file',0
db 'Save file',0
db 'Select dir',0
db 'Exit',0
.end:
db 0

View File

@ -1,6 +1,6 @@
;*****************************************************************************
; Macro for use Open Dialog - for Kolibri OS
; Copyright (c) 2009, Marat Zakiyanov aka Mario79, aka Mario
; Copyright (c) 2009 2010, Marat Zakiyanov aka Mario79, aka Mario
; All rights reserved.
;
; Redistribution and use in source and binary forms, with or without
@ -35,16 +35,16 @@ ret
macro use_OpenDialog
{
OpenDialog:
od_type equ dword [ebp]
od_procinfo equ dword [ebp+4]
od_com_area_name equ dword [ebp+8]
od_com_area equ dword [ebp+12]
od_opendir_pach equ dword [ebp+16]
od_dir_default_pach equ dword [ebp+20]
od_start_path equ dword [ebp+24]
od_draw_window equ dword [ebp+28]
od_status equ dword [ebp+32]
od_openfile_pach equ dword [ebp+36]
od_type equ dword [ebp] ; 0-Open, 1-Save, 2-Dir
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
od_dir_default_pach equ dword [ebp+20] ; Default path of directory,
od_start_path equ dword [ebp+24] ; Location path to OpenDialog
od_draw_window equ dword [ebp+28] ; Adress of procedure - draw_window
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
;*****************************************************************************
.init:
pusha
@ -52,7 +52,6 @@ od_openfile_pach equ dword [ebp+36]
mov ebx,[ebx+30]
mov edi,od_com_area_name
add edi,7
; mov edi,communication_area_name+7
std
mov ecx,4
@@:
@ -80,7 +79,10 @@ OpenDialog_exit
mov eax,od_com_area
test eax,eax
jz .1
mov [eax],dword 2 ; folder for open
mov ebx,od_type
mov [eax+2],bx
mov [eax],word 2 ; folder for open
mov edi,eax
add edi,4
@ -113,7 +115,7 @@ OpenDialog_exit
cmp eax,1
je .red
mov eax,od_com_area
mov ebx,[eax]
movzx ebx,word [eax]
test ebx,ebx
jz .still
cmp ebx,3