9990959c99
This method was confusing and dangerous as it didn't actually initialize the wxColour object because it didn't set its m_cgColour and so attempting to use wxColour "initialized" using this method resulted in a crash whenever its GetPixel(), GetCGColor() or CreateCGColor() methods were called. Just merge this function with InitCGColorRef() which is the only remaining place where it's used after rewriting wxColour(NSColor) ctor.
89 lines
2.5 KiB
C++
89 lines
2.5 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: wx/osx/core/colour.h
|
|
// Purpose: wxColour class
|
|
// Author: Stefan Csomor
|
|
// Modified by:
|
|
// Created: 1998-01-01
|
|
// Copyright: (c) Stefan Csomor
|
|
// Licence: wxWindows licence
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef _WX_COLOUR_H_
|
|
#define _WX_COLOUR_H_
|
|
|
|
#include "wx/object.h"
|
|
#include "wx/string.h"
|
|
|
|
#include "wx/osx/core/cfref.h"
|
|
|
|
struct RGBColor;
|
|
|
|
// Colour
|
|
class WXDLLIMPEXP_CORE wxColour: public wxColourBase
|
|
{
|
|
public:
|
|
// constructors
|
|
// ------------
|
|
DEFINE_STD_WXCOLOUR_CONSTRUCTORS
|
|
|
|
// default copy ctor and dtor are ok
|
|
|
|
// accessors
|
|
virtual bool IsOk() const { return m_cgColour != NULL; }
|
|
|
|
virtual WXDLLIMPEXP_INLINE_CORE ChannelType Red() const { return m_red; }
|
|
virtual WXDLLIMPEXP_INLINE_CORE ChannelType Green() const { return m_green; }
|
|
virtual WXDLLIMPEXP_INLINE_CORE ChannelType Blue() const { return m_blue; }
|
|
virtual WXDLLIMPEXP_INLINE_CORE ChannelType Alpha() const { return m_alpha; }
|
|
|
|
// comparison
|
|
bool operator == (const wxColour& colour) const;
|
|
|
|
bool operator != (const wxColour& colour) const { return !(*this == colour); }
|
|
|
|
CGColorRef GetPixel() const { return m_cgColour; }
|
|
|
|
CGColorRef GetCGColor() const { return m_cgColour; }
|
|
CGColorRef CreateCGColor() const { return wxCFRetain( (CGColorRef)m_cgColour ); }
|
|
|
|
#if wxOSX_USE_COCOA_OR_CARBON
|
|
void GetRGBColor( RGBColor *col ) const;
|
|
#endif
|
|
|
|
// Mac-specific ctor and assignment operator from the native colour
|
|
// assumes ownership of CGColorRef
|
|
wxColour( CGColorRef col );
|
|
#if wxOSX_USE_COCOA_OR_CARBON
|
|
wxColour(const RGBColor& col);
|
|
wxColour& operator=(const RGBColor& col);
|
|
#endif
|
|
#if wxOSX_USE_COCOA
|
|
// This ctor does not take ownership of the color.
|
|
explicit wxColour(WX_NSColor color);
|
|
WX_NSColor OSXGetNSColor() const;
|
|
#endif
|
|
wxColour& operator=(CGColorRef col);
|
|
wxColour& operator=(const wxColour& col);
|
|
|
|
protected :
|
|
virtual void
|
|
InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a);
|
|
#if wxOSX_USE_COCOA_OR_CARBON
|
|
void InitRGBColor( const RGBColor& col );
|
|
#endif
|
|
void InitCGColorRef( CGColorRef col );
|
|
|
|
private:
|
|
wxCFRef<CGColorRef> m_cgColour;
|
|
|
|
ChannelType m_red;
|
|
ChannelType m_blue;
|
|
ChannelType m_green;
|
|
ChannelType m_alpha;
|
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxColour);
|
|
};
|
|
|
|
#endif
|
|
// _WX_COLOUR_H_
|