]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/colour.h
Get rid of wxUSE_GSOCKET_CPLUSPLUS
[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
a24aff65 34 // implicit conversion from the colour name
683b185d 35 wxColour( const wxString &colourName )
683b185d
DE
36 { InitFromName(colourName); }
37 wxColour( const char *colourName )
683b185d 38 { InitFromName(wxString::FromAscii(colourName)); }
a24aff65
DE
39
40 // copy ctors and assignment operators
683b185d
DE
41 wxColour( const wxColour& col );
42 wxColour& operator = ( const wxColour& col );
a24aff65 43
211436b6 44 virtual ~wxColour();
a24aff65 45
683b185d
DE
46 // accessors
47 bool Ok() const { return m_cocoaNSColor; }
211436b6 48 WX_NSColor GetNSColor() { return m_cocoaNSColor; }
a24aff65 49
683b185d
DE
50 unsigned char Red() const { return m_red; }
51 unsigned char Green() const { return m_green; }
52 unsigned char Blue() const { return m_blue; }
a24aff65 53
683b185d
DE
54 // comparison
55 bool operator == (const wxColour& colour) const
56 {
211436b6 57 // VZ: sure we want to compare NSColor objects for equality here?
aad6765c
JS
58 return (m_cocoaNSColor == colour.m_cocoaNSColor
59 && m_red == colour.m_red
60 && m_green == colour.m_green
61 && m_blue == colour.m_blue);
683b185d
DE
62 }
63 bool operator != (const wxColour& colour) const
64 { return !(*this == colour); }
a24aff65 65
683b185d
DE
66 // Set() functions
67 void Set( unsigned char red, unsigned char green, unsigned char blue );
68 void Set( unsigned long colRGB )
69 {
70 // we don't need to know sizeof(long) here because we assume that the three
71 // least significant bytes contain the R, G and B values
72 Set((unsigned char)colRGB,
73 (unsigned char)(colRGB >> 8),
74 (unsigned char)(colRGB >> 16));
75 }
a24aff65 76
211436b6
VZ
77protected:
78 // puts the object in an invalid, uninitialized state
79 void Init();
80
81 // create the object from name, leaves it uninitialized if it failed
683b185d 82 void InitFromName(const wxString& col);
a24aff65
DE
83
84private:
683b185d
DE
85 WX_NSColor m_cocoaNSColor;
86 unsigned char m_red;
87 unsigned char m_green;
88 unsigned char m_blue;
211436b6
VZ
89
90 DECLARE_DYNAMIC_CLASS(wxColour)
a24aff65
DE
91};
92
683b185d 93#endif // __WX_COCOA_COLOUR_H__