]> git.saurik.com Git - wxWidgets.git/blobdiff - src/xrc/xh_radbx.cpp
Rename delegates to try and stop name clashes, probably with wxWebKitCtrl.
[wxWidgets.git] / src / xrc / xh_radbx.cpp
index 7bc108302e1cbf1a0369ee0a0d69487ed6175ec8..c6ee9307a685b10ea9ce1342a4a56580dce7febc 100644 (file)
 
 #ifndef WX_PRECOMP
     #include "wx/intl.h"
+    #include "wx/radiobox.h"
 #endif
 
-#include "wx/radiobox.h"
-
 IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler, wxXmlResourceHandler)
 
 wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
@@ -39,7 +38,7 @@ wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
 
 wxObject *wxRadioBoxXmlHandler::DoCreateResource()
 {
-    if( m_class == wxT("wxRadioBox"))
+    if ( m_class == wxT("wxRadioBox"))
     {
         // find the selection
         long selection = GetLong( wxT("selection"), -1 );
@@ -47,14 +46,6 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
         // need to build the list of strings from children
         m_insideBox = true;
         CreateChildrenPrivately( NULL, GetParamNode(wxT("content")));
-        wxString *strings = (wxString *) NULL;
-        if( strList.GetCount() > 0 )
-        {
-            strings = new wxString[strList.GetCount()];
-            int count = strList.GetCount();
-            for( int i = 0; i < count; i++ )
-                strings[i]=strList[i];
-        }
 
         XRC_MAKE_INSTANCE(control, wxRadioBox)
 
@@ -62,8 +53,7 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
                         GetID(),
                         GetText(wxT("label")),
                         GetPosition(), GetSize(),
-                        strList.GetCount(),
-                        strings,
+                        m_labels,
                         GetLong(wxT("dimension"), 1),
                         GetStyle(),
                         wxDefaultValidator,
@@ -74,22 +64,75 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
 
         SetupWindow(control);
 
-        if (strings != NULL)
-            delete[] strings;
-        strList.Clear();    // dump the strings
+        const unsigned count = m_labels.size();
+        for( unsigned i = 0; i < count; i++ )
+        {
+#if wxUSE_TOOLTIPS
+            if ( !m_tooltips[i].empty() )
+                control->SetItemToolTip(i, m_tooltips[i]);
+#endif // wxUSE_TOOLTIPS
+#if wxUSE_HELP
+            if ( m_helptextSpecified[i] )
+                control->SetItemHelpText(i, m_helptexts[i]);
+#endif // wxUSE_HELP
+
+            if ( !m_isShown[i] )
+                control->Show(i, false);
+            if ( !m_isEnabled[i] )
+                control->Enable(i, false);
+        }
+
+
+        // forget information about the items of this radiobox, we should start
+        // afresh for the next one
+        m_labels.clear();
+
+#if wxUSE_TOOLTIPS
+        m_tooltips.clear();
+#endif // wxUSE_TOOLTIPS
+
+#if wxUSE_HELP
+        m_helptexts.clear();
+        m_helptextSpecified.clear();
+#endif // wxUSE_HELP
+
+        m_isShown.clear();
+        m_isEnabled.clear();
 
         return control;
     }
-    else
+    else // inside the radiobox element
     {
-        // on the inside now.
-        // handle <item selected="boolean">Label</item>
+        // we handle handle <item>Label</item> constructs here, and the item
+        // tag can have tooltip, helptext, enabled and hidden attributes
+
+        wxString label = GetNodeContent(m_node);
+
+        wxString tooltip;
+        m_node->GetAttribute(wxT("tooltip"), &tooltip);
+
+        wxString helptext;
+        bool hasHelptext = m_node->GetAttribute(wxT("helptext"), &helptext);
 
-        // add to the list
-        wxString str = GetNodeContent(m_node);
         if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
-            str = wxGetTranslation(str);
-        strList.Add(str);
+        {
+            label = wxGetTranslation(label, m_resource->GetDomain());
+            if ( !tooltip.empty() )
+                tooltip = wxGetTranslation(tooltip, m_resource->GetDomain());
+            if ( hasHelptext )
+                helptext = wxGetTranslation(helptext, m_resource->GetDomain());
+        }
+
+        m_labels.push_back(label);
+#if wxUSE_TOOLTIPS
+        m_tooltips.push_back(tooltip);
+#endif // wxUSE_TOOLTIPS
+#if wxUSE_HELP
+        m_helptexts.push_back(helptext);
+        m_helptextSpecified.push_back(hasHelptext);
+#endif // wxUSE_HELP
+        m_isEnabled.push_back(GetBoolAttr("enabled", 1));
+        m_isShown.push_back(!GetBoolAttr("hidden", 0));
 
         return NULL;
     }