]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dcgraph.cpp
aui sample can now create extra notebooks
[wxWidgets.git] / src / common / dcgraph.cpp
index 5b173d0aa42804f8727f4972aac92aaf1246fb18..6a8bfab9894e020ce231cc1e0f148c40d27749f9 100644 (file)
@@ -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()
@@ -109,7 +108,18 @@ void wxGCDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool WXUNU
     wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid DC") );
     wxCHECK_RET( bmp.Ok(), wxT("wxGCDC(cg)::DoDrawBitmap - invalid bitmap") );
 
-    m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() );
+    if ( bmp.GetDepth() == 1 )
+    {
+        m_graphicContext->SetPen(*wxTRANSPARENT_PEN);
+        m_graphicContext->SetBrush( wxBrush( m_textBackgroundColour , wxSOLID ) );
+        m_graphicContext->DrawRectangle( x , y , bmp.GetWidth() , bmp.GetHeight() );        
+        m_graphicContext->SetBrush( wxBrush( m_textForegroundColour , wxSOLID ) );
+        m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() );
+        m_graphicContext->SetBrush( m_graphicContext->CreateBrush(m_brush));
+        m_graphicContext->SetPen( m_graphicContext->CreatePen(m_pen));
+    }
+    else
+        m_graphicContext->DrawBitmap( bmp, x , y , bmp.GetWidth() , bmp.GetHeight() );
 }
 
 void wxGCDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y )
@@ -298,13 +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 );
-    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) )
@@ -748,7 +762,10 @@ void wxGCDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
     if ( m_logicalFunction != wxCOPY )
         return;
 
-     m_graphicContext->DrawText( str, x ,y , DegToRad(angle ));
+    if ( m_backgroundMode == wxTRANSPARENT )
+        m_graphicContext->DrawText( str, x ,y , DegToRad(angle ));
+    else
+        m_graphicContext->DrawText( str, x ,y , DegToRad(angle ), m_graphicContext->CreateBrush( wxBrush(m_textBackgroundColour,wxSOLID) ) );
 }
 
 void wxGCDC::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
@@ -760,7 +777,10 @@ void wxGCDC::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
     if ( m_logicalFunction != wxCOPY )
         return;
 
-    m_graphicContext->DrawText( str, x ,y);
+    if ( m_backgroundMode == wxTRANSPARENT )
+        m_graphicContext->DrawText( str, x ,y);
+    else
+        m_graphicContext->DrawText( str, x ,y , m_graphicContext->CreateBrush( wxBrush(m_textBackgroundColour,wxSOLID) ) );
 }
 
 bool wxGCDC::CanGetTextExtent() const