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