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