great copy ctor/assignment operators cleanup by Paul Cornett (patch 1307665)
[wxWidgets.git] / include / wx / gtk / colour.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/colour.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef __GTKCOLOURH__
11 #define __GTKCOLOURH__
12
13 #include "wx/defs.h"
14 #include "wx/object.h"
15 #include "wx/string.h"
16 #include "wx/gdiobj.h"
17 #include "wx/palette.h"
18
19 //-----------------------------------------------------------------------------
20 // classes
21 //-----------------------------------------------------------------------------
22
23 class WXDLLIMPEXP_CORE wxDC;
24 class WXDLLIMPEXP_CORE wxPaintDC;
25 class WXDLLIMPEXP_CORE wxBitmap;
26 class WXDLLIMPEXP_CORE wxWindow;
27
28 class WXDLLIMPEXP_CORE wxColour;
29
30 //-----------------------------------------------------------------------------
31 // wxColour
32 //-----------------------------------------------------------------------------
33
34 class WXDLLIMPEXP_CORE wxColour: public wxGDIObject
35 {
36 public:
37 // constructors
38 // ------------
39
40 // default
41 wxColour() { }
42
43 // from separate RGB
44 wxColour( unsigned char red, unsigned char green, unsigned char blue );
45
46 // from packed RGB
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();
57
58 bool Ok() const { return m_refData != NULL; }
59
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
78 // Get colour from name or wxNullColour
79 static wxColour CreateByName(const wxString& name);
80
81 // Implementation part
82 void CalcPixel( GdkColormap *cmap );
83 int GetPixel() const;
84 GdkColor *GetColor() const;
85
86 void InitFromName(const wxString& colourName);
87
88 protected:
89 // ref counting code
90 virtual wxObjectRefData *CreateRefData() const;
91 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
92
93
94 private:
95 DECLARE_DYNAMIC_CLASS(wxColour)
96 };
97
98 #endif // __GTKCOLOURH__