]>
Commit | Line | Data |
---|---|---|
b600ed13 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: filedlg.h | |
3 | // Purpose: wxFileDialog base header | |
4 | // Author: Robert Roebling | |
5 | // Modified by: | |
6 | // Created: 8/17/99 | |
7 | // Copyright: (c) Robert Roebling | |
2ecf902b | 8 | // RCS-ID: $Id$ |
65571936 | 9 | // Licence: wxWindows licence |
b600ed13 VZ |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_FILEDLG_H_BASE_ |
13 | #define _WX_FILEDLG_H_BASE_ | |
c801d85f | 14 | |
2ecf902b WS |
15 | #include "wx/defs.h" |
16 | ||
1e6feb95 VZ |
17 | #if wxUSE_FILEDLG |
18 | ||
f74172ab | 19 | #include "wx/dialog.h" |
a9711a4d | 20 | #include "wx/arrstr.h" |
f74172ab | 21 | |
b600ed13 | 22 | //---------------------------------------------------------------------------- |
f74172ab | 23 | // wxFileDialog data |
b600ed13 VZ |
24 | //---------------------------------------------------------------------------- |
25 | ||
ff3e84ff | 26 | #if WXWIN_COMPATIBILITY_2_6 |
c61f4f6d VZ |
27 | enum |
28 | { | |
3f6638b8 VZ |
29 | wxOPEN = 0x0001, |
30 | wxSAVE = 0x0002, | |
31 | wxOVERWRITE_PROMPT = 0x0004, | |
21416306 | 32 | #if WXWIN_COMPATIBILITY_2_4 |
3f6638b8 | 33 | wxHIDE_READONLY = 0x0008, |
21416306 | 34 | #endif |
3f6638b8 VZ |
35 | wxFILE_MUST_EXIST = 0x0010, |
36 | wxMULTIPLE = 0x0020, | |
37 | wxCHANGE_DIR = 0x0040 | |
c61f4f6d | 38 | }; |
ff3e84ff | 39 | #endif |
c61f4f6d | 40 | |
ff3e84ff VZ |
41 | enum |
42 | { | |
43 | wxFD_OPEN = 0x0001, | |
44 | wxFD_SAVE = 0x0002, | |
45 | wxFD_OVERWRITE_PROMPT = 0x0004, | |
46 | wxFD_FILE_MUST_EXIST = 0x0010, | |
47 | wxFD_MULTIPLE = 0x0020, | |
48 | wxFD_CHANGE_DIR = 0x0040 | |
49 | }; | |
50 | ||
51 | #define wxFD_DEFAULT_STYLE wxFD_OPEN | |
52 | ||
53 | extern WXDLLEXPORT_DATA(const wxChar) wxFileDialogNameStr[]; | |
63ec432b MR |
54 | extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorPromptStr[]; |
55 | extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorDefaultWildcardStr[]; | |
b600ed13 | 56 | |
f74172ab VZ |
57 | //---------------------------------------------------------------------------- |
58 | // wxFileDialogBase | |
59 | //---------------------------------------------------------------------------- | |
60 | ||
61 | class WXDLLEXPORT wxFileDialogBase: public wxDialog | |
62 | { | |
63 | public: | |
fe6cf128 | 64 | wxFileDialogBase () { Init(); } |
f74172ab VZ |
65 | |
66 | wxFileDialogBase(wxWindow *parent, | |
fe6cf128 VZ |
67 | const wxString& message = wxFileSelectorPromptStr, |
68 | const wxString& defaultDir = wxEmptyString, | |
69 | const wxString& defaultFile = wxEmptyString, | |
70 | const wxString& wildCard = wxFileSelectorDefaultWildcardStr, | |
ff3e84ff VZ |
71 | long style = wxFD_DEFAULT_STYLE, |
72 | const wxPoint& pos = wxDefaultPosition, | |
73 | const wxSize& sz = wxDefaultSize, | |
74 | const wxString& name = wxFileDialogNameStr) | |
fe6cf128 VZ |
75 | { |
76 | Init(); | |
ff3e84ff | 77 | Create(parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name); |
fe6cf128 VZ |
78 | } |
79 | ||
80 | bool Create(wxWindow *parent, | |
81 | const wxString& message = wxFileSelectorPromptStr, | |
82 | const wxString& defaultDir = wxEmptyString, | |
83 | const wxString& defaultFile = wxEmptyString, | |
84 | const wxString& wildCard = wxFileSelectorDefaultWildcardStr, | |
ff3e84ff VZ |
85 | long style = wxFD_DEFAULT_STYLE, |
86 | const wxPoint& pos = wxDefaultPosition, | |
87 | const wxSize& sz = wxDefaultSize, | |
88 | const wxString& name = wxFileDialogNameStr); | |
f74172ab VZ |
89 | |
90 | virtual void SetMessage(const wxString& message) { m_message = message; } | |
91 | virtual void SetPath(const wxString& path) { m_path = path; } | |
92 | virtual void SetDirectory(const wxString& dir) { m_dir = dir; } | |
93 | virtual void SetFilename(const wxString& name) { m_fileName = name; } | |
94 | virtual void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; } | |
f74172ab VZ |
95 | virtual void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; } |
96 | ||
97 | virtual wxString GetMessage() const { return m_message; } | |
98 | virtual wxString GetPath() const { return m_path; } | |
99 | virtual void GetPaths(wxArrayString& paths) const { paths.Empty(); paths.Add(m_path); } | |
100 | virtual wxString GetDirectory() const { return m_dir; } | |
101 | virtual wxString GetFilename() const { return m_fileName; } | |
102 | virtual void GetFilenames(wxArrayString& files) const { files.Empty(); files.Add(m_fileName); } | |
103 | virtual wxString GetWildcard() const { return m_wildCard; } | |
f74172ab VZ |
104 | virtual int GetFilterIndex() const { return m_filterIndex; } |
105 | ||
106 | // Utility functions | |
107 | ||
9e152a55 | 108 | #if WXWIN_COMPATIBILITY_2_4 |
f74172ab VZ |
109 | // Parses the wildCard, returning the number of filters. |
110 | // Returns 0 if none or if there's a problem, | |
111 | // The arrays will contain an equal number of items found before the error. | |
112 | // wildCard is in the form: | |
113 | // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png" | |
eecb33b0 WS |
114 | wxDEPRECATED( static int ParseWildcard(const wxString& wildCard, |
115 | wxArrayString& descriptions, | |
116 | wxArrayString& filters) ); | |
9e152a55 | 117 | #endif // WXWIN_COMPATIBILITY_2_4 |
b600ed13 | 118 | |
f74172ab VZ |
119 | // Append first extension to filePath from a ';' separated extensionList |
120 | // if filePath = "path/foo.bar" just return it as is | |
121 | // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg" | |
122 | // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath | |
123 | static wxString AppendExtension(const wxString &filePath, | |
124 | const wxString &extensionList); | |
125 | ||
126 | protected: | |
127 | wxString m_message; | |
f74172ab VZ |
128 | wxString m_dir; |
129 | wxString m_path; // Full path | |
130 | wxString m_fileName; | |
131 | wxString m_wildCard; | |
132 | int m_filterIndex; | |
133 | ||
134 | private: | |
fe6cf128 | 135 | void Init(); |
f74172ab VZ |
136 | DECLARE_DYNAMIC_CLASS(wxFileDialogBase) |
137 | DECLARE_NO_COPY_CLASS(wxFileDialogBase) | |
138 | }; | |
139 | ||
b600ed13 VZ |
140 | //---------------------------------------------------------------------------- |
141 | // wxFileDialog convenience functions | |
142 | //---------------------------------------------------------------------------- | |
143 | ||
144 | // File selector - backward compatibility | |
145 | WXDLLEXPORT wxString | |
146 | wxFileSelector(const wxChar *message = wxFileSelectorPromptStr, | |
147 | const wxChar *default_path = NULL, | |
148 | const wxChar *default_filename = NULL, | |
149 | const wxChar *default_extension = NULL, | |
150 | const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, | |
151 | int flags = 0, | |
152 | wxWindow *parent = NULL, | |
a62848fd | 153 | int x = wxDefaultCoord, int y = wxDefaultCoord); |
b600ed13 VZ |
154 | |
155 | // An extended version of wxFileSelector | |
156 | WXDLLEXPORT wxString | |
157 | wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr, | |
158 | const wxChar *default_path = NULL, | |
159 | const wxChar *default_filename = NULL, | |
160 | int *indexDefaultExtension = NULL, | |
161 | const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, | |
162 | int flags = 0, | |
163 | wxWindow *parent = NULL, | |
a62848fd | 164 | int x = wxDefaultCoord, int y = wxDefaultCoord); |
b600ed13 VZ |
165 | |
166 | // Ask for filename to load | |
167 | WXDLLEXPORT wxString | |
168 | wxLoadFileSelector(const wxChar *what, | |
169 | const wxChar *extension, | |
170 | const wxChar *default_name = (const wxChar *)NULL, | |
171 | wxWindow *parent = (wxWindow *) NULL); | |
172 | ||
173 | // Ask for filename to save | |
174 | WXDLLEXPORT wxString | |
175 | wxSaveFileSelector(const wxChar *what, | |
176 | const wxChar *extension, | |
177 | const wxChar *default_name = (const wxChar *) NULL, | |
178 | wxWindow *parent = (wxWindow *) NULL); | |
179 | ||
180 | ||
099d4217 CE |
181 | #if defined (__WXUNIVERSAL__) |
182 | #include "wx/generic/filedlgg.h" | |
183 | #elif defined(__WXMSW__) | |
c801d85f | 184 | #include "wx/msw/filedlg.h" |
2049ba38 | 185 | #elif defined(__WXMOTIF__) |
34138703 | 186 | #include "wx/motif/filedlg.h" |
ff3e84ff VZ |
187 | #elif defined(__WXGTK24__) |
188 | #include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version | |
1be7a35c | 189 | #elif defined(__WXGTK20__) |
ff3e84ff | 190 | #include "wx/generic/filedlgg.h" |
1be7a35c | 191 | #elif defined(__WXGTK__) |
7e52dfd2 | 192 | #include "wx/gtk1/filedlg.h" |
83df96d6 | 193 | #elif defined(__WXX11__) |
7266b672 | 194 | #include "wx/generic/filedlgg.h" |
4a70a30b VS |
195 | #elif defined(__WXMGL__) |
196 | #include "wx/generic/filedlgg.h" | |
34138703 JS |
197 | #elif defined(__WXMAC__) |
198 | #include "wx/mac/filedlg.h" | |
0201182b | 199 | #elif defined(__WXCOCOA__) |
f31424db | 200 | #include "wx/cocoa/filedlg.h" |
1777b9bb DW |
201 | #elif defined(__WXPM__) |
202 | #include "wx/os2/filedlg.h" | |
c801d85f KB |
203 | #endif |
204 | ||
1e6feb95 | 205 | #endif // wxUSE_FILEDLG |
ba681060 | 206 | |
b600ed13 | 207 | #endif // _WX_FILEDLG_H_BASE_ |