Respect item font when rendering markup (wxOSX)

Respect per-item attributes and namely the font (which may differ from
the control's font) when rendering markup items in wxDataViewCtrl.
This commit is contained in:
Václav Slavík
2016-10-19 16:55:59 +02:00
committed by Václav Slavík
parent 58fc33d7c2
commit 5e5ffad0b8
4 changed files with 6 additions and 6 deletions

View File

@@ -22,8 +22,8 @@ public:
// We don't care about the original colours because we never use them but // We don't care about the original colours because we never use them but
// we do need the correct initial font as we apply modifiers (e.g. create a // we do need the correct initial font as we apply modifiers (e.g. create a
// font larger than it) to it and so it must be valid. // font larger than it) to it and so it must be valid.
wxMarkupToAttrString(wxWindow *win, const wxString& markup) wxMarkupToAttrString(const wxFont& font, const wxString& markup)
: wxMarkupParserAttrOutput(win->GetFont(), wxColour(), wxColour()) : wxMarkupParserAttrOutput(font, wxColour(), wxColour())
{ {
const wxCFStringRef const wxCFStringRef
label(wxControl::RemoveMnemonics(wxMarkupParser::Strip(markup))); label(wxControl::RemoveMnemonics(wxMarkupParser::Strip(markup)));
@@ -39,7 +39,7 @@ public:
// default which is different from the system "Lucida Grande" font. So // default which is different from the system "Lucida Grande" font. So
// we need to explicitly change the font for the entire string. // we need to explicitly change the font for the entire string.
[m_attrString addAttribute:NSFontAttributeName [m_attrString addAttribute:NSFontAttributeName
value:win->GetFont().OSXGetNSFont() value:font.OSXGetNSFont()
range:NSMakeRange(0, [m_attrString length])]; range:NSMakeRange(0, [m_attrString length])];
// Now translate the markup tags to corresponding attributes. // Now translate the markup tags to corresponding attributes.

View File

@@ -107,7 +107,7 @@ void wxButtonCocoaImpl::SetBitmap(const wxBitmap& bitmap)
#if wxUSE_MARKUP #if wxUSE_MARKUP
void wxButtonCocoaImpl::SetLabelMarkup(const wxString& markup) void wxButtonCocoaImpl::SetLabelMarkup(const wxString& markup)
{ {
wxMarkupToAttrString toAttr(GetWXPeer(), markup); wxMarkupToAttrString toAttr(GetWXPeer()->GetFont(), markup);
NSMutableAttributedString *attrString = toAttr.GetNSAttributedString(); NSMutableAttributedString *attrString = toAttr.GetNSAttributedString();
// Button text is always centered. // Button text is always centered.

View File

@@ -2829,7 +2829,7 @@ bool wxDataViewTextRenderer::MacRender()
#if wxUSE_MARKUP #if wxUSE_MARKUP
if ( m_useMarkup ) if ( m_useMarkup )
{ {
wxMarkupToAttrString toAttr(GetView(), GetValue().GetString()); wxMarkupToAttrString toAttr(wxFont([cell font]), GetValue().GetString());
NSMutableAttributedString *str = toAttr.GetNSAttributedString(); NSMutableAttributedString *str = toAttr.GetNSAttributedString();
if ( [cell lineBreakMode] != NSLineBreakByClipping ) if ( [cell lineBreakMode] != NSLineBreakByClipping )

View File

@@ -104,7 +104,7 @@ public:
#if wxUSE_MARKUP #if wxUSE_MARKUP
virtual void SetLabelMarkup( const wxString& markup) wxOVERRIDE virtual void SetLabelMarkup( const wxString& markup) wxOVERRIDE
{ {
wxMarkupToAttrString toAttr(GetWXPeer(), markup); wxMarkupToAttrString toAttr(GetWXPeer()->GetFont(), markup);
DoSetAttrString(toAttr.GetNSAttributedString()); DoSetAttrString(toAttr.GetNSAttributedString());
} }