1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFileDialog base header
4 // Author: Robert Roebling
7 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_FILEDLG_H_BASE_
13 #define _WX_FILEDLG_H_BASE_
17 #if defined(__GNUG__) && !defined(__APPLE__)
18 #pragma interface "filedlg.h"
21 #include "wx/dialog.h"
23 //----------------------------------------------------------------------------
25 //----------------------------------------------------------------------------
31 wxOVERWRITE_PROMPT
= 0x0004,
32 wxHIDE_READONLY
= 0x0008,
33 wxFILE_MUST_EXIST
= 0x0010,
38 WXDLLEXPORT_DATA(extern const wxChar
*) wxFileSelectorPromptStr
;
39 WXDLLEXPORT_DATA(extern const wxChar
*) wxFileSelectorDefaultWildcardStr
;
41 //----------------------------------------------------------------------------
43 //----------------------------------------------------------------------------
45 class WXDLLEXPORT wxFileDialogBase
: public wxDialog
48 wxFileDialogBase () {}
50 wxFileDialogBase(wxWindow
*parent
,
51 const wxString
& message
= wxFileSelectorPromptStr
,
52 const wxString
& defaultDir
= wxEmptyString
,
53 const wxString
& defaultFile
= wxEmptyString
,
54 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
56 const wxPoint
& pos
= wxDefaultPosition
);
58 virtual void SetMessage(const wxString
& message
) { m_message
= message
; }
59 virtual void SetPath(const wxString
& path
) { m_path
= path
; }
60 virtual void SetDirectory(const wxString
& dir
) { m_dir
= dir
; }
61 virtual void SetFilename(const wxString
& name
) { m_fileName
= name
; }
62 virtual void SetWildcard(const wxString
& wildCard
) { m_wildCard
= wildCard
; }
63 virtual void SetStyle(long style
) { m_dialogStyle
= style
; }
64 virtual void SetFilterIndex(int filterIndex
) { m_filterIndex
= filterIndex
; }
66 virtual wxString
GetMessage() const { return m_message
; }
67 virtual wxString
GetPath() const { return m_path
; }
68 virtual void GetPaths(wxArrayString
& paths
) const { paths
.Empty(); paths
.Add(m_path
); }
69 virtual wxString
GetDirectory() const { return m_dir
; }
70 virtual wxString
GetFilename() const { return m_fileName
; }
71 virtual void GetFilenames(wxArrayString
& files
) const { files
.Empty(); files
.Add(m_fileName
); }
72 virtual wxString
GetWildcard() const { return m_wildCard
; }
73 virtual long GetStyle() const { return m_dialogStyle
; }
74 virtual int GetFilterIndex() const { return m_filterIndex
; }
78 // Parses the wildCard, returning the number of filters.
79 // Returns 0 if none or if there's a problem,
80 // The arrays will contain an equal number of items found before the error.
81 // wildCard is in the form:
82 // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
83 static int ParseWildcard(const wxString
& wildCard
,
84 wxArrayString
& descriptions
,
85 wxArrayString
& filters
);
87 // Append first extension to filePath from a ';' separated extensionList
88 // if filePath = "path/foo.bar" just return it as is
89 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
90 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
91 static wxString
AppendExtension(const wxString
&filePath
,
92 const wxString
&extensionList
);
99 wxString m_path
; // Full path
105 DECLARE_DYNAMIC_CLASS(wxFileDialogBase
)
106 DECLARE_NO_COPY_CLASS(wxFileDialogBase
)
109 //----------------------------------------------------------------------------
110 // wxFileDialog convenience functions
111 //----------------------------------------------------------------------------
113 // File selector - backward compatibility
115 wxFileSelector(const wxChar
*message
= wxFileSelectorPromptStr
,
116 const wxChar
*default_path
= NULL
,
117 const wxChar
*default_filename
= NULL
,
118 const wxChar
*default_extension
= NULL
,
119 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
121 wxWindow
*parent
= NULL
,
122 int x
= -1, int y
= -1);
124 // An extended version of wxFileSelector
126 wxFileSelectorEx(const wxChar
*message
= wxFileSelectorPromptStr
,
127 const wxChar
*default_path
= NULL
,
128 const wxChar
*default_filename
= NULL
,
129 int *indexDefaultExtension
= NULL
,
130 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
132 wxWindow
*parent
= NULL
,
133 int x
= -1, int y
= -1);
135 // Ask for filename to load
137 wxLoadFileSelector(const wxChar
*what
,
138 const wxChar
*extension
,
139 const wxChar
*default_name
= (const wxChar
*)NULL
,
140 wxWindow
*parent
= (wxWindow
*) NULL
);
142 // Ask for filename to save
144 wxSaveFileSelector(const wxChar
*what
,
145 const wxChar
*extension
,
146 const wxChar
*default_name
= (const wxChar
*) NULL
,
147 wxWindow
*parent
= (wxWindow
*) NULL
);
150 #if defined (__WXUNIVERSAL__)
151 #include "wx/generic/filedlgg.h"
152 #elif defined(__WXMSW__)
153 #include "wx/msw/filedlg.h"
154 #elif defined(__WXMOTIF__)
155 #include "wx/motif/filedlg.h"
156 #elif defined(__WXGTK__)
157 #include "wx/generic/filedlgg.h"
158 #elif defined(__WXX11__)
159 #include "wx/generic/filedlgg.h"
160 #elif defined(__WXMGL__)
161 #include "wx/generic/filedlgg.h"
162 #elif defined(__WXMAC__)
163 #include "wx/mac/filedlg.h"
164 #elif defined(__WXCOCOA__)
165 #include "wx/generic/filedlgg.h"
166 #elif defined(__WXPM__)
167 #include "wx/os2/filedlg.h"
170 #endif // wxUSE_FILEDLG
172 #endif // _WX_FILEDLG_H_BASE_