aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--scripts/HeaderOrder.txt1
-rw-r--r--src/CallTip.cxx10
-rw-r--r--src/EditView.cxx52
-rw-r--r--src/Indicator.cxx87
-rw-r--r--src/IntegerRectangle.h29
-rw-r--r--src/LineMarker.cxx77
-rw-r--r--src/MarginView.cxx13
7 files changed, 157 insertions, 112 deletions
diff --git a/scripts/HeaderOrder.txt b/scripts/HeaderOrder.txt
index bd8a3b215..37ef50241 100644
--- a/scripts/HeaderOrder.txt
+++ b/scripts/HeaderOrder.txt
@@ -115,6 +115,7 @@
#include "Catalogue.h"
#include "Position.h"
+#include "IntegerRectangle.h"
#include "UniqueString.h"
#include "SplitVector.h"
#include "Partitioning.h"
diff --git a/src/CallTip.cxx b/src/CallTip.cxx
index f8bb77c48..21cf6e3d3 100644
--- a/src/CallTip.cxx
+++ b/src/CallTip.cxx
@@ -19,6 +19,7 @@
#include "Scintilla.h"
+#include "IntegerRectangle.h"
#include "StringCopy.h"
#include "Position.h"
#include "CallTip.h"
@@ -233,13 +234,14 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
#ifndef __APPLE__
// OSX doesn't put borders on "help tags"
// Draw a raised border around the edges of the window
- surfaceWindow->MoveTo(0, static_cast<int>(rcClientSize.bottom) - 1);
+ const IntegerRectangle ircClientSize(rcClientSize);
+ surfaceWindow->MoveTo(0, ircClientSize.bottom - 1);
surfaceWindow->PenColour(colourShade);
- surfaceWindow->LineTo(static_cast<int>(rcClientSize.right) - 1, static_cast<int>(rcClientSize.bottom) - 1);
- surfaceWindow->LineTo(static_cast<int>(rcClientSize.right) - 1, 0);
+ surfaceWindow->LineTo(ircClientSize.right - 1, ircClientSize.bottom - 1);
+ surfaceWindow->LineTo(ircClientSize.right - 1, 0);
surfaceWindow->PenColour(colourLight);
surfaceWindow->LineTo(0, 0);
- surfaceWindow->LineTo(0, static_cast<int>(rcClientSize.bottom) - 1);
+ surfaceWindow->LineTo(0, ircClientSize.bottom - 1);
#endif
}
diff --git a/src/EditView.cxx b/src/EditView.cxx
index 51bd0f634..dc8ba1c2d 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -32,6 +32,7 @@
#include "StringCopy.h"
#include "CharacterSet.h"
#include "Position.h"
+#include "IntegerRectangle.h"
#include "UniqueString.h"
#include "SplitVector.h"
#include "Partitioning.h"
@@ -294,22 +295,23 @@ static const char *ControlCharacterString(unsigned char ch) {
}
static void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid, const ViewStyle &vsDraw) {
+ const IntegerRectangle ircTab(rcTab);
if ((rcTab.left + 2) < (rcTab.right - 1))
- surface->MoveTo(static_cast<int>(rcTab.left) + 2, ymid);
+ surface->MoveTo(ircTab.left + 2, ymid);
else
- surface->MoveTo(static_cast<int>(rcTab.right) - 1, ymid);
- surface->LineTo(static_cast<int>(rcTab.right) - 1, ymid);
+ surface->MoveTo(ircTab.right - 1, ymid);
+ surface->LineTo(ircTab.right - 1, ymid);
// Draw the arrow head if needed
if (vsDraw.tabDrawMode == tdLongArrow) {
- int ydiff = static_cast<int>(rcTab.bottom - rcTab.top) / 2;
- int xhead = static_cast<int>(rcTab.right) - 1 - ydiff;
+ int ydiff = (ircTab.bottom - ircTab.top) / 2;
+ int xhead = ircTab.right - 1 - ydiff;
if (xhead <= rcTab.left) {
- ydiff -= static_cast<int>(rcTab.left) - xhead - 1;
- xhead = static_cast<int>(rcTab.left) - 1;
+ ydiff -= ircTab.left - xhead - 1;
+ xhead = ircTab.left - 1;
}
surface->LineTo(xhead, ymid - ydiff);
- surface->MoveTo(static_cast<int>(rcTab.right) - 1, ymid);
+ surface->MoveTo(ircTab.right - 1, ymid);
surface->LineTo(xhead, ymid + ydiff);
}
}
@@ -1165,14 +1167,15 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
PRectangle rcBox = rcSegment;
rcBox.left = round(rcSegment.left);
rcBox.right = round(rcSegment.right);
- surface->MoveTo(static_cast<int>(rcBox.left), static_cast<int>(rcBox.top));
- surface->LineTo(static_cast<int>(rcBox.left), static_cast<int>(rcBox.bottom));
- surface->MoveTo(static_cast<int>(rcBox.right), static_cast<int>(rcBox.top));
- surface->LineTo(static_cast<int>(rcBox.right), static_cast<int>(rcBox.bottom));
- surface->MoveTo(static_cast<int>(rcBox.left), static_cast<int>(rcBox.top));
- surface->LineTo(static_cast<int>(rcBox.right), static_cast<int>(rcBox.top));
- surface->MoveTo(static_cast<int>(rcBox.left), static_cast<int>(rcBox.bottom - 1));
- surface->LineTo(static_cast<int>(rcBox.right), static_cast<int>(rcBox.bottom - 1));
+ const IntegerRectangle ircBox(rcBox);
+ surface->MoveTo(ircBox.left, ircBox.top);
+ surface->LineTo(ircBox.left, ircBox.bottom);
+ surface->MoveTo(ircBox.right, ircBox.top);
+ surface->LineTo(ircBox.right, ircBox.bottom);
+ surface->MoveTo(ircBox.left, ircBox.top);
+ surface->LineTo(ircBox.right, ircBox.top);
+ surface->MoveTo(ircBox.left, ircBox.bottom - 1);
+ surface->LineTo(ircBox.right, ircBox.bottom - 1);
}
}
@@ -1228,17 +1231,18 @@ void EditView::DrawAnnotation(Surface *surface, const EditModel &model, const Vi
stAnnotation, start, lengthAnnotation, phase);
if ((phase & drawBack) && (vsDraw.annotationVisible == ANNOTATION_BOXED)) {
surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore);
- surface->MoveTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.top));
- surface->LineTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.bottom));
- surface->MoveTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.top));
- surface->LineTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.bottom));
+ const IntegerRectangle ircSegment(rcSegment);
+ surface->MoveTo(ircSegment.left, ircSegment.top);
+ surface->LineTo(ircSegment.left, ircSegment.bottom);
+ surface->MoveTo(ircSegment.right, ircSegment.top);
+ surface->LineTo(ircSegment.right, ircSegment.bottom);
if (subLine == ll->lines) {
- surface->MoveTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.top));
- surface->LineTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.top));
+ surface->MoveTo(ircSegment.left, ircSegment.top);
+ surface->LineTo(ircSegment.right, ircSegment.top);
}
if (subLine == ll->lines + annotationLines - 1) {
- surface->MoveTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.bottom - 1));
- surface->LineTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.bottom - 1));
+ surface->MoveTo(ircSegment.left, ircSegment.bottom - 1);
+ surface->LineTo(ircSegment.right, ircSegment.bottom - 1);
}
}
}
diff --git a/src/Indicator.cxx b/src/Indicator.cxx
index a18238cde..f9d0ca04a 100644
--- a/src/Indicator.cxx
+++ b/src/Indicator.cxx
@@ -16,6 +16,7 @@
#include "Platform.h"
#include "Scintilla.h"
+#include "IntegerRectangle.h"
#include "Indicator.h"
#include "XPM.h"
@@ -35,13 +36,15 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
if (drawState == drawHover) {
sacDraw = sacHover;
}
+ const IntegerRectangle irc(rc);
surface->PenColour(sacDraw.fore);
- const int ymid = static_cast<int>(rc.bottom + rc.top) / 2;
+ const int ymid = (irc.bottom + irc.top) / 2;
if (sacDraw.style == INDIC_SQUIGGLE) {
- int x = static_cast<int>(lround(rc.left));
- const int xLast = static_cast<int>(lround(rc.right));
+ const IntegerRectangle ircSquiggle(PixelGridAlign(rc));
+ int x = ircSquiggle.left;
+ const int xLast = ircSquiggle.right;
int y = 0;
- surface->MoveTo(x, static_cast<int>(rc.top) + y);
+ surface->MoveTo(x, irc.top + y);
while (x < xLast) {
if ((x + 2) > xLast) {
if (xLast > x)
@@ -51,7 +54,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
x += 2;
y = 2 - y;
}
- surface->LineTo(x, static_cast<int>(rc.top) + y);
+ surface->LineTo(x, irc.top + y);
}
} else if (sacDraw.style == INDIC_SQUIGGLEPIXMAP) {
const PRectangle rcSquiggle = PixelGridAlign(rc);
@@ -73,19 +76,19 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
}
surface->DrawRGBAImage(rcSquiggle, image.GetWidth(), image.GetHeight(), image.Pixels());
} else if (sacDraw.style == INDIC_SQUIGGLELOW) {
- surface->MoveTo(static_cast<int>(rc.left), static_cast<int>(rc.top));
- int x = static_cast<int>(rc.left) + 3;
+ surface->MoveTo(irc.left, irc.top);
+ int x = irc.left + 3;
int y = 0;
while (x < rc.right) {
- surface->LineTo(x - 1, static_cast<int>(rc.top) + y);
+ surface->LineTo(x - 1, irc.top + y);
y = 1 - y;
- surface->LineTo(x, static_cast<int>(rc.top) + y);
+ surface->LineTo(x, irc.top + y);
x += 3;
}
- surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rc.top) + y); // Finish the line
+ surface->LineTo(irc.right, irc.top + y); // Finish the line
} else if (sacDraw.style == INDIC_TT) {
- surface->MoveTo(static_cast<int>(rc.left), ymid);
- int x = static_cast<int>(rc.left) + 5;
+ surface->MoveTo(irc.left, ymid);
+ int x = irc.left + 5;
while (x < rc.right) {
surface->LineTo(x, ymid);
surface->MoveTo(x-3, ymid);
@@ -94,35 +97,36 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
surface->MoveTo(x, ymid);
x += 5;
}
- surface->LineTo(static_cast<int>(rc.right), ymid); // Finish the line
+ surface->LineTo(irc.right, ymid); // Finish the line
if (x - 3 <= rc.right) {
surface->MoveTo(x-3, ymid);
surface->LineTo(x-3, ymid+2);
}
} else if (sacDraw.style == INDIC_DIAGONAL) {
- int x = static_cast<int>(rc.left);
+ int x = irc.left;
while (x < rc.right) {
- surface->MoveTo(x, static_cast<int>(rc.top) + 2);
+ surface->MoveTo(x, irc.top + 2);
int endX = x+3;
- int endY = static_cast<int>(rc.top) - 1;
+ int endY = irc.top - 1;
if (endX > rc.right) {
- endY += endX - static_cast<int>(rc.right);
- endX = static_cast<int>(rc.right);
+ endY += endX - irc.right;
+ endX = irc.right;
}
surface->LineTo(endX, endY);
x += 4;
}
} else if (sacDraw.style == INDIC_STRIKE) {
- surface->MoveTo(static_cast<int>(rc.left), static_cast<int>(rc.top) - 4);
- surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rc.top) - 4);
+ surface->MoveTo(irc.left, irc.top - 4);
+ surface->LineTo(irc.right, irc.top - 4);
} else if ((sacDraw.style == INDIC_HIDDEN) || (sacDraw.style == INDIC_TEXTFORE)) {
// Draw nothing
} else if (sacDraw.style == INDIC_BOX) {
- surface->MoveTo(static_cast<int>(rc.left), ymid + 1);
- surface->LineTo(static_cast<int>(rc.right), ymid + 1);
- surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rcLine.top) + 1);
- surface->LineTo(static_cast<int>(rc.left), static_cast<int>(rcLine.top) + 1);
- surface->LineTo(static_cast<int>(rc.left), ymid + 1);
+ surface->MoveTo(irc.left, ymid + 1);
+ surface->LineTo(irc.right, ymid + 1);
+ const int lineTop = static_cast<int>(rcLine.top) + 1;
+ surface->LineTo(irc.right, lineTop);
+ surface->LineTo(irc.left, lineTop);
+ surface->LineTo(irc.left, ymid + 1);
} else if (sacDraw.style == INDIC_ROUNDBOX ||
sacDraw.style == INDIC_STRAIGHTBOX ||
sacDraw.style == INDIC_FULLBOX) {
@@ -137,32 +141,33 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
PRectangle rcBox = PixelGridAlign(rc);
rcBox.top = rcLine.top + 1;
rcBox.bottom = rcLine.bottom;
+ IntegerRectangle ircBox(rcBox);
// Cap width at 4000 to avoid large allocations when mistakes made
- const int width = std::min(static_cast<int>(rcBox.Width()), 4000);
- RGBAImage image(width, static_cast<int>(rcBox.Height()), 1.0, 0);
+ const int width = std::min(ircBox.Width(), 4000);
+ RGBAImage image(width, ircBox.Height(), 1.0, 0);
// Draw horizontal lines top and bottom
for (int x=0; x<width; x++) {
- for (int y = 0; y<static_cast<int>(rcBox.Height()); y += static_cast<int>(rcBox.Height()) - 1) {
+ for (int y = 0; y<ircBox.Height(); y += ircBox.Height() - 1) {
image.SetPixel(x, y, sacDraw.fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
}
}
// Draw vertical lines left and right
- for (int y = 1; y<static_cast<int>(rcBox.Height()); y++) {
+ for (int y = 1; y<ircBox.Height(); y++) {
for (int x=0; x<width; x += width-1) {
image.SetPixel(x, y, sacDraw.fore, ((x + y) % 2) ? outlineAlpha : fillAlpha);
}
}
surface->DrawRGBAImage(rcBox, image.GetWidth(), image.GetHeight(), image.Pixels());
} else if (sacDraw.style == INDIC_DASH) {
- int x = static_cast<int>(rc.left);
+ int x = irc.left;
while (x < rc.right) {
surface->MoveTo(x, ymid);
- surface->LineTo(std::min(x + 4, static_cast<int>(rc.right)), ymid);
+ surface->LineTo(std::min(x + 4, irc.right), ymid);
x += 7;
}
} else if (sacDraw.style == INDIC_DOTS) {
- int x = static_cast<int>(rc.left);
- while (x < static_cast<int>(rc.right)) {
+ int x = irc.left;
+ while (x < irc.right) {
const PRectangle rcDot = PRectangle::FromInts(x, ymid, x + 1, ymid + 1);
surface->FillRectangle(rcDot, sacDraw.fore);
x += 2;
@@ -175,20 +180,20 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
surface->FillRectangle(rcComposition, sacDraw.fore);
} else if (sacDraw.style == INDIC_POINT || sacDraw.style == INDIC_POINTCHARACTER) {
if (rcCharacter.Width() >= 0.1) {
- const int pixelHeight = static_cast<int>(rc.Height() - 1.0f); // 1 pixel onto next line if multiphase
+ const XYPOSITION pixelHeight = floor(rc.Height() - 1.0f); // 1 pixel onto next line if multiphase
const XYPOSITION x = (sacDraw.style == INDIC_POINT) ? (rcCharacter.left) : ((rcCharacter.right + rcCharacter.left) / 2);
- const int ix = static_cast<int>(lround(x));
- const int iy = static_cast<int>(rc.top + 1.0f);
+ const XYPOSITION ix = round(x);
+ const XYPOSITION iy = floor(rc.top + 1.0f);
Point pts[] = {
- Point::FromInts(ix - pixelHeight, iy + pixelHeight), // Left
- Point::FromInts(ix + pixelHeight, iy + pixelHeight), // Right
- Point::FromInts(ix, iy) // Top
+ Point(ix - pixelHeight, iy + pixelHeight), // Left
+ Point(ix + pixelHeight, iy + pixelHeight), // Right
+ Point(ix, iy) // Top
};
surface->Polygon(pts, 3, sacDraw.fore, sacDraw.fore);
}
} else { // Either INDIC_PLAIN or unknown
- surface->MoveTo(static_cast<int>(rc.left), ymid);
- surface->LineTo(static_cast<int>(rc.right), ymid);
+ surface->MoveTo(irc.left, ymid);
+ surface->LineTo(irc.right, ymid);
}
}
diff --git a/src/IntegerRectangle.h b/src/IntegerRectangle.h
new file mode 100644
index 000000000..4eaf39c43
--- /dev/null
+++ b/src/IntegerRectangle.h
@@ -0,0 +1,29 @@
+// Scintilla source code edit control
+/** @file IntegerRectangle.h
+ ** A rectangle with integer coordinates.
+ **/
+// Copyright 2018 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#ifndef INTEGERRECTANGLE_H
+#define INTEGERRECTANGLE_H
+
+namespace Scintilla {
+
+struct IntegerRectangle {
+ int left;
+ int top;
+ int right;
+ int bottom;
+
+ explicit IntegerRectangle(PRectangle rc) noexcept :
+ left(static_cast<int>(rc.left)), top(static_cast<int>(rc.top)),
+ right(static_cast<int>(rc.right)), bottom(static_cast<int>(rc.bottom)) {
+ }
+ int Width() const noexcept { return right - left; }
+ int Height() const noexcept { return bottom - top; }
+};
+
+}
+
+#endif
diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx
index 820ab9fae..7a66d5326 100644
--- a/src/LineMarker.cxx
+++ b/src/LineMarker.cxx
@@ -19,6 +19,7 @@
#include "Scintilla.h"
#include "StringCopy.h"
+#include "IntegerRectangle.h"
#include "XPM.h"
#include "LineMarker.h"
@@ -151,21 +152,20 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
surface->DrawRGBAImage(rcImage, image->GetWidth(), image->GetHeight(), image->Pixels());
return;
}
+ const IntegerRectangle ircWhole(rcWhole);
// Restrict most shapes a bit
- PRectangle rc = rcWhole;
- rc.top++;
- rc.bottom--;
- int minDim = std::min(static_cast<int>(rc.Width()), static_cast<int>(rc.Height()));
- minDim--; // Ensure does not go beyond edge
- int centreX = static_cast<int>(floor((rc.right + rc.left) / 2.0));
- const int centreY = static_cast<int>(floor((rc.bottom + rc.top) / 2.0));
+ const PRectangle rc(rcWhole.left, rcWhole.top + 1, rcWhole.right, rcWhole.bottom - 1);
+ // Ensure does not go beyond edge
+ const int minDim = std::min(ircWhole.Width(), ircWhole.Height()-2) - 1;
+ int centreX = (ircWhole.right + ircWhole.left) / 2;
+ const int centreY = (ircWhole.bottom + ircWhole.top) / 2;
const int dimOn2 = minDim / 2;
const int dimOn4 = minDim / 4;
const int blobSize = dimOn2-1;
const int armSize = dimOn2-2;
if (marginStyle == SC_MARGIN_NUMBER || marginStyle == SC_MARGIN_TEXT || marginStyle == SC_MARGIN_RTEXT) {
// On textual margins move marker to the left to try to avoid overlapping the text
- centreX = static_cast<int>(rc.left) + dimOn2 + 1;
+ centreX = ircWhole.left + dimOn2 + 1;
}
if (markType == SC_MARK_ROUNDRECT) {
PRectangle rcRounded = rc;
@@ -235,46 +235,46 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
} else if (markType == SC_MARK_VLINE) {
surface->PenColour(colourBody);
- surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
- surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
+ surface->MoveTo(centreX, ircWhole.top);
+ surface->LineTo(centreX, ircWhole.bottom);
} else if (markType == SC_MARK_LCORNER) {
surface->PenColour(colourTail);
- surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
+ surface->MoveTo(centreX, ircWhole.top);
surface->LineTo(centreX, centreY);
- surface->LineTo(static_cast<int>(rc.right) - 1, centreY);
+ surface->LineTo(ircWhole.right - 1, centreY);
} else if (markType == SC_MARK_TCORNER) {
surface->PenColour(colourTail);
surface->MoveTo(centreX, centreY);
- surface->LineTo(static_cast<int>(rc.right) - 1, centreY);
+ surface->LineTo(ircWhole.right - 1, centreY);
surface->PenColour(colourBody);
- surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
+ surface->MoveTo(centreX, ircWhole.top);
surface->LineTo(centreX, centreY + 1);
surface->PenColour(colourHead);
- surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
+ surface->LineTo(centreX, ircWhole.bottom);
} else if (markType == SC_MARK_LCORNERCURVE) {
surface->PenColour(colourTail);
- surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
+ surface->MoveTo(centreX, ircWhole.top);
surface->LineTo(centreX, centreY-3);
surface->LineTo(centreX+3, centreY);
- surface->LineTo(static_cast<int>(rc.right) - 1, centreY);
+ surface->LineTo(ircWhole.right - 1, centreY);
} else if (markType == SC_MARK_TCORNERCURVE) {
surface->PenColour(colourTail);
surface->MoveTo(centreX, centreY-3);
surface->LineTo(centreX+3, centreY);
- surface->LineTo(static_cast<int>(rc.right) - 1, centreY);
+ surface->LineTo(ircWhole.right - 1, centreY);
surface->PenColour(colourBody);
- surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
+ surface->MoveTo(centreX, ircWhole.top);
surface->LineTo(centreX, centreY-2);
surface->PenColour(colourHead);
- surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
+ surface->LineTo(centreX, ircWhole.bottom);
} else if (markType == SC_MARK_BOXPLUS) {
DrawBox(surface, centreX, centreY, blobSize, fore, colourHead);
@@ -286,10 +286,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
else
surface->PenColour(colourBody);
surface->MoveTo(centreX, centreY + blobSize);
- surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
+ surface->LineTo(centreX, ircWhole.bottom);
surface->PenColour(colourBody);
- surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
+ surface->MoveTo(centreX, ircWhole.top);
surface->LineTo(centreX, centreY - blobSize);
DrawBox(surface, centreX, centreY, blobSize, fore, colourHead);
@@ -312,7 +312,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
surface->PenColour(colourHead);
surface->MoveTo(centreX, centreY + blobSize);
- surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
+ surface->LineTo(centreX, ircWhole.bottom);
} else if (markType == SC_MARK_BOXMINUSCONNECTED) {
DrawBox(surface, centreX, centreY, blobSize, fore, colourHead);
@@ -320,10 +320,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
surface->PenColour(colourHead);
surface->MoveTo(centreX, centreY + blobSize);
- surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
+ surface->LineTo(centreX, ircWhole.bottom);
surface->PenColour(colourBody);
- surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
+ surface->MoveTo(centreX, ircWhole.top);
surface->LineTo(centreX, centreY - blobSize);
if (tFold == LineMarker::body) {
@@ -347,10 +347,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
else
surface->PenColour(colourBody);
surface->MoveTo(centreX, centreY + blobSize);
- surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
+ surface->LineTo(centreX, ircWhole.bottom);
surface->PenColour(colourBody);
- surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
+ surface->MoveTo(centreX, ircWhole.top);
surface->LineTo(centreX, centreY - blobSize);
DrawCircle(surface, centreX, centreY, blobSize, fore, colourHead);
@@ -359,7 +359,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
} else if (markType == SC_MARK_CIRCLEMINUS) {
surface->PenColour(colourHead);
surface->MoveTo(centreX, centreY + blobSize);
- surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
+ surface->LineTo(centreX, ircWhole.bottom);
DrawCircle(surface, centreX, centreY, blobSize, fore, colourHead);
DrawMinus(surface, centreX, centreY, blobSize, colourTail);
@@ -367,10 +367,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
} else if (markType == SC_MARK_CIRCLEMINUSCONNECTED) {
surface->PenColour(colourHead);
surface->MoveTo(centreX, centreY + blobSize);
- surface->LineTo(centreX, static_cast<int>(rcWhole.bottom));
+ surface->LineTo(centreX, ircWhole.bottom);
surface->PenColour(colourBody);
- surface->MoveTo(centreX, static_cast<int>(rcWhole.top));
+ surface->MoveTo(centreX, ircWhole.top);
surface->LineTo(centreX, centreY - blobSize);
DrawCircle(surface, centreX, centreY, blobSize, fore, colourHead);
@@ -380,9 +380,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
char character[1];
character[0] = static_cast<char>(markType - SC_MARK_CHARACTER);
const XYPOSITION width = surface->WidthText(fontForCharacter, character, 1);
- rc.left += (rc.Width() - width) / 2;
- rc.right = rc.left + width;
- surface->DrawTextClipped(rc, fontForCharacter, rc.bottom - 2,
+ PRectangle rcText = rc;
+ rcText.left += (rc.Width() - width) / 2;
+ rcText.right = rc.left + width;
+ surface->DrawTextClipped(rcText, fontForCharacter, rcText.bottom - 2,
character, 1, fore, back);
} else if (markType == SC_MARK_DOTDOTDOT) {
@@ -422,11 +423,11 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
} else if (markType == SC_MARK_BOOKMARK) {
const int halfHeight = minDim / 3;
Point pts[] = {
- Point::FromInts(static_cast<int>(rc.left), centreY-halfHeight),
- Point::FromInts(static_cast<int>(rc.right) - 3, centreY - halfHeight),
- Point::FromInts(static_cast<int>(rc.right) - 3 - halfHeight, centreY),
- Point::FromInts(static_cast<int>(rc.right) - 3, centreY + halfHeight),
- Point::FromInts(static_cast<int>(rc.left), centreY + halfHeight),
+ Point::FromInts(ircWhole.left, centreY-halfHeight),
+ Point::FromInts(ircWhole.right - 3, centreY - halfHeight),
+ Point::FromInts(ircWhole.right - 3 - halfHeight, centreY),
+ Point::FromInts(ircWhole.right - 3, centreY + halfHeight),
+ Point::FromInts(ircWhole.left, centreY + halfHeight),
};
surface->Polygon(pts, ELEMENTS(pts), fore, back);
} else { // SC_MARK_FULLRECT
diff --git a/src/MarginView.cxx b/src/MarginView.cxx
index 2b40b10bc..804ffcfcd 100644
--- a/src/MarginView.cxx
+++ b/src/MarginView.cxx
@@ -28,6 +28,7 @@
#include "StringCopy.h"
#include "Position.h"
+#include "IntegerRectangle.h"
#include "UniqueString.h"
#include "SplitVector.h"
#include "Partitioning.h"
@@ -58,16 +59,18 @@ void DrawWrapMarker(Surface *surface, PRectangle rcPlace,
bool isEndMarker, ColourDesired wrapColour) {
surface->PenColour(wrapColour);
+ const IntegerRectangle ircPlace(rcPlace);
+
enum { xa = 1 }; // gap before start
- const int w = static_cast<int>(rcPlace.right - rcPlace.left) - xa - 1;
+ const int w = ircPlace.Width() - xa - 1;
const bool xStraight = isEndMarker; // x-mirrored symbol for start marker
- const int x0 = static_cast<int>(xStraight ? rcPlace.left : rcPlace.right - 1);
- const int y0 = static_cast<int>(rcPlace.top);
+ const int x0 = xStraight ? ircPlace.left : ircPlace.right - 1;
+ const int y0 = ircPlace.top;
- const int dy = static_cast<int>(rcPlace.bottom - rcPlace.top) / 5;
- const int y = static_cast<int>(rcPlace.bottom - rcPlace.top) / 2 + dy;
+ const int dy = ircPlace.Height() / 5;
+ const int y = ircPlace.Height() / 2 + dy;
struct Relative {
Surface *surface;