1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFileDialog
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "filedlgg.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
25 #if !defined(__UNIX__) && !defined(__DOS__)
26 #error wxFileDialog currently only supports Unix and DOS
29 #include "wx/checkbox.h"
30 #include "wx/textctrl.h"
31 #include "wx/choice.h"
32 #include "wx/checkbox.h"
33 #include "wx/stattext.h"
34 #include "wx/filedlg.h"
38 #include "wx/listctrl.h"
39 #include "wx/msgdlg.h"
41 #include "wx/bmpbuttn.h"
42 #include "wx/tokenzr.h"
43 #include "wx/mimetype.h"
45 #include "wx/module.h"
46 #include "wx/config.h"
47 #include "wx/imaglist.h"
49 #include "wx/artprov.h"
52 #include "wx/tooltip.h"
55 #include <sys/types.h>
73 //-----------------------------------------------------------------------------
75 //-----------------------------------------------------------------------------
80 wxFileData( const wxString
&name
, const wxString
&fname
);
81 wxString
GetName() const;
82 wxString
GetFullName() const;
83 wxString
GetHint() const;
84 wxString
GetEntry( int num
);
89 void MakeItem( wxListItem
&item
);
90 void SetNewName( const wxString
&name
, const wxString
&fname
);
101 wxString m_permissions
;
107 //-----------------------------------------------------------------------------
109 //-----------------------------------------------------------------------------
111 class wxFileCtrl
: public wxListCtrl
115 wxFileCtrl( wxWindow
*win
,
117 const wxString
&dirName
,
118 const wxString
&wild
,
119 const wxPoint
&pos
= wxDefaultPosition
,
120 const wxSize
&size
= wxDefaultSize
,
121 long style
= wxLC_LIST
,
122 const wxValidator
&validator
= wxDefaultValidator
,
123 const wxString
&name
= wxT("filelist") );
124 virtual ~wxFileCtrl();
126 void ChangeToListMode();
127 void ChangeToReportMode();
128 void ChangeToIconMode();
129 void ShowHidden( bool show
= TRUE
);
130 long Add( wxFileData
*fd
, wxListItem
&item
);
132 virtual void StatusbarText( wxChar
*WXUNUSED(text
) ) {};
134 void GoToParentDir();
136 void GoToDir( const wxString
&dir
);
137 void SetWild( const wxString
&wild
);
138 void GetDir( wxString
&dir
);
139 void OnListDeleteItem( wxListEvent
&event
);
140 void OnListEndLabelEdit( wxListEvent
&event
);
142 // Associate commonly used UI controls with wxFileCtrl so that they can be
143 // disabled when they cannot be used (e.g. can't go to parent directory
144 // if wxFileCtrl already is in the root dir):
145 void SetGoToParentControl(wxWindow
*ctrl
) { m_goToParentControl
= ctrl
; }
146 void SetNewDirControl(wxWindow
*ctrl
) { m_newDirControl
= ctrl
; }
149 void FreeItemData(const wxListItem
& item
);
150 void FreeAllItemsData();
156 wxWindow
*m_goToParentControl
;
157 wxWindow
*m_newDirControl
;
159 DECLARE_DYNAMIC_CLASS(wxFileCtrl
);
160 DECLARE_EVENT_TABLE()
163 // ----------------------------------------------------------------------------
164 // private classes - icons list management
165 // ----------------------------------------------------------------------------
167 class wxFileIconEntry
: public wxObject
170 wxFileIconEntry(int i
) { id
= i
; }
176 class wxFileIconsTable
181 int GetIconID(const wxString
& extension
, const wxString
& mime
= wxEmptyString
);
182 wxImageList
*GetImageList() { return &m_ImageList
; }
185 wxImageList m_ImageList
;
186 wxHashTable m_HashTable
;
189 static wxFileIconsTable
*g_IconsTable
= NULL
;
193 #define FI_EXECUTABLE 2
195 wxFileIconsTable::wxFileIconsTable() :
197 m_HashTable(wxKEY_STRING
)
199 m_HashTable
.DeleteContents(TRUE
);
201 m_ImageList
.Add(wxArtProvider::GetBitmap(wxART_FOLDER
, wxART_CMN_DIALOG
));
203 m_ImageList
.Add(wxArtProvider::GetBitmap(wxART_NORMAL_FILE
, wxART_CMN_DIALOG
));
205 if (GetIconID(wxEmptyString
, _T("application/x-executable")) == FI_UNKNOWN
)
207 m_ImageList
.Add(wxArtProvider::GetBitmap(wxART_EXECUTABLE_FILE
, wxART_CMN_DIALOG
));
208 m_HashTable
.Delete(_T("exe"));
209 m_HashTable
.Put(_T("exe"), new wxFileIconEntry(FI_EXECUTABLE
));
211 /* else put into list by GetIconID
212 (KDE defines application/x-executable for *.exe and has nice icon)
219 // VS: we don't need this function w/o wxMimeTypesManager because we'll only have
220 // one icon and we won't resize it
222 static wxBitmap
CreateAntialiasedBitmap(const wxImage
& img
)
224 wxImage
small(16, 16);
225 unsigned char *p1
, *p2
, *ps
;
226 unsigned char mr
= img
.GetMaskRed(),
227 mg
= img
.GetMaskGreen(),
228 mb
= img
.GetMaskBlue();
231 unsigned sr
, sg
, sb
, smask
;
233 p1
= img
.GetData(), p2
= img
.GetData() + 3 * 32, ps
= small
.GetData();
234 small
.SetMaskColour(mr
, mr
, mr
);
236 for (y
= 0; y
< 16; y
++)
238 for (x
= 0; x
< 16; x
++)
240 sr
= sg
= sb
= smask
= 0;
241 if (p1
[0] != mr
|| p1
[1] != mg
|| p1
[2] != mb
)
242 sr
+= p1
[0], sg
+= p1
[1], sb
+= p1
[2];
245 if (p1
[0] != mr
|| p1
[1] != mg
|| p1
[2] != mb
)
246 sr
+= p1
[0], sg
+= p1
[1], sb
+= p1
[2];
249 if (p2
[0] != mr
|| p2
[1] != mg
|| p2
[2] != mb
)
250 sr
+= p2
[0], sg
+= p2
[1], sb
+= p2
[2];
253 if (p2
[0] != mr
|| p2
[1] != mg
|| p2
[2] != mb
)
254 sr
+= p2
[0], sg
+= p2
[1], sb
+= p2
[2];
259 ps
[0] = ps
[1] = ps
[2] = mr
;
261 ps
[0] = sr
>> 2, ps
[1] = sg
>> 2, ps
[2] = sb
>> 2;
264 p1
+= 32 * 3, p2
+= 32 * 3;
267 return wxBitmap(small
);
270 // finds empty borders and return non-empty area of image:
271 static wxImage
CutEmptyBorders(const wxImage
& img
)
273 unsigned char mr
= img
.GetMaskRed(),
274 mg
= img
.GetMaskGreen(),
275 mb
= img
.GetMaskBlue();
276 unsigned char *dt
= img
.GetData(), *dttmp
;
277 unsigned w
= img
.GetWidth(), h
= img
.GetHeight();
279 unsigned top
, bottom
, left
, right
, i
;
282 #define MK_DTTMP(x,y) dttmp = dt + ((x + y * w) * 3)
283 #define NOEMPTY_PIX(empt) if (dttmp[0] != mr || dttmp[1] != mg || dttmp[2] != mb) {empt = FALSE; break;}
285 for (empt
= TRUE
, top
= 0; empt
&& top
< h
; top
++)
288 for (i
= 0; i
< w
; i
++, dttmp
+=3)
291 for (empt
= TRUE
, bottom
= h
-1; empt
&& bottom
> top
; bottom
--)
294 for (i
= 0; i
< w
; i
++, dttmp
+=3)
297 for (empt
= TRUE
, left
= 0; empt
&& left
< w
; left
++)
300 for (i
= 0; i
< h
; i
++, dttmp
+=3*w
)
303 for (empt
= TRUE
, right
= w
-1; empt
&& right
> left
; right
--)
306 for (i
= 0; i
< h
; i
++, dttmp
+=3*w
)
309 top
--, left
--, bottom
++, right
++;
311 return img
.GetSubImage(wxRect(left
, top
, right
- left
+ 1, bottom
- top
+ 1));
313 #endif // wxUSE_MIMETYPE
317 int wxFileIconsTable::GetIconID(const wxString
& extension
, const wxString
& mime
)
320 if (!extension
.IsEmpty())
322 wxFileIconEntry
*entry
= (wxFileIconEntry
*) m_HashTable
.Get(extension
);
323 if (entry
) return (entry
-> id
);
326 wxFileType
*ft
= (mime
.IsEmpty()) ?
327 wxTheMimeTypesManager
-> GetFileTypeFromExtension(extension
) :
328 wxTheMimeTypesManager
-> GetFileTypeFromMimeType(mime
);
330 if (ft
== NULL
|| (!ft
-> GetIcon(&ic
)) || (!ic
.Ok()))
332 int newid
= FI_UNKNOWN
;
333 m_HashTable
.Put(extension
, new wxFileIconEntry(newid
));
336 wxImage img
= ic
.ConvertToImage();
339 int id
= m_ImageList
.GetImageCount();
340 if (img
.GetWidth() == 16 && img
.GetHeight() == 16)
341 m_ImageList
.Add(wxBitmap(img
));
344 if (img
.GetWidth() != 32 || img
.GetHeight() != 32)
345 m_ImageList
.Add(CreateAntialiasedBitmap(CutEmptyBorders(img
).Rescale(32, 32)));
347 m_ImageList
.Add(CreateAntialiasedBitmap(img
));
349 m_HashTable
.Put(extension
, new wxFileIconEntry(id
));
352 #else // !wxUSE_MIMETYPE
354 if (extension
== wxT("exe"))
355 return FI_EXECUTABLE
;
358 #endif // wxUSE_MIMETYPE/!wxUSE_MIMETYPE
363 // ----------------------------------------------------------------------------
365 // ----------------------------------------------------------------------------
368 int ListCompare( long data1
, long data2
, long WXUNUSED(data
) )
370 wxFileData
*fd1
= (wxFileData
*)data1
;
371 wxFileData
*fd2
= (wxFileData
*)data2
;
372 if (fd1
->GetName() == wxT("..")) return -1;
373 if (fd2
->GetName() == wxT("..")) return 1;
374 if (fd1
->IsDir() && !fd2
->IsDir()) return -1;
375 if (fd2
->IsDir() && !fd1
->IsDir()) return 1;
376 return wxStrcmp( fd1
->GetName(), fd2
->GetName() );
380 #define IsTopMostDir(dir) (dir == wxT("/"))
383 #if defined(__DOS__) || defined(__WINDOWS__)
384 #define IsTopMostDir(dir) (dir.IsEmpty())
387 #if defined(__DOS__) || defined(__WINDOWS__)
388 extern bool wxIsDriveAvailable(const wxString
& dirName
);
391 //-----------------------------------------------------------------------------
393 //-----------------------------------------------------------------------------
395 wxFileData::wxFileData( const wxString
&name
, const wxString
&fname
)
400 #if defined(__DOS__) || defined(__WINDOWS__)
401 // VS: In case the file is root directory of a volume (e.g. "C:"),
402 // we don't want it stat()ed, since the drive may not be in:
403 if (name
.length() == 2 && name
[1u] == wxT(':'))
406 m_isExe
= m_isLink
= FALSE
;
413 wxStat( m_fileName
, &buff
);
415 #if defined(__UNIX__) && (!defined( __EMX__ ) && !defined(__VMS))
417 lstat( m_fileName
.fn_str(), &lbuff
);
418 m_isLink
= S_ISLNK( lbuff
.st_mode
);
419 struct tm
*t
= localtime( &lbuff
.st_mtime
);
422 struct tm
*t
= localtime( &buff
.st_mtime
);
425 // struct passwd *user = getpwuid( buff.st_uid );
426 // struct group *grp = getgrgid( buff.st_gid );
428 m_isDir
= S_ISDIR( buff
.st_mode
);
429 m_isExe
= ((buff
.st_mode
& S_IXUSR
) == S_IXUSR
);
431 m_size
= buff
.st_size
;
434 m_minute
= t
->tm_min
;
435 m_month
= t
->tm_mon
+1;
441 sprintf( buffer
, "%c%c%c",
442 ((( buff
.st_mode
& S_IRUSR
) == S_IRUSR
) ? 'r' : '-'),
443 ((( buff
.st_mode
& S_IWUSR
) == S_IWUSR
) ? 'w' : '-'),
444 ((( buff
.st_mode
& S_IXUSR
) == S_IXUSR
) ? 'x' : '-') );
446 m_permissions
= wxConvUTF8
.cMB2WC( buffer
);
448 m_permissions
= buffer
;
451 // m_permissions.sprintf( wxT("%c%c%c"),
452 // ((( buff.st_mode & S_IRUSR ) == S_IRUSR ) ? wxT('r') : wxT('-')),
453 // ((( buff.st_mode & S_IWUSR ) == S_IWUSR ) ? wxT('w') : wxT('-')),
454 // ((( buff.st_mode & S_IXUSR ) == S_IXUSR ) ? wxT('x') : wxT('-')) );
457 wxString
wxFileData::GetName() const
462 wxString
wxFileData::GetFullName() const
467 wxString
wxFileData::GetHint() const
469 wxString s
= m_fileName
;
471 if (m_isDir
) s
+= _("<DIR> ");
472 else if (m_isLink
) s
+= _("<LINK> ");
475 s
+= LongToString( m_size
);
478 s
+= IntToString( m_day
);
480 s
+= IntToString( m_month
);
482 s
+= IntToString( m_year
);
484 s
+= IntToString( m_hour
);
486 s
+= IntToString( m_minute
);
492 wxString
wxFileData::GetEntry( int num
)
504 if (m_isDir
) s
= _("<DIR>");
505 else if (m_isLink
) s
= _("<LINK>");
506 else s
= LongToString( m_size
);
511 if (m_day
< 10) s
= wxT("0"); else s
= wxT("");
512 s
+= IntToString( m_day
);
514 if (m_month
< 10) s
+= wxT("0");
515 s
+= IntToString( m_month
);
517 s
+= IntToString( m_year
);
522 if (m_hour
< 10) s
= wxT("0"); else s
= wxT("");
523 s
+= IntToString( m_hour
);
525 if (m_minute
< 10) s
+= wxT("0");
526 s
+= IntToString( m_minute
);
539 bool wxFileData::IsDir()
544 bool wxFileData::IsExe()
549 bool wxFileData::IsLink()
554 long wxFileData::GetSize()
559 void wxFileData::SetNewName( const wxString
&name
, const wxString
&fname
)
565 void wxFileData::MakeItem( wxListItem
&item
)
567 item
.m_text
= m_name
;
568 item
.ClearAttributes();
569 if (IsExe()) item
.SetTextColour(*wxRED
);
570 if (IsDir()) item
.SetTextColour(*wxBLUE
);
573 item
.m_image
= FI_FOLDER
;
575 item
.m_image
= FI_EXECUTABLE
;
576 else if (m_name
.Find(wxT('.')) != wxNOT_FOUND
)
577 item
.m_image
= g_IconsTable
->GetIconID(m_name
.AfterLast(wxT('.')));
579 item
.m_image
= FI_UNKNOWN
;
583 wxColour
*dg
= wxTheColourDatabase
->FindColour( "MEDIUM GREY" );
584 item
.SetTextColour(*dg
);
586 item
.m_data
= (long)this;
589 //-----------------------------------------------------------------------------
591 //-----------------------------------------------------------------------------
593 IMPLEMENT_DYNAMIC_CLASS(wxFileCtrl
,wxListCtrl
)
595 BEGIN_EVENT_TABLE(wxFileCtrl
,wxListCtrl
)
596 EVT_LIST_DELETE_ITEM(-1, wxFileCtrl::OnListDeleteItem
)
597 EVT_LIST_END_LABEL_EDIT(-1, wxFileCtrl::OnListEndLabelEdit
)
601 wxFileCtrl::wxFileCtrl()
603 #if defined(__UNIX__)
604 m_dirName
= wxT("/");
605 #elif defined(__DOS__)
608 m_showHidden
= FALSE
;
611 wxFileCtrl::wxFileCtrl(wxWindow
*win
, wxWindowID id
,
612 const wxString
&dirName
, const wxString
&wild
,
613 const wxPoint
&pos
, const wxSize
&size
,
614 long style
, const wxValidator
&validator
,
615 const wxString
&name
)
616 : wxListCtrl(win
, id
, pos
, size
, style
, validator
, name
)
619 g_IconsTable
= new wxFileIconsTable
;
620 wxImageList
*imageList
= g_IconsTable
->GetImageList();
622 SetImageList( imageList
, wxIMAGE_LIST_SMALL
);
624 m_goToParentControl
= m_newDirControl
= NULL
;
628 m_showHidden
= FALSE
;
632 void wxFileCtrl::ChangeToListMode()
634 SetSingleStyle( wxLC_LIST
);
638 void wxFileCtrl::ChangeToReportMode()
640 SetSingleStyle( wxLC_REPORT
);
644 void wxFileCtrl::ChangeToIconMode()
646 SetSingleStyle( wxLC_ICON
);
650 void wxFileCtrl::ShowHidden( bool show
)
656 long wxFileCtrl::Add( wxFileData
*fd
, wxListItem
&item
)
659 item
.m_mask
= wxLIST_MASK_TEXT
+ wxLIST_MASK_DATA
+ wxLIST_MASK_IMAGE
;
660 fd
->MakeItem( item
);
661 long my_style
= GetWindowStyleFlag();
662 if (my_style
& wxLC_REPORT
)
665 const int noEntries
= 5;
667 const int noEntries
= 4;
669 ret
= InsertItem( item
);
670 for (int i
= 1; i
< noEntries
; i
++)
671 SetItem( item
.m_itemId
, i
, fd
->GetEntry( i
) );
673 else if (my_style
& wxLC_LIST
)
675 ret
= InsertItem( item
);
680 void wxFileCtrl::UpdateFiles()
682 wxBusyCursor bcur
; // this may take a while...
684 long my_style
= GetWindowStyleFlag();
685 int name_col_width
= 0;
686 if (my_style
& wxLC_REPORT
)
688 if (GetColumnCount() > 0)
689 name_col_width
= GetColumnWidth( 0 );
695 if (my_style
& wxLC_REPORT
)
697 if (name_col_width
< 140) name_col_width
= 140;
698 InsertColumn( 0, _("Name"), wxLIST_FORMAT_LEFT
, name_col_width
);
699 InsertColumn( 1, _("Size"), wxLIST_FORMAT_LEFT
, 60 );
700 InsertColumn( 2, _("Date"), wxLIST_FORMAT_LEFT
, 65 );
701 InsertColumn( 3, _("Time"), wxLIST_FORMAT_LEFT
, 50 );
703 InsertColumn( 4, _("Permissions"), wxLIST_FORMAT_LEFT
, 120 );
706 wxFileData
*fd
= (wxFileData
*) NULL
;
711 #if defined(__DOS__) || defined(__WINDOWS__)
712 if ( IsTopMostDir(m_dirName
) )
714 // Pseudo-directory with all available drives listed...
715 for (int drive
= 1; drive
<= 26; drive
++)
718 path
.Printf(wxT("%c:\\"), (char)(drive
+ 'A' - 1));
719 if ( wxIsDriveAvailable(path
) )
722 fd
= new wxFileData(path
, path
);
732 if ( !IsTopMostDir(m_dirName
) )
734 wxString
p(wxPathOnly(m_dirName
));
736 if (p
.IsEmpty()) p
= wxT("/");
738 fd
= new wxFileData( wxT(".."), p
);
743 wxString
dirname(m_dirName
);
744 #if defined(__DOS__) || defined(__WINDOWS__)
745 if (dirname
.length() == 2 && dirname
[1u] == wxT(':'))
746 dirname
<< wxT('\\');
750 if ( dir
.IsOpened() )
752 wxString
dirPrefix(dirname
+ wxFILE_SEP_PATH
);
753 int hiddenFlag
= m_showHidden
? wxDIR_HIDDEN
: 0;
758 // Get the directories first (not matched against wildcards):
759 cont
= dir
.GetFirst(&f
, wxEmptyString
, wxDIR_DIRS
| hiddenFlag
);
762 fd
= new wxFileData(f
, dirPrefix
+ f
);
765 cont
= dir
.GetNext(&f
);
768 // Tokenize the wildcard string, so we can handle more than 1
769 // search pattern in a wildcard.
770 wxStringTokenizer
tokenWild(m_wild
, wxT(";"));
771 while ( tokenWild
.HasMoreTokens() )
773 cont
= dir
.GetFirst(&f
, tokenWild
.GetNextToken(),
774 wxDIR_FILES
| hiddenFlag
);
777 fd
= new wxFileData(f
, dirPrefix
+ f
);
780 cont
= dir
.GetNext(&f
);
786 SortItems(ListCompare
, 0);
788 if ( my_style
& wxLC_REPORT
)
790 SetColumnWidth(1, wxLIST_AUTOSIZE
);
791 SetColumnWidth(2, wxLIST_AUTOSIZE
);
792 SetColumnWidth(3, wxLIST_AUTOSIZE
);
795 // Finally, enable/disable context-dependent controls:
796 if ( m_goToParentControl
)
797 m_goToParentControl
->Enable(!IsTopMostDir(m_dirName
));
798 #if defined(__DOS__) || defined(__WINDOWS__)
799 if ( m_newDirControl
)
800 m_newDirControl
->Enable(!IsTopMostDir(m_dirName
));
804 void wxFileCtrl::SetWild( const wxString
&wild
)
810 void wxFileCtrl::MakeDir()
812 wxString
new_name( _("NewName") );
813 wxString
path( m_dirName
);
814 path
+= wxFILE_SEP_PATH
;
816 if (wxFileExists(path
))
818 // try NewName0, NewName1 etc.
821 new_name
= _("NewName");
823 num
.Printf( wxT("%d"), i
);
827 path
+= wxFILE_SEP_PATH
;
830 } while (wxFileExists(path
));
836 wxMessageDialog
dialog(this, _("Operation not permitted."), _("Error"), wxOK
| wxICON_ERROR
);
841 wxFileData
*fd
= new wxFileData( new_name
, path
);
845 long id
= Add( fd
, item
);
849 SortItems( ListCompare
, 0 );
850 id
= FindItem( 0, (long)fd
);
856 void wxFileCtrl::GoToParentDir()
858 if (!IsTopMostDir(m_dirName
))
860 size_t len
= m_dirName
.Len();
861 if (m_dirName
[len
-1] == wxFILE_SEP_PATH
)
862 m_dirName
.Remove( len
-1, 1 );
863 wxString
fname( wxFileNameFromPath(m_dirName
) );
864 m_dirName
= wxPathOnly( m_dirName
);
866 if (m_dirName
.IsEmpty())
867 m_dirName
= wxT("/");
870 long id
= FindItem( 0, fname
);
873 SetItemState( id
, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
879 void wxFileCtrl::GoToHomeDir()
881 wxString s
= wxGetUserHome( wxString() );
885 void wxFileCtrl::GoToDir( const wxString
&dir
)
889 SetItemState( 0, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
893 void wxFileCtrl::GetDir( wxString
&dir
)
898 void wxFileCtrl::FreeItemData(const wxListItem
& item
)
900 wxFileData
*fd
= (wxFileData
*)item
.m_data
;
904 void wxFileCtrl::OnListDeleteItem( wxListEvent
&event
)
906 FreeItemData(event
.m_item
);
909 void wxFileCtrl::FreeAllItemsData()
912 item
.m_mask
= wxLIST_MASK_DATA
;
914 item
.m_itemId
= GetNextItem( -1, wxLIST_NEXT_ALL
);
915 while ( item
.m_itemId
!= -1 )
919 item
.m_itemId
= GetNextItem( item
.m_itemId
, wxLIST_NEXT_ALL
);
923 void wxFileCtrl::OnListEndLabelEdit( wxListEvent
&event
)
925 wxFileData
*fd
= (wxFileData
*)event
.m_item
.m_data
;
928 if ((event
.GetLabel().IsEmpty()) ||
929 (event
.GetLabel() == _(".")) ||
930 (event
.GetLabel() == _("..")) ||
931 (event
.GetLabel().First( wxFILE_SEP_PATH
) != wxNOT_FOUND
))
933 wxMessageDialog
dialog(this, _("Illegal directory name."), _("Error"), wxOK
| wxICON_ERROR
);
939 wxString
new_name( wxPathOnly( fd
->GetFullName() ) );
940 new_name
+= wxFILE_SEP_PATH
;
941 new_name
+= event
.GetLabel();
945 if (wxFileExists(new_name
))
947 wxMessageDialog
dialog(this, _("File name exists already."), _("Error"), wxOK
| wxICON_ERROR
);
952 if (wxRenameFile(fd
->GetFullName(),new_name
))
954 fd
->SetNewName( new_name
, event
.GetLabel() );
955 SetItemState( event
.GetItem(), wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
956 EnsureVisible( event
.GetItem() );
960 wxMessageDialog
dialog(this, _("Operation not permitted."), _("Error"), wxOK
| wxICON_ERROR
);
966 wxFileCtrl::~wxFileCtrl()
971 //-----------------------------------------------------------------------------
973 //-----------------------------------------------------------------------------
975 #define ID_LIST_MODE (wxID_FILEDLGG )
976 #define ID_REPORT_MODE (wxID_FILEDLGG + 1)
977 #define ID_UP_DIR (wxID_FILEDLGG + 5)
978 #define ID_PARENT_DIR (wxID_FILEDLGG + 6)
979 #define ID_NEW_DIR (wxID_FILEDLGG + 7)
980 #define ID_CHOICE (wxID_FILEDLGG + 8)
981 #define ID_TEXT (wxID_FILEDLGG + 9)
982 #define ID_LIST_CTRL (wxID_FILEDLGG + 10)
983 #define ID_ACTIVATED (wxID_FILEDLGG + 11)
984 #define ID_CHECK (wxID_FILEDLGG + 12)
986 IMPLEMENT_DYNAMIC_CLASS(wxFileDialog
,wxDialog
)
988 BEGIN_EVENT_TABLE(wxFileDialog
,wxDialog
)
989 EVT_BUTTON(ID_LIST_MODE
, wxFileDialog::OnList
)
990 EVT_BUTTON(ID_REPORT_MODE
, wxFileDialog::OnReport
)
991 EVT_BUTTON(ID_UP_DIR
, wxFileDialog::OnUp
)
992 EVT_BUTTON(ID_PARENT_DIR
, wxFileDialog::OnHome
)
993 EVT_BUTTON(ID_NEW_DIR
, wxFileDialog::OnNew
)
994 EVT_BUTTON(wxID_OK
, wxFileDialog::OnListOk
)
995 EVT_LIST_ITEM_SELECTED(ID_LIST_CTRL
, wxFileDialog::OnSelected
)
996 EVT_LIST_ITEM_ACTIVATED(ID_LIST_CTRL
, wxFileDialog::OnActivated
)
997 EVT_CHOICE(ID_CHOICE
,wxFileDialog::OnChoice
)
998 EVT_TEXT_ENTER(ID_TEXT
,wxFileDialog::OnTextEnter
)
999 EVT_CHECKBOX(ID_CHECK
,wxFileDialog::OnCheck
)
1002 long wxFileDialog::s_lastViewStyle
= wxLC_LIST
;
1003 bool wxFileDialog::s_lastShowHidden
= FALSE
;
1005 wxFileDialog::wxFileDialog(wxWindow
*parent
,
1006 const wxString
& message
,
1007 const wxString
& defaultDir
,
1008 const wxString
& defaultFile
,
1009 const wxString
& wildCard
,
1011 const wxPoint
& pos
) :
1012 wxDialog( parent
, -1, message
, pos
, wxDefaultSize
, wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
)
1016 if (wxConfig::Get(FALSE
))
1018 wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ViewStyle"),
1020 wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ShowHidden"),
1024 m_message
= message
;
1025 m_dialogStyle
= style
;
1027 if (m_dialogStyle
== 0) m_dialogStyle
= wxOPEN
;
1028 if ((m_dialogStyle
& wxMULTIPLE
) && !(m_dialogStyle
& wxOPEN
))
1029 m_dialogStyle
|= wxOPEN
;
1032 if ((m_dir
.empty()) || (m_dir
== wxT(".")))
1037 size_t len
= m_dir
.Len();
1038 if ((len
> 1) && (m_dir
[len
-1] == wxFILE_SEP_PATH
))
1039 m_dir
.Remove( len
-1, 1 );
1042 m_path
+= wxFILE_SEP_PATH
;
1043 m_path
+= defaultFile
;
1044 m_fileName
= defaultFile
;
1045 m_wildCard
= wildCard
;
1047 m_filterExtension
= wxEmptyString
;
1049 // interpret wildcards
1051 if (m_wildCard
.IsEmpty())
1052 m_wildCard
= _("All files (*)|*");
1054 wxStringTokenizer
tokens( m_wildCard
, wxT("|") );
1056 wxString firstWildText
;
1057 if (tokens
.CountTokens() == 1)
1059 firstWildText
= tokens
.GetNextToken();
1060 firstWild
= firstWildText
;
1064 wxASSERT_MSG( tokens
.CountTokens() % 2 == 0, wxT("Wrong file type descripition") );
1065 firstWildText
= tokens
.GetNextToken();
1066 firstWild
= tokens
.GetNextToken();
1068 if ( firstWild
.Left( 2 ) == wxT("*.") )
1069 m_filterExtension
= firstWild
.Mid( 1 );
1070 if ( m_filterExtension
== ".*" ) m_filterExtension
= wxEmptyString
;
1074 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
1076 wxBoxSizer
*buttonsizer
= new wxBoxSizer( wxHORIZONTAL
);
1078 wxBitmapButton
*but
;
1080 but
= new wxBitmapButton(this, ID_LIST_MODE
,
1081 wxArtProvider::GetBitmap(wxART_LIST_VIEW
, wxART_CMN_DIALOG
));
1083 but
->SetToolTip( _("View files as a list view") );
1085 buttonsizer
->Add( but
, 0, wxALL
, 5 );
1087 but
= new wxBitmapButton(this, ID_REPORT_MODE
,
1088 wxArtProvider::GetBitmap(wxART_REPORT_VIEW
, wxART_CMN_DIALOG
));
1090 but
->SetToolTip( _("View files as a detailed view") );
1092 buttonsizer
->Add( but
, 0, wxALL
, 5 );
1094 buttonsizer
->Add( 30, 5, 1 );
1096 wxWindow
*butDirUp
=
1097 new wxBitmapButton(this, ID_UP_DIR
,
1098 wxArtProvider::GetBitmap(wxART_GO_DIR_UP
, wxART_CMN_DIALOG
));
1100 butDirUp
->SetToolTip( _("Go to parent directory") );
1102 buttonsizer
->Add( butDirUp
, 0, wxALL
, 5 );
1104 #ifndef __DOS__ // VS: Home directory is meaningless in MS-DOS...
1105 but
= new wxBitmapButton(this, ID_PARENT_DIR
,
1106 wxArtProvider::GetBitmap(wxART_GO_HOME
, wxART_CMN_DIALOG
));
1108 but
->SetToolTip( _("Go to home directory") );
1110 buttonsizer
->Add( but
, 0, wxALL
, 5);
1112 buttonsizer
->Add( 20, 20 );
1115 wxWindow
*butNewDir
=
1116 new wxBitmapButton(this, ID_NEW_DIR
,
1117 wxArtProvider::GetBitmap(wxART_NEW_DIR
, wxART_CMN_DIALOG
));
1119 butNewDir
->SetToolTip( _("Create new directory") );
1121 buttonsizer
->Add( butNewDir
, 0, wxALL
, 5 );
1123 if (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
)
1124 mainsizer
->Add( buttonsizer
, 0, wxALL
| wxEXPAND
, 0 );
1126 mainsizer
->Add( buttonsizer
, 0, wxALL
| wxEXPAND
, 5 );
1128 wxBoxSizer
*staticsizer
= new wxBoxSizer( wxHORIZONTAL
);
1129 if (wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA
)
1130 staticsizer
->Add( new wxStaticText( this, -1, _("Current directory:") ), 0, wxRIGHT
, 10 );
1131 m_static
= new wxStaticText( this, -1, m_dir
);
1132 staticsizer
->Add( m_static
, 1 );
1133 mainsizer
->Add( staticsizer
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxBOTTOM
, 10 );
1135 if (m_dialogStyle
& wxMULTIPLE
)
1136 m_list
= new wxFileCtrl( this, ID_LIST_CTRL
, m_dir
, firstWild
, wxDefaultPosition
,
1137 wxSize(540,200), s_lastViewStyle
| wxSUNKEN_BORDER
);
1139 m_list
= new wxFileCtrl( this, ID_LIST_CTRL
, m_dir
, firstWild
, wxDefaultPosition
,
1140 wxSize(540,200), s_lastViewStyle
| wxSUNKEN_BORDER
| wxLC_SINGLE_SEL
);
1141 m_list
->ShowHidden(s_lastShowHidden
);
1142 m_list
->SetNewDirControl(butNewDir
);
1143 m_list
->SetGoToParentControl(butDirUp
);
1145 if (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
)
1147 // PDAs have a different screen layout
1148 mainsizer
->Add( m_list
, 1, wxEXPAND
| wxLEFT
|wxRIGHT
, 5 );
1150 wxBoxSizer
*choicesizer
= new wxBoxSizer( wxHORIZONTAL
);
1151 m_choice
= new wxChoice( this, ID_CHOICE
);
1152 choicesizer
->Add( m_choice
, 1, wxCENTER
|wxALL
, 5 );
1153 mainsizer
->Add( choicesizer
, 0, wxEXPAND
);
1155 wxBoxSizer
*textsizer
= new wxBoxSizer( wxHORIZONTAL
);
1156 m_text
= new wxTextCtrl( this, ID_TEXT
, m_fileName
, wxDefaultPosition
, wxDefaultSize
, wxPROCESS_ENTER
);
1157 textsizer
->Add( m_text
, 1, wxCENTER
| wxALL
, 5 );
1158 mainsizer
->Add( textsizer
, 0, wxEXPAND
);
1160 m_check
= new wxCheckBox( this, ID_CHECK
, _("Show hidden files") );
1161 m_check
->SetValue( s_lastShowHidden
);
1162 textsizer
->Add( m_check
, 0, wxCENTER
|wxALL
, 5 );
1164 buttonsizer
= new wxBoxSizer( wxHORIZONTAL
);
1165 buttonsizer
->Add( new wxButton( this, wxID_OK
, _("OK") ), 0, wxCENTER
| wxALL
, 5 );
1166 buttonsizer
->Add( new wxButton( this, wxID_CANCEL
, _("Cancel") ), 0, wxCENTER
| wxALL
, 5 );
1167 mainsizer
->Add( buttonsizer
, 0, wxALIGN_RIGHT
);
1171 mainsizer
->Add( m_list
, 1, wxEXPAND
| wxLEFT
|wxRIGHT
, 10 );
1173 wxBoxSizer
*textsizer
= new wxBoxSizer( wxHORIZONTAL
);
1174 m_text
= new wxTextCtrl( this, ID_TEXT
, m_fileName
, wxDefaultPosition
, wxDefaultSize
, wxPROCESS_ENTER
);
1175 textsizer
->Add( m_text
, 1, wxCENTER
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
1176 textsizer
->Add( new wxButton( this, wxID_OK
, _("OK") ), 0, wxCENTER
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
1177 mainsizer
->Add( textsizer
, 0, wxEXPAND
);
1179 wxBoxSizer
*choicesizer
= new wxBoxSizer( wxHORIZONTAL
);
1180 m_choice
= new wxChoice( this, ID_CHOICE
);
1181 choicesizer
->Add( m_choice
, 1, wxCENTER
|wxALL
, 10 );
1182 m_check
= new wxCheckBox( this, ID_CHECK
, _("Show hidden files") );
1183 m_check
->SetValue( s_lastShowHidden
);
1184 choicesizer
->Add( m_check
, 0, wxCENTER
|wxALL
, 10 );
1185 choicesizer
->Add( new wxButton( this, wxID_CANCEL
, _("Cancel") ), 0, wxCENTER
| wxALL
, 10 );
1186 mainsizer
->Add( choicesizer
, 0, wxEXPAND
);
1189 m_choice
->Append( firstWildText
, (void*) new wxString( firstWild
) );
1190 while (tokens
.HasMoreTokens())
1192 firstWildText
= tokens
.GetNextToken();
1193 firstWild
= tokens
.GetNextToken();
1194 m_choice
->Append( firstWildText
, (void*) new wxString( firstWild
) );
1196 m_choice
->SetSelection( 0 );
1198 SetAutoLayout( TRUE
);
1199 SetSizer( mainsizer
);
1201 mainsizer
->Fit( this );
1202 mainsizer
->SetSizeHints( this );
1207 if (m_fileName.IsEmpty())
1214 wxFileDialog::~wxFileDialog()
1216 if (wxConfig::Get(FALSE
))
1218 wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ViewStyle"),
1220 wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ShowHidden"),
1225 void wxFileDialog::SetFilterIndex( int filterindex
)
1227 m_choice
->SetSelection( filterindex
);
1228 wxCommandEvent event
;
1229 event
.SetInt( filterindex
);
1233 void wxFileDialog::OnChoice( wxCommandEvent
&event
)
1235 int index
= (int)event
.GetInt();
1236 wxString
*str
= (wxString
*) m_choice
->GetClientData( index
);
1237 m_list
->SetWild( *str
);
1238 m_filterIndex
= index
;
1239 if ( str
-> Left( 2 ) == wxT("*.") )
1241 m_filterExtension
= str
-> Mid( 1 );
1242 if (m_filterExtension
== ".*") m_filterExtension
= wxEmptyString
;
1245 m_filterExtension
= wxEmptyString
;
1248 void wxFileDialog::OnCheck( wxCommandEvent
&event
)
1250 m_list
->ShowHidden( (s_lastShowHidden
= event
.GetInt() != 0) );
1253 void wxFileDialog::OnActivated( wxListEvent
&event
)
1255 HandleAction( event
.m_item
.m_text
);
1258 void wxFileDialog::OnTextEnter( wxCommandEvent
&WXUNUSED(event
) )
1260 wxCommandEvent
cevent(wxEVT_COMMAND_BUTTON_CLICKED
, wxID_OK
);
1261 cevent
.SetEventObject( this );
1262 GetEventHandler()->ProcessEvent( cevent
);
1265 void wxFileDialog::OnSelected( wxListEvent
&event
)
1267 wxString
filename( event
.m_item
.m_text
);
1268 if (filename
== wxT("..")) return;
1271 m_list
->GetDir( dir
);
1272 if (!IsTopMostDir(dir
))
1273 dir
+= wxFILE_SEP_PATH
;
1275 if (wxDirExists(dir
)) return;
1277 m_text
->SetValue( filename
);
1280 void wxFileDialog::HandleAction( const wxString
&fn
)
1282 wxString
filename( fn
);
1284 m_list
->GetDir( dir
);
1285 if (filename
.IsEmpty()) return;
1286 if (filename
== wxT(".")) return;
1288 if (filename
== wxT(".."))
1290 m_list
->GoToParentDir();
1292 m_list
->GetDir( dir
);
1293 m_static
->SetLabel( dir
);
1298 if (filename
== wxT("~"))
1300 m_list
->GoToHomeDir();
1302 m_list
->GetDir( dir
);
1303 m_static
->SetLabel( dir
);
1307 if (filename
[0u] == wxT('~'))
1309 filename
.Remove( 0, 1 );
1310 wxString
tmp( wxGetUserHome() );
1317 if ((filename
.Find(wxT('*')) != wxNOT_FOUND
) ||
1318 (filename
.Find(wxT('?')) != wxNOT_FOUND
))
1320 if (filename
.Find(wxFILE_SEP_PATH
) != wxNOT_FOUND
)
1322 wxMessageBox(_("Illegal file specification."), _("Error"), wxOK
| wxICON_ERROR
);
1325 m_list
->SetWild( filename
);
1329 if (!IsTopMostDir(dir
))
1330 dir
+= wxFILE_SEP_PATH
;
1331 if (!wxIsAbsolutePath(filename
))
1337 if (wxDirExists(filename
))
1339 m_list
->GoToDir( filename
);
1340 m_list
->GetDir( dir
);
1341 m_static
->SetLabel( dir
);
1346 if ( (m_dialogStyle
& wxSAVE
) && (m_dialogStyle
& wxOVERWRITE_PROMPT
) )
1348 if (filename
.Find( wxT('.') ) == wxNOT_FOUND
||
1349 filename
.AfterLast( wxT('.') ).Find( wxFILE_SEP_PATH
) != wxNOT_FOUND
)
1350 filename
<< m_filterExtension
;
1351 if (wxFileExists( filename
))
1354 msg
.Printf( _("File '%s' already exists, do you really want to "
1355 "overwrite it?"), filename
.c_str() );
1357 if (wxMessageBox(msg
, _("Confirm"), wxYES_NO
) != wxYES
)
1361 else if ( m_dialogStyle
& wxOPEN
)
1363 if ( !wxFileExists( filename
) )
1364 if (filename
.Find( wxT('.') ) == wxNOT_FOUND
||
1365 filename
.AfterLast( wxT('.') ).Find( wxFILE_SEP_PATH
) != wxNOT_FOUND
)
1366 filename
<< m_filterExtension
;
1368 if ( m_dialogStyle
& wxFILE_MUST_EXIST
)
1370 if ( !wxFileExists( filename
) )
1372 wxMessageBox(_("Please choose an existing file."), _("Error"), wxOK
| wxICON_ERROR
);
1378 SetPath( filename
);
1380 // change to the directory where the user went if asked
1381 if ( m_dialogStyle
& wxCHANGE_DIR
)
1384 wxSplitPath(filename
, &cwd
, NULL
, NULL
);
1386 if ( cwd
!= wxGetWorkingDirectory() )
1388 wxSetWorkingDirectory(cwd
);
1392 wxCommandEvent event
;
1393 wxDialog::OnOK(event
);
1396 void wxFileDialog::OnListOk( wxCommandEvent
&WXUNUSED(event
) )
1398 HandleAction( m_text
->GetValue() );
1401 void wxFileDialog::OnList( wxCommandEvent
&WXUNUSED(event
) )
1403 m_list
->ChangeToListMode();
1404 s_lastViewStyle
= wxLC_LIST
;
1408 void wxFileDialog::OnReport( wxCommandEvent
&WXUNUSED(event
) )
1410 m_list
->ChangeToReportMode();
1411 s_lastViewStyle
= wxLC_REPORT
;
1415 void wxFileDialog::OnUp( wxCommandEvent
&WXUNUSED(event
) )
1417 m_list
->GoToParentDir();
1420 m_list
->GetDir( dir
);
1421 m_static
->SetLabel( dir
);
1424 void wxFileDialog::OnHome( wxCommandEvent
&WXUNUSED(event
) )
1426 m_list
->GoToHomeDir();
1429 m_list
->GetDir( dir
);
1430 m_static
->SetLabel( dir
);
1435 void wxFileDialog::OnNew( wxCommandEvent
&WXUNUSED(event
) )
1440 void wxFileDialog::SetPath( const wxString
& path
)
1442 // not only set the full path but also update filename and dir
1447 wxSplitPath(path
, &m_dir
, &m_fileName
, &ext
);
1450 m_fileName
+= wxT(".");
1456 void wxFileDialog::GetPaths( wxArrayString
& paths
) const
1459 if (m_list
->GetSelectedItemCount() == 0)
1461 paths
.Add( GetPath() );
1465 paths
.Alloc( m_list
->GetSelectedItemCount() );
1468 m_list
->GetDir( dir
);
1470 if (dir
!= wxT("/"))
1472 dir
+= wxFILE_SEP_PATH
;
1475 item
.m_mask
= wxLIST_MASK_TEXT
;
1477 item
.m_itemId
= m_list
->GetNextItem( -1, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1478 while ( item
.m_itemId
!= -1 )
1480 m_list
->GetItem( item
);
1481 paths
.Add( dir
+ item
.m_text
);
1482 item
.m_itemId
= m_list
->GetNextItem( item
.m_itemId
,
1483 wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1487 void wxFileDialog::GetFilenames(wxArrayString
& files
) const
1490 if (m_list
->GetSelectedItemCount() == 0)
1492 files
.Add( GetFilename() );
1495 files
.Alloc( m_list
->GetSelectedItemCount() );
1498 item
.m_mask
= wxLIST_MASK_TEXT
;
1500 item
.m_itemId
= m_list
->GetNextItem( -1, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1501 while ( item
.m_itemId
!= -1 )
1503 m_list
->GetItem( item
);
1504 files
.Add( item
.m_text
);
1505 item
.m_itemId
= m_list
->GetNextItem( item
.m_itemId
,
1506 wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1512 // ----------------------------------------------------------------------------
1514 // ----------------------------------------------------------------------------
1517 wxFileSelectorEx(const wxChar
*message
,
1518 const wxChar
*default_path
,
1519 const wxChar
*default_filename
,
1520 int *WXUNUSED(indexDefaultExtension
),
1521 const wxChar
*wildcard
,
1526 // TODO: implement this somehow
1527 return wxFileSelector(message
, default_path
, default_filename
, wxT(""),
1528 wildcard
, flags
, parent
, x
, y
);
1531 wxString
wxFileSelector( const wxChar
*title
,
1532 const wxChar
*defaultDir
, const wxChar
*defaultFileName
,
1533 const wxChar
*defaultExtension
, const wxChar
*filter
, int flags
,
1534 wxWindow
*parent
, int x
, int y
)
1537 if ( defaultExtension
&& !filter
)
1538 filter2
= wxString(wxT("*.")) + wxString(defaultExtension
) ;
1542 wxString defaultDirString
;
1544 defaultDirString
= defaultDir
;
1546 wxString defaultFilenameString
;
1547 if (defaultFileName
)
1548 defaultFilenameString
= defaultFileName
;
1550 wxFileDialog
fileDialog( parent
, title
, defaultDirString
, defaultFilenameString
, filter2
, flags
, wxPoint(x
, y
) );
1552 if ( fileDialog
.ShowModal() == wxID_OK
)
1554 return fileDialog
.GetPath();
1558 return wxEmptyString
;
1562 static wxString
GetWildcardString(const wxChar
*ext
)
1567 if ( *ext
== wxT('.') )
1570 wild
<< _T("*.") << ext
;
1572 else // no extension specified
1574 wild
= wxFileSelectorDefaultWildcardStr
;
1580 wxString
wxLoadFileSelector(const wxChar
*what
,
1582 const wxChar
*nameDef
,
1586 if ( what
&& *what
)
1587 prompt
= wxString::Format(_("Load %s file"), what
);
1589 prompt
= _("Load file");
1591 return wxFileSelector(prompt
, NULL
, nameDef
, ext
,
1592 GetWildcardString(ext
), 0, parent
);
1595 wxString
wxSaveFileSelector(const wxChar
*what
,
1597 const wxChar
*nameDef
,
1601 if ( what
&& *what
)
1602 prompt
= wxString::Format(_("Save %s file"), what
);
1604 prompt
= _("Save file");
1606 return wxFileSelector(prompt
, NULL
, nameDef
, ext
,
1607 GetWildcardString(ext
), 0, parent
);
1610 // A module to allow icons table cleanup
1612 class wxFileDialogGenericModule
: public wxModule
1614 DECLARE_DYNAMIC_CLASS(wxFileDialogGenericModule
)
1616 wxFileDialogGenericModule() {}
1617 bool OnInit() { return TRUE
; }
1618 void OnExit() { if (g_IconsTable
) {delete g_IconsTable
; g_IconsTable
= NULL
;} }
1621 IMPLEMENT_DYNAMIC_CLASS(wxFileDialogGenericModule
, wxModule
)
1623 #endif // wxUSE_FILEDLG