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