1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxColour class
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef __WX_COCOA_COLOUR_H__
13 #define __WX_COCOA_COLOUR_H__
15 #include "wx/object.h"
16 #include "wx/string.h"
18 // ========================================================================
20 // ========================================================================
21 class WXDLLEXPORT wxColour
: public wxObject
24 DECLARE_DYNAMIC_CLASS(wxColour
)
25 // ------------------------------------------------------------------------
27 // ------------------------------------------------------------------------
30 wxColour( unsigned char red
, unsigned char green
, unsigned char blue
)
31 : m_cocoaNSColor(NULL
)
32 { Set(red
,green
,blue
); }
33 wxColour( unsigned long colRGB
)
34 : m_cocoaNSColor(NULL
)
37 // implicit conversion from the colour name
38 wxColour( const wxString
&colourName
)
39 : m_cocoaNSColor(NULL
)
40 { InitFromName(colourName
); }
41 wxColour( const char *colourName
)
42 : m_cocoaNSColor(NULL
)
43 { InitFromName(wxString::FromAscii(colourName
)); }
45 // copy ctors and assignment operators
46 wxColour( const wxColour
& col
);
47 wxColour
& operator = ( const wxColour
& col
);
51 // ------------------------------------------------------------------------
53 // ------------------------------------------------------------------------
55 bool Ok() const { return m_cocoaNSColor
; }
57 unsigned char Red() const { return m_red
; }
58 unsigned char Green() const { return m_green
; }
59 unsigned char Blue() const { return m_blue
; }
62 bool operator == (const wxColour
& colour
) const
64 return (m_cocoaNSColor
== colour
.m_cocoaNSColor
&&
65 m_red
== colour
.m_red
&&
66 m_green
== colour
.m_green
&&
67 m_blue
== colour
.m_blue
);
69 bool operator != (const wxColour
& colour
) const
70 { return !(*this == colour
); }
72 // const WXCOLORREF& GetPixel() const { return m_pixel; };
75 void Set( unsigned char red
, unsigned char green
, unsigned char blue
);
76 void Set( unsigned long colRGB
)
78 // we don't need to know sizeof(long) here because we assume that the three
79 // least significant bytes contain the R, G and B values
80 Set((unsigned char)colRGB
,
81 (unsigned char)(colRGB
>> 8),
82 (unsigned char)(colRGB
>> 16));
86 void InitFromName(const wxString
& col
);
89 WX_NSColor m_cocoaNSColor
;
91 unsigned char m_green
;
95 #endif // __WX_COCOA_COLOUR_H__