1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFileDialog
4 // Author: Robert Roebling
8 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "filedlgg.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
33 #if !defined(__UNIX__) && !defined(__DOS__) && !defined(__WIN32__)
34 #error wxFileDialog currently only supports Unix, win32 and DOS
37 #include "wx/checkbox.h"
38 #include "wx/textctrl.h"
39 #include "wx/choice.h"
40 #include "wx/checkbox.h"
41 #include "wx/stattext.h"
42 #include "wx/filedlg.h"
46 #include "wx/listctrl.h"
47 #include "wx/msgdlg.h"
49 #include "wx/bmpbuttn.h"
50 #include "wx/tokenzr.h"
51 #include "wx/mimetype.h"
53 #include "wx/module.h"
54 #include "wx/config.h"
55 #include "wx/imaglist.h"
57 #include "wx/artprov.h"
60 #include "wx/tooltip.h"
63 #include <sys/types.h>
79 #if defined(__UNIX__) || defined(__DOS__)
83 // ----------------------------------------------------------------------------
85 // ----------------------------------------------------------------------------
87 // the list ctrl fields in report view
100 //-----------------------------------------------------------------------------
102 //-----------------------------------------------------------------------------
107 wxFileData( const wxString
&name
, const wxString
&fname
);
108 wxString
GetName() const;
109 wxString
GetFullName() const;
110 wxString
GetHint() const;
111 wxString
GetEntry( FileListField num
) const;
113 bool IsDir() const { return m_isDir
; }
114 bool IsLink() const { return m_isLink
; }
115 bool IsExe() const { return m_isExe
; }
116 long GetSize() const { return m_size
; }
118 void MakeItem( wxListItem
&item
);
119 void SetNewName( const wxString
&name
, const wxString
&fname
);
130 wxString m_permissions
;
136 //-----------------------------------------------------------------------------
138 //-----------------------------------------------------------------------------
140 class wxFileCtrl
: public wxListCtrl
144 wxFileCtrl( wxWindow
*win
,
145 wxStaticText
*labelDir
,
147 const wxString
&wild
,
149 const wxPoint
&pos
= wxDefaultPosition
,
150 const wxSize
&size
= wxDefaultSize
,
151 long style
= wxLC_LIST
,
152 const wxValidator
&validator
= wxDefaultValidator
,
153 const wxString
&name
= wxT("filelist") );
154 virtual ~wxFileCtrl();
156 void ChangeToListMode();
157 void ChangeToReportMode();
158 void ChangeToIconMode();
159 void ShowHidden( bool show
= TRUE
);
160 long Add( wxFileData
*fd
, wxListItem
&item
);
162 virtual void StatusbarText( wxChar
*WXUNUSED(text
) ) {};
164 void GoToParentDir();
166 void GoToDir( const wxString
&dir
);
167 void SetWild( const wxString
&wild
);
168 void GetDir( wxString
&dir
);
169 void OnListDeleteItem( wxListEvent
&event
);
170 void OnListEndLabelEdit( wxListEvent
&event
);
172 // Associate commonly used UI controls with wxFileCtrl so that they can be
173 // disabled when they cannot be used (e.g. can't go to parent directory
174 // if wxFileCtrl already is in the root dir):
175 void SetGoToParentControl(wxWindow
*ctrl
) { m_goToParentControl
= ctrl
; }
176 void SetNewDirControl(wxWindow
*ctrl
) { m_newDirControl
= ctrl
; }
179 void FreeItemData(const wxListItem
& item
);
180 void FreeAllItemsData();
186 wxWindow
*m_goToParentControl
;
187 wxWindow
*m_newDirControl
;
189 // the label showing the current directory
190 wxStaticText
*m_labelDir
;
192 DECLARE_DYNAMIC_CLASS(wxFileCtrl
);
193 DECLARE_EVENT_TABLE()
196 // ----------------------------------------------------------------------------
197 // private classes - icons list management
198 // ----------------------------------------------------------------------------
200 class wxFileIconEntry
: public wxObject
203 wxFileIconEntry(int i
) { id
= i
; }
209 class wxFileIconsTable
214 int GetIconID(const wxString
& extension
, const wxString
& mime
= wxEmptyString
);
215 wxImageList
*GetImageList() { return &m_ImageList
; }
218 wxImageList m_ImageList
;
219 wxHashTable m_HashTable
;
222 static wxFileIconsTable
*g_IconsTable
= NULL
;
226 #define FI_EXECUTABLE 2
228 wxFileIconsTable::wxFileIconsTable() :
230 m_HashTable(wxKEY_STRING
)
232 m_HashTable
.DeleteContents(TRUE
);
234 m_ImageList
.Add(wxArtProvider::GetBitmap(wxART_FOLDER
, wxART_CMN_DIALOG
));
236 m_ImageList
.Add(wxArtProvider::GetBitmap(wxART_NORMAL_FILE
, wxART_CMN_DIALOG
));
238 if (GetIconID(wxEmptyString
, _T("application/x-executable")) == FI_UNKNOWN
)
240 m_ImageList
.Add(wxArtProvider::GetBitmap(wxART_EXECUTABLE_FILE
, wxART_CMN_DIALOG
));
241 m_HashTable
.Delete(_T("exe"));
242 m_HashTable
.Put(_T("exe"), new wxFileIconEntry(FI_EXECUTABLE
));
244 /* else put into list by GetIconID
245 (KDE defines application/x-executable for *.exe and has nice icon)
252 // VS: we don't need this function w/o wxMimeTypesManager because we'll only have
253 // one icon and we won't resize it
255 static wxBitmap
CreateAntialiasedBitmap(const wxImage
& img
)
257 wxImage
small(16, 16);
258 unsigned char *p1
, *p2
, *ps
;
259 unsigned char mr
= img
.GetMaskRed(),
260 mg
= img
.GetMaskGreen(),
261 mb
= img
.GetMaskBlue();
264 unsigned sr
, sg
, sb
, smask
;
266 p1
= img
.GetData(), p2
= img
.GetData() + 3 * 32, ps
= small
.GetData();
267 small
.SetMaskColour(mr
, mr
, mr
);
269 for (y
= 0; y
< 16; y
++)
271 for (x
= 0; x
< 16; x
++)
273 sr
= sg
= sb
= smask
= 0;
274 if (p1
[0] != mr
|| p1
[1] != mg
|| p1
[2] != mb
)
275 sr
+= p1
[0], sg
+= p1
[1], sb
+= p1
[2];
278 if (p1
[0] != mr
|| p1
[1] != mg
|| p1
[2] != mb
)
279 sr
+= p1
[0], sg
+= p1
[1], sb
+= p1
[2];
282 if (p2
[0] != mr
|| p2
[1] != mg
|| p2
[2] != mb
)
283 sr
+= p2
[0], sg
+= p2
[1], sb
+= p2
[2];
286 if (p2
[0] != mr
|| p2
[1] != mg
|| p2
[2] != mb
)
287 sr
+= p2
[0], sg
+= p2
[1], sb
+= p2
[2];
292 ps
[0] = ps
[1] = ps
[2] = mr
;
294 ps
[0] = sr
>> 2, ps
[1] = sg
>> 2, ps
[2] = sb
>> 2;
297 p1
+= 32 * 3, p2
+= 32 * 3;
300 return wxBitmap(small
);
303 // finds empty borders and return non-empty area of image:
304 static wxImage
CutEmptyBorders(const wxImage
& img
)
306 unsigned char mr
= img
.GetMaskRed(),
307 mg
= img
.GetMaskGreen(),
308 mb
= img
.GetMaskBlue();
309 unsigned char *dt
= img
.GetData(), *dttmp
;
310 unsigned w
= img
.GetWidth(), h
= img
.GetHeight();
312 unsigned top
, bottom
, left
, right
, i
;
315 #define MK_DTTMP(x,y) dttmp = dt + ((x + y * w) * 3)
316 #define NOEMPTY_PIX(empt) if (dttmp[0] != mr || dttmp[1] != mg || dttmp[2] != mb) {empt = FALSE; break;}
318 for (empt
= TRUE
, top
= 0; empt
&& top
< h
; top
++)
321 for (i
= 0; i
< w
; i
++, dttmp
+=3)
324 for (empt
= TRUE
, bottom
= h
-1; empt
&& bottom
> top
; bottom
--)
327 for (i
= 0; i
< w
; i
++, dttmp
+=3)
330 for (empt
= TRUE
, left
= 0; empt
&& left
< w
; left
++)
333 for (i
= 0; i
< h
; i
++, dttmp
+=3*w
)
336 for (empt
= TRUE
, right
= w
-1; empt
&& right
> left
; right
--)
339 for (i
= 0; i
< h
; i
++, dttmp
+=3*w
)
342 top
--, left
--, bottom
++, right
++;
344 return img
.GetSubImage(wxRect(left
, top
, right
- left
+ 1, bottom
- top
+ 1));
346 #endif // wxUSE_MIMETYPE
350 int wxFileIconsTable::GetIconID(const wxString
& extension
, const wxString
& mime
)
353 if (!extension
.IsEmpty())
355 wxFileIconEntry
*entry
= (wxFileIconEntry
*) m_HashTable
.Get(extension
);
356 if (entry
) return (entry
-> id
);
359 wxFileType
*ft
= (mime
.IsEmpty()) ?
360 wxTheMimeTypesManager
-> GetFileTypeFromExtension(extension
) :
361 wxTheMimeTypesManager
-> GetFileTypeFromMimeType(mime
);
363 if (ft
== NULL
|| (!ft
-> GetIcon(&ic
)) || (!ic
.Ok()))
365 int newid
= FI_UNKNOWN
;
366 m_HashTable
.Put(extension
, new wxFileIconEntry(newid
));
370 wxBitmap
myBitmap (ic
.GetWidth(), ic
.GetHeight() ) ;
372 memDC
.SelectObject( myBitmap
);
373 memDC
.DrawIcon(ic
,0,0);
374 memDC
.SelectObject( wxNullBitmap
);
375 wxImage img
= myBitmap
.ConvertToImage();
377 wxImage img
= ic
.ConvertToImage();
381 int id
= m_ImageList
.GetImageCount();
382 if (img
.GetWidth() == 16 && img
.GetHeight() == 16)
383 m_ImageList
.Add(wxBitmap(img
));
386 if (img
.GetWidth() != 32 || img
.GetHeight() != 32)
387 m_ImageList
.Add(CreateAntialiasedBitmap(CutEmptyBorders(img
).Rescale(32, 32)));
389 m_ImageList
.Add(CreateAntialiasedBitmap(img
));
391 m_HashTable
.Put(extension
, new wxFileIconEntry(id
));
394 #else // !wxUSE_MIMETYPE
396 if (extension
== wxT("exe"))
397 return FI_EXECUTABLE
;
400 #endif // wxUSE_MIMETYPE/!wxUSE_MIMETYPE
405 // ----------------------------------------------------------------------------
407 // ----------------------------------------------------------------------------
410 int ListCompare( long data1
, long data2
, long WXUNUSED(data
))
412 wxFileData
*fd1
= (wxFileData
*)data1
;
413 wxFileData
*fd2
= (wxFileData
*)data2
;
414 if (fd1
->GetName() == wxT("..")) return -1;
415 if (fd2
->GetName() == wxT("..")) return 1;
416 if (fd1
->IsDir() && !fd2
->IsDir()) return -1;
417 if (fd2
->IsDir() && !fd1
->IsDir()) return 1;
418 return wxStrcmp( fd1
->GetName(), fd2
->GetName() );
422 #define IsTopMostDir(dir) (dir == wxT("/"))
425 #if defined(__DOS__) || defined(__WINDOWS__)
426 #define IsTopMostDir(dir) (dir.IsEmpty())
429 #if defined(__DOS__) || defined(__WINDOWS__)
430 extern bool wxIsDriveAvailable(const wxString
& dirName
);
433 //-----------------------------------------------------------------------------
435 //-----------------------------------------------------------------------------
437 wxFileData::wxFileData( const wxString
&name
, const wxString
&fname
)
442 #if defined(__DOS__) || defined(__WINDOWS__)
443 // VS: In case the file is root directory of a volume (e.g. "C:"),
444 // we don't want it stat()ed, since the drive may not be in:
445 if (name
.length() == 2 && name
[1u] == wxT(':'))
448 m_isExe
= m_isLink
= FALSE
;
455 wxStat( m_fileName
, &buff
);
457 #if defined(__UNIX__) && (!defined( __EMX__ ) && !defined(__VMS))
459 lstat( m_fileName
.fn_str(), &lbuff
);
460 m_isLink
= S_ISLNK( lbuff
.st_mode
);
461 struct tm
*t
= localtime( &lbuff
.st_mtime
);
464 struct tm
*t
= localtime( &buff
.st_mtime
);
467 // struct passwd *user = getpwuid( buff.st_uid );
468 // struct group *grp = getgrgid( buff.st_gid );
470 m_isDir
= S_ISDIR( buff
.st_mode
);
471 m_isExe
= ((buff
.st_mode
& S_IXUSR
) == S_IXUSR
);
473 m_size
= buff
.st_size
;
476 m_minute
= t
->tm_min
;
477 m_month
= t
->tm_mon
+1;
483 sprintf( buffer
, "%c%c%c",
484 ((( buff
.st_mode
& S_IRUSR
) == S_IRUSR
) ? 'r' : '-'),
485 ((( buff
.st_mode
& S_IWUSR
) == S_IWUSR
) ? 'w' : '-'),
486 ((( buff
.st_mode
& S_IXUSR
) == S_IXUSR
) ? 'x' : '-') );
488 m_permissions
= wxConvUTF8
.cMB2WC( buffer
);
490 m_permissions
= buffer
;
493 // m_permissions.sprintf( wxT("%c%c%c"),
494 // ((( buff.st_mode & S_IRUSR ) == S_IRUSR ) ? wxT('r') : wxT('-')),
495 // ((( buff.st_mode & S_IWUSR ) == S_IWUSR ) ? wxT('w') : wxT('-')),
496 // ((( buff.st_mode & S_IXUSR ) == S_IXUSR ) ? wxT('x') : wxT('-')) );
499 wxString
wxFileData::GetName() const
504 wxString
wxFileData::GetFullName() const
509 wxString
wxFileData::GetHint() const
511 wxString s
= m_fileName
;
513 if (m_isDir
) s
+= wxT("<DIR> ");
514 else if (m_isLink
) s
+= wxT("<LINK> ");
517 s
+= LongToString( m_size
);
520 s
+= IntToString( m_day
);
522 s
+= IntToString( m_month
);
524 s
+= IntToString( m_year
);
526 s
+= IntToString( m_hour
);
528 s
+= IntToString( m_minute
);
534 wxString
wxFileData::GetEntry( FileListField num
) const
549 s
.Printf(_T("%ld"), m_size
);
553 s
.Printf(_T("%02d.%02d.%d"), m_day
, m_month
, m_year
);
557 s
.Printf(_T("%02d:%02d"), m_hour
, m_minute
);
567 wxFAIL_MSG( _T("unexpected field in wxFileData::GetEntry()") );
573 void wxFileData::SetNewName( const wxString
&name
, const wxString
&fname
)
579 void wxFileData::MakeItem( wxListItem
&item
)
581 item
.m_text
= m_name
;
582 item
.ClearAttributes();
584 item
.SetTextColour(*wxRED
);
586 item
.SetTextColour(*wxBLUE
);
589 item
.m_image
= FI_FOLDER
;
591 item
.m_image
= FI_EXECUTABLE
;
592 else if (m_name
.Find(wxT('.')) != wxNOT_FOUND
)
593 item
.m_image
= g_IconsTable
->GetIconID(m_name
.AfterLast(wxT('.')));
595 item
.m_image
= FI_UNKNOWN
;
599 wxColour
*dg
= wxTheColourDatabase
->FindColour( _T("MEDIUM GREY") );
600 item
.SetTextColour(*dg
);
602 item
.m_data
= (long)this;
605 //-----------------------------------------------------------------------------
607 //-----------------------------------------------------------------------------
609 IMPLEMENT_DYNAMIC_CLASS(wxFileCtrl
,wxListCtrl
)
611 BEGIN_EVENT_TABLE(wxFileCtrl
,wxListCtrl
)
612 EVT_LIST_DELETE_ITEM(-1, wxFileCtrl::OnListDeleteItem
)
613 EVT_LIST_END_LABEL_EDIT(-1, wxFileCtrl::OnListEndLabelEdit
)
617 wxFileCtrl::wxFileCtrl()
619 m_showHidden
= FALSE
;
622 wxFileCtrl::wxFileCtrl(wxWindow
*win
,
623 wxStaticText
*labelDir
,
625 const wxString
& wild
,
630 const wxValidator
&validator
,
631 const wxString
&name
)
632 : wxListCtrl(win
, id
, pos
, size
, style
, validator
, name
),
636 g_IconsTable
= new wxFileIconsTable
;
637 wxImageList
*imageList
= g_IconsTable
->GetImageList();
639 SetImageList( imageList
, wxIMAGE_LIST_SMALL
);
641 m_goToParentControl
=
642 m_newDirControl
= NULL
;
644 m_labelDir
= labelDir
;
646 m_showHidden
= showHidden
;
649 void wxFileCtrl::ChangeToListMode()
651 SetSingleStyle( wxLC_LIST
);
655 void wxFileCtrl::ChangeToReportMode()
657 SetSingleStyle( wxLC_REPORT
);
661 void wxFileCtrl::ChangeToIconMode()
663 SetSingleStyle( wxLC_ICON
);
667 void wxFileCtrl::ShowHidden( bool show
)
673 long wxFileCtrl::Add( wxFileData
*fd
, wxListItem
&item
)
676 item
.m_mask
= wxLIST_MASK_TEXT
+ wxLIST_MASK_DATA
+ wxLIST_MASK_IMAGE
;
677 fd
->MakeItem( item
);
678 long my_style
= GetWindowStyleFlag();
679 if (my_style
& wxLC_REPORT
)
681 ret
= InsertItem( item
);
682 for (int i
= 1; i
< FileList_Max
; i
++)
683 SetItem( item
.m_itemId
, i
, fd
->GetEntry((FileListField
)i
) );
685 else if (my_style
& wxLC_LIST
)
687 ret
= InsertItem( item
);
692 void wxFileCtrl::UpdateFiles()
694 // don't do anything before ShowModal() call which sets m_dirName
695 if ( m_dirName
.empty() )
698 wxBusyCursor bcur
; // this may take a while...
700 long my_style
= GetWindowStyleFlag();
701 int name_col_width
= 0;
702 if (my_style
& wxLC_REPORT
)
704 if (GetColumnCount() > 0)
705 name_col_width
= GetColumnWidth( 0 );
711 if (my_style
& wxLC_REPORT
)
713 if (name_col_width
< 140) name_col_width
= 140;
714 InsertColumn( 0, _("Name"), wxLIST_FORMAT_LEFT
, name_col_width
);
715 InsertColumn( 1, _("Size"), wxLIST_FORMAT_LEFT
, 60 );
716 InsertColumn( 2, _("Date"), wxLIST_FORMAT_LEFT
, 65 );
717 InsertColumn( 3, _("Time"), wxLIST_FORMAT_LEFT
, 50 );
719 InsertColumn( 4, _("Permissions"), wxLIST_FORMAT_LEFT
, 120 );
722 wxFileData
*fd
= (wxFileData
*) NULL
;
727 #if defined(__DOS__) || defined(__WINDOWS__)
728 if ( IsTopMostDir(m_dirName
) )
730 // Pseudo-directory with all available drives listed...
731 for (int drive
= 1; drive
<= 26; drive
++)
734 path
.Printf(wxT("%c:\\"), (char)(drive
+ 'A' - 1));
735 if ( wxIsDriveAvailable(path
) )
738 fd
= new wxFileData(path
, path
);
748 if ( !IsTopMostDir(m_dirName
) )
750 wxString
p(wxPathOnly(m_dirName
));
752 if (p
.IsEmpty()) p
= wxT("/");
754 fd
= new wxFileData( wxT(".."), p
);
759 wxString
dirname(m_dirName
);
760 #if defined(__DOS__) || defined(__WINDOWS__)
761 if (dirname
.length() == 2 && dirname
[1u] == wxT(':'))
762 dirname
<< wxT('\\');
766 if ( dir
.IsOpened() )
768 wxString
dirPrefix(dirname
+ wxFILE_SEP_PATH
);
769 int hiddenFlag
= m_showHidden
? wxDIR_HIDDEN
: 0;
774 // Get the directories first (not matched against wildcards):
775 cont
= dir
.GetFirst(&f
, wxEmptyString
, wxDIR_DIRS
| hiddenFlag
);
778 fd
= new wxFileData(f
, dirPrefix
+ f
);
781 cont
= dir
.GetNext(&f
);
784 // Tokenize the wildcard string, so we can handle more than 1
785 // search pattern in a wildcard.
786 wxStringTokenizer
tokenWild(m_wild
, wxT(";"));
787 while ( tokenWild
.HasMoreTokens() )
789 cont
= dir
.GetFirst(&f
, tokenWild
.GetNextToken(),
790 wxDIR_FILES
| hiddenFlag
);
793 fd
= new wxFileData(f
, dirPrefix
+ f
);
796 cont
= dir
.GetNext(&f
);
802 SortItems((wxListCtrlCompare
)ListCompare
, 0);
804 if ( my_style
& wxLC_REPORT
)
806 SetColumnWidth(1, wxLIST_AUTOSIZE
);
807 SetColumnWidth(2, wxLIST_AUTOSIZE
);
808 SetColumnWidth(3, wxLIST_AUTOSIZE
);
811 // Finally, enable/disable context-dependent controls:
812 if ( m_goToParentControl
)
813 m_goToParentControl
->Enable(!IsTopMostDir(m_dirName
));
814 #if defined(__DOS__) || defined(__WINDOWS__)
815 if ( m_newDirControl
)
816 m_newDirControl
->Enable(!IsTopMostDir(m_dirName
));
820 void wxFileCtrl::SetWild( const wxString
&wild
)
826 void wxFileCtrl::MakeDir()
828 wxString
new_name( _("NewName") );
829 wxString
path( m_dirName
);
830 path
+= wxFILE_SEP_PATH
;
832 if (wxFileExists(path
))
834 // try NewName0, NewName1 etc.
837 new_name
= _("NewName");
839 num
.Printf( wxT("%d"), i
);
843 path
+= wxFILE_SEP_PATH
;
846 } while (wxFileExists(path
));
852 wxMessageDialog
dialog(this, _("Operation not permitted."), _("Error"), wxOK
| wxICON_ERROR
);
857 wxFileData
*fd
= new wxFileData( new_name
, path
);
861 long id
= Add( fd
, item
);
865 SortItems( (wxListCtrlCompare
) ListCompare
, 0 );
866 id
= FindItem( 0, (long)fd
);
872 void wxFileCtrl::GoToParentDir()
874 if (!IsTopMostDir(m_dirName
))
876 size_t len
= m_dirName
.Len();
877 if (m_dirName
[len
-1] == wxFILE_SEP_PATH
)
878 m_dirName
.Remove( len
-1, 1 );
879 wxString
fname( wxFileNameFromPath(m_dirName
) );
880 m_dirName
= wxPathOnly( m_dirName
);
882 if (m_dirName
.IsEmpty())
883 m_dirName
= wxT("/");
886 long id
= FindItem( 0, fname
);
889 SetItemState( id
, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
893 m_labelDir
->SetLabel(m_dirName
);
897 void wxFileCtrl::GoToHomeDir()
899 wxString s
= wxGetUserHome( wxString() );
903 void wxFileCtrl::GoToDir( const wxString
&dir
)
907 SetItemState( 0, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
910 m_labelDir
->SetLabel(dir
);
913 void wxFileCtrl::GetDir( wxString
&dir
)
918 void wxFileCtrl::FreeItemData(const wxListItem
& item
)
920 wxFileData
*fd
= (wxFileData
*)item
.m_data
;
924 void wxFileCtrl::OnListDeleteItem( wxListEvent
&event
)
926 FreeItemData(event
.m_item
);
929 void wxFileCtrl::FreeAllItemsData()
932 item
.m_mask
= wxLIST_MASK_DATA
;
934 item
.m_itemId
= GetNextItem( -1, wxLIST_NEXT_ALL
);
935 while ( item
.m_itemId
!= -1 )
939 item
.m_itemId
= GetNextItem( item
.m_itemId
, wxLIST_NEXT_ALL
);
943 void wxFileCtrl::OnListEndLabelEdit( wxListEvent
&event
)
945 wxFileData
*fd
= (wxFileData
*)event
.m_item
.m_data
;
948 if ((event
.GetLabel().IsEmpty()) ||
949 (event
.GetLabel() == _(".")) ||
950 (event
.GetLabel() == _("..")) ||
951 (event
.GetLabel().First( wxFILE_SEP_PATH
) != wxNOT_FOUND
))
953 wxMessageDialog
dialog(this, _("Illegal directory name."), _("Error"), wxOK
| wxICON_ERROR
);
959 wxString
new_name( wxPathOnly( fd
->GetFullName() ) );
960 new_name
+= wxFILE_SEP_PATH
;
961 new_name
+= event
.GetLabel();
965 if (wxFileExists(new_name
))
967 wxMessageDialog
dialog(this, _("File name exists already."), _("Error"), wxOK
| wxICON_ERROR
);
972 if (wxRenameFile(fd
->GetFullName(),new_name
))
974 fd
->SetNewName( new_name
, event
.GetLabel() );
975 SetItemState( event
.GetItem(), wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
976 EnsureVisible( event
.GetItem() );
980 wxMessageDialog
dialog(this, _("Operation not permitted."), _("Error"), wxOK
| wxICON_ERROR
);
986 wxFileCtrl::~wxFileCtrl()
991 //-----------------------------------------------------------------------------
993 //-----------------------------------------------------------------------------
995 #define ID_LIST_MODE (wxID_FILEDLGG )
996 #define ID_REPORT_MODE (wxID_FILEDLGG + 1)
997 #define ID_UP_DIR (wxID_FILEDLGG + 5)
998 #define ID_PARENT_DIR (wxID_FILEDLGG + 6)
999 #define ID_NEW_DIR (wxID_FILEDLGG + 7)
1000 #define ID_CHOICE (wxID_FILEDLGG + 8)
1001 #define ID_TEXT (wxID_FILEDLGG + 9)
1002 #define ID_LIST_CTRL (wxID_FILEDLGG + 10)
1003 #define ID_ACTIVATED (wxID_FILEDLGG + 11)
1004 #define ID_CHECK (wxID_FILEDLGG + 12)
1006 IMPLEMENT_DYNAMIC_CLASS(wxFileDialog
,wxDialog
)
1008 BEGIN_EVENT_TABLE(wxFileDialog
,wxDialog
)
1009 EVT_BUTTON(ID_LIST_MODE
, wxFileDialog::OnList
)
1010 EVT_BUTTON(ID_REPORT_MODE
, wxFileDialog::OnReport
)
1011 EVT_BUTTON(ID_UP_DIR
, wxFileDialog::OnUp
)
1012 EVT_BUTTON(ID_PARENT_DIR
, wxFileDialog::OnHome
)
1013 EVT_BUTTON(ID_NEW_DIR
, wxFileDialog::OnNew
)
1014 EVT_BUTTON(wxID_OK
, wxFileDialog::OnListOk
)
1015 EVT_LIST_ITEM_SELECTED(ID_LIST_CTRL
, wxFileDialog::OnSelected
)
1016 EVT_LIST_ITEM_ACTIVATED(ID_LIST_CTRL
, wxFileDialog::OnActivated
)
1017 EVT_CHOICE(ID_CHOICE
,wxFileDialog::OnChoiceFilter
)
1018 EVT_TEXT_ENTER(ID_TEXT
,wxFileDialog::OnTextEnter
)
1019 EVT_TEXT(ID_TEXT
,wxFileDialog::OnTextChange
)
1020 EVT_CHECKBOX(ID_CHECK
,wxFileDialog::OnCheck
)
1023 long wxFileDialog::ms_lastViewStyle
= wxLC_LIST
;
1024 bool wxFileDialog::ms_lastShowHidden
= FALSE
;
1026 wxFileDialog::wxFileDialog(wxWindow
*parent
,
1027 const wxString
& message
,
1028 const wxString
& defaultDir
,
1029 const wxString
& defaultFile
,
1030 const wxString
& wildCard
,
1032 const wxPoint
& pos
)
1033 : wxDialog( parent
, -1, message
, pos
, wxDefaultSize
,
1034 wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
)
1036 if (wxConfig::Get(FALSE
))
1038 wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ViewStyle"),
1040 wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ShowHidden"),
1041 &ms_lastShowHidden
);
1044 m_message
= message
;
1045 m_dialogStyle
= style
;
1047 if (m_dialogStyle
== 0)
1048 m_dialogStyle
= wxOPEN
;
1049 if ((m_dialogStyle
& wxMULTIPLE
) && !(m_dialogStyle
& wxOPEN
))
1050 m_dialogStyle
|= wxOPEN
;
1053 if ((m_dir
.empty()) || (m_dir
== wxT(".")))
1058 size_t len
= m_dir
.Len();
1059 if ((len
> 1) && (m_dir
[len
-1] == wxFILE_SEP_PATH
))
1060 m_dir
.Remove( len
-1, 1 );
1063 m_path
+= wxFILE_SEP_PATH
;
1064 m_path
+= defaultFile
;
1065 m_fileName
= defaultFile
;
1066 m_wildCard
= wildCard
;
1068 m_filterExtension
= wxEmptyString
;
1070 // interpret wildcards
1072 if (m_wildCard
.IsEmpty())
1073 m_wildCard
= _("All files (*)|*");
1075 wxStringTokenizer
tokens( m_wildCard
, wxT("|") );
1077 wxString firstWildText
;
1078 if (tokens
.CountTokens() == 1)
1080 firstWildText
= tokens
.GetNextToken();
1081 firstWild
= firstWildText
;
1085 wxASSERT_MSG( tokens
.CountTokens() % 2 == 0, wxT("Wrong file type descripition") );
1086 firstWildText
= tokens
.GetNextToken();
1087 firstWild
= tokens
.GetNextToken();
1089 if ( firstWild
.Left( 2 ) == wxT("*.") )
1090 m_filterExtension
= firstWild
.Mid( 1 );
1091 if ( m_filterExtension
== wxT(".*") )
1092 m_filterExtension
= wxEmptyString
;
1096 bool is_pda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
1098 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
1100 wxBoxSizer
*buttonsizer
= new wxBoxSizer( wxHORIZONTAL
);
1102 wxBitmapButton
*but
;
1104 but
= new wxBitmapButton(this, ID_LIST_MODE
,
1105 wxArtProvider::GetBitmap(wxART_LIST_VIEW
, wxART_CMN_DIALOG
));
1107 but
->SetToolTip( _("View files as a list view") );
1109 buttonsizer
->Add( but
, 0, wxALL
, 5 );
1111 but
= new wxBitmapButton(this, ID_REPORT_MODE
,
1112 wxArtProvider::GetBitmap(wxART_REPORT_VIEW
, wxART_CMN_DIALOG
));
1114 but
->SetToolTip( _("View files as a detailed view") );
1116 buttonsizer
->Add( but
, 0, wxALL
, 5 );
1118 buttonsizer
->Add( 30, 5, 1 );
1120 wxWindow
*butDirUp
=
1121 new wxBitmapButton(this, ID_UP_DIR
,
1122 wxArtProvider::GetBitmap(wxART_GO_DIR_UP
, wxART_CMN_DIALOG
));
1124 butDirUp
->SetToolTip( _("Go to parent directory") );
1126 buttonsizer
->Add( butDirUp
, 0, wxALL
, 5 );
1128 #ifndef __DOS__ // VS: Home directory is meaningless in MS-DOS...
1129 but
= new wxBitmapButton(this, ID_PARENT_DIR
,
1130 wxArtProvider::GetBitmap(wxART_GO_HOME
, wxART_CMN_DIALOG
));
1132 but
->SetToolTip( _("Go to home directory") );
1134 buttonsizer
->Add( but
, 0, wxALL
, 5);
1136 buttonsizer
->Add( 20, 20 );
1139 wxWindow
*butNewDir
=
1140 new wxBitmapButton(this, ID_NEW_DIR
,
1141 wxArtProvider::GetBitmap(wxART_NEW_DIR
, wxART_CMN_DIALOG
));
1143 butNewDir
->SetToolTip( _("Create new directory") );
1145 buttonsizer
->Add( butNewDir
, 0, wxALL
, 5 );
1148 mainsizer
->Add( buttonsizer
, 0, wxALL
| wxEXPAND
, 0 );
1150 mainsizer
->Add( buttonsizer
, 0, wxALL
| wxEXPAND
, 5 );
1152 wxBoxSizer
*staticsizer
= new wxBoxSizer( wxHORIZONTAL
);
1154 staticsizer
->Add( new wxStaticText( this, -1, _("Current directory:") ), 0, wxRIGHT
, 10 );
1155 m_static
= new wxStaticText( this, -1, m_dir
);
1156 staticsizer
->Add( m_static
, 1 );
1157 mainsizer
->Add( staticsizer
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxBOTTOM
, 10 );
1159 long style2
= ms_lastViewStyle
| wxSUNKEN_BORDER
;
1160 if ( !(m_dialogStyle
& wxMULTIPLE
) )
1161 style2
|= wxLC_SINGLE_SEL
;
1163 m_list
= new wxFileCtrl( this, m_static
, ID_LIST_CTRL
,
1164 firstWild
, ms_lastShowHidden
,
1165 wxDefaultPosition
, wxSize(540,200),
1168 m_list
->SetNewDirControl(butNewDir
);
1169 m_list
->SetGoToParentControl(butDirUp
);
1173 // PDAs have a different screen layout
1174 mainsizer
->Add( m_list
, 1, wxEXPAND
| wxLEFT
|wxRIGHT
, 5 );
1176 wxBoxSizer
*choicesizer
= new wxBoxSizer( wxHORIZONTAL
);
1177 m_choice
= new wxChoice( this, ID_CHOICE
);
1178 choicesizer
->Add( m_choice
, 1, wxCENTER
|wxALL
, 5 );
1179 mainsizer
->Add( choicesizer
, 0, wxEXPAND
);
1181 wxBoxSizer
*textsizer
= new wxBoxSizer( wxHORIZONTAL
);
1182 m_text
= new wxTextCtrl( this, ID_TEXT
, m_fileName
, wxDefaultPosition
, wxDefaultSize
, wxPROCESS_ENTER
);
1183 textsizer
->Add( m_text
, 1, wxCENTER
| wxALL
, 5 );
1184 mainsizer
->Add( textsizer
, 0, wxEXPAND
);
1186 m_check
= new wxCheckBox( this, ID_CHECK
, _("Show hidden files") );
1187 m_check
->SetValue( ms_lastShowHidden
);
1188 textsizer
->Add( m_check
, 0, wxCENTER
|wxALL
, 5 );
1190 buttonsizer
= new wxBoxSizer( wxHORIZONTAL
);
1191 buttonsizer
->Add( new wxButton( this, wxID_OK
, _("OK") ), 0, wxCENTER
| wxALL
, 5 );
1192 buttonsizer
->Add( new wxButton( this, wxID_CANCEL
, _("Cancel") ), 0, wxCENTER
| wxALL
, 5 );
1193 mainsizer
->Add( buttonsizer
, 0, wxALIGN_RIGHT
);
1197 mainsizer
->Add( m_list
, 1, wxEXPAND
| wxLEFT
|wxRIGHT
, 10 );
1199 wxBoxSizer
*textsizer
= new wxBoxSizer( wxHORIZONTAL
);
1200 m_text
= new wxTextCtrl( this, ID_TEXT
, m_fileName
, wxDefaultPosition
, wxDefaultSize
, wxPROCESS_ENTER
);
1201 textsizer
->Add( m_text
, 1, wxCENTER
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
1202 textsizer
->Add( new wxButton( this, wxID_OK
, _("OK") ), 0, wxCENTER
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
1203 mainsizer
->Add( textsizer
, 0, wxEXPAND
);
1205 wxBoxSizer
*choicesizer
= new wxBoxSizer( wxHORIZONTAL
);
1206 m_choice
= new wxChoice( this, ID_CHOICE
);
1207 choicesizer
->Add( m_choice
, 1, wxCENTER
|wxALL
, 10 );
1208 m_check
= new wxCheckBox( this, ID_CHECK
, _("Show hidden files") );
1209 m_check
->SetValue( ms_lastShowHidden
);
1210 choicesizer
->Add( m_check
, 0, wxCENTER
|wxALL
, 10 );
1211 choicesizer
->Add( new wxButton( this, wxID_CANCEL
, _("Cancel") ), 0, wxCENTER
| wxALL
, 10 );
1212 mainsizer
->Add( choicesizer
, 0, wxEXPAND
);
1215 m_choice
->Append( firstWildText
, (void*) new wxString( firstWild
) );
1216 while (tokens
.HasMoreTokens())
1218 firstWildText
= tokens
.GetNextToken();
1219 firstWild
= tokens
.GetNextToken();
1220 m_choice
->Append( firstWildText
, (void*) new wxString( firstWild
) );
1222 m_choice
->SetSelection( 0 );
1224 SetAutoLayout( TRUE
);
1225 SetSizer( mainsizer
);
1227 mainsizer
->Fit( this );
1228 mainsizer
->SetSizeHints( this );
1235 wxFileDialog::~wxFileDialog()
1237 if (wxConfig::Get(FALSE
))
1239 wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ViewStyle"),
1241 wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ShowHidden"),
1246 int wxFileDialog::ShowModal()
1248 m_list
->GoToDir(m_dir
);
1249 m_text
->SetValue(m_fileName
);
1251 return wxDialog::ShowModal();
1254 void wxFileDialog::DoSetFilterIndex(int filterindex
)
1256 wxString
*str
= (wxString
*) m_choice
->GetClientData( filterindex
);
1257 m_list
->SetWild( *str
);
1258 m_filterIndex
= filterindex
;
1259 if ( str
->Left(2) == wxT("*.") )
1261 m_filterExtension
= str
->Mid(2);
1262 if (m_filterExtension
== _T("*"))
1263 m_filterExtension
.clear();
1267 m_filterExtension
.clear();
1271 void wxFileDialog::SetFilterIndex( int filterindex
)
1273 m_choice
->SetSelection( filterindex
);
1275 DoSetFilterIndex(filterindex
);
1278 void wxFileDialog::OnChoiceFilter( wxCommandEvent
&event
)
1280 DoSetFilterIndex((int)event
.GetInt());
1283 void wxFileDialog::OnCheck( wxCommandEvent
&event
)
1285 m_list
->ShowHidden( (ms_lastShowHidden
= event
.GetInt() != 0) );
1288 void wxFileDialog::OnActivated( wxListEvent
&event
)
1290 HandleAction( event
.m_item
.m_text
);
1293 void wxFileDialog::OnTextEnter( wxCommandEvent
&WXUNUSED(event
) )
1295 wxCommandEvent
cevent(wxEVT_COMMAND_BUTTON_CLICKED
, wxID_OK
);
1296 cevent
.SetEventObject( this );
1297 GetEventHandler()->ProcessEvent( cevent
);
1300 static bool ignoreChanges
= FALSE
;
1302 void wxFileDialog::OnTextChange( wxCommandEvent
&WXUNUSED(event
) )
1306 // Clear selections. Otherwise when the user types in a value they may
1307 // not get the file whose name they typed.
1308 if (m_list
->GetSelectedItemCount() > 0)
1310 long item
= m_list
->GetNextItem(-1, wxLIST_NEXT_ALL
,
1311 wxLIST_STATE_SELECTED
);
1312 while ( item
!= -1 )
1314 m_list
->SetItemState(item
,0, wxLIST_STATE_SELECTED
);
1315 item
= m_list
->GetNextItem(item
, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1321 void wxFileDialog::OnSelected( wxListEvent
&event
)
1323 wxString
filename( event
.m_item
.m_text
);
1324 if (filename
== wxT("..")) return;
1327 m_list
->GetDir( dir
);
1328 if (!IsTopMostDir(dir
))
1329 dir
+= wxFILE_SEP_PATH
;
1331 if (wxDirExists(dir
)) return;
1333 ignoreChanges
= TRUE
;
1334 m_text
->SetValue( filename
);
1335 ignoreChanges
= FALSE
;
1338 void wxFileDialog::HandleAction( const wxString
&fn
)
1340 wxString
filename( fn
);
1342 m_list
->GetDir( dir
);
1343 if (filename
.IsEmpty()) return;
1344 if (filename
== wxT(".")) return;
1346 if (filename
== wxT(".."))
1348 m_list
->GoToParentDir();
1354 if (filename
== wxT("~"))
1356 m_list
->GoToHomeDir();
1361 if (filename
[0u] == wxT('~'))
1363 filename
.Remove( 0, 1 );
1364 wxString
tmp( wxGetUserHome() );
1371 if ((filename
.Find(wxT('*')) != wxNOT_FOUND
) ||
1372 (filename
.Find(wxT('?')) != wxNOT_FOUND
))
1374 if (filename
.Find(wxFILE_SEP_PATH
) != wxNOT_FOUND
)
1376 wxMessageBox(_("Illegal file specification."), _("Error"), wxOK
| wxICON_ERROR
);
1379 m_list
->SetWild( filename
);
1383 if (!IsTopMostDir(dir
))
1384 dir
+= wxFILE_SEP_PATH
;
1385 if (!wxIsAbsolutePath(filename
))
1391 if (wxDirExists(filename
))
1393 m_list
->GoToDir( filename
);
1397 // append the default extension to the filename if it doesn't have any
1399 // VZ: the logic of testing for !wxFileExists() only for the open file
1400 // dialog is not entirely clear to me, why don't we allow saving to a
1401 // file without extension as well?
1402 if ( !(m_dialogStyle
& wxOPEN
) || !wxFileExists(filename
) )
1405 wxSplitPath(filename
, NULL
, NULL
, &ext
);
1408 // append the first extension of the filter string
1409 filename
+= m_filterExtension
.BeforeFirst(_T(';'));
1413 // check that the file [doesn't] exist if necessary
1414 if ( (m_dialogStyle
& wxSAVE
) &&
1415 (m_dialogStyle
& wxOVERWRITE_PROMPT
) &&
1416 wxFileExists( filename
) )
1419 msg
.Printf( _("File '%s' already exists, do you really want to "
1420 "overwrite it?"), filename
.c_str() );
1422 if (wxMessageBox(msg
, _("Confirm"), wxYES_NO
) != wxYES
)
1425 else if ( (m_dialogStyle
& wxOPEN
) &&
1426 (m_dialogStyle
& wxFILE_MUST_EXIST
) &&
1427 !wxFileExists(filename
) )
1429 wxMessageBox(_("Please choose an existing file."), _("Error"),
1430 wxOK
| wxICON_ERROR
);
1433 SetPath( filename
);
1435 // change to the directory where the user went if asked
1436 if ( m_dialogStyle
& wxCHANGE_DIR
)
1439 wxSplitPath(filename
, &cwd
, NULL
, NULL
);
1441 if ( cwd
!= wxGetWorkingDirectory() )
1443 wxSetWorkingDirectory(cwd
);
1447 wxCommandEvent event
;
1448 wxDialog::OnOK(event
);
1451 void wxFileDialog::OnListOk( wxCommandEvent
&WXUNUSED(event
) )
1453 HandleAction( m_text
->GetValue() );
1456 void wxFileDialog::OnList( wxCommandEvent
&WXUNUSED(event
) )
1458 m_list
->ChangeToListMode();
1459 ms_lastViewStyle
= wxLC_LIST
;
1463 void wxFileDialog::OnReport( wxCommandEvent
&WXUNUSED(event
) )
1465 m_list
->ChangeToReportMode();
1466 ms_lastViewStyle
= wxLC_REPORT
;
1470 void wxFileDialog::OnUp( wxCommandEvent
&WXUNUSED(event
) )
1472 m_list
->GoToParentDir();
1476 void wxFileDialog::OnHome( wxCommandEvent
&WXUNUSED(event
) )
1478 m_list
->GoToHomeDir();
1482 void wxFileDialog::OnNew( wxCommandEvent
&WXUNUSED(event
) )
1487 void wxFileDialog::SetPath( const wxString
& path
)
1489 // not only set the full path but also update filename and dir
1491 if ( !path
.empty() )
1494 wxSplitPath(path
, &m_dir
, &m_fileName
, &ext
);
1497 m_fileName
+= wxT(".");
1503 void wxFileDialog::GetPaths( wxArrayString
& paths
) const
1506 if (m_list
->GetSelectedItemCount() == 0)
1508 paths
.Add( GetPath() );
1512 paths
.Alloc( m_list
->GetSelectedItemCount() );
1515 m_list
->GetDir( dir
);
1517 if (dir
!= wxT("/"))
1519 dir
+= wxFILE_SEP_PATH
;
1522 item
.m_mask
= wxLIST_MASK_TEXT
;
1524 item
.m_itemId
= m_list
->GetNextItem( -1, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1525 while ( item
.m_itemId
!= -1 )
1527 m_list
->GetItem( item
);
1528 paths
.Add( dir
+ item
.m_text
);
1529 item
.m_itemId
= m_list
->GetNextItem( item
.m_itemId
,
1530 wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1534 void wxFileDialog::GetFilenames(wxArrayString
& files
) const
1537 if (m_list
->GetSelectedItemCount() == 0)
1539 files
.Add( GetFilename() );
1542 files
.Alloc( m_list
->GetSelectedItemCount() );
1545 item
.m_mask
= wxLIST_MASK_TEXT
;
1547 item
.m_itemId
= m_list
->GetNextItem( -1, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1548 while ( item
.m_itemId
!= -1 )
1550 m_list
->GetItem( item
);
1551 files
.Add( item
.m_text
);
1552 item
.m_itemId
= m_list
->GetNextItem( item
.m_itemId
,
1553 wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1559 // ----------------------------------------------------------------------------
1561 // ----------------------------------------------------------------------------
1564 wxFileSelectorEx(const wxChar
*message
,
1565 const wxChar
*default_path
,
1566 const wxChar
*default_filename
,
1567 int *WXUNUSED(indexDefaultExtension
),
1568 const wxChar
*wildcard
,
1573 // TODO: implement this somehow
1574 return wxFileSelector(message
, default_path
, default_filename
, wxT(""),
1575 wildcard
, flags
, parent
, x
, y
);
1578 wxString
wxFileSelector( const wxChar
*title
,
1579 const wxChar
*defaultDir
, const wxChar
*defaultFileName
,
1580 const wxChar
*defaultExtension
, const wxChar
*filter
, int flags
,
1581 wxWindow
*parent
, int x
, int y
)
1584 if ( defaultExtension
&& !filter
)
1585 filter2
= wxString(wxT("*.")) + wxString(defaultExtension
) ;
1589 wxString defaultDirString
;
1591 defaultDirString
= defaultDir
;
1593 wxString defaultFilenameString
;
1594 if (defaultFileName
)
1595 defaultFilenameString
= defaultFileName
;
1597 wxFileDialog
fileDialog( parent
, title
, defaultDirString
, defaultFilenameString
, filter2
, flags
, wxPoint(x
, y
) );
1599 if ( fileDialog
.ShowModal() == wxID_OK
)
1601 return fileDialog
.GetPath();
1605 return wxEmptyString
;
1609 static wxString
GetWildcardString(const wxChar
*ext
)
1614 if ( *ext
== wxT('.') )
1617 wild
<< _T("*.") << ext
;
1619 else // no extension specified
1621 wild
= wxFileSelectorDefaultWildcardStr
;
1627 wxString
wxLoadFileSelector(const wxChar
*what
,
1629 const wxChar
*nameDef
,
1633 if ( what
&& *what
)
1634 prompt
= wxString::Format(_("Load %s file"), what
);
1636 prompt
= _("Load file");
1638 return wxFileSelector(prompt
, NULL
, nameDef
, ext
,
1639 GetWildcardString(ext
), 0, parent
);
1642 wxString
wxSaveFileSelector(const wxChar
*what
,
1644 const wxChar
*nameDef
,
1648 if ( what
&& *what
)
1649 prompt
= wxString::Format(_("Save %s file"), what
);
1651 prompt
= _("Save file");
1653 return wxFileSelector(prompt
, NULL
, nameDef
, ext
,
1654 GetWildcardString(ext
), 0, parent
);
1657 // A module to allow icons table cleanup
1659 class wxFileDialogGenericModule
: public wxModule
1661 DECLARE_DYNAMIC_CLASS(wxFileDialogGenericModule
)
1663 wxFileDialogGenericModule() {}
1664 bool OnInit() { return TRUE
; }
1665 void OnExit() { if (g_IconsTable
) {delete g_IconsTable
; g_IconsTable
= NULL
;} }
1668 IMPLEMENT_DYNAMIC_CLASS(wxFileDialogGenericModule
, wxModule
)
1670 #endif // wxUSE_FILEDLG