X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c575e45a24711793f98959a1f394a9e528c3129a..90e10cd1bedc5cac1ce1b5331d6fd2a351014cfa:/src/xrc/xh_tglbtn.cpp diff --git a/src/xrc/xh_tglbtn.cpp b/src/xrc/xh_tglbtn.cpp index 637e238434..be031f7565 100644 --- a/src/xrc/xh_tglbtn.cpp +++ b/src/xrc/xh_tglbtn.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: xh_tglbtn.cpp -// Purpose: XRC resource for wxCheckBox +// Purpose: XRC resource for wxToggleButton // Author: Bob Mitchell // Created: 2000/03/21 // RCS-ID: $Id$ @@ -8,10 +8,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "xh_tglbtn.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -23,36 +19,83 @@ #include "wx/xrc/xh_tglbtn.h" #include "wx/tglbtn.h" +#include "wx/button.h" // solely for wxBU_EXACTFIT IMPLEMENT_DYNAMIC_CLASS(wxToggleButtonXmlHandler, wxXmlResourceHandler) wxToggleButtonXmlHandler::wxToggleButtonXmlHandler() -: wxXmlResourceHandler() + : wxXmlResourceHandler() { + XRC_ADD_STYLE(wxBU_EXACTFIT); + AddWindowStyles(); } wxObject *wxToggleButtonXmlHandler::DoCreateResource() { - XRC_MAKE_INSTANCE(control, wxToggleButton) - control->Create(m_parentAsWindow, - GetID(), - GetText(wxT("label")), - GetPosition(), GetSize(), - GetStyle(), - wxDefaultValidator, - GetName()); + wxObject *control = m_instance; - control->SetValue(GetBool( wxT("checked"))); - SetupWindow(control); +#if !defined(__WXUNIVERSAL__) && !defined(__WXMOTIF__) && !defined(__WXPALMOS__) && !defined(__WXPM__) && !(defined(__WXGTK__) && !defined(__WXGTK20__)) + + if (m_class == wxT("wxBitmapToggleButton")) + { + if (!control) + control = new wxBitmapToggleButton; + + DoCreateBitmapToggleButton(control); + } + else +#endif + { + if (!control) + control = new wxToggleButton; + + DoCreateToggleButton(control); + } + + SetupWindow(wxDynamicCast(control, wxWindow)); return control; } bool wxToggleButtonXmlHandler::CanHandle(wxXmlNode *node) { - return IsOfClass(node, wxT("wxToggleButton")); + return ( + IsOfClass(node, wxT("wxToggleButton")) || + IsOfClass(node, wxT("wxBitmapToggleButton")) + ); +} + +void wxToggleButtonXmlHandler::DoCreateToggleButton(wxObject *control) +{ + wxToggleButton *button = wxDynamicCast(control, wxToggleButton); + + button->Create(m_parentAsWindow, + GetID(), + GetText(wxT("label")), + GetPosition(), GetSize(), + GetStyle(), + wxDefaultValidator, + GetName()); + + button->SetValue(GetBool( wxT("checked"))); } +#if !defined(__WXUNIVERSAL__) && !defined(__WXMOTIF__) && !defined(__WXPALMOS__) && !defined(__WXPM__) && !(defined(__WXGTK__) && !defined(__WXGTK20__)) +void wxToggleButtonXmlHandler::DoCreateBitmapToggleButton(wxObject *control) +{ + wxBitmapToggleButton *button = wxDynamicCast(control, wxBitmapToggleButton); + + button->Create(m_parentAsWindow, + GetID(), + GetBitmap(wxT("bitmap"), wxART_BUTTON), + GetPosition(), GetSize(), + GetStyle(), + wxDefaultValidator, + GetName()); + + button->SetValue(GetBool( wxT("checked"))); +} +#endif #endif // wxUSE_XRC && wxUSE_TOGGLEBTN