]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dcgraph.cpp
I think the "specific to PostScript" methods have been gone since 2.6, so let's stop...
[wxWidgets.git] / src / common / dcgraph.cpp
index 427ef4ab311cb17414e379e64221c3046760443e..3b49dce031cac84073b59f4d6c920eba148ad99b 100644 (file)
@@ -38,6 +38,8 @@
 #endif
 #endif
 
+#include <limits.h>     // for INT_MAX
+
 //-----------------------------------------------------------------------------
 // constants
 //-----------------------------------------------------------------------------
@@ -155,7 +157,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxGCDCImpl, wxDCImpl)
 wxGCDCImpl::wxGCDCImpl( wxDC *owner ) :
    wxDCImpl( owner )
 {
-    Init();
+    Init(wxGraphicsContext::Create());
 }
 
 void wxGCDCImpl::SetGraphicsContext( wxGraphicsContext* ctx )
@@ -177,26 +179,21 @@ void wxGCDCImpl::SetGraphicsContext( wxGraphicsContext* ctx )
 wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxWindowDC& dc ) :
    wxDCImpl( owner )
 {
-    Init();
-    SetGraphicsContext( wxGraphicsContext::Create(dc) );
+    Init(wxGraphicsContext::Create(dc));
     m_window = dc.GetWindow();
 }
 
 wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxMemoryDC& dc ) :
    wxDCImpl( owner )
 {
-    Init();
-    wxGraphicsContext* context;
-    context = wxGraphicsContext::Create(dc);
-    SetGraphicsContext( context );
+    Init(wxGraphicsContext::Create(dc));
 }
 
 #if wxUSE_PRINTING_ARCHITECTURE
 wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxPrinterDC& dc ) :
    wxDCImpl( owner )
 {
-    Init();
-    SetGraphicsContext( wxGraphicsContext::Create(dc) );
+    Init(wxGraphicsContext::Create(dc));
 }
 #endif
 
@@ -204,12 +201,18 @@ wxGCDCImpl::wxGCDCImpl( wxDC *owner, const wxPrinterDC& dc ) :
 wxGCDCImpl::wxGCDCImpl(wxDC *owner, const wxEnhMetaFileDC& dc)
    : wxDCImpl(owner)
 {
-    Init();
-    SetGraphicsContext(wxGraphicsContext::Create(dc));
+    Init(wxGraphicsContext::Create(dc));
 }
 #endif
 
-void wxGCDCImpl::Init()
+wxGCDCImpl::wxGCDCImpl(wxDC* owner, int)
+   : wxDCImpl(owner)
+{
+    // derived class will set a context
+    Init(NULL);
+}
+
+void wxGCDCImpl::Init(wxGraphicsContext* ctx)
 {
     m_ok = false;
     m_colour = true;
@@ -220,11 +223,13 @@ void wxGCDCImpl::Init()
     m_font = *wxNORMAL_FONT;
     m_brush = *wxWHITE_BRUSH;
 
-    m_graphicContext = wxGraphicsContext::Create();
+    m_graphicContext = NULL;
+    if (ctx)
+        SetGraphicsContext(ctx);
+
     m_logicalFunctionSupported = true;
 }
 
-
 wxGCDCImpl::~wxGCDCImpl()
 {
     delete m_graphicContext;
@@ -399,35 +404,6 @@ void wxGCDCImpl::SetTextBackground( const wxColour &col )
     m_textBackgroundColour = col;
 }
 
-void wxGCDCImpl::SetMapMode( wxMappingMode mode )
-{
-    switch (mode)
-    {
-    case wxMM_TWIPS:
-        SetLogicalScale( twips2mm * m_mm_to_pix_x, twips2mm * m_mm_to_pix_y );
-        break;
-
-    case wxMM_POINTS:
-        SetLogicalScale( pt2mm * m_mm_to_pix_x, pt2mm * m_mm_to_pix_y );
-        break;
-
-    case wxMM_METRIC:
-        SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
-        break;
-
-    case wxMM_LOMETRIC:
-        SetLogicalScale( m_mm_to_pix_x / 10.0, m_mm_to_pix_y / 10.0 );
-        break;
-
-    case wxMM_TEXT:
-    default:
-        SetLogicalScale( 1.0, 1.0 );
-        break;
-    }
-
-    ComputeScaleAndOrigin();
-}
-
 wxSize wxGCDCImpl::GetPPI() const
 {
     return wxSize(72, 72);
@@ -472,10 +448,7 @@ void wxGCDCImpl::SetFont( const wxFont &font )
     m_font = font;
     if ( m_graphicContext )
     {
-        wxFont f = font;
-        if ( f.IsOk() )
-            f.SetPointSize( /*LogicalToDeviceYRel*/(font.GetPointSize()));
-        m_graphicContext->SetFont( f, m_textForegroundColour );
+        m_graphicContext->SetFont(font, m_textForegroundColour);
     }
 }
 
@@ -1077,7 +1050,7 @@ void wxGCDCImpl::Clear(void)
     m_graphicContext->SetPen( p );
     wxCompositionMode formerMode = m_graphicContext->GetCompositionMode();
     m_graphicContext->SetCompositionMode(wxCOMPOSITION_SOURCE);
-    DoDrawRectangle( 0, 0, 32000 , 32000 );
+    DoDrawRectangle( 0, 0, INT_MAX , INT_MAX );
     m_graphicContext->SetCompositionMode(formerMode);
     m_graphicContext->SetPen( m_pen );
     m_graphicContext->SetBrush( m_brush );