Merge branch 'osx-set-color-without-font'
Set colour without changing font in wxOSX. See https://github.com/wxWidgets/wxWidgets/pull/2278
This commit is contained in:
@@ -101,6 +101,7 @@ public :
|
||||
|
||||
virtual void SetBackgroundColour(const wxColour&) wxOVERRIDE;
|
||||
virtual bool SetBackgroundStyle(wxBackgroundStyle style) wxOVERRIDE;
|
||||
virtual void SetForegroundColour(const wxColour& col) wxOVERRIDE;
|
||||
|
||||
virtual void GetContentArea( int &left, int &top, int &width, int &height ) const wxOVERRIDE;
|
||||
virtual void Move(int x, int y, int width, int height) wxOVERRIDE;
|
||||
@@ -241,6 +242,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
|
||||
|
@@ -276,6 +276,7 @@ public :
|
||||
|
||||
virtual void SetBackgroundColour( const wxColour& col ) = 0;
|
||||
virtual bool SetBackgroundStyle(wxBackgroundStyle style) = 0;
|
||||
virtual void SetForegroundColour( const wxColour& col ) = 0;
|
||||
|
||||
// all coordinates in native parent widget relative coordinates
|
||||
virtual void GetContentArea( int &left , int &top , int &width , int &height ) const = 0;
|
||||
|
@@ -56,6 +56,7 @@ public :
|
||||
|
||||
virtual void SetBackgroundColour( const wxColour& col ) ;
|
||||
virtual bool SetBackgroundStyle(wxBackgroundStyle style) ;
|
||||
virtual void SetForegroundColour( const wxColour& col ) ;
|
||||
|
||||
virtual void GetContentArea( int &left , int &top , int &width , int &height ) const;
|
||||
virtual void Move(int x, int y, int width, int height);
|
||||
|
@@ -342,7 +342,6 @@ protected:
|
||||
bool MacHasScrollBarCorner() const;
|
||||
void MacCreateScrollBars( long style ) ;
|
||||
void MacRepositionScrollBars() ;
|
||||
void MacUpdateControlFont() ;
|
||||
|
||||
// implement the base class pure virtuals
|
||||
virtual void DoGetTextExtent(const wxString& string,
|
||||
|
@@ -3578,23 +3578,35 @@ 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()];
|
||||
if ([m_osxView respondsToSelector:@selector(setAttributedTitle:)])
|
||||
SetLabel(wxStripMenuCodes(GetWXPeer()->GetLabel(), wxStrip_Mnemonics), GetWXPeer()->GetFont().GetEncoding());
|
||||
}
|
||||
|
||||
void wxWidgetCocoaImpl::SetForegroundColour(const wxColour& col)
|
||||
{
|
||||
NSView* const targetView = GetViewWithText();
|
||||
|
||||
if ([targetView respondsToSelector:@selector(setTextColor:)])
|
||||
{
|
||||
wxColor col = GetWXPeer()->GetForegroundColour();
|
||||
[targetView setTextColor: col.OSXGetNSColor()];
|
||||
}
|
||||
if ([m_osxView respondsToSelector:@selector(setAttributedTitle:)])
|
||||
SetLabel(wxStripMenuCodes(GetWXPeer()->GetLabel(), wxStrip_Mnemonics), GetWXPeer()->GetFont().GetEncoding());
|
||||
}
|
||||
|
||||
void wxWidgetCocoaImpl::SetToolTip(wxToolTip* tooltip)
|
||||
|
@@ -421,6 +421,11 @@ void wxWidgetIPhoneImpl::SetBackgroundColour( const wxColour &col )
|
||||
m_osxView.backgroundColor = [UIColor colorWithCGColor:col.GetCGColor()];
|
||||
}
|
||||
|
||||
void wxWidgetIPhoneImpl::SetForegroundColour( const wxColour &col )
|
||||
{
|
||||
// TODO: use textColor if available?
|
||||
}
|
||||
|
||||
bool wxWidgetIPhoneImpl::SetBackgroundStyle(wxBackgroundStyle style)
|
||||
{
|
||||
if ( style == wxBG_STYLE_PAINT )
|
||||
|
@@ -504,33 +504,32 @@ void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant )
|
||||
}
|
||||
}
|
||||
|
||||
void wxWindowMac::MacUpdateControlFont()
|
||||
{
|
||||
if ( GetPeer() )
|
||||
GetPeer()->SetFont(GetFont()) ;
|
||||
|
||||
// do not trigger refreshes upon invisible and possible partly created objects
|
||||
if ( IsShownOnScreen() )
|
||||
Refresh() ;
|
||||
}
|
||||
|
||||
bool wxWindowMac::SetFont(const wxFont& font)
|
||||
{
|
||||
bool retval = wxWindowBase::SetFont( font );
|
||||
|
||||
MacUpdateControlFont() ;
|
||||
if (retval)
|
||||
{
|
||||
if ( GetPeer() )
|
||||
GetPeer()->SetFont(GetFont()) ;
|
||||
|
||||
// do not trigger refreshes upon invisible and possible partly created objects
|
||||
if ( IsShownOnScreen() )
|
||||
Refresh() ;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool wxWindowMac::SetForegroundColour(const wxColour& col )
|
||||
{
|
||||
bool retval = wxWindowBase::SetForegroundColour( col );
|
||||
if ( !wxWindowBase::SetForegroundColour( col ) )
|
||||
return false;
|
||||
|
||||
if (retval)
|
||||
MacUpdateControlFont();
|
||||
if ( GetPeer() )
|
||||
GetPeer()->SetForegroundColour(col);
|
||||
|
||||
return retval;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxWindowMac::SetBackgroundStyle(wxBackgroundStyle style)
|
||||
|
Reference in New Issue
Block a user