aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/CallTip.cxx7
-rw-r--r--src/EditView.cxx8
-rw-r--r--win32/PlatWin.cxx22
3 files changed, 12 insertions, 25 deletions
diff --git a/src/CallTip.cxx b/src/CallTip.cxx
index 3d62dba88..ffd808c66 100644
--- a/src/CallTip.cxx
+++ b/src/CallTip.cxx
@@ -8,6 +8,7 @@
#include <cstdlib>
#include <cstring>
#include <cstdio>
+#include <cmath>
#include <stdexcept>
#include <string>
@@ -150,7 +151,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
} else if (IsTabCharacter(s[startSeg])) {
xEnd = NextTabPos(x);
} else {
- xEnd = x + RoundXYPosition(surface->WidthText(font, s + startSeg, endSeg - startSeg));
+ xEnd = x + lround(surface->WidthText(font, s + startSeg, endSeg - startSeg));
if (draw) {
rcClient.left = static_cast<XYPOSITION>(x);
rcClient.right = static_cast<XYPOSITION>(xEnd);
@@ -172,7 +173,7 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1);
// To make a nice small call tip window, it is only sized to fit most normal characters without accents
- const int ascent = RoundXYPosition(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font));
+ const int ascent = lround(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font));
// For each line...
// Draw the definition in three parts: before highlight, highlighted, after highlight
@@ -281,7 +282,7 @@ PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, co
look = newline + 1;
numLines++;
}
- lineHeight = RoundXYPosition(surfaceMeasure->Height(font));
+ lineHeight = lround(surfaceMeasure->Height(font));
// The returned
// rectangle is aligned to the right edge of the last arrow encountered in
diff --git a/src/EditView.cxx b/src/EditView.cxx
index 1b98d6fe0..d30f761eb 100644
--- a/src/EditView.cxx
+++ b/src/EditView.cxx
@@ -1163,8 +1163,8 @@ void EditView::DrawFoldDisplayText(Surface *surface, const EditModel &model, con
if (model.foldDisplayTextStyle == SC_FOLDDISPLAYTEXT_BOXED) {
surface->PenColour(textFore);
PRectangle rcBox = rcSegment;
- rcBox.left = static_cast<XYPOSITION>(RoundXYPosition(rcSegment.left));
- rcBox.right = static_cast<XYPOSITION>(RoundXYPosition(rcSegment.right));
+ 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));
@@ -1366,7 +1366,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
xposCaret += xStart;
if (model.posDrag.IsValid()) {
/* Dragging text, use a line caret */
- rcCaret.left = static_cast<XYPOSITION>(RoundXYPosition(xposCaret - caretWidthOffset));
+ rcCaret.left = round(xposCaret - caretWidthOffset);
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
} else if (model.inOverstrike && drawOverstrikeCaret) {
/* Overstrike (insert mode), use a modified bar caret */
@@ -1384,7 +1384,7 @@ void EditView::DrawCarets(Surface *surface, const EditModel &model, const ViewSt
}
} else {
/* Line caret */
- rcCaret.left = static_cast<XYPOSITION>(RoundXYPosition(xposCaret - caretWidthOffset));
+ rcCaret.left = round(xposCaret - caretWidthOffset);
rcCaret.right = rcCaret.left + vsDraw.caretWidth;
}
const ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour;
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 8e06b7f4c..2e3ed0d00 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -2441,20 +2441,6 @@ void ListBoxX::SetRedraw(bool on) {
::InvalidateRect(lb, NULL, TRUE);
}
-static XYPOSITION XYMinimum(XYPOSITION a, XYPOSITION b) {
- if (a < b)
- return a;
- else
- return b;
-}
-
-static XYPOSITION XYMaximum(XYPOSITION a, XYPOSITION b) {
- if (a > b)
- return a;
- else
- return b;
-}
-
void ListBoxX::ResizeToCursor() {
PRectangle rc = GetPosition();
POINT ptw;
@@ -2497,10 +2483,10 @@ void ListBoxX::ResizeToCursor() {
POINT ptMin = MinTrackSize();
POINT ptMax = MaxTrackSize();
// We don't allow the left edge to move at present, but just in case
- rc.left = XYMaximum(XYMinimum(rc.left, rcPreSize.right - ptMin.x), rcPreSize.right - ptMax.x);
- rc.top = XYMaximum(XYMinimum(rc.top, rcPreSize.bottom - ptMin.y), rcPreSize.bottom - ptMax.y);
- rc.right = XYMaximum(XYMinimum(rc.right, rcPreSize.left + ptMax.x), rcPreSize.left + ptMin.x);
- rc.bottom = XYMaximum(XYMinimum(rc.bottom, rcPreSize.top + ptMax.y), rcPreSize.top + ptMin.y);
+ rc.left = std::clamp(rc.left, rcPreSize.right - ptMax.x, rcPreSize.right - ptMin.x);
+ rc.top = std::clamp(rc.top, rcPreSize.bottom - ptMax.y, rcPreSize.bottom - ptMin.y);
+ rc.right = std::clamp(rc.right, rcPreSize.left + ptMin.x, rcPreSize.left + ptMax.x);
+ rc.bottom = std::clamp(rc.bottom, rcPreSize.top + ptMin.y, rcPreSize.top + ptMax.y);
SetPosition(rc);
}