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