]> git.saurik.com Git - wxWidgets.git/blame - include/wx/filedlg.h
Added wxPGChoices::Copy(), tweaked related documentation
[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
8ce68f7f
VZ
123 virtual bool SupportsExtraControl() const { return false; }
124
d6dae1b4 125 bool SetExtraControlCreator(ExtraControlCreatorFunction creator);
8ce68f7f
VZ
126 wxWindow *GetExtraControl() const { return m_extraControl; }
127
f74172ab
VZ
128 // Utility functions
129
cc197ed4
VZ
130#if WXWIN_COMPATIBILITY_2_6
131
132 wxDEPRECATED( long GetStyle() const );
133 wxDEPRECATED( void SetStyle(long style) );
134
135#endif // WXWIN_COMPATIBILITY_2_6
136
137
f74172ab
VZ
138 // Append first extension to filePath from a ';' separated extensionList
139 // if filePath = "path/foo.bar" just return it as is
140 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
141 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
142 static wxString AppendExtension(const wxString &filePath,
143 const wxString &extensionList);
144
145protected:
146 wxString m_message;
f74172ab
VZ
147 wxString m_dir;
148 wxString m_path; // Full path
149 wxString m_fileName;
150 wxString m_wildCard;
151 int m_filterIndex;
8ce68f7f
VZ
152 wxWindow* m_extraControl;
153
154 // returns true if control is created (if it already exists returns false)
155 bool CreateExtraControl();
6fa6d659
VZ
156 // return true if SetExtraControlCreator() was called
157 bool HasExtraControlCreator() const
158 { return m_extraControlCreator != NULL; }
159 // get the size of the extra control by creating and deleting it
160 wxSize GetExtraControlSize();
f74172ab
VZ
161
162private:
8ce68f7f
VZ
163 ExtraControlCreatorFunction m_extraControlCreator;
164
fe6cf128 165 void Init();
f74172ab
VZ
166 DECLARE_DYNAMIC_CLASS(wxFileDialogBase)
167 DECLARE_NO_COPY_CLASS(wxFileDialogBase)
168};
169
8ce68f7f 170
b600ed13
VZ
171//----------------------------------------------------------------------------
172// wxFileDialog convenience functions
173//----------------------------------------------------------------------------
174
f8bcb37d 175// File selector - backward compatibility
53a2db12 176WXDLLIMPEXP_CORE wxString
6dc2e823
VS
177wxFileSelector(const wxString& message = wxFileSelectorPromptStr,
178 const wxString& default_path = wxEmptyString,
179 const wxString& default_filename = wxEmptyString,
180 const wxString& default_extension = wxEmptyString,
f8bcb37d 181 const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
b600ed13
VZ
182 int flags = 0,
183 wxWindow *parent = NULL,
6dc2e823 184 int x = wxDefaultCoord, int y = wxDefaultCoord);
b600ed13
VZ
185
186// An extended version of wxFileSelector
53a2db12 187WXDLLIMPEXP_CORE wxString
6dc2e823
VS
188wxFileSelectorEx(const wxString& message = wxFileSelectorPromptStr,
189 const wxString& default_path = wxEmptyString,
190 const wxString& default_filename = wxEmptyString,
b600ed13 191 int *indexDefaultExtension = NULL,
f8bcb37d 192 const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
b600ed13
VZ
193 int flags = 0,
194 wxWindow *parent = NULL,
6dc2e823 195 int x = wxDefaultCoord, int y = wxDefaultCoord);
b600ed13
VZ
196
197// Ask for filename to load
53a2db12 198WXDLLIMPEXP_CORE wxString
6dc2e823
VS
199wxLoadFileSelector(const wxString& what,
200 const wxString& extension,
201 const wxString& default_name = wxEmptyString,
202 wxWindow *parent = NULL);
b600ed13
VZ
203
204// Ask for filename to save
53a2db12 205WXDLLIMPEXP_CORE wxString
6dc2e823
VS
206wxSaveFileSelector(const wxString& what,
207 const wxString& extension,
208 const wxString& default_name = wxEmptyString,
209 wxWindow *parent = NULL);
b600ed13
VZ
210
211
099d4217 212#if defined (__WXUNIVERSAL__)
0cf3e587
VZ
213 #define wxHAS_GENERIC_FILEDIALOG
214 #include "wx/generic/filedlgg.h"
099d4217 215#elif defined(__WXMSW__)
0cf3e587 216 #include "wx/msw/filedlg.h"
2049ba38 217#elif defined(__WXMOTIF__)
0cf3e587 218 #include "wx/motif/filedlg.h"
ff654490 219#elif defined(__WXGTK20__)
0cf3e587 220 #include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version
1be7a35c 221#elif defined(__WXGTK__)
0cf3e587 222 #include "wx/gtk1/filedlg.h"
34138703 223#elif defined(__WXMAC__)
ef0e9220 224 #include "wx/osx/filedlg.h"
0201182b 225#elif defined(__WXCOCOA__)
0cf3e587 226 #include "wx/cocoa/filedlg.h"
1777b9bb 227#elif defined(__WXPM__)
0cf3e587 228 #include "wx/os2/filedlg.h"
a85ad1db
VZ
229#elif defined(__WXPALMOS__)
230 #define wxHAS_GENERIC_FILEDIALOG
231 #include "wx/generic/filedlgg.h"
c801d85f
KB
232#endif
233
1e6feb95 234#endif // wxUSE_FILEDLG
ba681060 235
b600ed13 236#endif // _WX_FILEDLG_H_BASE_