diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-02-26 18:00:07 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-05-31 08:28:06 +0200 |
| commit | b027d2ba57a8e0d6f0862e0a891ddd5dee4b02e2 (patch) | |
| tree | 3ed894bd9a891337804367a09de500ff060be640 /src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx | |
| parent | d95dd7acc4af3a4bd521d151ba3576b91d8ace53 (diff) | |
Windows platform: use GDI+ to antialias oblique lines and curves.
Diffstat (limited to 'src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx')
| -rw-r--r-- | src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx index 91cfe2ca4..20418333b 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx @@ -59,3 +59,52 @@ void Fl_GDI_Graphics_Driver::line_style_unscaled(int style, int width, char* das DeleteObject(fl_current_xmap->pen); fl_current_xmap->pen = newpen; } + +#if USE_GDIPLUS + +void Fl_GDIplus_Graphics_Driver::line_style(int style, int width, char* dashes) { + if (!active) return Fl_Scalable_Graphics_Driver::line_style(style, width, dashes); + int gdi_width = (width ? width : 1); + pen_->SetWidth(Gdiplus::REAL(gdi_width)); + int standard_dash = style & 0x7; + if (standard_dash == FL_DASH ) + pen_->SetDashStyle(Gdiplus::DashStyleDash); + else if (standard_dash == FL_DOT ) + pen_->SetDashStyle(Gdiplus::DashStyleDot); + else if (standard_dash == FL_DASHDOT ) + pen_->SetDashStyle(Gdiplus::DashStyleDashDot); + else if (standard_dash == FL_DASHDOTDOT ) + pen_->SetDashStyle(Gdiplus::DashStyleDashDotDot); + else if(!dashes || !*dashes) + pen_->SetDashStyle(Gdiplus::DashStyleSolid); + + if (style & FL_CAP_ROUND ) { + pen_->SetStartCap(Gdiplus::LineCapRound); + pen_->SetEndCap(Gdiplus::LineCapRound); + } else if (style & FL_CAP_SQUARE ) { + pen_->SetStartCap(Gdiplus::LineCapSquare); + pen_->SetEndCap(Gdiplus::LineCapSquare); + } else { + pen_->SetStartCap(Gdiplus::LineCapFlat); + pen_->SetEndCap(Gdiplus::LineCapFlat); + } + + if (style & FL_JOIN_MITER ) { + pen_->SetLineJoin(Gdiplus::LineJoinMiter); + } else if (style & FL_JOIN_BEVEL ) { + pen_->SetLineJoin(Gdiplus::LineJoinBevel); + } else { + pen_->SetLineJoin(Gdiplus::LineJoinRound); + } + + if (dashes && *dashes) { + int n = 0; while (dashes[n]) n++; + Gdiplus::REAL *gdi_dashes = new Gdiplus::REAL[n]; + for (int i = 0; i < n; i++) gdi_dashes[i] = dashes[i]/float(gdi_width); + pen_->SetDashPattern(gdi_dashes, n); + delete[] gdi_dashes; + } + Fl_Scalable_Graphics_Driver::line_style(style, width, dashes); +} + +#endif |
