]>
Commit | Line | Data |
---|---|---|
8b17ba72 RR |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: filedlgg.h | |
23254b13 | 3 | // Purpose: wxGenericFileDialog |
8b17ba72 RR |
4 | // Author: Robert Roebling |
5 | // Modified by: | |
6 | // Created: 8/17/99 | |
7 | // Copyright: (c) Robert Roebling | |
8 | // RCS-ID: $Id$ | |
c8c0e54c | 9 | // Licence: wxWindows licence |
8b17ba72 RR |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_FILEDLGG_H_ | |
13 | #define _WX_FILEDLGG_H_ | |
14 | ||
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
8b17ba72 RR |
16 | #pragma interface "filedlgg.h" |
17 | #endif | |
18 | ||
23254b13 | 19 | #include "wx/listctrl.h" |
06cc1fb9 | 20 | #include "wx/datetime.h" |
8b17ba72 RR |
21 | |
22 | //----------------------------------------------------------------------------- | |
23 | // classes | |
24 | //----------------------------------------------------------------------------- | |
25 | ||
06cc1fb9 JS |
26 | class WXDLLEXPORT wxBitmapButton; |
27 | class WXDLLEXPORT wxCheckBox; | |
28 | class WXDLLEXPORT wxChoice; | |
29 | class WXDLLEXPORT wxFileData; | |
30 | class WXDLLEXPORT wxFileCtrl; | |
31 | class WXDLLEXPORT wxGenericFileDialog; | |
32 | class WXDLLEXPORT wxListEvent; | |
33 | class WXDLLEXPORT wxListItem; | |
34 | class WXDLLEXPORT wxStaticText; | |
35 | class WXDLLEXPORT wxTextCtrl; | |
8b17ba72 | 36 | |
c29e2743 | 37 | #if defined(__WXUNIVERSAL__)||defined(__WXGTK__)||defined(__WXX11__)||defined(__WXMGL__)||defined(__WXCOCOA__) |
23254b13 JS |
38 | #define USE_GENERIC_FILEDIALOG |
39 | #endif | |
40 | ||
8b17ba72 | 41 | //------------------------------------------------------------------------- |
b600ed13 | 42 | // wxGenericFileDialog |
8b17ba72 RR |
43 | //------------------------------------------------------------------------- |
44 | ||
f74172ab | 45 | class WXDLLEXPORT wxGenericFileDialog: public wxFileDialogBase |
8b17ba72 RR |
46 | { |
47 | public: | |
6463b9f5 | 48 | wxGenericFileDialog() { } |
8b17ba72 | 49 | |
23254b13 | 50 | wxGenericFileDialog(wxWindow *parent, |
8b17ba72 | 51 | const wxString& message = wxFileSelectorPromptStr, |
f74172ab VZ |
52 | const wxString& defaultDir = wxEmptyString, |
53 | const wxString& defaultFile = wxEmptyString, | |
8b17ba72 RR |
54 | const wxString& wildCard = wxFileSelectorDefaultWildcardStr, |
55 | long style = 0, | |
56 | const wxPoint& pos = wxDefaultPosition); | |
23254b13 | 57 | virtual ~wxGenericFileDialog(); |
8b17ba72 | 58 | |
f74172ab VZ |
59 | virtual void SetMessage(const wxString& message) { SetTitle(message); } |
60 | virtual void SetPath(const wxString& path); | |
61 | virtual void SetFilterIndex(int filterIndex); | |
c61f4f6d | 62 | |
7941ba11 | 63 | // for multiple file selection |
f74172ab VZ |
64 | virtual void GetPaths(wxArrayString& paths) const; |
65 | virtual void GetFilenames(wxArrayString& files) const; | |
c8c0e54c | 66 | |
9cedab37 VZ |
67 | // implementation only from now on |
68 | // ------------------------------- | |
69 | ||
70 | virtual int ShowModal(); | |
71 | ||
8b17ba72 RR |
72 | void OnSelected( wxListEvent &event ); |
73 | void OnActivated( wxListEvent &event ); | |
74 | void OnList( wxCommandEvent &event ); | |
75 | void OnReport( wxCommandEvent &event ); | |
8b17ba72 RR |
76 | void OnUp( wxCommandEvent &event ); |
77 | void OnHome( wxCommandEvent &event ); | |
78 | void OnListOk( wxCommandEvent &event ); | |
0b855868 | 79 | void OnNew( wxCommandEvent &event ); |
2b5f62a0 | 80 | void OnChoiceFilter( wxCommandEvent &event ); |
cae5359f | 81 | void OnTextEnter( wxCommandEvent &event ); |
df413171 | 82 | void OnTextChange( wxCommandEvent &event ); |
bf9e3e73 | 83 | void OnCheck( wxCommandEvent &event ); |
c61f4f6d | 84 | |
06cc1fb9 JS |
85 | virtual void HandleAction( const wxString &fn ); |
86 | ||
87 | virtual void UpdateControls(); | |
c8c0e54c VZ |
88 | |
89 | protected: | |
2b5f62a0 VZ |
90 | // use the filter with the given index |
91 | void DoSetFilterIndex(int filterindex); | |
92 | ||
cefc49fd | 93 | wxString m_filterExtension; |
9c884972 RR |
94 | wxChoice *m_choice; |
95 | wxTextCtrl *m_text; | |
96 | wxFileCtrl *m_list; | |
97 | wxCheckBox *m_check; | |
98 | wxStaticText *m_static; | |
06cc1fb9 JS |
99 | wxBitmapButton *m_upDirButton; |
100 | wxBitmapButton *m_newDirButton; | |
c8c0e54c | 101 | |
8b17ba72 | 102 | private: |
23254b13 | 103 | DECLARE_DYNAMIC_CLASS(wxGenericFileDialog) |
8b17ba72 | 104 | DECLARE_EVENT_TABLE() |
cefc49fd | 105 | |
23254b13 | 106 | // these variables are preserved between wxGenericFileDialog calls |
9cedab37 VZ |
107 | static long ms_lastViewStyle; // list or report? |
108 | static bool ms_lastShowHidden; // did we show hidden files? | |
8b17ba72 RR |
109 | }; |
110 | ||
23254b13 JS |
111 | #ifdef USE_GENERIC_FILEDIALOG |
112 | ||
113 | class WXDLLEXPORT wxFileDialog: public wxGenericFileDialog | |
114 | { | |
115 | DECLARE_DYNAMIC_CLASS(wxFileDialog) | |
116 | ||
117 | public: | |
6463b9f5 | 118 | wxFileDialog() {} |
23254b13 JS |
119 | |
120 | wxFileDialog(wxWindow *parent, | |
121 | const wxString& message = wxFileSelectorPromptStr, | |
122 | const wxString& defaultDir = _T(""), | |
123 | const wxString& defaultFile = _T(""), | |
124 | const wxString& wildCard = wxFileSelectorDefaultWildcardStr, | |
125 | long style = 0, | |
6463b9f5 JS |
126 | const wxPoint& pos = wxDefaultPosition) |
127 | :wxGenericFileDialog(parent, message, defaultDir, defaultFile, wildCard, style, pos) | |
128 | { | |
129 | } | |
23254b13 JS |
130 | }; |
131 | ||
23254b13 | 132 | #endif // USE_GENERIC_FILEDIALOG |
8b17ba72 | 133 | |
23254b13 | 134 | //----------------------------------------------------------------------------- |
b600ed13 | 135 | // wxFileData - a class to hold the file info for the wxFileCtrl |
23254b13 JS |
136 | //----------------------------------------------------------------------------- |
137 | ||
138 | class WXDLLEXPORT wxFileData | |
139 | { | |
140 | public: | |
141 | enum fileType | |
142 | { | |
06cc1fb9 | 143 | is_file = 0x0000, |
23254b13 JS |
144 | is_dir = 0x0001, |
145 | is_link = 0x0002, | |
146 | is_exe = 0x0004, | |
147 | is_drive = 0x0008 | |
148 | }; | |
149 | ||
b600ed13 | 150 | // Full copy constructor |
81169710 | 151 | wxFileData( const wxFileData& fileData ) { Copy(fileData); } |
b600ed13 | 152 | // Create a filedata from this information |
06cc1fb9 JS |
153 | wxFileData( const wxString &filePath, const wxString &fileName, |
154 | fileType type, int image_id ); | |
155 | ||
81169710 VZ |
156 | // make a full copy of the other wxFileData |
157 | void Copy( const wxFileData &other ); | |
158 | ||
b600ed13 VZ |
159 | // (re)read the extra data about the file from the system |
160 | void ReadData(); | |
161 | ||
06cc1fb9 JS |
162 | // get the name of the file, dir, drive |
163 | wxString GetFileName() const { return m_fileName; } | |
164 | // get the full path + name of the file, dir, path | |
165 | wxString GetFilePath() const { return m_filePath; } | |
b600ed13 VZ |
166 | // Set the path + name and name of the item |
167 | void SetNewName( const wxString &filePath, const wxString &fileName ); | |
168 | ||
169 | // Get the size of the file in bytes | |
06cc1fb9 JS |
170 | long GetSize() const { return m_size; } |
171 | // Get the type of file, either file extension or <DIR>, <LINK>, <DRIVE> | |
b600ed13 | 172 | wxString GetFileType() const; |
06cc1fb9 | 173 | // get the last modification time |
b600ed13 VZ |
174 | wxDateTime GetDateTime() const { return m_dateTime; } |
175 | // Get the time as a formatted string | |
06cc1fb9 JS |
176 | wxString GetModificationTime() const; |
177 | // in UNIX get rwx for file, in MSW get attributes ARHS | |
178 | wxString GetPermissions() const { return m_permissions; } | |
b600ed13 | 179 | // Get the id of the image used in a wxImageList |
06cc1fb9 JS |
180 | int GetImageId() const { return m_image; } |
181 | ||
b600ed13 | 182 | bool IsFile() const { return !IsDir() && !IsLink() && !IsDrive(); } |
06cc1fb9 JS |
183 | bool IsDir() const { return (m_type & is_dir ) != 0; } |
184 | bool IsLink() const { return (m_type & is_link ) != 0; } | |
185 | bool IsExe() const { return (m_type & is_exe ) != 0; } | |
186 | bool IsDrive() const { return (m_type & is_drive) != 0; } | |
187 | ||
b600ed13 VZ |
188 | // Get/Set the type of file, file/dir/drive/link |
189 | int GetType() const { return m_type; } | |
23254b13 JS |
190 | |
191 | // the wxFileCtrl fields in report view | |
192 | enum fileListFieldType | |
193 | { | |
194 | FileList_Name, | |
06cc1fb9 | 195 | FileList_Size, |
23254b13 | 196 | FileList_Type, |
23254b13 | 197 | FileList_Time, |
06cc1fb9 | 198 | #if defined(__UNIX__) || defined(__WIN32__) |
23254b13 | 199 | FileList_Perm, |
06cc1fb9 | 200 | #endif // defined(__UNIX__) || defined(__WIN32__) |
23254b13 JS |
201 | FileList_Max |
202 | }; | |
203 | ||
b600ed13 | 204 | // Get the entry for report view of wxFileCtrl |
23254b13 JS |
205 | wxString GetEntry( fileListFieldType num ) const; |
206 | ||
06cc1fb9 JS |
207 | // Get a string representation of the file info |
208 | wxString GetHint() const; | |
b600ed13 | 209 | // initialize a wxListItem attributes |
23254b13 | 210 | void MakeItem( wxListItem &item ); |
23254b13 | 211 | |
81169710 VZ |
212 | |
213 | wxFileData& operator = (const wxFileData& fd) { Copy(fd); return *this; } | |
214 | ||
23254b13 | 215 | private: |
23254b13 | 216 | wxString m_fileName; |
06cc1fb9 | 217 | wxString m_filePath; |
23254b13 | 218 | long m_size; |
06cc1fb9 | 219 | wxDateTime m_dateTime; |
23254b13 JS |
220 | wxString m_permissions; |
221 | int m_type; | |
06cc1fb9 | 222 | int m_image; |
23254b13 JS |
223 | }; |
224 | ||
225 | //----------------------------------------------------------------------------- | |
226 | // wxFileCtrl | |
227 | //----------------------------------------------------------------------------- | |
228 | ||
229 | class WXDLLEXPORT wxFileCtrl : public wxListCtrl | |
230 | { | |
231 | public: | |
232 | wxFileCtrl(); | |
233 | wxFileCtrl( wxWindow *win, | |
234 | wxWindowID id, | |
235 | const wxString &wild, | |
236 | bool showHidden, | |
237 | const wxPoint &pos = wxDefaultPosition, | |
238 | const wxSize &size = wxDefaultSize, | |
239 | long style = wxLC_LIST, | |
240 | const wxValidator &validator = wxDefaultValidator, | |
241 | const wxString &name = wxT("filelist") ); | |
242 | virtual ~wxFileCtrl(); | |
243 | ||
06cc1fb9 JS |
244 | virtual void ChangeToListMode(); |
245 | virtual void ChangeToReportMode(); | |
246 | virtual void ChangeToSmallIconMode(); | |
247 | virtual void ShowHidden( bool show = TRUE ); | |
23254b13 JS |
248 | bool GetShowHidden() const { return m_showHidden; } |
249 | ||
06cc1fb9 | 250 | virtual long Add( wxFileData *fd, wxListItem &item ); |
b600ed13 | 251 | virtual void UpdateItem(const wxListItem &item); |
06cc1fb9 JS |
252 | virtual void UpdateFiles(); |
253 | virtual void MakeDir(); | |
254 | virtual void GoToParentDir(); | |
255 | virtual void GoToHomeDir(); | |
256 | virtual void GoToDir( const wxString &dir ); | |
257 | virtual void SetWild( const wxString &wild ); | |
23254b13 | 258 | wxString GetWild() const { return m_wild; } |
23254b13 JS |
259 | wxString GetDir() const { return m_dirName; } |
260 | ||
261 | void OnListDeleteItem( wxListEvent &event ); | |
81169710 | 262 | void OnListDeleteAllItems( wxListEvent &event ); |
23254b13 JS |
263 | void OnListEndLabelEdit( wxListEvent &event ); |
264 | void OnListColClick( wxListEvent &event ); | |
265 | ||
06cc1fb9 JS |
266 | virtual void SortItems(wxFileData::fileListFieldType field, bool foward); |
267 | bool GetSortDirection() const { return m_sort_foward; } | |
23254b13 JS |
268 | wxFileData::fileListFieldType GetSortField() const { return m_sort_field; } |
269 | ||
06cc1fb9 | 270 | protected: |
81169710 | 271 | void FreeItemData(wxListItem& item); |
23254b13 JS |
272 | void FreeAllItemsData(); |
273 | ||
274 | wxString m_dirName; | |
275 | bool m_showHidden; | |
276 | wxString m_wild; | |
277 | ||
06cc1fb9 | 278 | bool m_sort_foward; |
23254b13 JS |
279 | wxFileData::fileListFieldType m_sort_field; |
280 | ||
06cc1fb9 | 281 | private: |
23254b13 JS |
282 | DECLARE_DYNAMIC_CLASS(wxFileCtrl); |
283 | DECLARE_EVENT_TABLE() | |
284 | }; | |
8b17ba72 | 285 | |
b600ed13 | 286 | #endif // _WX_FILEDLGG_H_ |
9cedab37 | 287 |