X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e03951b772a4e202282fbbd6eb4ff618204148db..ce0ee9aec1fe43a5645390bd1e45f27a2518a03b:/src/xrc/xmlres.cpp diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 88fa86ab4a..4aeeb37a11 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -1189,18 +1189,11 @@ float wxXmlResourceHandler::GetFloat(const wxString& param, float defaultv) { wxString str = GetParamValue(param); -#if wxUSE_INTL - // strings in XRC always use C locale but wxString::ToDouble() uses the - // current one, so transform the string to it supposing that the only - // difference between them is the decimal separator - // - // TODO: use wxString::ToCDouble() when we have it - str.Replace(wxT("."), wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, - wxLOCALE_CAT_NUMBER)); -#endif // wxUSE_INTL - + // strings in XRC always use C locale so make sure to use the + // locale-independent wxString::ToCDouble() and not ToDouble() which uses + // the current locale with a potentially different decimal point character double value; - if (!str.ToDouble(&value)) + if (!str.ToCDouble(&value)) value = defaultv; return wx_truncate_cast(float, value); @@ -1500,18 +1493,13 @@ wxImageList *wxXmlResourceHandler::GetImageList(const wxString& param) wxXmlNode * const oldnode = m_node; m_node = imagelist_node; - // size + // Get the size if we have it, otherwise we will use the size of the first + // list element. wxSize size = GetSize(); - size.SetDefaults(wxSize(wxSystemSettings::GetMetric(wxSYS_ICON_X), - wxSystemSettings::GetMetric(wxSYS_ICON_Y))); - - // mask: true by default - bool mask = HasParam(wxT("mask")) ? GetBool(wxT("mask"), true) : true; - // now we have everything we need to create the image list - wxImageList *imagelist = new wxImageList(size.x, size.y, mask); - - // add images + // Start adding images, we'll create the image list when adding the first + // one. + wxImageList * imagelist = NULL; wxString parambitmap = wxT("bitmap"); if ( HasParam(parambitmap) ) { @@ -1520,8 +1508,21 @@ wxImageList *wxXmlResourceHandler::GetImageList(const wxString& param) { if (n->GetType() == wxXML_ELEMENT_NODE && n->GetName() == parambitmap) { + wxIcon icon = GetIcon(n); + if ( !imagelist ) + { + // We need the real image list size to create it. + if ( size == wxDefaultSize ) + size = icon.GetSize(); + + // We use the mask by default. + bool mask = !HasParam(wxS("mask")) || GetBool(wxS("mask")); + + imagelist = new wxImageList(size.x, size.y, mask); + } + // add icon instead of bitmap to keep the bitmap mask - imagelist->Add(GetIcon(n)); + imagelist->Add(icon); } n = n->GetNext(); } @@ -1554,9 +1555,10 @@ wxXmlNode *wxXmlResourceHandler::GetParamNode(const wxString& param) return NULL; } +/* static */ bool wxXmlResourceHandler::IsOfClass(wxXmlNode *node, const wxString& classname) { - return node->GetAttribute(wxT("class"), wxEmptyString) == classname; + return node->GetAttribute(wxT("class")) == classname; }