]> git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/colour.h
non virtual dtors warning fixes
[wxWidgets.git] / include / wx / x11 / colour.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/x11/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 #include "wx/defs.h"
16 #include "wx/object.h"
17 #include "wx/string.h"
18 #include "wx/gdiobj.h"
19 #include "wx/palette.h"
20
21 //-----------------------------------------------------------------------------
22 // classes
23 //-----------------------------------------------------------------------------
24
25 class WXDLLIMPEXP_CORE wxDC;
26 class WXDLLIMPEXP_CORE wxPaintDC;
27 class WXDLLIMPEXP_CORE wxBitmap;
28 class WXDLLIMPEXP_CORE wxWindow;
29
30 class WXDLLIMPEXP_CORE wxColour;
31
32 //-----------------------------------------------------------------------------
33 // wxColour
34 //-----------------------------------------------------------------------------
35
36 class WXDLLEXPORT wxColour: public wxGDIObject
37 {
38 public:
39 // constructors
40 // ------------
41
42 // default
43 wxColour() { }
44
45 // from separate RGB
46 wxColour( unsigned char red, unsigned char green, unsigned char blue );
47
48 // from packed RGB
49 wxColour( unsigned long colRGB ) { Set(colRGB); }
50
51 // Implicit conversion from the colour name
52 wxColour( const wxString &colourName ) { InitFromName(colourName); }
53 wxColour( const char *colourName ) { InitFromName( wxString::FromAscii(colourName) ); }
54 #if wxUSE_UNICODE
55 wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); }
56 #endif
57
58 // Get colour from name or wxNullColour
59 static wxColour CreateByName(const wxString& name);
60
61 ~wxColour();
62
63 bool Ok() const { return m_refData != NULL; }
64
65 bool operator == ( const wxColour& col ) const;
66 bool operator != ( const wxColour& col ) const { return !(*this == col); }
67
68 void Set( unsigned char red, unsigned char green, unsigned char blue );
69 void Set( unsigned long colRGB )
70 {
71 // We don't need to know sizeof(long) here because we assume that the three
72 // least significant bytes contain the R, G and B values
73 Set((unsigned char)colRGB,
74 (unsigned char)(colRGB >> 8),
75 (unsigned char)(colRGB >> 16));
76 }
77
78 unsigned char Red() const;
79 unsigned char Green() const;
80 unsigned char Blue() const;
81
82 // Implementation part
83
84 void CalcPixel( WXColormap cmap );
85 unsigned long GetPixel() const;
86 WXColor *GetColor() const;
87
88 void InitFromName(const wxString& colourName);
89
90 protected:
91 // ref counting code
92 virtual wxObjectRefData *CreateRefData() const;
93 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
94
95
96 private:
97 DECLARE_DYNAMIC_CLASS(wxColour)
98 };
99
100 #endif
101
102 // _WX_COLOUR_H_