]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/filedlgg.h
04f081b6bfe4bb4f4b5fbef217f1c52254b5f51a
[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/button.h"
25 #include "wx/validate.h"
26 #include "wx/textctrl.h"
27 #include "wx/choice.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 bool NewNameIsLegal( const wxString &s );
76 bool Rename( const wxString &s );
77 void MakeItem( wxListItem &item );
78
79 private:
80 DECLARE_DYNAMIC_CLASS(wxFileData);
81 };
82
83 //-----------------------------------------------------------------------------
84 // wxFileCtrl
85 //-----------------------------------------------------------------------------
86
87 class wxFileCtrl : public wxListCtrl
88 {
89 private:
90 wxString m_dirName;
91 bool m_showHidden;
92
93 public:
94 wxFileCtrl();
95 wxFileCtrl( wxWindow *win, const wxWindowID id, const wxString &dirName,
96 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
97 const long style = wxLC_LIST, const wxValidator &validator = wxDefaultValidator,
98 const wxString &name = _T("filelist") );
99 void ChangeToListMode();
100 void ChangeToReportMode();
101 void ChangeToIconMode();
102 void ShowHidden( bool show = TRUE );
103 void Update();
104 virtual void StatusbarText( char *WXUNUSED(text) ) {};
105 int FillList( wxStringList &list );
106 void DeleteFiles();
107 void CopyFiles( char *dest );
108 void MoveFiles( char *dest );
109 void RenameFile();
110 void MakeDir();
111 void GoToParentDir();
112 void GoToHomeDir();
113 void GoToDir( const wxString &dir );
114 void GetDir( wxString &dir );
115 void OnListDeleteItem( wxListEvent &event );
116 void OnListKeyDown( wxListEvent &event );
117 void OnListEndLabelEdit( wxListEvent &event );
118
119 private:
120 DECLARE_DYNAMIC_CLASS(wxFileCtrl);
121 DECLARE_EVENT_TABLE()
122 };
123
124 //-------------------------------------------------------------------------
125 // File selector
126 //-------------------------------------------------------------------------
127
128 class wxFileDialog: public wxDialog
129 {
130 public:
131 wxFileDialog() { }
132
133 wxFileDialog(wxWindow *parent,
134 const wxString& message = wxFileSelectorPromptStr,
135 const wxString& defaultDir = "",
136 const wxString& defaultFile = "",
137 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
138 long style = 0,
139 const wxPoint& pos = wxDefaultPosition);
140
141 void SetMessage(const wxString& message) { m_message = message; }
142 void SetPath(const wxString& path);
143 void SetDirectory(const wxString& dir) { m_dir = dir; }
144 void SetFilename(const wxString& name) { m_fileName = name; }
145 void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; }
146 void SetStyle(long style) { m_dialogStyle = style; }
147 void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; }
148
149 wxString GetMessage() const { return m_message; }
150 wxString GetPath() const { return m_path; }
151 wxString GetDirectory() const { return m_dir; }
152 wxString GetFilename() const { return m_fileName; }
153 wxString GetWildcard() const { return m_wildCard; }
154 long GetStyle() const { return m_dialogStyle; }
155 int GetFilterIndex() const { return m_filterIndex ; }
156
157 void OnSelected( wxListEvent &event );
158 void OnActivated( wxListEvent &event );
159 void OnList( wxCommandEvent &event );
160 void OnReport( wxCommandEvent &event );
161 void OnIcon( wxCommandEvent &event );
162 void OnUp( wxCommandEvent &event );
163 void OnHome( wxCommandEvent &event );
164 void OnListOk( 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
178 private:
179 DECLARE_DYNAMIC_CLASS(wxFileDialog)
180 DECLARE_EVENT_TABLE()
181 };
182
183 #define wxOPEN 1
184 #define wxSAVE 2
185 #define wxOVERWRITE_PROMPT 4
186 #define wxHIDE_READONLY 8
187 #define wxFILE_MUST_EXIST 16
188
189 // File selector - backward compatibility
190 WXDLLEXPORT wxString
191 wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
192 const wxChar *default_path = NULL,
193 const wxChar *default_filename = NULL,
194 const wxChar *default_extension = NULL,
195 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
196 int flags = 0,
197 wxWindow *parent = NULL,
198 int x = -1, int y = -1);
199
200 // An extended version of wxFileSelector
201 WXDLLEXPORT wxString
202 wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
203 const wxChar *default_path = NULL,
204 const wxChar *default_filename = NULL,
205 int *indexDefaultExtension = NULL,
206 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
207 int flags = 0,
208 wxWindow *parent = NULL,
209 int x = -1, int y = -1);
210
211 // Ask for filename to load
212 WXDLLEXPORT wxString
213 wxLoadFileSelector(const wxChar *what,
214 const wxChar *extension,
215 const wxChar *default_name = (const wxChar *)NULL,
216 wxWindow *parent = (wxWindow *) NULL);
217
218 // Ask for filename to save
219 WXDLLEXPORT wxString
220 wxSaveFileSelector(const wxChar *what,
221 const wxChar *extension,
222 const wxChar *default_name = (const wxChar *) NULL,
223 wxWindow *parent = (wxWindow *) NULL);
224
225
226
227 #endif
228 // _WX_DIRDLGG_H_
229