wxCocoa: Added preliminary Blit support

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22241 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Elliott 2003-07-22 17:40:52 +00:00
parent 68d31398dd
commit 2c23fe91e3
4 changed files with 59 additions and 0 deletions

View File

@ -56,6 +56,10 @@ protected:
void CocoaApplyTransformations();
float m_cocoaHeight;
bool m_cocoaFlipped;
// Blitting
virtual bool CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask);
//-------------------------------------------------------------------------
// Implementation
//-------------------------------------------------------------------------

View File

@ -29,6 +29,10 @@ protected:
// DC stack
virtual bool CocoaLockFocus();
virtual bool CocoaUnlockFocus();
// Blitting
virtual bool CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask);
};
#endif // __WX_COCOA_DCMEMORY_H__

View File

@ -447,6 +447,16 @@ void wxDC::DoCrossHair(wxCoord x, wxCoord y)
bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask , wxCoord xsrcMask, wxCoord ysrcMask)
{
if(!CocoaTakeFocus()) return false;
if(!source) return false;
return source->CocoaDoBlitOnFocusedDC(xdest,ydest,width,height,
xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask);
}
bool wxDC::CocoaDoBlitOnFocusedDC(wxCoord xdest, wxCoord ydest,
wxCoord width, wxCoord height, wxCoord xsrc, wxCoord ysrc,
int logicalFunc, bool useMask, wxCoord xsrcMask, wxCoord ysrcMask)
{
return false;
}

View File

@ -10,8 +10,11 @@
/////////////////////////////////////////////////////////////////////////////
#include "wx/dcmemory.h"
#include "wx/log.h"
#import <AppKit/NSImage.h>
#import <AppKit/NSAffineTransform.h>
#import <AppKit/NSGraphicsContext.h>
//-----------------------------------------------------------------------------
// 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;
}