]> git.saurik.com Git - wxWidgets.git/blame - include/wx/filedlg.h
Applied patch which allows you to detach a stream
[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
ff3e84ff
VZ
26enum
27{
28 wxFD_OPEN = 0x0001,
29 wxFD_SAVE = 0x0002,
30 wxFD_OVERWRITE_PROMPT = 0x0004,
31 wxFD_FILE_MUST_EXIST = 0x0010,
32 wxFD_MULTIPLE = 0x0020,
9f057af5
VZ
33 wxFD_CHANGE_DIR = 0x0040,
34 wxFD_PREVIEW = 0x0080
ff3e84ff
VZ
35};
36
e031f1df
WS
37#if WXWIN_COMPATIBILITY_2_6
38enum
39{
40 wxOPEN = wxFD_OPEN,
41 wxSAVE = wxFD_SAVE,
42 wxOVERWRITE_PROMPT = wxFD_OVERWRITE_PROMPT,
43#if WXWIN_COMPATIBILITY_2_4
44 wxHIDE_READONLY = 0x0008,
45#endif
46 wxFILE_MUST_EXIST = wxFD_FILE_MUST_EXIST,
47 wxMULTIPLE = wxFD_MULTIPLE,
48 wxCHANGE_DIR = wxFD_CHANGE_DIR
49};
50#endif
51
ff3e84ff
VZ
52#define wxFD_DEFAULT_STYLE wxFD_OPEN
53
54extern WXDLLEXPORT_DATA(const wxChar) wxFileDialogNameStr[];
63ec432b
MR
55extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorPromptStr[];
56extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorDefaultWildcardStr[];
b600ed13 57
f74172ab
VZ
58//----------------------------------------------------------------------------
59// wxFileDialogBase
60//----------------------------------------------------------------------------
61
62class WXDLLEXPORT wxFileDialogBase: public wxDialog
63{
64public:
fe6cf128 65 wxFileDialogBase () { Init(); }
f74172ab
VZ
66
67 wxFileDialogBase(wxWindow *parent,
fe6cf128
VZ
68 const wxString& message = wxFileSelectorPromptStr,
69 const wxString& defaultDir = wxEmptyString,
70 const wxString& defaultFile = wxEmptyString,
71 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
ff3e84ff
VZ
72 long style = wxFD_DEFAULT_STYLE,
73 const wxPoint& pos = wxDefaultPosition,
74 const wxSize& sz = wxDefaultSize,
75 const wxString& name = wxFileDialogNameStr)
fe6cf128
VZ
76 {
77 Init();
ff3e84ff 78 Create(parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name);
fe6cf128
VZ
79 }
80
81 bool Create(wxWindow *parent,
82 const wxString& message = wxFileSelectorPromptStr,
83 const wxString& defaultDir = wxEmptyString,
84 const wxString& defaultFile = wxEmptyString,
85 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
ff3e84ff
VZ
86 long style = wxFD_DEFAULT_STYLE,
87 const wxPoint& pos = wxDefaultPosition,
88 const wxSize& sz = wxDefaultSize,
89 const wxString& name = wxFileDialogNameStr);
f74172ab
VZ
90
91 virtual void SetMessage(const wxString& message) { m_message = message; }
92 virtual void SetPath(const wxString& path) { m_path = path; }
93 virtual void SetDirectory(const wxString& dir) { m_dir = dir; }
94 virtual void SetFilename(const wxString& name) { m_fileName = name; }
95 virtual void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; }
f74172ab
VZ
96 virtual void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; }
97
98 virtual wxString GetMessage() const { return m_message; }
99 virtual wxString GetPath() const { return m_path; }
100 virtual void GetPaths(wxArrayString& paths) const { paths.Empty(); paths.Add(m_path); }
101 virtual wxString GetDirectory() const { return m_dir; }
102 virtual wxString GetFilename() const { return m_fileName; }
103 virtual void GetFilenames(wxArrayString& files) const { files.Empty(); files.Add(m_fileName); }
104 virtual wxString GetWildcard() const { return m_wildCard; }
f74172ab
VZ
105 virtual int GetFilterIndex() const { return m_filterIndex; }
106
107 // Utility functions
108
9e152a55 109#if WXWIN_COMPATIBILITY_2_4
f74172ab
VZ
110 // Parses the wildCard, returning the number of filters.
111 // Returns 0 if none or if there's a problem,
112 // The arrays will contain an equal number of items found before the error.
113 // wildCard is in the form:
114 // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
eecb33b0
WS
115 wxDEPRECATED( static int ParseWildcard(const wxString& wildCard,
116 wxArrayString& descriptions,
117 wxArrayString& filters) );
9e152a55 118#endif // WXWIN_COMPATIBILITY_2_4
b600ed13 119
f74172ab
VZ
120 // Append first extension to filePath from a ';' separated extensionList
121 // if filePath = "path/foo.bar" just return it as is
122 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
123 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
124 static wxString AppendExtension(const wxString &filePath,
125 const wxString &extensionList);
126
127protected:
128 wxString m_message;
f74172ab
VZ
129 wxString m_dir;
130 wxString m_path; // Full path
131 wxString m_fileName;
132 wxString m_wildCard;
133 int m_filterIndex;
134
135private:
fe6cf128 136 void Init();
f74172ab
VZ
137 DECLARE_DYNAMIC_CLASS(wxFileDialogBase)
138 DECLARE_NO_COPY_CLASS(wxFileDialogBase)
139};
140
b600ed13
VZ
141//----------------------------------------------------------------------------
142// wxFileDialog convenience functions
143//----------------------------------------------------------------------------
144
145// File selector - backward compatibility
146WXDLLEXPORT wxString
147wxFileSelector(const wxChar *message = wxFileSelectorPromptStr,
148 const wxChar *default_path = NULL,
149 const wxChar *default_filename = NULL,
150 const wxChar *default_extension = NULL,
151 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
152 int flags = 0,
153 wxWindow *parent = NULL,
a62848fd 154 int x = wxDefaultCoord, int y = wxDefaultCoord);
b600ed13
VZ
155
156// An extended version of wxFileSelector
157WXDLLEXPORT wxString
158wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr,
159 const wxChar *default_path = NULL,
160 const wxChar *default_filename = NULL,
161 int *indexDefaultExtension = NULL,
162 const wxChar *wildcard = wxFileSelectorDefaultWildcardStr,
163 int flags = 0,
164 wxWindow *parent = NULL,
a62848fd 165 int x = wxDefaultCoord, int y = wxDefaultCoord);
b600ed13
VZ
166
167// Ask for filename to load
168WXDLLEXPORT wxString
169wxLoadFileSelector(const wxChar *what,
170 const wxChar *extension,
171 const wxChar *default_name = (const wxChar *)NULL,
172 wxWindow *parent = (wxWindow *) NULL);
173
174// Ask for filename to save
175WXDLLEXPORT wxString
176wxSaveFileSelector(const wxChar *what,
177 const wxChar *extension,
178 const wxChar *default_name = (const wxChar *) NULL,
179 wxWindow *parent = (wxWindow *) NULL);
180
181
099d4217 182#if defined (__WXUNIVERSAL__)
a84f5f39 183#define wxUSE_GENERIC_FILEDIALOG
099d4217
CE
184#include "wx/generic/filedlgg.h"
185#elif defined(__WXMSW__)
c801d85f 186#include "wx/msw/filedlg.h"
2049ba38 187#elif defined(__WXMOTIF__)
34138703 188#include "wx/motif/filedlg.h"
ff3e84ff
VZ
189#elif defined(__WXGTK24__)
190#include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version
1be7a35c 191#elif defined(__WXGTK20__)
a84f5f39 192#define wxUSE_GENERIC_FILEDIALOG
ff3e84ff 193#include "wx/generic/filedlgg.h"
1be7a35c 194#elif defined(__WXGTK__)
7e52dfd2 195#include "wx/gtk1/filedlg.h"
34138703
JS
196#elif defined(__WXMAC__)
197#include "wx/mac/filedlg.h"
0201182b 198#elif defined(__WXCOCOA__)
f31424db 199#include "wx/cocoa/filedlg.h"
1777b9bb
DW
200#elif defined(__WXPM__)
201#include "wx/os2/filedlg.h"
c801d85f
KB
202#endif
203
1e6feb95 204#endif // wxUSE_FILEDLG
ba681060 205
b600ed13 206#endif // _WX_FILEDLG_H_BASE_