]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/generic/filedlgg.h
fixed the channel order for Mac (alpha comes first)
[wxWidgets.git] / include / wx / generic / filedlgg.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: filedlgg.h
3// Purpose: wxGenericFileDialog
4// Author: Robert Roebling
5// Modified by:
6// Created: 8/17/99
7// Copyright: (c) Robert Roebling
8// RCS-ID: $Id$
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_FILEDLGG_H_
13#define _WX_FILEDLGG_H_
14
15#if defined(__GNUG__) && !defined(__APPLE__)
16#pragma interface "filedlgg.h"
17#endif
18
19#include "wx/dialog.h"
20#include "wx/listctrl.h"
21#include "wx/datetime.h"
22
23//-----------------------------------------------------------------------------
24// classes
25//-----------------------------------------------------------------------------
26
27class WXDLLEXPORT wxBitmapButton;
28class WXDLLEXPORT wxCheckBox;
29class WXDLLEXPORT wxChoice;
30class WXDLLEXPORT wxFileData;
31class WXDLLEXPORT wxFileCtrl;
32class WXDLLEXPORT wxGenericFileDialog;
33class WXDLLEXPORT wxListEvent;
34class WXDLLEXPORT wxListItem;
35class WXDLLEXPORT wxStaticText;
36class WXDLLEXPORT wxTextCtrl;
37
38#if defined(__WXUNIVERSAL__)||defined(__WXGTK__)||defined(__WXX11__)||defined(__WXMGL__)||defined(__WXCOCOA__)
39 #define USE_GENERIC_FILEDIALOG
40#endif
41
42#ifdef USE_GENERIC_FILEDIALOG
43
44//-----------------------------------------------------------------------------
45// data
46//-----------------------------------------------------------------------------
47
48WXDLLEXPORT_DATA(extern const wxChar *)wxFileSelectorPromptStr;
49WXDLLEXPORT_DATA(extern const wxChar *)wxFileSelectorDefaultWildcardStr;
50
51#endif // USE_GENERIC_FILEDIALOG
52
53//-------------------------------------------------------------------------
54// File selector
55//-------------------------------------------------------------------------
56
57class WXDLLEXPORT wxGenericFileDialog: public wxDialog
58{
59public:
60 wxGenericFileDialog() { }
61
62 wxGenericFileDialog(wxWindow *parent,
63 const wxString& message = wxFileSelectorPromptStr,
64 const wxString& defaultDir = _T(""),
65 const wxString& defaultFile = _T(""),
66 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
67 long style = 0,
68 const wxPoint& pos = wxDefaultPosition);
69 virtual ~wxGenericFileDialog();
70
71 void SetMessage(const wxString& message) { SetTitle(message); }
72 void SetPath(const wxString& path);
73 void SetDirectory(const wxString& dir) { m_dir = dir; }
74 void SetFilename(const wxString& name) { m_fileName = name; }
75 void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; }
76 void SetStyle(long style) { m_dialogStyle = style; }
77 void SetFilterIndex(int filterIndex);
78
79 wxString GetMessage() const { return m_message; }
80 wxString GetPath() const { return m_path; }
81 wxString GetDirectory() const { return m_dir; }
82 wxString GetFilename() const { return m_fileName; }
83 wxString GetWildcard() const { return m_wildCard; }
84 long GetStyle() const { return m_dialogStyle; }
85 int GetFilterIndex() const { return m_filterIndex; }
86
87 // for multiple file selection
88 void GetPaths(wxArrayString& paths) const;
89 void GetFilenames(wxArrayString& files) const;
90
91 // implementation only from now on
92 // -------------------------------
93
94 virtual int ShowModal();
95
96 void OnSelected( wxListEvent &event );
97 void OnActivated( wxListEvent &event );
98 void OnList( wxCommandEvent &event );
99 void OnReport( wxCommandEvent &event );
100 void OnUp( wxCommandEvent &event );
101 void OnHome( wxCommandEvent &event );
102 void OnListOk( wxCommandEvent &event );
103 void OnNew( wxCommandEvent &event );
104 void OnChoiceFilter( wxCommandEvent &event );
105 void OnTextEnter( wxCommandEvent &event );
106 void OnTextChange( wxCommandEvent &event );
107 void OnCheck( wxCommandEvent &event );
108
109 virtual void HandleAction( const wxString &fn );
110
111 virtual void UpdateControls();
112
113protected:
114 // use the filter with the given index
115 void DoSetFilterIndex(int filterindex);
116
117 wxString m_message;
118 long m_dialogStyle;
119 wxString m_dir;
120 wxString m_path; // Full path
121 wxString m_fileName;
122 wxString m_wildCard;
123 int m_filterIndex;
124 wxString m_filterExtension;
125 wxChoice *m_choice;
126 wxTextCtrl *m_text;
127 wxFileCtrl *m_list;
128 wxCheckBox *m_check;
129 wxStaticText *m_static;
130 wxBitmapButton *m_upDirButton;
131 wxBitmapButton *m_newDirButton;
132
133private:
134 DECLARE_DYNAMIC_CLASS(wxGenericFileDialog)
135 DECLARE_EVENT_TABLE()
136
137 // these variables are preserved between wxGenericFileDialog calls
138 static long ms_lastViewStyle; // list or report?
139 static bool ms_lastShowHidden; // did we show hidden files?
140};
141
142#ifdef USE_GENERIC_FILEDIALOG
143
144class WXDLLEXPORT wxFileDialog: public wxGenericFileDialog
145{
146 DECLARE_DYNAMIC_CLASS(wxFileDialog)
147
148public:
149 wxFileDialog() {}
150
151 wxFileDialog(wxWindow *parent,
152 const wxString& message = wxFileSelectorPromptStr,
153 const wxString& defaultDir = _T(""),
154 const wxString& defaultFile = _T(""),
155 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
156 long style = 0,
157 const wxPoint& pos = wxDefaultPosition)
158 :wxGenericFileDialog(parent, message, defaultDir, defaultFile, wildCard, style, pos)
159 {
160 }
161};
162
163// File selector - backward compatibility
164WXDLLEXPORT wxString
165wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
166 const wxChar *default_path = NULL,
167 const wxChar *default_filename = NULL,
168 const wxChar *default_extension = NULL,
169 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
170 int flags = 0,
171 wxWindow *parent = NULL,
172 int x = -1, int y = -1);
173
174// An extended version of wxFileSelector
175WXDLLEXPORT wxString
176wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
177 const wxChar *default_path = NULL,
178 const wxChar *default_filename = NULL,
179 int *indexDefaultExtension = NULL,
180 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
181 int flags = 0,
182 wxWindow *parent = NULL,
183 int x = -1, int y = -1);
184
185// Ask for filename to load
186WXDLLEXPORT wxString
187wxLoadFileSelector(const wxChar *what,
188 const wxChar *extension,
189 const wxChar *default_name = (const wxChar *)NULL,
190 wxWindow *parent = (wxWindow *) NULL);
191
192// Ask for filename to save
193WXDLLEXPORT wxString
194wxSaveFileSelector(const wxChar *what,
195 const wxChar *extension,
196 const wxChar *default_name = (const wxChar *) NULL,
197 wxWindow *parent = (wxWindow *) NULL);
198
199#endif // USE_GENERIC_FILEDIALOG
200
201//-----------------------------------------------------------------------------
202// wxFileData
203//-----------------------------------------------------------------------------
204
205class WXDLLEXPORT wxFileData
206{
207public:
208 enum fileType
209 {
210 is_file = 0x0000,
211 is_dir = 0x0001,
212 is_link = 0x0002,
213 is_exe = 0x0004,
214 is_drive = 0x0008
215 };
216
217 wxFileData( const wxString &filePath, const wxString &fileName,
218 fileType type, int image_id );
219
220 // get the name of the file, dir, drive
221 wxString GetFileName() const { return m_fileName; }
222 // get the full path + name of the file, dir, path
223 wxString GetFilePath() const { return m_filePath; }
224 long GetSize() const { return m_size; }
225 // Get the type of file, either file extension or <DIR>, <LINK>, <DRIVE>
226 wxString GetType() const;
227 // get the last modification time
228 wxDateTime GetTime() const { return m_dateTime; }
229 wxString GetModificationTime() const;
230 // in UNIX get rwx for file, in MSW get attributes ARHS
231 wxString GetPermissions() const { return m_permissions; }
232 int GetImageId() const { return m_image; }
233
234 bool IsDir() const { return (m_type & is_dir ) != 0; }
235 bool IsLink() const { return (m_type & is_link ) != 0; }
236 bool IsExe() const { return (m_type & is_exe ) != 0; }
237 bool IsDrive() const { return (m_type & is_drive) != 0; }
238
239 int GetFileType() const { return m_type; }
240
241 // the wxFileCtrl fields in report view
242 enum fileListFieldType
243 {
244 FileList_Name,
245 FileList_Size,
246 FileList_Type,
247 FileList_Time,
248#if defined(__UNIX__) || defined(__WIN32__)
249 FileList_Perm,
250#endif // defined(__UNIX__) || defined(__WIN32__)
251 FileList_Max
252 };
253
254 wxString GetEntry( fileListFieldType num ) const;
255
256 // Get a string representation of the file info
257 wxString GetHint() const;
258 void MakeItem( wxListItem &item );
259 void SetNewName( const wxString &filePath, const wxString &fileName );
260
261private:
262 wxString m_fileName;
263 wxString m_filePath;
264 long m_size;
265 wxDateTime m_dateTime;
266 wxString m_permissions;
267 int m_type;
268 int m_image;
269};
270
271//-----------------------------------------------------------------------------
272// wxFileCtrl
273//-----------------------------------------------------------------------------
274
275class WXDLLEXPORT wxFileCtrl : public wxListCtrl
276{
277public:
278 wxFileCtrl();
279 wxFileCtrl( wxWindow *win,
280 wxWindowID id,
281 const wxString &wild,
282 bool showHidden,
283 const wxPoint &pos = wxDefaultPosition,
284 const wxSize &size = wxDefaultSize,
285 long style = wxLC_LIST,
286 const wxValidator &validator = wxDefaultValidator,
287 const wxString &name = wxT("filelist") );
288 virtual ~wxFileCtrl();
289
290 virtual void ChangeToListMode();
291 virtual void ChangeToReportMode();
292 virtual void ChangeToSmallIconMode();
293 virtual void ShowHidden( bool show = TRUE );
294 bool GetShowHidden() const { return m_showHidden; }
295
296 virtual long Add( wxFileData *fd, wxListItem &item );
297 virtual void UpdateFiles();
298 virtual void MakeDir();
299 virtual void GoToParentDir();
300 virtual void GoToHomeDir();
301 virtual void GoToDir( const wxString &dir );
302 virtual void SetWild( const wxString &wild );
303 wxString GetWild() const { return m_wild; }
304 wxString GetDir() const { return m_dirName; }
305
306 void OnListDeleteItem( wxListEvent &event );
307 void OnListEndLabelEdit( wxListEvent &event );
308 void OnListColClick( wxListEvent &event );
309
310 virtual void SortItems(wxFileData::fileListFieldType field, bool foward);
311 bool GetSortDirection() const { return m_sort_foward; }
312 wxFileData::fileListFieldType GetSortField() const { return m_sort_field; }
313
314protected:
315 void FreeItemData(const wxListItem& item);
316 void FreeAllItemsData();
317
318 wxString m_dirName;
319 bool m_showHidden;
320 wxString m_wild;
321
322 bool m_sort_foward;
323 wxFileData::fileListFieldType m_sort_field;
324
325private:
326 DECLARE_DYNAMIC_CLASS(wxFileCtrl);
327 DECLARE_EVENT_TABLE()
328};
329
330#endif
331 // _WX_FILEDLGG_H_
332
333