X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/da249bc35920bd7781f3d2284004fd5162c27670..16bf3190407e402c8c40d3eed43c42f52f297684:/samples/printing/printing.cpp diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index c424da9b46..0b4c31accc 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -40,6 +40,10 @@ #include "wx/generic/prntdlgg.h" #endif +#if wxUSE_GRAPHICS_CONTEXT +#include "wx/graphics.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.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 - char *test = "Hebrew שלום -- Japanese (日本語)"; + const char *test = "Hebrew שלום -- Japanese (日本語)"; wxString tmp = wxConvUTF8.cMB2WC( test ); dc.DrawText( tmp, 10, 200 ); #endif @@ -405,6 +410,38 @@ void MyFrame::Draw(wxDC& dc) if (m_bitmap.Ok()) 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 ); + + if (gc) + { + // make a path that contains a circle and some lines, centered at 100,100 + gc->SetPen( *wxRED_PEN ); + gc->SetFont( wxGetApp().m_testFont, *wxGREEN ); + 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 )