adding raster op hook to graphics context
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43761 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -171,6 +171,7 @@ protected:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// scaling variables
|
// scaling variables
|
||||||
|
bool m_logicalFunctionSupported;
|
||||||
double m_mm_to_pix_x, m_mm_to_pix_y;
|
double m_mm_to_pix_x, m_mm_to_pix_y;
|
||||||
wxGraphicsMatrix m_matrixOriginal;
|
wxGraphicsMatrix m_matrixOriginal;
|
||||||
wxGraphicsMatrix m_matrixCurrent;
|
wxGraphicsMatrix m_matrixCurrent;
|
||||||
|
@@ -27,10 +27,6 @@
|
|||||||
#include "wx/region.h"
|
#include "wx/region.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
|
|
||||||
#define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -103,6 +99,7 @@ void wxGCDC::Init()
|
|||||||
m_brush = *wxWHITE_BRUSH;
|
m_brush = *wxWHITE_BRUSH;
|
||||||
|
|
||||||
m_graphicContext = NULL;
|
m_graphicContext = NULL;
|
||||||
|
m_logicalFunctionSupported = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -378,7 +375,7 @@ void wxGCDC::SetBrush( const wxBrush &brush )
|
|||||||
m_graphicContext->SetBrush( m_brush );
|
m_graphicContext->SetBrush( m_brush );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGCDC::SetBackground( const wxBrush &brush )
|
void wxGCDC::SetBackground( const wxBrush &brush )
|
||||||
{
|
{
|
||||||
if (m_backgroundBrush == brush)
|
if (m_backgroundBrush == brush)
|
||||||
@@ -395,17 +392,10 @@ void wxGCDC::SetLogicalFunction( int function )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_logicalFunction = function;
|
m_logicalFunction = function;
|
||||||
#if wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
|
if ( m_graphicContext->SetLogicalFunction( function ) )
|
||||||
|
m_logicalFunctionSupported=true;
|
||||||
CGContextRef cgContext = ((wxCairoContext*)(m_graphicContext))->GetNativeContext();
|
|
||||||
if ( m_logicalFunction == wxCOPY )
|
|
||||||
CGContextSetBlendMode( cgContext, kCGBlendModeNormal );
|
|
||||||
else if ( m_logicalFunction == wxINVERT )
|
|
||||||
CGContextSetBlendMode( cgContext, kCGBlendModeExclusion );
|
|
||||||
else
|
else
|
||||||
CGContextSetBlendMode( cgContext, kCGBlendModeNormal );
|
m_logicalFunctionSupported=false;
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxGCDC::DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
|
bool wxGCDC::DoFloodFill(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
|
||||||
@@ -424,11 +414,8 @@ void wxGCDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 )
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") );
|
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLine - invalid DC") );
|
||||||
|
|
||||||
#if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
|
if ( !m_logicalFunctionSupported )
|
||||||
|
|
||||||
if ( m_logicalFunction != wxCOPY )
|
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
|
|
||||||
m_graphicContext->StrokeLine(x1,y1,x2,y2);
|
m_graphicContext->StrokeLine(x1,y1,x2,y2);
|
||||||
|
|
||||||
@@ -440,7 +427,7 @@ void wxGCDC::DoCrossHair( wxCoord x, wxCoord y )
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") );
|
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoCrossHair - invalid DC") );
|
||||||
|
|
||||||
if ( m_logicalFunction != wxCOPY )
|
if ( !m_logicalFunctionSupported )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int w = 0, h = 0;
|
int w = 0, h = 0;
|
||||||
@@ -460,7 +447,7 @@ void wxGCDC::DoDrawArc( wxCoord x1, wxCoord y1,
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") );
|
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawArc - invalid DC") );
|
||||||
|
|
||||||
if ( m_logicalFunction != wxCOPY )
|
if ( !m_logicalFunctionSupported )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
double dx = x1 - xc;
|
double dx = x1 - xc;
|
||||||
@@ -505,7 +492,7 @@ void wxGCDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") );
|
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipticArc - invalid DC") );
|
||||||
|
|
||||||
if ( m_logicalFunction != wxCOPY )
|
if ( !m_logicalFunctionSupported )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool fill = m_brush.GetStyle() != wxTRANSPARENT;
|
bool fill = m_brush.GetStyle() != wxTRANSPARENT;
|
||||||
@@ -538,11 +525,8 @@ void wxGCDC::DoDrawLines(int n, wxPoint points[],
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") );
|
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawLines - invalid DC") );
|
||||||
|
|
||||||
#if !wxMAC_USE_CORE_GRAPHICS_BLEND_MODES
|
if ( !m_logicalFunctionSupported )
|
||||||
|
|
||||||
if ( m_logicalFunction != wxCOPY )
|
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
|
|
||||||
wxPoint2DDouble* pointsD = new wxPoint2DDouble[n];
|
wxPoint2DDouble* pointsD = new wxPoint2DDouble[n];
|
||||||
for( int i = 0; i < n; ++i)
|
for( int i = 0; i < n; ++i)
|
||||||
@@ -560,7 +544,7 @@ void wxGCDC::DoDrawSpline(wxList *points)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") );
|
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawSpline - invalid DC") );
|
||||||
|
|
||||||
if ( m_logicalFunction != wxCOPY )
|
if ( !m_logicalFunctionSupported )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxGraphicsPath path = m_graphicContext->CreatePath();
|
wxGraphicsPath path = m_graphicContext->CreatePath();
|
||||||
@@ -622,7 +606,7 @@ void wxGCDC::DoDrawPolygon( int n, wxPoint points[],
|
|||||||
|
|
||||||
if ( n <= 0 || (m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT ) )
|
if ( n <= 0 || (m_brush.GetStyle() == wxTRANSPARENT && m_pen.GetStyle() == wxTRANSPARENT ) )
|
||||||
return;
|
return;
|
||||||
if ( m_logicalFunction != wxCOPY )
|
if ( !m_logicalFunctionSupported )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool closeIt = false;
|
bool closeIt = false;
|
||||||
@@ -675,7 +659,7 @@ void wxGCDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRectangle - invalid DC") );
|
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRectangle - invalid DC") );
|
||||||
|
|
||||||
if ( m_logicalFunction != wxCOPY )
|
if ( !m_logicalFunctionSupported )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// CMB: draw nothing if transformed w or h is 0
|
// CMB: draw nothing if transformed w or h is 0
|
||||||
@@ -698,7 +682,7 @@ void wxGCDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") );
|
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawRoundedRectangle - invalid DC") );
|
||||||
|
|
||||||
if ( m_logicalFunction != wxCOPY )
|
if ( !m_logicalFunctionSupported )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (radius < 0.0)
|
if (radius < 0.0)
|
||||||
@@ -715,7 +699,7 @@ void wxGCDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") );
|
wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawEllipse - invalid DC") );
|
||||||
|
|
||||||
if ( m_logicalFunction != wxCOPY )
|
if ( !m_logicalFunctionSupported )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_graphicContext->DrawEllipse(x,y,w,h);
|
m_graphicContext->DrawEllipse(x,y,w,h);
|
||||||
@@ -773,7 +757,7 @@ void wxGCDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
|
|||||||
|
|
||||||
if ( str.length() == 0 )
|
if ( str.length() == 0 )
|
||||||
return;
|
return;
|
||||||
if ( m_logicalFunction != wxCOPY )
|
if ( !m_logicalFunctionSupported )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( m_backgroundMode == wxTRANSPARENT )
|
if ( m_backgroundMode == wxTRANSPARENT )
|
||||||
@@ -788,7 +772,8 @@ void wxGCDC::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
|
|||||||
|
|
||||||
if ( str.length() == 0 )
|
if ( str.length() == 0 )
|
||||||
return;
|
return;
|
||||||
if ( m_logicalFunction != wxCOPY )
|
|
||||||
|
if ( !m_logicalFunctionSupported )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( m_backgroundMode == wxTRANSPARENT )
|
if ( m_backgroundMode == wxTRANSPARENT )
|
||||||
|
@@ -495,6 +495,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxGraphicsContext, wxObject)
|
|||||||
|
|
||||||
wxGraphicsContext::wxGraphicsContext(wxGraphicsRenderer* renderer) : wxGraphicsObject(renderer)
|
wxGraphicsContext::wxGraphicsContext(wxGraphicsRenderer* renderer) : wxGraphicsObject(renderer)
|
||||||
{
|
{
|
||||||
|
m_logicalFunction = wxCOPY;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGraphicsContext::~wxGraphicsContext()
|
wxGraphicsContext::~wxGraphicsContext()
|
||||||
@@ -535,6 +536,16 @@ void wxGraphicsContext::SetFont( const wxGraphicsFont& font )
|
|||||||
m_font = font;
|
m_font = font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxGraphicsContext::SetLogicalFunction( int function )
|
||||||
|
{
|
||||||
|
if ( function == wxCOPY )
|
||||||
|
{
|
||||||
|
m_logicalFunction = function;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void wxGraphicsContext::SetFont( const wxFont& font, const wxColour& colour )
|
void wxGraphicsContext::SetFont( const wxFont& font, const wxColour& colour )
|
||||||
{
|
{
|
||||||
if ( font.Ok() )
|
if ( font.Ok() )
|
||||||
|
Reference in New Issue
Block a user