X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9e15c94f41c8cdf42470d318269e48e90d6ba75e..79f82e1f664dd17fd1682637911bd5a9ade455c2:/src/common/dcgraph.cpp?ds=sidebyside diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index de8f07b3fb..c0bcd97b1a 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -3,7 +3,7 @@ // Purpose: graphics context methods common to all platforms // Author: Stefan Csomor // Modified by: -// Created: +// Created: // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence @@ -27,6 +27,10 @@ #include "wx/region.h" #endif +#ifndef wxMAC_USE_CORE_GRAPHICS_BLEND_MODES + #define wxMAC_USE_CORE_GRAPHICS_BLEND_MODES 0 +#endif + //----------------------------------------------------------------------------- // constants //----------------------------------------------------------------------------- @@ -58,18 +62,20 @@ wxGCDC::wxGCDC() } void wxGCDC::SetGraphicsContext( wxGraphicsContext* ctx ) -{ +{ delete m_graphicContext; m_graphicContext = ctx; - m_matrixOriginal = m_graphicContext->GetTransform(); + if ( m_graphicContext ) + { + m_matrixOriginal = m_graphicContext->GetTransform(); + m_ok = true; + } } wxGCDC::wxGCDC(const wxWindowDC& dc) { Init(); - m_graphicContext = wxGraphicsContext::Create(dc); - m_matrixOriginal = m_graphicContext->GetTransform(); - m_ok = true; + SetGraphicsContext( wxGraphicsContext::Create(dc) ); if ( dc.GetFont().Ok()) m_graphicContext->SetFont( m_graphicContext->CreateFont(dc.GetFont(),dc.GetTextForeground())); if ( dc.GetPen().Ok()) @@ -295,8 +301,9 @@ void wxGCDC::ComputeScaleAndOrigin() m_matrixCurrent = m_graphicContext->CreateMatrix(); m_matrixCurrent.Translate( m_deviceOriginX, m_deviceOriginY ); m_matrixCurrent.Scale( m_scaleX, m_scaleY ); - m_matrixCurrent.Translate( m_logicalOriginX, m_logicalOriginY ); - + // the logical origin sets the origin to have new coordinates + m_matrixCurrent.Translate( -m_logicalOriginX, -m_logicalOriginY ); + m_graphicContext->SetTransform( m_matrixOriginal ); m_graphicContext->ConcatTransform( m_matrixCurrent ); } @@ -699,7 +706,7 @@ bool wxGCDC::DoBlit( { wxCHECK_MSG( Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid DC") ); wxCHECK_MSG( source->Ok(), false, wxT("wxGCDC(cg)::DoBlit - invalid source DC") ); - + if ( logical_func == wxNO_OP ) return true; else if ( logical_func != wxCOPY ) @@ -714,59 +721,11 @@ bool wxGCDC::DoBlit( ysrcMask = ysrc; } - wxCoord yysrc = source-> LogicalToDeviceY(ysrc); - wxCoord xxsrc = source-> LogicalToDeviceX(xsrc); - wxCoord wwsrc = source-> LogicalToDeviceXRel(width); - wxCoord hhsrc = source-> LogicalToDeviceYRel(height); - - wxBitmap blit; - wxMemoryDC* memdc = wxDynamicCast(source,wxMemoryDC); - if ( memdc ) - { - blit = memdc->GetSelectedBitmap(); - - wxASSERT_MSG( blit.Ok() , wxT("Invalid bitmap for blitting") ); + wxRect subrect(source-> LogicalToDeviceX(xsrc),source-> LogicalToDeviceY(ysrc), + source-> LogicalToDeviceXRel(width),source-> LogicalToDeviceYRel(height)); - wxCoord bmpwidth = blit.GetWidth(); - wxCoord bmpheight = blit.GetHeight(); + wxBitmap blit = source->GetAsBitmap( &subrect ); - if ( xxsrc != 0 || yysrc != 0 || bmpwidth != wwsrc || bmpheight != hhsrc ) - { - wwsrc = wxMin( wwsrc , bmpwidth - xxsrc ); - hhsrc = wxMin( hhsrc , bmpheight - yysrc ); - if ( wwsrc > 0 && hhsrc > 0 ) - { - if ( xxsrc >= 0 && yysrc >= 0 ) - { - wxRect subrect( xxsrc, yysrc, wwsrc , hhsrc ); - // TODO we perhaps could add a DrawSubBitmap call to dc for performance reasons - blit = blit.GetSubBitmap( subrect ); - } - else - { - // in this case we'd probably have to adjust the different coordinates, but - // we have to find out proper contract first - blit = wxNullBitmap; - } - } - else - { - blit = wxNullBitmap; - } - } - } - else - { - wxWindowDC* windc = wxDynamicCast(source,wxWindowDC); - if (windc) - { - wxBitmap bmp; - bmp = windc->GetAsBitmap(); - if (bmp.IsOk()) - blit = bmp.GetSubBitmap( wxRect(xsrc, ysrc, width, height ) ); - } - } - if ( blit.Ok() ) { m_graphicContext->DrawBitmap( blit, xdest , ydest , width , height ); @@ -828,13 +787,13 @@ void wxGCDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *heig m_graphicContext->GetTextExtent( str, &w, &h, &d, &e ); if ( height ) - *height = h; + *height = (wxCoord)h; if ( descent ) - *descent = d; + *descent = (wxCoord)d; if ( externalLeading ) - *externalLeading =e; + *externalLeading = (wxCoord)e; if ( width ) - *width = w; + *width = (wxCoord)w; if ( theFont ) { @@ -883,7 +842,7 @@ void wxGCDC::Clear(void) wxPen p = *wxTRANSPARENT_PEN; m_graphicContext->SetPen( p ); DoDrawRectangle( 0, 0, 32000 , 32000 ); - m_graphicContext->SetPen( m_pen ); + m_graphicContext->SetPen( m_pen ); m_graphicContext->SetBrush( m_brush ); }