]> git.saurik.com Git - wxWidgets.git/blob - src/generic/filepickerg.cpp
don't use deprecated toolbar API
[wxWidgets.git] / src / generic / filepickerg.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/filepickerg.cpp
3 // Purpose: wxGenericFileDirButton class implementation
4 // Author: Francesco Montorsi
5 // Modified by:
6 // Created: 15/04/2006
7 // RCS-ID: $Id$
8 // Copyright: (c) Francesco Montorsi
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
22
23 #ifdef __BORLANDC__
24 #pragma hdrstop
25 #endif
26
27 #if wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL
28
29 #include "wx/filepicker.h"
30
31
32 // ============================================================================
33 // implementation
34 // ============================================================================
35
36 IMPLEMENT_DYNAMIC_CLASS(wxGenericFileButton, wxButton)
37 IMPLEMENT_DYNAMIC_CLASS(wxGenericDirButton, wxButton)
38
39 // ----------------------------------------------------------------------------
40 // wxGenericFileButton
41 // ----------------------------------------------------------------------------
42
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)
48 {
49 // create this button
50 if (!wxButton::Create(parent, id, label, pos, size, style,
51 validator, name))
52 {
53 wxFAIL_MSG( wxT("wxGenericFileButton creation failed") );
54 return false;
55 }
56
57 // and handle user clicks on it
58 Connect(GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
59 wxCommandEventHandler(wxGenericFileDirButton::OnButtonClick),
60 NULL, this);
61
62 // create the dialog associated with this button
63 m_path = path;
64 m_message = message;
65 m_wildcard = wildcard;
66
67 return true;
68 }
69
70 void wxGenericFileDirButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev))
71 {
72 wxDialog *p = CreateDialog();
73 if (p->ShowModal() == wxID_OK)
74 {
75 // save updated path in m_path
76 UpdatePathFromDialog(p);
77
78 // fire an event
79 wxFileDirPickerEvent event(GetEventType(), this, GetId(), m_path);
80 GetEventHandler()->ProcessEvent(event);
81 }
82
83 wxDELETE(p);
84 }
85
86 #endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL