1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/colour.h
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef __GTKCOLOURH__
11 #define __GTKCOLOURH__
14 #include "wx/object.h"
15 #include "wx/string.h"
16 #include "wx/gdiobj.h"
17 #include "wx/palette.h"
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
23 class WXDLLIMPEXP_CORE wxDC
;
24 class WXDLLIMPEXP_CORE wxPaintDC
;
25 class WXDLLIMPEXP_CORE wxBitmap
;
26 class WXDLLIMPEXP_CORE wxWindow
;
28 class WXDLLIMPEXP_CORE wxColour
;
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
34 class WXDLLIMPEXP_CORE wxColour
: public wxGDIObject
44 wxColour( unsigned char red
, unsigned char green
, unsigned char blue
);
47 wxColour( unsigned long colRGB
) { Set(colRGB
); }
49 // Implicit conversion from the colour name
50 wxColour( const wxString
&colourName
) { InitFromName(colourName
); }
51 wxColour( const char *colourName
) { InitFromName( wxString::FromAscii(colourName
) ); }
53 wxColour( const wxChar
*colourName
) { InitFromName( wxString(colourName
) ); }
57 wxColour( const wxColour
& col
)
60 wxColour
& operator = ( const wxColour
& col
) { Ref(col
); return *this; }
64 bool Ok() const { return m_refData
!= NULL
; }
66 bool operator == ( const wxColour
& col
) const;
67 bool operator != ( const wxColour
& col
) const { return !(*this == col
); }
69 void Set( unsigned char red
, unsigned char green
, unsigned char blue
);
70 void Set( unsigned long colRGB
)
72 // We don't need to know sizeof(long) here because we assume that the three
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));
79 unsigned char Red() const;
80 unsigned char Green() const;
81 unsigned char Blue() const;
84 // Get colour from name or wxNullColour
85 static wxColour
CreateByName(const wxString
& name
);
87 // Implementation part
88 void CalcPixel( GdkColormap
*cmap
);
90 GdkColor
*GetColor() const;
92 void InitFromName(const wxString
& colourName
);
96 virtual wxObjectRefData
*CreateRefData() const;
97 virtual wxObjectRefData
*CloneRefData(const wxObjectRefData
*data
) const;
101 DECLARE_DYNAMIC_CLASS(wxColour
)
104 #endif // __GTKCOLOURH__