]>
Commit | Line | Data |
---|---|---|
3e265680 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: xh_tglbtn.cpp | |
dd47af27 | 3 | // Purpose: XRC resource for wxToggleButton |
3e265680 JS |
4 | // Author: Bob Mitchell |
5 | // Created: 2000/03/21 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2000 Bob Mitchell and Verant Interactive | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
3e265680 JS |
11 | // For compilers that support precompilation, includes "wx.h". |
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
621be1ec | 18 | #if wxUSE_XRC && wxUSE_TOGGLEBTN |
a1e4ec87 | 19 | |
3e265680 JS |
20 | #include "wx/xrc/xh_tglbtn.h" |
21 | #include "wx/tglbtn.h" | |
491016e5 | 22 | #include "wx/button.h" // solely for wxBU_EXACTFIT |
3e265680 | 23 | |
3e265680 JS |
24 | IMPLEMENT_DYNAMIC_CLASS(wxToggleButtonXmlHandler, wxXmlResourceHandler) |
25 | ||
26 | wxToggleButtonXmlHandler::wxToggleButtonXmlHandler() | |
61a9bd42 | 27 | : wxXmlResourceHandler() |
3e265680 | 28 | { |
61a9bd42 VZ |
29 | XRC_ADD_STYLE(wxBU_EXACTFIT); |
30 | ||
3e265680 JS |
31 | AddWindowStyles(); |
32 | } | |
33 | ||
34 | wxObject *wxToggleButtonXmlHandler::DoCreateResource() | |
35 | { | |
3e265680 | 36 | |
3f6e622f | 37 | wxObject *control = m_instance; |
3e265680 | 38 | |
9015d579 | 39 | #if !defined(__WXUNIVERSAL__) && !defined(__WXMOTIF__) && !defined(__WXPALMOS__) && !defined(__WXPM__) && !(defined(__WXGTK__) && !defined(__WXGTK20__)) |
3f6e622f RR |
40 | |
41 | if (m_class == wxT("wxBitmapToggleButton")) | |
42 | { | |
43 | if (!control) | |
44 | control = new wxBitmapToggleButton; | |
45 | ||
46 | DoCreateBitmapToggleButton(control); | |
47 | } | |
48 | else | |
49 | #endif | |
50 | { | |
51 | if (!control) | |
52 | control = new wxToggleButton; | |
53 | ||
54 | DoCreateToggleButton(control); | |
55 | } | |
56 | ||
57 | SetupWindow(wxDynamicCast(control, wxWindow)); | |
3e265680 JS |
58 | |
59 | return control; | |
60 | } | |
61 | ||
62 | bool wxToggleButtonXmlHandler::CanHandle(wxXmlNode *node) | |
63 | { | |
3f6e622f RR |
64 | return ( |
65 | IsOfClass(node, wxT("wxToggleButton")) || | |
66 | IsOfClass(node, wxT("wxBitmapToggleButton")) | |
67 | ); | |
68 | } | |
69 | ||
70 | void wxToggleButtonXmlHandler::DoCreateToggleButton(wxObject *control) | |
71 | { | |
72 | wxToggleButton *button = wxDynamicCast(control, wxToggleButton); | |
73 | ||
74 | wxString label = GetText(wxT("label")); | |
75 | ||
76 | button->Create(m_parentAsWindow, | |
77 | GetID(), | |
78 | #if defined(__WXUNIVERSAL__) | |
79 | !label.empty() ? label : GetBitmap(wxT("bitmap"), wxART_BUTTON), | |
80 | #else | |
81 | label, | |
82 | #endif | |
83 | GetPosition(), GetSize(), | |
84 | GetStyle(), | |
85 | wxDefaultValidator, | |
86 | GetName()); | |
87 | ||
88 | button->SetValue(GetBool( wxT("checked"))); | |
89 | } | |
90 | ||
9015d579 | 91 | #if !defined(__WXUNIVERSAL__) && !defined(__WXMOTIF__) && !defined(__WXPALMOS__) && !defined(__WXPM__) && !(defined(__WXGTK__) && !defined(__WXGTK20__)) |
3f6e622f RR |
92 | void wxToggleButtonXmlHandler::DoCreateBitmapToggleButton(wxObject *control) |
93 | { | |
94 | wxBitmapToggleButton *button = wxDynamicCast(control, wxBitmapToggleButton); | |
95 | ||
96 | button->Create(m_parentAsWindow, | |
97 | GetID(), | |
98 | GetBitmap(wxT("bitmap"), wxART_BUTTON), | |
99 | GetPosition(), GetSize(), | |
100 | GetStyle(), | |
101 | wxDefaultValidator, | |
102 | GetName()); | |
103 | ||
104 | button->SetValue(GetBool( wxT("checked"))); | |
3e265680 | 105 | } |
9015d579 | 106 | #endif |
621be1ec | 107 | #endif // wxUSE_XRC && wxUSE_TOGGLEBTN |