+ wxPaintDC dcWin(this);
+ PrepareDC( dcWin );
+
+ if ( m_useBuffer )
+ {
+ const wxSize size = GetClientSize();
+ wxMemoryDC dc;
+ wxBitmap bmp(size.x, size.y);
+ dc.SelectObject(bmp);
+ dc.Blit(0, 0, size.x, size.y, &dcWin, 0, 0);
+ dc.DrawText(_T("(copy of background)"), 5, 120 );
+
+ DoPaint(dc);
+
+ dcWin.Blit(0, 0, size.x, size.y, &dc, 0, 0);
+ }
+ else
+ {
+ DoPaint(dcWin);
+ }
+}
+
+void MyCanvas::OnEraseBackground( wxEraseEvent& event )
+{
+ if ( !m_eraseBg )
+ {
+ event.Skip();
+ return;
+ }
+
+ wxDC& dc = *event.GetDC();
+ dc.SetPen(*wxGREEN_PEN);
+
+ PrepareDC( dc );
+
+ // clear any junk currently displayed
+ dc.Clear();
+
+ const wxSize size = GetClientSize();
+ for ( int x = 0; x < size.x; x += 15 )
+ {
+ dc.DrawLine(x, 0, x, size.y);
+ }
+
+ for ( int y = 0; y < size.y; y += 15 )
+ {
+ dc.DrawLine(0, y, size.x, y);
+ }
+
+ dc.SetTextForeground(*wxRED);
+ dc.DrawText(_T("This text is drawn from OnEraseBackground"), 60, 160);