]> git.saurik.com Git - wxWidgets.git/blame - include/wx/filedlg.h
fixing -fvisibility-inlines-hidden problem (IsOk function didn't get exported)
[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,
53#if WXWIN_COMPATIBILITY_2_4
54 wxHIDE_READONLY = 0x0008,
55#endif
56 wxFILE_MUST_EXIST = wxFD_FILE_MUST_EXIST,
57 wxMULTIPLE = wxFD_MULTIPLE,
58 wxCHANGE_DIR = wxFD_CHANGE_DIR
59};
60#endif
61
ff3e84ff
VZ
62#define wxFD_DEFAULT_STYLE wxFD_OPEN
63
64extern WXDLLEXPORT_DATA(const wxChar) wxFileDialogNameStr[];
63ec432b
MR
65extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorPromptStr[];
66extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorDefaultWildcardStr[];
b600ed13 67
f74172ab
VZ
68//----------------------------------------------------------------------------
69// wxFileDialogBase
70//----------------------------------------------------------------------------
71
72class WXDLLEXPORT wxFileDialogBase: public wxDialog
73{
74public:
fe6cf128 75 wxFileDialogBase () { Init(); }
f74172ab
VZ
76
77 wxFileDialogBase(wxWindow *parent,
fe6cf128
VZ
78 const wxString& message = wxFileSelectorPromptStr,
79 const wxString& defaultDir = wxEmptyString,
80 const wxString& defaultFile = wxEmptyString,
81 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
ff3e84ff
VZ
82 long style = wxFD_DEFAULT_STYLE,
83 const wxPoint& pos = wxDefaultPosition,
84 const wxSize& sz = wxDefaultSize,
85 const wxString& name = wxFileDialogNameStr)
fe6cf128
VZ
86 {
87 Init();
ff3e84ff 88 Create(parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name);
fe6cf128
VZ
89 }
90
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
119 // Utility functions
120
9e152a55 121#if WXWIN_COMPATIBILITY_2_4
f74172ab
VZ
122 // Parses the wildCard, returning the number of filters.
123 // Returns 0 if none or if there's a problem,
124 // The arrays will contain an equal number of items found before the error.
125 // wildCard is in the form:
126 // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
eecb33b0
WS
127 wxDEPRECATED( static int ParseWildcard(const wxString& wildCard,
128 wxArrayString& descriptions,
129 wxArrayString& filters) );
9e152a55 130#endif // WXWIN_COMPATIBILITY_2_4
b600ed13 131
f74172ab
VZ
132 // Append first extension to filePath from a ';' separated extensionList
133 // if filePath = "path/foo.bar" just return it as is
134 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
135 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
136 static wxString AppendExtension(const wxString &filePath,
137 const wxString &extensionList);
138
139protected:
140 wxString m_message;
f74172ab
VZ
141 wxString m_dir;
142 wxString m_path; // Full path
143 wxString m_fileName;
144 wxString m_wildCard;
145 int m_filterIndex;
146
147private:
fe6cf128 148 void Init();
f74172ab
VZ
149 DECLARE_DYNAMIC_CLASS(wxFileDialogBase)
150 DECLARE_NO_COPY_CLASS(wxFileDialogBase)
151};
152
b600ed13
VZ
153//----------------------------------------------------------------------------
154// wxFileDialog convenience functions
155//----------------------------------------------------------------------------
156
157// File selector - backward compatibility
158WXDLLEXPORT wxString
159wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
160 const wxChar *default_path = NULL,
161 const wxChar *default_filename = NULL,
162 const wxChar *default_extension = NULL,
163 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
164 int flags = 0,
165 wxWindow *parent = NULL,
a62848fd 166 int x = wxDefaultCoord, int y = wxDefaultCoord);
b600ed13
VZ
167
168// An extended version of wxFileSelector
169WXDLLEXPORT wxString
170wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
171 const wxChar *default_path = NULL,
172 const wxChar *default_filename = NULL,
173 int *indexDefaultExtension = NULL,
174 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
175 int flags = 0,
176 wxWindow *parent = NULL,
a62848fd 177 int x = wxDefaultCoord, int y = wxDefaultCoord);
b600ed13
VZ
178
179// Ask for filename to load
180WXDLLEXPORT wxString
181wxLoadFileSelector(const wxChar *what,
182 const wxChar *extension,
183 const wxChar *default_name = (const wxChar *)NULL,
184 wxWindow *parent = (wxWindow *) NULL);
185
186// Ask for filename to save
187WXDLLEXPORT wxString
188wxSaveFileSelector(const wxChar *what,
189 const wxChar *extension,
190 const wxChar *default_name = (const wxChar *) NULL,
191 wxWindow *parent = (wxWindow *) NULL);
192
193
099d4217 194#if defined (__WXUNIVERSAL__)
a84f5f39 195#define wxUSE_GENERIC_FILEDIALOG
099d4217
CE
196#include "wx/generic/filedlgg.h"
197#elif defined(__WXMSW__)
c801d85f 198#include "wx/msw/filedlg.h"
2049ba38 199#elif defined(__WXMOTIF__)
34138703 200#include "wx/motif/filedlg.h"
ff3e84ff
VZ
201#elif defined(__WXGTK24__)
202#include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version
1be7a35c 203#elif defined(__WXGTK20__)
a84f5f39 204#define wxUSE_GENERIC_FILEDIALOG
ff3e84ff 205#include "wx/generic/filedlgg.h"
1be7a35c 206#elif defined(__WXGTK__)
7e52dfd2 207#include "wx/gtk1/filedlg.h"
34138703
JS
208#elif defined(__WXMAC__)
209#include "wx/mac/filedlg.h"
0201182b 210#elif defined(__WXCOCOA__)
f31424db 211#include "wx/cocoa/filedlg.h"
1777b9bb
DW
212#elif defined(__WXPM__)
213#include "wx/os2/filedlg.h"
c801d85f
KB
214#endif
215
1e6feb95 216#endif // wxUSE_FILEDLG
ba681060 217
b600ed13 218#endif // _WX_FILEDLG_H_BASE_