diff options
Diffstat (limited to 'qt/ScintillaEditBase')
-rw-r--r-- | qt/ScintillaEditBase/PlatQt.cpp | 47 | ||||
-rw-r--r-- | qt/ScintillaEditBase/PlatQt.h | 11 |
2 files changed, 58 insertions, 0 deletions
diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp index a8553e658..6c7f789ce 100644 --- a/qt/ScintillaEditBase/PlatQt.cpp +++ b/qt/ScintillaEditBase/PlatQt.cpp @@ -230,11 +230,24 @@ void SurfaceImpl::PenColour(ColourDesired fore) GetPainter()->setPen(penOutline); } +void SurfaceImpl::PenColourWidth(ColourAlpha fore, XYPOSITION strokeWidth) { + QPen penOutline(QColorFromColourAlpha(fore)); + penOutline.setCapStyle(Qt::FlatCap); + penOutline.setJoinStyle(Qt::MiterJoin); + penOutline.setWidthF(strokeWidth); + GetPainter()->setPen(penOutline); +} + void SurfaceImpl::BrushColour(ColourDesired back) { GetPainter()->setBrush(QBrush(QColorFromCA(back))); } +void SurfaceImpl::BrushColour(ColourAlpha back) +{ + GetPainter()->setBrush(QBrush(QColorFromColourAlpha(back))); +} + void SurfaceImpl::SetCodec(const Font *font) { const FontAndCharacterSet *pfacs = AsFontAndCharacterSet(font); @@ -304,6 +317,17 @@ void SurfaceImpl::Polygon(Point *pts, GetPainter()->drawPolygon(&qpts[0], static_cast<int>(npts)); } +void SurfaceImpl::Polygon(const Point *pts, size_t npts, FillStroke fillStroke) +{ + PenColourWidth(fillStroke.stroke.colour, fillStroke.stroke.width); + BrushColour(fillStroke.fill.colour); + + std::vector<QPointF> qpts; + std::transform(pts, pts + npts, std::back_inserter(qpts), QPointFFromPoint); + + GetPainter()->drawPolygon(&qpts[0], static_cast<int>(npts)); +} + void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) @@ -314,6 +338,14 @@ void SurfaceImpl::RectangleDraw(PRectangle rc, GetPainter()->drawRect(rect); } +void SurfaceImpl::RectangleDraw(PRectangle rc, FillStroke fillStroke) +{ + PenColourWidth(fillStroke.stroke.colour, fillStroke.stroke.width); + BrushColour(fillStroke.fill.colour); + const QRectF rect = QRectFFromPRect(rc.Inset(fillStroke.stroke.width / 2)); + GetPainter()->drawRect(rect); +} + void SurfaceImpl::FillRectangle(PRectangle rc, ColourDesired back) { GetPainter()->fillRect(QRectFFromPRect(rc), QColorFromCA(back)); @@ -352,6 +384,13 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, GetPainter()->drawRoundedRect(QRectFFromPRect(RectangleInset(rc, 0.5f)), 3.0f, 3.0f); } +void SurfaceImpl::RoundedRectangle(PRectangle rc, FillStroke fillStroke) +{ + PenColourWidth(fillStroke.stroke.colour, fillStroke.stroke.width); + BrushColour(fillStroke.fill.colour); + GetPainter()->drawRoundedRect(QRectFFromPRect(rc), 3.0f, 3.0f); +} + void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, @@ -469,6 +508,14 @@ void SurfaceImpl::Ellipse(PRectangle rc, GetPainter()->drawEllipse(QRectFFromPRect(rc)); } +void SurfaceImpl::Ellipse(PRectangle rc, FillStroke fillStroke) +{ + PenColourWidth(fillStroke.stroke.colour, fillStroke.stroke.width); + BrushColour(fillStroke.fill.colour); + const QRectF rect = QRectFFromPRect(rc.Inset(fillStroke.stroke.width / 2)); + GetPainter()->drawEllipse(rect); +} + void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) { SurfaceImpl *source = dynamic_cast<SurfaceImpl *>(&surfaceSource); diff --git a/qt/ScintillaEditBase/PlatQt.h b/qt/ScintillaEditBase/PlatQt.h index 257dbda56..12f3e7726 100644 --- a/qt/ScintillaEditBase/PlatQt.h +++ b/qt/ScintillaEditBase/PlatQt.h @@ -62,6 +62,11 @@ inline Point PointFromQPoint(QPoint qp) return Point(qp.x(), qp.y()); } +inline QPointF QPointFFromPoint(Point qp) +{ + return QPointF(qp.x, qp.y); +} + constexpr PRectangle RectangleInset(PRectangle rc, XYPOSITION delta) noexcept { return PRectangle(rc.left + delta, rc.top + delta, rc.right - delta, rc.bottom - delta); } @@ -93,6 +98,7 @@ public: int Supports(int feature) noexcept override; bool Initialised() override; void PenColour(ColourDesired fore) override; + void PenColourWidth(ColourAlpha fore, XYPOSITION strokeWidth); int LogPixelsY() override; int PixelDivisions() override; int DeviceHeightFont(int points) override; @@ -100,13 +106,16 @@ public: void LineTo(int x_, int y_) override; void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) override; + void Polygon(const Point *pts, size_t npts, FillStroke fillStroke) override; void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override; + void RectangleDraw(PRectangle rc, FillStroke fillStroke) override; void FillRectangle(PRectangle rc, ColourDesired back) override; void FillRectangle(PRectangle rc, Fill fill) override; void FillRectangle(PRectangle rc, Surface &surfacePattern) override; void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) override; + void RoundedRectangle(PRectangle rc, FillStroke fillStroke) override; void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, ColourDesired outline, int alphaOutline, int flags) override; void AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) override; @@ -115,6 +124,7 @@ public: const unsigned char *pixelsImage) override; void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override; + void Ellipse(PRectangle rc, FillStroke fillStroke) override; void Copy(PRectangle rc, Point from, Surface &surfaceSource) override; std::unique_ptr<IScreenLineLayout> Layout(const IScreenLine *screenLine) override; @@ -155,6 +165,7 @@ public: void SetBidiR2L(bool bidiR2L_) override; void BrushColour(ColourDesired back); + void BrushColour(ColourAlpha back); void SetCodec(const Font *font); void SetFont(const Font *font); |