]> git.saurik.com Git - wxWidgets.git/blobdiff - src/xrc/xh_radbx.cpp
Use generic collapsible pane for wxUniv based builds.
[wxWidgets.git] / src / xrc / xh_radbx.cpp
index 0bff4dda51b134eabe0cc98880e1cf87003888a0..5cf6472c5beb0e0c1363902f7f44646d4cffd29d 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        xh_radbx.cpp
+// Name:        src/xrc/xh_radbx.cpp
 // Purpose:     XRC resource for wxRadioBox
 // Author:      Bob Mitchell
 // Created:     2000/03/21
 // Purpose:     XRC resource for wxRadioBox
 // Author:      Bob Mitchell
 // Created:     2000/03/21
@@ -7,10 +7,6 @@
 // Copyright:   (c) 2000 Bob Mitchell and Verant Interactive
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 // Copyright:   (c) 2000 Bob Mitchell and Verant Interactive
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
-#pragma implementation "xh_radbx.h"
-#endif
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
     #pragma hdrstop
 #endif
 
     #pragma hdrstop
 #endif
 
+#if wxUSE_XRC && wxUSE_RADIOBOX
+
 #include "wx/xrc/xh_radbx.h"
 #include "wx/xrc/xh_radbx.h"
-#include "wx/radiobox.h"
-#include "wx/intl.h"
 
 
-#if wxUSE_RADIOBOX
+#ifndef WX_PRECOMP
+    #include "wx/intl.h"
+    #include "wx/radiobox.h"
+#endif
 
 IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler, wxXmlResourceHandler)
 
 
 IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler, wxXmlResourceHandler)
 
-wxRadioBoxXmlHandler::wxRadioBoxXmlHandler() 
-: wxXmlResourceHandler(), m_insideBox(FALSE)
+wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
+: wxXmlResourceHandler(), m_insideBox(false)
 {
     XRC_ADD_STYLE(wxRA_SPECIFY_COLS);
     XRC_ADD_STYLE(wxRA_HORIZONTAL);
 {
     XRC_ADD_STYLE(wxRA_SPECIFY_COLS);
     XRC_ADD_STYLE(wxRA_HORIZONTAL);
@@ -38,22 +37,27 @@ wxRadioBoxXmlHandler::wxRadioBoxXmlHandler()
 }
 
 wxObject *wxRadioBoxXmlHandler::DoCreateResource()
 }
 
 wxObject *wxRadioBoxXmlHandler::DoCreateResource()
-{ 
-    if( m_class == wxT("wxRadioBox"))
+{
+    if ( m_class == wxT("wxRadioBox"))
     {
         // find the selection
         long selection = GetLong( wxT("selection"), -1 );
 
         // need to build the list of strings from children
     {
         // find the selection
         long selection = GetLong( wxT("selection"), -1 );
 
         // need to build the list of strings from children
-        m_insideBox = TRUE;
+        m_insideBox = true;
         CreateChildrenPrivately( NULL, GetParamNode(wxT("content")));
         CreateChildrenPrivately( NULL, GetParamNode(wxT("content")));
-        wxString *strings = (wxString *) NULL;
-        if( strList.GetCount() > 0 )
+
+        wxString *strings;
+        if ( !labels.empty() )
         {
         {
-            strings = new wxString[strList.GetCount()];
-            int count = strList.GetCount();
-            for( int i = 0; i < count; i++ )
-                strings[i]=strList[i];
+            strings = new wxString[labels.size()];
+            const unsigned count = labels.size();
+            for( unsigned i = 0; i < count; i++ )
+                strings[i] = labels[i];
+        }
+        else
+        {
+            strings = NULL;
         }
 
         XRC_MAKE_INSTANCE(control, wxRadioBox)
         }
 
         XRC_MAKE_INSTANCE(control, wxRadioBox)
@@ -62,34 +66,67 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
                         GetID(),
                         GetText(wxT("label")),
                         GetPosition(), GetSize(),
                         GetID(),
                         GetText(wxT("label")),
                         GetPosition(), GetSize(),
-                        strList.GetCount(),
+                        labels.size(),
                         strings,
                         GetLong(wxT("dimension"), 1),
                         GetStyle(),
                         wxDefaultValidator,
                         GetName());
 
                         strings,
                         GetLong(wxT("dimension"), 1),
                         GetStyle(),
                         wxDefaultValidator,
                         GetName());
 
+        delete[] strings;
+
         if (selection != -1)
             control->SetSelection(selection);
 
         SetupWindow(control);
 
         if (selection != -1)
             control->SetSelection(selection);
 
         SetupWindow(control);
 
-        if (strings != NULL)
-            delete[] strings;
-        strList.Clear();    // dump the strings   
+        const unsigned count = labels.size();
+        for( unsigned i = 0; i < count; i++ )
+        {
+#if wxUSE_TOOLTIPS
+            if ( !tooltips[i].empty() )
+                control->SetItemToolTip(i, tooltips[i]);
+#endif // wxUSE_TOOLTIPS
+#if wxUSE_HELP
+            if ( helptextSpecified[i] )
+                control->SetItemHelpText(i, helptexts[i]);
+#endif // wxUSE_HELP
+        }
+
+        labels.clear();    // dump the strings
+
+        tooltips.clear();    // dump the tooltips
+
+        helptexts.clear();   // dump the helptexts
+        helptextSpecified.clear();
 
         return control;
     }
 
         return control;
     }
-    else
+    else // inside the radiobox element
     {
     {
-        // on the inside now.
-        // handle <item selected="boolean">Label</item>
+        // we handle handle <item tooltip="..." helptext="...">Label</item> constructs here
 
 
-        // add to the list
         wxString str = GetNodeContent(m_node);
         wxString str = GetNodeContent(m_node);
+
+        wxString tooltip;
+        m_node->GetPropVal(wxT("tooltip"), &tooltip);
+
+        wxString helptext;
+        bool hasHelptext = m_node->GetPropVal(wxT("helptext"), &helptext);
+
         if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
         if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
-            str = wxGetTranslation(str);
-        strList.Add(str);
+        {
+            str = wxGetTranslation(str, m_resource->GetDomain());
+            if ( !tooltip.empty() )
+                tooltip = wxGetTranslation(tooltip, m_resource->GetDomain());
+            if ( hasHelptext )
+                helptext = wxGetTranslation(helptext, m_resource->GetDomain());
+        }
+
+        labels.push_back(str);
+        tooltips.push_back(tooltip);
+        helptexts.push_back(helptext);
+        helptextSpecified.push_back(hasHelptext);
 
         return NULL;
     }
 
         return NULL;
     }
@@ -102,4 +139,4 @@ bool wxRadioBoxXmlHandler::CanHandle(wxXmlNode *node)
            (m_insideBox && node->GetName() == wxT("item")));
 }
 
            (m_insideBox && node->GetName() == wxT("item")));
 }
 
-#endif
+#endif // wxUSE_XRC && wxUSE_RADIOBOX