Whole lot of stuff for new wxFileDialog
[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
136 void SetMessage(const wxString& message) { m_message = message; }
137 void SetPath(const wxString& path);
138 void SetDirectory(const wxString& dir) { m_dir = dir; }
139 void SetFilename(const wxString& name) { m_fileName = name; }
140 void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; }
141 void SetStyle(long style) { m_dialogStyle = style; }
142 void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; }
143
144 wxString GetMessage() const { return m_message; }
145 wxString GetPath() const { return m_path; }
146 wxString GetDirectory() const { return m_dir; }
147 wxString GetFilename() const { return m_fileName; }
148 wxString GetWildcard() const { return m_wildCard; }
149 long GetStyle() const { return m_dialogStyle; }
150 int GetFilterIndex() const { return m_filterIndex ; }
151
152 void OnSelected( wxListEvent &event );
153 void OnActivated( wxListEvent &event );
154 void OnList( wxCommandEvent &event );
155 void OnReport( wxCommandEvent &event );
156 void OnUp( wxCommandEvent &event );
157 void OnHome( wxCommandEvent &event );
158 void OnListOk( wxCommandEvent &event );
159 void OnNew( wxCommandEvent &event );
160
161 protected:
162 wxString m_message;
163 long m_dialogStyle;
164 wxString m_dir;
165 wxString m_path; // Full path
166 wxString m_fileName;
167 wxString m_wildCard;
168 int m_filterIndex;
169 wxChoice *m_choice;
170 wxTextCtrl *m_text;
171 wxFileCtrl *m_list;
172
173 private:
174 DECLARE_DYNAMIC_CLASS(wxFileDialog)
175 DECLARE_EVENT_TABLE()
176 };
177
178 #define wxOPEN 1
179 #define wxSAVE 2
180 #define wxOVERWRITE_PROMPT 4
181 #define wxHIDE_READONLY 8
182 #define wxFILE_MUST_EXIST 16
183
184 // File selector - backward compatibility
185 WXDLLEXPORT wxString
186 wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
187 const wxChar *default_path = NULL,
188 const wxChar *default_filename = NULL,
189 const wxChar *default_extension = NULL,
190 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
191 int flags = 0,
192 wxWindow *parent = NULL,
193 int x = -1, int y = -1);
194
195 // An extended version of wxFileSelector
196 WXDLLEXPORT wxString
197 wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
198 const wxChar *default_path = NULL,
199 const wxChar *default_filename = NULL,
200 int *indexDefaultExtension = NULL,
201 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
202 int flags = 0,
203 wxWindow *parent = NULL,
204 int x = -1, int y = -1);
205
206 // Ask for filename to load
207 WXDLLEXPORT wxString
208 wxLoadFileSelector(const wxChar *what,
209 const wxChar *extension,
210 const wxChar *default_name = (const wxChar *)NULL,
211 wxWindow *parent = (wxWindow *) NULL);
212
213 // Ask for filename to save
214 WXDLLEXPORT wxString
215 wxSaveFileSelector(const wxChar *what,
216 const wxChar *extension,
217 const wxChar *default_name = (const wxChar *) NULL,
218 wxWindow *parent = (wxWindow *) NULL);
219
220
221
222 #endif
223 // _WX_DIRDLGG_H_
224