X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/28f3fe51bddd89bf473581eaca1a15c8f3b0e2c5..4e209a2064a2b6d97b810ccab66859ab30b4bf2a:/src/cocoa/dcmemory.mm diff --git a/src/cocoa/dcmemory.mm b/src/cocoa/dcmemory.mm index e097fea9a5..02efda166f 100644 --- a/src/cocoa/dcmemory.mm +++ b/src/cocoa/dcmemory.mm @@ -10,8 +10,11 @@ ///////////////////////////////////////////////////////////////////////////// #include "wx/dcmemory.h" +#include "wx/log.h" #import +#import +#import //----------------------------------------------------------------------------- // wxMemoryDC @@ -77,3 +80,41 @@ void wxMemoryDC::DoGetSize( int *width, int *height ) const *height = m_selectedBitmap.GetHeight(); } +bool wxMemoryDC::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest, + wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc, + int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask) +{ + if(!m_selectedBitmap.Ok()) + return false; + + NSAffineTransform *transform = [NSAffineTransform transform]; + [transform translateXBy:xdest yBy:ydest]; + + NSAffineTransform *flipTransform = [NSAffineTransform transform]; + /* x' = 1x + 0y + 0 + y' = 0x + -1y + window's height + */ + NSAffineTransformStruct matrix = { + 1, 0 + , 0, -1 + , 0, height + }; + [flipTransform setTransformStruct: matrix]; + + NSGraphicsContext *context = [NSGraphicsContext currentContext]; + [context saveGraphicsState]; + [transform concat]; + [flipTransform concat]; + + wxLogDebug("[m_cocoaNSImage isFlipped]=%d", [m_cocoaNSImage isFlipped]); + [m_cocoaNSImage drawAtPoint: NSMakePoint(0,0) + fromRect: NSMakeRect(xsrc, + m_selectedBitmap.GetHeight()-height-ysrc, + width, height) + operation: NSCompositeCopy // FIXME: raster ops + fraction: 1.0]; + + [context restoreGraphicsState]; + return false; +} +