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"
24 #error wxFileDialog currently only supports unix
27 #include "wx/filedlg.h"
31 #include "wx/msgdlg.h"
33 #include "wx/bmpbuttn.h"
34 #include "wx/tokenzr.h"
37 #include "wx/tooltip.h"
40 #include <sys/types.h>
48 #include "wx/generic/home.xpm"
49 #include "wx/generic/listview.xpm"
50 #include "wx/generic/repview.xpm"
51 #include "wx/generic/new_dir.xpm"
52 #include "wx/generic/dir_up.xpm"
55 static char * folder_xpm
[] = {
56 /* width height ncolors chars_per_pixel */
83 //-----------------------------------------------------------------------------
85 //-----------------------------------------------------------------------------
87 IMPLEMENT_DYNAMIC_CLASS(wxFileData
,wxObject
);
89 wxFileData::wxFileData( const wxString
&name
, const wxString
&fname
)
95 stat( m_fileName
.GetData(), &buff
);
97 lstat( m_fileName
.GetData(), &lbuff
);
99 struct tm
*t
= localtime( &lbuff
.st_mtime
);
100 // struct passwd *user = getpwuid( buff.st_uid );
101 // struct group *grp = getgrgid( buff.st_gid );
103 m_isDir
= S_ISDIR( buff
.st_mode
);
104 m_isLink
= S_ISLNK( lbuff
.st_mode
);
105 m_isExe
= ((buff
.st_mode
& S_IXUSR
) == S_IXUSR
);
107 m_size
= buff
.st_size
;
110 m_minute
= t
->tm_min
;
111 m_month
= t
->tm_mon
+1;
115 m_permissions
.sprintf( "%c%c%c",
116 ((( buff
.st_mode
& S_IRUSR
) == S_IRUSR
) ? 'r' : '-'),
117 ((( buff
.st_mode
& S_IWUSR
) == S_IWUSR
) ? 'w' : '-'),
118 ((( buff
.st_mode
& S_IXUSR
) == S_IXUSR
) ? 'x' : '-') );
121 wxString
wxFileData::GetName() const
126 wxString
wxFileData::GetFullName() const
131 wxString
wxFileData::GetHint() const
133 wxString s
= m_fileName
;
135 if (m_isDir
) s
+= _("<DIR> ");
136 else if (m_isLink
) s
+= _("<LINK> ");
139 s
+= LongToString( m_size
);
142 s
+= IntToString( m_day
);
144 s
+= IntToString( m_month
);
146 s
+= IntToString( m_year
);
148 s
+= IntToString( m_hour
);
150 s
+= IntToString( m_minute
);
156 wxString
wxFileData::GetEntry( const int num
)
165 if (m_isDir
) s
= _("<DIR>");
166 else if (m_isLink
) s
= _("<LINK>");
167 else s
= LongToString( m_size
);
170 if (m_day
< 10) s
= _T("0"); else s
= _T("");
171 s
+= IntToString( m_day
);
173 if (m_month
< 10) s
+= _T("0");
174 s
+= IntToString( m_month
);
176 if (m_year
< 10) s
+= _T("0"); // this should happen real soon...
177 s
+= IntToString( m_year
);
180 if (m_hour
< 10) s
= _T("0"); else s
= _T("");
181 s
+= IntToString( m_hour
);
183 if (m_minute
< 10) s
+= _T("0");
184 s
+= IntToString( m_minute
);
196 bool wxFileData::IsDir()
201 bool wxFileData::IsExe()
206 bool wxFileData::IsLink()
211 long wxFileData::GetSize()
216 void wxFileData::SetNewName( const wxString
&name
, const wxString
&fname
)
222 void wxFileData::MakeItem( wxListItem
&item
)
224 item
.m_text
= m_name
;
225 item
.m_colour
= wxBLACK
;
226 if (IsExe()) item
.m_colour
= wxRED
;
227 if (IsDir()) item
.m_colour
= wxBLUE
;
228 if (IsDir()) item
.m_image
= 0; else item
.m_image
= -1;
231 wxColour
*dg
= wxTheColourDatabase
->FindColour( "MEDIUM GREY" );
234 item
.m_data
= (long)this;
237 //-----------------------------------------------------------------------------
239 //-----------------------------------------------------------------------------
241 IMPLEMENT_DYNAMIC_CLASS(wxFileCtrl
,wxListCtrl
);
243 BEGIN_EVENT_TABLE(wxFileCtrl
,wxListCtrl
)
244 EVT_LIST_DELETE_ITEM(-1, wxFileCtrl::OnListDeleteItem
)
245 EVT_LIST_END_LABEL_EDIT(-1, wxFileCtrl::OnListEndLabelEdit
)
248 wxFileCtrl::wxFileCtrl()
251 m_showHidden
= FALSE
;
254 wxFileCtrl::wxFileCtrl( wxWindow
*win
, wxWindowID id
,
255 const wxString
&dirName
, const wxString
&wild
,
256 const wxPoint
&pos
, const wxSize
&size
,
257 long style
, const wxValidator
&validator
, const wxString
&name
) :
258 wxListCtrl( win
, id
, pos
, size
, style
, validator
, name
)
260 wxImageList
*imageList
= new wxImageList( 16, 16 );
261 imageList
->Add( wxBitmap( folder_xpm
) );
262 SetImageList( imageList
, wxIMAGE_LIST_SMALL
);
266 m_showHidden
= FALSE
;
270 void wxFileCtrl::ChangeToListMode()
272 SetSingleStyle( wxLC_LIST
);
276 void wxFileCtrl::ChangeToReportMode()
278 SetSingleStyle( wxLC_REPORT
);
282 void wxFileCtrl::ChangeToIconMode()
284 SetSingleStyle( wxLC_ICON
);
288 void wxFileCtrl::ShowHidden( bool show
)
294 int ListCompare( const long data1
, const long data2
, const long WXUNUSED(data
) )
296 wxFileData
*fd1
= (wxFileData
*)data1
;
297 wxFileData
*fd2
= (wxFileData
*)data2
;
298 if (fd1
->GetName() == _T("..")) return -1;
299 if (fd2
->GetName() == _T("..")) return 1;
300 if (fd1
->IsDir() && !fd2
->IsDir()) return -1;
301 if (fd2
->IsDir() && !fd1
->IsDir()) return 1;
302 return strcmp( fd1
->GetName(), fd2
->GetName() );
305 long wxFileCtrl::Add( wxFileData
*fd
, wxListItem
&item
)
308 item
.m_mask
= wxLIST_MASK_TEXT
+ wxLIST_MASK_DATA
+ wxLIST_MASK_IMAGE
;
309 fd
->MakeItem( item
);
310 long my_style
= GetWindowStyleFlag();
311 if (my_style
& wxLC_REPORT
)
313 ret
= InsertItem( item
);
314 for (int i
= 1; i
< 5; i
++) SetItem( item
.m_itemId
, i
, fd
->GetEntry( i
) );
316 else if (my_style
& wxLC_LIST
)
318 ret
= InsertItem( item
);
323 void wxFileCtrl::Update()
326 long my_style
= GetWindowStyleFlag();
327 if (my_style
& wxLC_REPORT
)
329 InsertColumn( 0, _("Name"), wxLIST_FORMAT_LEFT
, 130 );
330 InsertColumn( 1, _("Size"), wxLIST_FORMAT_LEFT
, 60 );
331 InsertColumn( 2, _("Date"), wxLIST_FORMAT_LEFT
, 55 );
332 InsertColumn( 3, _("Time"), wxLIST_FORMAT_LEFT
, 50 );
333 InsertColumn( 4, _("Permissions"), wxLIST_FORMAT_LEFT
, 120 );
335 wxFileData
*fd
= (wxFileData
*) NULL
;
340 if (m_dirName
!= _T("/"))
342 wxString
p( wxPathOnly(m_dirName
) );
343 if (p
.IsEmpty()) p
= _T("/");
344 fd
= new wxFileData( _T(".."), p
);
349 wxString res
= m_dirName
+ _T("/*");
350 wxString
f( wxFindFirstFile( res
.GetData(), wxDIR
) );
353 res
= wxFileNameFromPath( f
);
354 fd
= new wxFileData( res
, f
);
355 wxString s
= fd
->GetName();
356 if (m_showHidden
|| (s
[0] != _T('.')))
361 f
= wxFindNextFile();
364 res
= m_dirName
+ _T("/") + m_wild
;
365 f
= wxFindFirstFile( res
.GetData(), wxFILE
);
368 res
= wxFileNameFromPath( f
);
369 fd
= new wxFileData( res
, f
);
370 wxString s
= fd
->GetName();
371 if (m_showHidden
|| (s
[0] != _T('.')))
376 f
= wxFindNextFile();
379 SortItems( ListCompare
, 0 );
382 void wxFileCtrl::SetWild( const wxString
&wild
)
388 void wxFileCtrl::MakeDir()
390 wxString
new_name( _T("NewName") );
391 wxString
path( m_dirName
);
394 if (wxFileExists(path
))
396 // try NewName0, NewName1 etc.
399 new_name
= _("NewName");
401 num
.Printf( _T("%d"), i
);
408 } while (wxFileExists(path
));
414 wxMessageDialog
dialog(this, _("Operation not permitted."), _("Error"), wxOK
| wxICON_ERROR
);
419 wxFileData
*fd
= new wxFileData( new_name
, path
);
423 int id
= Add( fd
, item
);
427 SortItems( ListCompare
, 0 );
428 id
= FindItem( 0, (long)fd
);
434 void wxFileCtrl::GoToParentDir()
436 if (m_dirName
!= _T("/"))
438 wxString
fname( wxFileNameFromPath(m_dirName
) );
439 m_dirName
= wxPathOnly( m_dirName
);
440 if (m_dirName
.IsEmpty()) m_dirName
= _T("/");
442 int id
= FindItem( 0, fname
);
445 SetItemState( id
, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
451 void wxFileCtrl::GoToHomeDir()
453 wxString s
= wxGetUserHome( wxString() );
456 SetItemState( 0, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
460 void wxFileCtrl::GoToDir( const wxString
&dir
)
464 SetItemState( 0, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
468 void wxFileCtrl::GetDir( wxString
&dir
)
473 void wxFileCtrl::OnListDeleteItem( wxListEvent
&event
)
475 wxFileData
*fd
= (wxFileData
*)event
.m_item
.m_data
;
479 void wxFileCtrl::OnListEndLabelEdit( wxListEvent
&event
)
481 wxFileData
*fd
= (wxFileData
*)event
.m_item
.m_data
;
484 if ((event
.GetLabel().IsEmpty()) ||
485 (event
.GetLabel() == _(".")) ||
486 (event
.GetLabel() == _("..")) ||
487 (event
.GetLabel().First( _T("/") ) != wxNOT_FOUND
))
489 wxMessageDialog
dialog(this, _("Illegal directory name."), _("Error"), wxOK
| wxICON_ERROR
);
495 wxString
new_name( wxPathOnly( fd
->GetFullName() ) );
497 new_name
+= event
.GetLabel();
501 if (wxFileExists(new_name
))
503 wxMessageDialog
dialog(this, _("File name exists already."), _("Error"), wxOK
| wxICON_ERROR
);
508 if (wxRenameFile(fd
->GetFullName(),new_name
))
510 fd
->SetNewName( new_name
, event
.GetLabel() );
511 SetItemState( event
.GetItem(), wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
512 EnsureVisible( event
.GetItem() );
516 wxMessageDialog
dialog(this, _("Operation not permitted."), _("Error"), wxOK
| wxICON_ERROR
);
522 //-----------------------------------------------------------------------------
524 //-----------------------------------------------------------------------------
526 #define ID_LIST_MODE wxID_FILEDLGG
527 #define ID_REPORT_MODE wxID_FILEDLGG + 1
528 #define ID_UP_DIR wxID_FILEDLGG + 5
529 #define ID_PARENT_DIR wxID_FILEDLGG + 6
530 #define ID_NEW_DIR wxID_FILEDLGG + 7
531 #define ID_CHOICE wxID_FILEDLGG + 8
532 #define ID_TEXT wxID_FILEDLGG + 9
533 #define ID_LIST_CTRL wxID_FILEDLGG + 10
534 #define ID_ACTIVATED wxID_FILEDLGG + 11
536 IMPLEMENT_DYNAMIC_CLASS(wxFileDialog
,wxDialog
)
538 BEGIN_EVENT_TABLE(wxFileDialog
,wxDialog
)
539 EVT_BUTTON(ID_LIST_MODE
, wxFileDialog::OnList
)
540 EVT_BUTTON(ID_REPORT_MODE
, wxFileDialog::OnReport
)
541 EVT_BUTTON(ID_UP_DIR
, wxFileDialog::OnUp
)
542 EVT_BUTTON(ID_PARENT_DIR
, wxFileDialog::OnHome
)
543 EVT_BUTTON(ID_NEW_DIR
, wxFileDialog::OnNew
)
544 EVT_BUTTON(wxID_OK
, wxFileDialog::OnListOk
)
545 EVT_LIST_ITEM_SELECTED(ID_LIST_CTRL
, wxFileDialog::OnSelected
)
546 EVT_LIST_ITEM_ACTIVATED(ID_LIST_CTRL
, wxFileDialog::OnActivated
)
547 EVT_CHOICE(ID_CHOICE
,wxFileDialog::OnChoice
)
548 EVT_TEXT_ENTER(ID_TEXT
,wxFileDialog::OnTextEnter
)
551 wxFileDialog::wxFileDialog(wxWindow
*parent
,
552 const wxString
& message
,
553 const wxString
& defaultDir
,
554 const wxString
& defaultFile
,
555 const wxString
& wildCard
,
557 const wxPoint
& pos
) :
558 wxDialog( parent
, -1, message
, pos
, wxDefaultSize
, wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
)
563 m_dialogStyle
= style
;
568 m_dir
= getcwd( buf
, sizeof(buf
) );
572 m_path
+= defaultFile
;
573 m_fileName
= defaultFile
;
574 m_wildCard
= wildCard
;
577 // interpret wildcards
579 if (m_wildCard
.IsEmpty())
580 m_wildCard
= _("All files (*)|*");
582 wxStringTokenizer
tokens( m_wildCard
, _T("|") );
584 wxString firstWildText
;
585 if (tokens
.CountTokens() == 1)
587 firstWildText
= tokens
.GetNextToken();
588 firstWild
= firstWildText
;
592 wxASSERT_MSG( tokens
.CountTokens() % 2 == 0, _T("Wrong file type descripition") );
593 firstWildText
= tokens
.GetNextToken();
594 firstWild
= tokens
.GetNextToken();
599 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
601 wxBoxSizer
*buttonsizer
= new wxBoxSizer( wxHORIZONTAL
);
605 but
= new wxBitmapButton( this, ID_LIST_MODE
, wxBitmap( listview_xpm
) );
607 but
->SetToolTip( _("View files as a list view") );
609 buttonsizer
->Add( but
, 0, wxALL
, 5 );
611 but
= new wxBitmapButton( this, ID_REPORT_MODE
, wxBitmap( repview_xpm
) );
613 but
->SetToolTip( _("View files as a detailed view") );
615 buttonsizer
->Add( but
, 0, wxALL
, 5 );
617 buttonsizer
->Add( 30, 5, 1 );
619 but
= new wxBitmapButton( this, ID_UP_DIR
, wxBitmap( dir_up_xpm
) );
621 but
->SetToolTip( _("Go to parent directory") );
623 buttonsizer
->Add( but
, 0, wxALL
, 5 );
625 but
= new wxBitmapButton( this, ID_PARENT_DIR
, wxBitmap(home_xpm
) );
627 but
->SetToolTip( _("Go to home directory") );
629 buttonsizer
->Add( but
, 0, wxALL
, 5);
631 buttonsizer
->Add( 20, 20 );
633 but
= new wxBitmapButton( this, ID_NEW_DIR
, wxBitmap(new_dir_xpm
) );
635 but
->SetToolTip( _("Create new directory") );
637 buttonsizer
->Add( but
, 0, wxALL
, 5 );
639 mainsizer
->Add( buttonsizer
, 0, wxALL
| wxEXPAND
, 5 );
641 wxBoxSizer
*staticsizer
= new wxBoxSizer( wxHORIZONTAL
);
642 staticsizer
->Add( new wxStaticText( this, -1, _("Current directory:") ), 0, wxRIGHT
, 10 );
643 m_static
= new wxStaticText( this, -1, m_dir
);
644 staticsizer
->Add( m_static
, 1 );
645 mainsizer
->Add( staticsizer
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxBOTTOM
, 10 );
647 m_list
= new wxFileCtrl( this, ID_LIST_CTRL
, m_dir
, firstWild
, wxDefaultPosition
, wxSize(440,180),
648 wxLC_LIST
| wxSUNKEN_BORDER
| wxLC_SINGLE_SEL
);
649 mainsizer
->Add( m_list
, 1, wxEXPAND
| wxLEFT
|wxRIGHT
, 10 );
651 wxBoxSizer
*textsizer
= new wxBoxSizer( wxHORIZONTAL
);
652 m_text
= new wxTextCtrl( this, ID_TEXT
, m_fileName
, wxDefaultPosition
, wxDefaultSize
, wxPROCESS_ENTER
);
653 textsizer
->Add( m_text
, 1, wxCENTER
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
654 textsizer
->Add( new wxButton( this, wxID_OK
, _("OK") ), 0, wxCENTER
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
655 mainsizer
->Add( textsizer
, 0, wxEXPAND
);
657 wxBoxSizer
*choicesizer
= new wxBoxSizer( wxHORIZONTAL
);
658 m_choice
= new wxChoice( this, ID_CHOICE
);
659 choicesizer
->Add( m_choice
, 1, wxCENTER
|wxALL
, 10 );
660 choicesizer
->Add( new wxButton( this, wxID_CANCEL
, _("Cancel") ), 0, wxCENTER
| wxALL
, 10 );
661 mainsizer
->Add( choicesizer
, 0, wxEXPAND
);
663 m_choice
->Append( firstWildText
, (void*) new wxString( firstWild
) );
664 while (tokens
.HasMoreTokens())
666 firstWildText
= tokens
.GetNextToken();
667 firstWild
= tokens
.GetNextToken();
668 m_choice
->Append( firstWildText
, (void*) new wxString( firstWild
) );
670 m_choice
->SetSelection( 0 );
672 SetAutoLayout( TRUE
);
673 SetSizer( mainsizer
);
675 mainsizer
->Fit( this );
676 mainsizer
->SetSizeHints( this );
680 if (m_fileName
.IsEmpty())
688 wxFileDialog::~wxFileDialog()
692 void wxFileDialog::OnChoice( wxCommandEvent
&event
)
694 wxString
*str
= (wxString
*) m_choice
->GetClientData( event
.GetInt() );
695 m_list
->SetWild( *str
);
698 void wxFileDialog::OnActivated( wxListEvent
&WXUNUSED(event
) )
700 wxCommandEvent
cevent(wxEVT_COMMAND_BUTTON_CLICKED
, wxID_OK
);
701 cevent
.SetEventObject( this );
702 GetEventHandler()->ProcessEvent( cevent
);
705 void wxFileDialog::OnTextEnter( wxCommandEvent
&WXUNUSED(event
) )
707 wxCommandEvent
cevent(wxEVT_COMMAND_BUTTON_CLICKED
, wxID_OK
);
708 cevent
.SetEventObject( this );
709 GetEventHandler()->ProcessEvent( cevent
);
712 void wxFileDialog::OnSelected( wxListEvent
&event
)
714 if (FindFocus() == m_list
)
715 m_text
->SetValue( event
.m_item
.m_text
);
718 void wxFileDialog::OnListOk( wxCommandEvent
&event
)
720 wxString
filename( m_text
->GetValue() );
722 m_list
->GetDir( dir
);
723 if (filename
.IsEmpty()) return;
724 if (filename
== _T(".")) return;
726 if (filename
== _T(".."))
728 m_list
->GoToParentDir();
730 m_list
->GetDir( dir
);
731 m_static
->SetLabel( dir
);
735 if (filename
== _T("~"))
737 m_list
->GoToHomeDir();
739 m_list
->GetDir( dir
);
740 m_static
->SetLabel( dir
);
744 if (filename
[0] == _T('~'))
746 filename
.Remove( 0, 1 );
747 wxString
tmp( wxGetUserHome() );
753 if ((filename
.Find(_T('*')) != wxNOT_FOUND
) ||
754 (filename
.Find(_T('?')) != wxNOT_FOUND
))
756 if (filename
.Find(_T('/')) != wxNOT_FOUND
)
758 wxMessageBox(_("Illegal file specification."), _("Error"), wxOK
| wxICON_ERROR
);
761 m_list
->SetWild( filename
);
765 if (dir
!= _T("/")) dir
+= _T("/");
766 if (filename
[0] != _T('/'))
772 if (wxDirExists(filename
))
774 m_list
->GoToDir( filename
);
775 if (filename
== _T("/"))
776 m_text
->SetValue( _T("") );
778 m_text
->SetValue( _T("..") );
779 m_list
->GetDir( dir
);
780 m_static
->SetLabel( dir
);
784 if ( (m_dialogStyle
& wxSAVE
) && (m_dialogStyle
& wxOVERWRITE_PROMPT
) )
786 if (wxFileExists( filename
))
789 msg
.Printf( _("File '%s' already exists, do you really want to "
790 "overwrite it?"), filename
.c_str() );
792 if (wxMessageBox(msg
, _("Confirm"), wxYES_NO
) != wxYES
)
796 else if ( (m_dialogStyle
& wxOPEN
) && (m_dialogStyle
& wxFILE_MUST_EXIST
) )
798 if ( !wxFileExists( filename
) )
800 wxMessageBox(_("Please choose an existing file."), _("Error"), wxOK
| wxICON_ERROR
);
809 void wxFileDialog::OnList( wxCommandEvent
&WXUNUSED(event
) )
811 m_list
->ChangeToListMode();
815 void wxFileDialog::OnReport( wxCommandEvent
&WXUNUSED(event
) )
817 m_list
->ChangeToReportMode();
821 void wxFileDialog::OnUp( wxCommandEvent
&WXUNUSED(event
) )
823 m_list
->GoToParentDir();
826 m_list
->GetDir( dir
);
827 m_static
->SetLabel( dir
);
830 void wxFileDialog::OnHome( wxCommandEvent
&WXUNUSED(event
) )
832 m_list
->GoToHomeDir();
835 m_list
->GetDir( dir
);
836 m_static
->SetLabel( dir
);
839 void wxFileDialog::OnNew( wxCommandEvent
&WXUNUSED(event
) )
844 void wxFileDialog::SetPath( const wxString
& path
)
846 // not only set the full path but also update filename and dir
851 wxSplitPath(path
, &m_dir
, &m_fileName
, &ext
);
854 m_fileName
+= _T(".");
860 // ----------------------------------------------------------------------------
862 // ----------------------------------------------------------------------------
865 wxFileSelectorEx(const wxChar
*message
,
866 const wxChar
*default_path
,
867 const wxChar
*default_filename
,
868 int *indexDefaultExtension
,
869 const wxChar
*wildcard
,
874 // TODO: implement this somehow
875 return wxFileSelector(message
, default_path
, default_filename
, _T(""),
876 wildcard
, flags
, parent
, x
, y
);
879 wxString
wxFileSelector( const wxChar
*title
,
880 const wxChar
*defaultDir
, const wxChar
*defaultFileName
,
881 const wxChar
*defaultExtension
, const wxChar
*filter
, int flags
,
882 wxWindow
*parent
, int x
, int y
)
885 if ( defaultExtension
&& !filter
)
886 filter2
= wxString(_T("*.")) + wxString(defaultExtension
) ;
890 wxString defaultDirString
;
892 defaultDirString
= defaultDir
;
894 wxString defaultFilenameString
;
896 defaultFilenameString
= defaultFileName
;
898 wxFileDialog
fileDialog( parent
, title
, defaultDirString
, defaultFilenameString
, filter2
, flags
, wxPoint(x
, y
) );
900 if ( fileDialog
.ShowModal() == wxID_OK
)
902 return fileDialog
.GetPath();
906 return wxEmptyString
;
910 wxString
wxLoadFileSelector( const wxChar
*what
, const wxChar
*extension
, const wxChar
*default_name
, wxWindow
*parent
)
912 wxChar
*ext
= (wxChar
*)extension
;
915 wxString str
= _("Load %s file");
916 wxSprintf(prompt
, str
, what
);
918 if (*ext
== _T('.')) ext
++;
920 wxSprintf(wild
, _T("*.%s"), ext
);
922 return wxFileSelector (prompt
, (const wxChar
*) NULL
, default_name
, ext
, wild
, 0, parent
);
925 wxString
wxSaveFileSelector(const wxChar
*what
, const wxChar
*extension
, const wxChar
*default_name
,
928 wxChar
*ext
= (wxChar
*)extension
;
931 wxString str
= _("Save %s file");
932 wxSprintf(prompt
, str
, what
);
934 if (*ext
== _T('.')) ext
++;
936 wxSprintf(wild
, _T("*.%s"), ext
);
938 return wxFileSelector (prompt
, (const wxChar
*) NULL
, default_name
, ext
, wild
, 0, parent
);