1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxGenericFileDialog
4 // Author: Robert Roebling
7 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_FILEDLGG_H_
13 #define _WX_FILEDLGG_H_
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "filedlgg.h"
19 #include "wx/dialog.h"
20 #include "wx/listctrl.h"
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
30 class wxGenericFileDialog
;
36 #if defined(__WXUNIVERSAL__)||defined(__WXGTK__)||defined(__WXX11__)||defined(__WXMGL__)
37 #define USE_GENERIC_FILEDIALOG
40 #ifdef USE_GENERIC_FILEDIALOG
42 //-----------------------------------------------------------------------------
44 //-----------------------------------------------------------------------------
46 WXDLLEXPORT_DATA(extern const wxChar
*)wxFileSelectorPromptStr
;
47 WXDLLEXPORT_DATA(extern const wxChar
*)wxFileSelectorDefaultWildcardStr
;
49 #endif // USE_GENERIC_FILEDIALOG
51 //-------------------------------------------------------------------------
53 //-------------------------------------------------------------------------
55 class WXDLLEXPORT wxGenericFileDialog
: public wxDialog
58 wxGenericFileDialog() { }
60 wxGenericFileDialog(wxWindow
*parent
,
61 const wxString
& message
= wxFileSelectorPromptStr
,
62 const wxString
& defaultDir
= _T(""),
63 const wxString
& defaultFile
= _T(""),
64 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
66 const wxPoint
& pos
= wxDefaultPosition
);
67 virtual ~wxGenericFileDialog();
69 void SetMessage(const wxString
& message
) { SetTitle(message
); }
70 void SetPath(const wxString
& path
);
71 void SetDirectory(const wxString
& dir
) { m_dir
= dir
; }
72 void SetFilename(const wxString
& name
) { m_fileName
= name
; }
73 void SetWildcard(const wxString
& wildCard
) { m_wildCard
= wildCard
; }
74 void SetStyle(long style
) { m_dialogStyle
= style
; }
75 void SetFilterIndex(int filterIndex
);
77 wxString
GetMessage() const { return m_message
; }
78 wxString
GetPath() const { return m_path
; }
79 wxString
GetDirectory() const { return m_dir
; }
80 wxString
GetFilename() const { return m_fileName
; }
81 wxString
GetWildcard() const { return m_wildCard
; }
82 long GetStyle() const { return m_dialogStyle
; }
83 int GetFilterIndex() const { return m_filterIndex
; }
85 // for multiple file selection
86 void GetPaths(wxArrayString
& paths
) const;
87 void GetFilenames(wxArrayString
& files
) const;
89 // implementation only from now on
90 // -------------------------------
92 virtual int ShowModal();
94 void OnSelected( wxListEvent
&event
);
95 void OnActivated( wxListEvent
&event
);
96 void OnList( wxCommandEvent
&event
);
97 void OnReport( wxCommandEvent
&event
);
98 void OnUp( wxCommandEvent
&event
);
99 void OnHome( wxCommandEvent
&event
);
100 void OnListOk( wxCommandEvent
&event
);
101 void OnNew( wxCommandEvent
&event
);
102 void OnChoiceFilter( wxCommandEvent
&event
);
103 void OnTextEnter( wxCommandEvent
&event
);
104 void OnTextChange( wxCommandEvent
&event
);
105 void OnCheck( wxCommandEvent
&event
);
107 void HandleAction( const wxString
&fn
);
110 // use the filter with the given index
111 void DoSetFilterIndex(int filterindex
);
116 wxString m_path
; // Full path
120 wxString m_filterExtension
;
125 wxStaticText
*m_static
;
128 DECLARE_DYNAMIC_CLASS(wxGenericFileDialog
)
129 DECLARE_EVENT_TABLE()
131 // these variables are preserved between wxGenericFileDialog calls
132 static long ms_lastViewStyle
; // list or report?
133 static bool ms_lastShowHidden
; // did we show hidden files?
136 #ifdef USE_GENERIC_FILEDIALOG
138 class WXDLLEXPORT wxFileDialog
: public wxGenericFileDialog
140 DECLARE_DYNAMIC_CLASS(wxFileDialog
)
145 wxFileDialog(wxWindow
*parent
,
146 const wxString
& message
= wxFileSelectorPromptStr
,
147 const wxString
& defaultDir
= _T(""),
148 const wxString
& defaultFile
= _T(""),
149 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
151 const wxPoint
& pos
= wxDefaultPosition
)
152 :wxGenericFileDialog(parent
, message
, defaultDir
, defaultFile
, wildCard
, style
, pos
)
157 // File selector - backward compatibility
159 wxFileSelector(const wxChar
*message
= wxFileSelectorPromptStr
,
160 const wxChar
*default_path
= NULL
,
161 const wxChar
*default_filename
= NULL
,
162 const wxChar
*default_extension
= NULL
,
163 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
165 wxWindow
*parent
= NULL
,
166 int x
= -1, int y
= -1);
168 // An extended version of wxFileSelector
170 wxFileSelectorEx(const wxChar
*message
= wxFileSelectorPromptStr
,
171 const wxChar
*default_path
= NULL
,
172 const wxChar
*default_filename
= NULL
,
173 int *indexDefaultExtension
= NULL
,
174 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
176 wxWindow
*parent
= NULL
,
177 int x
= -1, int y
= -1);
179 // Ask for filename to load
181 wxLoadFileSelector(const wxChar
*what
,
182 const wxChar
*extension
,
183 const wxChar
*default_name
= (const wxChar
*)NULL
,
184 wxWindow
*parent
= (wxWindow
*) NULL
);
186 // Ask for filename to save
188 wxSaveFileSelector(const wxChar
*what
,
189 const wxChar
*extension
,
190 const wxChar
*default_name
= (const wxChar
*) NULL
,
191 wxWindow
*parent
= (wxWindow
*) NULL
);
193 #endif // USE_GENERIC_FILEDIALOG
195 //-----------------------------------------------------------------------------
197 //-----------------------------------------------------------------------------
199 class WXDLLEXPORT wxFileData
211 wxFileData( const wxString
&name
, const wxString
&fname
, fileType type
);
212 wxString
GetName() const;
213 wxString
GetFullName() const;
214 wxString
GetHint() const;
216 // the wxFileCtrl fields in report view
217 enum fileListFieldType
229 wxString
GetEntry( fileListFieldType num
) const;
234 bool IsDrive() const;
235 long GetSize() const { return m_size
; }
236 int GetHour() const { return m_hour
; }
237 int GetMinute() const { return m_minute
; }
238 int GetYear() const { return m_year
; }
239 int GetMonth() const { return m_month
; }
240 int GetDay() const { return m_day
; }
242 void MakeItem( wxListItem
&item
);
243 void SetNewName( const wxString
&name
, const wxString
&fname
);
254 wxString m_permissions
;
258 //-----------------------------------------------------------------------------
260 //-----------------------------------------------------------------------------
262 class WXDLLEXPORT wxFileCtrl
: public wxListCtrl
266 wxFileCtrl( wxWindow
*win
,
268 const wxString
&wild
,
270 const wxPoint
&pos
= wxDefaultPosition
,
271 const wxSize
&size
= wxDefaultSize
,
272 long style
= wxLC_LIST
,
273 const wxValidator
&validator
= wxDefaultValidator
,
274 const wxString
&name
= wxT("filelist") );
275 virtual ~wxFileCtrl();
277 void ChangeToListMode();
278 void ChangeToReportMode();
279 void ChangeToIconMode();
280 void ShowHidden( bool show
= TRUE
);
281 bool GetShowHidden() const { return m_showHidden
; }
283 long Add( wxFileData
*fd
, wxListItem
&item
);
285 virtual void StatusbarText( wxChar
*WXUNUSED(text
) ) {};
287 void GoToParentDir();
289 void GoToDir( const wxString
&dir
);
290 void SetWild( const wxString
&wild
);
291 wxString
GetWild() const { return m_wild
; }
292 void GetDir( wxString
&dir
);
293 wxString
GetDir() const { return m_dirName
; }
295 void OnListDeleteItem( wxListEvent
&event
);
296 void OnListEndLabelEdit( wxListEvent
&event
);
297 void OnListColClick( wxListEvent
&event
);
299 // Associate commonly used UI controls with wxFileCtrl so that they can be
300 // disabled when they cannot be used (e.g. can't go to parent directory
301 // if wxFileCtrl already is in the root dir):
302 void SetGoToParentControl(wxWindow
*ctrl
) { m_goToParentControl
= ctrl
; }
303 void SetNewDirControl(wxWindow
*ctrl
) { m_newDirControl
= ctrl
; }
305 void SortItems(wxFileData::fileListFieldType field
, bool foward
);
306 bool GetSortDirection() const { return m_sort_foward
> 0; }
307 wxFileData::fileListFieldType
GetSortField() const { return m_sort_field
; }
310 void FreeItemData(const wxListItem
& item
);
311 void FreeAllItemsData();
317 wxWindow
*m_goToParentControl
;
318 wxWindow
*m_newDirControl
;
321 wxFileData::fileListFieldType m_sort_field
;
323 DECLARE_DYNAMIC_CLASS(wxFileCtrl
);
324 DECLARE_EVENT_TABLE()