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