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 samplediff -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) |
—
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.![]()
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.![]()