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__)
34 #error wxFileDialog currently only supports Unix 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>
81 // ----------------------------------------------------------------------------
83 // ----------------------------------------------------------------------------
85 // the list ctrl fields in report view
98 //-----------------------------------------------------------------------------
100 //-----------------------------------------------------------------------------
105 wxFileData( const wxString
&name
, const wxString
&fname
);
106 wxString
GetName() const;
107 wxString
GetFullName() const;
108 wxString
GetHint() const;
109 wxString
GetEntry( FileListField num
) const;
111 bool IsDir() const { return m_isDir
; }
112 bool IsLink() const { return m_isLink
; }
113 bool IsExe() const { return m_isExe
; }
114 long GetSize() const { return m_size
; }
116 void MakeItem( wxListItem
&item
);
117 void SetNewName( const wxString
&name
, const wxString
&fname
);
128 wxString m_permissions
;
134 //-----------------------------------------------------------------------------
136 //-----------------------------------------------------------------------------
138 class wxFileCtrl
: public wxListCtrl
142 wxFileCtrl( wxWindow
*win
,
143 wxStaticText
*labelDir
,
145 const wxString
&wild
,
147 const wxPoint
&pos
= wxDefaultPosition
,
148 const wxSize
&size
= wxDefaultSize
,
149 long style
= wxLC_LIST
,
150 const wxValidator
&validator
= wxDefaultValidator
,
151 const wxString
&name
= wxT("filelist") );
152 virtual ~wxFileCtrl();
154 void ChangeToListMode();
155 void ChangeToReportMode();
156 void ChangeToIconMode();
157 void ShowHidden( bool show
= TRUE
);
158 long Add( wxFileData
*fd
, wxListItem
&item
);
160 virtual void StatusbarText( wxChar
*WXUNUSED(text
) ) {};
162 void GoToParentDir();
164 void GoToDir( const wxString
&dir
);
165 void SetWild( const wxString
&wild
);
166 void GetDir( wxString
&dir
);
167 void OnListDeleteItem( wxListEvent
&event
);
168 void OnListEndLabelEdit( wxListEvent
&event
);
170 // Associate commonly used UI controls with wxFileCtrl so that they can be
171 // disabled when they cannot be used (e.g. can't go to parent directory
172 // if wxFileCtrl already is in the root dir):
173 void SetGoToParentControl(wxWindow
*ctrl
) { m_goToParentControl
= ctrl
; }
174 void SetNewDirControl(wxWindow
*ctrl
) { m_newDirControl
= ctrl
; }
177 void FreeItemData(const wxListItem
& item
);
178 void FreeAllItemsData();
184 wxWindow
*m_goToParentControl
;
185 wxWindow
*m_newDirControl
;
187 // the label showing the current directory
188 wxStaticText
*m_labelDir
;
190 DECLARE_DYNAMIC_CLASS(wxFileCtrl
);
191 DECLARE_EVENT_TABLE()
194 // ----------------------------------------------------------------------------
195 // private classes - icons list management
196 // ----------------------------------------------------------------------------
198 class wxFileIconEntry
: public wxObject
201 wxFileIconEntry(int i
) { id
= i
; }
207 class wxFileIconsTable
212 int GetIconID(const wxString
& extension
, const wxString
& mime
= wxEmptyString
);
213 wxImageList
*GetImageList() { return &m_ImageList
; }
216 wxImageList m_ImageList
;
217 wxHashTable m_HashTable
;
220 static wxFileIconsTable
*g_IconsTable
= NULL
;
224 #define FI_EXECUTABLE 2
226 wxFileIconsTable::wxFileIconsTable() :
228 m_HashTable(wxKEY_STRING
)
230 m_HashTable
.DeleteContents(TRUE
);
232 m_ImageList
.Add(wxArtProvider::GetBitmap(wxART_FOLDER
, wxART_CMN_DIALOG
));
234 m_ImageList
.Add(wxArtProvider::GetBitmap(wxART_NORMAL_FILE
, wxART_CMN_DIALOG
));
236 if (GetIconID(wxEmptyString
, _T("application/x-executable")) == FI_UNKNOWN
)
238 m_ImageList
.Add(wxArtProvider::GetBitmap(wxART_EXECUTABLE_FILE
, wxART_CMN_DIALOG
));
239 m_HashTable
.Delete(_T("exe"));
240 m_HashTable
.Put(_T("exe"), new wxFileIconEntry(FI_EXECUTABLE
));
242 /* else put into list by GetIconID
243 (KDE defines application/x-executable for *.exe and has nice icon)
250 // VS: we don't need this function w/o wxMimeTypesManager because we'll only have
251 // one icon and we won't resize it
253 static wxBitmap
CreateAntialiasedBitmap(const wxImage
& img
)
255 wxImage
small(16, 16);
256 unsigned char *p1
, *p2
, *ps
;
257 unsigned char mr
= img
.GetMaskRed(),
258 mg
= img
.GetMaskGreen(),
259 mb
= img
.GetMaskBlue();
262 unsigned sr
, sg
, sb
, smask
;
264 p1
= img
.GetData(), p2
= img
.GetData() + 3 * 32, ps
= small
.GetData();
265 small
.SetMaskColour(mr
, mr
, mr
);
267 for (y
= 0; y
< 16; y
++)
269 for (x
= 0; x
< 16; x
++)
271 sr
= sg
= sb
= smask
= 0;
272 if (p1
[0] != mr
|| p1
[1] != mg
|| p1
[2] != mb
)
273 sr
+= p1
[0], sg
+= p1
[1], sb
+= p1
[2];
276 if (p1
[0] != mr
|| p1
[1] != mg
|| p1
[2] != mb
)
277 sr
+= p1
[0], sg
+= p1
[1], sb
+= p1
[2];
280 if (p2
[0] != mr
|| p2
[1] != mg
|| p2
[2] != mb
)
281 sr
+= p2
[0], sg
+= p2
[1], sb
+= p2
[2];
284 if (p2
[0] != mr
|| p2
[1] != mg
|| p2
[2] != mb
)
285 sr
+= p2
[0], sg
+= p2
[1], sb
+= p2
[2];
290 ps
[0] = ps
[1] = ps
[2] = mr
;
292 ps
[0] = sr
>> 2, ps
[1] = sg
>> 2, ps
[2] = sb
>> 2;
295 p1
+= 32 * 3, p2
+= 32 * 3;
298 return wxBitmap(small
);
301 // finds empty borders and return non-empty area of image:
302 static wxImage
CutEmptyBorders(const wxImage
& img
)
304 unsigned char mr
= img
.GetMaskRed(),
305 mg
= img
.GetMaskGreen(),
306 mb
= img
.GetMaskBlue();
307 unsigned char *dt
= img
.GetData(), *dttmp
;
308 unsigned w
= img
.GetWidth(), h
= img
.GetHeight();
310 unsigned top
, bottom
, left
, right
, i
;
313 #define MK_DTTMP(x,y) dttmp = dt + ((x + y * w) * 3)
314 #define NOEMPTY_PIX(empt) if (dttmp[0] != mr || dttmp[1] != mg || dttmp[2] != mb) {empt = FALSE; break;}
316 for (empt
= TRUE
, top
= 0; empt
&& top
< h
; top
++)
319 for (i
= 0; i
< w
; i
++, dttmp
+=3)
322 for (empt
= TRUE
, bottom
= h
-1; empt
&& bottom
> top
; bottom
--)
325 for (i
= 0; i
< w
; i
++, dttmp
+=3)
328 for (empt
= TRUE
, left
= 0; empt
&& left
< w
; left
++)
331 for (i
= 0; i
< h
; i
++, dttmp
+=3*w
)
334 for (empt
= TRUE
, right
= w
-1; empt
&& right
> left
; right
--)
337 for (i
= 0; i
< h
; i
++, dttmp
+=3*w
)
340 top
--, left
--, bottom
++, right
++;
342 return img
.GetSubImage(wxRect(left
, top
, right
- left
+ 1, bottom
- top
+ 1));
344 #endif // wxUSE_MIMETYPE
348 int wxFileIconsTable::GetIconID(const wxString
& extension
, const wxString
& mime
)
351 if (!extension
.IsEmpty())
353 wxFileIconEntry
*entry
= (wxFileIconEntry
*) m_HashTable
.Get(extension
);
354 if (entry
) return (entry
-> id
);
357 wxFileType
*ft
= (mime
.IsEmpty()) ?
358 wxTheMimeTypesManager
-> GetFileTypeFromExtension(extension
) :
359 wxTheMimeTypesManager
-> GetFileTypeFromMimeType(mime
);
361 if (ft
== NULL
|| (!ft
-> GetIcon(&ic
)) || (!ic
.Ok()))
363 int newid
= FI_UNKNOWN
;
364 m_HashTable
.Put(extension
, new wxFileIconEntry(newid
));
367 wxImage img
= ic
.ConvertToImage();
370 int id
= m_ImageList
.GetImageCount();
371 if (img
.GetWidth() == 16 && img
.GetHeight() == 16)
372 m_ImageList
.Add(wxBitmap(img
));
375 if (img
.GetWidth() != 32 || img
.GetHeight() != 32)
376 m_ImageList
.Add(CreateAntialiasedBitmap(CutEmptyBorders(img
).Rescale(32, 32)));
378 m_ImageList
.Add(CreateAntialiasedBitmap(img
));
380 m_HashTable
.Put(extension
, new wxFileIconEntry(id
));
383 #else // !wxUSE_MIMETYPE
385 if (extension
== wxT("exe"))
386 return FI_EXECUTABLE
;
389 #endif // wxUSE_MIMETYPE/!wxUSE_MIMETYPE
394 // ----------------------------------------------------------------------------
396 // ----------------------------------------------------------------------------
399 int ListCompare( long data1
, long data2
, long WXUNUSED(data
) )
401 wxFileData
*fd1
= (wxFileData
*)data1
;
402 wxFileData
*fd2
= (wxFileData
*)data2
;
403 if (fd1
->GetName() == wxT("..")) return -1;
404 if (fd2
->GetName() == wxT("..")) return 1;
405 if (fd1
->IsDir() && !fd2
->IsDir()) return -1;
406 if (fd2
->IsDir() && !fd1
->IsDir()) return 1;
407 return wxStrcmp( fd1
->GetName(), fd2
->GetName() );
411 #define IsTopMostDir(dir) (dir == wxT("/"))
414 #if defined(__DOS__) || defined(__WINDOWS__)
415 #define IsTopMostDir(dir) (dir.IsEmpty())
418 #if defined(__DOS__) || defined(__WINDOWS__)
419 extern bool wxIsDriveAvailable(const wxString
& dirName
);
422 //-----------------------------------------------------------------------------
424 //-----------------------------------------------------------------------------
426 wxFileData::wxFileData( const wxString
&name
, const wxString
&fname
)
431 #if defined(__DOS__) || defined(__WINDOWS__)
432 // VS: In case the file is root directory of a volume (e.g. "C:"),
433 // we don't want it stat()ed, since the drive may not be in:
434 if (name
.length() == 2 && name
[1u] == wxT(':'))
437 m_isExe
= m_isLink
= FALSE
;
444 wxStat( m_fileName
, &buff
);
446 #if defined(__UNIX__) && (!defined( __EMX__ ) && !defined(__VMS))
448 lstat( m_fileName
.fn_str(), &lbuff
);
449 m_isLink
= S_ISLNK( lbuff
.st_mode
);
450 struct tm
*t
= localtime( &lbuff
.st_mtime
);
453 struct tm
*t
= localtime( &buff
.st_mtime
);
456 // struct passwd *user = getpwuid( buff.st_uid );
457 // struct group *grp = getgrgid( buff.st_gid );
459 m_isDir
= S_ISDIR( buff
.st_mode
);
460 m_isExe
= ((buff
.st_mode
& S_IXUSR
) == S_IXUSR
);
462 m_size
= buff
.st_size
;
465 m_minute
= t
->tm_min
;
466 m_month
= t
->tm_mon
+1;
472 sprintf( buffer
, "%c%c%c",
473 ((( buff
.st_mode
& S_IRUSR
) == S_IRUSR
) ? 'r' : '-'),
474 ((( buff
.st_mode
& S_IWUSR
) == S_IWUSR
) ? 'w' : '-'),
475 ((( buff
.st_mode
& S_IXUSR
) == S_IXUSR
) ? 'x' : '-') );
477 m_permissions
= wxConvUTF8
.cMB2WC( buffer
);
479 m_permissions
= buffer
;
482 // m_permissions.sprintf( wxT("%c%c%c"),
483 // ((( buff.st_mode & S_IRUSR ) == S_IRUSR ) ? wxT('r') : wxT('-')),
484 // ((( buff.st_mode & S_IWUSR ) == S_IWUSR ) ? wxT('w') : wxT('-')),
485 // ((( buff.st_mode & S_IXUSR ) == S_IXUSR ) ? wxT('x') : wxT('-')) );
488 wxString
wxFileData::GetName() const
493 wxString
wxFileData::GetFullName() const
498 wxString
wxFileData::GetHint() const
500 wxString s
= m_fileName
;
502 if (m_isDir
) s
+= wxT("<DIR> ");
503 else if (m_isLink
) s
+= wxT("<LINK> ");
506 s
+= LongToString( m_size
);
509 s
+= IntToString( m_day
);
511 s
+= IntToString( m_month
);
513 s
+= IntToString( m_year
);
515 s
+= IntToString( m_hour
);
517 s
+= IntToString( m_minute
);
523 wxString
wxFileData::GetEntry( FileListField num
) const
538 s
.Printf(_T("%ld"), m_size
);
542 s
.Printf(_T("%02d.%02d.%d"), m_day
, m_month
, m_year
);
546 s
.Printf(_T("%02d:%02d"), m_hour
, m_minute
);
556 wxFAIL_MSG( _T("unexpected field in wxFileData::GetEntry()") );
562 void wxFileData::SetNewName( const wxString
&name
, const wxString
&fname
)
568 void wxFileData::MakeItem( wxListItem
&item
)
570 item
.m_text
= m_name
;
571 item
.ClearAttributes();
573 item
.SetTextColour(*wxRED
);
575 item
.SetTextColour(*wxBLUE
);
578 item
.m_image
= FI_FOLDER
;
580 item
.m_image
= FI_EXECUTABLE
;
581 else if (m_name
.Find(wxT('.')) != wxNOT_FOUND
)
582 item
.m_image
= g_IconsTable
->GetIconID(m_name
.AfterLast(wxT('.')));
584 item
.m_image
= FI_UNKNOWN
;
588 wxColour
*dg
= wxTheColourDatabase
->FindColour( _T("MEDIUM GREY") );
589 item
.SetTextColour(*dg
);
591 item
.m_data
= (long)this;
594 //-----------------------------------------------------------------------------
596 //-----------------------------------------------------------------------------
598 IMPLEMENT_DYNAMIC_CLASS(wxFileCtrl
,wxListCtrl
)
600 BEGIN_EVENT_TABLE(wxFileCtrl
,wxListCtrl
)
601 EVT_LIST_DELETE_ITEM(-1, wxFileCtrl::OnListDeleteItem
)
602 EVT_LIST_END_LABEL_EDIT(-1, wxFileCtrl::OnListEndLabelEdit
)
606 wxFileCtrl::wxFileCtrl()
608 m_showHidden
= FALSE
;
611 wxFileCtrl::wxFileCtrl(wxWindow
*win
,
612 wxStaticText
*labelDir
,
614 const wxString
& wild
,
619 const wxValidator
&validator
,
620 const wxString
&name
)
621 : wxListCtrl(win
, id
, pos
, size
, style
, validator
, name
),
625 g_IconsTable
= new wxFileIconsTable
;
626 wxImageList
*imageList
= g_IconsTable
->GetImageList();
628 SetImageList( imageList
, wxIMAGE_LIST_SMALL
);
630 m_goToParentControl
=
631 m_newDirControl
= NULL
;
633 m_labelDir
= labelDir
;
635 m_showHidden
= showHidden
;
638 void wxFileCtrl::ChangeToListMode()
640 SetSingleStyle( wxLC_LIST
);
644 void wxFileCtrl::ChangeToReportMode()
646 SetSingleStyle( wxLC_REPORT
);
650 void wxFileCtrl::ChangeToIconMode()
652 SetSingleStyle( wxLC_ICON
);
656 void wxFileCtrl::ShowHidden( bool show
)
662 long wxFileCtrl::Add( wxFileData
*fd
, wxListItem
&item
)
665 item
.m_mask
= wxLIST_MASK_TEXT
+ wxLIST_MASK_DATA
+ wxLIST_MASK_IMAGE
;
666 fd
->MakeItem( item
);
667 long my_style
= GetWindowStyleFlag();
668 if (my_style
& wxLC_REPORT
)
670 ret
= InsertItem( item
);
671 for (int i
= 1; i
< FileList_Max
; i
++)
672 SetItem( item
.m_itemId
, i
, fd
->GetEntry((FileListField
)i
) );
674 else if (my_style
& wxLC_LIST
)
676 ret
= InsertItem( item
);
681 void wxFileCtrl::UpdateFiles()
683 // don't do anything before ShowModal() call which sets m_dirName
684 if ( m_dirName
.empty() )
687 wxBusyCursor bcur
; // this may take a while...
689 long my_style
= GetWindowStyleFlag();
690 int name_col_width
= 0;
691 if (my_style
& wxLC_REPORT
)
693 if (GetColumnCount() > 0)
694 name_col_width
= GetColumnWidth( 0 );
700 if (my_style
& wxLC_REPORT
)
702 if (name_col_width
< 140) name_col_width
= 140;
703 InsertColumn( 0, _("Name"), wxLIST_FORMAT_LEFT
, name_col_width
);
704 InsertColumn( 1, _("Size"), wxLIST_FORMAT_LEFT
, 60 );
705 InsertColumn( 2, _("Date"), wxLIST_FORMAT_LEFT
, 65 );
706 InsertColumn( 3, _("Time"), wxLIST_FORMAT_LEFT
, 50 );
708 InsertColumn( 4, _("Permissions"), wxLIST_FORMAT_LEFT
, 120 );
711 wxFileData
*fd
= (wxFileData
*) NULL
;
716 #if defined(__DOS__) || defined(__WINDOWS__)
717 if ( IsTopMostDir(m_dirName
) )
719 // Pseudo-directory with all available drives listed...
720 for (int drive
= 1; drive
<= 26; drive
++)
723 path
.Printf(wxT("%c:\\"), (char)(drive
+ 'A' - 1));
724 if ( wxIsDriveAvailable(path
) )
727 fd
= new wxFileData(path
, path
);
737 if ( !IsTopMostDir(m_dirName
) )
739 wxString
p(wxPathOnly(m_dirName
));
741 if (p
.IsEmpty()) p
= wxT("/");
743 fd
= new wxFileData( wxT(".."), p
);
748 wxString
dirname(m_dirName
);
749 #if defined(__DOS__) || defined(__WINDOWS__)
750 if (dirname
.length() == 2 && dirname
[1u] == wxT(':'))
751 dirname
<< wxT('\\');
755 if ( dir
.IsOpened() )
757 wxString
dirPrefix(dirname
+ wxFILE_SEP_PATH
);
758 int hiddenFlag
= m_showHidden
? wxDIR_HIDDEN
: 0;
763 // Get the directories first (not matched against wildcards):
764 cont
= dir
.GetFirst(&f
, wxEmptyString
, wxDIR_DIRS
| hiddenFlag
);
767 fd
= new wxFileData(f
, dirPrefix
+ f
);
770 cont
= dir
.GetNext(&f
);
773 // Tokenize the wildcard string, so we can handle more than 1
774 // search pattern in a wildcard.
775 wxStringTokenizer
tokenWild(m_wild
, wxT(";"));
776 while ( tokenWild
.HasMoreTokens() )
778 cont
= dir
.GetFirst(&f
, tokenWild
.GetNextToken(),
779 wxDIR_FILES
| hiddenFlag
);
782 fd
= new wxFileData(f
, dirPrefix
+ f
);
785 cont
= dir
.GetNext(&f
);
791 SortItems(ListCompare
, 0);
793 if ( my_style
& wxLC_REPORT
)
795 SetColumnWidth(1, wxLIST_AUTOSIZE
);
796 SetColumnWidth(2, wxLIST_AUTOSIZE
);
797 SetColumnWidth(3, wxLIST_AUTOSIZE
);
800 // Finally, enable/disable context-dependent controls:
801 if ( m_goToParentControl
)
802 m_goToParentControl
->Enable(!IsTopMostDir(m_dirName
));
803 #if defined(__DOS__) || defined(__WINDOWS__)
804 if ( m_newDirControl
)
805 m_newDirControl
->Enable(!IsTopMostDir(m_dirName
));
809 void wxFileCtrl::SetWild( const wxString
&wild
)
815 void wxFileCtrl::MakeDir()
817 wxString
new_name( _("NewName") );
818 wxString
path( m_dirName
);
819 path
+= wxFILE_SEP_PATH
;
821 if (wxFileExists(path
))
823 // try NewName0, NewName1 etc.
826 new_name
= _("NewName");
828 num
.Printf( wxT("%d"), i
);
832 path
+= wxFILE_SEP_PATH
;
835 } while (wxFileExists(path
));
841 wxMessageDialog
dialog(this, _("Operation not permitted."), _("Error"), wxOK
| wxICON_ERROR
);
846 wxFileData
*fd
= new wxFileData( new_name
, path
);
850 long id
= Add( fd
, item
);
854 SortItems( ListCompare
, 0 );
855 id
= FindItem( 0, (long)fd
);
861 void wxFileCtrl::GoToParentDir()
863 if (!IsTopMostDir(m_dirName
))
865 size_t len
= m_dirName
.Len();
866 if (m_dirName
[len
-1] == wxFILE_SEP_PATH
)
867 m_dirName
.Remove( len
-1, 1 );
868 wxString
fname( wxFileNameFromPath(m_dirName
) );
869 m_dirName
= wxPathOnly( m_dirName
);
871 if (m_dirName
.IsEmpty())
872 m_dirName
= wxT("/");
875 long id
= FindItem( 0, fname
);
878 SetItemState( id
, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
882 m_labelDir
->SetLabel(m_dirName
);
886 void wxFileCtrl::GoToHomeDir()
888 wxString s
= wxGetUserHome( wxString() );
892 void wxFileCtrl::GoToDir( const wxString
&dir
)
896 SetItemState( 0, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
899 m_labelDir
->SetLabel(dir
);
902 void wxFileCtrl::GetDir( wxString
&dir
)
907 void wxFileCtrl::FreeItemData(const wxListItem
& item
)
909 wxFileData
*fd
= (wxFileData
*)item
.m_data
;
913 void wxFileCtrl::OnListDeleteItem( wxListEvent
&event
)
915 FreeItemData(event
.m_item
);
918 void wxFileCtrl::FreeAllItemsData()
921 item
.m_mask
= wxLIST_MASK_DATA
;
923 item
.m_itemId
= GetNextItem( -1, wxLIST_NEXT_ALL
);
924 while ( item
.m_itemId
!= -1 )
928 item
.m_itemId
= GetNextItem( item
.m_itemId
, wxLIST_NEXT_ALL
);
932 void wxFileCtrl::OnListEndLabelEdit( wxListEvent
&event
)
934 wxFileData
*fd
= (wxFileData
*)event
.m_item
.m_data
;
937 if ((event
.GetLabel().IsEmpty()) ||
938 (event
.GetLabel() == _(".")) ||
939 (event
.GetLabel() == _("..")) ||
940 (event
.GetLabel().First( wxFILE_SEP_PATH
) != wxNOT_FOUND
))
942 wxMessageDialog
dialog(this, _("Illegal directory name."), _("Error"), wxOK
| wxICON_ERROR
);
948 wxString
new_name( wxPathOnly( fd
->GetFullName() ) );
949 new_name
+= wxFILE_SEP_PATH
;
950 new_name
+= event
.GetLabel();
954 if (wxFileExists(new_name
))
956 wxMessageDialog
dialog(this, _("File name exists already."), _("Error"), wxOK
| wxICON_ERROR
);
961 if (wxRenameFile(fd
->GetFullName(),new_name
))
963 fd
->SetNewName( new_name
, event
.GetLabel() );
964 SetItemState( event
.GetItem(), wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
965 EnsureVisible( event
.GetItem() );
969 wxMessageDialog
dialog(this, _("Operation not permitted."), _("Error"), wxOK
| wxICON_ERROR
);
975 wxFileCtrl::~wxFileCtrl()
980 //-----------------------------------------------------------------------------
982 //-----------------------------------------------------------------------------
984 #define ID_LIST_MODE (wxID_FILEDLGG )
985 #define ID_REPORT_MODE (wxID_FILEDLGG + 1)
986 #define ID_UP_DIR (wxID_FILEDLGG + 5)
987 #define ID_PARENT_DIR (wxID_FILEDLGG + 6)
988 #define ID_NEW_DIR (wxID_FILEDLGG + 7)
989 #define ID_CHOICE (wxID_FILEDLGG + 8)
990 #define ID_TEXT (wxID_FILEDLGG + 9)
991 #define ID_LIST_CTRL (wxID_FILEDLGG + 10)
992 #define ID_ACTIVATED (wxID_FILEDLGG + 11)
993 #define ID_CHECK (wxID_FILEDLGG + 12)
995 IMPLEMENT_DYNAMIC_CLASS(wxFileDialog
,wxDialog
)
997 BEGIN_EVENT_TABLE(wxFileDialog
,wxDialog
)
998 EVT_BUTTON(ID_LIST_MODE
, wxFileDialog::OnList
)
999 EVT_BUTTON(ID_REPORT_MODE
, wxFileDialog::OnReport
)
1000 EVT_BUTTON(ID_UP_DIR
, wxFileDialog::OnUp
)
1001 EVT_BUTTON(ID_PARENT_DIR
, wxFileDialog::OnHome
)
1002 EVT_BUTTON(ID_NEW_DIR
, wxFileDialog::OnNew
)
1003 EVT_BUTTON(wxID_OK
, wxFileDialog::OnListOk
)
1004 EVT_LIST_ITEM_SELECTED(ID_LIST_CTRL
, wxFileDialog::OnSelected
)
1005 EVT_LIST_ITEM_ACTIVATED(ID_LIST_CTRL
, wxFileDialog::OnActivated
)
1006 EVT_CHOICE(ID_CHOICE
,wxFileDialog::OnChoiceFilter
)
1007 EVT_TEXT_ENTER(ID_TEXT
,wxFileDialog::OnTextEnter
)
1008 EVT_TEXT(ID_TEXT
,wxFileDialog::OnTextChange
)
1009 EVT_CHECKBOX(ID_CHECK
,wxFileDialog::OnCheck
)
1012 long wxFileDialog::ms_lastViewStyle
= wxLC_LIST
;
1013 bool wxFileDialog::ms_lastShowHidden
= FALSE
;
1015 wxFileDialog::wxFileDialog(wxWindow
*parent
,
1016 const wxString
& message
,
1017 const wxString
& defaultDir
,
1018 const wxString
& defaultFile
,
1019 const wxString
& wildCard
,
1021 const wxPoint
& pos
)
1022 : wxDialog( parent
, -1, message
, pos
, wxDefaultSize
,
1023 wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
)
1025 if (wxConfig::Get(FALSE
))
1027 wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ViewStyle"),
1029 wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ShowHidden"),
1030 &ms_lastShowHidden
);
1033 m_message
= message
;
1034 m_dialogStyle
= style
;
1036 if (m_dialogStyle
== 0)
1037 m_dialogStyle
= wxOPEN
;
1038 if ((m_dialogStyle
& wxMULTIPLE
) && !(m_dialogStyle
& wxOPEN
))
1039 m_dialogStyle
|= wxOPEN
;
1042 if ((m_dir
.empty()) || (m_dir
== wxT(".")))
1047 size_t len
= m_dir
.Len();
1048 if ((len
> 1) && (m_dir
[len
-1] == wxFILE_SEP_PATH
))
1049 m_dir
.Remove( len
-1, 1 );
1052 m_path
+= wxFILE_SEP_PATH
;
1053 m_path
+= defaultFile
;
1054 m_fileName
= defaultFile
;
1055 m_wildCard
= wildCard
;
1057 m_filterExtension
= wxEmptyString
;
1059 // interpret wildcards
1061 if (m_wildCard
.IsEmpty())
1062 m_wildCard
= _("All files (*)|*");
1064 wxStringTokenizer
tokens( m_wildCard
, wxT("|") );
1066 wxString firstWildText
;
1067 if (tokens
.CountTokens() == 1)
1069 firstWildText
= tokens
.GetNextToken();
1070 firstWild
= firstWildText
;
1074 wxASSERT_MSG( tokens
.CountTokens() % 2 == 0, wxT("Wrong file type descripition") );
1075 firstWildText
= tokens
.GetNextToken();
1076 firstWild
= tokens
.GetNextToken();
1078 if ( firstWild
.Left( 2 ) == wxT("*.") )
1079 m_filterExtension
= firstWild
.Mid( 1 );
1080 if ( m_filterExtension
== wxT(".*") )
1081 m_filterExtension
= wxEmptyString
;
1085 bool is_pda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
1087 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
1089 wxBoxSizer
*buttonsizer
= new wxBoxSizer( wxHORIZONTAL
);
1091 wxBitmapButton
*but
;
1093 but
= new wxBitmapButton(this, ID_LIST_MODE
,
1094 wxArtProvider::GetBitmap(wxART_LIST_VIEW
, wxART_CMN_DIALOG
));
1096 but
->SetToolTip( _("View files as a list view") );
1098 buttonsizer
->Add( but
, 0, wxALL
, 5 );
1100 but
= new wxBitmapButton(this, ID_REPORT_MODE
,
1101 wxArtProvider::GetBitmap(wxART_REPORT_VIEW
, wxART_CMN_DIALOG
));
1103 but
->SetToolTip( _("View files as a detailed view") );
1105 buttonsizer
->Add( but
, 0, wxALL
, 5 );
1107 buttonsizer
->Add( 30, 5, 1 );
1109 wxWindow
*butDirUp
=
1110 new wxBitmapButton(this, ID_UP_DIR
,
1111 wxArtProvider::GetBitmap(wxART_GO_DIR_UP
, wxART_CMN_DIALOG
));
1113 butDirUp
->SetToolTip( _("Go to parent directory") );
1115 buttonsizer
->Add( butDirUp
, 0, wxALL
, 5 );
1117 #ifndef __DOS__ // VS: Home directory is meaningless in MS-DOS...
1118 but
= new wxBitmapButton(this, ID_PARENT_DIR
,
1119 wxArtProvider::GetBitmap(wxART_GO_HOME
, wxART_CMN_DIALOG
));
1121 but
->SetToolTip( _("Go to home directory") );
1123 buttonsizer
->Add( but
, 0, wxALL
, 5);
1125 buttonsizer
->Add( 20, 20 );
1128 wxWindow
*butNewDir
=
1129 new wxBitmapButton(this, ID_NEW_DIR
,
1130 wxArtProvider::GetBitmap(wxART_NEW_DIR
, wxART_CMN_DIALOG
));
1132 butNewDir
->SetToolTip( _("Create new directory") );
1134 buttonsizer
->Add( butNewDir
, 0, wxALL
, 5 );
1137 mainsizer
->Add( buttonsizer
, 0, wxALL
| wxEXPAND
, 0 );
1139 mainsizer
->Add( buttonsizer
, 0, wxALL
| wxEXPAND
, 5 );
1141 wxBoxSizer
*staticsizer
= new wxBoxSizer( wxHORIZONTAL
);
1143 staticsizer
->Add( new wxStaticText( this, -1, _("Current directory:") ), 0, wxRIGHT
, 10 );
1144 m_static
= new wxStaticText( this, -1, m_dir
);
1145 staticsizer
->Add( m_static
, 1 );
1146 mainsizer
->Add( staticsizer
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxBOTTOM
, 10 );
1148 long style2
= ms_lastViewStyle
| wxSUNKEN_BORDER
;
1149 if ( !(m_dialogStyle
& wxMULTIPLE
) )
1150 style2
|= wxLC_SINGLE_SEL
;
1152 m_list
= new wxFileCtrl( this, m_static
, ID_LIST_CTRL
,
1153 firstWild
, ms_lastShowHidden
,
1154 wxDefaultPosition
, wxSize(540,200),
1157 m_list
->SetNewDirControl(butNewDir
);
1158 m_list
->SetGoToParentControl(butDirUp
);
1162 // PDAs have a different screen layout
1163 mainsizer
->Add( m_list
, 1, wxEXPAND
| wxLEFT
|wxRIGHT
, 5 );
1165 wxBoxSizer
*choicesizer
= new wxBoxSizer( wxHORIZONTAL
);
1166 m_choice
= new wxChoice( this, ID_CHOICE
);
1167 choicesizer
->Add( m_choice
, 1, wxCENTER
|wxALL
, 5 );
1168 mainsizer
->Add( choicesizer
, 0, wxEXPAND
);
1170 wxBoxSizer
*textsizer
= new wxBoxSizer( wxHORIZONTAL
);
1171 m_text
= new wxTextCtrl( this, ID_TEXT
, m_fileName
, wxDefaultPosition
, wxDefaultSize
, wxPROCESS_ENTER
);
1172 textsizer
->Add( m_text
, 1, wxCENTER
| wxALL
, 5 );
1173 mainsizer
->Add( textsizer
, 0, wxEXPAND
);
1175 m_check
= new wxCheckBox( this, ID_CHECK
, _("Show hidden files") );
1176 m_check
->SetValue( ms_lastShowHidden
);
1177 textsizer
->Add( m_check
, 0, wxCENTER
|wxALL
, 5 );
1179 buttonsizer
= new wxBoxSizer( wxHORIZONTAL
);
1180 buttonsizer
->Add( new wxButton( this, wxID_OK
, _("OK") ), 0, wxCENTER
| wxALL
, 5 );
1181 buttonsizer
->Add( new wxButton( this, wxID_CANCEL
, _("Cancel") ), 0, wxCENTER
| wxALL
, 5 );
1182 mainsizer
->Add( buttonsizer
, 0, wxALIGN_RIGHT
);
1186 mainsizer
->Add( m_list
, 1, wxEXPAND
| wxLEFT
|wxRIGHT
, 10 );
1188 wxBoxSizer
*textsizer
= new wxBoxSizer( wxHORIZONTAL
);
1189 m_text
= new wxTextCtrl( this, ID_TEXT
, m_fileName
, wxDefaultPosition
, wxDefaultSize
, wxPROCESS_ENTER
);
1190 textsizer
->Add( m_text
, 1, wxCENTER
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
1191 textsizer
->Add( new wxButton( this, wxID_OK
, _("OK") ), 0, wxCENTER
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
1192 mainsizer
->Add( textsizer
, 0, wxEXPAND
);
1194 wxBoxSizer
*choicesizer
= new wxBoxSizer( wxHORIZONTAL
);
1195 m_choice
= new wxChoice( this, ID_CHOICE
);
1196 choicesizer
->Add( m_choice
, 1, wxCENTER
|wxALL
, 10 );
1197 m_check
= new wxCheckBox( this, ID_CHECK
, _("Show hidden files") );
1198 m_check
->SetValue( ms_lastShowHidden
);
1199 choicesizer
->Add( m_check
, 0, wxCENTER
|wxALL
, 10 );
1200 choicesizer
->Add( new wxButton( this, wxID_CANCEL
, _("Cancel") ), 0, wxCENTER
| wxALL
, 10 );
1201 mainsizer
->Add( choicesizer
, 0, wxEXPAND
);
1204 m_choice
->Append( firstWildText
, (void*) new wxString( firstWild
) );
1205 while (tokens
.HasMoreTokens())
1207 firstWildText
= tokens
.GetNextToken();
1208 firstWild
= tokens
.GetNextToken();
1209 m_choice
->Append( firstWildText
, (void*) new wxString( firstWild
) );
1211 m_choice
->SetSelection( 0 );
1213 SetAutoLayout( TRUE
);
1214 SetSizer( mainsizer
);
1216 mainsizer
->Fit( this );
1217 mainsizer
->SetSizeHints( this );
1224 wxFileDialog::~wxFileDialog()
1226 if (wxConfig::Get(FALSE
))
1228 wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ViewStyle"),
1230 wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ShowHidden"),
1235 int wxFileDialog::ShowModal()
1237 m_list
->GoToDir(m_dir
);
1238 m_text
->SetValue(m_fileName
);
1240 return wxDialog::ShowModal();
1243 void wxFileDialog::DoSetFilterIndex(int filterindex
)
1245 wxString
*str
= (wxString
*) m_choice
->GetClientData( filterindex
);
1246 m_list
->SetWild( *str
);
1247 m_filterIndex
= filterindex
;
1248 if ( str
->Left(2) == wxT("*.") )
1250 m_filterExtension
= str
->Mid(2);
1251 if (m_filterExtension
== _T("*"))
1252 m_filterExtension
.clear();
1256 m_filterExtension
.clear();
1260 void wxFileDialog::SetFilterIndex( int filterindex
)
1262 m_choice
->SetSelection( filterindex
);
1264 DoSetFilterIndex(filterindex
);
1267 void wxFileDialog::OnChoiceFilter( wxCommandEvent
&event
)
1269 DoSetFilterIndex((int)event
.GetInt());
1272 void wxFileDialog::OnCheck( wxCommandEvent
&event
)
1274 m_list
->ShowHidden( (ms_lastShowHidden
= event
.GetInt() != 0) );
1277 void wxFileDialog::OnActivated( wxListEvent
&event
)
1279 HandleAction( event
.m_item
.m_text
);
1282 void wxFileDialog::OnTextEnter( wxCommandEvent
&WXUNUSED(event
) )
1284 wxCommandEvent
cevent(wxEVT_COMMAND_BUTTON_CLICKED
, wxID_OK
);
1285 cevent
.SetEventObject( this );
1286 GetEventHandler()->ProcessEvent( cevent
);
1289 static bool ignoreChanges
= FALSE
;
1291 void wxFileDialog::OnTextChange( wxCommandEvent
&WXUNUSED(event
) )
1295 // Clear selections. Otherwise when the user types in a value they may
1296 // not get the file whose name they typed.
1297 if (m_list
->GetSelectedItemCount() > 0)
1299 long item
= m_list
->GetNextItem(-1, wxLIST_NEXT_ALL
,
1300 wxLIST_STATE_SELECTED
);
1301 while ( item
!= -1 )
1303 m_list
->SetItemState(item
,0, wxLIST_STATE_SELECTED
);
1304 item
= m_list
->GetNextItem(item
, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1310 void wxFileDialog::OnSelected( wxListEvent
&event
)
1312 wxString
filename( event
.m_item
.m_text
);
1313 if (filename
== wxT("..")) return;
1316 m_list
->GetDir( dir
);
1317 if (!IsTopMostDir(dir
))
1318 dir
+= wxFILE_SEP_PATH
;
1320 if (wxDirExists(dir
)) return;
1322 ignoreChanges
= TRUE
;
1323 m_text
->SetValue( filename
);
1324 ignoreChanges
= FALSE
;
1327 void wxFileDialog::HandleAction( const wxString
&fn
)
1329 wxString
filename( fn
);
1331 m_list
->GetDir( dir
);
1332 if (filename
.IsEmpty()) return;
1333 if (filename
== wxT(".")) return;
1335 if (filename
== wxT(".."))
1337 m_list
->GoToParentDir();
1343 if (filename
== wxT("~"))
1345 m_list
->GoToHomeDir();
1350 if (filename
[0u] == wxT('~'))
1352 filename
.Remove( 0, 1 );
1353 wxString
tmp( wxGetUserHome() );
1360 if ((filename
.Find(wxT('*')) != wxNOT_FOUND
) ||
1361 (filename
.Find(wxT('?')) != wxNOT_FOUND
))
1363 if (filename
.Find(wxFILE_SEP_PATH
) != wxNOT_FOUND
)
1365 wxMessageBox(_("Illegal file specification."), _("Error"), wxOK
| wxICON_ERROR
);
1368 m_list
->SetWild( filename
);
1372 if (!IsTopMostDir(dir
))
1373 dir
+= wxFILE_SEP_PATH
;
1374 if (!wxIsAbsolutePath(filename
))
1380 if (wxDirExists(filename
))
1382 m_list
->GoToDir( filename
);
1386 // append the default extension to the filename if it doesn't have any
1388 // VZ: the logic of testing for !wxFileExists() only for the open file
1389 // dialog is not entirely clear to me, why don't we allow saving to a
1390 // file without extension as well?
1391 if ( !(m_dialogStyle
& wxOPEN
) || !wxFileExists(filename
) )
1394 wxSplitPath(filename
, NULL
, NULL
, &ext
);
1397 // append the first extension of the filter string
1398 filename
+= m_filterExtension
.BeforeFirst(_T(';'));
1402 // check that the file [doesn't] exist if necessary
1403 if ( (m_dialogStyle
& wxSAVE
) &&
1404 (m_dialogStyle
& wxOVERWRITE_PROMPT
) &&
1405 wxFileExists( filename
) )
1408 msg
.Printf( _("File '%s' already exists, do you really want to "
1409 "overwrite it?"), filename
.c_str() );
1411 if (wxMessageBox(msg
, _("Confirm"), wxYES_NO
) != wxYES
)
1414 else if ( (m_dialogStyle
& wxOPEN
) &&
1415 (m_dialogStyle
& wxFILE_MUST_EXIST
) &&
1416 !wxFileExists(filename
) )
1418 wxMessageBox(_("Please choose an existing file."), _("Error"),
1419 wxOK
| wxICON_ERROR
);
1422 SetPath( filename
);
1424 // change to the directory where the user went if asked
1425 if ( m_dialogStyle
& wxCHANGE_DIR
)
1428 wxSplitPath(filename
, &cwd
, NULL
, NULL
);
1430 if ( cwd
!= wxGetWorkingDirectory() )
1432 wxSetWorkingDirectory(cwd
);
1436 wxCommandEvent event
;
1437 wxDialog::OnOK(event
);
1440 void wxFileDialog::OnListOk( wxCommandEvent
&WXUNUSED(event
) )
1442 HandleAction( m_text
->GetValue() );
1445 void wxFileDialog::OnList( wxCommandEvent
&WXUNUSED(event
) )
1447 m_list
->ChangeToListMode();
1448 ms_lastViewStyle
= wxLC_LIST
;
1452 void wxFileDialog::OnReport( wxCommandEvent
&WXUNUSED(event
) )
1454 m_list
->ChangeToReportMode();
1455 ms_lastViewStyle
= wxLC_REPORT
;
1459 void wxFileDialog::OnUp( wxCommandEvent
&WXUNUSED(event
) )
1461 m_list
->GoToParentDir();
1465 void wxFileDialog::OnHome( wxCommandEvent
&WXUNUSED(event
) )
1467 m_list
->GoToHomeDir();
1471 void wxFileDialog::OnNew( wxCommandEvent
&WXUNUSED(event
) )
1476 void wxFileDialog::SetPath( const wxString
& path
)
1478 // not only set the full path but also update filename and dir
1480 if ( !path
.empty() )
1483 wxSplitPath(path
, &m_dir
, &m_fileName
, &ext
);
1486 m_fileName
+= wxT(".");
1492 void wxFileDialog::GetPaths( wxArrayString
& paths
) const
1495 if (m_list
->GetSelectedItemCount() == 0)
1497 paths
.Add( GetPath() );
1501 paths
.Alloc( m_list
->GetSelectedItemCount() );
1504 m_list
->GetDir( dir
);
1506 if (dir
!= wxT("/"))
1508 dir
+= wxFILE_SEP_PATH
;
1511 item
.m_mask
= wxLIST_MASK_TEXT
;
1513 item
.m_itemId
= m_list
->GetNextItem( -1, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1514 while ( item
.m_itemId
!= -1 )
1516 m_list
->GetItem( item
);
1517 paths
.Add( dir
+ item
.m_text
);
1518 item
.m_itemId
= m_list
->GetNextItem( item
.m_itemId
,
1519 wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1523 void wxFileDialog::GetFilenames(wxArrayString
& files
) const
1526 if (m_list
->GetSelectedItemCount() == 0)
1528 files
.Add( GetFilename() );
1531 files
.Alloc( m_list
->GetSelectedItemCount() );
1534 item
.m_mask
= wxLIST_MASK_TEXT
;
1536 item
.m_itemId
= m_list
->GetNextItem( -1, wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1537 while ( item
.m_itemId
!= -1 )
1539 m_list
->GetItem( item
);
1540 files
.Add( item
.m_text
);
1541 item
.m_itemId
= m_list
->GetNextItem( item
.m_itemId
,
1542 wxLIST_NEXT_ALL
, wxLIST_STATE_SELECTED
);
1548 // ----------------------------------------------------------------------------
1550 // ----------------------------------------------------------------------------
1553 wxFileSelectorEx(const wxChar
*message
,
1554 const wxChar
*default_path
,
1555 const wxChar
*default_filename
,
1556 int *WXUNUSED(indexDefaultExtension
),
1557 const wxChar
*wildcard
,
1562 // TODO: implement this somehow
1563 return wxFileSelector(message
, default_path
, default_filename
, wxT(""),
1564 wildcard
, flags
, parent
, x
, y
);
1567 wxString
wxFileSelector( const wxChar
*title
,
1568 const wxChar
*defaultDir
, const wxChar
*defaultFileName
,
1569 const wxChar
*defaultExtension
, const wxChar
*filter
, int flags
,
1570 wxWindow
*parent
, int x
, int y
)
1573 if ( defaultExtension
&& !filter
)
1574 filter2
= wxString(wxT("*.")) + wxString(defaultExtension
) ;
1578 wxString defaultDirString
;
1580 defaultDirString
= defaultDir
;
1582 wxString defaultFilenameString
;
1583 if (defaultFileName
)
1584 defaultFilenameString
= defaultFileName
;
1586 wxFileDialog
fileDialog( parent
, title
, defaultDirString
, defaultFilenameString
, filter2
, flags
, wxPoint(x
, y
) );
1588 if ( fileDialog
.ShowModal() == wxID_OK
)
1590 return fileDialog
.GetPath();
1594 return wxEmptyString
;
1598 static wxString
GetWildcardString(const wxChar
*ext
)
1603 if ( *ext
== wxT('.') )
1606 wild
<< _T("*.") << ext
;
1608 else // no extension specified
1610 wild
= wxFileSelectorDefaultWildcardStr
;
1616 wxString
wxLoadFileSelector(const wxChar
*what
,
1618 const wxChar
*nameDef
,
1622 if ( what
&& *what
)
1623 prompt
= wxString::Format(_("Load %s file"), what
);
1625 prompt
= _("Load file");
1627 return wxFileSelector(prompt
, NULL
, nameDef
, ext
,
1628 GetWildcardString(ext
), 0, parent
);
1631 wxString
wxSaveFileSelector(const wxChar
*what
,
1633 const wxChar
*nameDef
,
1637 if ( what
&& *what
)
1638 prompt
= wxString::Format(_("Save %s file"), what
);
1640 prompt
= _("Save file");
1642 return wxFileSelector(prompt
, NULL
, nameDef
, ext
,
1643 GetWildcardString(ext
), 0, parent
);
1646 // A module to allow icons table cleanup
1648 class wxFileDialogGenericModule
: public wxModule
1650 DECLARE_DYNAMIC_CLASS(wxFileDialogGenericModule
)
1652 wxFileDialogGenericModule() {}
1653 bool OnInit() { return TRUE
; }
1654 void OnExit() { if (g_IconsTable
) {delete g_IconsTable
; g_IconsTable
= NULL
;} }
1657 IMPLEMENT_DYNAMIC_CLASS(wxFileDialogGenericModule
, wxModule
)
1659 #endif // wxUSE_FILEDLG