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