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"
28 #include "wx/window.h"
31 #include "wx/filepicker.h"
32 #include "wx/filedlg.h"
35 // ============================================================================
37 // ============================================================================
39 #if wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL
41 IMPLEMENT_DYNAMIC_CLASS(wxGenericFileButton
, wxButton
)
42 IMPLEMENT_DYNAMIC_CLASS(wxGenericDirButton
, wxButton
)
44 // ----------------------------------------------------------------------------
45 // wxGenericFileButton
46 // ----------------------------------------------------------------------------
48 bool wxGenericFileDirButton::Create( wxWindow
*parent
, wxWindowID id
,
49 const wxString
&label
, const wxString
&path
,
50 const wxString
&message
, const wxString
&wildcard
,
51 const wxPoint
&pos
, const wxSize
&size
, long style
,
52 const wxValidator
& validator
, const wxString
&name
)
55 if (!wxButton::Create(parent
, id
, label
, pos
, size
, style
,
58 wxFAIL_MSG( wxT("wxGenericFileButton creation failed") );
62 // and handle user clicks on it
63 Connect(wxEVT_COMMAND_BUTTON_CLICKED
,
64 wxCommandEventHandler(wxGenericFileDirButton::OnButtonClick
),
67 // create the dialog associated with this button
70 m_wildcard
= wildcard
;
75 void wxGenericFileDirButton::OnButtonClick(wxCommandEvent
& WXUNUSED(ev
))
77 wxDialog
*p
= CreateDialog();
78 if (p
->ShowModal() == wxID_OK
)
80 // save updated path in m_path
81 UpdatePathFromDialog(p
);
84 wxFileDirPickerEvent
event(GetEventType(), this, GetId(), m_path
);
85 GetEventHandler()->ProcessEvent(event
);
91 #endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL