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