From a5e40d85a477a366182d9364130d4c604c403092 Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Mon, 10 May 2010 14:14:35 +0000 Subject: [PATCH] Use wxGraphicsContext to draw some text and a rectangle around it (so that GetTextExtent() can be verified to work correctly) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64273 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/printing/printing.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/samples/printing/printing.cpp b/samples/printing/printing.cpp index 735b36f391..4b15b80930 100644 --- a/samples/printing/printing.cpp +++ b/samples/printing/printing.cpp @@ -234,7 +234,7 @@ void MyApp::Draw(wxDC&dc) { // make a path that contains a circle and some lines, centered at 100,100 gc->SetPen( *wxRED_PEN ); - gc->SetFont( m_testFont, *wxGREEN ); + wxGraphicsPath path = gc->CreatePath(); path.AddCircle( 50.0, 50.0, 50.0 ); path.MoveToPoint(0.0, 50.0); @@ -246,6 +246,17 @@ void MyApp::Draw(wxDC&dc) gc->StrokePath(path); + // draw some text + wxString text("This text is drawn by wxGraphicsContext"); + gc->SetFont( m_testFont, *wxBLUE ); + gc->DrawText(text, 50.0, 50.0); + + // draw rectangle around the text + double w, h, d, el; + gc->GetTextExtent(text, &w, &h, &d, &el); + gc->SetPen( *wxBLUE_PEN ); + gc->DrawRectangle(50.0, 50.0, w, h); + delete gc; } #endif -- 2.47.2