Factor out wxWidgetCocoaImpl::GetViewWithText()

Extract this function from wxWidgetCocoaImpl::SetFont() to allow its
reuse.

No changes, this is a pure refactoring.
This commit is contained in:
Vadim Zeitlin
2021-03-13 23:01:21 +01:00
parent f6194cb797
commit ede4ff9490
2 changed files with 15 additions and 5 deletions

View File

@@ -241,6 +241,10 @@ protected:
// was the wx event for the current native key down event sent
bool WasKeyDownSent() const;
// Return the view to apply the font/colour to.
NSView* GetViewWithText() const;
NSEvent* m_lastKeyDownEvent;
bool m_lastKeyDownWXSent;
#if !wxOSX_USE_NATIVE_FLIPPED

View File

@@ -3543,13 +3543,19 @@ void wxWidgetCocoaImpl::SetControlSize( wxWindowVariant variant )
}
}
NSView* wxWidgetCocoaImpl::GetViewWithText() const
{
if ( [m_osxView isKindOfClass:[NSScrollView class] ] )
return [(NSScrollView*) m_osxView documentView];
else if ( [m_osxView isKindOfClass:[NSBox class] ] )
return [(NSBox*) m_osxView titleCell];
return m_osxView;
}
void wxWidgetCocoaImpl::SetFont(wxFont const& font)
{
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];
NSView* const targetView = GetViewWithText();
if ([targetView respondsToSelector:@selector(setFont:)])
[targetView setFont: font.OSXGetNSFont()];