]> git.saurik.com Git - wxWidgets.git/blob - include/wx/filedlg.h
*** empty log message ***
[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 WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr;
42 WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorDefaultWildcardStr;
43
44 //----------------------------------------------------------------------------
45 // wxFileDialogBase
46 //----------------------------------------------------------------------------
47
48 class WXDLLEXPORT wxFileDialogBase: public wxDialog
49 {
50 public:
51 wxFileDialogBase () {}
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 #if WXWIN_COMPATIBILITY_2_4
82 // Parses the wildCard, returning the number of filters.
83 // Returns 0 if none or if there's a problem,
84 // The arrays will contain an equal number of items found before the error.
85 // wildCard is in the form:
86 // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
87 static int ParseWildcard(const wxString& wildCard,
88 wxArrayString& descriptions,
89 wxArrayString& filters);
90 #endif // WXWIN_COMPATIBILITY_2_4
91
92 // Append first extension to filePath from a ';' separated extensionList
93 // if filePath = "path/foo.bar" just return it as is
94 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
95 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
96 static wxString AppendExtension(const wxString &filePath,
97 const wxString &extensionList);
98
99 protected:
100 wxString m_message;
101 long m_dialogStyle;
102 wxWindow *m_parent;
103 wxString m_dir;
104 wxString m_path; // Full path
105 wxString m_fileName;
106 wxString m_wildCard;
107 int m_filterIndex;
108
109 private:
110 DECLARE_DYNAMIC_CLASS(wxFileDialogBase)
111 DECLARE_NO_COPY_CLASS(wxFileDialogBase)
112 };
113
114 //----------------------------------------------------------------------------
115 // wxFileDialog convenience functions
116 //----------------------------------------------------------------------------
117
118 // File selector - backward compatibility
119 WXDLLEXPORT wxString
120 wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
121 const wxChar *default_path = NULL,
122 const wxChar *default_filename = NULL,
123 const wxChar *default_extension = NULL,
124 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
125 int flags = 0,
126 wxWindow *parent = NULL,
127 int x = wxDefaultCoord, int y = wxDefaultCoord);
128
129 // An extended version of wxFileSelector
130 WXDLLEXPORT wxString
131 wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
132 const wxChar *default_path = NULL,
133 const wxChar *default_filename = NULL,
134 int *indexDefaultExtension = NULL,
135 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
136 int flags = 0,
137 wxWindow *parent = NULL,
138 int x = wxDefaultCoord, int y = wxDefaultCoord);
139
140 // Ask for filename to load
141 WXDLLEXPORT wxString
142 wxLoadFileSelector(const wxChar *what,
143 const wxChar *extension,
144 const wxChar *default_name = (const wxChar *)NULL,
145 wxWindow *parent = (wxWindow *) NULL);
146
147 // Ask for filename to save
148 WXDLLEXPORT wxString
149 wxSaveFileSelector(const wxChar *what,
150 const wxChar *extension,
151 const wxChar *default_name = (const wxChar *) NULL,
152 wxWindow *parent = (wxWindow *) NULL);
153
154
155 #if defined (__WXUNIVERSAL__)
156 #include "wx/generic/filedlgg.h"
157 #elif defined(__WXMSW__)
158 #include "wx/msw/filedlg.h"
159 #elif defined(__WXMOTIF__)
160 #include "wx/motif/filedlg.h"
161 #elif defined(__WXGTK__)
162 #include "wx/generic/filedlgg.h"
163 #elif defined(__WXX11__)
164 #include "wx/generic/filedlgg.h"
165 #elif defined(__WXMGL__)
166 #include "wx/generic/filedlgg.h"
167 #elif defined(__WXMAC__)
168 #include "wx/mac/filedlg.h"
169 #elif defined(__WXCOCOA__)
170 #include "wx/cocoa/filedlg.h"
171 #elif defined(__WXPM__)
172 #include "wx/os2/filedlg.h"
173 #endif
174
175 #endif // wxUSE_FILEDLG
176
177 #endif // _WX_FILEDLG_H_BASE_