Thick dashed lines are not dashed with GTK3 (Issue #26449)

19 views
Skip to first unread message

taler21

unread,
May 12, 2026, 4:58:35 AM (2 days ago) May 12
to wx-...@googlegroups.com, Subscribed
taler21 created an issue (wxWidgets/wxWidgets#26449)

With a wxPen width of 10 or more, wxDC::DrawLine() draws dashed lines not dashed, but rather solid.

This issue can be seen in the drawing sample, even more with thicker line widths, for example by using the following patch:

Patch for drawing sample
diff -r -u -p a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp
--- a/samples/drawing/drawing.cpp	2026-05-12 10:22:24.793184400 +0200
+++ b/samples/drawing/drawing.cpp	2026-05-12 08:33:40.209233300 +0200
@@ -780,23 +780,24 @@ void MyCanvas::DrawTestPoly(wxDC& dc)
 
 void MyCanvas::DrawTestLines( int x, int y, int width, wxDC &dc )
 {
+    const int vStep = 5 * (2 + (width / 6));
     dc.SetPen( wxPen( *wxBLACK, width ) );
     dc.SetBrush( *wxWHITE_BRUSH );
     dc.DrawText(wxString::Format("Testing lines of width %d", width), dc.FromDIP(x + 10), dc.FromDIP(y - 10));
-    dc.DrawRectangle(dc.FromDIP(x + 10), dc.FromDIP(y + 10), dc.FromDIP(100), dc.FromDIP(190));
+    dc.DrawRectangle(dc.FromDIP(x + 10), dc.FromDIP(y + 1*vStep), dc.FromDIP(200), dc.FromDIP(6*vStep));
 
-    dc.DrawText("Solid/dot/short dash/long dash/dot dash", dc.FromDIP(x + 150), dc.FromDIP(y + 10));
+    dc.DrawText("Solid/dot/short dash/long dash/dot dash", dc.FromDIP(x + 250), dc.FromDIP(y + 10));
     dc.SetPen( wxPen( *wxBLACK, width ) );
-    dc.DrawLine(dc.FromDIP(x + 20), dc.FromDIP(y + 20), dc.FromDIP(100), dc.FromDIP(y + 20));
+    dc.DrawLine(dc.FromDIP(x + 20), dc.FromDIP(y + 2*vStep), dc.FromDIP(200), dc.FromDIP(y + 2*vStep));
     dc.SetPen( wxPen( *wxBLACK, width, wxPENSTYLE_DOT) );
-    dc.DrawLine(dc.FromDIP(x + 20), dc.FromDIP(y + 30), dc.FromDIP(100), dc.FromDIP(y + 30));
+    dc.DrawLine(dc.FromDIP(x + 20), dc.FromDIP(y + 3*vStep), dc.FromDIP(200), dc.FromDIP(y + 3*vStep));
     dc.SetPen( wxPen( *wxBLACK, width, wxPENSTYLE_SHORT_DASH) );
-    dc.DrawLine(dc.FromDIP(x + 20), dc.FromDIP(y + 40), dc.FromDIP(100), dc.FromDIP(y + 40));
+    dc.DrawLine(dc.FromDIP(x + 20), dc.FromDIP(y + 4*vStep), dc.FromDIP(200), dc.FromDIP(y + 4*vStep));
     dc.SetPen( wxPen( *wxBLACK, width, wxPENSTYLE_LONG_DASH) );
-    dc.DrawLine(dc.FromDIP(x + 20), dc.FromDIP(y + 50), dc.FromDIP(100), dc.FromDIP(y + 50));
+    dc.DrawLine(dc.FromDIP(x + 20), dc.FromDIP(y + 5*vStep), dc.FromDIP(200), dc.FromDIP(y + 5*vStep));
     dc.SetPen( wxPen( *wxBLACK, width, wxPENSTYLE_DOT_DASH) );
-    dc.DrawLine(dc.FromDIP(x + 20), dc.FromDIP(y + 60), dc.FromDIP(100), dc.FromDIP(y + 60));
-
+    dc.DrawLine(dc.FromDIP(x + 20), dc.FromDIP(y + 6*vStep), dc.FromDIP(200), dc.FromDIP(y + 6*vStep));
+/*
     dc.DrawText("Hatches", dc.FromDIP(x + 150), dc.FromDIP(y + 70));
     dc.SetPen( wxPen( *wxBLACK, width, wxPENSTYLE_BDIAGONAL_HATCH) );
     dc.DrawLine(dc.FromDIP(x + 20), dc.FromDIP(y + 70), dc.FromDIP(100), dc.FromDIP(y + 70));
@@ -855,6 +856,7 @@ void MyCanvas::DrawTestLines( int x, int
     dc.SetPen(penWithCap);
     dc.DrawText("Projecting cap", dc.FromDIP(x + 270), dc.FromDIP(y + 100));
     dc.DrawLine(dc.FromDIP(x + 200), dc.FromDIP(y + 110), dc.FromDIP(x + 250), dc.FromDIP(y + 110));
+*/
 }
 
 void MyCanvas::DrawCrossHair(int x, int y, int width, int heigth, wxDC &dc)
@@ -2232,10 +2234,10 @@ void MyCanvas::Draw(wxDC& pdc)
             break;
 
         case File_ShowLines:
-            DrawTestLines( 0, 100, 0, dc );
-            DrawTestLines( 0, 320, 1, dc );
-            DrawTestLines( 0, 540, 2, dc );
-            DrawTestLines( 0, 760, 6, dc );
+            DrawTestLines( 0, 100, 2, dc );
+            DrawTestLines( 0, 190, 5, dc );
+            DrawTestLines( 0, 280, 10, dc );
+            DrawTestLines( 0, 410, 15, dc );
             DrawCrossHair( 0, 0, 400, 90, dc);
             break;
 

In comparison with MSW and GTK2:

GTK3 MSW GTK2
dashed-lines-GTK3.png (view on web) dashed-lines-MSW.png (view on web) dashed-lines-GTK2.png (view on web)

Platform and version information

  • wxWidgets version you use: 3.2.8 and master (4ed05f7)
  • wxWidgets port you use: wxGTK
  • OS and its version: Linux Mint 22
    • GTK version: 3.24.41
    • Which GDK backend is used: X11
    • Desktop environment : Cinnamon
    • Current theme: Mint-Y


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26449@github.com>

VZ

unread,
May 12, 2026, 11:12:52 AM (2 days ago) May 12
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26449)

We probably need to scale the values hardcoded in wxCairoPenData ctor by the pen width. Including 2.0 used for dotted lines which are not dotted at all with thicker pens.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26449/4431670602@github.com>

Reply all
Reply to author
Forward
0 new messages