]> git.saurik.com Git - wxWidgets.git/blob - src/generic/filepickerg.cpp
Added help button
[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,
44 wxWindowID id,
45 const wxString& label,
46 const wxString& path,
47 const wxString& message,
48 const wxString& wildcard,
49 const wxPoint& pos,
50 const wxSize& size,
51 long WXUNUSED(style),
52 const wxValidator& validator,
53 const wxString& name)
54 {
55 // create this button
56 if ( !wxButton::Create(parent, id, label, pos, size, 0, validator, name) )
57 {
58 wxFAIL_MSG( wxT("wxGenericFileButton creation failed") );
59 return false;
60 }
61
62 // and handle user clicks on it
63 Connect(GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
64 wxCommandEventHandler(wxGenericFileDirButton::OnButtonClick),
65 NULL, this);
66
67 // create the dialog associated with this button
68 m_path = path;
69 m_message = message;
70 m_wildcard = wildcard;
71
72 return true;
73 }
74
75 void wxGenericFileDirButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev))
76 {
77 wxDialog *p = CreateDialog();
78 if (p->ShowModal() == wxID_OK)
79 {
80 // save updated path in m_path
81 UpdatePathFromDialog(p);
82
83 // fire an event
84 wxFileDirPickerEvent event(GetEventType(), this, GetId(), m_path);
85 GetEventHandler()->ProcessEvent(event);
86 }
87
88 wxDELETE(p);
89 }
90
91 #endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL