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