5 #include <wx/settings.h>
7 class CMuleColour
: public wxColour
11 enum ColourComponent
{ COLOUR_R
= 1, COLOUR_G
= 2, COLOUR_B
= 4 };
14 CMuleColour(const wxColour
& colour
) : wxColour(colour
) { }
15 CMuleColour(byte r
, byte g
, byte b
) : wxColour(r
,g
,b
) { }
16 CMuleColour(unsigned long rgb
) : wxColour() { wxColour::Set(rgb
); }
17 CMuleColour(wxSystemColour colour
) : wxColour(wxSystemSettings::GetColour(colour
)) { }
21 const CMuleColour
& Blend(byte percentage
, ColourComponent flags
= (ColourComponent
)(COLOUR_R
| COLOUR_G
| COLOUR_B
) )
23 unsigned int red
= (unsigned int)(Red() * ((flags
& COLOUR_R
) ? ((float)percentage
/(float)100) : (float)1));
24 unsigned int green
= (unsigned int)(Green() * ((flags
& COLOUR_G
) ? ((float)percentage
/(float)100) : (float)1));
25 unsigned int blue
= (unsigned int)(Blue() * ((flags
& COLOUR_B
) ? ((float)percentage
/(float)100) : (float)1));
26 Set((red
< 255) ? red
: 255, (green
< 255) ? green
: 255, (blue
< 255) ? blue
: 255, Alpha());
30 const CMuleColour
& BlendWith(const CMuleColour
& colour
, double covered
)
32 unsigned int red
= (unsigned int)(Red() + (colour
.Red() * covered
) + 0.5);
33 unsigned int green
= (unsigned int)(Green() + (colour
.Green() * covered
) + 0.5);
34 unsigned int blue
= (unsigned int)(Blue() + (colour
.Blue() * covered
) + 0.5);
35 Set((red
< 255) ? red
: 255, (green
< 255) ? green
: 255, (blue
< 255) ? blue
: 255, Alpha());
39 unsigned long GetULong() const { return (Blue() << 16) | (Green() << 8) | Red(); }
41 bool IsBlack() const { return !Red() && !Blue() && !Green(); }
43 bool IsSameAs(const CMuleColour
& colour
) const { return GetULong() == colour
.GetULong(); }