Invalid clipping region after call to wxPaintDC::DestroyClippingRegion() on wxGTK3 (Issue #23046)

16 views
Skip to first unread message

AW

unread,
Dec 18, 2022, 2:33:24 PM12/18/22
to wx-...@googlegroups.com, Subscribed

Description

When logical coordinates of wxPaintDC (under wxGTK3) are changed with transformation matrix (with SetTransformMatrix()), clipping region is invalid after call toDestroyClippingRegion() .
This issue is not seen when logical coordinates are changed with other functions, like SetDeviceOrigin(), SetUserScale(), SetLogicalOrigin(), etc.

Clipping region after call to SetTransformMatrix():
wxGTK_clip_invalid
Reported coordinates of clipping region:

Debug: Invalid position: Actual: (0, 0)  Expected: (-20, -25)
Debug: Invalid size: Actual: 180 x 29  Expected: 200 x 54

Clipping region after call to SetDeviceOrigin() etc.:
wxGTK_clip_ok

--- a/samples/minimal/minimal.cpp
+++ b/samples/minimal/minimal.cpp
@@ -63,6 +63,7 @@ public:
     // event handlers (these functions should _not_ be virtual)
     void OnQuit(wxCommandEvent& event);
     void OnAbout(wxCommandEvent& event);
+    void OnPaint(wxPaintEvent& evt);
 
 private:
     // any class wishing to process wxWidgets events must use this macro
@@ -175,11 +176,52 @@ MyFrame::MyFrame(const wxString& title)
     CreateStatusBar(2);
     SetStatusText("Welcome to wxWidgets!");
 #endif // wxUSE_STATUSBAR
+    Bind(wxEVT_PAINT, &MyFrame::OnPaint, this);
 }
 
 
 // event handlers
 
+void MyFrame::OnPaint(wxPaintEvent&)
+{
+    wxPaintDC dc(this);
+    if ( true )
+    {
+        wxAffineMatrix2D m;
+        m.Translate(40, 75);
+        m.Scale(2.0, 3.0);
+        dc.SetTransformMatrix(m);
+    }
+    else
+    {
+        dc.SetDeviceOrigin(10, 15);
+        dc.SetUserScale(0.5, 1.5);
+        dc.SetLogicalScale(4.0, 2.0);
+        dc.SetLogicalOrigin(-15, -20);
+    }
+
+    dc.DestroyClippingRegion();
+    dc.SetBackground(*wxYELLOW_BRUSH);
+    dc.Clear();
+
+    // Logical coordinates of painting area
+    wxPoint orig = dc.DeviceToLogical(0, 0);
+    wxSize dim = dc.DeviceToLogicalRel(dc.GetSize());
+
+    wxRect clip;
+    dc.GetClippingBox(clip);
+
+    wxString msg;
+    if ( orig != clip.GetPosition() )
+    {
+        wxLogDebug("Invalid position: Actual: (%i, %i)  Expected: (%i, %i)", clip.x, clip.y, orig.x, orig.y);
+    }
+    if ( dim != clip.GetSize() )
+    {
+        wxLogDebug("Invalid size: Actual: %i x %i  Expected: %i x %i", clip.width, clip.height, dim.x, dim.y);
+    }
+}
+
 void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
 {
     // true is to force the frame to close

Platform and version information

  • wxWidgets version: 3.3.0
  • wxWidgets port: wxGTK
  • OS: Debian 11
  • GTK version: 3.24.24
  • GDK backend: X11


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/23046@github.com>

AW

unread,
Dec 22, 2022, 12:43:14 PM12/22/22
to wx-...@googlegroups.com, Subscribed

Closed #23046 as completed via #23052.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/23046/issue_event/8097833803@github.com>

Reply all
Reply to author
Forward
0 new messages