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:
@@ -234,7 +234,7 @@ void MyApp::Draw(wxDC&dc)
|
|||||||
{
|
{
|
||||||
// make a path that contains a circle and some lines, centered at 100,100
|
// make a path that contains a circle and some lines, centered at 100,100
|
||||||
gc->SetPen( *wxRED_PEN );
|
gc->SetPen( *wxRED_PEN );
|
||||||
gc->SetFont( m_testFont, *wxGREEN );
|
|
||||||
wxGraphicsPath path = gc->CreatePath();
|
wxGraphicsPath path = gc->CreatePath();
|
||||||
path.AddCircle( 50.0, 50.0, 50.0 );
|
path.AddCircle( 50.0, 50.0, 50.0 );
|
||||||
path.MoveToPoint(0.0, 50.0);
|
path.MoveToPoint(0.0, 50.0);
|
||||||
@@ -246,6 +246,17 @@ void MyApp::Draw(wxDC&dc)
|
|||||||
|
|
||||||
gc->StrokePath(path);
|
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;
|
delete gc;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user