]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mgl/colour.h
Nuke #pragma implementation/interface's
[wxWidgets.git] / include / wx / mgl / colour.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: colour.h
3 // Purpose: wxColour class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_COLOUR_H_
13 #define _WX_COLOUR_H_
14
15 #include "wx/object.h"
16
17 // Colour
18 class WXDLLEXPORT wxColour: public wxObject
19 {
20 public:
21 // ctors
22 // default
23 wxColour();
24 // from RGB
25 wxColour(unsigned char red, unsigned char green, unsigned char blue)
26 { Set(red, green, blue); }
27 wxColour(unsigned long colRGB) { Set(colRGB); }
28
29 // implicit conversion from the colour name
30 wxColour(const wxString &colourName) { InitFromName(colourName); }
31 wxColour(const char *colourName) { InitFromName(colourName); }
32
33
34 // copy ctors and assignment operators
35 wxColour(const wxColour& col);
36 wxColour& operator = (const wxColour& col);
37
38 // dtor
39 ~wxColour();
40
41 // Set() functions
42 void Set(unsigned char red, unsigned char green, unsigned char blue);
43 void Set(unsigned long colRGB)
44 {
45 // we don't need to know sizeof(long) here because we assume that the three
46 // least significant bytes contain the R, G and B values
47 Set((unsigned char)colRGB,
48 (unsigned char)(colRGB >> 8),
49 (unsigned char)(colRGB >> 16));
50 }
51
52 // accessors
53 bool Ok() const { return m_isInit; }
54
55 unsigned char Red() const { return m_red; }
56 unsigned char Green() const { return m_green; }
57 unsigned char Blue() const { return m_blue; }
58
59 // comparison
60 bool operator == (const wxColour& colour) const
61 {
62 return (m_red == colour.m_red &&
63 m_green == colour.m_green &&
64 m_blue == colour.m_blue &&
65 m_isInit == colour.m_isInit);
66 }
67 bool operator != (const wxColour& colour) const { return !(*this == colour); }
68
69 void InitFromName(const wxString& colourName);
70
71 protected:
72
73 // Helper function
74 void Init();
75
76 private:
77 bool m_isInit;
78 unsigned char m_red;
79 unsigned char m_blue;
80 unsigned char m_green;
81
82 private:
83 DECLARE_DYNAMIC_CLASS(wxColour)
84 };
85
86 #endif
87 // _WX_COLOUR_H_