Use wxColour::OSXGetNSColor() instead of reproducing it

No real changes, just simplify wxOSX code by using the existing
wxColour::OSXGetNSColor() method instead of reproducing it in many places.
This commit is contained in:
Vadim Zeitlin 2015-11-26 23:54:28 +01:00
parent 200f24301c
commit bcd16394df
5 changed files with 7 additions and 35 deletions

View File

@ -107,12 +107,7 @@ bool wxColourDialog::Create(wxWindow *parent, wxColourData *data)
[[NSColorPanel sharedColorPanel] setShowsAlpha:YES];
if(m_colourData.GetColour().IsOk())
[[NSColorPanel sharedColorPanel] setColor:
[NSColor colorWithCalibratedRed:(CGFloat) (m_colourData.GetColour().Red() / 255.0)
green:(CGFloat) (m_colourData.GetColour().Green() / 255.0)
blue:(CGFloat) (m_colourData.GetColour().Blue() / 255.0)
alpha:(CGFloat) (m_colourData.GetColour().Alpha() / 255.0)]
];
[[NSColorPanel sharedColorPanel] setColor:m_colourData.GetColour().OSXGetNSColor()];
else
[[NSColorPanel sharedColorPanel] setColor:[NSColor blackColor]];

View File

@ -184,12 +184,7 @@ int RunMixedFontDialog(wxFontDialog* dialog)
[[NSFontPanel sharedFontPanel] setPanelFont: font.OSXGetNSFont() isMultiple:NO];
if(fontdata.m_fontColour.IsOk())
[[NSColorPanel sharedColorPanel] setColor:
[NSColor colorWithCalibratedRed:fontdata.m_fontColour.Red() / 255.0
green:fontdata.m_fontColour.Green() / 255.0
blue:fontdata.m_fontColour.Blue() / 255.0
alpha:1.0]
];
[[NSColorPanel sharedColorPanel] setColor: fontdata.m_fontColour.OSXGetNSColor()];
else
[[NSColorPanel sharedColorPanel] setColor:[NSColor blackColor]];
#endif
@ -418,12 +413,7 @@ bool wxFontDialog::Create(wxWindow *parent)
}
if(m_fontData.m_fontColour.IsOk())
[[NSColorPanel sharedColorPanel] setColor:
[NSColor colorWithCalibratedRed:m_fontData.m_fontColour.Red() / 255.0
green:m_fontData.m_fontColour.Green() / 255.0
blue:m_fontData.m_fontColour.Blue() / 255.0
alpha:1.0]
];
[[NSColorPanel sharedColorPanel] setColor: fontdata.m_fontColour.OSXGetNSColor()];
else
[[NSColorPanel sharedColorPanel] setColor:[NSColor blackColor]];

View File

@ -2729,11 +2729,7 @@ void wxDataViewRenderer::SetAttr(const wxDataViewItemAttr& attr)
data->SaveOriginalTextColour([(id)cell textColor]);
}
const wxColour& c = attr.GetColour();
colText = [NSColor colorWithCalibratedRed:c.Red() / 255.
green:c.Green() / 255.
blue:c.Blue() / 255.
alpha:c.Alpha() / 255.];
colText = attr.GetColour().OSXGetNSColor();
}
}

View File

@ -839,10 +839,7 @@ bool wxNonOwnedWindowCocoaImpl::SetTransparent(wxByte alpha)
bool wxNonOwnedWindowCocoaImpl::SetBackgroundColour(const wxColour& col )
{
[m_macWindow setBackgroundColor:[NSColor colorWithCalibratedRed:(CGFloat) (col.Red() / 255.0)
green:(CGFloat) (col.Green() / 255.0)
blue:(CGFloat) (col.Blue() / 255.0)
alpha:(CGFloat) (col.Alpha() / 255.0)]];
[m_macWindow setBackgroundColor:col.OSXGetNSColor()];
return true;
}

View File

@ -2402,10 +2402,7 @@ void wxWidgetCocoaImpl::SetBackgroundColour( const wxColour &col )
if ( [targetView respondsToSelector:@selector(setBackgroundColor:) ] )
{
[targetView setBackgroundColor:[NSColor colorWithCalibratedRed:(CGFloat) (col.Red() / 255.0)
green:(CGFloat) (col.Green() / 255.0)
blue:(CGFloat) (col.Blue() / 255.0)
alpha:(CGFloat) (col.Alpha() / 255.0)]];
[targetView setBackgroundColor: col.OSXGetNSColor()];
}
}
@ -2668,10 +2665,7 @@ void wxWidgetCocoaImpl::SetFont(wxFont const& font, wxColour const&col, long, bo
if ([targetView respondsToSelector:@selector(setFont:)])
[targetView setFont: font.OSXGetNSFont()];
if ([targetView respondsToSelector:@selector(setTextColor:)])
[targetView setTextColor:[NSColor colorWithCalibratedRed:(CGFloat) (col.Red() / 255.0)
green:(CGFloat) (col.Green() / 255.0)
blue:(CGFloat) (col.Blue() / 255.0)
alpha:(CGFloat) (col.Alpha() / 255.0)]];
[targetView setTextColor: col.OSXGetNSColor()];
}
void wxWidgetCocoaImpl::SetToolTip(wxToolTip* tooltip)