Doc updates, wxsizer et al
[wxWidgets.git] / include / wx / generic / filedlgg.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: filedlgg.h
3 // Purpose: wxFileDialog
4 // Author: Robert Roebling
5 // Modified by:
6 // Created: 8/17/99
7 // Copyright: (c) Robert Roebling
8 // RCS-ID: $Id$
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_FILEDLGG_H_
13 #define _WX_FILEDLGG_H_
14
15 #ifdef __GNUG__
16 #pragma interface "filedlgg.h"
17 #endif
18
19 #include "wx/defs.h"
20
21 #include "wx/dialog.h"
22 #include "wx/checkbox.h"
23 #include "wx/listctrl.h"
24 #include "wx/textctrl.h"
25 #include "wx/choice.h"
26 #include "wx/checkbox.h"
27 #include "wx/stattext.h"
28
29 //-----------------------------------------------------------------------------
30 // data
31 //-----------------------------------------------------------------------------
32
33 WXDLLEXPORT_DATA(extern const wxChar *)wxFileSelectorPromptStr;
34 WXDLLEXPORT_DATA(extern const wxChar *)wxFileSelectorDefaultWildcardStr;
35
36 //-----------------------------------------------------------------------------
37 // classes
38 //-----------------------------------------------------------------------------
39
40 class wxFileData;
41 class wxFileCtrl;
42 class wxFileDialog;
43
44 //-----------------------------------------------------------------------------
45 // wxFileData
46 //-----------------------------------------------------------------------------
47
48 class wxFileData : public wxObject
49 {
50 private:
51 wxString m_name;
52 wxString m_fileName;
53 long m_size;
54 int m_hour;
55 int m_minute;
56 int m_year;
57 int m_month;
58 int m_day;
59 wxString m_permissions;
60 bool m_isDir;
61 bool m_isLink;
62 bool m_isExe;
63
64 public:
65 wxFileData() {}
66 wxFileData( const wxString &name, const wxString &fname );
67 wxString GetName() const;
68 wxString GetFullName() const;
69 wxString GetHint() const;
70 wxString GetEntry( const int num );
71 bool IsDir();
72 bool IsLink();
73 bool IsExe();
74 long GetSize();
75 void MakeItem( wxListItem &item );
76 void SetNewName( const wxString &name, const wxString &fname );
77
78 private:
79 DECLARE_DYNAMIC_CLASS(wxFileData);
80 };
81
82 //-----------------------------------------------------------------------------
83 // wxFileCtrl
84 //-----------------------------------------------------------------------------
85
86 class wxFileCtrl : public wxListCtrl
87 {
88 private:
89 wxString m_dirName;
90 bool m_showHidden;
91 wxString m_wild;
92
93 public:
94 wxFileCtrl();
95 wxFileCtrl( wxWindow *win, const wxWindowID id,
96 const wxString &dirName, const wxString &wild,
97 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
98 const long style = wxLC_LIST, const wxValidator &validator = wxDefaultValidator,
99 const wxString &name = _T("filelist") );
100 void ChangeToListMode();
101 void ChangeToReportMode();
102 void ChangeToIconMode();
103 void ShowHidden( bool show = TRUE );
104 long Add( wxFileData *fd, wxListItem &item );
105 void Update();
106 virtual void StatusbarText( char *WXUNUSED(text) ) {};
107 void MakeDir();
108 void GoToParentDir();
109 void GoToHomeDir();
110 void GoToDir( const wxString &dir );
111 void SetWild( const wxString &wild );
112 void GetDir( wxString &dir );
113 void OnListDeleteItem( wxListEvent &event );
114 void OnListEndLabelEdit( wxListEvent &event );
115
116 private:
117 DECLARE_DYNAMIC_CLASS(wxFileCtrl);
118 DECLARE_EVENT_TABLE()
119 };
120
121 //-------------------------------------------------------------------------
122 // File selector
123 //-------------------------------------------------------------------------
124
125 class wxFileDialog: public wxDialog
126 {
127 public:
128 wxFileDialog() { }
129
130 wxFileDialog(wxWindow *parent,
131 const wxString& message = wxFileSelectorPromptStr,
132 const wxString& defaultDir = "",
133 const wxString& defaultFile = "",
134 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
135 long style = 0,
136 const wxPoint& pos = wxDefaultPosition);
137 ~wxFileDialog();
138
139 void SetMessage(const wxString& message) { m_message = message; }
140 void SetPath(const wxString& path);
141 void SetDirectory(const wxString& dir) { m_dir = dir; }
142 void SetFilename(const wxString& name) { m_fileName = name; }
143 void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; }
144 void SetStyle(long style) { m_dialogStyle = style; }
145 void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; }
146
147 wxString GetMessage() const { return m_message; }
148 wxString GetPath() const { return m_path; }
149 wxString GetDirectory() const { return m_dir; }
150 wxString GetFilename() const { return m_fileName; }
151 wxString GetWildcard() const { return m_wildCard; }
152 long GetStyle() const { return m_dialogStyle; }
153 int GetFilterIndex() const { return m_filterIndex ; }
154
155 void OnSelected( wxListEvent &event );
156 void OnActivated( wxListEvent &event );
157 void OnList( wxCommandEvent &event );
158 void OnReport( wxCommandEvent &event );
159 void OnUp( wxCommandEvent &event );
160 void OnHome( wxCommandEvent &event );
161 void OnListOk( wxCommandEvent &event );
162 void OnNew( wxCommandEvent &event );
163 void OnChoice( wxCommandEvent &event );
164 void OnTextEnter( wxCommandEvent &event );
165
166 protected:
167 wxString m_message;
168 long m_dialogStyle;
169 wxString m_dir;
170 wxString m_path; // Full path
171 wxString m_fileName;
172 wxString m_wildCard;
173 int m_filterIndex;
174 wxChoice *m_choice;
175 wxTextCtrl *m_text;
176 wxFileCtrl *m_list;
177 wxCheckBox *m_check;
178 wxStaticText *m_static;
179
180 private:
181 DECLARE_DYNAMIC_CLASS(wxFileDialog)
182 DECLARE_EVENT_TABLE()
183 };
184
185 #define wxOPEN 1
186 #define wxSAVE 2
187 #define wxOVERWRITE_PROMPT 4
188 #define wxHIDE_READONLY 8
189 #define wxFILE_MUST_EXIST 16
190
191 // File selector - backward compatibility
192 WXDLLEXPORT wxString
193 wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
194 const wxChar *default_path = NULL,
195 const wxChar *default_filename = NULL,
196 const wxChar *default_extension = NULL,
197 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
198 int flags = 0,
199 wxWindow *parent = NULL,
200 int x = -1, int y = -1);
201
202 // An extended version of wxFileSelector
203 WXDLLEXPORT wxString
204 wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
205 const wxChar *default_path = NULL,
206 const wxChar *default_filename = NULL,
207 int *indexDefaultExtension = NULL,
208 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
209 int flags = 0,
210 wxWindow *parent = NULL,
211 int x = -1, int y = -1);
212
213 // Ask for filename to load
214 WXDLLEXPORT wxString
215 wxLoadFileSelector(const wxChar *what,
216 const wxChar *extension,
217 const wxChar *default_name = (const wxChar *)NULL,
218 wxWindow *parent = (wxWindow *) NULL);
219
220 // Ask for filename to save
221 WXDLLEXPORT wxString
222 wxSaveFileSelector(const wxChar *what,
223 const wxChar *extension,
224 const wxChar *default_name = (const wxChar *) NULL,
225 wxWindow *parent = (wxWindow *) NULL);
226
227
228
229 #endif
230 // _WX_DIRDLGG_H_
231