X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b478f242888560d1cb0d397bd70a9e47a640d394..ab67e8874db324fab5223cc8d5dff8a8de3e2b77:/src/osx/cocoa/colour.mm?ds=sidebyside diff --git a/src/osx/cocoa/colour.mm b/src/osx/cocoa/colour.mm index ffce54a794..ac622553e4 100644 --- a/src/osx/cocoa/colour.mm +++ b/src/osx/cocoa/colour.mm @@ -4,7 +4,7 @@ // Author: Kevin Ollivier // Modified by: // Created: 2009-10-31 -// RCS-ID: $Id: colour.cpp 61724 2009-08-21 10:41:26Z VZ $ +// RCS-ID: $Id$ // Copyright: (c) Kevin Ollivier // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -19,18 +19,28 @@ #include "wx/osx/private.h" -#if wxOSX_USE_COCOA 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; + } + else // Unsupported colour format. + { + p = NULL; } - InitFromComponents(const_cast(components), noComp); + + InitFromComponents(components, noComp); +} + +WX_NSColor wxColour::OSXGetNSColor() const +{ + return [NSColor colorWithCalibratedRed:m_red / 255.0 green:m_green / 255.0 blue:m_blue / 255.0 alpha:m_alpha / 255.0]; } -#endif \ No newline at end of file