wxOSX: Implement function to retrieve pattern image for non-solid colour
Under wxOSX non-solid wxColour with NSColor backend is represented by pattern image and it would be useful to have ability to get it e.g. to help dealing with non-solid wxColours by frameworks not supporting such colours, like e.g. Cairo.
This commit is contained in:
@@ -68,6 +68,7 @@ public:
|
||||
// This ctor does not take ownership of the color.
|
||||
explicit wxColour(WX_NSColor color);
|
||||
WX_NSColor OSXGetNSColor() const;
|
||||
WX_NSImage OSXGetNSPatternImage() const;
|
||||
#endif
|
||||
|
||||
protected :
|
||||
@@ -102,6 +103,7 @@ public:
|
||||
|
||||
#if wxOSX_USE_COCOA
|
||||
virtual WX_NSColor GetNSColor() const;
|
||||
virtual WX_NSImage GetNSPatternImage() const;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@@ -35,6 +35,7 @@ public:
|
||||
virtual wxColourRefData* Clone() const wxOVERRIDE { return new wxNSColorRefData(*this); }
|
||||
|
||||
virtual WX_NSColor GetNSColor() const wxOVERRIDE;
|
||||
virtual WX_NSImage GetNSPatternImage() const wxOVERRIDE;
|
||||
private:
|
||||
WX_NSColor m_nsColour;
|
||||
|
||||
@@ -186,15 +187,33 @@ CGColorRef wxNSColorRefData::GetCGColor() const
|
||||
return cgcolor;
|
||||
}
|
||||
|
||||
WX_NSImage wxNSColorRefData::GetNSPatternImage() const
|
||||
{
|
||||
NSColor* colPat = [m_nsColour colorUsingColorSpaceName:NSPatternColorSpace];
|
||||
if ( colPat )
|
||||
{
|
||||
NSImage* nsimage = [colPat patternImage];
|
||||
if ( nsimage )
|
||||
{
|
||||
return nsimage;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
WX_NSColor wxColourRefData::GetNSColor() const
|
||||
{
|
||||
wxOSXEffectiveAppearanceSetter helper;
|
||||
return [NSColor colorWithCalibratedRed:Red() green:Green() blue:Blue() alpha:Alpha() ];
|
||||
}
|
||||
|
||||
WX_NSImage wxColourRefData::GetNSPatternImage() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wxColour::wxColour(WX_NSColor col)
|
||||
{
|
||||
m_refData = new wxNSColorRefData(col);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -222,6 +222,13 @@ WX_NSColor wxColour::OSXGetNSColor() const
|
||||
|
||||
return M_COLDATA->GetNSColor();
|
||||
}
|
||||
|
||||
WX_NSImage wxColour::OSXGetNSPatternImage() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), NULL, "invalid colour" );
|
||||
|
||||
return M_COLDATA->GetNSPatternImage();
|
||||
}
|
||||
#endif
|
||||
|
||||
void wxColour::InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a)
|
||||
|
Reference in New Issue
Block a user