X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/88a7a4e10ed18f81a576dcd866cfbf02bf404c00..9d5507f7a2701395e1d5c121bd877bb9066ee6ea:/src/xrc/xh_radbx.cpp?ds=inline diff --git a/src/xrc/xh_radbx.cpp b/src/xrc/xh_radbx.cpp index 7bc108302e..dbbf54b5e4 100644 --- a/src/xrc/xh_radbx.cpp +++ b/src/xrc/xh_radbx.cpp @@ -21,10 +21,9 @@ #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,13 +46,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 +66,67 @@ 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 + 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; } - else + else // inside the radiobox element { - // on the inside now. - // handle Label + // we handle handle Label constructs here - // add to the list wxString str = GetNodeContent(m_node); + + wxString tooltip; + m_node->GetAttribute(wxT("tooltip"), &tooltip); + + wxString helptext; + bool hasHelptext = m_node->GetAttribute(wxT("helptext"), &helptext); + 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; }