]> git.saurik.com Git - wxWidgets.git/blobdiff - src/xrc/xh_radbx.cpp
use a filename, not URL, when quering its modification time
[wxWidgets.git] / src / xrc / xh_radbx.cpp
index 07a98db9b83b3ff0e2625f2e8c733dccd5328da3..83be9a2d291f93d00e894e871d76fc5123432090 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
@@ -8,10 +8,6 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "xh_radbx.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #if wxUSE_XRC && wxUSE_RADIOBOX
 
 #include "wx/xrc/xh_radbx.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/intl.h"
+#endif
+
 #include "wx/radiobox.h"
-#include "wx/intl.h"
 
 IMPLEMENT_DYNAMIC_CLASS(wxRadioBoxXmlHandler, wxXmlResourceHandler)
 
@@ -39,7 +39,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,13 +47,18 @@ 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 )
+
+        wxString *strings;
+        if ( !labels.empty() )
+        {
+            strings = new wxString[labels.size()];
+            const unsigned count = labels.size();
+            for( unsigned i = 0; i < count; i++ )
+                strings[i] = labels[i];
+        }
+        else
         {
-            strings = new wxString[strList.GetCount()];
-            int count = strList.GetCount();
-            for( int i = 0; i < count; i++ )
-                strings[i]=strList[i];
+            strings = NULL;
         }
 
         XRC_MAKE_INSTANCE(control, wxRadioBox)
@@ -62,34 +67,51 @@ wxObject *wxRadioBoxXmlHandler::DoCreateResource()
                         GetID(),
                         GetText(wxT("label")),
                         GetPosition(), GetSize(),
-                        strList.GetCount(),
+                        labels.size(),
                         strings,
                         GetLong(wxT("dimension"), 1),
                         GetStyle(),
                         wxDefaultValidator,
                         GetName());
 
+        delete[] strings;
+
         if (selection != -1)
             control->SetSelection(selection);
 
         SetupWindow(control);
 
-        if (strings != NULL)
-            delete[] strings;
-        strList.Clear();    // dump the strings
+#if wxUSE_TOOLTIPS
+        const unsigned count = labels.size();
+        for( unsigned i = 0; i < count; i++ )
+        {
+            if ( !tooltips[i].empty() )
+                control->SetItemToolTip(i, tooltips[i]);
+        }
+#endif // wxUSE_TOOLTIPS
+
+        labels.clear();    // dump the strings
+        tooltips.clear();    // dump the tooltips
 
         return control;
     }
-    else
+    else // inside the radiobox element
     {
-        // on the inside now.
-        // handle <item selected="boolean">Label</item>
+        // we handle <item tooltip="...">Label</item> constructs here
 
-        // add to the list
         wxString str = GetNodeContent(m_node);
+        wxString tooltip;
+        m_node->GetPropVal(wxT("tooltip"), &tooltip);
+
         if (m_resource->GetFlags() & wxXRC_USE_LOCALE)
+        {
             str = wxGetTranslation(str);
-        strList.Add(str);
+            if ( !tooltip.empty() )
+                tooltip = wxGetTranslation(tooltip);
+        }
+
+        labels.push_back(str);
+        tooltips.push_back(tooltip);
 
         return NULL;
     }