X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/33611ebbd99217ef90f1178eed37e30385c121de..644231539d2ccf9ef873060154079f33ba7a42db:/samples/erase/erase.cpp diff --git a/samples/erase/erase.cpp b/samples/erase/erase.cpp index 8162f96f6f..d9f5cfc041 100644 --- a/samples/erase/erase.cpp +++ b/samples/erase/erase.cpp @@ -18,8 +18,8 @@ // ---------------------------------------------------------------------------- #ifdef __GNUG__ - #pragma implementation "minimal.cpp" - #pragma interface "minimal.cpp" + #pragma implementation "erase.cpp" + #pragma interface "erase.cpp" #endif // For compilers that support precompilation, includes "wx/wx.h". @@ -39,7 +39,7 @@ // resources // ---------------------------------------------------------------------------- // the application icon -#if defined(__WXGTK__) || defined(__WXMOTIF__) +#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__) #include "mondrian.xpm" #endif @@ -74,6 +74,8 @@ public: void OnPaint( wxPaintEvent &event ); void OnEraseBackground( wxEraseEvent &event ); + + wxBitmap m_bitmap; private: DECLARE_EVENT_TABLE() @@ -157,10 +159,10 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { wxString msg; - msg.Printf( _T("This is the about dialog of minimal sample.\n") + msg.Printf( _T("This is the about dialog of the Erase sample.\n") _T("Welcome to %s"), wxVERSION_STRING); - wxMessageBox(msg, "About Minimal", wxOK | wxICON_INFORMATION, this); + wxMessageBox(msg, "About Erase", wxOK | wxICON_INFORMATION, this); } @@ -171,9 +173,13 @@ END_EVENT_TABLE() MyCanvas::MyCanvas( MyFrame *parent ) : wxScrolledWindow( parent, -1, wxDefaultPosition, wxDefaultSize, - wxScrolledWindowStyle|wxNO_FULL_REPAINT_ON_RESIZE ) + wxScrolledWindowStyle|wxNO_FULL_REPAINT_ON_RESIZE|wxSUNKEN_BORDER ) { SetScrollbars( 10, 10, 40, 100, 0, 0 ); + + m_bitmap = wxBitmap( mondrian_xpm ); + + new wxStaticBitmap( this, -1, m_bitmap, wxPoint(80,20) ); } void MyCanvas::OnPaint( wxPaintEvent &event ) @@ -181,8 +187,54 @@ void MyCanvas::OnPaint( wxPaintEvent &event ) wxPaintDC dc(this); PrepareDC( dc ); + dc.SetBrush( *wxBLACK_BRUSH ); + dc.DrawRectangle( 0,0,200,50 ); + + dc.DrawBitmap( m_bitmap, 10, 20, TRUE ); + +#if 0 + wxRegionIterator upd( GetUpdateRegion() ); + while (upd) + { + wxLogDebug( "Paint: %d %d %d %d", upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() ); + upd ++; + } +#endif + +#if 0 + wxSize size = GetSize(); + wxSize client_size = GetClientSize(); + wxLogDebug( "size %d %d client_size %d %d", size.x, size.y, client_size.x, client_size.y ); +#endif + + int i; + dc.SetPen( *wxWHITE_PEN ); + for (i = 0; i < 20; i += 2) + dc.DrawLine( i,i, i+100,i ); + + dc.SetPen( *wxWHITE_PEN ); + for (i = 200; i < 220; i += 2) + dc.DrawLine( i-200,i, i-100,i ); + + wxRegion region( 110, 110, 80, 80 ); + wxRegion hole( 130, 130, 40, 1 ); + region.Intersect( hole ); + dc.SetClippingRegion( region ); + dc.SetBrush( *wxRED_BRUSH ); - dc.DrawRectangle( 100, 100, 300, 500 ); + dc.DrawRectangle( 100, 100, 200, 200 ); + + dc.DestroyClippingRegion(); + + dc.SetPen( *wxTRANSPARENT_PEN ); + + wxRegion strip( 110, 200, 30, 1 ); + wxRegionIterator it( strip ); + while (it) + { + dc.DrawRectangle( it.GetX(), it.GetY(), it.GetWidth(), it.GetHeight() ); + it ++; + } } void MyCanvas::OnEraseBackground( wxEraseEvent &event )