]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: colour.h | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
dbf858b5 | 5 | // Id: $Id$ |
01111366 | 6 | // Copyright: (c) 1998 Robert Roebling |
65571936 | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
c801d85f KB |
10 | #ifndef __GTKCOLOURH__ |
11 | #define __GTKCOLOURH__ | |
12 | ||
c801d85f KB |
13 | #include "wx/defs.h" |
14 | #include "wx/object.h" | |
15 | #include "wx/string.h" | |
16 | #include "wx/gdiobj.h" | |
401ec7b6 | 17 | #include "wx/palette.h" |
c801d85f KB |
18 | |
19 | //----------------------------------------------------------------------------- | |
20 | // classes | |
21 | //----------------------------------------------------------------------------- | |
22 | ||
20123d49 MW |
23 | class WXDLLIMPEXP_CORE wxDC; |
24 | class WXDLLIMPEXP_CORE wxPaintDC; | |
25 | class WXDLLIMPEXP_CORE wxBitmap; | |
26 | class WXDLLIMPEXP_CORE wxWindow; | |
c801d85f | 27 | |
20123d49 | 28 | class WXDLLIMPEXP_CORE wxColour; |
c801d85f KB |
29 | |
30 | //----------------------------------------------------------------------------- | |
31 | // wxColour | |
32 | //----------------------------------------------------------------------------- | |
33 | ||
20123d49 | 34 | class WXDLLIMPEXP_CORE wxColour: public wxGDIObject |
c801d85f | 35 | { |
e4a81a2e | 36 | public: |
c89f5c02 | 37 | wxColour() { } |
aad6765c | 38 | |
c89f5c02 RR |
39 | // Construct from RGB |
40 | wxColour( unsigned char red, unsigned char green, unsigned char blue ); | |
41 | wxColour( unsigned long colRGB ) { Set(colRGB); } | |
42 | ||
43 | // Implicit conversion from the colour name | |
44 | wxColour( const wxString &colourName ) { InitFromName(colourName); } | |
2b5f62a0 | 45 | wxColour( const char *colourName ) { InitFromName( wxString::FromAscii(colourName) ); } |
401eb3de RR |
46 | #if wxUSE_UNICODE |
47 | wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); } | |
48 | #endif | |
49 | ||
c89f5c02 | 50 | |
d84afea9 GD |
51 | wxColour( const wxColour& col ) |
52 | : wxGDIObject() | |
53 | { Ref(col); } | |
c89f5c02 RR |
54 | wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; } |
55 | ||
56 | ~wxColour(); | |
57 | ||
58 | bool Ok() const { return m_refData != NULL; } | |
aad6765c | 59 | |
c89f5c02 RR |
60 | bool operator == ( const wxColour& col ) const; |
61 | bool operator != ( const wxColour& col ) const { return !(*this == col); } | |
62 | ||
63 | void Set( unsigned char red, unsigned char green, unsigned char blue ); | |
64 | void Set( unsigned long colRGB ) | |
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 | Set((unsigned char)colRGB, | |
69 | (unsigned char)(colRGB >> 8), | |
70 | (unsigned char)(colRGB >> 16)); | |
71 | } | |
72 | ||
73 | unsigned char Red() const; | |
74 | unsigned char Green() const; | |
75 | unsigned char Blue() const; | |
76 | ||
77 | ||
4e6b8309 VZ |
78 | // Get colour from name or wxNullColour |
79 | static wxColour CreateByName(const wxString& name); | |
80 | ||
c89f5c02 RR |
81 | // Implementation part |
82 | void CalcPixel( GdkColormap *cmap ); | |
83 | int GetPixel() const; | |
84 | GdkColor *GetColor() const; | |
c0ac1c32 | 85 | |
aad6765c JS |
86 | void InitFromName(const wxString& colourName); |
87 | ||
68dda785 | 88 | protected: |
c89f5c02 RR |
89 | // ref counting code |
90 | virtual wxObjectRefData *CreateRefData() const; | |
91 | virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; | |
aad6765c | 92 | |
68dda785 VZ |
93 | |
94 | private: | |
c89f5c02 | 95 | DECLARE_DYNAMIC_CLASS(wxColour) |
c801d85f | 96 | }; |
c0ac1c32 | 97 | |
c801d85f | 98 | #endif // __GTKCOLOURH__ |