]> git.saurik.com Git - wxWidgets.git/commitdiff
Small correction to erase sample, added PrepareDC()
authorRobert Roebling <robert@roebling.de>
Sun, 13 Feb 2005 14:36:15 +0000 (14:36 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 13 Feb 2005 14:36:15 +0000 (14:36 +0000)
   to erase background handler.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31995 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/erase/erase.cpp

index db1a3632cc4c37fbb5a81008dff3c8b9f6131f96..932c2baccedc8b4d707382b82ee9e12a2d6ade8a 100644 (file)
@@ -198,6 +198,8 @@ MyCanvas::MyCanvas( wxFrame *parent )
     m_bitmap = wxBitmap( wxICON(mondrian) );
 
     new wxStaticBitmap( this, wxID_ANY, m_bitmap, wxPoint(80,20) );
     m_bitmap = wxBitmap( wxICON(mondrian) );
 
     new wxStaticBitmap( this, wxID_ANY, m_bitmap, wxPoint(80,20) );
+    
+    SetFocusIgnoringChildren();
 }
 
 void MyCanvas::OnChar( wxKeyEvent &event )
 }
 
 void MyCanvas::OnChar( wxKeyEvent &event )
@@ -226,7 +228,7 @@ void MyCanvas::OnChar( wxKeyEvent &event )
 void MyCanvas::DoPaint(wxDC& dc)
 {
     dc.SetBrush( *wxBLACK_BRUSH );
 void MyCanvas::DoPaint(wxDC& dc)
 {
     dc.SetBrush( *wxBLACK_BRUSH );
-    dc.DrawRectangle( 0,0,200,50 );
+    dc.DrawRectangle( 10,10,200,50 );
 
     dc.DrawBitmap( m_bitmap, 10, 20, true );
 
 
     dc.DrawBitmap( m_bitmap, 10, 20, true );
 
@@ -317,21 +319,23 @@ void MyCanvas::OnEraseBackground( wxEraseEvent& event )
     wxDC& dc = *event.GetDC();
     dc.SetPen(*wxGREEN_PEN);
 
     wxDC& dc = *event.GetDC();
     dc.SetPen(*wxGREEN_PEN);
 
+    PrepareDC( dc );
+    
     // clear any junk currently displayed
     dc.Clear();
 
     const wxSize size = GetClientSize();
     // clear any junk currently displayed
     dc.Clear();
 
     const wxSize size = GetClientSize();
-    for ( int x = 0; x < size.x; x += 10 )
+    for ( int x = 0; x < size.x; x += 15 )
     {
         dc.DrawLine(x, 0, x, size.y);
     }
 
     {
         dc.DrawLine(x, 0, x, size.y);
     }
 
-    for ( int y = 0; y < size.y; y += 10 )
+    for ( int y = 0; y < size.y; y += 15 )
     {
         dc.DrawLine(0, y, size.x, y);
     }
 
     dc.SetTextForeground(*wxRED);
     {
         dc.DrawLine(0, y, size.x, y);
     }
 
     dc.SetTextForeground(*wxRED);
-    dc.DrawText(_T("This text is drawn from OnEraseBackground"), 60, 60);
+    dc.DrawText(_T("This text is drawn from OnEraseBackground"), 60, 160);
 }
 
 }