]> git.saurik.com Git - wxWidgets.git/blob - include/wx/filedlg.h
Corrections
[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: $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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
20 #pragma interface "filedlg.h"
21 #endif
22
23 #include "wx/dialog.h"
24 #include "wx/arrstr.h"
25
26 //----------------------------------------------------------------------------
27 // wxFileDialog data
28 //----------------------------------------------------------------------------
29
30 enum
31 {
32 wxOPEN = 0x0001,
33 wxSAVE = 0x0002,
34 wxOVERWRITE_PROMPT = 0x0004,
35 #if WXWIN_COMPATIBILITY_2_4
36 wxHIDE_READONLY = 0x0008,
37 #endif
38 wxFILE_MUST_EXIST = 0x0010,
39 wxMULTIPLE = 0x0020,
40 wxCHANGE_DIR = 0x0040
41 };
42
43 extern WXDLLEXPORT_DATA(const wxChar*) wxFileSelectorPromptStr;
44 extern WXDLLEXPORT_DATA(const wxChar*) wxFileSelectorDefaultWildcardStr;
45
46 //----------------------------------------------------------------------------
47 // wxFileDialogBase
48 //----------------------------------------------------------------------------
49
50 class WXDLLEXPORT wxFileDialogBase: public wxDialog
51 {
52 public:
53 wxFileDialogBase () { Init(); }
54
55 wxFileDialogBase(wxWindow *parent,
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);
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
95 #if WXWIN_COMPATIBILITY_2_4
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"
101 wxDEPRECATED( static int ParseWildcard(const wxString& wildCard,
102 wxArrayString& descriptions,
103 wxArrayString& filters) );
104 #endif // WXWIN_COMPATIBILITY_2_4
105
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:
124 void Init();
125 DECLARE_DYNAMIC_CLASS(wxFileDialogBase)
126 DECLARE_NO_COPY_CLASS(wxFileDialogBase)
127 };
128
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,
142 int x = wxDefaultCoord, int y = wxDefaultCoord);
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,
153 int x = wxDefaultCoord, int y = wxDefaultCoord);
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
170 #if defined (__WXUNIVERSAL__)
171 #include "wx/generic/filedlgg.h"
172 #elif defined(__WXMSW__)
173 #include "wx/msw/filedlg.h"
174 #elif defined(__WXMOTIF__)
175 #include "wx/motif/filedlg.h"
176 #elif defined(__WXGTK__)
177 #include "wx/gtk/filedlg.h"
178 #elif defined(__WXX11__)
179 #include "wx/generic/filedlgg.h"
180 #elif defined(__WXMGL__)
181 #include "wx/generic/filedlgg.h"
182 #elif defined(__WXMAC__)
183 #include "wx/mac/filedlg.h"
184 #elif defined(__WXCOCOA__)
185 #include "wx/cocoa/filedlg.h"
186 #elif defined(__WXPM__)
187 #include "wx/os2/filedlg.h"
188 #endif
189
190 #endif // wxUSE_FILEDLG
191
192 #endif // _WX_FILEDLG_H_BASE_