]> git.saurik.com Git - wxWidgets.git/commitdiff
Some testing code for wxGraphicsContext printing
authorRobert Roebling <robert@roebling.de>
Fri, 25 Apr 2008 18:50:27 +0000 (18:50 +0000)
committerRobert Roebling <robert@roebling.de>
Fri, 25 Apr 2008 18:50:27 +0000 (18:50 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53357 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

interface/graphics.h
samples/printing/printing.cpp

index 5d973ec52b1d726b0b224554ae6b4285203b8768..a701b38bca3484cd4ee87418a7a1e12184510d02 100644 (file)
@@ -205,17 +205,24 @@ public:
         // Create graphics context from it
         wxGraphicsContext *gc = dc.CreateGraphicsContext();
     
         // Create graphics context from it
         wxGraphicsContext *gc = dc.CreateGraphicsContext();
     
-        // make a path that contains a circle and some lines, centered at 100,100
-        wxGraphicsPath path = gc->CreatePath();
-        path.AddCircle( 0.0, 0.0, 100.0 );
-        path.MoveToPoint(0.0, -100.0);
-        path.AddLineToPoint(0.0, 100.0);
-        path.MoveToPoint(-100.0, 0.0);
-        path.AddLineToPoint(100.0, 0);
-        path.CloseSubpath();
-        path.AddRectangle(-50.0, -25.0, 100.0, 50.0);
+        if (gc)
+        {
+            // make a path that contains a circle and some lines, centered at 100,100
+            gc->SetPen( *wxRED_PEN );
+            wxGraphicsPath path = gc->CreatePath();
+            path.AddCircle( 50.0, 50.0, 50.0 );
+            path.MoveToPoint(0.0, 50.0);
+            path.AddLineToPoint(100.0, 50.0);
+            path.MoveToPoint(50.0, 0.0);
+            path.AddLineToPoint(50.0, 100.0 );
+            path.CloseSubpath();
+            path.AddRectangle(25.0, 25.0, 50.0, 50.0);
         
         
-        delete gc;
+           gc->StrokePath(path);
+        
+           delete gc;
+        }
+    }
     @endcode
 
 
     @endcode
 
 
index c424da9b466d0911ecd4cf8dcb241d9c35b937a2..536702e351ddcf9de9e94ed70c5241f4a83c0330 100644 (file)
 #include "wx/generic/prntdlgg.h"
 #endif
 
 #include "wx/generic/prntdlgg.h"
 #endif
 
+#if wxUSE_GRAPHICS_CONTEXT
+#include "wx/graphics.h"
+#endif
+
 #ifdef __WXMAC__
 #include "wx/mac/printdlg.h"
 #endif
 #ifdef __WXMAC__
 #include "wx/mac/printdlg.h"
 #endif
@@ -338,6 +342,7 @@ void MyFrame::Draw(wxDC& dc)
 
     dc.SetPen(*wxBLACK_PEN);
     dc.SetBrush(*wxLIGHT_GREY_BRUSH);
 
     dc.SetPen(*wxBLACK_PEN);
     dc.SetBrush(*wxLIGHT_GREY_BRUSH);
+    
     dc.DrawRectangle(0, 0, 230, 350);
     dc.DrawLine(0, 0, 229, 349);
     dc.DrawLine(229, 0, 0, 349);
     dc.DrawRectangle(0, 0, 230, 350);
     dc.DrawLine(0, 0, 229, 349);
     dc.DrawLine(229, 0, 0, 349);
@@ -357,7 +362,7 @@ void MyFrame::Draw(wxDC& dc)
     dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180);
     
 #if wxUSE_UNICODE
     dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180);
     
 #if wxUSE_UNICODE
-    char *test = "Hebrew    שלום -- Japanese (日本語)";
+    const char *test = "Hebrew    שלום -- Japanese (日本語)";
     wxString tmp = wxConvUTF8.cMB2WC( test );
     dc.DrawText( tmp, 10, 200 );
 #endif
     wxString tmp = wxConvUTF8.cMB2WC( test );
     dc.DrawText( tmp, 10, 200 );
 #endif
@@ -405,6 +410,28 @@ void MyFrame::Draw(wxDC& dc)
 
     if (m_bitmap.Ok())
         dc.DrawBitmap( m_bitmap, 10, 10 );
 
     if (m_bitmap.Ok())
         dc.DrawBitmap( m_bitmap, 10, 10 );
+
+#if wxUSE_GRAPHICS_CONTEXT
+    wxGraphicsContext *gc = dc.CreateGraphicsContext();
+    if (gc)
+    {
+        // make a path that contains a circle and some lines, centered at 100,100
+        gc->SetPen( *wxRED_PEN );
+        wxGraphicsPath path = gc->CreatePath();
+        path.AddCircle( 50.0, 50.0, 50.0 );
+        path.MoveToPoint(0.0, 50.0);
+        path.AddLineToPoint(100.0, 50.0);
+        path.MoveToPoint(50.0, 0.0);
+        path.AddLineToPoint(50.0, 100.0 );
+        path.CloseSubpath();
+        path.AddRectangle(25.0, 25.0, 50.0, 50.0);
+        
+        gc->StrokePath(path);
+        
+        delete gc;
+    }
+#endif
+
 }
 
 void MyFrame::OnSize(wxSizeEvent& event )
 }
 
 void MyFrame::OnSize(wxSizeEvent& event )