]> git.saurik.com Git - wxWidgets.git/blame - include/wx/filedlg.h
Set wxTextCtrl::m_verRichEdit to 4 for RichEdit 4.1.
[wxWidgets.git] / include / wx / filedlg.h
CommitLineData
b600ed13 1/////////////////////////////////////////////////////////////////////////////
e031f1df 2// Name: wx/filedlg.h
b600ed13
VZ
3// Purpose: wxFileDialog base header
4// Author: Robert Roebling
5// Modified by:
6// Created: 8/17/99
7// Copyright: (c) Robert Roebling
2ecf902b 8// RCS-ID: $Id$
65571936 9// Licence: wxWindows licence
b600ed13
VZ
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_FILEDLG_H_BASE_
13#define _WX_FILEDLG_H_BASE_
c801d85f 14
2ecf902b
WS
15#include "wx/defs.h"
16
1e6feb95
VZ
17#if wxUSE_FILEDLG
18
f74172ab 19#include "wx/dialog.h"
a9711a4d 20#include "wx/arrstr.h"
f74172ab 21
f92ec193
VZ
22// this symbol is defined for the platforms which support multiple
23// ('|'-separated) filters in the file dialog
26078494
VZ
24#if defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXMAC__)
25 #define wxHAS_MULTIPLE_FILEDLG_FILTERS
26#endif
27
b600ed13 28//----------------------------------------------------------------------------
f74172ab 29// wxFileDialog data
b600ed13
VZ
30//----------------------------------------------------------------------------
31
45f4109c
RR
32/*
33 The flags below must coexist with the following flags in m_windowStyle
34 #define wxCAPTION 0x20000000
35 #define wxMAXIMIZE 0x00002000
36 #define wxCLOSE_BOX 0x00001000
37 #define wxSYSTEM_MENU 0x00000800
38 wxBORDER_NONE = 0x00200000
39 #define wxRESIZE_BORDER 0x00000040
40*/
41
ff3e84ff
VZ
42enum
43{
44 wxFD_OPEN = 0x0001,
45 wxFD_SAVE = 0x0002,
46 wxFD_OVERWRITE_PROMPT = 0x0004,
47 wxFD_FILE_MUST_EXIST = 0x0010,
48 wxFD_MULTIPLE = 0x0020,
45f4109c
RR
49 wxFD_CHANGE_DIR = 0x0080,
50 wxFD_PREVIEW = 0x0100
ff3e84ff
VZ
51};
52
e031f1df
WS
53#if WXWIN_COMPATIBILITY_2_6
54enum
55{
56 wxOPEN = wxFD_OPEN,
57 wxSAVE = wxFD_SAVE,
58 wxOVERWRITE_PROMPT = wxFD_OVERWRITE_PROMPT,
e031f1df
WS
59 wxFILE_MUST_EXIST = wxFD_FILE_MUST_EXIST,
60 wxMULTIPLE = wxFD_MULTIPLE,
61 wxCHANGE_DIR = wxFD_CHANGE_DIR
62};
63#endif
64
ff3e84ff
VZ
65#define wxFD_DEFAULT_STYLE wxFD_OPEN
66
53a2db12
FM
67extern WXDLLIMPEXP_DATA_CORE(const char) wxFileDialogNameStr[];
68extern WXDLLIMPEXP_DATA_CORE(const char) wxFileSelectorPromptStr[];
69extern WXDLLIMPEXP_DATA_CORE(const char) wxFileSelectorDefaultWildcardStr[];
b600ed13 70
f74172ab
VZ
71//----------------------------------------------------------------------------
72// wxFileDialogBase
73//----------------------------------------------------------------------------
74
53a2db12 75class WXDLLIMPEXP_CORE wxFileDialogBase: public wxDialog
f74172ab
VZ
76{
77public:
fe6cf128 78 wxFileDialogBase () { Init(); }
f74172ab
VZ
79
80 wxFileDialogBase(wxWindow *parent,
fe6cf128
VZ
81 const wxString& message = wxFileSelectorPromptStr,
82 const wxString& defaultDir = wxEmptyString,
83 const wxString& defaultFile = wxEmptyString,
84 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
ff3e84ff
VZ
85 long style = wxFD_DEFAULT_STYLE,
86 const wxPoint& pos = wxDefaultPosition,
87 const wxSize& sz = wxDefaultSize,
88 const wxString& name = wxFileDialogNameStr)
fe6cf128
VZ
89 {
90 Init();
ff3e84ff 91 Create(parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name);
fe6cf128
VZ
92 }
93
8ce68f7f
VZ
94 virtual ~wxFileDialogBase() {}
95
96
fe6cf128
VZ
97 bool Create(wxWindow *parent,
98 const wxString& message = wxFileSelectorPromptStr,
99 const wxString& defaultDir = wxEmptyString,
100 const wxString& defaultFile = wxEmptyString,
101 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
ff3e84ff
VZ
102 long style = wxFD_DEFAULT_STYLE,
103 const wxPoint& pos = wxDefaultPosition,
104 const wxSize& sz = wxDefaultSize,
105 const wxString& name = wxFileDialogNameStr);
f74172ab 106
45f4109c 107 bool HasFdFlag(int flag) const { return HasFlag(flag); }
b014db05 108
f74172ab 109 virtual void SetMessage(const wxString& message) { m_message = message; }
7430a4bb
VZ
110 virtual void SetPath(const wxString& path);
111 virtual void SetDirectory(const wxString& dir);
112 virtual void SetFilename(const wxString& name);
f74172ab 113 virtual void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; }
f74172ab
VZ
114 virtual void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; }
115
116 virtual wxString GetMessage() const { return m_message; }
117 virtual wxString GetPath() const { return m_path; }
118 virtual void GetPaths(wxArrayString& paths) const { paths.Empty(); paths.Add(m_path); }
119 virtual wxString GetDirectory() const { return m_dir; }
120 virtual wxString GetFilename() const { return m_fileName; }
121 virtual void GetFilenames(wxArrayString& files) const { files.Empty(); files.Add(m_fileName); }
122 virtual wxString GetWildcard() const { return m_wildCard; }
f74172ab
VZ
123 virtual int GetFilterIndex() const { return m_filterIndex; }
124
8ce68f7f
VZ
125 // this function is called with wxFileDialog as parameter and should
126 // create the window containing the extra controls we want to show in it
127 typedef wxWindow *(*ExtraControlCreatorFunction)(wxWindow*);
128
8ce68f7f
VZ
129 virtual bool SupportsExtraControl() const { return false; }
130
d6dae1b4 131 bool SetExtraControlCreator(ExtraControlCreatorFunction creator);
8ce68f7f
VZ
132 wxWindow *GetExtraControl() const { return m_extraControl; }
133
f74172ab
VZ
134 // Utility functions
135
cc197ed4
VZ
136#if WXWIN_COMPATIBILITY_2_6
137
138 wxDEPRECATED( long GetStyle() const );
139 wxDEPRECATED( void SetStyle(long style) );
140
141#endif // WXWIN_COMPATIBILITY_2_6
142
143
f74172ab
VZ
144 // Append first extension to filePath from a ';' separated extensionList
145 // if filePath = "path/foo.bar" just return it as is
146 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
147 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
148 static wxString AppendExtension(const wxString &filePath,
149 const wxString &extensionList);
150
151protected:
152 wxString m_message;
f74172ab
VZ
153 wxString m_dir;
154 wxString m_path; // Full path
155 wxString m_fileName;
156 wxString m_wildCard;
157 int m_filterIndex;
8ce68f7f
VZ
158 wxWindow* m_extraControl;
159
160 // returns true if control is created (if it already exists returns false)
161 bool CreateExtraControl();
6fa6d659
VZ
162 // return true if SetExtraControlCreator() was called
163 bool HasExtraControlCreator() const
164 { return m_extraControlCreator != NULL; }
165 // get the size of the extra control by creating and deleting it
166 wxSize GetExtraControlSize();
f74172ab
VZ
167
168private:
8ce68f7f
VZ
169 ExtraControlCreatorFunction m_extraControlCreator;
170
fe6cf128 171 void Init();
f74172ab 172 DECLARE_DYNAMIC_CLASS(wxFileDialogBase)
c0c133e1 173 wxDECLARE_NO_COPY_CLASS(wxFileDialogBase);
f74172ab
VZ
174};
175
8ce68f7f 176
b600ed13
VZ
177//----------------------------------------------------------------------------
178// wxFileDialog convenience functions
179//----------------------------------------------------------------------------
180
f8bcb37d 181// File selector - backward compatibility
53a2db12 182WXDLLIMPEXP_CORE wxString
6dc2e823
VS
183wxFileSelector(const wxString& message = wxFileSelectorPromptStr,
184 const wxString& default_path = wxEmptyString,
185 const wxString& default_filename = wxEmptyString,
186 const wxString& default_extension = wxEmptyString,
f8bcb37d 187 const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
b600ed13
VZ
188 int flags = 0,
189 wxWindow *parent = NULL,
6dc2e823 190 int x = wxDefaultCoord, int y = wxDefaultCoord);
b600ed13
VZ
191
192// An extended version of wxFileSelector
53a2db12 193WXDLLIMPEXP_CORE wxString
6dc2e823
VS
194wxFileSelectorEx(const wxString& message = wxFileSelectorPromptStr,
195 const wxString& default_path = wxEmptyString,
196 const wxString& default_filename = wxEmptyString,
b600ed13 197 int *indexDefaultExtension = NULL,
f8bcb37d 198 const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
b600ed13
VZ
199 int flags = 0,
200 wxWindow *parent = NULL,
6dc2e823 201 int x = wxDefaultCoord, int y = wxDefaultCoord);
b600ed13
VZ
202
203// Ask for filename to load
53a2db12 204WXDLLIMPEXP_CORE wxString
6dc2e823
VS
205wxLoadFileSelector(const wxString& what,
206 const wxString& extension,
207 const wxString& default_name = wxEmptyString,
208 wxWindow *parent = NULL);
b600ed13
VZ
209
210// Ask for filename to save
53a2db12 211WXDLLIMPEXP_CORE wxString
6dc2e823
VS
212wxSaveFileSelector(const wxString& what,
213 const wxString& extension,
214 const wxString& default_name = wxEmptyString,
215 wxWindow *parent = NULL);
b600ed13
VZ
216
217
099d4217 218#if defined (__WXUNIVERSAL__)
0cf3e587
VZ
219 #define wxHAS_GENERIC_FILEDIALOG
220 #include "wx/generic/filedlgg.h"
099d4217 221#elif defined(__WXMSW__)
0cf3e587 222 #include "wx/msw/filedlg.h"
2049ba38 223#elif defined(__WXMOTIF__)
0cf3e587 224 #include "wx/motif/filedlg.h"
ff654490 225#elif defined(__WXGTK20__)
0cf3e587 226 #include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version
1be7a35c 227#elif defined(__WXGTK__)
0cf3e587 228 #include "wx/gtk1/filedlg.h"
34138703 229#elif defined(__WXMAC__)
ef0e9220 230 #include "wx/osx/filedlg.h"
0201182b 231#elif defined(__WXCOCOA__)
0cf3e587 232 #include "wx/cocoa/filedlg.h"
1777b9bb 233#elif defined(__WXPM__)
0cf3e587 234 #include "wx/os2/filedlg.h"
a85ad1db
VZ
235#elif defined(__WXPALMOS__)
236 #define wxHAS_GENERIC_FILEDIALOG
237 #include "wx/generic/filedlgg.h"
c801d85f
KB
238#endif
239
1e6feb95 240#endif // wxUSE_FILEDLG
ba681060 241
b600ed13 242#endif // _WX_FILEDLG_H_BASE_