Add wxColour::{Set,Get}RGB[A]().
These methods allow to operate with all 3 or 4 colour channels at once. Add their implementation, documentation and a unit test for wxColour exercising them. Closes #9918. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61976 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -90,7 +90,7 @@ public:
|
||||
ChannelType green,
|
||||
ChannelType blue,
|
||||
ChannelType alpha = wxALPHA_OPAQUE)
|
||||
{ InitRGBA(red,green,blue, alpha); }
|
||||
{ InitRGBA(red, green, blue, alpha); }
|
||||
|
||||
// implemented in colourcmn.cpp
|
||||
bool Set(const wxString &str)
|
||||
@@ -119,6 +119,27 @@ public:
|
||||
// implemented in colourcmn.cpp
|
||||
virtual wxString GetAsString(long flags = wxC2S_NAME | wxC2S_CSS_SYNTAX) const;
|
||||
|
||||
void SetRGB(wxUint32 colRGB)
|
||||
{
|
||||
Set((ChannelType)(0xFF & colRGB),
|
||||
(ChannelType)(0xFF & (colRGB >> 8)),
|
||||
(ChannelType)(0xFF & (colRGB >> 16)));
|
||||
}
|
||||
|
||||
void SetRGBA(wxUint32 colRGBA)
|
||||
{
|
||||
Set((ChannelType)(0xFF & colRGBA),
|
||||
(ChannelType)(0xFF & (colRGBA >> 8)),
|
||||
(ChannelType)(0xFF & (colRGBA >> 16)),
|
||||
(ChannelType)(0xFF & (colRGBA >> 24)));
|
||||
}
|
||||
|
||||
wxUint32 GetRGB() const
|
||||
{ return Red() | (Green() << 8) | (Blue() << 16); }
|
||||
|
||||
wxUint32 GetRGBA() const
|
||||
{ return Red() | (Green() << 8) | (Blue() << 16) | (Alpha() << 24); }
|
||||
|
||||
#if !wxCOLOUR_IS_GDIOBJECT
|
||||
virtual bool IsOk() const= 0;
|
||||
|
||||
|
Reference in New Issue
Block a user