1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/x11/colour.h
3 // Purpose: wxColour class
4 // Author: Julian Smart, Robert Roebling
8 // Copyright: (c) Julian Smart, Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #include "wx/object.h"
17 #include "wx/string.h"
18 #include "wx/gdiobj.h"
19 #include "wx/palette.h"
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 class WXDLLIMPEXP_CORE wxDC
;
26 class WXDLLIMPEXP_CORE wxPaintDC
;
27 class WXDLLIMPEXP_CORE wxBitmap
;
28 class WXDLLIMPEXP_CORE wxWindow
;
30 class WXDLLIMPEXP_CORE wxColour
;
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 class WXDLLEXPORT wxColour
: public wxGDIObject
46 wxColour( unsigned char red
, unsigned char green
, unsigned char blue
);
49 wxColour( unsigned long colRGB
) { Set(colRGB
); }
51 // Implicit conversion from the colour name
52 wxColour( const wxString
&colourName
) { InitFromName(colourName
); }
53 wxColour( const char *colourName
) { InitFromName( wxString::FromAscii(colourName
) ); }
55 wxColour( const wxChar
*colourName
) { InitFromName( wxString(colourName
) ); }
58 // Get colour from name or wxNullColour
59 static wxColour
CreateByName(const wxString
& name
);
61 wxColour( const wxColour
& col
) { Ref(col
); }
62 wxColour
& operator = ( const wxColour
& col
) { Ref(col
); return *this; }
66 bool Ok() const { return m_refData
!= NULL
; }
68 bool operator == ( const wxColour
& col
) const;
69 bool operator != ( const wxColour
& col
) const { return !(*this == col
); }
71 void Set( unsigned char red
, unsigned char green
, unsigned char blue
);
72 void Set( unsigned long colRGB
)
74 // We don't need to know sizeof(long) here because we assume that the three
75 // least significant bytes contain the R, G and B values
76 Set((unsigned char)colRGB
,
77 (unsigned char)(colRGB
>> 8),
78 (unsigned char)(colRGB
>> 16));
81 unsigned char Red() const;
82 unsigned char Green() const;
83 unsigned char Blue() const;
85 // Implementation part
87 void CalcPixel( WXColormap cmap
);
88 unsigned long GetPixel() const;
89 WXColor
*GetColor() const;
91 void InitFromName(const wxString
& colourName
);
95 virtual wxObjectRefData
*CreateRefData() const;
96 virtual wxObjectRefData
*CloneRefData(const wxObjectRefData
*data
) const;
100 DECLARE_DYNAMIC_CLASS(wxColour
)