]>
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: | |
9 | // Licence: wxWindows licence | |
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 | ||
b600ed13 VZ |
41 | WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr; |
42 | WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorDefaultWildcardStr; | |
43 | ||
f74172ab VZ |
44 | //---------------------------------------------------------------------------- |
45 | // wxFileDialogBase | |
46 | //---------------------------------------------------------------------------- | |
47 | ||
48 | class WXDLLEXPORT wxFileDialogBase: public wxDialog | |
49 | { | |
50 | public: | |
6463b9f5 | 51 | wxFileDialogBase () {} |
f74172ab VZ |
52 | |
53 | wxFileDialogBase(wxWindow *parent, | |
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); | |
60 | ||
61 | virtual void SetMessage(const wxString& message) { m_message = message; } | |
62 | virtual void SetPath(const wxString& path) { m_path = path; } | |
63 | virtual void SetDirectory(const wxString& dir) { m_dir = dir; } | |
64 | virtual void SetFilename(const wxString& name) { m_fileName = name; } | |
65 | virtual void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; } | |
66 | virtual void SetStyle(long style) { m_dialogStyle = style; } | |
67 | virtual void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; } | |
68 | ||
69 | virtual wxString GetMessage() const { return m_message; } | |
70 | virtual wxString GetPath() const { return m_path; } | |
71 | virtual void GetPaths(wxArrayString& paths) const { paths.Empty(); paths.Add(m_path); } | |
72 | virtual wxString GetDirectory() const { return m_dir; } | |
73 | virtual wxString GetFilename() const { return m_fileName; } | |
74 | virtual void GetFilenames(wxArrayString& files) const { files.Empty(); files.Add(m_fileName); } | |
75 | virtual wxString GetWildcard() const { return m_wildCard; } | |
76 | virtual long GetStyle() const { return m_dialogStyle; } | |
77 | virtual int GetFilterIndex() const { return m_filterIndex; } | |
78 | ||
79 | // Utility functions | |
80 | ||
81 | // Parses the wildCard, returning the number of filters. | |
82 | // Returns 0 if none or if there's a problem, | |
83 | // The arrays will contain an equal number of items found before the error. | |
84 | // wildCard is in the form: | |
85 | // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png" | |
86 | static int ParseWildcard(const wxString& wildCard, | |
b600ed13 VZ |
87 | wxArrayString& descriptions, |
88 | wxArrayString& filters); | |
89 | ||
f74172ab VZ |
90 | // Append first extension to filePath from a ';' separated extensionList |
91 | // if filePath = "path/foo.bar" just return it as is | |
92 | // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg" | |
93 | // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath | |
94 | static wxString AppendExtension(const wxString &filePath, | |
95 | const wxString &extensionList); | |
96 | ||
97 | protected: | |
98 | wxString m_message; | |
99 | long m_dialogStyle; | |
100 | wxWindow *m_parent; | |
101 | wxString m_dir; | |
102 | wxString m_path; // Full path | |
103 | wxString m_fileName; | |
104 | wxString m_wildCard; | |
105 | int m_filterIndex; | |
106 | ||
107 | private: | |
108 | DECLARE_DYNAMIC_CLASS(wxFileDialogBase) | |
109 | DECLARE_NO_COPY_CLASS(wxFileDialogBase) | |
110 | }; | |
111 | ||
b600ed13 VZ |
112 | //---------------------------------------------------------------------------- |
113 | // wxFileDialog convenience functions | |
114 | //---------------------------------------------------------------------------- | |
115 | ||
116 | // File selector - backward compatibility | |
117 | WXDLLEXPORT wxString | |
118 | wxFileSelector(const wxChar *message = wxFileSelectorPromptStr, | |
119 | const wxChar *default_path = NULL, | |
120 | const wxChar *default_filename = NULL, | |
121 | const wxChar *default_extension = NULL, | |
122 | const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, | |
123 | int flags = 0, | |
124 | wxWindow *parent = NULL, | |
125 | int x = -1, int y = -1); | |
126 | ||
127 | // An extended version of wxFileSelector | |
128 | WXDLLEXPORT wxString | |
129 | wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr, | |
130 | const wxChar *default_path = NULL, | |
131 | const wxChar *default_filename = NULL, | |
132 | int *indexDefaultExtension = NULL, | |
133 | const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, | |
134 | int flags = 0, | |
135 | wxWindow *parent = NULL, | |
136 | int x = -1, int y = -1); | |
137 | ||
138 | // Ask for filename to load | |
139 | WXDLLEXPORT wxString | |
140 | wxLoadFileSelector(const wxChar *what, | |
141 | const wxChar *extension, | |
142 | const wxChar *default_name = (const wxChar *)NULL, | |
143 | wxWindow *parent = (wxWindow *) NULL); | |
144 | ||
145 | // Ask for filename to save | |
146 | WXDLLEXPORT wxString | |
147 | wxSaveFileSelector(const wxChar *what, | |
148 | const wxChar *extension, | |
149 | const wxChar *default_name = (const wxChar *) NULL, | |
150 | wxWindow *parent = (wxWindow *) NULL); | |
151 | ||
152 | ||
099d4217 CE |
153 | #if defined (__WXUNIVERSAL__) |
154 | #include "wx/generic/filedlgg.h" | |
155 | #elif defined(__WXMSW__) | |
c801d85f | 156 | #include "wx/msw/filedlg.h" |
2049ba38 | 157 | #elif defined(__WXMOTIF__) |
34138703 | 158 | #include "wx/motif/filedlg.h" |
2049ba38 | 159 | #elif defined(__WXGTK__) |
8b17ba72 | 160 | #include "wx/generic/filedlgg.h" |
83df96d6 | 161 | #elif defined(__WXX11__) |
7266b672 | 162 | #include "wx/generic/filedlgg.h" |
4a70a30b VS |
163 | #elif defined(__WXMGL__) |
164 | #include "wx/generic/filedlgg.h" | |
34138703 JS |
165 | #elif defined(__WXMAC__) |
166 | #include "wx/mac/filedlg.h" | |
0201182b DE |
167 | #elif defined(__WXCOCOA__) |
168 | #include "wx/generic/filedlgg.h" | |
1777b9bb DW |
169 | #elif defined(__WXPM__) |
170 | #include "wx/os2/filedlg.h" | |
c801d85f KB |
171 | #endif |
172 | ||
1e6feb95 | 173 | #endif // wxUSE_FILEDLG |
ba681060 | 174 | |
b600ed13 | 175 | #endif // _WX_FILEDLG_H_BASE_ |