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
,
45 const wxString
& label
,
47 const wxString
& message
,
48 const wxString
& wildcard
,
52 const wxValidator
& validator
,
55 m_pickerStyle
= style
;
57 // If the special wxPB_SMALL flag is used, ignore the provided label and
58 // use the shortest possible label and the smallest possible button fitting
62 if ( m_pickerStyle
& wxPB_SMALL
)
64 labelButton
= _("...");
65 styleButton
= wxBU_EXACTFIT
;
73 if ( !wxButton::Create(parent
, id
, labelButton
,
74 pos
, size
, styleButton
, validator
, name
) )
76 wxFAIL_MSG( wxT("wxGenericFileButton creation failed") );
80 // and handle user clicks on it
81 Connect(GetId(), wxEVT_COMMAND_BUTTON_CLICKED
,
82 wxCommandEventHandler(wxGenericFileDirButton::OnButtonClick
),
85 // create the dialog associated with this button
88 m_wildcard
= wildcard
;
93 void wxGenericFileDirButton::OnButtonClick(wxCommandEvent
& WXUNUSED(ev
))
95 wxDialog
*p
= CreateDialog();
96 if (p
->ShowModal() == wxID_OK
)
98 // save updated path in m_path
99 UpdatePathFromDialog(p
);
102 wxFileDirPickerEvent
event(GetEventType(), this, GetId(), m_path
);
103 GetEventHandler()->ProcessEvent(event
);
109 #endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL