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 5000
527 #define ID_REPORT_MODE 5001
528 #define ID_UP_DIR 5005
529 #define ID_PARENT_DIR 5006
530 #define ID_NEW_DIR 5007
531 #define ID_CHOICE 5008
533 #define ID_LIST_CTRL 5010
535 IMPLEMENT_DYNAMIC_CLASS(wxFileDialog
,wxDialog
)
537 BEGIN_EVENT_TABLE(wxFileDialog
,wxDialog
)
538 EVT_BUTTON(ID_LIST_MODE
, wxFileDialog::OnList
)
539 EVT_BUTTON(ID_REPORT_MODE
, wxFileDialog::OnReport
)
540 EVT_BUTTON(ID_UP_DIR
, wxFileDialog::OnUp
)
541 EVT_BUTTON(ID_PARENT_DIR
, wxFileDialog::OnHome
)
542 EVT_BUTTON(ID_NEW_DIR
, wxFileDialog::OnNew
)
543 EVT_BUTTON(wxID_OK
, wxFileDialog::OnListOk
)
544 EVT_LIST_ITEM_SELECTED(ID_LIST_CTRL
, wxFileDialog::OnSelected
)
545 EVT_LIST_ITEM_ACTIVATED(ID_LIST_CTRL
, wxFileDialog::OnActivated
)
546 EVT_CHOICE(ID_CHOICE
,wxFileDialog::OnChoice
)
547 EVT_TEXT_ENTER(ID_TEXT
,wxFileDialog::OnTextEnter
)
550 wxFileDialog::wxFileDialog(wxWindow
*parent
,
551 const wxString
& message
,
552 const wxString
& defaultDir
,
553 const wxString
& defaultFile
,
554 const wxString
& wildCard
,
556 const wxPoint
& pos
) :
557 wxDialog( parent
, -1, message
, pos
, wxDefaultSize
, wxDEFAULT_DIALOG_STYLE
| wxRESIZE_BORDER
)
562 m_dialogStyle
= style
;
567 m_dir
= getcwd( buf
, sizeof(buf
) );
571 m_path
+= defaultFile
;
572 m_fileName
= defaultFile
;
573 m_wildCard
= wildCard
;
576 // interpret wildcards
578 if (m_wildCard
.IsEmpty())
579 m_wildCard
= _("All files (*)|*");
581 wxStringTokenizer
tokens( m_wildCard
, _T("|") );
583 wxString firstWildText
;
584 if (tokens
.CountTokens() == 1)
586 firstWildText
= tokens
.GetNextToken();
587 firstWild
= firstWildText
;
591 wxASSERT_MSG( tokens
.CountTokens() % 2 == 0, _T("Wrong file type descripition") );
592 firstWildText
= tokens
.GetNextToken();
593 firstWild
= tokens
.GetNextToken();
598 wxBoxSizer
*mainsizer
= new wxBoxSizer( wxVERTICAL
);
600 wxBoxSizer
*buttonsizer
= new wxBoxSizer( wxHORIZONTAL
);
604 but
= new wxBitmapButton( this, ID_LIST_MODE
, wxBitmap( listview_xpm
) );
606 but
->SetToolTip( _("View files as a list view") );
608 buttonsizer
->Add( but
, 0, wxALL
, 5 );
610 but
= new wxBitmapButton( this, ID_REPORT_MODE
, wxBitmap( repview_xpm
) );
612 but
->SetToolTip( _("View files as a detailed view") );
614 buttonsizer
->Add( but
, 0, wxALL
, 5 );
616 buttonsizer
->Add( 30, 5, 1 );
618 but
= new wxBitmapButton( this, ID_UP_DIR
, wxBitmap( dir_up_xpm
) );
620 but
->SetToolTip( _("Go to parent directory") );
622 buttonsizer
->Add( but
, 0, wxALL
, 5 );
624 but
= new wxBitmapButton( this, ID_PARENT_DIR
, wxBitmap(home_xpm
) );
626 but
->SetToolTip( _("Go to home directory") );
628 buttonsizer
->Add( but
, 0, wxALL
, 5);
630 buttonsizer
->Add( 20, 20 );
632 but
= new wxBitmapButton( this, ID_NEW_DIR
, wxBitmap(new_dir_xpm
) );
634 but
->SetToolTip( _("Create new directory") );
636 buttonsizer
->Add( but
, 0, wxALL
, 5 );
638 mainsizer
->Add( buttonsizer
, 0, wxALL
| wxEXPAND
, 5 );
640 wxBoxSizer
*staticsizer
= new wxBoxSizer( wxHORIZONTAL
);
641 staticsizer
->Add( new wxStaticText( this, -1, _("Current directory:") ), 0, wxRIGHT
, 10 );
642 m_static
= new wxStaticText( this, -1, m_dir
);
643 staticsizer
->Add( m_static
, 1 );
644 mainsizer
->Add( staticsizer
, 0, wxEXPAND
| wxLEFT
|wxRIGHT
|wxBOTTOM
, 10 );
646 m_list
= new wxFileCtrl( this, ID_LIST_CTRL
, m_dir
, firstWild
, wxDefaultPosition
, wxSize(440,180),
647 wxLC_LIST
| wxSUNKEN_BORDER
| wxLC_SINGLE_SEL
);
648 mainsizer
->Add( m_list
, 1, wxEXPAND
| wxLEFT
|wxRIGHT
, 10 );
650 wxBoxSizer
*textsizer
= new wxBoxSizer( wxHORIZONTAL
);
651 m_text
= new wxTextCtrl( this, ID_TEXT
, m_fileName
, wxDefaultPosition
, wxDefaultSize
, wxPROCESS_ENTER
);
652 textsizer
->Add( m_text
, 1, wxCENTER
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
653 textsizer
->Add( new wxButton( this, wxID_OK
, _("OK") ), 0, wxCENTER
| wxLEFT
|wxRIGHT
|wxTOP
, 10 );
654 mainsizer
->Add( textsizer
, 0, wxEXPAND
);
656 wxBoxSizer
*choicesizer
= new wxBoxSizer( wxHORIZONTAL
);
657 m_choice
= new wxChoice( this, ID_CHOICE
);
658 choicesizer
->Add( m_choice
, 1, wxCENTER
|wxALL
, 10 );
659 choicesizer
->Add( new wxButton( this, wxID_CANCEL
, _("Cancel") ), 0, wxCENTER
| wxALL
, 10 );
660 mainsizer
->Add( choicesizer
, 0, wxEXPAND
);
662 m_choice
->Append( firstWildText
, (void*) new wxString( firstWild
) );
663 while (tokens
.HasMoreTokens())
665 firstWildText
= tokens
.GetNextToken();
666 firstWild
= tokens
.GetNextToken();
667 m_choice
->Append( firstWildText
, (void*) new wxString( firstWild
) );
669 m_choice
->SetSelection( 0 );
671 SetAutoLayout( TRUE
);
672 SetSizer( mainsizer
);
674 mainsizer
->Fit( this );
675 mainsizer
->SetSizeHints( this );
679 if (m_fileName
.IsEmpty())
687 wxFileDialog::~wxFileDialog()
691 void wxFileDialog::OnChoice( wxCommandEvent
&event
)
693 wxString
*str
= (wxString
*) m_choice
->GetClientData( event
.GetInt() );
694 m_list
->SetWild( *str
);
697 void wxFileDialog::OnActivated( wxListEvent
&WXUNUSED(event
) )
699 wxCommandEvent
cevent(wxEVT_COMMAND_BUTTON_CLICKED
, wxID_OK
);
700 cevent
.SetEventObject( this );
701 GetEventHandler()->ProcessEvent( cevent
);
704 void wxFileDialog::OnTextEnter( wxCommandEvent
&WXUNUSED(event
) )
706 wxCommandEvent
cevent(wxEVT_COMMAND_BUTTON_CLICKED
, wxID_OK
);
707 cevent
.SetEventObject( this );
708 GetEventHandler()->ProcessEvent( cevent
);
711 void wxFileDialog::OnSelected( wxListEvent
&event
)
713 if (FindFocus() == m_list
)
714 m_text
->SetValue( event
.m_item
.m_text
);
717 void wxFileDialog::OnListOk( wxCommandEvent
&event
)
719 wxString
filename( m_text
->GetValue() );
721 m_list
->GetDir( dir
);
722 if (filename
.IsEmpty()) return;
723 if (filename
== _T(".")) return;
725 if (filename
== _T(".."))
727 m_list
->GoToParentDir();
729 m_list
->GetDir( dir
);
730 m_static
->SetLabel( dir
);
734 if (filename
== _T("~"))
736 m_list
->GoToHomeDir();
738 m_list
->GetDir( dir
);
739 m_static
->SetLabel( dir
);
743 if (filename
[0] == _T('~'))
745 filename
.Remove( 0, 1 );
746 wxString
tmp( wxGetUserHome() );
752 if ((filename
.Find(_T('*')) != wxNOT_FOUND
) ||
753 (filename
.Find(_T('?')) != wxNOT_FOUND
))
755 if (filename
.Find(_T('/')) != wxNOT_FOUND
)
757 wxMessageBox(_("Illegal file specification."), _("Error"), wxOK
| wxICON_ERROR
);
760 m_list
->SetWild( filename
);
764 if (dir
!= _T("/")) dir
+= _T("/");
765 if (filename
[0] != _T('/'))
771 if (wxDirExists(filename
))
773 m_list
->GoToDir( filename
);
774 if (filename
== _T("/"))
775 m_text
->SetValue( _T("") );
777 m_text
->SetValue( _T("..") );
778 m_list
->GetDir( dir
);
779 m_static
->SetLabel( dir
);
783 if ( (m_dialogStyle
& wxSAVE
) && (m_dialogStyle
& wxOVERWRITE_PROMPT
) )
785 if (wxFileExists( filename
))
788 msg
.Printf( _("File '%s' already exists, do you really want to "
789 "overwrite it?"), filename
.c_str() );
791 if (wxMessageBox(msg
, _("Confirm"), wxYES_NO
) != wxYES
)
795 else if ( (m_dialogStyle
& wxOPEN
) && (m_dialogStyle
& wxFILE_MUST_EXIST
) )
797 if ( !wxFileExists( filename
) )
799 wxMessageBox(_("Please choose an existing file."), _("Error"), wxOK
| wxICON_ERROR
);
808 void wxFileDialog::OnList( wxCommandEvent
&WXUNUSED(event
) )
810 m_list
->ChangeToListMode();
814 void wxFileDialog::OnReport( wxCommandEvent
&WXUNUSED(event
) )
816 m_list
->ChangeToReportMode();
820 void wxFileDialog::OnUp( wxCommandEvent
&WXUNUSED(event
) )
822 m_list
->GoToParentDir();
825 m_list
->GetDir( dir
);
826 m_static
->SetLabel( dir
);
829 void wxFileDialog::OnHome( wxCommandEvent
&WXUNUSED(event
) )
831 m_list
->GoToHomeDir();
834 m_list
->GetDir( dir
);
835 m_static
->SetLabel( dir
);
838 void wxFileDialog::OnNew( wxCommandEvent
&WXUNUSED(event
) )
843 void wxFileDialog::SetPath( const wxString
& path
)
845 // not only set the full path but also update filename and dir
850 wxSplitPath(path
, &m_dir
, &m_fileName
, &ext
);
853 m_fileName
+= _T(".");
859 // ----------------------------------------------------------------------------
861 // ----------------------------------------------------------------------------
864 wxFileSelectorEx(const wxChar
*message
,
865 const wxChar
*default_path
,
866 const wxChar
*default_filename
,
867 int *indexDefaultExtension
,
868 const wxChar
*wildcard
,
873 // TODO: implement this somehow
874 return wxFileSelector(message
, default_path
, default_filename
, _T(""),
875 wildcard
, flags
, parent
, x
, y
);
878 wxString
wxFileSelector( const wxChar
*title
,
879 const wxChar
*defaultDir
, const wxChar
*defaultFileName
,
880 const wxChar
*defaultExtension
, const wxChar
*filter
, int flags
,
881 wxWindow
*parent
, int x
, int y
)
884 if ( defaultExtension
&& !filter
)
885 filter2
= wxString(_T("*.")) + wxString(defaultExtension
) ;
889 wxString defaultDirString
;
891 defaultDirString
= defaultDir
;
893 wxString defaultFilenameString
;
895 defaultFilenameString
= defaultFileName
;
897 wxFileDialog
fileDialog( parent
, title
, defaultDirString
, defaultFilenameString
, filter2
, flags
, wxPoint(x
, y
) );
899 if ( fileDialog
.ShowModal() == wxID_OK
)
901 return fileDialog
.GetPath();
905 return wxEmptyString
;
909 wxString
wxLoadFileSelector( const wxChar
*what
, const wxChar
*extension
, const wxChar
*default_name
, wxWindow
*parent
)
911 wxChar
*ext
= (wxChar
*)extension
;
914 wxString str
= _("Load %s file");
915 wxSprintf(prompt
, str
, what
);
917 if (*ext
== _T('.')) ext
++;
919 wxSprintf(wild
, _T("*.%s"), ext
);
921 return wxFileSelector (prompt
, (const wxChar
*) NULL
, default_name
, ext
, wild
, 0, parent
);
924 wxString
wxSaveFileSelector(const wxChar
*what
, const wxChar
*extension
, const wxChar
*default_name
,
927 wxChar
*ext
= (wxChar
*)extension
;
930 wxString str
= _("Save %s file");
931 wxSprintf(prompt
, str
, what
);
933 if (*ext
== _T('.')) ext
++;
935 wxSprintf(wild
, _T("*.%s"), ext
);
937 return wxFileSelector (prompt
, (const wxChar
*) NULL
, default_name
, ext
, wild
, 0, parent
);