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"
31 #include "wx/scopedptr.h"
34 // ============================================================================
36 // ============================================================================
38 IMPLEMENT_DYNAMIC_CLASS(wxGenericFileButton
, wxButton
)
39 IMPLEMENT_DYNAMIC_CLASS(wxGenericDirButton
, wxButton
)
41 // ----------------------------------------------------------------------------
42 // wxGenericFileButton
43 // ----------------------------------------------------------------------------
45 bool wxGenericFileDirButton::Create(wxWindow
*parent
,
47 const wxString
& label
,
49 const wxString
& message
,
50 const wxString
& wildcard
,
54 const wxValidator
& validator
,
57 m_pickerStyle
= style
;
59 // If the special wxPB_SMALL flag is used, ignore the provided label and
60 // use the shortest possible label and the smallest possible button fitting
64 if ( m_pickerStyle
& wxPB_SMALL
)
66 labelButton
= _("...");
67 styleButton
= wxBU_EXACTFIT
;
75 if ( !wxButton::Create(parent
, id
, labelButton
,
76 pos
, size
, styleButton
, validator
, name
) )
78 wxFAIL_MSG( wxT("wxGenericFileButton creation failed") );
82 // and handle user clicks on it
83 Connect(GetId(), wxEVT_COMMAND_BUTTON_CLICKED
,
84 wxCommandEventHandler(wxGenericFileDirButton::OnButtonClick
),
87 // create the dialog associated with this button
90 m_wildcard
= wildcard
;
95 void wxGenericFileDirButton::OnButtonClick(wxCommandEvent
& WXUNUSED(ev
))
97 wxScopedPtr
<wxDialog
> p(CreateDialog());
98 if (p
->ShowModal() == wxID_OK
)
100 // save updated path in m_path
101 UpdatePathFromDialog(p
.get());
104 wxFileDirPickerEvent
event(GetEventType(), this, GetId(), m_path
);
105 GetEventHandler()->ProcessEvent(event
);
109 #endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL