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
This commit is contained in:
Jaakko Salli 2010-05-10 14:14:35 +00:00
parent 465642da29
commit a5e40d85a4

View File

@ -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