wxGraphicsContex Text Drawing
Posted: Wed Aug 30, 2017 5:14 am
Hello,
I am writing a custom control & using & wxBufferedPaintDC & wxGraphicsContext for it. I am able to draw rectangles, lines, circle etc. & its works as expected. But unable to draw the text. Nothing appears at all.
I am using wxWidgets 3.0.3 & Code::Blocks/mingw
I also tried the same code with wxPython 4.0.0b1 which works just fine.
If I disable wxGraphicsContext with C++, everything again works fine, including drawing text.
Any help would be highly appreciated.
TIA,
sam_des
I am writing a custom control & using & wxBufferedPaintDC & wxGraphicsContext for it. I am able to draw rectangles, lines, circle etc. & its works as expected. But unable to draw the text. Nothing appears at all.
I am using wxWidgets 3.0.3 & Code::Blocks/mingw
Code: Select all
void PlotWidget::DrawBackground( wxBufferedDC* dc )
{
wxGraphicsContext* gc = wxGraphicsContext::Create( *dc );
wxRect rc = GetClientRect();
gc->SetBrush( wxBrush(m_WidgetBkColor) );
gc->SetPen( wxPen(m_WidgetBkColor, 1, wxSOLID) );
gc->DrawRectangle( rc.x, rc.y, rc.width, rc.height );
// This works as expected
gc->SetFont( m_PlotLabelFont, m_PlotLabelColor );
// these are wxFont & wxColour class members, initialized elsewhere
// Creating a font & colour explicitly here also doesn't work either
gc->DrawText( _("SOME TEXT"), rc.width/2, rc.height/2 );
delete gc;
}
If I disable wxGraphicsContext with C++, everything again works fine, including drawing text.
Any help would be highly appreciated.
TIA,
sam_des