]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/colour.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxColour class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/object.h"
16 #include "wx/string.h"
19 class WXDLLEXPORT wxColour
: public wxObject
21 DECLARE_DYNAMIC_CLASS(wxColour
)
27 wxColour( unsigned char red
, unsigned char green
, unsigned char blue
)
28 { Set(red
, green
, blue
); }
29 wxColour( unsigned long colRGB
) { Set(colRGB
); }
31 // implicit conversion from the colour name
32 wxColour( const wxString
&colourName
) { InitFromName(colourName
); }
33 wxColour( const char *colourName
) { InitFromName(colourName
); }
35 // copy ctors and assignment operators
36 wxColour( const wxColour
& col
);
37 wxColour
& operator = ( const wxColour
& col
);
43 void Set( unsigned char red
, unsigned char green
, unsigned char blue
);
44 void Set( unsigned long colRGB
)
46 // we don't need to know sizeof(long) here because we assume that the three
47 // least significant bytes contain the R, G and B values
48 Set((unsigned char)colRGB
,
49 (unsigned char)(colRGB
>> 8),
50 (unsigned char)(colRGB
>> 16));
54 bool Ok() const {return m_isInit
; }
55 unsigned char Red() const { return m_red
; }
56 unsigned char Green() const { return m_green
; }
57 unsigned char Blue() const { return m_blue
; }
59 int GetPixel() const { return m_pixel
; };
60 void SetPixel(int pixel
) { m_pixel
= pixel
; m_isInit
= true; };
62 inline bool operator == (const wxColour
& colour
) const { return (m_red
== colour
.m_red
&& m_green
== colour
.m_green
&& m_blue
== colour
.m_blue
); }
64 inline bool operator != (const wxColour
& colour
) const { return (!(m_red
== colour
.m_red
&& m_green
== colour
.m_green
&& m_blue
== colour
.m_blue
)); }
66 // Get colour from name or wxNullColour
67 static wxColour
CreateByName(const wxString
& name
);
69 // Allocate a colour, or nearest colour, using the given display.
70 // If realloc is true, ignore the existing pixel, otherwise just return
72 // Returns the allocated pixel.
74 // TODO: can this handle mono displays? If not, we should have an extra
75 // flag to specify whether this should be black or white by default.
77 int AllocColour(WXDisplay
* display
, bool realloc
= false);
79 void InitFromName(const wxString
& col
);
89 unsigned char m_green
;