]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: colour.h | |
3 | // Purpose: wxColour class | |
4 | // Author: Julian Smart, Robert Roebling | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart, Robert Roebling | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_COLOUR_H_ | |
13 | #define _WX_COLOUR_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "colour.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/defs.h" | |
20 | #include "wx/object.h" | |
21 | #include "wx/string.h" | |
22 | #include "wx/gdiobj.h" | |
23 | #include "wx/palette.h" | |
24 | ||
25 | //----------------------------------------------------------------------------- | |
26 | // classes | |
27 | //----------------------------------------------------------------------------- | |
28 | ||
29 | class wxDC; | |
30 | class wxPaintDC; | |
31 | class wxBitmap; | |
32 | class wxWindow; | |
33 | ||
34 | class wxColour; | |
35 | ||
36 | //----------------------------------------------------------------------------- | |
37 | // wxColour | |
38 | //----------------------------------------------------------------------------- | |
39 | ||
40 | class wxColour: public wxGDIObject | |
41 | { | |
42 | public: | |
43 | wxColour() { } | |
44 | ||
45 | // Construct from RGB | |
46 | wxColour( unsigned char red, unsigned char green, unsigned char blue ); | |
47 | wxColour( unsigned long colRGB ) { Set(colRGB); } | |
48 | ||
49 | // Implicit conversion from the colour name | |
50 | wxColour( const wxString &colourName ) { InitFromName(colourName); } | |
51 | wxColour( const char *colourName ) { InitFromName( wxString::FromAscii(colourName) ); } | |
52 | #if wxUSE_UNICODE | |
53 | wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); } | |
54 | #endif | |
55 | ||
56 | wxColour( const wxColour& col ) { Ref(col); } | |
57 | wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; } | |
58 | ||
59 | ~wxColour(); | |
60 | ||
61 | bool Ok() const { return m_refData != NULL; } | |
62 | ||
63 | bool operator == ( const wxColour& col ) const; | |
64 | bool operator != ( const wxColour& col ) const { return !(*this == col); } | |
65 | ||
66 | void Set( unsigned char red, unsigned char green, unsigned char blue ); | |
67 | void Set( unsigned long colRGB ) | |
68 | { | |
69 | // We don't need to know sizeof(long) here because we assume that the three | |
70 | // least significant bytes contain the R, G and B values | |
71 | Set((unsigned char)colRGB, | |
72 | (unsigned char)(colRGB >> 8), | |
73 | (unsigned char)(colRGB >> 16)); | |
74 | } | |
75 | ||
76 | unsigned char Red() const; | |
77 | unsigned char Green() const; | |
78 | unsigned char Blue() const; | |
79 | ||
80 | // Implementation part | |
81 | ||
82 | void CalcPixel( WXColormap cmap ); | |
83 | unsigned long GetPixel() const; | |
84 | WXColor *GetColor() const; | |
85 | ||
86 | protected: | |
87 | // ref counting code | |
88 | virtual wxObjectRefData *CreateRefData() const; | |
89 | virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; | |
90 | ||
91 | // Helper functions | |
92 | void InitFromName(const wxString& colourName); | |
93 | ||
94 | private: | |
95 | DECLARE_DYNAMIC_CLASS(wxColour) | |
96 | }; | |
97 | ||
98 | #endif | |
99 | ||
100 | // _WX_COLOUR_H_ | |
101 |