]> git.saurik.com Git - wxWidgets.git/blobdiff - src/xrc/xh_tglbtn.cpp
new file added
[wxWidgets.git] / src / xrc / xh_tglbtn.cpp
index c5f0b559e75031edbbedccd9f285ffe9fb3a8d1c..7d2e1cb9456a8d8c89db1b2cca6753f562cb3579 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        xh_tglbtn.cpp
+// Name:        src/xrc/xh_tglbtn.cpp
 // Purpose:     XRC resource for wxToggleButton
 // Author:      Bob Mitchell
 // Created:     2000/03/21
 // Purpose:     XRC resource for wxToggleButton
 // Author:      Bob Mitchell
 // Created:     2000/03/21
@@ -19,6 +19,7 @@
 
 #include "wx/xrc/xh_tglbtn.h"
 #include "wx/tglbtn.h"
 
 #include "wx/xrc/xh_tglbtn.h"
 #include "wx/tglbtn.h"
+#include "wx/button.h" // solely for wxBU_EXACTFIT
 
 IMPLEMENT_DYNAMIC_CLASS(wxToggleButtonXmlHandler, wxXmlResourceHandler)
 
 
 IMPLEMENT_DYNAMIC_CLASS(wxToggleButtonXmlHandler, wxXmlResourceHandler)
 
@@ -32,25 +33,69 @@ wxToggleButtonXmlHandler::wxToggleButtonXmlHandler()
 
 wxObject *wxToggleButtonXmlHandler::DoCreateResource()
 {
 
 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(__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 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(__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
 #endif // wxUSE_XRC && wxUSE_TOGGLEBTN