]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/x11/colour.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxColour class
4 // Author: Julian Smart, Robert Roebling
8 // Copyright: (c) Julian Smart, Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "colour.h"
20 #include "wx/object.h"
21 #include "wx/string.h"
22 #include "wx/gdiobj.h"
23 #include "wx/palette.h"
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 class WXDLLEXPORT wxColour
: public wxGDIObject
46 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
) ); }
56 // Get colour from name or wxNullColour
57 static wxColour
CreateByName(const wxString
& name
);
59 wxColour( const wxColour
& col
) { Ref(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;
83 // Implementation part
85 void CalcPixel( WXColormap cmap
);
86 unsigned long GetPixel() const;
87 WXColor
*GetColor() const;
89 void InitFromName(const wxString
& colourName
);
93 virtual wxObjectRefData
*CreateRefData() const;
94 virtual wxObjectRefData
*CloneRefData(const wxObjectRefData
*data
) const;
98 DECLARE_DYNAMIC_CLASS(wxColour
)