X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3721dc6efe6f9ffe550c4c83bee2da210043bcaa..3d777efedc1e05bd6c2a7c34a00a65895b62bb13:/src/osx/cocoa/colour.mm diff --git a/src/osx/cocoa/colour.mm b/src/osx/cocoa/colour.mm index 55a305d29f..73df7fbf01 100644 --- a/src/osx/cocoa/colour.mm +++ b/src/osx/cocoa/colour.mm @@ -4,7 +4,6 @@ // Author: Kevin Ollivier // Modified by: // Created: 2009-10-31 -// RCS-ID: $Id: colour.cpp 61724 2009-08-21 10:41:26Z VZ $ // Copyright: (c) Kevin Ollivier // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -23,17 +22,24 @@ wxColour::wxColour(WX_NSColor col) { size_t noComp = [col numberOfComponents]; - CGFloat *components = NULL; - if ( noComp >= 1 && noComp <= 4 ) + CGFloat components[4]; + CGFloat *p; + if ( noComp < 1 || noComp > WXSIZEOF(components) ) { // TODO verify whether we really are on a RGB color space m_alpha = wxALPHA_OPAQUE; [col getComponents: components]; + p = components; } - InitFromComponents(const_cast(components), noComp); + else // Unsupported colour format. + { + p = NULL; + } + + InitFromComponents(components, noComp); } -WX_NSColor wxColour::OSXGetNSColor() +WX_NSColor wxColour::OSXGetNSColor() const { - return [NSColor colorWithDeviceRed:m_red / 255.0 green:m_green / 255.0 blue:m_blue / 255.0 alpha:m_alpha / 255.0]; + return [NSColor colorWithCalibratedRed:m_red / 255.0 green:m_green / 255.0 blue:m_blue / 255.0 alpha:m_alpha / 255.0]; }