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