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