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