aboutsummaryrefslogtreecommitdiffhomepage
path: root/cocoa
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-03-20 09:56:18 +1100
committerNeil <nyamatongwe@gmail.com>2021-03-20 09:56:18 +1100
commitfa10779da55ff13c95a0cd39bffdf57dcdfc9cc5 (patch)
treef29c68da031bbc4219f96a9e023380adfaa21cec /cocoa
parent7fe8bb0dba466798ca9efc448f772d37f360efe2 (diff)
downloadscintilla-mirror-fa10779da55ff13c95a0cd39bffdf57dcdfc9cc5.tar.gz
Implement LineDraw and PolyLine.
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/PlatCocoa.h2
-rw-r--r--cocoa/PlatCocoa.mm33
2 files changed, 35 insertions, 0 deletions
diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h
index c14ca1928..29a3626ce 100644
--- a/cocoa/PlatCocoa.h
+++ b/cocoa/PlatCocoa.h
@@ -96,6 +96,8 @@ public:
int DeviceHeightFont(int points) override;
void MoveTo(int x_, int y_) override;
void LineTo(int x_, int y_) override;
+ void LineDraw(Point start, Point end, Stroke stroke) override;
+ void PolyLine(const Point *pts, size_t npts, Stroke stroke) override;
void Polygon(Scintilla::Point *pts, size_t npts, ColourDesired fore, ColourDesired back) override;
void Polygon(const Scintilla::Point *pts, size_t npts, FillStroke fillStroke) override;
void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override;
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index 7bec2d73d..275587288 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -657,6 +657,39 @@ void SurfaceImpl::LineTo(int x_, int y_) {
//--------------------------------------------------------------------------------------------------
+void SurfaceImpl::LineDraw(Point start, Point end, Stroke stroke) {
+ PenColourAlpha(stroke.colour);
+ CGContextSetLineWidth(gc, stroke.width);
+
+ CGContextBeginPath(gc);
+ CGContextMoveToPoint(gc, start.x, start.y);
+ CGContextAddLineToPoint(gc, end.x, end.y);
+ CGContextStrokePath(gc);
+
+ CGContextSetLineWidth(gc, 1.0f);
+}
+
+//--------------------------------------------------------------------------------------------------
+
+void SurfaceImpl::PolyLine(const Point *pts, size_t npts, Stroke stroke) {
+ PLATFORM_ASSERT(gc && (npts > 1));
+ if (!gc || (npts <= 1)) {
+ return;
+ }
+ PenColourAlpha(stroke.colour);
+ CGContextSetLineWidth(gc, stroke.width);
+ CGContextBeginPath(gc);
+ CGContextMoveToPoint(gc, pts[0].x, pts[0].y);
+ for (size_t i = 1; i < npts; i++) {
+ CGContextAddLineToPoint(gc, pts[i].x, pts[i].y);
+ }
+ CGContextStrokePath(gc);
+
+ CGContextSetLineWidth(gc, 1.0f);
+}
+
+//--------------------------------------------------------------------------------------------------
+
void SurfaceImpl::Polygon(Scintilla::Point *pts, size_t npts, ColourDesired fore,
ColourDesired back) {
// Allocate memory for the array of points.