]> git.saurik.com Git - wxWidgets.git/blame - src/generic/filepickerg.cpp
[ 1522988 ] Keypress causes crash in combo sample
[wxWidgets.git] / src / generic / filepickerg.cpp
CommitLineData
ec376c8f
VZ
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
c757b5fe 27#if wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL
ec376c8f
VZ
28
29#include "wx/filepicker.h"
ec376c8f
VZ
30
31
32// ============================================================================
33// implementation
34// ============================================================================
35
ec376c8f
VZ
36IMPLEMENT_DYNAMIC_CLASS(wxGenericFileButton, wxButton)
37IMPLEMENT_DYNAMIC_CLASS(wxGenericDirButton, wxButton)
38
39// ----------------------------------------------------------------------------
40// wxGenericFileButton
41// ----------------------------------------------------------------------------
42
43bool 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(wxEVT_COMMAND_BUTTON_CLICKED,
59 wxCommandEventHandler(wxGenericFileDirButton::OnButtonClick),
60 NULL, this);
61
62 // create the dialog associated with this button
63 m_path = path;
556151f5
MW
64 m_message = message;
65 m_wildcard = wildcard;
66
67 return true;
ec376c8f
VZ
68}
69
70void wxGenericFileDirButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev))
71{
556151f5
MW
72 wxDialog *p = CreateDialog();
73 if (p->ShowModal() == wxID_OK)
ec376c8f 74 {
556151f5
MW
75 // save updated path in m_path
76 UpdatePathFromDialog(p);
ec376c8f
VZ
77
78 // fire an event
79 wxFileDirPickerEvent event(GetEventType(), this, GetId(), m_path);
80 GetEventHandler()->ProcessEvent(event);
81 }
556151f5
MW
82
83 wxDELETE(p);
ec376c8f
VZ
84}
85
86#endif // wxUSE_FILEPICKERCTRL || wxUSE_DIRPICKERCTRL