]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/filedlgg.h
Added wxFopen to the MSLU code.
[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();
4e1901b7
RR
98
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 }
4e1901b7
RR
142
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
b600ed13 165 // Full copy constructor
81169710 166 wxFileData( const wxFileData& fileData ) { Copy(fileData); }
b600ed13 167 // Create a filedata from this information
06cc1fb9
JS
168 wxFileData( const wxString &filePath, const wxString &fileName,
169 fileType type, int image_id );
170
81169710
VZ
171 // make a full copy of the other wxFileData
172 void Copy( const wxFileData &other );
173
b600ed13
VZ
174 // (re)read the extra data about the file from the system
175 void ReadData();
176
06cc1fb9
JS
177 // get the name of the file, dir, drive
178 wxString GetFileName() const { return m_fileName; }
179 // get the full path + name of the file, dir, path
180 wxString GetFilePath() const { return m_filePath; }
b600ed13
VZ
181 // Set the path + name and name of the item
182 void SetNewName( const wxString &filePath, const wxString &fileName );
183
184 // Get the size of the file in bytes
06cc1fb9
JS
185 long GetSize() const { return m_size; }
186 // Get the type of file, either file extension or <DIR>, <LINK>, <DRIVE>
b600ed13 187 wxString GetFileType() const;
06cc1fb9 188 // get the last modification time
b600ed13
VZ
189 wxDateTime GetDateTime() const { return m_dateTime; }
190 // Get the time as a formatted string
06cc1fb9
JS
191 wxString GetModificationTime() const;
192 // in UNIX get rwx for file, in MSW get attributes ARHS
193 wxString GetPermissions() const { return m_permissions; }
b600ed13 194 // Get the id of the image used in a wxImageList
06cc1fb9
JS
195 int GetImageId() const { return m_image; }
196
b600ed13 197 bool IsFile() const { return !IsDir() && !IsLink() && !IsDrive(); }
06cc1fb9
JS
198 bool IsDir() const { return (m_type & is_dir ) != 0; }
199 bool IsLink() const { return (m_type & is_link ) != 0; }
200 bool IsExe() const { return (m_type & is_exe ) != 0; }
201 bool IsDrive() const { return (m_type & is_drive) != 0; }
202
b600ed13
VZ
203 // Get/Set the type of file, file/dir/drive/link
204 int GetType() const { return m_type; }
23254b13
JS
205
206 // the wxFileCtrl fields in report view
207 enum fileListFieldType
208 {
209 FileList_Name,
06cc1fb9 210 FileList_Size,
23254b13 211 FileList_Type,
23254b13 212 FileList_Time,
06cc1fb9 213#if defined(__UNIX__) || defined(__WIN32__)
23254b13 214 FileList_Perm,
06cc1fb9 215#endif // defined(__UNIX__) || defined(__WIN32__)
23254b13
JS
216 FileList_Max
217 };
218
b600ed13 219 // Get the entry for report view of wxFileCtrl
23254b13
JS
220 wxString GetEntry( fileListFieldType num ) const;
221
06cc1fb9
JS
222 // Get a string representation of the file info
223 wxString GetHint() const;
b600ed13 224 // initialize a wxListItem attributes
23254b13 225 void MakeItem( wxListItem &item );
23254b13 226
81169710
VZ
227
228 wxFileData& operator = (const wxFileData& fd) { Copy(fd); return *this; }
229
23254b13 230private:
23254b13 231 wxString m_fileName;
06cc1fb9 232 wxString m_filePath;
23254b13 233 long m_size;
06cc1fb9 234 wxDateTime m_dateTime;
23254b13
JS
235 wxString m_permissions;
236 int m_type;
06cc1fb9 237 int m_image;
23254b13
JS
238};
239
240//-----------------------------------------------------------------------------
241// wxFileCtrl
242//-----------------------------------------------------------------------------
243
244class WXDLLEXPORT wxFileCtrl : public wxListCtrl
245{
246public:
247 wxFileCtrl();
248 wxFileCtrl( wxWindow *win,
249 wxWindowID id,
250 const wxString &wild,
251 bool showHidden,
252 const wxPoint &pos = wxDefaultPosition,
253 const wxSize &size = wxDefaultSize,
254 long style = wxLC_LIST,
255 const wxValidator &validator = wxDefaultValidator,
256 const wxString &name = wxT("filelist") );
257 virtual ~wxFileCtrl();
258
06cc1fb9
JS
259 virtual void ChangeToListMode();
260 virtual void ChangeToReportMode();
261 virtual void ChangeToSmallIconMode();
ca65c044 262 virtual void ShowHidden( bool show = true );
23254b13
JS
263 bool GetShowHidden() const { return m_showHidden; }
264
06cc1fb9 265 virtual long Add( wxFileData *fd, wxListItem &item );
b600ed13 266 virtual void UpdateItem(const wxListItem &item);
06cc1fb9
JS
267 virtual void UpdateFiles();
268 virtual void MakeDir();
269 virtual void GoToParentDir();
270 virtual void GoToHomeDir();
271 virtual void GoToDir( const wxString &dir );
272 virtual void SetWild( const wxString &wild );
23254b13 273 wxString GetWild() const { return m_wild; }
23254b13
JS
274 wxString GetDir() const { return m_dirName; }
275
276 void OnListDeleteItem( wxListEvent &event );
81169710 277 void OnListDeleteAllItems( wxListEvent &event );
23254b13
JS
278 void OnListEndLabelEdit( wxListEvent &event );
279 void OnListColClick( wxListEvent &event );
280
06cc1fb9
JS
281 virtual void SortItems(wxFileData::fileListFieldType field, bool foward);
282 bool GetSortDirection() const { return m_sort_foward; }
23254b13
JS
283 wxFileData::fileListFieldType GetSortField() const { return m_sort_field; }
284
06cc1fb9 285protected:
81169710 286 void FreeItemData(wxListItem& item);
23254b13
JS
287 void FreeAllItemsData();
288
289 wxString m_dirName;
290 bool m_showHidden;
291 wxString m_wild;
292
06cc1fb9 293 bool m_sort_foward;
23254b13
JS
294 wxFileData::fileListFieldType m_sort_field;
295
06cc1fb9 296private:
23254b13
JS
297 DECLARE_DYNAMIC_CLASS(wxFileCtrl);
298 DECLARE_EVENT_TABLE()
299};
8b17ba72 300
b600ed13 301#endif // _WX_FILEDLGG_H_
9cedab37 302