]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/colour.h
forcefully disable wxUSE_STACKWALKER
[wxWidgets.git] / include / wx / cocoa / colour.h
CommitLineData
a24aff65
DE
1/////////////////////////////////////////////////////////////////////////////
2// Name: colour.h
3// Purpose: wxColour class
683b185d 4// Author: David Elliott
a24aff65 5// Modified by:
683b185d 6// Created: 2003/06/17
a24aff65 7// RCS-ID: $Id$
683b185d 8// Copyright: (c) 2003 David Elliott
65571936 9// Licence: wxWindows licence
a24aff65
DE
10/////////////////////////////////////////////////////////////////////////////
11
683b185d
DE
12#ifndef __WX_COCOA_COLOUR_H__
13#define __WX_COCOA_COLOUR_H__
a24aff65
DE
14
15#include "wx/object.h"
16#include "wx/string.h"
17
683b185d
DE
18// ========================================================================
19// wxColour
20// ========================================================================
a24aff65
DE
21class WXDLLEXPORT wxColour: public wxObject
22{
23public:
211436b6
VZ
24 wxColour() { Init(); }
25
a24aff65 26 // from RGB
683b185d
DE
27 wxColour( unsigned char red, unsigned char green, unsigned char blue )
28 : m_cocoaNSColor(NULL)
29 { Set(red,green,blue); }
30 wxColour( unsigned long colRGB )
31 : m_cocoaNSColor(NULL)
32 { Set(colRGB); }
aad6765c 33
d8fdd58f
DE
34 // initialization using existing NSColor
35 wxColour( WX_NSColor aColor );
36
a24aff65 37 // implicit conversion from the colour name
683b185d 38 wxColour( const wxString &colourName )
683b185d
DE
39 { InitFromName(colourName); }
40 wxColour( const char *colourName )
683b185d 41 { InitFromName(wxString::FromAscii(colourName)); }
c58ae5f2
RN
42#if wxUSE_UNICODE
43 wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); }
44#endif
a24aff65
DE
45
46 // copy ctors and assignment operators
683b185d
DE
47 wxColour( const wxColour& col );
48 wxColour& operator = ( const wxColour& col );
a24aff65 49
211436b6 50 virtual ~wxColour();
a24aff65 51
683b185d
DE
52 // accessors
53 bool Ok() const { return m_cocoaNSColor; }
211436b6 54 WX_NSColor GetNSColor() { return m_cocoaNSColor; }
a24aff65 55
683b185d
DE
56 unsigned char Red() const { return m_red; }
57 unsigned char Green() const { return m_green; }
58 unsigned char Blue() const { return m_blue; }
a24aff65 59
683b185d
DE
60 // comparison
61 bool operator == (const wxColour& colour) const
62 {
d8fdd58f 63 // TODO: Really compare the NSColor
aad6765c 64 return (m_cocoaNSColor == colour.m_cocoaNSColor
d8fdd58f 65 || (m_red == colour.m_red
aad6765c 66 && m_green == colour.m_green
d8fdd58f 67 && m_blue == colour.m_blue));
683b185d
DE
68 }
69 bool operator != (const wxColour& colour) const
70 { return !(*this == colour); }
a24aff65 71
683b185d
DE
72 // Set() functions
73 void Set( unsigned char red, unsigned char green, unsigned char blue );
74 void Set( unsigned long colRGB )
75 {
76 // we don't need to know sizeof(long) here because we assume that the three
77 // least significant bytes contain the R, G and B values
78 Set((unsigned char)colRGB,
79 (unsigned char)(colRGB >> 8),
80 (unsigned char)(colRGB >> 16));
81 }
d8fdd58f 82 void Set( WX_NSColor aColor );
a24aff65 83
211436b6
VZ
84protected:
85 // puts the object in an invalid, uninitialized state
86 void Init();
87
88 // create the object from name, leaves it uninitialized if it failed
683b185d 89 void InitFromName(const wxString& col);
a24aff65
DE
90
91private:
683b185d
DE
92 WX_NSColor m_cocoaNSColor;
93 unsigned char m_red;
94 unsigned char m_green;
95 unsigned char m_blue;
211436b6
VZ
96
97 DECLARE_DYNAMIC_CLASS(wxColour)
a24aff65
DE
98};
99
683b185d 100#endif // __WX_COCOA_COLOUR_H__