Add wxColour::Get{Red,Green,Blue,Alpha}() to avoid gcc 12 warnings
These functions return the colour components as unsigned int and so promote to this type in arithmetic expressions, unlike unsigned char returned by the existing accessors without the "Get" prefix, which promotes to (signed) int and results in gcc 12 -Warith-conversion warnings when the result is then converted to unsigned, as it happened in our own wxColour::GetRGB() and GetRGBA() functions and would probably happen in a lot of code outside wx, which could also be updated to use the new functions instead of inserting casts.
This commit is contained in:
@@ -125,6 +125,13 @@ public:
|
||||
virtual ChannelType Alpha() const
|
||||
{ return wxALPHA_OPAQUE ; }
|
||||
|
||||
// These getters return the values as unsigned int, which avoids promoting
|
||||
// them to (signed) int in arithmetic expressions, unlike the ones above.
|
||||
unsigned int GetRed() const { return Red(); }
|
||||
unsigned int GetGreen() const { return Green(); }
|
||||
unsigned int GetBlue() const { return Blue(); }
|
||||
unsigned int GetAlpha() const { return Alpha(); }
|
||||
|
||||
virtual bool IsSolid() const
|
||||
{ return true; }
|
||||
|
||||
@@ -147,10 +154,10 @@ public:
|
||||
}
|
||||
|
||||
wxUint32 GetRGB() const
|
||||
{ return Red() | (Green() << 8) | (Blue() << 16); }
|
||||
{ return GetRed() | (GetGreen() << 8) | (GetBlue() << 16); }
|
||||
|
||||
wxUint32 GetRGBA() const
|
||||
{ return Red() | (Green() << 8) | (Blue() << 16) | (Alpha() << 24); }
|
||||
{ return GetRed() | (GetGreen() << 8) | (GetBlue() << 16) | (GetAlpha() << 24); }
|
||||
|
||||
#if !wxCOLOUR_IS_GDIOBJECT
|
||||
virtual bool IsOk() const= 0;
|
||||
|
||||
Reference in New Issue
Block a user