]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/colour.h
compatibility changes: WXWIN_COMPATIBILITY_EVENT_TYPES and DECLARE_EVENT_TABLE_ENTRY...
[wxWidgets.git] / include / wx / os2 / colour.h
CommitLineData
0e320a79
DW
1/////////////////////////////////////////////////////////////////////////////
2// Name: colour.h
3// Purpose: wxColour class
37f214d5 4// Author: David Webster
0e320a79 5// Modified by:
37f214d5 6// Created: 10/13/99
0e320a79 7// RCS-ID: $Id$
37f214d5 8// Copyright: (c) David Webster
0e320a79
DW
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_COLOUR_H_
13#define _WX_COLOUR_H_
14
0e320a79 15#include "wx/object.h"
0e320a79
DW
16
17// Colour
18class WXDLLEXPORT wxColour: public wxObject
19{
20public:
a0606634
DW
21 //
22 // Ctors
23 //
24
25 //
26 // Default
27 //
28 wxColour();
29
30 //
0e320a79 31 // from RGB
a0606634
DW
32 //
33 wxColour( unsigned char cRed
34 ,unsigned char cGreen
35 ,unsigned char cBlue
36 );
37
38 //
39 // Implicit conversion from the colour name
40 //
41 wxColour(const wxString& rColourName) { InitFromName(rColourName); }
42 wxColour(const char* zColourName) { InitFromName(zColourName); }
43
44 //
45 // Copy ctors and assignment operators
46 //
47 wxColour(const wxColour& rCol);
48 wxColour(const wxColour* pCol);
49 wxColour&operator = (const wxColour& rCol);
50
51 //
52 // Dtor
53 //
54 ~wxColour();
55
56 //
57 // Set functions
58 //
59 void Set( unsigned char cRed
60 ,unsigned char cGreen
61 ,unsigned char cBlue
62 );
63 void Set(unsigned long lColRGB)
64 {
65 //
66 // We don't need to know sizeof(long) here because we assume that the three
67 // least significant bytes contain the R, G and B values
68 //
69 Set( (unsigned char)lColRGB
70 ,(unsigned char)(lColRGB >> 8)
71 ,(unsigned char)(lColRGB >> 16)
72 );
73 }
5a56a532
DW
74 void Set(const wxString& rsColour)
75 {
76 InitFromName(rsColour);
77 }
a0606634
DW
78
79 //
80 // Accessors
8c5907ce 81 //
a0606634
DW
82 bool Ok(void) const {return m_bIsInit; }
83
84 //
85 // Let's remove this inelegant function
86 //
0e320a79 87#if WXWIN_COMPATIBILITY
a0606634
DW
88 void Get( unsigned char* pRed
89 ,unsigned char* pGreen
90 ,unsigned char* pBlue
91 ) const;
0e320a79
DW
92#endif
93
a0606634
DW
94 unsigned char Red(void) const { return m_cRed; }
95 unsigned char Green(void) const { return m_cGreen; }
96 unsigned char Blue(void) const { return m_cBlue; }
0e320a79 97
a0606634
DW
98 //
99 // Comparison
100 //
101 bool operator == (const wxColour& rColour) const
102 {
103 return (m_cRed == rColour.m_cRed &&
104 m_cGreen == rColour.m_cGreen &&
105 m_cBlue == rColour.m_cBlue
106 );
107 }
108 bool operator != (const wxColour& rColour) const { return !(*this == rColour); }
0e320a79 109
a0606634
DW
110 void InitFromName(const wxString& rCol);
111 WXCOLORREF GetPixel(void) const { return m_vPixel; };
0e320a79
DW
112
113private:
a0606634
DW
114 bool m_bIsInit;
115 unsigned char m_cRed;
116 unsigned char m_cBlue;
117 unsigned char m_cGreen;
0e320a79
DW
118
119public:
a0606634 120 WXCOLORREF m_vPixel ;
0e320a79
DW
121private:
122 DECLARE_DYNAMIC_CLASS(wxColour)
a0606634 123}; // end of class wxColour
0e320a79
DW
124
125#endif
126 // _WX_COLOUR_H_