wxDC* dc = ... ; // get a device context somehow wxRect clipRect(10, 10, 100, 100); dc->SetClippingRegion(clipRect); // Now all drawing operations will be limited to the rectangle (10, 10, 100, 100)
wxDC* dc = ... ; // get a device context somehow wxRegion clipRegion; clipRegion.Union(wxRect(10, 10, 50, 50)); clipRegion.Union(wxRect(50, 50, 100, 100)); dc->SetClippingRegion(clipRegion); // Now all drawing operations will be limited to the two rectangles unioned togetherIn this example, we create a wxRegion object to represent an arbitrary clipping region consisting of the union of two rectangles. We use the Union method of the region object to combine the two rectangles into a single region, and then pass it to SetClippingRegion to set it as the active clipping region. Package/Library: wxWidgets (a.k.a. wxWindows) C++ library.