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