+ // ----------------------------
+
+ MyFrame* frame = new MyFrame((wxFrame *) NULL, wxT("wxWidgets Printing Demo"),
+ wxPoint(0, 0), wxSize(400, 400));
+
+ frame->Centre(wxBOTH);
+ frame->Show();
+
+ SetTopWindow(frame);
+
+ return true;
+}
+
+int MyApp::OnExit()
+{
+ delete g_printData;
+ delete g_pageSetupData;
+
+ return wxApp::OnExit();
+}
+
+void MyApp::Draw(wxDC&dc)
+{
+ // This routine just draws a bunch of random stuff on the screen so that we
+ // can check that different types of object are being drawn consistently
+ // between the screen image, the print preview image (at various zoom
+ // levels), and the printed page.
+ dc.SetBackground(*wxWHITE_BRUSH);
+ // dc.Clear();
+ dc.SetFont(m_testFont);
+
+ // dc.SetBackgroundMode(wxTRANSPARENT);
+
+ 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.SetBrush(*wxTRANSPARENT_BRUSH);
+
+ dc.SetBrush(*wxCYAN_BRUSH);
+ dc.SetPen(*wxRED_PEN);
+
+ dc.DrawRoundedRectangle(0, 20, 200, 80, 20);
+
+ dc.DrawText( wxT("Rectangle 200 by 80"), 40, 40);
+
+ dc.SetPen( wxPen(*wxBLACK,0,wxDOT_DASH) );
+ dc.DrawEllipse(50, 140, 100, 50);
+ dc.SetPen(*wxRED_PEN);
+
+ dc.DrawText( wxT("Test message: this is in 10 point text"), 10, 180);
+
+#if wxUSE_UNICODE
+ const char *test = "Hebrew שלום -- Japanese (日本語)";
+ wxString tmp = wxConvUTF8.cMB2WC( test );
+ dc.DrawText( tmp, 10, 200 );
+#endif
+
+ wxPoint points[5];
+ points[0].x = 0;
+ points[0].y = 0;
+ points[1].x = 20;
+ points[1].y = 0;
+ points[2].x = 20;
+ points[2].y = 20;
+ points[3].x = 10;
+ points[3].y = 20;
+ points[4].x = 10;
+ points[4].y = -20;
+ dc.DrawPolygon( 5, points, 20, 250, wxODDEVEN_RULE );
+ dc.DrawPolygon( 5, points, 50, 250, wxWINDING_RULE );
+
+ dc.DrawEllipticArc( 80, 250, 60, 30, 0.0, 270.0 );
+
+ points[0].x = 150;
+ points[0].y = 250;
+ points[1].x = 180;
+ points[1].y = 250;
+ points[2].x = 180;
+ points[2].y = 220;
+ points[3].x = 200;
+ points[3].y = 220;
+ dc.DrawSpline( 4, points );
+
+ dc.DrawArc( 20,10, 10,10, 25,40 );
+
+ wxString str;
+ int i = 0;
+ str.Printf( wxT("---- Text at angle %d ----"), i );
+ dc.DrawRotatedText( str, 100, 300, i );
+
+ i = m_angle;
+ str.Printf( wxT("---- Text at angle %d ----"), i );
+ dc.DrawRotatedText( str, 100, 300, i );
+
+ wxIcon my_icon = wxICON(sample);
+
+ dc.DrawIcon( my_icon, 100, 100);
+
+ if (m_bitmap.IsOk())
+ dc.DrawBitmap( m_bitmap, 10, 10 );
+
+#if wxUSE_GRAPHICS_CONTEXT
+ wxGraphicsContext *gc = NULL;
+
+ wxPrinterDC *printer_dc = wxDynamicCast( &dc, wxPrinterDC );
+ if (printer_dc)
+ gc = wxGraphicsContext::Create( *printer_dc );
+
+ wxWindowDC *window_dc = wxDynamicCast( &dc, wxWindowDC );
+ if (window_dc)
+ gc = wxGraphicsContext::Create( *window_dc );
+
+#ifdef __WXMSW__
+ wxEnhMetaFileDC *emf_dc = wxDynamicCast( &dc, wxEnhMetaFileDC );
+ if (emf_dc)
+ gc = wxGraphicsContext::Create( *emf_dc );
+#endif
+
+ 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);
+
+ // draw some text
+ wxString text("Text by wxGraphicsContext");
+ gc->SetFont( m_testFont, *wxBLACK );
+ gc->DrawText(text, 25.0, 60.0);
+
+ // draw rectangle around the text
+ double w, h, d, el;
+ gc->GetTextExtent(text, &w, &h, &d, &el);
+ gc->SetPen( *wxBLACK_PEN );
+ gc->DrawRectangle(25.0, 60.0, w, h);
+
+ delete gc;
+ }
+#endif
+}
+
+
+// ----------------------------------------------------------------------------
+// MyFrame
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+ EVT_MENU(wxID_EXIT, MyFrame::OnExit)
+ EVT_MENU(wxID_PRINT, MyFrame::OnPrint)
+ EVT_MENU(wxID_PREVIEW, MyFrame::OnPrintPreview)
+ EVT_MENU(WXPRINT_PAGE_SETUP, MyFrame::OnPageSetup)
+ EVT_MENU(wxID_ABOUT, MyFrame::OnPrintAbout)
+#if defined(__WXMSW__) &&wxTEST_POSTSCRIPT_IN_MSW
+ EVT_MENU(WXPRINT_PRINT_PS, MyFrame::OnPrintPS)
+ EVT_MENU(WXPRINT_PREVIEW_PS, MyFrame::OnPrintPreviewPS)
+ EVT_MENU(WXPRINT_PAGE_SETUP_PS, MyFrame::OnPageSetupPS)
+#endif
+#ifdef __WXMAC__
+ EVT_MENU(WXPRINT_PAGE_MARGINS, MyFrame::OnPageMargins)
+#endif
+ EVT_MENU(WXPRINT_ANGLEUP, MyFrame::OnAngleUp)
+ EVT_MENU(WXPRINT_ANGLEDOWN, MyFrame::OnAngleDown)
+END_EVENT_TABLE()
+
+MyFrame::MyFrame(wxFrame *frame, const wxString&title, const wxPoint&pos, const wxSize&size)
+ : wxFrame(frame, wxID_ANY, title, pos, size)
+{
+ m_canvas = NULL;