X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/326462ae94e4b1d4fb6a8d56875ce0fcbd9d1c33..a188ac2988b6fedeead7a809124b8eaa2290c020:/src/xrc/xmlres.cpp diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 988d73027a..5b21be5d36 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -1334,13 +1334,29 @@ wxBitmap wxXmlResourceHandler::GetBitmap(const wxString& param, const wxArtClient& defaultArtClient, wxSize size) { - return GetBitmap(GetParamNode(param), defaultArtClient, size); + // it used to be possible to pass an empty string here to indicate that the + // bitmap name should be read from this node itself but this is not + // supported any more because GetBitmap(m_node) can be used directly + // instead + wxASSERT_MSG( !param.empty(), "bitmap parameter name can't be empty" ); + + const wxXmlNode* const node = GetParamNode(param); + + if ( !node ) + { + // this is not an error as bitmap parameter could be optional + return wxNullBitmap; + } + + return GetBitmap(node, defaultArtClient, size); } wxBitmap wxXmlResourceHandler::GetBitmap(const wxXmlNode* node, const wxArtClient& defaultArtClient, wxSize size) { + wxCHECK_MSG( node, wxNullBitmap, "bitmap node can't be NULL" ); + /* If the bitmap is specified as stock item, query wxArtProvider for it: */ wxString art_id, art_client; if ( GetStockArtAttrs(node, defaultArtClient, @@ -1389,7 +1405,18 @@ wxIcon wxXmlResourceHandler::GetIcon(const wxString& param, const wxArtClient& defaultArtClient, wxSize size) { - return GetIcon(GetParamNode(param), defaultArtClient, size); + // see comment in GetBitmap(wxString) overload + wxASSERT_MSG( !param.empty(), "icon parameter name can't be empty" ); + + const wxXmlNode* const node = GetParamNode(param); + + if ( !node ) + { + // this is not an error as icon parameter could be optional + return wxIcon(); + } + + return GetIcon(node, defaultArtClient, size); } wxIcon wxXmlResourceHandler::GetIcon(const wxXmlNode* node, @@ -1823,8 +1850,12 @@ void wxXmlResourceHandler::SetupWindow(wxWindow *wnd) wnd->SetExtraStyle(wnd->GetExtraStyle() | GetStyle(wxT("exstyle"))); if (HasParam(wxT("bg"))) wnd->SetBackgroundColour(GetColour(wxT("bg"))); + if (HasParam(wxT("ownbg"))) + wnd->SetOwnBackgroundColour(GetColour(wxT("ownbg"))); if (HasParam(wxT("fg"))) wnd->SetForegroundColour(GetColour(wxT("fg"))); + if (HasParam(wxT("ownfg"))) + wnd->SetOwnForegroundColour(GetColour(wxT("ownfg"))); if (GetBool(wxT("enabled"), 1) == 0) wnd->Enable(false); if (GetBool(wxT("focused"), 0) == 1) @@ -1836,7 +1867,9 @@ void wxXmlResourceHandler::SetupWindow(wxWindow *wnd) wnd->SetToolTip(GetText(wxT("tooltip"))); #endif if (HasParam(wxT("font"))) - wnd->SetFont(GetFont()); + wnd->SetFont(GetFont(wxT("font"))); + if (HasParam(wxT("ownfont"))) + wnd->SetOwnFont(GetFont(wxT("ownfont"))); if (HasParam(wxT("help"))) wnd->SetHelpText(GetText(wxT("help"))); }