X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f889bdb323d20a9acb0b979d62d0f45c5cd3842e..72366f68d1036084d1adc5971eeee4885f36fe5c:/src/common/dcgraph.cpp diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp index 20058b9073..d5da1bb58b 100644 --- a/src/common/dcgraph.cpp +++ b/src/common/dcgraph.cpp @@ -69,6 +69,11 @@ void wxGCDC::SetGraphicsContext( wxGraphicsContext* ctx ) { m_matrixOriginal = m_graphicContext->GetTransform(); m_ok = true; + // apply the stored transformations to the passed in context + ComputeScaleAndOrigin(); + m_graphicContext->SetFont( m_font , m_textForegroundColour ); + m_graphicContext->SetPen( m_pen ); + m_graphicContext->SetBrush( m_brush); } } @@ -76,12 +81,6 @@ wxGCDC::wxGCDC(const wxWindowDC& dc) { Init(); SetGraphicsContext( wxGraphicsContext::Create(dc) ); - if ( dc.GetFont().Ok()) - m_graphicContext->SetFont( m_graphicContext->CreateFont(dc.GetFont(),dc.GetTextForeground())); - if ( dc.GetPen().Ok()) - m_graphicContext->SetPen( m_graphicContext->CreatePen(dc.GetPen())); - if ( dc.GetBrush().Ok()) - m_graphicContext->SetBrush( m_graphicContext->CreateBrush(dc.GetBrush())); } void wxGCDC::Init() @@ -309,14 +308,17 @@ void wxGCDC::ComputeScaleAndOrigin() m_scaleX = m_logicalScaleX * m_userScaleX; m_scaleY = m_logicalScaleY * m_userScaleY; - m_matrixCurrent = m_graphicContext->CreateMatrix(); - m_matrixCurrent.Translate( m_deviceOriginX, m_deviceOriginY ); - m_matrixCurrent.Scale( m_scaleX, m_scaleY ); - // 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 ); + if ( m_graphicContext ) + { + m_matrixCurrent = m_graphicContext->CreateMatrix(); + m_matrixCurrent.Translate( m_deviceOriginX, m_deviceOriginY ); + m_matrixCurrent.Scale( m_scaleX, m_scaleY ); + // 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 ); + } } void wxGCDC::SetPalette( const wxPalette& WXUNUSED(palette) )