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