+ dc.SetBackground(*wxLIGHT_GREY);
+ dc.Clear();
+
+ dc.DrawText("Background erased in OnPaint", 65, 110);
+ }
+ else if ( GetBackgroundStyle() == wxBG_STYLE_PAINT )
+ {
+ dc.SetTextForeground(*wxRED);
+ dc.DrawText("You must enable erasing background in OnPaint to avoid "
+ "display corruption", 65, 110);
+ }
+
+ dc.SetBrush( *wxBLACK_BRUSH );
+ dc.DrawRectangle( 10,10,60,50 );
+
+ dc.DrawBitmap( m_bitmap, 20, 20, true );
+
+ dc.SetTextForeground(*wxWHITE);
+ dc.DrawText("This text is drawn from OnPaint", 65, 65);
+
+ wxString tmp;
+ tmp.Printf("Hit any key to display more text: %s", m_text);
+
+ int w,h;
+ dc.GetTextExtent( tmp, &w, &h );
+ dc.DrawRectangle( 65, 85, w, h );
+ dc.DrawText( tmp, 65, 85 );
+}
+
+void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
+{
+ if ( m_useBuffer )
+ {
+ wxAutoBufferedPaintDC dc(this);
+ PrepareDC(dc);
+
+ DoPaint(dc);
+ }
+ else
+ {
+ wxPaintDC dc(this);
+ PrepareDC(dc);
+
+ DoPaint(dc);