]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/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: $Id$ | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_FILEDLG_H_BASE_ | |
13 | #define _WX_FILEDLG_H_BASE_ | |
14 | ||
15 | #include "wx/defs.h" | |
16 | ||
17 | #if wxUSE_FILEDLG | |
18 | ||
19 | #include "wx/dialog.h" | |
20 | #include "wx/arrstr.h" | |
21 | ||
22 | //---------------------------------------------------------------------------- | |
23 | // wxFileDialog data | |
24 | //---------------------------------------------------------------------------- | |
25 | ||
26 | /* | |
27 | The flags below must coexist with the following flags in m_windowStyle | |
28 | #define wxCAPTION 0x20000000 | |
29 | #define wxMAXIMIZE 0x00002000 | |
30 | #define wxCLOSE_BOX 0x00001000 | |
31 | #define wxSYSTEM_MENU 0x00000800 | |
32 | wxBORDER_NONE = 0x00200000 | |
33 | #define wxRESIZE_BORDER 0x00000040 | |
34 | */ | |
35 | ||
36 | enum | |
37 | { | |
38 | wxFD_OPEN = 0x0001, | |
39 | wxFD_SAVE = 0x0002, | |
40 | wxFD_OVERWRITE_PROMPT = 0x0004, | |
41 | wxFD_FILE_MUST_EXIST = 0x0010, | |
42 | wxFD_MULTIPLE = 0x0020, | |
43 | wxFD_CHANGE_DIR = 0x0080, | |
44 | wxFD_PREVIEW = 0x0100 | |
45 | }; | |
46 | ||
47 | #if WXWIN_COMPATIBILITY_2_6 | |
48 | enum | |
49 | { | |
50 | wxOPEN = wxFD_OPEN, | |
51 | wxSAVE = wxFD_SAVE, | |
52 | wxOVERWRITE_PROMPT = wxFD_OVERWRITE_PROMPT, | |
53 | wxFILE_MUST_EXIST = wxFD_FILE_MUST_EXIST, | |
54 | wxMULTIPLE = wxFD_MULTIPLE, | |
55 | wxCHANGE_DIR = wxFD_CHANGE_DIR | |
56 | }; | |
57 | #endif | |
58 | ||
59 | #define wxFD_DEFAULT_STYLE wxFD_OPEN | |
60 | ||
61 | extern WXDLLEXPORT_DATA(const wxChar) wxFileDialogNameStr[]; | |
62 | extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorPromptStr[]; | |
63 | extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorDefaultWildcardStr[]; | |
64 | ||
65 | //---------------------------------------------------------------------------- | |
66 | // wxFileDialogBase | |
67 | //---------------------------------------------------------------------------- | |
68 | ||
69 | class WXDLLEXPORT wxFileDialogBase: public wxDialog | |
70 | { | |
71 | public: | |
72 | wxFileDialogBase () { Init(); } | |
73 | ||
74 | wxFileDialogBase(wxWindow *parent, | |
75 | const wxString& message = wxFileSelectorPromptStr, | |
76 | const wxString& defaultDir = wxEmptyString, | |
77 | const wxString& defaultFile = wxEmptyString, | |
78 | const wxString& wildCard = wxFileSelectorDefaultWildcardStr, | |
79 | long style = wxFD_DEFAULT_STYLE, | |
80 | const wxPoint& pos = wxDefaultPosition, | |
81 | const wxSize& sz = wxDefaultSize, | |
82 | const wxString& name = wxFileDialogNameStr) | |
83 | { | |
84 | Init(); | |
85 | Create(parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name); | |
86 | } | |
87 | ||
88 | bool Create(wxWindow *parent, | |
89 | const wxString& message = wxFileSelectorPromptStr, | |
90 | const wxString& defaultDir = wxEmptyString, | |
91 | const wxString& defaultFile = wxEmptyString, | |
92 | const wxString& wildCard = wxFileSelectorDefaultWildcardStr, | |
93 | long style = wxFD_DEFAULT_STYLE, | |
94 | const wxPoint& pos = wxDefaultPosition, | |
95 | const wxSize& sz = wxDefaultSize, | |
96 | const wxString& name = wxFileDialogNameStr); | |
97 | ||
98 | bool HasFdFlag(int flag) const { return HasFlag(flag); } | |
99 | ||
100 | virtual void SetMessage(const wxString& message) { m_message = message; } | |
101 | virtual void SetPath(const wxString& path) { m_path = path; } | |
102 | virtual void SetDirectory(const wxString& dir) { m_dir = dir; } | |
103 | virtual void SetFilename(const wxString& name) { m_fileName = name; } | |
104 | virtual void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; } | |
105 | virtual void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; } | |
106 | ||
107 | virtual wxString GetMessage() const { return m_message; } | |
108 | virtual wxString GetPath() const { return m_path; } | |
109 | virtual void GetPaths(wxArrayString& paths) const { paths.Empty(); paths.Add(m_path); } | |
110 | virtual wxString GetDirectory() const { return m_dir; } | |
111 | virtual wxString GetFilename() const { return m_fileName; } | |
112 | virtual void GetFilenames(wxArrayString& files) const { files.Empty(); files.Add(m_fileName); } | |
113 | virtual wxString GetWildcard() const { return m_wildCard; } | |
114 | virtual int GetFilterIndex() const { return m_filterIndex; } | |
115 | ||
116 | // Utility functions | |
117 | ||
118 | #if WXWIN_COMPATIBILITY_2_6 | |
119 | ||
120 | wxDEPRECATED( long GetStyle() const ); | |
121 | wxDEPRECATED( void SetStyle(long style) ); | |
122 | ||
123 | #endif // WXWIN_COMPATIBILITY_2_6 | |
124 | ||
125 | ||
126 | // Append first extension to filePath from a ';' separated extensionList | |
127 | // if filePath = "path/foo.bar" just return it as is | |
128 | // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg" | |
129 | // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath | |
130 | static wxString AppendExtension(const wxString &filePath, | |
131 | const wxString &extensionList); | |
132 | ||
133 | protected: | |
134 | wxString m_message; | |
135 | wxString m_dir; | |
136 | wxString m_path; // Full path | |
137 | wxString m_fileName; | |
138 | wxString m_wildCard; | |
139 | int m_filterIndex; | |
140 | ||
141 | private: | |
142 | void Init(); | |
143 | DECLARE_DYNAMIC_CLASS(wxFileDialogBase) | |
144 | DECLARE_NO_COPY_CLASS(wxFileDialogBase) | |
145 | }; | |
146 | ||
147 | //---------------------------------------------------------------------------- | |
148 | // wxFileDialog convenience functions | |
149 | //---------------------------------------------------------------------------- | |
150 | ||
151 | // File selector - backward compatibility | |
152 | WXDLLEXPORT wxString | |
153 | wxFileSelector(const wxString& message = wxFileSelectorPromptStr, | |
154 | const wxString& default_path = wxEmptyString, | |
155 | const wxString& default_filename = wxEmptyString, | |
156 | const wxString& default_extension = wxEmptyString, | |
157 | const wxString& wildcard = wxFileSelectorDefaultWildcardStr, | |
158 | int flags = 0, | |
159 | wxWindow *parent = NULL, | |
160 | int x = wxDefaultCoord, int y = wxDefaultCoord); | |
161 | ||
162 | // An extended version of wxFileSelector | |
163 | WXDLLEXPORT wxString | |
164 | wxFileSelectorEx(const wxString& message = wxFileSelectorPromptStr, | |
165 | const wxString& default_path = wxEmptyString, | |
166 | const wxString& default_filename = wxEmptyString, | |
167 | int *indexDefaultExtension = NULL, | |
168 | const wxString& wildcard = wxFileSelectorDefaultWildcardStr, | |
169 | int flags = 0, | |
170 | wxWindow *parent = NULL, | |
171 | int x = wxDefaultCoord, int y = wxDefaultCoord); | |
172 | ||
173 | // Ask for filename to load | |
174 | WXDLLEXPORT wxString | |
175 | wxLoadFileSelector(const wxString& what, | |
176 | const wxString& extension, | |
177 | const wxString& default_name = wxEmptyString, | |
178 | wxWindow *parent = NULL); | |
179 | ||
180 | // Ask for filename to save | |
181 | WXDLLEXPORT wxString | |
182 | wxSaveFileSelector(const wxString& what, | |
183 | const wxString& extension, | |
184 | const wxString& default_name = wxEmptyString, | |
185 | wxWindow *parent = NULL); | |
186 | ||
187 | ||
188 | #if defined (__WXUNIVERSAL__) | |
189 | #define wxHAS_GENERIC_FILEDIALOG | |
190 | #include "wx/generic/filedlgg.h" | |
191 | #elif defined(__WXMSW__) | |
192 | #include "wx/msw/filedlg.h" | |
193 | #elif defined(__WXMOTIF__) | |
194 | #include "wx/motif/filedlg.h" | |
195 | #elif defined(__WXGTK24__) | |
196 | #include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version | |
197 | #elif defined(__WXGTK20__) | |
198 | #define wxHAS_GENERIC_FILEDIALOG | |
199 | #include "wx/generic/filedlgg.h" | |
200 | #elif defined(__WXGTK__) | |
201 | #include "wx/gtk1/filedlg.h" | |
202 | #elif defined(__WXMAC__) | |
203 | #include "wx/mac/filedlg.h" | |
204 | #elif defined(__WXCOCOA__) | |
205 | #include "wx/cocoa/filedlg.h" | |
206 | #elif defined(__WXPM__) | |
207 | #include "wx/os2/filedlg.h" | |
208 | #endif | |
209 | ||
210 | #endif // wxUSE_FILEDLG | |
211 | ||
212 | #endif // _WX_FILEDLG_H_BASE_ |