Adding IsSolid to wxColour
Under macOS colors can be patterns, then accessors for RGB values are useless, IsSolid returns true if the color can be expressed in RGB values at all.
This commit is contained in:
@@ -119,6 +119,9 @@ public:
|
||||
virtual ChannelType Alpha() const
|
||||
{ return wxALPHA_OPAQUE ; }
|
||||
|
||||
virtual bool IsSolid() const
|
||||
{ return true; }
|
||||
|
||||
// implemented in colourcmn.cpp
|
||||
virtual wxString GetAsString(long flags = wxC2S_NAME | wxC2S_CSS_SYNTAX) const;
|
||||
|
||||
|
@@ -34,6 +34,8 @@ public:
|
||||
virtual ChannelType Blue() const wxOVERRIDE;
|
||||
virtual ChannelType Alpha() const wxOVERRIDE;
|
||||
|
||||
virtual bool IsSolid() const wxOVERRIDE;
|
||||
|
||||
wxColour& operator=(const wxColour& col);
|
||||
|
||||
// comparison
|
||||
@@ -91,6 +93,9 @@ public:
|
||||
virtual CGFloat Blue() const = 0;
|
||||
virtual CGFloat Alpha() const = 0;
|
||||
|
||||
virtual bool IsSolid() const
|
||||
{ return true; }
|
||||
|
||||
virtual CGColorRef GetCGColor() const = 0;
|
||||
|
||||
virtual wxColourRefData* Clone() const = 0;
|
||||
|
@@ -182,6 +182,11 @@ public:
|
||||
*/
|
||||
virtual unsigned char Red() const;
|
||||
|
||||
/**
|
||||
Returns @true if the color can be described using RGB values, ie is solid,
|
||||
@false if it is a pattern (currently only possible on macOS)
|
||||
*/
|
||||
virtual bool IsSolid() const;
|
||||
//@{
|
||||
/**
|
||||
Sets the RGB intensity values using the given values (first overload),
|
||||
|
@@ -27,6 +27,8 @@ public:
|
||||
virtual CGFloat Blue() const wxOVERRIDE;
|
||||
virtual CGFloat Alpha() const wxOVERRIDE;
|
||||
|
||||
virtual bool IsSolid() const wxOVERRIDE;
|
||||
|
||||
CGColorRef GetCGColor() const wxOVERRIDE;
|
||||
|
||||
virtual wxColourRefData* Clone() const wxOVERRIDE { return new wxNSColorRefData(*this); }
|
||||
@@ -94,6 +96,11 @@ CGFloat wxNSColorRefData::Alpha() const
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool wxNSColorRefData::IsSolid() const
|
||||
{
|
||||
return [m_nsColour colorUsingColorSpaceName:NSCalibratedRGBColorSpace] != nil;
|
||||
}
|
||||
|
||||
CGColorRef wxNSColorRefData::GetCGColor() const
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
|
||||
|
@@ -189,6 +189,13 @@ wxColour::ChannelType wxColour::Alpha() const
|
||||
return wxRound(M_COLDATA->Alpha() * 255.0);
|
||||
}
|
||||
|
||||
bool wxColour::IsSolid() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), false, "invalid colour" );
|
||||
|
||||
return M_COLDATA->IsSolid();
|
||||
}
|
||||
|
||||
#if wxOSX_USE_COCOA_OR_CARBON
|
||||
void wxColour::GetRGBColor(RGBColor* col) const
|
||||
{
|
||||
|
Reference in New Issue
Block a user