1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/filedirpicker.h
3 // Purpose: wxFileButton, wxDirButton header
4 // Author: Francesco Montorsi
7 // Copyright: (c) Francesco Montorsi
9 // Licence: wxWindows Licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_GTK_FILEPICKER_H_
13 #define _WX_GTK_FILEPICKER_H_
15 // since GtkColorButton is available only for GTK+ >= 2.4,
16 // we need to use generic versions if we detect (at runtime)
18 #include "wx/generic/filepickerg.h"
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 //-----------------------------------------------------------------------------
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 */ \
32 /* request in response to the user click as the generic implementation */ \
34 virtual wxWindow *GetDialogParent() \
39 virtual bool Destroy() \
41 m_dialog->Destroy(); \
42 return wxButton::Destroy(); \
46 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
50 class WXDLLIMPEXP_CORE wxFileButton
: public wxGenericFileButton
53 wxFileButton() { m_dialog
= NULL
; }
54 wxFileButton(wxWindow
*parent
,
56 const wxString
& label
= wxFilePickerWidgetLabel
,
57 const wxString
&path
= wxEmptyString
,
58 const wxString
&message
= wxFileSelectorPromptStr
,
59 const wxString
&wildcard
= wxFileSelectorDefaultWildcardStr
,
60 const wxPoint
& pos
= wxDefaultPosition
,
61 const wxSize
& size
= wxDefaultSize
,
62 long style
= wxFILEBTN_DEFAULT_STYLE
,
63 const wxValidator
& validator
= wxDefaultValidator
,
64 const wxString
& name
= wxFilePickerWidgetNameStr
)
67 Create(parent
, id
, label
, path
, message
, wildcard
,
68 pos
, size
, style
, validator
, name
);
71 virtual ~wxFileButton();
76 bool Create(wxWindow
*parent
,
78 const wxString
& label
= wxFilePickerWidgetLabel
,
79 const wxString
&path
= wxEmptyString
,
80 const wxString
&message
= wxFileSelectorPromptStr
,
81 const wxString
&wildcard
= wxFileSelectorDefaultWildcardStr
,
82 const wxPoint
& pos
= wxDefaultPosition
,
83 const wxSize
& size
= wxDefaultSize
,
85 const wxValidator
& validator
= wxDefaultValidator
,
86 const wxString
& name
= wxFilePickerWidgetNameStr
);
88 // event handler for the click
89 void OnDialogOK(wxCommandEvent
&);
92 public: // some overrides
94 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_ACTION_SAVE
95 // so we replace it with GTK_FILE_CHOOSER_ACTION_OPEN; since wxFD_SAVE
96 // is not supported, wxFD_OVERWRITE_PROMPT isn't too...
97 virtual long GetDialogStyle() const
99 return (wxGenericFileButton::GetDialogStyle() &
100 ~(wxFD_SAVE
| wxFD_OVERWRITE_PROMPT
)) | wxFD_OPEN
;
103 virtual void SetPath(const wxString
&str
);
105 // see macro defined above
112 DECLARE_DYNAMIC_CLASS(wxFileButton
)
116 //-----------------------------------------------------------------------------
118 //-----------------------------------------------------------------------------
120 class WXDLLIMPEXP_CORE wxDirButton
: public wxGenericDirButton
123 wxDirButton() { Init(); }
124 wxDirButton(wxWindow
*parent
,
126 const wxString
& label
= wxFilePickerWidgetLabel
,
127 const wxString
&path
= wxEmptyString
,
128 const wxString
&message
= wxFileSelectorPromptStr
,
129 const wxPoint
& pos
= wxDefaultPosition
,
130 const wxSize
& size
= wxDefaultSize
,
131 long style
= wxDIRBTN_DEFAULT_STYLE
,
132 const wxValidator
& validator
= wxDefaultValidator
,
133 const wxString
& name
= wxFilePickerWidgetNameStr
)
137 Create(parent
, id
, label
, path
, message
, wxEmptyString
,
138 pos
, size
, style
, validator
, name
);
141 virtual ~wxDirButton();
146 bool Create(wxWindow
*parent
,
148 const wxString
& label
= wxFilePickerWidgetLabel
,
149 const wxString
&path
= wxEmptyString
,
150 const wxString
&message
= wxFileSelectorPromptStr
,
151 const wxString
&wildcard
= wxFileSelectorDefaultWildcardStr
,
152 const wxPoint
& pos
= wxDefaultPosition
,
153 const wxSize
& size
= wxDefaultSize
,
155 const wxValidator
& validator
= wxDefaultValidator
,
156 const wxString
& name
= wxFilePickerWidgetNameStr
);
159 // GtkFileChooserButton does not support GTK_FILE_CHOOSER_CREATE_FOLDER
160 // thus we must ensure that the wxDD_DIR_MUST_EXIST style was given
161 long GetDialogStyle() const
163 return (wxGenericDirButton::GetDialogStyle() | wxDD_DIR_MUST_EXIST
);
166 virtual void SetPath(const wxString
&str
);
168 // see macro defined above
172 // common part of all ctors
176 m_bIgnoreNextChange
= false;
181 public: // used by the GTK callback only
183 bool m_bIgnoreNextChange
;
185 void UpdatePath(const char *gtkpath
)
186 { m_path
= wxString::FromAscii(gtkpath
); }
189 DECLARE_DYNAMIC_CLASS(wxDirButton
)
192 #undef FILEDIRBTN_OVERRIDES
194 #endif // _WX_GTK_FILEPICKER_H_