Add "inherit" to <font> XRC tag.
This allows to construct a font based on the parent window font instead of either fully specifying all font parameters or basing it on a standard font. Closes #14632. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72572 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2201,7 +2201,7 @@ static wxFont GetSystemFont(const wxString& name)
|
||||
return wxNullFont;
|
||||
}
|
||||
|
||||
wxFont wxXmlResourceHandler::GetFont(const wxString& param)
|
||||
wxFont wxXmlResourceHandler::GetFont(const wxString& param, wxWindow* parent)
|
||||
{
|
||||
wxXmlNode *font_node = GetParamNode(param);
|
||||
if (font_node == NULL)
|
||||
@@ -2304,8 +2304,21 @@ wxFont wxXmlResourceHandler::GetFont(const wxString& param)
|
||||
}
|
||||
#endif // wxUSE_FONTMAP
|
||||
|
||||
wxFont font;
|
||||
|
||||
// is this font based on a system font?
|
||||
wxFont font = GetSystemFont(GetParamValue(wxT("sysfont")));
|
||||
if (HasParam(wxT("sysfont")))
|
||||
{
|
||||
font = GetSystemFont(GetParamValue(wxT("sysfont")));
|
||||
}
|
||||
// or should the font of the widget be used?
|
||||
else if (GetBool(wxT("inherit"), false))
|
||||
{
|
||||
if (parent)
|
||||
font = parent->GetFont();
|
||||
else
|
||||
ReportError("no parent window specified to derive the font from");
|
||||
}
|
||||
|
||||
if (font.IsOk())
|
||||
{
|
||||
@@ -2368,9 +2381,9 @@ void wxXmlResourceHandler::SetupWindow(wxWindow *wnd)
|
||||
wnd->SetToolTip(GetText(wxT("tooltip")));
|
||||
#endif
|
||||
if (HasParam(wxT("font")))
|
||||
wnd->SetFont(GetFont(wxT("font")));
|
||||
wnd->SetFont(GetFont(wxT("font"), wnd));
|
||||
if (HasParam(wxT("ownfont")))
|
||||
wnd->SetOwnFont(GetFont(wxT("ownfont")));
|
||||
wnd->SetOwnFont(GetFont(wxT("ownfont"), wnd));
|
||||
if (HasParam(wxT("help")))
|
||||
wnd->SetHelpText(GetText(wxT("help")));
|
||||
}
|
||||
|
Reference in New Issue
Block a user