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