1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/filepickerg.cpp
3 // Purpose: wxGenericFileDirButton class implementation
4 // Author: Francesco Montorsi
8 // Copyright: (c) Francesco Montorsi
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
27 #if wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL
29 #include "wx/filepicker.h"
32 // ============================================================================
34 // ============================================================================
36 IMPLEMENT_DYNAMIC_CLASS(wxGenericFileButton
, wxButton
)
37 IMPLEMENT_DYNAMIC_CLASS(wxGenericDirButton
, wxButton
)
39 // ----------------------------------------------------------------------------
40 // wxGenericFileButton
41 // ----------------------------------------------------------------------------
43 bool wxGenericFileDirButton::Create( wxWindow
*parent
, wxWindowID id
,
44 const wxString
&label
, const wxString
&path
,
45 const wxString
&message
, const wxString
&wildcard
,
46 const wxPoint
&pos
, const wxSize
&size
, long style
,
47 const wxValidator
& validator
, const wxString
&name
)
50 if (!wxButton::Create(parent
, id
, label
, pos
, size
, style
,
53 wxFAIL_MSG( wxT("wxGenericFileButton creation failed") );
57 // and handle user clicks on it
58 Connect(wxEVT_COMMAND_BUTTON_CLICKED
,
59 wxCommandEventHandler(wxGenericFileDirButton::OnButtonClick
),
62 // create the dialog associated with this button
65 m_wildcard
= wildcard
;
70 void wxGenericFileDirButton::OnButtonClick(wxCommandEvent
& WXUNUSED(ev
))
72 wxDialog
*p
= CreateDialog();
73 if (p
->ShowModal() == wxID_OK
)
75 // save updated path in m_path
76 UpdatePathFromDialog(p
);
79 wxFileDirPickerEvent
event(GetEventType(), this, GetId(), m_path
);
80 GetEventHandler()->ProcessEvent(event
);
86 #endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL