]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/filepicker.h
deselect all items when SetSelection(-1) is called (patch 1506943)
[wxWidgets.git] / include / wx / gtk / filepicker.h
CommitLineData
ec376c8f
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/gtk/filedirpicker.h
3// Purpose: wxFileButton, wxDirButton header
4// Author: Francesco Montorsi
5// Modified by:
6// Created: 14/4/2006
7// Copyright: (c) Francesco Montorsi
8// RCS-ID: $Id$
9// Licence: wxWindows Licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_GTK_FILEPICKER_H_
13#define _WX_GTK_FILEPICKER_H_
14
15// since GtkColorButton is available only for GTK+ >= 2.4,
16// we need to use generic versions if we detect (at runtime)
17// that GTK+ < 2.4
18#include "wx/generic/filepickerg.h"
19
556151f5
MW
20
21
22//-----------------------------------------------------------------------------
23// wxFileButton and wxDirButton shared code
24// (cannot be a base class since they need to derive from wxGenericFileButton
25// and from wxGenericDirButton classes !)
26//-----------------------------------------------------------------------------
27
28#define FILEDIRBTN_OVERRIDES \
29 /* NULL is because of a problem with destruction order which happens */ \
30 /* if we pass GetParent(): in fact, this GTK native implementation */ \
31 /* needs to create the dialog in ::Create() and not for each user request */ \
32 /* in response to the user click as the generic implementation does */ \
33 virtual wxWindow *GetDialogParent() \
34 { \
35 return NULL; \
36 } \
37 \
38 virtual bool Destroy() \
39 { \
40 m_dialog->Destroy(); \
41 return wxButton::Destroy(); \
42 } \
43 \
44 virtual void SetPath(const wxString &str) \
45 { \
46 m_path=str; \
47 UpdateDialogPath(m_dialog); \
48 }
49
50
ec376c8f
VZ
51//-----------------------------------------------------------------------------
52// wxFileButton
53//-----------------------------------------------------------------------------
54
55class WXDLLIMPEXP_CORE wxFileButton : public wxGenericFileButton
56{
57public:
556151f5 58 wxFileButton() { m_dialog = NULL; }
ec376c8f
VZ
59 wxFileButton(wxWindow *parent,
60 wxWindowID id,
61 const wxString& label = wxFilePickerWidgetLabel,
62 const wxString &path = wxEmptyString,
63 const wxString &message = wxFileSelectorPromptStr,
64 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
65 const wxPoint& pos = wxDefaultPosition,
66 const wxSize& size = wxDefaultSize,
67 long style = wxFILEBTN_DEFAULT_STYLE,
68 const wxValidator& validator = wxDefaultValidator,
69 const wxString& name = wxFilePickerWidgetNameStr)
70 {
556151f5 71 m_dialog = NULL;
ec376c8f
VZ
72 Create(parent, id, label, path, message, wildcard,
73 pos, size, style, validator, name);
74 }
75
556151f5 76 virtual ~wxFileButton();
ec376c8f
VZ
77
78
79public: // overrides
80
81 bool Create(wxWindow *parent,
82 wxWindowID id,
83 const wxString& label = wxFilePickerWidgetLabel,
84 const wxString &path = wxEmptyString,
85 const wxString &message = wxFileSelectorPromptStr,
86 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
87 const wxPoint& pos = wxDefaultPosition,
88 const wxSize& size = wxDefaultSize,
89 long style = 0,
90 const wxValidator& validator = wxDefaultValidator,
91 const wxString& name = wxFilePickerWidgetNameStr);
92
93 // event handler for the click
94 void OnDialogOK(wxCommandEvent &);
95
96
556151f5
MW
97public: // some overrides
98
ec376c8f 99 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_ACTION_SAVE
556151f5
MW
100 // so we replace it with GTK_FILE_CHOOSER_ACTION_OPEN; since wxFD_SAVE
101 // is not supported, wxFD_OVERWRITE_PROMPT isn't too...
102 virtual long GetDialogStyle() const
ec376c8f 103 {
556151f5
MW
104 return (wxGenericFileButton::GetDialogStyle() &
105 ~(wxFD_SAVE | wxFD_OVERWRITE_PROMPT)) | wxFD_OPEN;
ec376c8f
VZ
106 }
107
556151f5
MW
108 // see macro defined above
109 FILEDIRBTN_OVERRIDES
110
111protected:
112 wxDialog *m_dialog;
ec376c8f
VZ
113
114private:
115 DECLARE_DYNAMIC_CLASS(wxFileButton)
116};
117
118
119//-----------------------------------------------------------------------------
120// wxDirButton
121//-----------------------------------------------------------------------------
122
123class WXDLLIMPEXP_CORE wxDirButton : public wxGenericDirButton
124{
125public:
556151f5 126 wxDirButton() { m_dialog = NULL;}
ec376c8f
VZ
127 wxDirButton(wxWindow *parent,
128 wxWindowID id,
129 const wxString& label = wxFilePickerWidgetLabel,
130 const wxString &path = wxEmptyString,
131 const wxString &message = wxFileSelectorPromptStr,
132 const wxPoint& pos = wxDefaultPosition,
133 const wxSize& size = wxDefaultSize,
134 long style = wxDIRBTN_DEFAULT_STYLE,
135 const wxValidator& validator = wxDefaultValidator,
136 const wxString& name = wxFilePickerWidgetNameStr)
137 {
556151f5 138 m_dialog = NULL;
ec376c8f
VZ
139 Create(parent, id, label, path, message, wxEmptyString,
140 pos, size, style, validator, name);
141 }
142
143 virtual ~wxDirButton();
144
145
146public: // overrides
147
148 bool Create(wxWindow *parent,
149 wxWindowID id,
150 const wxString& label = wxFilePickerWidgetLabel,
151 const wxString &path = wxEmptyString,
152 const wxString &message = wxFileSelectorPromptStr,
153 const wxString &wildcard = wxFileSelectorDefaultWildcardStr,
154 const wxPoint& pos = wxDefaultPosition,
155 const wxSize& size = wxDefaultSize,
156 long style = 0,
157 const wxValidator& validator = wxDefaultValidator,
158 const wxString& name = wxFilePickerWidgetNameStr);
159
160 // used by the GTK callback only
161 void UpdatePath(char *gtkpath)
162 { m_path = wxString::FromAscii(gtkpath); }
163
164 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_CREATE_FOLDER
165 // thus we must ensure that the wxDD_DIR_MUST_EXIST style was given
166 long GetDialogStyle() const
167 {
168 return (wxGenericDirButton::GetDialogStyle() | wxDD_DIR_MUST_EXIST);
169 }
170
556151f5
MW
171 // see macro defined above
172 FILEDIRBTN_OVERRIDES
173
174protected:
175 wxDialog *m_dialog;
176
ec376c8f
VZ
177private:
178 DECLARE_DYNAMIC_CLASS(wxDirButton)
179};
180
556151f5
MW
181#undef FILEDIRBTN_OVERRIDES
182
ec376c8f
VZ
183#endif // _WX_GTK_FILEPICKER_H_
184