Fix setting foreground color for several controls in wxOSX
This allows setting color of wxStaticBox, wxCheckBox, wxRadioButton and any other controls that use NSBox and NSButton to work. Closes #16284. Closes https://github.com/wxWidgets/wxWidgets/pull/489
This commit is contained in:
committed by
Vadim Zeitlin
parent
a0f9ab3e6d
commit
31ba2d4ca3
@@ -199,6 +199,7 @@ wxMSW:
|
||||
wxOSX:
|
||||
|
||||
- Fix handling of non-BMP characters in GetPartialTextExtents() (ARATA Mizuki).
|
||||
- Fix setting foreground colour for several controls (Steve Browne).
|
||||
- Fix dialogs using wxFRAME_FLOAT_ON_PARENT frame as parent (Lauri Nurmi).
|
||||
- Implement wxGetDisplaySizeMM() and fix printing DPI (David Vanderson).
|
||||
- Remove extra borders around wxFilePickerCtrl (John Roberts).
|
||||
|
@@ -2447,7 +2447,8 @@ void wxWidgetCocoaImpl::SetLabel( const wxString& title, wxFontEncoding encoding
|
||||
if ( [m_osxView respondsToSelector:@selector(setAttributedTitle:) ] )
|
||||
{
|
||||
wxFont f = GetWXPeer()->GetFont();
|
||||
if ( f.GetStrikethrough() || f.GetUnderlined() )
|
||||
wxColour col = GetWXPeer()->GetForegroundColour();
|
||||
if ( f.GetStrikethrough() || f.GetUnderlined() || col.IsOk() )
|
||||
{
|
||||
wxCFStringRef cf(title, encoding );
|
||||
|
||||
@@ -2476,6 +2477,13 @@ void wxWidgetCocoaImpl::SetLabel( const wxString& title, wxFontEncoding encoding
|
||||
|
||||
}
|
||||
|
||||
if ( col.IsOk() )
|
||||
{
|
||||
[attrString addAttribute:NSForegroundColorAttributeName
|
||||
value:col.OSXGetNSColor()
|
||||
range:NSMakeRange(0, [attrString length])];
|
||||
}
|
||||
|
||||
[attrString endEditing];
|
||||
|
||||
[(id)m_osxView setAttributedTitle:attrString];
|
||||
@@ -2727,11 +2735,15 @@ void wxWidgetCocoaImpl::SetFont(wxFont const& font, wxColour const&col, long, bo
|
||||
NSView* targetView = m_osxView;
|
||||
if ( [m_osxView isKindOfClass:[NSScrollView class] ] )
|
||||
targetView = [(NSScrollView*) m_osxView documentView];
|
||||
else if ( [m_osxView isKindOfClass:[NSBox class] ] )
|
||||
targetView = [(NSBox*) m_osxView titleCell];
|
||||
|
||||
if ([targetView respondsToSelector:@selector(setFont:)])
|
||||
[targetView setFont: font.OSXGetNSFont()];
|
||||
if ([targetView respondsToSelector:@selector(setTextColor:)])
|
||||
[targetView setTextColor: col.OSXGetNSColor()];
|
||||
if ([m_osxView respondsToSelector:@selector(setAttributedTitle:)])
|
||||
SetLabel(wxStripMenuCodes(GetWXPeer()->GetLabel(), wxStrip_Mnemonics), GetWXPeer()->GetFont().GetEncoding());
|
||||
}
|
||||
|
||||
void wxWidgetCocoaImpl::SetToolTip(wxToolTip* tooltip)
|
||||
|
Reference in New Issue
Block a user