]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/xrc/xh_tglbtn.cpp | |
3 | // Purpose: XRC resource for wxToggleButton | |
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 | ||
11 | // For compilers that support precompilation, includes "wx.h". | |
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #ifdef __BORLANDC__ | |
15 | #pragma hdrstop | |
16 | #endif | |
17 | ||
18 | #if wxUSE_XRC && wxUSE_TOGGLEBTN | |
19 | ||
20 | #include "wx/xrc/xh_tglbtn.h" | |
21 | #include "wx/tglbtn.h" | |
22 | #include "wx/button.h" // solely for wxBU_EXACTFIT | |
23 | ||
24 | IMPLEMENT_DYNAMIC_CLASS(wxToggleButtonXmlHandler, wxXmlResourceHandler) | |
25 | ||
26 | wxToggleButtonXmlHandler::wxToggleButtonXmlHandler() | |
27 | : wxXmlResourceHandler() | |
28 | { | |
29 | XRC_ADD_STYLE(wxBU_EXACTFIT); | |
30 | ||
31 | AddWindowStyles(); | |
32 | } | |
33 | ||
34 | wxObject *wxToggleButtonXmlHandler::DoCreateResource() | |
35 | { | |
36 | ||
37 | wxObject *control = m_instance; | |
38 | ||
39 | #if !defined(__WXUNIVERSAL__) && !defined(__WXMOTIF__) && !defined(__WXPALMOS__) && !defined(__WXPM__) && !(defined(__WXGTK__) && !defined(__WXGTK20__)) | |
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)); | |
58 | ||
59 | return control; | |
60 | } | |
61 | ||
62 | bool wxToggleButtonXmlHandler::CanHandle(wxXmlNode *node) | |
63 | { | |
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 | button->Create(m_parentAsWindow, | |
75 | GetID(), | |
76 | GetText(wxT("label")), | |
77 | GetPosition(), GetSize(), | |
78 | GetStyle(), | |
79 | wxDefaultValidator, | |
80 | GetName()); | |
81 | ||
82 | button->SetValue(GetBool( wxT("checked"))); | |
83 | } | |
84 | ||
85 | #if !defined(__WXUNIVERSAL__) && !defined(__WXMOTIF__) && !defined(__WXPALMOS__) && !defined(__WXPM__) && !(defined(__WXGTK__) && !defined(__WXGTK20__)) | |
86 | void wxToggleButtonXmlHandler::DoCreateBitmapToggleButton(wxObject *control) | |
87 | { | |
88 | wxBitmapToggleButton *button = wxDynamicCast(control, wxBitmapToggleButton); | |
89 | ||
90 | button->Create(m_parentAsWindow, | |
91 | GetID(), | |
92 | GetBitmap(wxT("bitmap"), wxART_BUTTON), | |
93 | GetPosition(), GetSize(), | |
94 | GetStyle(), | |
95 | wxDefaultValidator, | |
96 | GetName()); | |
97 | ||
98 | button->SetValue(GetBool( wxT("checked"))); | |
99 | } | |
100 | #endif | |
101 | #endif // wxUSE_XRC && wxUSE_TOGGLEBTN |