]> git.saurik.com Git - wxWidgets.git/commitdiff
Applied #11755: wxBitmapToggleButton Xml Handler
authorRobert Roebling <robert@roebling.de>
Sun, 16 May 2010 14:30:13 +0000 (14:30 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 16 May 2010 14:30:13 +0000 (14:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64317 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/xrc/xh_tglbtn.h
src/xrc/xh_tglbtn.cpp

index a37287e69b1bdc70e6b7ba1c28634fd440b69130..63e185865c4e05bdf5751a8cb3aeb09b7f47512a 100644 (file)
@@ -23,6 +23,10 @@ public:
     wxToggleButtonXmlHandler();
     virtual wxObject *DoCreateResource();
     virtual bool CanHandle(wxXmlNode *node);
+
+protected:
+    virtual void DoCreateToggleButton(wxObject *control);
+    virtual void DoCreateBitmapToggleButton(wxObject *control);
 };
 
 #endif // wxUSE_XRC && wxUSE_TOGGLEBTN
index 174252ae28b04096310ca25708f4ebbfe036a5e7..30def16e253e7426f3fcbe70713ac3d2e4a869f0 100644 (file)
@@ -33,25 +33,74 @@ wxToggleButtonXmlHandler::wxToggleButtonXmlHandler()
 
 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__)
+
+    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);
+
+    wxString label = GetText(wxT("label"));
+
+    button->Create(m_parentAsWindow,
+                   GetID(),
+#if defined(__WXUNIVERSAL__)
+                   !label.empty() ? label : GetBitmap(wxT("bitmap"), wxART_BUTTON),
+#else
+                   label,
+#endif
+                   GetPosition(), GetSize(),
+                   GetStyle(),
+                   wxDefaultValidator,
+                   GetName());
+
+    button->SetValue(GetBool( wxT("checked")));
+}
+
+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 // wxUSE_XRC && wxUSE_TOGGLEBTN