init member variables properly (patch 1156088)
[wxWidgets.git] / include / wx / filedlg.h
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
12 #ifndef _WX_FILEDLG_H_BASE_
13 #define _WX_FILEDLG_H_BASE_
14
15 #if wxUSE_FILEDLG
16
17 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
18 #pragma interface "filedlg.h"
19 #endif
20
21 #include "wx/dialog.h"
22 #include "wx/arrstr.h"
23
24 //----------------------------------------------------------------------------
25 // wxFileDialog data
26 //----------------------------------------------------------------------------
27
28 enum
29 {
30 wxOPEN = 0x0001,
31 wxSAVE = 0x0002,
32 wxOVERWRITE_PROMPT = 0x0004,
33 #if WXWIN_COMPATIBILITY_2_4
34 wxHIDE_READONLY = 0x0008,
35 #endif
36 wxFILE_MUST_EXIST = 0x0010,
37 wxMULTIPLE = 0x0020,
38 wxCHANGE_DIR = 0x0040
39 };
40
41 extern WXDLLEXPORT_DATA(const wxChar*) wxFileSelectorPromptStr;
42 extern WXDLLEXPORT_DATA(const wxChar*) wxFileSelectorDefaultWildcardStr;
43
44 //----------------------------------------------------------------------------
45 // wxFileDialogBase
46 //----------------------------------------------------------------------------
47
48 class WXDLLEXPORT wxFileDialogBase: public wxDialog
49 {
50 public:
51 wxFileDialogBase () { Init(); }
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) : 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);
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
93 #if WXWIN_COMPATIBILITY_2_4
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"
99 wxDEPRECATED( static int ParseWildcard(const wxString& wildCard,
100 wxArrayString& descriptions,
101 wxArrayString& filters) );
102 #endif // WXWIN_COMPATIBILITY_2_4
103
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:
122 void Init();
123 DECLARE_DYNAMIC_CLASS(wxFileDialogBase)
124 DECLARE_NO_COPY_CLASS(wxFileDialogBase)
125 };
126
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,
140 int x = wxDefaultCoord, int y = wxDefaultCoord);
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,
151 int x = wxDefaultCoord, int y = wxDefaultCoord);
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
168 #if defined (__WXUNIVERSAL__)
169 #include "wx/generic/filedlgg.h"
170 #elif defined(__WXMSW__)
171 #include "wx/msw/filedlg.h"
172 #elif defined(__WXMOTIF__)
173 #include "wx/motif/filedlg.h"
174 #elif defined(__WXGTK__)
175 #include "wx/gtk/filedlg.h"
176 #elif defined(__WXX11__)
177 #include "wx/generic/filedlgg.h"
178 #elif defined(__WXMGL__)
179 #include "wx/generic/filedlgg.h"
180 #elif defined(__WXMAC__)
181 #include "wx/mac/filedlg.h"
182 #elif defined(__WXCOCOA__)
183 #include "wx/cocoa/filedlg.h"
184 #elif defined(__WXPM__)
185 #include "wx/os2/filedlg.h"
186 #endif
187
188 #endif // wxUSE_FILEDLG
189
190 #endif // _WX_FILEDLG_H_BASE_