aboutsummaryrefslogtreecommitdiffhomepage
path: root/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/PlatCocoa.h17
-rw-r--r--cocoa/PlatCocoa.mm292
2 files changed, 0 insertions, 309 deletions
diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h
index 83b724df9..70a9b68f1 100644
--- a/cocoa/PlatCocoa.h
+++ b/cocoa/PlatCocoa.h
@@ -42,8 +42,6 @@ namespace Scintilla {
class SurfaceImpl : public Surface {
private:
SurfaceMode mode;
- float x;
- float y;
CGContextRef gc;
@@ -58,7 +56,6 @@ private:
int bitmapHeight;
/** Set the CGContext's fill colour to the specified desired colour. */
- void FillColour(const ColourDesired &back);
void FillColour(ColourAlpha fill);
void PenColourAlpha(ColourAlpha fore);
@@ -80,7 +77,6 @@ public:
void Init(WindowID wid) override;
void Init(SurfaceID sid, WindowID wid) override;
- void InitPixMap(int width, int height, Surface *surface_, WindowID wid) override;
std::unique_ptr<Surface> AllocatePixMap(int width, int height) override;
std::unique_ptr<SurfaceImpl> AllocatePixMapImplementation(int width, int height);
CGContextRef GetContext() { return gc; }
@@ -90,7 +86,6 @@ public:
void Release() noexcept override;
int Supports(int feature) noexcept override;
bool Initialised() override;
- void PenColour(ColourDesired fore) override;
/** Returns a CGImageRef that represents the surface. Returns NULL if this is not possible. */
CGImageRef CreateImage();
@@ -99,27 +94,18 @@ public:
int LogPixelsY() override;
int PixelDivisions() override;
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;
void RectangleDraw(PRectangle rc, FillStroke fillStroke) override;
void RectangleFrame(PRectangle rc, Stroke stroke) override;
- void FillRectangle(PRectangle rc, ColourDesired back) override;
void FillRectangle(PRectangle rc, Fill fill) override;
void FillRectangleAligned(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;
void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) override;
void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override;
- void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override;
void Ellipse(PRectangle rc, FillStroke fillStroke) override;
void Stadium(PRectangle rc, FillStroke fillStroke, Ends ends) override;
void Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource) override;
@@ -152,9 +138,6 @@ public:
void FlushCachedState() override;
void FlushDrawing() override;
- void SetUnicodeMode(bool unicodeMode_) override;
- void SetDBCSMode(int codePage_) override;
- void SetBidiR2L(bool bidiR2L_) override;
}; // SurfaceImpl class
} // Scintilla namespace
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index d509145d2..0e1897438 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -352,8 +352,6 @@ const int SupportsCocoa[] = {
//----------------- SurfaceImpl --------------------------------------------------------------------
SurfaceImpl::SurfaceImpl() {
- x = 0;
- y = 0;
gc = NULL;
textLayout.reset(new QuartzTextLayout());
@@ -367,8 +365,6 @@ SurfaceImpl::SurfaceImpl() {
}
SurfaceImpl::SurfaceImpl(const SurfaceImpl *surface, int width, int height) {
- x = 0;
- y = 0;
textLayout.reset(new QuartzTextLayout());
@@ -439,8 +435,6 @@ void SurfaceImpl::Clear() {
bitmapWidth = 0;
bitmapHeight = 0;
- x = 0;
- y = 0;
}
//--------------------------------------------------------------------------------------------------
@@ -476,58 +470,6 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID) {
CGContextSetLineWidth(gc, 1.0);
}
-//--------------------------------------------------------------------------------------------------
-
-void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID /* wid */) {
- Release();
-
- // Create a new bitmap context, along with the RAM for the bitmap itself
- bitmapWidth = width;
- bitmapHeight = height;
-
- const int bitmapBytesPerRow = (width * BYTES_PER_PIXEL);
- const int bitmapByteCount = (bitmapBytesPerRow * height);
-
- // Create an RGB color space.
- CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
- if (colorSpace == NULL)
- return;
-
- // Create the bitmap.
- bitmapData.reset(new uint8_t[bitmapByteCount]);
- // create the context
- gc = CGBitmapContextCreate(bitmapData.get(),
- width,
- height,
- BITS_PER_COMPONENT,
- bitmapBytesPerRow,
- colorSpace,
- kCGImageAlphaPremultipliedLast);
-
- if (gc == NULL) {
- // the context couldn't be created for some reason,
- // and we have no use for the bitmap without the context
- bitmapData.reset();
- }
-
- // the context retains the color space, so we can release it
- CGColorSpaceRelease(colorSpace);
-
- if (gc && bitmapData) {
- // "Erase" to white.
- CGContextClearRect(gc, CGRectMake(0, 0, width, height));
- CGContextSetRGBFillColor(gc, 1.0, 1.0, 1.0, 1.0);
- CGContextFillRect(gc, CGRectMake(0, 0, width, height));
- }
-
- if (surface_) {
- SurfaceImpl *psurfOther = static_cast<SurfaceImpl *>(surface_);
- mode = psurfOther->mode;
- } else {
- mode.codePage = SC_CP_UTF8;
- }
-}
-
std::unique_ptr<Surface> SurfaceImpl::AllocatePixMap(int width, int height) {
return std::make_unique<SurfaceImpl>(this, width, height);
}
@@ -554,18 +496,6 @@ int SurfaceImpl::Supports(int feature) noexcept {
//--------------------------------------------------------------------------------------------------
-void SurfaceImpl::PenColour(ColourDesired fore) {
- if (gc) {
- ColourDesired colour(fore.AsInteger());
-
- // Set the Stroke color to match
- CGContextSetRGBStrokeColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0,
- colour.GetBlue() / 255.0, 1.0);
- }
-}
-
-//--------------------------------------------------------------------------------------------------
-
void SurfaceImpl::FillColour(ColourAlpha fill) {
// Set the Fill color to match
CGContextSetRGBFillColor(gc,
@@ -577,18 +507,6 @@ void SurfaceImpl::FillColour(ColourAlpha fill) {
//--------------------------------------------------------------------------------------------------
-void SurfaceImpl::FillColour(const ColourDesired &back) {
- if (gc) {
- ColourDesired colour(back.AsInteger());
-
- // Set the Fill color to match
- CGContextSetRGBFillColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0,
- colour.GetBlue() / 255.0, 1.0);
- }
-}
-
-//--------------------------------------------------------------------------------------------------
-
void SurfaceImpl::PenColourAlpha(ColourAlpha fore) {
// Set the Stroke color to match
CGContextSetRGBStrokeColor(gc,
@@ -699,30 +617,6 @@ int SurfaceImpl::DeviceHeightFont(int points) {
//--------------------------------------------------------------------------------------------------
-void SurfaceImpl::MoveTo(int x_, int y_) {
- x = x_;
- y = y_;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-void SurfaceImpl::LineTo(int x_, int y_) {
- CGContextBeginPath(gc);
-
- // Because Quartz is based on floating point, lines are drawn with half their colour
- // on each side of the line. Integer coordinates specify the INTERSECTION of the pixel
- // division lines. If you specify exact pixel values, you get a line that
- // is twice as thick but half as intense. To get pixel aligned rendering,
- // we render the "middle" of the pixels by adding 0.5 to the coordinates.
- CGContextMoveToPoint(gc, x + 0.5, y + 0.5);
- CGContextAddLineToPoint(gc, x_ + 0.5, y_ + 0.5);
- CGContextStrokePath(gc);
- x = x_;
- y = y_;
-}
-
-//--------------------------------------------------------------------------------------------------
-
void SurfaceImpl::LineDraw(Point start, Point end, Stroke stroke) {
PenColourAlpha(stroke.colour);
CGContextSetLineWidth(gc, stroke.width);
@@ -756,33 +650,6 @@ void SurfaceImpl::PolyLine(const Point *pts, size_t npts, Stroke stroke) {
//--------------------------------------------------------------------------------------------------
-void SurfaceImpl::Polygon(Scintilla::Point *pts, size_t npts, ColourDesired fore,
- ColourDesired back) {
- // Allocate memory for the array of points.
- std::vector<CGPoint> points(npts);
-
- for (size_t i = 0; i < npts; i++) {
- // Quartz floating point issues: plot the MIDDLE of the pixels
- points[i].x = pts[i].x + 0.5;
- points[i].y = pts[i].y + 0.5;
- }
-
- CGContextBeginPath(gc);
-
- // Set colours
- FillColour(back);
- PenColour(fore);
-
- // Draw the polygon
- CGContextAddLines(gc, points.data(), npts);
-
- // Explicitly close the path, so it is closed for stroking AND filling (implicit close = filling only)
- CGContextClosePath(gc);
- CGContextDrawPath(gc, kCGPathFillStroke);
-}
-
-//--------------------------------------------------------------------------------------------------
-
void SurfaceImpl::Polygon(const Scintilla::Point *pts, size_t npts, FillStroke fillStroke) {
std::vector<CGPoint> points;
std::transform(pts, pts + npts, std::back_inserter(points), CGPointFromPoint);
@@ -804,22 +671,6 @@ void SurfaceImpl::Polygon(const Scintilla::Point *pts, size_t npts, FillStroke f
//--------------------------------------------------------------------------------------------------
-void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) {
- if (gc) {
- CGContextBeginPath(gc);
- FillColour(back);
- PenColour(fore);
-
- // Quartz integer -> float point conversion fun (see comment in SurfaceImpl::LineTo)
- // We subtract 1 from the Width() and Height() so that all our drawing is within the area defined
- // by the PRectangle. Otherwise, we draw one pixel too far to the right and bottom.
- CGContextAddRect(gc, CGRectMake(rc.left + 0.5, rc.top + 0.5, rc.Width() - 1, rc.Height() - 1));
- CGContextDrawPath(gc, kCGPathFillStroke);
- }
-}
-
-//--------------------------------------------------------------------------------------------------
-
void SurfaceImpl::RectangleDraw(PRectangle rc, FillStroke fillStroke) {
if (!gc)
return;
@@ -854,19 +705,6 @@ void SurfaceImpl::RectangleFrame(PRectangle rc, Stroke stroke) {
//--------------------------------------------------------------------------------------------------
-void SurfaceImpl::FillRectangle(PRectangle rc, ColourDesired back) {
- if (gc) {
- FillColour(back);
- // Snap rectangle boundaries to nearest int
- rc.left = std::round(rc.left);
- rc.right = std::round(rc.right);
- CGRect rect = PRectangleToCGRect(rc);
- CGContextFillRect(gc, rect);
- }
-}
-
-//--------------------------------------------------------------------------------------------------
-
void SurfaceImpl::FillRectangle(PRectangle rc, Fill fill) {
if (gc) {
FillColour(fill.colour);
@@ -940,68 +778,6 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
} /* pattern != NULL */
}
-void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) {
- // This is only called from the margin marker drawing code for SC_MARK_ROUNDRECT
- // The Win32 version does
- // ::RoundRect(hdc, rc.left + 1, rc.top, rc.right - 1, rc.bottom, 8, 8 );
- // which is a rectangle with rounded corners each having a radius of 4 pixels.
- // It would be almost as good just cutting off the corners with lines at
- // 45 degrees as is done on GTK+.
-
- // Create a rectangle with semicircles at the corners
- const int MAX_RADIUS = 4;
- const int radius = std::min(MAX_RADIUS, static_cast<int>(std::min(rc.Height()/2, rc.Width()/2)));
-
- // Points go clockwise, starting from just below the top left
- // Corners are kept together, so we can easily create arcs to connect them
- CGPoint corners[4][3] = {
- {
- { rc.left, rc.top + radius },
- { rc.left, rc.top },
- { rc.left + radius, rc.top },
- },
- {
- { rc.right - radius - 1, rc.top },
- { rc.right - 1, rc.top },
- { rc.right - 1, rc.top + radius },
- },
- {
- { rc.right - 1, rc.bottom - radius - 1 },
- { rc.right - 1, rc.bottom - 1 },
- { rc.right - radius - 1, rc.bottom - 1 },
- },
- {
- { rc.left + radius, rc.bottom - 1 },
- { rc.left, rc.bottom - 1 },
- { rc.left, rc.bottom - radius - 1 },
- },
- };
-
- // Align the points in the middle of the pixels
- for (int i = 0; i < 4; ++ i) {
- for (int j = 0; j < 3; ++ j) {
- corners[i][j].x += 0.5;
- corners[i][j].y += 0.5;
- }
- }
-
- PenColour(fore);
- FillColour(back);
-
- // Move to the last point to begin the path
- CGContextBeginPath(gc);
- CGContextMoveToPoint(gc, corners[3][2].x, corners[3][2].y);
-
- for (int i = 0; i < 4; ++ i) {
- CGContextAddLineToPoint(gc, corners[i][0].x, corners[i][0].y);
- CGContextAddArcToPoint(gc, corners[i][1].x, corners[i][1].y, corners[i][2].x, corners[i][2].y, radius);
- }
-
- // Close the path to enclose it for stroking and for filling, then draw it
- CGContextClosePath(gc);
- CGContextDrawPath(gc, kCGPathFillStroke);
-}
-
void SurfaceImpl::RoundedRectangle(PRectangle rc, FillStroke fillStroke) {
// This is only called from the margin marker drawing code for SC_MARK_ROUNDRECT
// The Win32 version does
@@ -1111,54 +887,6 @@ static void DrawChamferedRectangle(CGContextRef gc, PRectangle rc, int cornerSiz
CGContextDrawPath(gc, mode);
}
-void Scintilla::SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
- ColourDesired outline, int alphaOutline, int /*flags*/) {
- if (gc) {
- // Snap rectangle boundaries to nearest int
- rc.left = std::round(rc.left);
- rc.right = std::round(rc.right);
- // Set the Fill color to match
- CGContextSetRGBFillColor(gc, fill.GetRed() / 255.0, fill.GetGreen() / 255.0, fill.GetBlue() / 255.0, alphaFill / 255.0);
- CGContextSetRGBStrokeColor(gc, outline.GetRed() / 255.0, outline.GetGreen() / 255.0, outline.GetBlue() / 255.0, alphaOutline / 255.0);
- PRectangle rcFill = rc;
- if (cornerSize == 0) {
- // A simple rectangle, no rounded corners
- if ((fill == outline) && (alphaFill == alphaOutline)) {
- // Optimization for simple case
- CGRect rect = PRectangleToCGRect(rcFill);
- CGContextFillRect(gc, rect);
- } else {
- rcFill.left += 1.0;
- rcFill.top += 1.0;
- rcFill.right -= 1.0;
- rcFill.bottom -= 1.0;
- CGRect rect = PRectangleToCGRect(rcFill);
- CGContextFillRect(gc, rect);
- CGContextAddRect(gc, CGRectMake(rc.left + 0.5, rc.top + 0.5, rc.Width() - 1, rc.Height() - 1));
- CGContextStrokePath(gc);
- }
- } else {
- // Approximate rounded corners with 45 degree chamfers.
- // Drawing real circular arcs often leaves some over- or under-drawn pixels.
- if ((fill == outline) && (alphaFill == alphaOutline)) {
- // Specializing this case avoids a few stray light/dark pixels in corners.
- rcFill.left -= 0.5;
- rcFill.top -= 0.5;
- rcFill.right += 0.5;
- rcFill.bottom += 0.5;
- DrawChamferedRectangle(gc, rcFill, cornerSize, kCGPathFill);
- } else {
- rcFill.left += 0.5;
- rcFill.top += 0.5;
- rcFill.right -= 0.5;
- rcFill.bottom -= 0.5;
- DrawChamferedRectangle(gc, rcFill, cornerSize-1, kCGPathFill);
- DrawChamferedRectangle(gc, rc, cornerSize, kCGPathStroke);
- }
- }
- }
-}
-
void Scintilla::SurfaceImpl::AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) {
if (gc) {
const XYPOSITION halfStroke = fillStroke.stroke.width / 2.0f;
@@ -1317,15 +1045,6 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi
}
}
-void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) {
- CGRect ellipseRect = CGRectMake(rc.left, rc.top, rc.Width(), rc.Height());
- FillColour(back);
- PenColour(fore);
- CGContextBeginPath(gc);
- CGContextAddEllipseInRect(gc, ellipseRect);
- CGContextDrawPath(gc, kCGPathFillStroke);
-}
-
void SurfaceImpl::Ellipse(PRectangle rc, FillStroke fillStroke) {
const CGRect ellipseRect = CGRectFromPRectangleInset(rc, fillStroke.stroke.width / 2.0f);
SetFillStroke(fillStroke);
@@ -1784,17 +1503,6 @@ void SurfaceImpl::FlushCachedState() {
CGContextSynchronize(gc);
}
-void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) {
- mode.codePage = unicodeMode_ ? SC_CP_UTF8 : 0;
-}
-
-void SurfaceImpl::SetDBCSMode(int codePage_) {
- mode.codePage = codePage_;
-}
-
-void SurfaceImpl::SetBidiR2L(bool) {
-}
-
void SurfaceImpl::FlushDrawing() {
}