]> git.saurik.com Git - wxWidgets.git/blame - src/xrc/xh_tglbtn.cpp
Make public headers compatible with Objective-C++ with ARC.
[wxWidgets.git] / src / xrc / xh_tglbtn.cpp
CommitLineData
3e265680 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/xrc/xh_tglbtn.cpp
dd47af27 3// Purpose: XRC resource for wxToggleButton
3e265680
JS
4// Author: Bob Mitchell
5// Created: 2000/03/21
3e265680
JS
6// Copyright: (c) 2000 Bob Mitchell and Verant Interactive
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
3e265680
JS
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#ifdef __BORLANDC__
14 #pragma hdrstop
15#endif
16
621be1ec 17#if wxUSE_XRC && wxUSE_TOGGLEBTN
a1e4ec87 18
3e265680
JS
19#include "wx/xrc/xh_tglbtn.h"
20#include "wx/tglbtn.h"
491016e5 21#include "wx/button.h" // solely for wxBU_EXACTFIT
3e265680 22
3e265680
JS
23IMPLEMENT_DYNAMIC_CLASS(wxToggleButtonXmlHandler, wxXmlResourceHandler)
24
25wxToggleButtonXmlHandler::wxToggleButtonXmlHandler()
61a9bd42 26 : wxXmlResourceHandler()
3e265680 27{
61a9bd42
VZ
28 XRC_ADD_STYLE(wxBU_EXACTFIT);
29
3e265680
JS
30 AddWindowStyles();
31}
32
33wxObject *wxToggleButtonXmlHandler::DoCreateResource()
34{
3e265680 35
3f6e622f 36 wxObject *control = m_instance;
3e265680 37
bd362275 38#if !defined(__WXUNIVERSAL__) && !defined(__WXMOTIF__) && !defined(__WXPM__) && !(defined(__WXGTK__) && !defined(__WXGTK20__))
3f6e622f
RR
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));
3e265680
JS
57
58 return control;
59}
60
61bool wxToggleButtonXmlHandler::CanHandle(wxXmlNode *node)
62{
3f6e622f
RR
63 return (
64 IsOfClass(node, wxT("wxToggleButton")) ||
65 IsOfClass(node, wxT("wxBitmapToggleButton"))
66 );
67}
68
69void wxToggleButtonXmlHandler::DoCreateToggleButton(wxObject *control)
70{
71 wxToggleButton *button = wxDynamicCast(control, wxToggleButton);
72
3f6e622f
RR
73 button->Create(m_parentAsWindow,
74 GetID(),
969641a3 75 GetText(wxT("label")),
3f6e622f
RR
76 GetPosition(), GetSize(),
77 GetStyle(),
78 wxDefaultValidator,
79 GetName());
80
81 button->SetValue(GetBool( wxT("checked")));
82}
83
bd362275 84#if !defined(__WXUNIVERSAL__) && !defined(__WXMOTIF__) && !defined(__WXPM__) && !(defined(__WXGTK__) && !defined(__WXGTK20__))
3f6e622f
RR
85void 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")));
3e265680 98}
9015d579 99#endif
621be1ec 100#endif // wxUSE_XRC && wxUSE_TOGGLEBTN