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