]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/erase/erase.cpp
Make TOOLKIT variable constant in MSW makefiles.
[wxWidgets.git] / samples / erase / erase.cpp
index ee468651b6d5d68dec223d3cb67e48e088e3b879..37fc81bb8870ddcdf4a444b02bde67e89b951343 100644 (file)
@@ -39,7 +39,7 @@
 // ----------------------------------------------------------------------------
 
 // the application icon
-#if !defined(__WXMSW__) && !defined(__WXPM__)
+#ifndef wxHAS_IMAGES_IN_RESOURCES
     #include "../sample.xpm"
 #endif
 
@@ -362,10 +362,16 @@ MyCanvas::MyCanvas(wxFrame *parent)
 
 void MyCanvas::DoPaint(wxDC& dc)
 {
+    PrepareDC(dc);
+
     if ( m_eraseBgInPaint )
     {
         dc.SetBackground(*wxLIGHT_GREY);
-        dc.Clear();
+
+        // Erase the entire virtual area, not just the client area.
+        dc.SetPen(*wxTRANSPARENT_PEN);
+        dc.SetBrush(GetBackgroundColour());
+        dc.DrawRectangle(GetVirtualSize());
 
         dc.DrawText("Background erased in OnPaint", 65, 110);
     }
@@ -387,15 +393,11 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
     if ( m_useBuffer )
     {
         wxAutoBufferedPaintDC dc(this);
-        PrepareDC(dc);
-
         DoPaint(dc);
     }
     else
     {
         wxPaintDC dc(this);
-        PrepareDC(dc);
-
         DoPaint(dc);
     }
 }
@@ -419,12 +421,12 @@ void MyCanvas::OnEraseBackground( wxEraseEvent& event )
     wxDC& dc = *event.GetDC();
     dc.SetPen(*wxGREEN_PEN);
 
-    PrepareDC( dc );
-
     // clear any junk currently displayed
     dc.Clear();
 
-    const wxSize size = GetClientSize();
+    PrepareDC( dc );
+
+    const wxSize size = GetVirtualSize();
     for ( int x = 0; x < size.x; x += 15 )
     {
         dc.DrawLine(x, 0, x, size.y);