X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c4218a74033e3091a3566c9c6619809a00b53744..b771aa29dd34686cc92ef4675978b1fdc1a47a29:/samples/drawing/drawing.cpp diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index 84d05d3412..0e8f8ee757 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -43,7 +43,7 @@ // ---------------------------------------------------------------------------- // the application icon -#if defined(__WXGTK__) || defined(__WXMOTIF__) +#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) #include "mondrian.xpm" #endif @@ -159,6 +159,8 @@ protected: void DrawCircles(wxDC& dc); void DrawDefault(wxDC& dc); + void DrawRegionsHelper(wxDC& dc, wxCoord x); + private: MyFrame *m_owner; @@ -988,35 +990,49 @@ void MyCanvas::DrawRegions(wxDC& dc) dc.DrawText("You should see a red rect partly covered by a cyan one " "on the left", 10, 5); dc.DrawText("and 5 smileys from which 4 are partially clipped on the " - "right", 10, 5 + dc.GetCharHeight()); + "right (2 copies should be identical)", + 10, 5 + dc.GetCharHeight()); + + DrawRegionsHelper(dc, 10); + DrawRegionsHelper(dc, 350); +} +void MyCanvas::DrawRegionsHelper(wxDC& dc, wxCoord x) +{ + dc.DestroyClippingRegion(); dc.SetBrush( *wxWHITE_BRUSH ); dc.SetPen( *wxTRANSPARENT_PEN ); - dc.DrawRectangle( 10,50,310,310 ); + dc.DrawRectangle( x,50,310,310 ); - dc.SetClippingRegion( 20,60,100,270 ); + dc.SetClippingRegion( x+10,60,100,270 ); dc.SetBrush( *wxRED_BRUSH ); - dc.DrawRectangle( 10,50,310,310 ); + dc.DrawRectangle( x,50,310,310 ); - dc.SetClippingRegion( 20,60,100,100 ); + dc.SetClippingRegion( x+10,60,100,100 ); dc.SetBrush( *wxCYAN_BRUSH ); - dc.DrawRectangle( 10,50,310,310 ); + dc.DrawRectangle( x,50,310,310 ); - dc.DestroyClippingRegion(); - dc.SetClippingRegion( 120,70,100,270 ); + // when drawing the left half, destroy the clipping region, when drawing + // the right one - leave it + // + // normally it shouldn't make any difference as SetClippingRegion() + // replaces the old clipping region + if ( x < 300 ) + dc.DestroyClippingRegion(); + dc.SetClippingRegion( x+110,70,100,270 ); dc.SetBrush( *wxGREY_BRUSH ); - dc.DrawRectangle( 10,50,310,310 ); + dc.DrawRectangle( x,50,310,310 ); if (m_smile_bmp.Ok()) { - dc.DrawBitmap( m_smile_bmp, 160, 200, TRUE ); - dc.DrawBitmap( m_smile_bmp, 140, 60, TRUE ); - dc.DrawBitmap( m_smile_bmp, 140, 330, TRUE ); - dc.DrawBitmap( m_smile_bmp, 110, 120, TRUE ); - dc.DrawBitmap( m_smile_bmp, 210, 120, TRUE ); + dc.DrawBitmap( m_smile_bmp, x+150, 200, TRUE ); + dc.DrawBitmap( m_smile_bmp, x+130, 60, TRUE ); + dc.DrawBitmap( m_smile_bmp, x+130, 330, TRUE ); + dc.DrawBitmap( m_smile_bmp, x+100, 120, TRUE ); + dc.DrawBitmap( m_smile_bmp, x+200, 120, TRUE ); } }