diff options
author | Neil <nyamatongwe@gmail.com> | 2014-05-03 18:01:22 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2014-05-03 18:01:22 +1000 |
commit | c3e5215e06bd8ff394a9911b5573969cc55681a0 (patch) | |
tree | 097a99fce5619ad78dd5f66f6de0539e24063e83 | |
parent | e7f79269406933b3edef09c5e6ece9f0d8a99bad (diff) | |
download | scintilla-mirror-c3e5215e06bd8ff394a9911b5573969cc55681a0.tar.gz |
Turn on MSVC 'possible loss of data' warnings and add explicit casts.
-rw-r--r-- | include/Platform.h | 16 | ||||
-rw-r--r-- | src/CallTip.cxx | 4 | ||||
-rw-r--r-- | src/Editor.cxx | 764 | ||||
-rw-r--r-- | src/Indicator.cxx | 68 | ||||
-rw-r--r-- | src/LineMarker.cxx | 88 | ||||
-rw-r--r-- | src/PositionCache.cxx | 2 | ||||
-rw-r--r-- | src/ScintillaBase.cxx | 55 | ||||
-rw-r--r-- | src/ViewStyle.h | 2 | ||||
-rw-r--r-- | win32/PlatWin.cxx | 26 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 58 |
10 files changed, 547 insertions, 536 deletions
diff --git a/include/Platform.h b/include/Platform.h index 5f8c2f2a1..c9156fc0c 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -105,6 +105,8 @@ public: } explicit Point(int x_, int y_) : x(static_cast<XYPOSITION>(x_)), y(static_cast<XYPOSITION>(y_)) { } + explicit Point(long x_, long y_) : x(static_cast<XYPOSITION>(x_)), y(static_cast<XYPOSITION>(y_)) { + } // Other automatically defined methods (assignment, copy constructor, destructor) are fine @@ -123,10 +125,14 @@ public: XYPOSITION right; XYPOSITION bottom; - PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) : + explicit PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) : left(left_), top(top_), right(right_), bottom(bottom_) { } - PRectangle(int left_, int top_, int right_, int bottom_) : + explicit PRectangle(int left_, int top_, int right_, int bottom_) : + left(static_cast<XYPOSITION>(left_)), top(static_cast<XYPOSITION>(top_)), + right(static_cast<XYPOSITION>(right_)), bottom(static_cast<XYPOSITION>(bottom_)) { + } + explicit PRectangle(long left_, long top_, long right_, long bottom_) : left(static_cast<XYPOSITION>(left_)), top(static_cast<XYPOSITION>(top_)), right(static_cast<XYPOSITION>(right_)), bottom(static_cast<XYPOSITION>(bottom_)) { } @@ -524,12 +530,6 @@ public: } #endif -// Shut up annoying Visual C++ warnings: -#ifdef _MSC_VER -// This is: conversion from X to Y, possible loss of data -#pragma warning(disable: 4244) -#endif - #if defined(__GNUC__) && defined(SCINTILLA_QT) #pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif diff --git a/src/CallTip.cxx b/src/CallTip.cxx index 804bb9769..c1a3582f3 100644 --- a/src/CallTip.cxx +++ b/src/CallTip.cxx @@ -186,8 +186,8 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) { chunkEnd = chunkVal + strlen(chunkVal); moreChunks = false; } - int chunkOffset = chunkVal - val.c_str(); - int chunkLength = chunkEnd - chunkVal; + int chunkOffset = static_cast<int>(chunkVal - val.c_str()); + int chunkLength = static_cast<int>(chunkEnd - chunkVal); int chunkEndOffset = chunkOffset + chunkLength; int thisStartHighlight = Platform::Maximum(startHighlight, chunkOffset); thisStartHighlight = Platform::Minimum(thisStartHighlight, chunkEndOffset); diff --git a/src/Editor.cxx b/src/Editor.cxx index 946e0fe2b..1e1d7bf07 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -113,7 +113,7 @@ Editor::Editor() { stylesValid = false; technology = SC_TECHNOLOGY_DEFAULT; - scaleRGBAImage = 100; + scaleRGBAImage = 100.0f; cursorMode = SC_CURSORNORMAL; @@ -397,7 +397,7 @@ PRectangle Editor::GetTextRectangle() { int Editor::LinesOnScreen() { PRectangle rcClient = GetClientRectangle(); - int htClient = rcClient.bottom - rcClient.top; + int htClient = static_cast<int>(rcClient.bottom - rcClient.top); //Platform::DebugPrintf("lines on screen = %d\n", htClient / lineHeight + 1); return htClient / vs.lineHeight; } @@ -506,16 +506,16 @@ Point Editor::LocationFromPosition(int pos) { int Editor::XFromPosition(int pos) { Point pt = LocationFromPosition(pos); - return pt.x - vs.textStart + xOffset; + return static_cast<int>(pt.x) - vs.textStart + xOffset; } int Editor::XFromPosition(SelectionPosition sp) { Point pt = LocationFromPosition(sp); - return pt.x - vs.textStart + xOffset; + return static_cast<int>(pt.x) - vs.textStart + xOffset; } int Editor::LineFromLocation(Point pt) const { - return cs.DocFromDisplay(pt.y / vs.lineHeight + topLine); + return cs.DocFromDisplay(static_cast<int>(pt.y) / vs.lineHeight + topLine); } void Editor::SetTopLine(int topLineNew) { @@ -542,7 +542,7 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, } pt = DocumentPointFromView(pt); pt.x = pt.x - vs.textStart; - int visibleLine = floor(pt.y / vs.lineHeight); + int visibleLine = static_cast<int>(floor(pt.y / vs.lineHeight)); if (!canReturnInvalid && (visibleLine < 0)) visibleLine = 0; const int lineDoc = cs.DocFromDisplay(visibleLine); @@ -568,8 +568,8 @@ SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, } if (virtualSpace) { const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth; - const int spaceOffset = (pt.x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) / - spaceWidth; + const int spaceOffset = static_cast<int>( + (pt.x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) / spaceWidth); return SelectionPosition(rangeSubLine.end + posLineStart, spaceOffset); } else if (canReturnInvalid) { if (pt.x < (ll->positions[rangeSubLine.end] - subLineStart)) { @@ -611,7 +611,8 @@ SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) { return SelectionPosition(pdoc->MovePositionOutsideChar(positionInLine + posLineStart, 1)); } const XYPOSITION spaceWidth = vs.styles[ll->EndLineStyle()].spaceWidth; - const int spaceOffset = (x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) / spaceWidth; + const int spaceOffset = static_cast<int>( + (x + subLineStart - ll->positions[rangeSubLine.end] + spaceWidth / 2) / spaceWidth); return SelectionPosition(rangeSubLine.end + posLineStart, spaceOffset); } return SelectionPosition(0); @@ -711,13 +712,13 @@ PRectangle Editor::RectangleFromRange(Range r) { const PRectangle rcClientDrawing = GetClientDrawingRectangle(); PRectangle rc; const int leftTextOverlap = ((xOffset == 0) && (vs.leftMarginWidth > 0)) ? 1 : 0; - rc.left = vs.textStart - leftTextOverlap; - rc.top = (minLine - TopLineOfMain()) * vs.lineHeight; + rc.left = static_cast<XYPOSITION>(vs.textStart - leftTextOverlap); + rc.top = static_cast<XYPOSITION>((minLine - TopLineOfMain()) * vs.lineHeight); if (rc.top < rcClientDrawing.top) rc.top = rcClientDrawing.top; // Extend to right of prepared area if any to prevent artifacts from caret line highlight rc.right = rcClientDrawing.right; - rc.bottom = (maxLine - TopLineOfMain() + 1) * vs.lineHeight; + rc.bottom = static_cast<XYPOSITION>((maxLine - TopLineOfMain() + 1) * vs.lineHeight); return rc; } @@ -1022,7 +1023,7 @@ Point Editor::PointMainCaret() { */ void Editor::SetLastXChosen() { Point pt = PointMainCaret(); - lastXChosen = pt.x + xOffset; + lastXChosen = static_cast<int>(pt.x) + xOffset; } void Editor::ScrollTo(int line, bool moveThumb) { @@ -1167,7 +1168,7 @@ void Editor::MoveCaretInsideView(bool ensureVisible) { false, false, UserVirtualSpace()), Selection::noSel, ensureVisible); } else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) { - int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight; + int yOfLastLineFullyDisplayed = static_cast<int>(rcClient.top) + (LinesOnScreen() - 1) * vs.lineHeight; MovePositionTo(SPositionFromLocation( Point(lastXChosen - xOffset, static_cast<int>(rcClient.top) + yOfLastLineFullyDisplayed), false, false, UserVirtualSpace()), @@ -1359,7 +1360,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran // Horizontal positioning if ((options & xysHorizontal) && !Wrapping()) { - const int halfScreen = Platform::Maximum(rcClient.Width() - 4, 4) / 2; + const int halfScreen = Platform::Maximum(static_cast<int>(rcClient.Width()) - 4, 4) / 2; const bool bSlop = (caretXPolicy & CARET_SLOP) != 0; const bool bStrict = (caretXPolicy & CARET_STRICT) != 0; const bool bJump = (caretXPolicy & CARET_JUMPS) != 0; @@ -1380,7 +1381,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran if (bEven) { xMarginL = xMarginR; } else { - xMarginL = rcClient.Width() - xMarginR - 4; + xMarginL = static_cast<int>(rcClient.Width()) - xMarginR - 4; } } if (bJump && bEven) { @@ -1395,7 +1396,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran newXY.xOffset -= xMoveL; } else { // Move just enough to allow to display the caret - newXY.xOffset -= (rcClient.left + xMarginL) - pt.x; + newXY.xOffset -= static_cast<int>((rcClient.left + xMarginL) - pt.x); } } else if (pt.x >= rcClient.right - xMarginR) { // Caret is on the right of the display @@ -1403,7 +1404,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran newXY.xOffset += xMoveR; } else { // Move just enough to allow to display the caret - newXY.xOffset += pt.x - (rcClient.right - xMarginR) + 1; + newXY.xOffset += static_cast<int>(pt.x - (rcClient.right - xMarginR) + 1); } } } else { // Not strict @@ -1412,7 +1413,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran if (bEven) { xMoveL = xMoveR; } else { - xMoveL = rcClient.Width() - xMoveR - 4; + xMoveL = static_cast<int>(rcClient.Width()) - xMoveR - 4; } if (pt.x < rcClient.left) { // Caret is on the left of the display @@ -1428,31 +1429,31 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran // Strict or going out of display if (bEven) { // Center caret - newXY.xOffset += pt.x - rcClient.left - halfScreen; + newXY.xOffset += static_cast<int>(pt.x - rcClient.left - halfScreen); } else { // Put caret on right - newXY.xOffset += pt.x - rcClient.right + 1; + newXY.xOffset += static_cast<int>(pt.x - rcClient.right + 1); } } else { // Move just enough to allow to display the caret if (pt.x < rcClient.left) { // Caret is on the left of the display if (bEven) { - newXY.xOffset -= rcClient.left - pt.x; + newXY.xOffset -= static_cast<int>(rcClient.left - pt.x); } else { - newXY.xOffset += pt.x - rcClient.right + 1; + newXY.xOffset += static_cast<int>(pt.x - rcClient.right) + 1; } } else if (pt.x >= rcClient.right) { // Caret is on the right of the display - newXY.xOffset += pt.x - rcClient.right + 1; + newXY.xOffset += static_cast<int>(pt.x - rcClient.right) + 1; } } } // In case of a jump (find result) largely out of display, adjust the offset to display the caret if (pt.x + xOffset < rcClient.left + newXY.xOffset) { - newXY.xOffset = pt.x + xOffset - rcClient.left - 2; + newXY.xOffset = static_cast<int>(pt.x + xOffset - rcClient.left) - 2; } else if (pt.x + xOffset >= rcClient.right + newXY.xOffset) { - newXY.xOffset = pt.x + xOffset - rcClient.right + 2; + newXY.xOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 2; if (vs.caretStyle == CARETSTYLE_BLOCK) { // Ensure we can see a good portion of the block caret newXY.xOffset += static_cast<int>(vs.aveCharWidth); @@ -1461,14 +1462,14 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran if (!(range.caret == range.anchor)) { if (ptAnchor.x < pt.x) { // Shift to left to show anchor or as much of range as possible - int maxOffset = ptAnchor.x + xOffset - rcClient.left - 1; - int minOffset = pt.x + xOffset - rcClient.right + 1; + int maxOffset = static_cast<int>(ptAnchor.x + xOffset - rcClient.left) - 1; + int minOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 1; newXY.xOffset = std::min(newXY.xOffset, maxOffset); newXY.xOffset = std::max(newXY.xOffset, minOffset); } else { // Shift to right to show anchor or as much of range as possible - int minOffset = ptAnchor.x + xOffset - rcClient.right + 1; - int maxOffset = pt.x + xOffset - rcClient.left - 1; + int minOffset = static_cast<int>(ptAnchor.x + xOffset - rcClient.right) + 1; + int maxOffset = static_cast<int>(pt.x + xOffset - rcClient.left) - 1; newXY.xOffset = std::max(newXY.xOffset, minOffset); newXY.xOffset = std::min(newXY.xOffset, maxOffset); } @@ -1494,7 +1495,7 @@ void Editor::SetXYScroll(XYScrollPosition newXY) { PRectangle rcText = GetTextRectangle(); if (horizontalScrollBarVisible && rcText.Width() + xOffset > scrollWidth) { - scrollWidth = xOffset + rcText.Width(); + scrollWidth = xOffset + static_cast<int>(rcText.Width()); SetScrollBars(); } } @@ -1638,9 +1639,9 @@ bool Editor::WrapLines(enum wrapScope ws) { if (lineToWrap < lineToWrapEnd) { PRectangle rcTextArea = GetClientRectangle(); - rcTextArea.left = vs.textStart; + rcTextArea.left = static_cast<XYPOSITION>(vs.textStart); rcTextArea.right -= vs.rightMarginWidth; - wrapWidth = rcTextArea.Width(); + wrapWidth = static_cast<int>(rcTextArea.Width()); RefreshStyleData(); AutoSurface surface(this); if (surface) { @@ -1707,7 +1708,7 @@ void Editor::LinesSplit(int pixelWidth) { if (!RangeContainsProtected(targetStart, targetEnd)) { if (pixelWidth == 0) { PRectangle rcText = GetTextRectangle(); - pixelWidth = rcText.Width(); + pixelWidth = static_cast<int>(rcText.Width()); } int lineStart = pdoc->LineFromPosition(targetStart); int lineEnd = pdoc->LineFromPosition(targetEnd); @@ -1762,8 +1763,8 @@ static int WidthStyledText(Surface *surface, ViewStyle &vs, int styleOffset, size_t endSegment = start; while ((endSegment+1 < len) && (static_cast<size_t>(styles[endSegment+1]) == style)) endSegment++; - width += surface->WidthText(vs.styles[style+styleOffset].font, text + start, - static_cast<int>(endSegment - start + 1)); + width += static_cast<int>(surface->WidthText(vs.styles[style + styleOffset].font, text + start, + static_cast<int>(endSegment - start + 1))); start = endSegment + 1; } return width; @@ -1778,8 +1779,8 @@ static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, con if (st.multipleStyles) { widthSubLine = WidthStyledText(surface, vs, styleOffset, st.text + start, st.styles + start, lenLine); } else { - widthSubLine = surface->WidthText(vs.styles[styleOffset + st.style].font, - st.text + start, static_cast<int>(lenLine)); + widthSubLine = static_cast<int>(surface->WidthText(vs.styles[styleOffset + st.style].font, + st.text + start, static_cast<int>(lenLine))); } if (widthSubLine > widthMax) widthMax = widthSubLine; @@ -1792,7 +1793,7 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle const StyledText &st, size_t start, size_t length) { if (st.multipleStyles) { - int x = rcText.left; + int x = static_cast<int>(rcText.left); size_t i = 0; while (i < length) { size_t end = i; @@ -1800,13 +1801,13 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle while (end < length-1 && st.styles[start+end+1] == style) end++; style += styleOffset; - int width = surface->WidthText(vs.styles[style].font, - st.text + start + i, static_cast<int>(end - i + 1)); + int width = static_cast<int>(surface->WidthText(vs.styles[style].font, + st.text + start + i, static_cast<int>(end - i + 1))); PRectangle rcSegment = rcText; - rcSegment.left = x; - rcSegment.right = x + width + 1; + rcSegment.left = static_cast<XYPOSITION>(x); + rcSegment.right = static_cast<XYPOSITION>(x + width + 1); surface->DrawTextNoClip(rcSegment, vs.styles[style].font, - ascent, st.text + start + i, + static_cast<XYPOSITION>(ascent), st.text + start + i, static_cast<int>(end - i + 1), vs.styles[style].fore, vs.styles[style].back); @@ -1835,7 +1836,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { Point ptOrigin = GetVisibleOriginInMain(); rcMargin.Move(0, -ptOrigin.y); rcMargin.left = 0; - rcMargin.right = vs.fixedColumnWidth; + rcMargin.right = static_cast<XYPOSITION>(vs.fixedColumnWidth); if (!rc.Intersects(rcMargin)) return; @@ -1891,9 +1892,9 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { surface->FillRectangle(rcSelMargin, vs.styles[STYLE_LINENUMBER].back); } - const int lineStartPaint = (rcMargin.top + ptOrigin.y) / vs.lineHeight; + const int lineStartPaint = static_cast<int>(rcMargin.top + ptOrigin.y) / vs.lineHeight; int visibleLine = TopLineOfMain() + lineStartPaint; - int yposScreen = lineStartPaint * vs.lineHeight - ptOrigin.y; + int yposScreen = lineStartPaint * vs.lineHeight - static_cast<int>(ptOrigin.y); // Work out whether the top line is whitespace located after a // lessening of fold level which implies a 'fold tail' but which should not // be displayed until the last of a sequence of whitespace. @@ -2030,8 +2031,8 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { marks &= vs.ms[margin].mask; PRectangle rcMarker = rcSelMargin; - rcMarker.top = yposScreen; - rcMarker.bottom = yposScreen + vs.lineHeight; + rcMarker.top = static_cast<XYPOSITION>(yposScreen); + rcMarker.bottom = static_cast<XYPOSITION>(yposScreen + vs.lineHeight); if (vs.ms[margin].style == SC_MARGIN_NUMBER) { if (firstSubLine) { char number[100] = ""; @@ -2076,7 +2077,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin); rcMarker.left = rcMarker.right - width - 3; } - DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, rcMarker.top + vs.maxAscent, + DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, static_cast<int>(rcMarker.top) + vs.maxAscent, stMargin, 0, stMargin.length); } } @@ -2125,19 +2126,19 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { } void DrawTabArrow(Surface *surface, PRectangle rcTab, int ymid) { - int ydiff = (rcTab.bottom - rcTab.top) / 2; - int xhead = rcTab.right - 1 - ydiff; + int ydiff = static_cast<int>(rcTab.bottom - rcTab.top) / 2; + int xhead = static_cast<int>(rcTab.right) - 1 - ydiff; if (xhead <= rcTab.left) { - ydiff -= rcTab.left - xhead - 1; - xhead = rcTab.left - 1; + ydiff -= static_cast<int>(rcTab.left) - xhead - 1; + xhead = static_cast<int>(rcTab.left) - 1; } if ((rcTab.left + 2) < (rcTab.right - 1)) - surface->MoveTo(rcTab.left + 2, ymid); + surface->MoveTo(static_cast<int>(rcTab.left) + 2, ymid); else - surface->MoveTo(rcTab.right - 1, ymid); - surface->LineTo(rcTab.right - 1, ymid); + surface->MoveTo(static_cast<int>(rcTab.right) - 1, ymid); + surface->LineTo(static_cast<int>(rcTab.right) - 1, ymid); surface->LineTo(xhead, ymid - ydiff); - surface->MoveTo(rcTab.right - 1, ymid); + surface->MoveTo(static_cast<int>(rcTab.right) - 1, ymid); surface->LineTo(xhead, ymid + ydiff); } @@ -2433,15 +2434,15 @@ void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace, surface->PenColour(wrapColour); enum { xa = 1 }; // gap before start - int w = rcPlace.right - rcPlace.left - xa - 1; + int w = static_cast<int>(rcPlace.right - rcPlace.left) - xa - 1; bool xStraight = isEndMarker; // x-mirrored symbol for start marker - int x0 = xStraight ? rcPlace.left : rcPlace.right - 1; - int y0 = rcPlace.top; + int x0 = static_cast<int>(xStraight ? rcPlace.left : rcPlace.right - 1); + int y0 = static_cast<int>(rcPlace.top); - int dy = (rcPlace.bottom - rcPlace.top) / 5; - int y = (rcPlace.bottom - rcPlace.top) / 2 + dy; + int dy = static_cast<int>(rcPlace.bottom - rcPlace.top) / 5; + int y = static_cast<int>(rcPlace.bottom - rcPlace.top) / 2 + dy; struct Relative { Surface *surface; @@ -2484,8 +2485,8 @@ void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, surface->FillRectangle(rcSegment, textBack); } Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; - int normalCharHeight = surface->Ascent(ctrlCharsFont) - - surface->InternalLeading(ctrlCharsFont); + int normalCharHeight = static_cast<int>(surface->Ascent(ctrlCharsFont) - + surface->InternalLeading(ctrlCharsFont)); PRectangle rcCChar = rcSegment; rcCChar.left = rcCChar.left + 1; rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight; @@ -2517,7 +2518,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; virtualSpace = sel.VirtualSpaceFor(pdoc->LineEnd(line)) * spaceWidth; } - XYPOSITION xEol = ll->positions[lineEnd] - subLineStart; + XYPOSITION xEol = static_cast<XYPOSITION>(ll->positions[lineEnd] - subLineStart); // Fill the virtual space and show selections within it if (virtualSpace) { @@ -2532,8 +2533,10 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange); if (!portion.Empty()) { const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; - rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth; - rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth; + rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - + static_cast<XYPOSITION>(subLineStart) + portion.start.VirtualSpace() * spaceWidth; + rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - + static_cast<XYPOSITION>(subLineStart) + portion.end.VirtualSpace() * spaceWidth; rcSegment.left = (rcSegment.left > rcLine.left) ? rcSegment.left : rcLine.left; rcSegment.right = (rcSegment.right < rcLine.right) ? rcSegment.right : rcLine.right; surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, r == sel.Main())); @@ -2555,8 +2558,8 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin XYPOSITION blobsWidth = 0; if (lastSubLine) { for (int eolPos=ll->numCharsBeforeEOL; eolPos<ll->numCharsInLine; eolPos++) { - rcSegment.left = xStart + ll->positions[eolPos] - subLineStart + virtualSpace; - rcSegment.right = xStart + ll->positions[eolPos+1] - subLineStart + virtualSpace; + rcSegment.left = xStart + ll->positions[eolPos] - static_cast<XYPOSITION>(subLineStart) + virtualSpace; + rcSegment.right = xStart + ll->positions[eolPos + 1] - static_cast<XYPOSITION>(subLineStart) + virtualSpace; blobsWidth += rcSegment.Width(); char hexits[4]; const char *ctrlChar; @@ -2746,23 +2749,23 @@ void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int x void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { - int indent = pdoc->GetLineIndentation(line) * vsDraw.spaceWidth; + int indent = static_cast<int>(pdoc->GetLineIndentation(line) * vsDraw.spaceWidth); PRectangle rcSegment = rcLine; int annotationLine = subLine - ll->lines; const StyledText stAnnotation = pdoc->AnnotationStyledText(line); if (stAnnotation.text && ValidStyledText(vsDraw, vsDraw.annotationStyleOffset, stAnnotation)) { surface->FillRectangle(rcSegment, vsDraw.styles[0].back); - rcSegment.left = xStart; + rcSegment.left = static_cast<XYPOSITION>(xStart); if (trackLineWidth || (vs.annotationVisible == ANNOTATION_BOXED)) { // Only care about calculating width if tracking or need to draw box int widthAnnotation = WidestLineWidth(surface, vsDraw, vsDraw.annotationStyleOffset, stAnnotation); if (vs.annotationVisible == ANNOTATION_BOXED) { - widthAnnotation += vsDraw.spaceWidth * 2; // Margins + widthAnnotation += static_cast<int>(vsDraw.spaceWidth * 2); // Margins } if (widthAnnotation > lineWidthMaxSeen) lineWidthMaxSeen = widthAnnotation; if (vs.annotationVisible == ANNOTATION_BOXED) { - rcSegment.left = xStart + indent; + rcSegment.left = static_cast<XYPOSITION>(xStart + indent); rcSegment.right = rcSegment.left + widthAnnotation; } } @@ -2781,21 +2784,21 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back); rcText.left += vsDraw.spaceWidth; } - DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, rcText.top + vsDraw.maxAscent, + DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, static_cast<int>(rcText.top + vsDraw.maxAscent), stAnnotation, start, lengthAnnotation); if (vs.annotationVisible == ANNOTATION_BOXED) { surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore); - surface->MoveTo(rcSegment.left, rcSegment.top); - surface->LineTo(rcSegment.left, rcSegment.bottom); - surface->MoveTo(rcSegment.right, rcSegment.top); - surface->LineTo(rcSegment.right, rcSegment.bottom); + 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)); if (subLine == ll->lines) { - surface->MoveTo(rcSegment.left, rcSegment.top); - surface->LineTo(rcSegment.right, rcSegment.top); + surface->MoveTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.top)); + surface->LineTo(static_cast<int>(rcSegment.right), static_cast<int>(rcSegment.top)); } if (subLine == ll->lines+annotationLines-1) { - surface->MoveTo(rcSegment.left, rcSegment.bottom - 1); - surface->LineTo(rcSegment.right, rcSegment.bottom - 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)); } } } @@ -2897,7 +2900,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis // draw continuation rect PRectangle rcPlace = rcSegment; - rcPlace.left = ll->positions[startseg] + xStart - subLineStart; + rcPlace.left = ll->positions[startseg] + xStart - static_cast<XYPOSITION>(subLineStart); rcPlace.right = rcPlace.left + ll->wrapIndent; // default bgnd here.. @@ -2941,8 +2944,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis const int i = ts.end() - 1; const int iDoc = i + posLineStart; - rcSegment.left = ll->positions[ts.start] + xStart - subLineStart; - rcSegment.right = ll->positions[ts.end()] + xStart - subLineStart; + rcSegment.left = ll->positions[ts.start] + xStart - static_cast<XYPOSITION>(subLineStart); + rcSegment.right = ll->positions[ts.end()] + xStart - static_cast<XYPOSITION>(subLineStart); // Only try to draw if really visible - enhances performance by not calling environment to // draw strings that are completely past the right side of the window. if (rcSegment.Intersects(rcLine)) { @@ -2976,9 +2979,10 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (ll->chars[cpos + ts.start] == ' ') { if (drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { - PRectangle rcSpace(ll->positions[cpos + ts.start] + xStart - subLineStart, + PRectangle rcSpace( + ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart), rcSegment.top, - ll->positions[cpos + ts.start + 1] + xStart - subLineStart, + ll->positions[cpos + ts.start + 1] + xStart - static_cast<XYPOSITION>(subLineStart), rcSegment.bottom); surface->FillRectangle(rcSpace, vsDraw.whitespaceColours.back); } @@ -3001,8 +3005,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, true); if (vsDraw.edgeState == EDGE_LINE) { - int edgeX = vsDraw.theEdge * vsDraw.spaceWidth; - rcSegment.left = edgeX + xStart; + int edgeX = static_cast<int>(vsDraw.theEdge * vsDraw.spaceWidth); + rcSegment.left = static_cast<XYPOSITION>(edgeX + xStart); if ((ll->wrapIndent != 0) && (lineStart != 0)) rcSegment.left -= ll->wrapIndent; rcSegment.right = rcSegment.left + 1; @@ -3033,8 +3037,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis const int i = ts.end() - 1; const int iDoc = i + posLineStart; - rcSegment.left = ll->positions[ts.start] + xStart - subLineStart; - rcSegment.right = ll->positions[ts.end()] + xStart - subLineStart; + rcSegment.left = ll->positions[ts.start] + xStart - static_cast<XYPOSITION>(subLineStart); + rcSegment.right = ll->positions[ts.end()] + xStart - static_cast<XYPOSITION>(subLineStart); // Only try to draw if really visible - enhances performance by not calling environment to // draw strings that are completely past the right side of the window. if (rcSegment.Intersects(rcLine)) { @@ -3062,11 +3066,11 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis surface->FillRectangle(rcSegment, textBack); } if (inIndentation && vsDraw.viewIndentationGuides == ivReal) { - for (int indentCount = (ll->positions[i] + epsilon) / indentWidth; + for (int indentCount = static_cast<int>((ll->positions[i] + epsilon) / indentWidth); indentCount <= (ll->positions[i + 1] - epsilon) / indentWidth; indentCount++) { if (indentCount > 0) { - int xIndent = indentCount * indentWidth; + int xIndent = static_cast<int>(indentCount * indentWidth); DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); } @@ -3079,7 +3083,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis surface->PenColour(textFore); PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4, rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent); - DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2); + DrawTabArrow(surface, rcTab, static_cast<int>(rcSegment.top + vsDraw.lineHeight / 2)); } } } else { @@ -3118,24 +3122,26 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (!twoPhaseDraw && drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { textBack = vsDraw.whitespaceColours.back; - PRectangle rcSpace(ll->positions[cpos + ts.start] + xStart - subLineStart, + PRectangle rcSpace( + ll->positions[cpos + ts.start] + xStart - static_cast<XYPOSITION>(subLineStart), rcSegment.top, - ll->positions[cpos + ts.start + 1] + xStart - subLineStart, + ll->positions[cpos + ts.start + 1] + xStart - static_cast<XYPOSITION>(subLineStart), rcSegment.bottom); surface->FillRectangle(rcSpace, textBack); } - PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f); + PRectangle rcDot(xmid + xStart - static_cast<XYPOSITION>(subLineStart), + rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f); rcDot.right = rcDot.left + vs.whitespaceSize; rcDot.bottom = rcDot.top + vs.whitespaceSize; surface->FillRectangle(rcDot, textFore); } } if (inIndentation && vsDraw.viewIndentationGuides == ivReal) { - for (int indentCount = (ll->positions[cpos + ts.start] + epsilon) / indentWidth; + for (int indentCount = static_cast<int>((ll->positions[cpos + ts.start] + epsilon) / indentWidth); indentCount <= (ll->positions[cpos + ts.start + 1] - epsilon) / indentWidth; indentCount++) { if (indentCount > 0) { - int xIndent = indentCount * indentWidth; + int xIndent = static_cast<int>(indentCount * indentWidth); DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); } @@ -3168,7 +3174,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if ((vsDraw.viewIndentationGuides == ivLookForward || vsDraw.viewIndentationGuides == ivLookBoth) && (subLine == 0)) { int indentSpace = pdoc->GetLineIndentation(line); - int xStartText = ll->positions[pdoc->GetLineIndentPosition(line) - posLineStart]; + int xStartText = static_cast<int>(ll->positions[pdoc->GetLineIndentPosition(line) - posLineStart]); // Find the most recent line with some text @@ -3207,7 +3213,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } for (int indentPos = pdoc->IndentSize(); indentPos < indentSpace; indentPos += pdoc->IndentSize()) { - int xIndent = indentPos * vsDraw.spaceWidth; + int xIndent = static_cast<int>(indentPos * vsDraw.spaceWidth); if (xIndent < xStartText) { DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, (ll->xHighlightGuide == xIndent)); @@ -3238,8 +3244,10 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis SelectionSegment portion = sel.Range(r).Intersect(virtualSpaceRange); if (!portion.Empty()) { const XYPOSITION spaceWidth = vsDraw.styles[ll->EndLineStyle()].spaceWidth; - rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth; - rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth; + rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - + static_cast<XYPOSITION>(subLineStart) + portion.start.VirtualSpace() * spaceWidth; + rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - + static_cast<XYPOSITION>(subLineStart) + portion.end.VirtualSpace() * spaceWidth; if ((ll->wrapIndent != 0) && (lineStart != 0)) { if ((portion.start.Position() - posLineStart) == lineStart && sel.Range(r).ContainsCharacter(portion.start.Position() - 1)) rcSegment.left -= static_cast<int>(ll->wrapIndent); // indentation added to xStart was truncated to int, so we do the same here @@ -3407,10 +3415,10 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) { if (bufferedDraw) { if (!pixmapLine->Initialised()) { PRectangle rcClient = GetClientRectangle(); - pixmapLine->InitPixMap(rcClient.Width(), vs.lineHeight, + pixmapLine->InitPixMap(static_cast<int>(rcClient.Width()), vs.lineHeight, surfaceWindow, wMain.GetID()); pixmapSelMargin->InitPixMap(vs.fixedColumnWidth, - rcClient.Height(), surfaceWindow, wMain.GetID()); + static_cast<int>(rcClient.Height()), surfaceWindow, wMain.GetID()); } } } @@ -3464,7 +3472,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS xposCaret += xStart; if (posDrag.IsValid()) { /* Dragging text, use a line caret */ - rcCaret.left = RoundXYPosition(xposCaret - caretWidthOffset); + rcCaret.left = static_cast<XYPOSITION>(RoundXYPosition(xposCaret - caretWidthOffset)); rcCaret.right = rcCaret.left + vsDraw.caretWidth; } else if (inOverstrike && drawOverstrikeCaret) { /* Overstrike (insert mode), use a modified bar caret */ @@ -3482,7 +3490,7 @@ void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xS } } else { /* Line caret */ - rcCaret.left = RoundXYPosition(xposCaret - caretWidthOffset); + rcCaret.left = static_cast<XYPOSITION>(RoundXYPosition(xposCaret - caretWidthOffset)); rcCaret.right = rcCaret.left + vsDraw.caretWidth; } ColourDesired caretColour = mainCaret ? vsDraw.caretcolour : vsDraw.additionalCaretColour; @@ -3517,9 +3525,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //Platform::DebugPrintf("Client: (%3d,%3d) ... (%3d,%3d) %d\n", // rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); - int screenLinePaintFirst = rcArea.top / vs.lineHeight; + int screenLinePaintFirst = static_cast<int>(rcArea.top) / vs.lineHeight; - int xStart = vs.textStart - xOffset + ptOrigin.x; + int xStart = vs.textStart - xOffset + static_cast<int>(ptOrigin.x); int ypos = 0; if (!bufferedDraw) ypos += screenLinePaintFirst * vs.lineHeight; @@ -3650,8 +3658,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { GetHotSpotRange(ll->hsStart, ll->hsEnd); PRectangle rcLine = rcTextArea; - rcLine.top = ypos; - rcLine.bottom = ypos + vs.lineHeight; + rcLine.top = static_cast<XYPOSITION>(ypos); + rcLine.bottom = static_cast<XYPOSITION>(ypos + vs.lineHeight); bool bracesIgnoreStyle = false; if ((vs.braceHighlightIndicatorSet && (bracesMatchStyle == STYLE_BRACELIGHT)) || @@ -3661,7 +3669,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { Range rangeLine(pdoc->LineStart(lineDoc), pdoc->LineStart(lineDoc + 1)); // Highlight the current braces if any ll->SetBracesHighlight(rangeLine, braces, static_cast<char>(bracesMatchStyle), - highlightGuideColumn * vs.spaceWidth, bracesIgnoreStyle); + static_cast<int>(highlightGuideColumn * vs.spaceWidth), bracesIgnoreStyle); if (leftTextOverlap && bufferedDraw) { PRectangle rcSpacer = rcLine; @@ -3711,7 +3719,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { } lineWidthMaxSeen = Platform::Maximum( - lineWidthMaxSeen, ll->positions[ll->numCharsInLine]); + lineWidthMaxSeen, static_cast<int>(ll->positions[ll->numCharsInLine])); //durCopy += et.Duration(true); } @@ -3730,14 +3738,14 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { // Right column limit indicator PRectangle rcBeyondEOF = (vs.marginInside) ? rcClient : rcArea; - rcBeyondEOF.left = vs.textStart; + rcBeyondEOF.left = static_cast<XYPOSITION>(vs.textStart); rcBeyondEOF.right = rcBeyondEOF.right - ((vs.marginInside) ? vs.rightMarginWidth : 0); - rcBeyondEOF.top = (cs.LinesDisplayed() - TopLineOfMain()) * vs.lineHeight; + rcBeyondEOF.top = static_cast<XYPOSITION>((cs.LinesDisplayed() - TopLineOfMain()) * vs.lineHeight); if (rcBeyondEOF.top < rcBeyondEOF.bottom) { surfaceWindow->FillRectangle(rcBeyondEOF, vs.styles[STYLE_DEFAULT].back); if (vs.edgeState == EDGE_LINE) { - int edgeX = vs.theEdge * vs.spaceWidth; - rcBeyondEOF.left = edgeX + xStart; + int edgeX = static_cast<int>(vs.theEdge * vs.spaceWidth); + rcBeyondEOF.left = static_cast<XYPOSITION>(edgeX + xStart); rcBeyondEOF.right = rcBeyondEOF.left + 1; surfaceWindow->FillRectangle(rcBeyondEOF, vs.edgecolour); } @@ -3842,8 +3850,8 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { // Determining width must hapen after fonts have been realised in Refresh int lineNumberWidth = 0; if (lineNumberIndex >= 0) { - lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, - "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace)); + lineNumberWidth = static_cast<int>(surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font, + "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace))); vsPrint.ms[lineNumberIndex].width = lineNumberWidth; vsPrint.Refresh(*surfaceMeasure, pdoc->tabInChars); // Recalculate fixedColumnWidth } @@ -3891,11 +3899,11 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { ll.containsCaret = false; - PRectangle rcLine; - rcLine.left = pfr->rc.left; - rcLine.top = ypos; - rcLine.right = pfr->rc.right - 1; - rcLine.bottom = ypos + vsPrint.lineHeight; + PRectangle rcLine( + pfr->rc.left, + ypos, + pfr->rc.right - 1, + ypos + vsPrint.lineHeight); // When document line is wrapped over multiple display lines, find where // to start printing from to ensure a particular position is on the first @@ -3925,7 +3933,7 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { vsPrint.styles[STYLE_LINENUMBER].font, number, istrlen(number)); surface->FlushCachedState(); surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font, - ypos + vsPrint.maxAscent, number, istrlen(number), + static_cast<XYPOSITION>(ypos + vsPrint.maxAscent), number, istrlen(number), vsPrint.styles[STYLE_LINENUMBER].fore, vsPrint.styles[STYLE_LINENUMBER].back); } @@ -3937,8 +3945,8 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { if (ypos + vsPrint.lineHeight <= pfr->rc.bottom) { if (visibleLine >= 0) { if (draw) { - rcLine.top = ypos; - rcLine.bottom = ypos + vsPrint.lineHeight; + rcLine.top = static_cast<XYPOSITION>(ypos); + rcLine.bottom = static_cast<XYPOSITION>(ypos + vsPrint.lineHeight); DrawLine(surface, vsPrint, lineDoc, visibleLine, xStart, rcLine, &ll, iwl); } ypos += vsPrint.lineHeight; @@ -3964,7 +3972,7 @@ int Editor::TextWidth(int style, const char *text) { RefreshStyleData(); AutoSurface surface(this); if (surface) { - return surface->WidthText(vs.styles[style].font, text, istrlen(text)); + return static_cast<int>(surface->WidthText(vs.styles[style].font, text, istrlen(text))); } else { return 1; } @@ -4002,7 +4010,7 @@ void Editor::ChangeSize() { SetScrollBars(); if (Wrapping()) { PRectangle rcTextArea = GetClientRectangle(); - rcTextArea.left = vs.textStart; + rcTextArea.left = static_cast<XYPOSITION>(vs.textStart); rcTextArea.right -= vs.rightMarginWidth; if (wrapWidth != rcTextArea.Width()) { NeedWrapping(); @@ -4639,8 +4647,8 @@ void Editor::NotifyDwelling(Point pt, bool state) { SCNotification scn = {}; scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND; scn.position = PositionFromLocation(pt, true); - scn.x = pt.x + vs.ExternalMarginWidth(); - scn.y = pt.y; + scn.x = static_cast<int>(pt.x + vs.ExternalMarginWidth()); + scn.y = static_cast<int>(pt.y); NotifyParent(scn); } @@ -5210,7 +5218,7 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { if (vs.annotationVisible) { int lineDoc = pdoc->LineFromPosition(caretToUse.Position()); Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc)); - int subLine = (pt.y - ptStartLine.y) / vs.lineHeight; + int subLine = static_cast<int>(pt.y - ptStartLine.y) / vs.lineHeight; if (direction < 0 && subLine == 0) { int lineDisplay = cs.DisplayFromDoc(lineDoc); @@ -5222,7 +5230,7 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { } } - int newY = pt.y + (1 + skipLines) * direction * vs.lineHeight; + int newY = static_cast<int>(pt.y) + (1 + skipLines) * direction * vs.lineHeight; SelectionPosition posNew = SPositionFromLocation( Point(lastXChosen - xOffset, newY), false, false, UserVirtualSpace()); @@ -5797,7 +5805,7 @@ int Editor::KeyDownWithModifiers(int key, int modifiers, bool *consumed) { if (msg) { if (consumed) *consumed = true; - return WndProc(msg, 0, 0); + return static_cast<int>(WndProc(msg, 0, 0)); } else { if (consumed) *consumed = false; @@ -5917,7 +5925,7 @@ long Editor::FindText( (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, - wParam, + static_cast<int>(wParam), &lengthFound); if (pos != -1) { ft->chrgText.cpMin = pos; @@ -5963,7 +5971,7 @@ long Editor::SearchText( (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, - wParam, + static_cast<int>(wParam), &lengthFound); } else { pos = pdoc->FindText(searchAnchor, 0, txt, @@ -5971,7 +5979,7 @@ long Editor::SearchText( (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, - wParam, + static_cast<int>(wParam), &lengthFound); } if (pos != -1) { @@ -6125,8 +6133,8 @@ void Editor::DisplayCursor(Window::Cursor c) { } bool Editor::DragThreshold(Point ptStart, Point ptNow) { - int xMove = ptStart.x - ptNow.x; - int yMove = ptStart.y - ptNow.y; + int xMove = static_cast<int>(ptStart.x - ptNow.x); + int yMove = static_cast<int>(ptStart.y - ptNow.y); int distanceSquared = xMove * xMove + yMove * yMove; return distanceSquared > 16; } @@ -6245,8 +6253,8 @@ bool Editor::PointInSelMargin(Point pt) { // Really means: "Point in a margin" if (vs.fixedColumnWidth > 0) { // There is a margin PRectangle rcSelMargin = GetClientRectangle(); - rcSelMargin.right = vs.textStart - vs.leftMarginWidth; - rcSelMargin.left = vs.textStart - vs.fixedColumnWidth; + rcSelMargin.right = static_cast<XYPOSITION>(vs.textStart - vs.leftMarginWidth); + rcSelMargin.left = static_cast<XYPOSITION>(vs.textStart - vs.fixedColumnWidth); return rcSelMargin.Contains(pt); } else { return false; @@ -6520,7 +6528,7 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie } lastClickTime = curTime; lastClick = pt; - lastXChosen = pt.x + xOffset; + lastXChosen = static_cast<int>(pt.x) + xOffset; ShowCaretAtCurrentPosition(); } @@ -6772,7 +6780,7 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { SetRectangularRange(); lastClickTime = curTime; lastClick = pt; - lastXChosen = pt.x + xOffset; + lastXChosen = static_cast<int>(pt.x) + xOffset; if (sel.selType == Selection::selStream) { SetLastXChosen(); } @@ -6853,7 +6861,7 @@ int Editor::PositionAfterArea(PRectangle rcArea) const { // The start of the document line after the display line after the area // This often means that the line after a modification is restyled which helps // detect multiline comment additions and heals single line comments - int lineAfter = TopLineOfMain() + (rcArea.bottom - 1) / vs.lineHeight + 1; + int lineAfter = TopLineOfMain() + static_cast<int>(rcArea.bottom - 1) / vs.lineHeight + 1; if (lineAfter < cs.LinesDisplayed()) return pdoc->LineStart(cs.DocFromDisplay(lineAfter) + 1); else @@ -6907,7 +6915,7 @@ bool Editor::PaintContainsMargin() { return false; } PRectangle rcSelMargin = GetClientRectangle(); - rcSelMargin.right = vs.textStart; + rcSelMargin.right = static_cast<XYPOSITION>(vs.textStart); return PaintContains(rcSelMargin); } @@ -7341,7 +7349,7 @@ void Editor::AddStyledText(char *buffer, int appendLength) { SetEmptySelection(sel.MainCaret() + lengthInserted); } -static bool ValidMargin(unsigned long wParam) { +static bool ValidMargin(uptr_t wParam) { return wParam <= SC_MAX_MARGIN; } @@ -7353,16 +7361,16 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam vs.EnsureStyle(wParam); switch (iMessage) { case SCI_STYLESETFORE: - vs.styles[wParam].fore = ColourDesired(lParam); + vs.styles[wParam].fore = ColourDesired(static_cast<long>(lParam)); break; case SCI_STYLESETBACK: - vs.styles[wParam].back = ColourDesired(lParam); + vs.styles[wParam].back = ColourDesired(static_cast<long>(lParam)); break; case SCI_STYLESETBOLD: vs.styles[wParam].weight = lParam != 0 ? SC_WEIGHT_BOLD : SC_WEIGHT_NORMAL; break; case SCI_STYLESETWEIGHT: - vs.styles[wParam].weight = lParam; + vs.styles[wParam].weight = static_cast<int>(lParam); break; case SCI_STYLESETITALIC: vs.styles[wParam].italic = lParam != 0; @@ -7371,14 +7379,14 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam vs.styles[wParam].eolFilled = lParam != 0; break; case SCI_STYLESETSIZE: - vs.styles[wParam].size = lParam * SC_FONT_SIZE_MULTIPLIER; + vs.styles[wParam].size = static_cast<int>(lParam * SC_FONT_SIZE_MULTIPLIER); break; case SCI_STYLESETSIZEFRACTIONAL: - vs.styles[wParam].size = lParam; + vs.styles[wParam].size = static_cast<int>(lParam); break; case SCI_STYLESETFONT: if (lParam != 0) { - vs.SetStyleFontName(wParam, CharPtrFromSPtr(lParam)); + vs.SetStyleFontName(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); } break; case SCI_STYLESETUNDERLINE: @@ -7388,7 +7396,7 @@ void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam vs.styles[wParam].caseForce = static_cast<Style::ecaseForced>(lParam); break; case SCI_STYLESETCHARACTERSET: - vs.styles[wParam].characterSet = lParam; + vs.styles[wParam].characterSet = static_cast<int>(lParam); pdoc->SetCaseFolder(NULL); break; case SCI_STYLESETVISIBLE: @@ -7527,11 +7535,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_COPYRANGE: - CopyRangeToClipboard(wParam, lParam); + CopyRangeToClipboard(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_COPYTEXT: - CopyText(wParam, CharPtrFromSPtr(lParam)); + CopyText(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); break; case SCI_PASTE: @@ -7564,12 +7572,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return topLine; case SCI_SETFIRSTVISIBLELINE: - ScrollTo(wParam); + ScrollTo(static_cast<int>(wParam)); break; case SCI_GETLINE: { // Risk of overwriting the end of the buffer - int lineStart = pdoc->LineStart(wParam); - int lineEnd = pdoc->LineStart(wParam + 1); + int lineStart = pdoc->LineStart(static_cast<int>(wParam)); + int lineEnd = pdoc->LineStart(static_cast<int>(wParam + 1)); if (lParam == 0) { return lineEnd - lineStart; } @@ -7626,7 +7634,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_LINEFROMPOSITION: if (static_cast<int>(wParam) < 0) return 0; - return pdoc->LineFromPosition(wParam); + return pdoc->LineFromPosition(static_cast<int>(wParam)); case SCI_POSITIONFROMLINE: if (static_cast<int>(wParam) < 0) @@ -7637,14 +7645,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return -1; //if (wParam > pdoc->LineFromPosition(pdoc->Length())) // Useful test, anyway... // return -1; - return pdoc->LineStart(wParam); + return pdoc->LineStart(static_cast<int>(wParam)); // Replacement of the old Scintilla interpretation of EM_LINELENGTH case SCI_LINELENGTH: if ((static_cast<int>(wParam) < 0) || (static_cast<int>(wParam) > pdoc->LineFromPosition(pdoc->Length()))) return 0; - return pdoc->LineStart(wParam + 1) - pdoc->LineStart(wParam); + return pdoc->LineStart(static_cast<int>(wParam) + 1) - pdoc->LineStart(static_cast<int>(wParam)); case SCI_REPLACESEL: { if (lParam == 0) @@ -7660,14 +7668,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETTARGETSTART: - targetStart = wParam; + targetStart = static_cast<int>(wParam); break; case SCI_GETTARGETSTART: return targetStart; case SCI_SETTARGETEND: - targetEnd = wParam; + targetEnd = static_cast<int>(wParam); break; case SCI_GETTARGETEND: @@ -7685,42 +7693,42 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_REPLACETARGET: PLATFORM_ASSERT(lParam); - return ReplaceTarget(false, CharPtrFromSPtr(lParam), wParam); + return ReplaceTarget(false, CharPtrFromSPtr(lParam), static_cast<int>(wParam)); case SCI_REPLACETARGETRE: PLATFORM_ASSERT(lParam); - return ReplaceTarget(true, CharPtrFromSPtr(lParam), wParam); + return ReplaceTarget(true, CharPtrFromSPtr(lParam), static_cast<int>(wParam)); case SCI_SEARCHINTARGET: PLATFORM_ASSERT(lParam); - return SearchInTarget(CharPtrFromSPtr(lParam), wParam); + return SearchInTarget(CharPtrFromSPtr(lParam), static_cast<int>(wParam)); case SCI_SETSEARCHFLAGS: - searchFlags = wParam; + searchFlags = static_cast<int>(wParam); break; case SCI_GETSEARCHFLAGS: return searchFlags; case SCI_GETTAG: - return GetTag(CharPtrFromSPtr(lParam), wParam); + return GetTag(CharPtrFromSPtr(lParam), static_cast<int>(wParam)); case SCI_POSITIONBEFORE: - return pdoc->MovePositionOutsideChar(wParam - 1, -1, true); + return pdoc->MovePositionOutsideChar(static_cast<int>(wParam) - 1, -1, true); case SCI_POSITIONAFTER: - return pdoc->MovePositionOutsideChar(wParam + 1, 1, true); + return pdoc->MovePositionOutsideChar(static_cast<int>(wParam) + 1, 1, true); case SCI_POSITIONRELATIVE: - return Platform::Clamp(pdoc->GetRelativePosition(wParam, lParam), 0, pdoc->Length()); + return Platform::Clamp(pdoc->GetRelativePosition(static_cast<int>(wParam), static_cast<int>(lParam)), 0, pdoc->Length()); case SCI_LINESCROLL: - ScrollTo(topLine + lParam); - HorizontalScrollTo(xOffset + static_cast<int>(wParam) * vs.spaceWidth); + ScrollTo(topLine + static_cast<int>(lParam)); + HorizontalScrollTo(xOffset + static_cast<int>(wParam)* static_cast<int>(vs.spaceWidth)); return 1; case SCI_SETXOFFSET: - xOffset = wParam; + xOffset = static_cast<int>(wParam); ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); SetHorizontalScrollPos(); Redraw(); @@ -7751,17 +7759,17 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (lParam < 0) { return 0; } else { - Point pt = LocationFromPosition(lParam); + Point pt = LocationFromPosition(static_cast<int>(lParam)); // Convert to view-relative - return pt.x - vs.textStart + vs.fixedColumnWidth; + return static_cast<int>(pt.x) - vs.textStart + vs.fixedColumnWidth; } case SCI_POINTYFROMPOSITION: if (lParam < 0) { return 0; } else { - Point pt = LocationFromPosition(lParam); - return pt.y; + Point pt = LocationFromPosition(static_cast<int>(lParam)); + return static_cast<int>(pt.y); } case SCI_FINDTEXT: @@ -7797,13 +7805,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.rightMarginWidth; case SCI_SETMARGINLEFT: - lastXChosen += lParam - vs.leftMarginWidth; - vs.leftMarginWidth = lParam; + lastXChosen += static_cast<int>(lParam) - vs.leftMarginWidth; + vs.leftMarginWidth = static_cast<int>(lParam); InvalidateStyleRedraw(); break; case SCI_SETMARGINRIGHT: - vs.rightMarginWidth = lParam; + vs.rightMarginWidth = static_cast<int>(lParam); InvalidateStyleRedraw(); break; @@ -7813,20 +7821,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (lParam == 0) return 0; const int lengthInserted = pdoc->InsertString( - CurrentPosition(), CharPtrFromSPtr(lParam), wParam); + CurrentPosition(), CharPtrFromSPtr(lParam), static_cast<int>(wParam)); SetEmptySelection(sel.MainCaret() + lengthInserted); return 0; } case SCI_ADDSTYLEDTEXT: if (lParam) - AddStyledText(CharPtrFromSPtr(lParam), wParam); + AddStyledText(CharPtrFromSPtr(lParam), static_cast<int>(wParam)); return 0; case SCI_INSERTTEXT: { if (lParam == 0) return 0; - int insertPos = wParam; + int insertPos = static_cast<int>(wParam); if (static_cast<int>(wParam) == -1) insertPos = CurrentPosition(); int newCurrent = CurrentPosition(); @@ -7840,11 +7848,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_CHANGEINSERTION: PLATFORM_ASSERT(lParam); - pdoc->ChangeInsertion(CharPtrFromSPtr(lParam), wParam); + pdoc->ChangeInsertion(CharPtrFromSPtr(lParam), static_cast<int>(wParam)); return 0; case SCI_APPENDTEXT: - pdoc->InsertString(pdoc->Length(), CharPtrFromSPtr(lParam), wParam); + pdoc->InsertString(pdoc->Length(), CharPtrFromSPtr(lParam), static_cast<int>(wParam)); return 0; case SCI_CLEARALL: @@ -7852,7 +7860,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return 0; case SCI_DELETERANGE: - pdoc->DeleteChars(wParam, lParam); + pdoc->DeleteChars(static_cast<int>(wParam), static_cast<int>(lParam)); return 0; case SCI_CLEARDOCUMENTSTYLE: @@ -7878,7 +7886,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return caret.period; case SCI_SETCARETPERIOD: - CaretSetPeriod(wParam); + CaretSetPeriod(static_cast<int>(wParam)); break; case SCI_GETWORDCHARS: @@ -7920,19 +7928,19 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->Length(); case SCI_ALLOCATE: - pdoc->Allocate(wParam); + pdoc->Allocate(static_cast<int>(wParam)); break; case SCI_GETCHARAT: - return pdoc->CharAt(wParam); + return pdoc->CharAt(static_cast<int>(wParam)); case SCI_SETCURRENTPOS: if (sel.IsRectangular()) { - sel.Rectangular().caret.SetPosition(wParam); + sel.Rectangular().caret.SetPosition(static_cast<int>(wParam)); SetRectangularRange(); Redraw(); } else { - SetSelection(wParam, sel.MainAnchor()); + SetSelection(static_cast<int>(wParam), sel.MainAnchor()); } break; @@ -7941,11 +7949,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETANCHOR: if (sel.IsRectangular()) { - sel.Rectangular().anchor.SetPosition(wParam); + sel.Rectangular().anchor.SetPosition(static_cast<int>(wParam)); SetRectangularRange(); Redraw(); } else { - SetSelection(sel.MainCaret(), wParam); + SetSelection(sel.MainCaret(), static_cast<int>(wParam)); } break; @@ -7953,32 +7961,32 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.IsRectangular() ? sel.Rectangular().anchor.Position() : sel.MainAnchor(); case SCI_SETSELECTIONSTART: - SetSelection(Platform::Maximum(sel.MainCaret(), wParam), wParam); + SetSelection(Platform::Maximum(sel.MainCaret(), static_cast<int>(wParam)), static_cast<int>(wParam)); break; case SCI_GETSELECTIONSTART: return sel.LimitsForRectangularElseMain().start.Position(); case SCI_SETSELECTIONEND: - SetSelection(wParam, Platform::Minimum(sel.MainAnchor(), wParam)); + SetSelection(static_cast<int>(wParam), Platform::Minimum(sel.MainAnchor(), static_cast<int>(wParam))); break; case SCI_GETSELECTIONEND: return sel.LimitsForRectangularElseMain().end.Position(); case SCI_SETEMPTYSELECTION: - SetEmptySelection(wParam); + SetEmptySelection(static_cast<int>(wParam)); break; case SCI_SETPRINTMAGNIFICATION: - printParameters.magnification = wParam; + printParameters.magnification = static_cast<int>(wParam); break; case SCI_GETPRINTMAGNIFICATION: return printParameters.magnification; case SCI_SETPRINTCOLOURMODE: - printParameters.colourMode = wParam; + printParameters.colourMode = static_cast<int>(wParam); break; case SCI_GETPRINTCOLOURMODE: @@ -7995,7 +8003,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (static_cast<int>(wParam) >= pdoc->Length()) return 0; else - return pdoc->StyleAt(wParam); + return pdoc->StyleAt(static_cast<int>(wParam)); case SCI_REDO: Redo(); @@ -8027,10 +8035,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return (pdoc->CanRedo() && !pdoc->IsReadOnly()) ? 1 : 0; case SCI_MARKERLINEFROMHANDLE: - return pdoc->LineFromHandle(wParam); + return pdoc->LineFromHandle(static_cast<int>(wParam)); case SCI_MARKERDELETEHANDLE: - pdoc->DeleteMarkFromHandle(wParam); + pdoc->DeleteMarkFromHandle(static_cast<int>(wParam)); break; case SCI_GETVIEWWS: @@ -8050,27 +8058,27 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_POSITIONFROMPOINT: - return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam), + return PositionFromLocation(Point(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), false, false); case SCI_POSITIONFROMPOINTCLOSE: - return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam), + return PositionFromLocation(Point(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), true, false); case SCI_CHARPOSITIONFROMPOINT: - return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam), + return PositionFromLocation(Point(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), false, true); case SCI_CHARPOSITIONFROMPOINTCLOSE: - return PositionFromLocation(Point(wParam - vs.ExternalMarginWidth(), lParam), + return PositionFromLocation(Point(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), true, true); case SCI_GOTOLINE: - GoToLine(wParam); + GoToLine(static_cast<int>(wParam)); break; case SCI_GOTOPOS: - SetEmptySelection(wParam); + SetEmptySelection(static_cast<int>(wParam)); EnsureCaretVisible(); break; @@ -8098,11 +8106,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->eolMode; case SCI_SETEOLMODE: - pdoc->eolMode = wParam; + pdoc->eolMode = static_cast<int>(wParam); break; case SCI_SETLINEENDTYPESALLOWED: - if (pdoc->SetLineEndTypesAllowed(wParam)) { + if (pdoc->SetLineEndTypesAllowed(static_cast<int>(wParam))) { cs.Clear(); cs.InsertLines(0, pdoc->LinesTotal() - 1); SetAnnotationHeights(0, pdoc->LinesTotal()); @@ -8117,17 +8125,17 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->GetLineEndTypesActive(); case SCI_STARTSTYLING: - pdoc->StartStyling(wParam, static_cast<char>(lParam)); + pdoc->StartStyling(static_cast<int>(wParam), static_cast<char>(lParam)); break; case SCI_SETSTYLING: - pdoc->SetStyleFor(wParam, static_cast<char>(lParam)); + pdoc->SetStyleFor(static_cast<int>(wParam), static_cast<char>(lParam)); break; case SCI_SETSTYLINGEX: // Specify a complete styling buffer if (lParam == 0) return 0; - pdoc->SetStyles(wParam, CharPtrFromSPtr(lParam)); + pdoc->SetStyles(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); break; case SCI_SETBUFFEREDDRAW: @@ -8156,7 +8164,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETTABWIDTH: if (wParam > 0) { - pdoc->tabInChars = wParam; + pdoc->tabInChars = static_cast<int>(wParam); if (pdoc->indentInChars == 0) pdoc->actualIndentInChars = pdoc->tabInChars; } @@ -8167,7 +8175,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->tabInChars; case SCI_SETINDENT: - pdoc->indentInChars = wParam; + pdoc->indentInChars = static_cast<int>(wParam); if (pdoc->indentInChars != 0) pdoc->actualIndentInChars = pdoc->indentInChars; else @@ -8187,14 +8195,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->useTabs; case SCI_SETLINEINDENTATION: - pdoc->SetLineIndentation(wParam, lParam); + pdoc->SetLineIndentation(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_GETLINEINDENTATION: - return pdoc->GetLineIndentation(wParam); + return pdoc->GetLineIndentation(static_cast<int>(wParam)); case SCI_GETLINEINDENTPOSITION: - return pdoc->GetLineIndentPosition(wParam); + return pdoc->GetLineIndentPosition(static_cast<int>(wParam)); case SCI_SETTABINDENTS: pdoc->tabIndents = wParam != 0; @@ -8211,7 +8219,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->backspaceUnindents; case SCI_SETMOUSEDWELLTIME: - dwellDelay = wParam; + dwellDelay = static_cast<int>(wParam); ticksToDwell = dwellDelay; break; @@ -8219,13 +8227,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return dwellDelay; case SCI_WORDSTARTPOSITION: - return pdoc->ExtendWordSelect(wParam, -1, lParam != 0); + return pdoc->ExtendWordSelect(static_cast<int>(wParam), -1, lParam != 0); case SCI_WORDENDPOSITION: - return pdoc->ExtendWordSelect(wParam, 1, lParam != 0); + return pdoc->ExtendWordSelect(static_cast<int>(wParam), 1, lParam != 0); case SCI_SETWRAPMODE: - if (vs.SetWrapState(wParam)) { + if (vs.SetWrapState(static_cast<int>(wParam))) { xOffset = 0; ContainerNeedsUpdate(SC_UPDATE_H_SCROLL); InvalidateStyleRedraw(); @@ -8237,7 +8245,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.wrapState; case SCI_SETWRAPVISUALFLAGS: - if (vs.SetWrapVisualFlags(wParam)) { + if (vs.SetWrapVisualFlags(static_cast<int>(wParam))) { InvalidateStyleRedraw(); ReconfigureScrollBars(); } @@ -8247,7 +8255,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.wrapVisualFlags; case SCI_SETWRAPVISUALFLAGSLOCATION: - if (vs.SetWrapVisualFlagsLocation(wParam)) { + if (vs.SetWrapVisualFlagsLocation(static_cast<int>(wParam))) { InvalidateStyleRedraw(); } break; @@ -8256,7 +8264,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.wrapVisualFlagsLocation; case SCI_SETWRAPSTARTINDENT: - if (vs.SetWrapVisualStartIndent(wParam)) { + if (vs.SetWrapVisualStartIndent(static_cast<int>(wParam))) { InvalidateStyleRedraw(); ReconfigureScrollBars(); } @@ -8266,7 +8274,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.wrapVisualStartIndent; case SCI_SETWRAPINDENTMODE: - if (vs.SetWrapIndentMode(wParam)) { + if (vs.SetWrapIndentMode(static_cast<int>(wParam))) { InvalidateStyleRedraw(); ReconfigureScrollBars(); } @@ -8276,7 +8284,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.wrapIndentMode; case SCI_SETLAYOUTCACHE: - llc.SetLevel(wParam); + llc.SetLevel(static_cast<int>(wParam)); break; case SCI_GETLAYOUTCACHE: @@ -8293,7 +8301,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { PLATFORM_ASSERT(wParam > 0); if ((wParam > 0) && (wParam != static_cast<unsigned int >(scrollWidth))) { lineWidthMaxSeen = 0; - scrollWidth = wParam; + scrollWidth = static_cast<int>(wParam); SetScrollBars(); } break; @@ -8313,13 +8321,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_LINESSPLIT: - LinesSplit(wParam); + LinesSplit(static_cast<int>(wParam)); break; case SCI_TEXTWIDTH: PLATFORM_ASSERT(wParam < vs.styles.size()); PLATFORM_ASSERT(lParam); - return TextWidth(wParam, CharPtrFromSPtr(lParam)); + return TextWidth(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); case SCI_TEXTHEIGHT: return vs.lineHeight; @@ -8338,7 +8346,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETCARETSTICKY: PLATFORM_ASSERT(wParam <= SC_CARETSTICKY_WHITESPACE); if (wParam <= SC_CARETSTICKY_WHITESPACE) { - caretSticky = wParam; + caretSticky = static_cast<int>(wParam); } break; @@ -8350,10 +8358,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETCOLUMN: - return pdoc->GetColumn(wParam); + return pdoc->GetColumn(static_cast<int>(wParam)); case SCI_FINDCOLUMN: - return pdoc->FindColumn(wParam, lParam); + return pdoc->FindColumn(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_SETHSCROLLBAR : if (horizontalScrollBarVisible != (wParam != 0)) { @@ -8389,7 +8397,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETHIGHLIGHTGUIDE: if ((highlightGuideColumn != static_cast<int>(wParam)) || (wParam > 0)) { - highlightGuideColumn = wParam; + highlightGuideColumn = static_cast<int>(wParam); Redraw(); } break; @@ -8398,11 +8406,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return highlightGuideColumn; case SCI_GETLINEENDPOSITION: - return pdoc->LineEnd(wParam); + return pdoc->LineEnd(static_cast<int>(wParam)); case SCI_SETCODEPAGE: - if (ValidCodePage(wParam)) { - if (pdoc->SetDBCSCodePage(wParam)) { + if (ValidCodePage(static_cast<int>(wParam))) { + if (pdoc->SetDBCSCodePage(static_cast<int>(wParam))) { cs.Clear(); cs.InsertLines(0, pdoc->LinesTotal() - 1); SetAnnotationHeights(0, pdoc->LinesTotal()); @@ -8427,7 +8435,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { // Marker definition and setting case SCI_MARKERDEFINE: if (wParam <= MARKER_MAX) { - vs.markers[wParam].markType = lParam; + vs.markers[wParam].markType = static_cast<int>(lParam); vs.CalcLargestMarkerHeight(); } InvalidateStyleData(); @@ -8442,13 +8450,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_MARKERSETFORE: if (wParam <= MARKER_MAX) - vs.markers[wParam].fore = ColourDesired(lParam); + vs.markers[wParam].fore = ColourDesired(static_cast<long>(lParam)); InvalidateStyleData(); RedrawSelMargin(); break; case SCI_MARKERSETBACKSELECTED: if (wParam <= MARKER_MAX) - vs.markers[wParam].backSelected = ColourDesired(lParam); + vs.markers[wParam].backSelected = ColourDesired(static_cast<long>(lParam)); InvalidateStyleData(); RedrawSelMargin(); break; @@ -8458,26 +8466,26 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_MARKERSETBACK: if (wParam <= MARKER_MAX) - vs.markers[wParam].back = ColourDesired(lParam); + vs.markers[wParam].back = ColourDesired(static_cast<long>(lParam)); InvalidateStyleData(); RedrawSelMargin(); break; case SCI_MARKERSETALPHA: if (wParam <= MARKER_MAX) - vs.markers[wParam].alpha = lParam; + vs.markers[wParam].alpha = static_cast<int>(lParam); InvalidateStyleRedraw(); break; case SCI_MARKERADD: { - int markerID = pdoc->AddMark(wParam, lParam); + int markerID = pdoc->AddMark(static_cast<int>(wParam), static_cast<int>(lParam)); return markerID; } case SCI_MARKERADDSET: if (lParam != 0) - pdoc->AddMarkSet(wParam, lParam); + pdoc->AddMarkSet(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_MARKERDELETE: - pdoc->DeleteMark(wParam, lParam); + pdoc->DeleteMark(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_MARKERDELETEALL: @@ -8485,13 +8493,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_MARKERGET: - return pdoc->GetMark(wParam); + return pdoc->GetMark(static_cast<int>(wParam)); case SCI_MARKERNEXT: - return pdoc->MarkerNext(wParam, lParam); + return pdoc->MarkerNext(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_MARKERPREVIOUS: { - for (int iLine = wParam; iLine >= 0; iLine--) { + for (int iLine = static_cast<int>(wParam); iLine >= 0; iLine--) { if ((pdoc->GetMark(iLine) & lParam) != 0) return iLine; } @@ -8508,20 +8516,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_RGBAIMAGESETWIDTH: - sizeRGBAImage.x = wParam; + sizeRGBAImage.x = static_cast<XYPOSITION>(wParam); break; case SCI_RGBAIMAGESETHEIGHT: - sizeRGBAImage.y = wParam; + sizeRGBAImage.y = static_cast<XYPOSITION>(wParam); break; case SCI_RGBAIMAGESETSCALE: - scaleRGBAImage = wParam; + scaleRGBAImage = static_cast<float>(wParam); break; case SCI_MARKERDEFINERGBAIMAGE: if (wParam <= MARKER_MAX) { - vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0, reinterpret_cast<unsigned char *>(lParam)); + vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0f, reinterpret_cast<unsigned char *>(lParam)); vs.CalcLargestMarkerHeight(); } InvalidateStyleData(); @@ -8530,7 +8538,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETMARGINTYPEN: if (ValidMargin(wParam)) { - vs.ms[wParam].style = lParam; + vs.ms[wParam].style = static_cast<int>(lParam); InvalidateStyleRedraw(); } break; @@ -8545,8 +8553,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (ValidMargin(wParam)) { // Short-circuit if the width is unchanged, to avoid unnecessary redraw. if (vs.ms[wParam].width != lParam) { - lastXChosen += lParam - vs.ms[wParam].width; - vs.ms[wParam].width = lParam; + lastXChosen += static_cast<int>(lParam) - vs.ms[wParam].width; + vs.ms[wParam].width = static_cast<int>(lParam); InvalidateStyleRedraw(); } } @@ -8560,7 +8568,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETMARGINMASKN: if (ValidMargin(wParam)) { - vs.ms[wParam].mask = lParam; + vs.ms[wParam].mask = static_cast<int>(lParam); InvalidateStyleRedraw(); } break; @@ -8586,7 +8594,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETMARGINCURSORN: if (ValidMargin(wParam)) - vs.ms[wParam].cursor = lParam; + vs.ms[wParam].cursor = static_cast<int>(lParam); break; case SCI_GETMARGINCURSORN: @@ -8641,17 +8649,17 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETSTYLEBITS: vs.EnsureStyle((1 << wParam) - 1); - pdoc->SetStylingBits(wParam); + pdoc->SetStylingBits(static_cast<int>(wParam)); break; case SCI_GETSTYLEBITS: return pdoc->stylingBits; case SCI_SETLINESTATE: - return pdoc->SetLineState(wParam, lParam); + return pdoc->SetLineState(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_GETLINESTATE: - return pdoc->GetLineState(wParam); + return pdoc->GetLineState(static_cast<int>(wParam)); case SCI_GETMAXLINESTATE: return pdoc->GetMaxLineState(); @@ -8672,114 +8680,114 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETCARETLINEBACK: return vs.caretLineBackground.AsLong(); case SCI_SETCARETLINEBACK: - vs.caretLineBackground = wParam; + vs.caretLineBackground = static_cast<int>(wParam); InvalidateStyleRedraw(); break; case SCI_GETCARETLINEBACKALPHA: return vs.caretLineAlpha; case SCI_SETCARETLINEBACKALPHA: - vs.caretLineAlpha = wParam; + vs.caretLineAlpha = static_cast<int>(wParam); InvalidateStyleRedraw(); break; // Folding messages case SCI_VISIBLEFROMDOCLINE: - return cs.DisplayFromDoc(wParam); + return cs.DisplayFromDoc(static_cast<int>(wParam)); case SCI_DOCLINEFROMVISIBLE: - return cs.DocFromDisplay(wParam); + return cs.DocFromDisplay(static_cast<int>(wParam)); case SCI_WRAPCOUNT: - return WrapCount(wParam); + return WrapCount(static_cast<int>(wParam)); case SCI_SETFOLDLEVEL: { - int prev = pdoc->SetLevel(wParam, lParam); - if (prev != lParam) + int prev = pdoc->SetLevel(static_cast<int>(wParam), static_cast<int>(lParam)); + if (prev != static_cast<int>(lParam)) RedrawSelMargin(); return prev; } case SCI_GETFOLDLEVEL: - return pdoc->GetLevel(wParam); + return pdoc->GetLevel(static_cast<int>(wParam)); case SCI_GETLASTCHILD: - return pdoc->GetLastChild(wParam, lParam); + return pdoc->GetLastChild(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_GETFOLDPARENT: - return pdoc->GetFoldParent(wParam); + return pdoc->GetFoldParent(static_cast<int>(wParam)); case SCI_SHOWLINES: - cs.SetVisible(wParam, lParam, true); + cs.SetVisible(static_cast<int>(wParam), static_cast<int>(lParam), true); SetScrollBars(); Redraw(); break; case SCI_HIDELINES: if (wParam > 0) - cs.SetVisible(wParam, lParam, false); + cs.SetVisible(static_cast<int>(wParam), static_cast<int>(lParam), false); SetScrollBars(); Redraw(); break; case SCI_GETLINEVISIBLE: - return cs.GetVisible(wParam); + return cs.GetVisible(static_cast<int>(wParam)); case SCI_GETALLLINESVISIBLE: return cs.HiddenLines() ? 0 : 1; case SCI_SETFOLDEXPANDED: - SetFoldExpanded(wParam, lParam != 0); + SetFoldExpanded(static_cast<int>(wParam), lParam != 0); break; case SCI_GETFOLDEXPANDED: - return cs.GetExpanded(wParam); + return cs.GetExpanded(static_cast<int>(wParam)); case SCI_SETAUTOMATICFOLD: - foldAutomatic = wParam; + foldAutomatic = static_cast<int>(wParam); break; case SCI_GETAUTOMATICFOLD: return foldAutomatic; case SCI_SETFOLDFLAGS: - foldFlags = wParam; + foldFlags = static_cast<int>(wParam); Redraw(); break; case SCI_TOGGLEFOLD: - FoldLine(wParam, SC_FOLDACTION_TOGGLE); + FoldLine(static_cast<int>(wParam), SC_FOLDACTION_TOGGLE); break; case SCI_FOLDLINE: - FoldLine(wParam, lParam); + FoldLine(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_FOLDCHILDREN: - FoldExpand(wParam, lParam, pdoc->GetLevel(wParam)); + FoldExpand(static_cast<int>(wParam), static_cast<int>(lParam), pdoc->GetLevel(static_cast<int>(wParam))); break; case SCI_FOLDALL: - FoldAll(wParam); + FoldAll(static_cast<int>(wParam)); break; case SCI_EXPANDCHILDREN: - FoldExpand(wParam, SC_FOLDACTION_EXPAND, lParam); + FoldExpand(static_cast<int>(wParam), SC_FOLDACTION_EXPAND, static_cast<int>(lParam)); break; case SCI_CONTRACTEDFOLDNEXT: - return ContractedFoldNext(wParam); + return ContractedFoldNext(static_cast<int>(wParam)); case SCI_ENSUREVISIBLE: - EnsureLineVisible(wParam, false); + EnsureLineVisible(static_cast<int>(wParam), false); break; case SCI_ENSUREVISIBLEENFORCEPOLICY: - EnsureLineVisible(wParam, true); + EnsureLineVisible(static_cast<int>(wParam), true); break; case SCI_SCROLLRANGE: - ScrollRange(SelectionRange(lParam, wParam)); + ScrollRange(SelectionRange(static_cast<int>(wParam), static_cast<int>(lParam))); break; case SCI_SEARCHANCHOR: @@ -8791,18 +8799,18 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return SearchText(iMessage, wParam, lParam); case SCI_SETXCARETPOLICY: - caretXPolicy = wParam; - caretXSlop = lParam; + caretXPolicy = static_cast<int>(wParam); + caretXSlop = static_cast<int>(lParam); break; case SCI_SETYCARETPOLICY: - caretYPolicy = wParam; - caretYSlop = lParam; + caretYPolicy = static_cast<int>(wParam); + caretYSlop = static_cast<int>(lParam); break; case SCI_SETVISIBLEPOLICY: - visiblePolicy = wParam; - visibleSlop = lParam; + visiblePolicy = static_cast<int>(wParam); + visibleSlop = static_cast<int>(lParam); break; case SCI_LINESONSCREEN: @@ -8810,19 +8818,19 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETSELFORE: vs.selColours.fore = ColourOptional(wParam, lParam); - vs.selAdditionalForeground = ColourDesired(lParam); + vs.selAdditionalForeground = ColourDesired(static_cast<long>(lParam)); InvalidateStyleRedraw(); break; case SCI_SETSELBACK: vs.selColours.back = ColourOptional(wParam, lParam); - vs.selAdditionalBackground = ColourDesired(lParam); + vs.selAdditionalBackground = ColourDesired(static_cast<long>(lParam)); InvalidateStyleRedraw(); break; case SCI_SETSELALPHA: - vs.selAlpha = wParam; - vs.selAdditionalAlpha = wParam; + vs.selAlpha = static_cast<int>(wParam); + vs.selAdditionalAlpha = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -8848,7 +8856,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETCARETFORE: - vs.caretcolour = ColourDesired(wParam); + vs.caretcolour = ColourDesired(static_cast<long>(wParam)); InvalidateStyleRedraw(); break; @@ -8857,7 +8865,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETCARETSTYLE: if (wParam <= CARETSTYLE_BLOCK) - vs.caretStyle = wParam; + vs.caretStyle = static_cast<int>(wParam); else /* Default to the line caret */ vs.caretStyle = CARETSTYLE_LINE; @@ -8873,7 +8881,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { else if (wParam >= 3) vs.caretWidth = 3; else - vs.caretWidth = wParam; + vs.caretWidth = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -8881,13 +8889,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.caretWidth; case SCI_ASSIGNCMDKEY: - kmap.AssignCmdKey(Platform::LowShortFromLong(wParam), - Platform::HighShortFromLong(wParam), lParam); + kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)), + Platform::HighShortFromLong(static_cast<long>(wParam)), static_cast<unsigned int>(lParam)); break; case SCI_CLEARCMDKEY: - kmap.AssignCmdKey(Platform::LowShortFromLong(wParam), - Platform::HighShortFromLong(wParam), SCI_NULL); + kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)), + Platform::HighShortFromLong(static_cast<long>(wParam)), SCI_NULL); break; case SCI_CLEARALLCMDKEYS: @@ -8896,7 +8904,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICSETSTYLE: if (wParam <= INDIC_MAX) { - vs.indicators[wParam].style = lParam; + vs.indicators[wParam].style = static_cast<int>(lParam); InvalidateStyleRedraw(); } break; @@ -8906,7 +8914,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICSETFORE: if (wParam <= INDIC_MAX) { - vs.indicators[wParam].fore = ColourDesired(lParam); + vs.indicators[wParam].fore = ColourDesired(static_cast<long>(lParam)); InvalidateStyleRedraw(); } break; @@ -8926,7 +8934,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICSETALPHA: if (wParam <= INDIC_MAX && lParam >=0 && lParam <= 255) { - vs.indicators[wParam].fillAlpha = lParam; + vs.indicators[wParam].fillAlpha = static_cast<int>(lParam); InvalidateStyleRedraw(); } break; @@ -8936,7 +8944,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICSETOUTLINEALPHA: if (wParam <= INDIC_MAX && lParam >=0 && lParam <= 255) { - vs.indicators[wParam].outlineAlpha = lParam; + vs.indicators[wParam].outlineAlpha = static_cast<int>(lParam); InvalidateStyleRedraw(); } break; @@ -8945,35 +8953,35 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return (wParam <= INDIC_MAX) ? vs.indicators[wParam].outlineAlpha : 0; case SCI_SETINDICATORCURRENT: - pdoc->decorations.SetCurrentIndicator(wParam); + pdoc->decorations.SetCurrentIndicator(static_cast<int>(wParam)); break; case SCI_GETINDICATORCURRENT: return pdoc->decorations.GetCurrentIndicator(); case SCI_SETINDICATORVALUE: - pdoc->decorations.SetCurrentValue(wParam); + pdoc->decorations.SetCurrentValue(static_cast<int>(wParam)); break; case SCI_GETINDICATORVALUE: return pdoc->decorations.GetCurrentValue(); case SCI_INDICATORFILLRANGE: - pdoc->DecorationFillRange(wParam, pdoc->decorations.GetCurrentValue(), lParam); + pdoc->DecorationFillRange(static_cast<int>(wParam), pdoc->decorations.GetCurrentValue(), static_cast<int>(lParam)); break; case SCI_INDICATORCLEARRANGE: - pdoc->DecorationFillRange(wParam, 0, lParam); + pdoc->DecorationFillRange(static_cast<int>(wParam), 0, static_cast<int>(lParam)); break; case SCI_INDICATORALLONFOR: - return pdoc->decorations.AllOnFor(wParam); + return pdoc->decorations.AllOnFor(static_cast<int>(wParam)); case SCI_INDICATORVALUEAT: - return pdoc->decorations.ValueAt(wParam, lParam); + return pdoc->decorations.ValueAt(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_INDICATORSTART: - return pdoc->decorations.Start(wParam, lParam); + return pdoc->decorations.Start(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_INDICATOREND: - return pdoc->decorations.End(wParam, lParam); + return pdoc->decorations.End(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_LINEDOWN: case SCI_LINEDOWNEXTEND: @@ -9070,13 +9078,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return KeyCommand(iMessage); case SCI_BRACEHIGHLIGHT: - SetBraceHighlight(static_cast<int>(wParam), lParam, STYLE_BRACELIGHT); + SetBraceHighlight(static_cast<int>(wParam), static_cast<int>(lParam), STYLE_BRACELIGHT); break; case SCI_BRACEHIGHLIGHTINDICATOR: if (lParam >= 0 && lParam <= INDIC_MAX) { vs.braceHighlightIndicatorSet = wParam != 0; - vs.braceHighlightIndicator = lParam; + vs.braceHighlightIndicator = static_cast<int>(lParam); } break; @@ -9087,14 +9095,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_BRACEBADLIGHTINDICATOR: if (lParam >= 0 && lParam <= INDIC_MAX) { vs.braceBadLightIndicatorSet = wParam != 0; - vs.braceBadLightIndicator = lParam; + vs.braceBadLightIndicator = static_cast<int>(lParam); } break; case SCI_BRACEMATCH: // wParam is position of char to find brace for, // lParam is maximum amount of text to restyle to find it - return pdoc->BraceMatch(wParam, lParam); + return pdoc->BraceMatch(static_cast<int>(wParam), static_cast<int>(lParam)); case SCI_GETVIEWEOL: return vs.viewEOL; @@ -9105,7 +9113,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETZOOM: - vs.zoomLevel = wParam; + vs.zoomLevel = static_cast<int>(wParam); InvalidateStyleRedraw(); NotifyZoom(); break; @@ -9117,7 +9125,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.theEdge; case SCI_SETEDGECOLUMN: - vs.theEdge = wParam; + vs.theEdge = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9125,7 +9133,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.edgeState; case SCI_SETEDGEMODE: - vs.edgeState = wParam; + vs.edgeState = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9133,7 +9141,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.edgecolour.AsLong(); case SCI_SETEDGECOLOUR: - vs.edgecolour = ColourDesired(wParam); + vs.edgecolour = ColourDesired(static_cast<long>(wParam)); InvalidateStyleRedraw(); break; @@ -9162,25 +9170,25 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_CREATELOADER: { Document *doc = new Document(); doc->AddRef(); - doc->Allocate(wParam); + doc->Allocate(static_cast<int>(wParam)); doc->SetUndoCollection(false); return reinterpret_cast<sptr_t>(static_cast<ILoader *>(doc)); } case SCI_SETMODEVENTMASK: - modEventMask = wParam; + modEventMask = static_cast<int>(wParam); return 0; case SCI_GETMODEVENTMASK: return modEventMask; case SCI_CONVERTEOLS: - pdoc->ConvertLineEnds(wParam); + pdoc->ConvertLineEnds(static_cast<int>(wParam)); SetSelection(sel.MainCaret(), sel.MainAnchor()); // Ensure selection inside document return 0; case SCI_SETLENGTHFORENCODE: - lengthForEncode = wParam; + lengthForEncode = static_cast<int>(wParam); return 0; case SCI_SELECTIONISRECTANGLE: @@ -9226,8 +9234,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { } case SCI_GETLINESELSTARTPOSITION: case SCI_GETLINESELENDPOSITION: { - SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(wParam)), - SelectionPosition(pdoc->LineEnd(wParam))); + SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(static_cast<int>(wParam))), + SelectionPosition(pdoc->LineEnd(static_cast<int>(wParam)))); for (size_t r=0; r<sel.Count(); r++) { SelectionSegment portion = sel.Range(r).Intersect(segmentLine); if (portion.start.IsValid()) { @@ -9252,7 +9260,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return hasFocus; case SCI_SETSTATUS: - errorStatus = wParam; + errorStatus = static_cast<int>(wParam); break; case SCI_GETSTATUS: @@ -9266,7 +9274,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return mouseDownCaptures; case SCI_SETCURSOR: - cursorMode = wParam; + cursorMode = static_cast<int>(wParam); DisplayCursor(Window::cursorText); break; @@ -9274,7 +9282,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return cursorMode; case SCI_SETCONTROLCHARSYMBOL: - vs.controlCharSymbol = wParam; + vs.controlCharSymbol = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9363,13 +9371,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return reinterpret_cast<sptr_t>(pdoc->BufferPointer()); case SCI_GETRANGEPOINTER: - return reinterpret_cast<sptr_t>(pdoc->RangePointer(wParam, lParam)); + return reinterpret_cast<sptr_t>(pdoc->RangePointer(static_cast<int>(wParam), static_cast<int>(lParam))); case SCI_GETGAPPOSITION: return pdoc->GapPosition(); case SCI_SETEXTRAASCENT: - vs.extraAscent = wParam; + vs.extraAscent = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9377,7 +9385,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.extraAscent; case SCI_SETEXTRADESCENT: - vs.extraDescent = wParam; + vs.extraDescent = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9385,7 +9393,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.extraDescent; case SCI_MARGINSETSTYLEOFFSET: - vs.marginStyleOffset = wParam; + vs.marginStyleOffset = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9393,36 +9401,36 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.marginStyleOffset; case SCI_SETMARGINOPTIONS: - marginOptions = wParam; + marginOptions = static_cast<int>(wParam); break; case SCI_GETMARGINOPTIONS: return marginOptions; case SCI_MARGINSETTEXT: - pdoc->MarginSetText(wParam, CharPtrFromSPtr(lParam)); + pdoc->MarginSetText(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); break; case SCI_MARGINGETTEXT: { - const StyledText st = pdoc->MarginStyledText(wParam); + const StyledText st = pdoc->MarginStyledText(static_cast<int>(wParam)); return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length); } case SCI_MARGINSETSTYLE: - pdoc->MarginSetStyle(wParam, lParam); + pdoc->MarginSetStyle(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_MARGINGETSTYLE: { - const StyledText st = pdoc->MarginStyledText(wParam); + const StyledText st = pdoc->MarginStyledText(static_cast<int>(wParam)); return st.style; } case SCI_MARGINSETSTYLES: - pdoc->MarginSetStyles(wParam, reinterpret_cast<const unsigned char *>(lParam)); + pdoc->MarginSetStyles(static_cast<int>(wParam), reinterpret_cast<const unsigned char *>(lParam)); break; case SCI_MARGINGETSTYLES: { - const StyledText st = pdoc->MarginStyledText(wParam); + const StyledText st = pdoc->MarginStyledText(static_cast<int>(wParam)); return BytesResult(lParam, st.styles, st.length); } @@ -9431,48 +9439,48 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_ANNOTATIONSETTEXT: - pdoc->AnnotationSetText(wParam, CharPtrFromSPtr(lParam)); + pdoc->AnnotationSetText(static_cast<int>(wParam), CharPtrFromSPtr(lParam)); break; case SCI_ANNOTATIONGETTEXT: { - const StyledText st = pdoc->AnnotationStyledText(wParam); + const StyledText st = pdoc->AnnotationStyledText(static_cast<int>(wParam)); return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length); } case SCI_ANNOTATIONGETSTYLE: { - const StyledText st = pdoc->AnnotationStyledText(wParam); + const StyledText st = pdoc->AnnotationStyledText(static_cast<int>(wParam)); return st.style; } case SCI_ANNOTATIONSETSTYLE: - pdoc->AnnotationSetStyle(wParam, lParam); + pdoc->AnnotationSetStyle(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_ANNOTATIONSETSTYLES: - pdoc->AnnotationSetStyles(wParam, reinterpret_cast<const unsigned char *>(lParam)); + pdoc->AnnotationSetStyles(static_cast<int>(wParam), reinterpret_cast<const unsigned char *>(lParam)); break; case SCI_ANNOTATIONGETSTYLES: { - const StyledText st = pdoc->AnnotationStyledText(wParam); + const StyledText st = pdoc->AnnotationStyledText(static_cast<int>(wParam)); return BytesResult(lParam, st.styles, st.length); } case SCI_ANNOTATIONGETLINES: - return pdoc->AnnotationLines(wParam); + return pdoc->AnnotationLines(static_cast<int>(wParam)); case SCI_ANNOTATIONCLEARALL: pdoc->AnnotationClearAll(); break; case SCI_ANNOTATIONSETVISIBLE: - SetAnnotationVisible(wParam); + SetAnnotationVisible(static_cast<int>(wParam)); break; case SCI_ANNOTATIONGETVISIBLE: return vs.annotationVisible; case SCI_ANNOTATIONSETSTYLEOFFSET: - vs.annotationStyleOffset = wParam; + vs.annotationStyleOffset = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9484,10 +9492,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_ALLOCATEEXTENDEDSTYLES: - return vs.AllocateExtendedStyles(wParam); + return vs.AllocateExtendedStyles(static_cast<int>(wParam)); case SCI_ADDUNDOACTION: - pdoc->AddUndoAction(wParam, lParam & UNDO_MAY_COALESCE); + pdoc->AddUndoAction(static_cast<int>(wParam), lParam & UNDO_MAY_COALESCE); break; case SCI_SETMOUSESELECTIONRECTANGULARSWITCH: @@ -9514,7 +9522,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return additionalSelectionTyping; case SCI_SETMULTIPASTE: - multiPasteMode = wParam; + multiPasteMode = static_cast<int>(wParam); break; case SCI_GETMULTIPASTE: @@ -9548,22 +9556,22 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_SETSELECTION: - sel.SetSelection(SelectionRange(wParam, lParam)); + sel.SetSelection(SelectionRange(static_cast<int>(wParam), static_cast<int>(lParam))); Redraw(); break; case SCI_ADDSELECTION: - sel.AddSelection(SelectionRange(wParam, lParam)); + sel.AddSelection(SelectionRange(static_cast<int>(wParam), static_cast<int>(lParam))); Redraw(); break; case SCI_DROPSELECTIONN: - sel.DropSelection(wParam); + sel.DropSelection(static_cast<int>(wParam)); Redraw(); break; case SCI_SETMAINSELECTION: - sel.SetMain(wParam); + sel.SetMain(static_cast<int>(wParam)); Redraw(); break; @@ -9571,7 +9579,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Main(); case SCI_SETSELECTIONNCARET: - sel.Range(wParam).caret.SetPosition(lParam); + sel.Range(wParam).caret.SetPosition(static_cast<int>(lParam)); Redraw(); break; @@ -9579,14 +9587,14 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Range(wParam).caret.Position(); case SCI_SETSELECTIONNANCHOR: - sel.Range(wParam).anchor.SetPosition(lParam); + sel.Range(wParam).anchor.SetPosition(static_cast<int>(lParam)); Redraw(); break; case SCI_GETSELECTIONNANCHOR: return sel.Range(wParam).anchor.Position(); case SCI_SETSELECTIONNCARETVIRTUALSPACE: - sel.Range(wParam).caret.SetVirtualSpace(lParam); + sel.Range(wParam).caret.SetVirtualSpace(static_cast<int>(lParam)); Redraw(); break; @@ -9594,7 +9602,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Range(wParam).caret.VirtualSpace(); case SCI_SETSELECTIONNANCHORVIRTUALSPACE: - sel.Range(wParam).anchor.SetVirtualSpace(lParam); + sel.Range(wParam).anchor.SetVirtualSpace(static_cast<int>(lParam)); Redraw(); break; @@ -9602,7 +9610,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Range(wParam).anchor.VirtualSpace(); case SCI_SETSELECTIONNSTART: - sel.Range(wParam).anchor.SetPosition(lParam); + sel.Range(wParam).anchor.SetPosition(static_cast<int>(lParam)); Redraw(); break; @@ -9610,7 +9618,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Range(wParam).Start().Position(); case SCI_SETSELECTIONNEND: - sel.Range(wParam).caret.SetPosition(lParam); + sel.Range(wParam).caret.SetPosition(static_cast<int>(lParam)); Redraw(); break; @@ -9621,7 +9629,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; - sel.Rectangular().caret.SetPosition(wParam); + sel.Rectangular().caret.SetPosition(static_cast<int>(wParam)); SetRectangularRange(); Redraw(); break; @@ -9633,7 +9641,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; - sel.Rectangular().anchor.SetPosition(wParam); + sel.Rectangular().anchor.SetPosition(static_cast<int>(wParam)); SetRectangularRange(); Redraw(); break; @@ -9645,7 +9653,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; - sel.Rectangular().caret.SetVirtualSpace(wParam); + sel.Rectangular().caret.SetVirtualSpace(static_cast<int>(wParam)); SetRectangularRange(); Redraw(); break; @@ -9657,7 +9665,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (!sel.IsRectangular()) sel.Clear(); sel.selType = Selection::selRectangle; - sel.Rectangular().anchor.SetVirtualSpace(wParam); + sel.Rectangular().anchor.SetVirtualSpace(static_cast<int>(wParam)); SetRectangularRange(); Redraw(); break; @@ -9666,24 +9674,24 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return sel.Rectangular().anchor.VirtualSpace(); case SCI_SETVIRTUALSPACEOPTIONS: - virtualSpaceOptions = wParam; + virtualSpaceOptions = static_cast<int>(wParam); break; case SCI_GETVIRTUALSPACEOPTIONS: return virtualSpaceOptions; case SCI_SETADDITIONALSELFORE: - vs.selAdditionalForeground = ColourDesired(wParam); + vs.selAdditionalForeground = ColourDesired(static_cast<long>(wParam)); InvalidateStyleRedraw(); break; case SCI_SETADDITIONALSELBACK: - vs.selAdditionalBackground = ColourDesired(wParam); + vs.selAdditionalBackground = ColourDesired(static_cast<long>(wParam)); InvalidateStyleRedraw(); break; case SCI_SETADDITIONALSELALPHA: - vs.selAdditionalAlpha = wParam; + vs.selAdditionalAlpha = static_cast<int>(wParam); InvalidateStyleRedraw(); break; @@ -9691,7 +9699,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return vs.selAdditionalAlpha; case SCI_SETADDITIONALCARETFORE: - vs.additionalCaretColour = ColourDesired(wParam); + vs.additionalCaretColour = ColourDesired(static_cast<long>(wParam)); InvalidateStyleRedraw(); break; @@ -9709,11 +9717,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_CHANGELEXERSTATE: - pdoc->ChangeLexerState(wParam, lParam); + pdoc->ChangeLexerState(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_SETIDENTIFIER: - SetCtrlID(wParam); + SetCtrlID(static_cast<int>(wParam)); break; case SCI_GETIDENTIFIER: @@ -9727,7 +9735,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return technology; case SCI_COUNTCHARACTERS: - return pdoc->CountCharacters(wParam, lParam); + return pdoc->CountCharacters(static_cast<int>(wParam), static_cast<int>(lParam)); default: return DefWndProc(iMessage, wParam, lParam); diff --git a/src/Indicator.cxx b/src/Indicator.cxx index 45dccc8e2..ba20dd941 100644 --- a/src/Indicator.cxx +++ b/src/Indicator.cxx @@ -25,12 +25,12 @@ static PRectangle PixelGridAlign(const PRectangle &rc) { void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) { surface->PenColour(fore); - int ymid = (rc.bottom + rc.top) / 2; + int ymid = static_cast<int>(rc.bottom + rc.top) / 2; if (style == INDIC_SQUIGGLE) { int x = int(rc.left+0.5); int xLast = int(rc.right+0.5); int y = 0; - surface->MoveTo(x, rc.top + y); + surface->MoveTo(x, static_cast<int>(rc.top) + y); while (x < xLast) { if ((x + 2) > xLast) { if (xLast > x) @@ -40,12 +40,12 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r x += 2; y = 2 - y; } - surface->LineTo(x, rc.top + y); + surface->LineTo(x, static_cast<int>(rc.top) + y); } } else if (style == INDIC_SQUIGGLEPIXMAP) { PRectangle rcSquiggle = PixelGridAlign(rc); - int width = Platform::Minimum(4000, rcSquiggle.Width()); + int width = Platform::Minimum(4000, static_cast<int>(rcSquiggle.Width())); RGBAImage image(width, 3, 1.0, 0); enum { alphaFull = 0xff, alphaSide = 0x2f, alphaSide2=0x5f }; for (int x = 0; x < width; x++) { @@ -62,19 +62,19 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r } surface->DrawRGBAImage(rcSquiggle, image.GetWidth(), image.GetHeight(), image.Pixels()); } else if (style == INDIC_SQUIGGLELOW) { - surface->MoveTo(rc.left, rc.top); - int x = rc.left + 3; + surface->MoveTo(static_cast<int>(rc.left), static_cast<int>(rc.top)); + int x = static_cast<int>(rc.left) + 3; int y = 0; while (x < rc.right) { - surface->LineTo(x-1, rc.top + y); + surface->LineTo(x - 1, static_cast<int>(rc.top) + y); y = 1 - y; - surface->LineTo(x, rc.top + y); + surface->LineTo(x, static_cast<int>(rc.top) + y); x += 3; } - surface->LineTo(rc.right, rc.top + y); // Finish the line + surface->LineTo(static_cast<int>(rc.right), static_cast<int>(rc.top) + y); // Finish the line } else if (style == INDIC_TT) { - surface->MoveTo(rc.left, ymid); - int x = rc.left + 5; + surface->MoveTo(static_cast<int>(rc.left), ymid); + int x = static_cast<int>(rc.left) + 5; while (x < rc.right) { surface->LineTo(x, ymid); surface->MoveTo(x-3, ymid); @@ -83,35 +83,35 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r surface->MoveTo(x, ymid); x += 5; } - surface->LineTo(rc.right, ymid); // Finish the line + surface->LineTo(static_cast<int>(rc.right), ymid); // Finish the line if (x - 3 <= rc.right) { surface->MoveTo(x-3, ymid); surface->LineTo(x-3, ymid+2); } } else if (style == INDIC_DIAGONAL) { - int x = rc.left; + int x = static_cast<int>(rc.left); while (x < rc.right) { - surface->MoveTo(x, rc.top+2); + surface->MoveTo(x, static_cast<int>(rc.top) + 2); int endX = x+3; - int endY = rc.top - 1; + int endY = static_cast<int>(rc.top) - 1; if (endX > rc.right) { - endY += endX - rc.right; - endX = rc.right; + endY += endX - static_cast<int>(rc.right); + endX = static_cast<int>(rc.right); } surface->LineTo(endX, endY); x += 4; } } else if (style == INDIC_STRIKE) { - surface->MoveTo(rc.left, rc.top - 4); - surface->LineTo(rc.right, rc.top - 4); + 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); } else if (style == INDIC_HIDDEN) { // Draw nothing } else if (style == INDIC_BOX) { - surface->MoveTo(rc.left, ymid+1); - surface->LineTo(rc.right, ymid+1); - surface->LineTo(rc.right, rcLine.top+1); - surface->LineTo(rc.left, rcLine.top+1); - surface->LineTo(rc.left, ymid+1); + 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); } else if (style == INDIC_ROUNDBOX || style == INDIC_STRAIGHTBOX) { PRectangle rcBox = rcLine; rcBox.top = rcLine.top + 1; @@ -123,31 +123,31 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r rcBox.top = rcLine.top + 1; rcBox.bottom = rcLine.bottom; // Cap width at 4000 to avoid large allocations when mistakes made - int width = Platform::Minimum(rcBox.Width(), 4000); - RGBAImage image(width, rcBox.Height(), 1.0, 0); + int width = Platform::Minimum(static_cast<int>(rcBox.Width()), 4000); + RGBAImage image(width, static_cast<int>(rcBox.Height()), 1.0, 0); // Draw horizontal lines top and bottom for (int x=0; x<width; x++) { - for (int y=0; y<rcBox.Height(); y += rcBox.Height()-1) { + for (int y = 0; y<static_cast<int>(rcBox.Height()); y += static_cast<int>(rcBox.Height()) - 1) { image.SetPixel(x, y, fore, ((x + y) % 2) ? outlineAlpha : fillAlpha); } } // Draw vertical lines left and right - for (int y=1; y<rcBox.Height(); y++) { + for (int y = 1; y<static_cast<int>(rcBox.Height()); y++) { for (int x=0; x<width; x += width-1) { image.SetPixel(x, y, fore, ((x + y) % 2) ? outlineAlpha : fillAlpha); } } surface->DrawRGBAImage(rcBox, image.GetWidth(), image.GetHeight(), image.Pixels()); } else if (style == INDIC_DASH) { - int x = rc.left; + int x = static_cast<int>(rc.left); while (x < rc.right) { surface->MoveTo(x, ymid); - surface->LineTo(Platform::Minimum(x + 4, rc.right), ymid); + surface->LineTo(Platform::Minimum(x + 4, static_cast<int>(rc.right)), ymid); x += 7; } } else if (style == INDIC_DOTS) { - int x = rc.left; - while (x < rc.right) { + int x = static_cast<int>(rc.left); + while (x < static_cast<int>(rc.right)) { PRectangle rcDot(x, ymid, x+1, ymid+1); surface->FillRectangle(rcDot, fore); x += 2; @@ -156,8 +156,8 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r PRectangle rcComposition(rc.left+1, rcLine.bottom-2, rc.right-1, rcLine.bottom); surface->FillRectangle(rcComposition, fore); } else { // Either INDIC_PLAIN or unknown - surface->MoveTo(rc.left, ymid); - surface->LineTo(rc.right, ymid); + surface->MoveTo(static_cast<int>(rc.left), ymid); + surface->LineTo(static_cast<int>(rc.right), ymid); } } diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx index 3bf671b6e..ced622b75 100644 --- a/src/LineMarker.cxx +++ b/src/LineMarker.cxx @@ -37,25 +37,25 @@ void LineMarker::SetXPM(const char *const *linesForm) { void LineMarker::SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage) { delete image; - image = new RGBAImage(sizeRGBAImage.x, sizeRGBAImage.y, scale, pixelsRGBAImage); + image = new RGBAImage(static_cast<int>(sizeRGBAImage.x), static_cast<int>(sizeRGBAImage.y), scale, pixelsRGBAImage); markType = SC_MARK_RGBAIMAGE; } static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) { - PRectangle rc; - rc.left = centreX - armSize; - rc.top = centreY - armSize; - rc.right = centreX + armSize + 1; - rc.bottom = centreY + armSize + 1; + PRectangle rc( + centreX - armSize, + centreY - armSize, + centreX + armSize + 1, + centreY + armSize + 1); surface->RectangleDraw(rc, back, fore); } static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) { - PRectangle rcCircle; - rcCircle.left = centreX - armSize; - rcCircle.top = centreY - armSize; - rcCircle.right = centreX + armSize + 1; - rcCircle.bottom = centreY + armSize + 1; + PRectangle rcCircle( + centreX - armSize, + centreY - armSize, + centreX + armSize + 1, + centreY + armSize + 1); surface->Ellipse(rcCircle, back, fore); } @@ -102,9 +102,9 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac if ((markType == SC_MARK_RGBAIMAGE) && (image)) { // Make rectangle just large enough to fit image centred on centre of rcWhole PRectangle rcImage; - rcImage.top = static_cast<int>(((rcWhole.top + rcWhole.bottom) - image->GetScaledHeight()) / 2); + rcImage.top = ((rcWhole.top + rcWhole.bottom) - image->GetScaledHeight()) / 2; rcImage.bottom = rcImage.top + image->GetScaledHeight(); - rcImage.left = static_cast<int>(((rcWhole.left + rcWhole.right) - image->GetScaledWidth()) / 2); + rcImage.left = ((rcWhole.left + rcWhole.right) - image->GetScaledWidth()) / 2; rcImage.right = rcImage.left + image->GetScaledWidth(); surface->DrawRGBAImage(rcImage, image->GetWidth(), image->GetHeight(), image->Pixels()); return; @@ -113,17 +113,17 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac PRectangle rc = rcWhole; rc.top++; rc.bottom--; - int minDim = Platform::Minimum(rc.Width(), rc.Height()); + int minDim = Platform::Minimum(static_cast<int>(rc.Width()), static_cast<int>(rc.Height())); minDim--; // Ensure does not go beyond edge - int centreX = floor((rc.right + rc.left) / 2.0); - int centreY = floor((rc.bottom + rc.top) / 2.0); + int centreX = static_cast<int>(floor((rc.right + rc.left) / 2.0)); + int centreY = static_cast<int>(floor((rc.bottom + rc.top) / 2.0)); int dimOn2 = minDim / 2; int dimOn4 = minDim / 4; int blobSize = dimOn2-1; 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 = rc.left + dimOn2 + 1; + centreX = static_cast<int>(rc.left) + dimOn2 + 1; } if (markType == SC_MARK_ROUNDRECT) { PRectangle rcRounded = rc; @@ -131,11 +131,11 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac rcRounded.right = rc.right - 1; surface->RoundedRectangle(rcRounded, fore, back); } else if (markType == SC_MARK_CIRCLE) { - PRectangle rcCircle; - rcCircle.left = centreX - dimOn2; - rcCircle.top = centreY - dimOn2; - rcCircle.right = centreX + dimOn2; - rcCircle.bottom = centreY + dimOn2; + PRectangle rcCircle( + centreX - dimOn2, + centreY - dimOn2, + centreX + dimOn2, + centreY + dimOn2); surface->Ellipse(rcCircle, fore, back); } else if (markType == SC_MARK_ARROW) { Point pts[] = { @@ -193,46 +193,46 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac } else if (markType == SC_MARK_VLINE) { surface->PenColour(body); - surface->MoveTo(centreX, rcWhole.top); - surface->LineTo(centreX, rcWhole.bottom); + surface->MoveTo(centreX, static_cast<int>(rcWhole.top)); + surface->LineTo(centreX, static_cast<int>(rcWhole.bottom)); } else if (markType == SC_MARK_LCORNER) { surface->PenColour(tail); - surface->MoveTo(centreX, rcWhole.top); + surface->MoveTo(centreX, static_cast<int>(rcWhole.top)); surface->LineTo(centreX, centreY); - surface->LineTo(rc.right - 1, centreY); + surface->LineTo(static_cast<int>(rc.right) - 1, centreY); } else if (markType == SC_MARK_TCORNER) { surface->PenColour(tail); surface->MoveTo(centreX, centreY); - surface->LineTo(rc.right - 1, centreY); + surface->LineTo(static_cast<int>(rc.right) - 1, centreY); surface->PenColour(body); - surface->MoveTo(centreX, rcWhole.top); + surface->MoveTo(centreX, static_cast<int>(rcWhole.top)); surface->LineTo(centreX, centreY + 1); surface->PenColour(head); - surface->LineTo(centreX, rcWhole.bottom); + surface->LineTo(centreX, static_cast<int>(rcWhole.bottom)); } else if (markType == SC_MARK_LCORNERCURVE) { surface->PenColour(tail); - surface->MoveTo(centreX, rcWhole.top); + surface->MoveTo(centreX, static_cast<int>(rcWhole.top)); surface->LineTo(centreX, centreY-3); surface->LineTo(centreX+3, centreY); - surface->LineTo(rc.right - 1, centreY); + surface->LineTo(static_cast<int>(rc.right) - 1, centreY); } else if (markType == SC_MARK_TCORNERCURVE) { surface->PenColour(tail); surface->MoveTo(centreX, centreY-3); surface->LineTo(centreX+3, centreY); - surface->LineTo(rc.right - 1, centreY); + surface->LineTo(static_cast<int>(rc.right) - 1, centreY); surface->PenColour(body); - surface->MoveTo(centreX, rcWhole.top); + surface->MoveTo(centreX, static_cast<int>(rcWhole.top)); surface->LineTo(centreX, centreY-2); surface->PenColour(head); - surface->LineTo(centreX, rcWhole.bottom); + surface->LineTo(centreX, static_cast<int>(rcWhole.bottom)); } else if (markType == SC_MARK_BOXPLUS) { DrawBox(surface, centreX, centreY, blobSize, fore, head); @@ -244,10 +244,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac else surface->PenColour(body); surface->MoveTo(centreX, centreY + blobSize); - surface->LineTo(centreX, rcWhole.bottom); + surface->LineTo(centreX, static_cast<int>(rcWhole.bottom)); surface->PenColour(body); - surface->MoveTo(centreX, rcWhole.top); + surface->MoveTo(centreX, static_cast<int>(rcWhole.top)); surface->LineTo(centreX, centreY - blobSize); DrawBox(surface, centreX, centreY, blobSize, fore, head); @@ -270,7 +270,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac surface->PenColour(head); surface->MoveTo(centreX, centreY + blobSize); - surface->LineTo(centreX, rcWhole.bottom); + surface->LineTo(centreX, static_cast<int>(rcWhole.bottom)); } else if (markType == SC_MARK_BOXMINUSCONNECTED) { DrawBox(surface, centreX, centreY, blobSize, fore, head); @@ -278,10 +278,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac surface->PenColour(head); surface->MoveTo(centreX, centreY + blobSize); - surface->LineTo(centreX, rcWhole.bottom); + surface->LineTo(centreX, static_cast<int>(rcWhole.bottom)); surface->PenColour(body); - surface->MoveTo(centreX, rcWhole.top); + surface->MoveTo(centreX, static_cast<int>(rcWhole.top)); surface->LineTo(centreX, centreY - blobSize); if (tFold == LineMarker::body) { @@ -305,10 +305,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac else surface->PenColour(body); surface->MoveTo(centreX, centreY + blobSize); - surface->LineTo(centreX, rcWhole.bottom); + surface->LineTo(centreX, static_cast<int>(rcWhole.bottom)); surface->PenColour(body); - surface->MoveTo(centreX, rcWhole.top); + surface->MoveTo(centreX, static_cast<int>(rcWhole.top)); surface->LineTo(centreX, centreY - blobSize); DrawCircle(surface, centreX, centreY, blobSize, fore, head); @@ -317,7 +317,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac } else if (markType == SC_MARK_CIRCLEMINUS) { surface->PenColour(head); surface->MoveTo(centreX, centreY + blobSize); - surface->LineTo(centreX, rcWhole.bottom); + surface->LineTo(centreX, static_cast<int>(rcWhole.bottom)); DrawCircle(surface, centreX, centreY, blobSize, fore, head); DrawMinus(surface, centreX, centreY, blobSize, tail); @@ -325,10 +325,10 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac } else if (markType == SC_MARK_CIRCLEMINUSCONNECTED) { surface->PenColour(head); surface->MoveTo(centreX, centreY + blobSize); - surface->LineTo(centreX, rcWhole.bottom); + surface->LineTo(centreX, static_cast<int>(rcWhole.bottom)); surface->PenColour(body); - surface->MoveTo(centreX, rcWhole.top); + surface->MoveTo(centreX, static_cast<int>(rcWhole.top)); surface->LineTo(centreX, centreY - blobSize); DrawCircle(surface, centreX, centreY, blobSize, fore, head); diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index e782c77c7..2a120c1cf 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -646,7 +646,7 @@ void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc) { allClear = false; - unsigned int probe = pces.size(); // Out of bounds + size_t probe = pces.size(); // Out of bounds if ((!pces.empty()) && (len < 30)) { // Only store short strings in the cache so it doesn't churn with // long comments with only a single comment. diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index e36d31389..9736c52f0 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -233,7 +233,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { int heightLB = ac.heightLBDefault; int widthLB = ac.widthLBDefault; if (pt.x >= rcClient.right - widthLB) { - HorizontalScrollTo(xOffset + pt.x - rcClient.right + widthLB); + HorizontalScrollTo(static_cast<int>(xOffset + pt.x - rcClient.right + widthLB)); Redraw(); pt = PointMainCaret(); } @@ -248,17 +248,17 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { pt.y >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2) { // and there is more room above. rcac.top = pt.y - heightLB; if (rcac.top < rcPopupBounds.top) { - heightLB -= (rcPopupBounds.top - rcac.top); + heightLB -= static_cast<int>(rcPopupBounds.top - rcac.top); rcac.top = rcPopupBounds.top; } } else { rcac.top = pt.y + vs.lineHeight; } rcac.right = rcac.left + widthLB; - rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcPopupBounds.bottom); + rcac.bottom = static_cast<XYPOSITION>(Platform::Minimum(static_cast<int>(rcac.top) + heightLB, static_cast<int>(rcPopupBounds.bottom))); ac.lb->SetPositionRelative(rcac, wMain); ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font); - unsigned int aveCharWidth = vs.styles[STYLE_DEFAULT].aveCharWidth; + unsigned int aveCharWidth = static_cast<unsigned int>(vs.styles[STYLE_DEFAULT].aveCharWidth); ac.lb->SetAverageCharWidth(aveCharWidth); ac.lb->SetDoubleClickAction(AutoCompleteDoubleClick, this); @@ -266,8 +266,8 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { // Fiddle the position of the list so it is right next to the target and wide enough for all its strings PRectangle rcList = ac.lb->GetDesiredRect(); - int heightAlloced = rcList.bottom - rcList.top; - widthLB = Platform::Maximum(widthLB, rcList.right - rcList.left); + int heightAlloced = static_cast<int>(rcList.bottom - rcList.top); + widthLB = Platform::Maximum(widthLB, static_cast<int>(rcList.right - rcList.left)); if (maxListWidth != 0) widthLB = Platform::Minimum(widthLB, aveCharWidth*maxListWidth); // Make an allowance for large strings in list @@ -416,7 +416,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) { // If the call-tip window would be out of the client // space PRectangle rcClient = GetClientRectangle(); - int offset = vs.lineHeight + rc.Height(); + int offset = vs.lineHeight + static_cast<int>(rc.Height()); // adjust so it displays above the text. if (rc.bottom > rcClient.bottom) { rc.top -= offset; @@ -749,7 +749,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara switch (iMessage) { case SCI_AUTOCSHOW: listType = 0; - AutoCompleteStart(wParam, reinterpret_cast<const char *>(lParam)); + AutoCompleteStart(static_cast<int>(wParam), reinterpret_cast<const char *>(lParam)); break; case SCI_AUTOCCANCEL: @@ -813,21 +813,21 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ac.ignoreCase; case SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR: - ac.ignoreCaseBehaviour = wParam; + ac.ignoreCaseBehaviour = static_cast<unsigned int>(wParam); break; case SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR: return ac.ignoreCaseBehaviour; case SCI_AUTOCSETORDER: - ac.autoSort = wParam; + ac.autoSort = static_cast<int>(wParam); break; case SCI_AUTOCGETORDER: return ac.autoSort; case SCI_USERLISTSHOW: - listType = wParam; + listType = static_cast<int>(wParam); AutoCompleteStart(0, reinterpret_cast<const char *>(lParam)); break; @@ -846,25 +846,26 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ac.dropRestOfWord; case SCI_AUTOCSETMAXHEIGHT: - ac.lb->SetVisibleRows(wParam); + ac.lb->SetVisibleRows(static_cast<int>(wParam)); break; case SCI_AUTOCGETMAXHEIGHT: return ac.lb->GetVisibleRows(); case SCI_AUTOCSETMAXWIDTH: - maxListWidth = wParam; + maxListWidth = static_cast<int>(wParam); break; case SCI_AUTOCGETMAXWIDTH: return maxListWidth; case SCI_REGISTERIMAGE: - ac.lb->RegisterImage(wParam, reinterpret_cast<const char *>(lParam)); + ac.lb->RegisterImage(static_cast<int>(wParam), reinterpret_cast<const char *>(lParam)); break; case SCI_REGISTERRGBAIMAGE: - ac.lb->RegisterRGBAImage(wParam, sizeRGBAImage.x, sizeRGBAImage.y, reinterpret_cast<unsigned char *>(lParam)); + ac.lb->RegisterRGBAImage(static_cast<int>(wParam), static_cast<int>(sizeRGBAImage.x), static_cast<int>(sizeRGBAImage.y), + reinterpret_cast<unsigned char *>(lParam)); break; case SCI_CLEARREGISTEREDIMAGES: @@ -879,7 +880,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ac.GetTypesep(); case SCI_CALLTIPSHOW: - CallTipShow(LocationFromPosition(wParam), + CallTipShow(LocationFromPosition(static_cast<int>(wParam)), reinterpret_cast<const char *>(lParam)); break; @@ -894,32 +895,32 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ct.posStartCallTip; case SCI_CALLTIPSETPOSSTART: - ct.posStartCallTip = wParam; + ct.posStartCallTip = static_cast<int>(wParam); break; case SCI_CALLTIPSETHLT: - ct.SetHighlight(wParam, lParam); + ct.SetHighlight(static_cast<int>(wParam), static_cast<int>(lParam)); break; case SCI_CALLTIPSETBACK: - ct.colourBG = ColourDesired(wParam); + ct.colourBG = ColourDesired(static_cast<long>(wParam)); vs.styles[STYLE_CALLTIP].back = ct.colourBG; InvalidateStyleRedraw(); break; case SCI_CALLTIPSETFORE: - ct.colourUnSel = ColourDesired(wParam); + ct.colourUnSel = ColourDesired(static_cast<long>(wParam)); vs.styles[STYLE_CALLTIP].fore = ct.colourUnSel; InvalidateStyleRedraw(); break; case SCI_CALLTIPSETFOREHLT: - ct.colourSel = ColourDesired(wParam); + ct.colourSel = ColourDesired(static_cast<long>(wParam)); InvalidateStyleRedraw(); break; case SCI_CALLTIPUSESTYLE: - ct.SetTabSize((int)wParam); + ct.SetTabSize(static_cast<int>(wParam)); InvalidateStyleRedraw(); break; @@ -934,7 +935,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara #ifdef SCI_LEXER case SCI_SETLEXER: - DocumentLexState()->SetLexer(wParam); + DocumentLexState()->SetLexer(static_cast<int>(wParam)); break; case SCI_GETLEXER: @@ -942,10 +943,10 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara case SCI_COLOURISE: if (DocumentLexState()->lexLanguage == SCLEX_CONTAINER) { - pdoc->ModifiedAt(wParam); - NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : lParam); + pdoc->ModifiedAt(static_cast<int>(wParam)); + NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : static_cast<int>(lParam)); } else { - DocumentLexState()->Colourise(wParam, lParam); + DocumentLexState()->Colourise(static_cast<int>(wParam), static_cast<int>(lParam)); } Redraw(); break; @@ -963,7 +964,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara reinterpret_cast<char *>(lParam)); case SCI_GETPROPERTYINT: - return DocumentLexState()->PropGetInt(reinterpret_cast<const char *>(wParam), lParam); + return DocumentLexState()->PropGetInt(reinterpret_cast<const char *>(wParam), static_cast<int>(lParam)); case SCI_SETKEYWORDS: DocumentLexState()->SetWordList(wParam, reinterpret_cast<const char *>(lParam)); diff --git a/src/ViewStyle.h b/src/ViewStyle.h index 91b51b2ad..be9d8abfc 100644 --- a/src/ViewStyle.h +++ b/src/ViewStyle.h @@ -63,7 +63,7 @@ public: bool isSet; ColourOptional(ColourDesired colour_=ColourDesired(0,0,0), bool isSet_=false) : ColourDesired(colour_), isSet(isSet_) { } - ColourOptional(uptr_t wParam, sptr_t lParam) : ColourDesired(lParam), isSet(wParam != 0) { + ColourOptional(uptr_t wParam, sptr_t lParam) : ColourDesired(static_cast<long>(lParam)), isSet(wParam != 0) { } }; diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 5fb2b16d3..180d2d1a7 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -2158,7 +2158,7 @@ class ListBoxX : public ListBox { void OnDoubleClick(); void ResizeToCursor(); void StartResize(WPARAM); - int NcHitTest(WPARAM, LPARAM) const; + LRESULT NcHitTest(WPARAM, LPARAM) const; void CentreItem(int n); void Paint(HDC); static LRESULT PASCAL ControlWndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam); @@ -2344,7 +2344,7 @@ void ListBoxX::Select(int n) { } int ListBoxX::GetSelection() { - return ::SendMessage(lb, LB_GETCURSEL, 0, 0); + return static_cast<int>(::SendMessage(lb, LB_GETCURSEL, 0, 0)); } // This is not actually called at present @@ -2414,7 +2414,7 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { if (surfaceItem) { if (technology == SCWIN_TECH_GDI) { surfaceItem->Init(pDrawItem->hDC, pDrawItem->hwndItem); - int left = pDrawItem->rcItem.left + static_cast<int>(ItemInset.x + ImageInset.x); + long left = pDrawItem->rcItem.left + static_cast<int>(ItemInset.x + ImageInset.x); PRectangle rcImage(left, pDrawItem->rcItem.top, left + images.GetWidth(), pDrawItem->rcItem.bottom); surfaceItem->DrawRGBAImage(rcImage, @@ -2442,7 +2442,7 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { if (SUCCEEDED(hr)) { surfaceItem->Init(pDCRT, pDrawItem->hwndItem); pDCRT->BeginDraw(); - int left = pDrawItem->rcItem.left + static_cast<int>(ItemInset.x + ImageInset.x); + long left = pDrawItem->rcItem.left + static_cast<long>(ItemInset.x + ImageInset.x); PRectangle rcImage(left, pDrawItem->rcItem.top, left + images.GetWidth(), pDrawItem->rcItem.bottom); surfaceItem->DrawRGBAImage(rcImage, @@ -2660,11 +2660,11 @@ void ListBoxX::StartResize(WPARAM hitCode) { } ::SetCapture(GetHWND()); - resizeHit = hitCode; + resizeHit = static_cast<int>(hitCode); } -int ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const { - int hit = ::DefWindowProc(GetHWND(), WM_NCHITTEST, wParam, lParam); +LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const { + LRESULT hit = ::DefWindowProc(GetHWND(), WM_NCHITTEST, wParam, lParam); // There is an apparent bug in the DefWindowProc hit test code whereby it will // return HTTOPXXX if the window in question is shorter than the default // window caption height + frame, even if one is hovering over the bottom edge of @@ -2730,7 +2730,7 @@ void ListBoxX::CentreItem(int n) { POINT extent = GetClientExtent(); int visible = extent.y/ItemHeight(); if (visible < Length()) { - int top = ::SendMessage(lb, LB_GETTOPINDEX, 0, 0); + LRESULT top = ::SendMessage(lb, LB_GETTOPINDEX, 0, 0); int half = (visible - 1) / 2; if (n > (top + half)) ::SendMessage(lb, LB_SETTOPINDEX, n - half , 0); @@ -2927,7 +2927,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam linesToScroll = 3; } linesToScroll *= (wheelDelta / WHEEL_DELTA); - int top = ::SendMessage(lb, LB_GETTOPINDEX, 0, 0) + linesToScroll; + LRESULT top = ::SendMessage(lb, LB_GETTOPINDEX, 0, 0) + linesToScroll; if (top < 0) { top = 0; } @@ -3126,12 +3126,14 @@ bool Platform::IsKeyDown(int key) { } long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) { - return ::SendMessage(reinterpret_cast<HWND>(w), msg, wParam, lParam); + // This should never be called - its here to satisfy an old interface + return static_cast<long>(::SendMessage(reinterpret_cast<HWND>(w), msg, wParam, lParam)); } long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long wParam, void *lParam) { - return ::SendMessage(reinterpret_cast<HWND>(w), msg, wParam, - reinterpret_cast<LPARAM>(lParam)); + // This should never be called - its here to satisfy an old interface + return static_cast<long>(::SendMessage(reinterpret_cast<HWND>(w), msg, wParam, + reinterpret_cast<LPARAM>(lParam))); } bool Platform::IsDBCSLeadByte(int codePage, char ch) { diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index db79cf33c..9288eb21b 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -465,8 +465,8 @@ HWND ScintillaWin::MainHWND() { } bool ScintillaWin::DragThreshold(Point ptStart, Point ptNow) { - int xMove = abs(ptStart.x - ptNow.x); - int yMove = abs(ptStart.y - ptNow.y); + int xMove = static_cast<int>(abs(ptStart.x - ptNow.x)); + int yMove = static_cast<int>(abs(ptStart.y - ptNow.y)); return (xMove > ::GetSystemMetrics(SM_CXDRAG)) || (yMove > ::GetSystemMetrics(SM_CYDRAG)); } @@ -494,11 +494,11 @@ void ScintillaWin::StartDrag() { } // Avoid warnings everywhere for old style casts by concentrating them here -static WORD LoWord(DWORD l) { +static WORD LoWord(uptr_t l) { return LOWORD(l); } -static WORD HiWord(DWORD l) { +static WORD HiWord(uptr_t l) { return HIWORD(l); } @@ -643,8 +643,8 @@ sptr_t ScintillaWin::HandleComposition(uptr_t wParam, sptr_t lParam) { Point pos = PointMainCaret(); COMPOSITIONFORM CompForm; CompForm.dwStyle = CFS_POINT; - CompForm.ptCurrentPos.x = pos.x; - CompForm.ptCurrentPos.y = pos.y; + CompForm.ptCurrentPos.x = static_cast<int>(pos.x); + CompForm.ptCurrentPos.y = static_cast<int>(pos.y); ::ImmSetCompositionWindow(hIMC, &CompForm); ::ImmReleaseContext(MainHWND(), hIMC); } @@ -837,7 +837,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam // the low priority events have a turn (after which the timer will fire again). DWORD dwCurrent = GetTickCount(); - DWORD dwStart = wParam ? wParam : dwCurrent; + DWORD dwStart = wParam ? static_cast<DWORD>(wParam) : dwCurrent; const DWORD maxWorkTime = 50; if (dwCurrent >= dwStart && dwCurrent > maxWorkTime && dwCurrent - maxWorkTime < dwStart) @@ -863,7 +863,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam // Platform::IsKeyDown(VK_CONTROL), // Platform::IsKeyDown(VK_MENU)); ::SetFocus(MainHWND()); - ButtonDown(Point::FromLong(lParam), ::GetMessageTime(), + ButtonDown(Point::FromLong(static_cast<long>(lParam)), ::GetMessageTime(), (wParam & MK_SHIFT) != 0, (wParam & MK_CONTROL) != 0, Platform::IsKeyDown(VK_MENU)); @@ -872,7 +872,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam case WM_MOUSEMOVE: SetTrackMouseLeaveEvent(true); - ButtonMoveWithModifiers(Point::FromLong(lParam), + ButtonMoveWithModifiers(Point::FromLong(static_cast<long>(lParam)), ((wParam & MK_SHIFT) != 0 ? SCI_SHIFT : 0) | ((wParam & MK_CONTROL) != 0 ? SCI_CTRL : 0) | (Platform::IsKeyDown(VK_MENU) ? SCI_ALT : 0)); @@ -884,16 +884,16 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); case WM_LBUTTONUP: - ButtonUp(Point::FromLong(lParam), + ButtonUp(Point::FromLong(static_cast<long>(lParam)), ::GetMessageTime(), (wParam & MK_CONTROL) != 0); break; case WM_RBUTTONDOWN: ::SetFocus(MainHWND()); - if (!PointInSelection(Point::FromLong(lParam))) { + if (!PointInSelection(Point::FromLong(static_cast<long>(lParam)))) { CancelModes(); - SetEmptySelection(PositionFromLocation(Point::FromLong(lParam))); + SetEmptySelection(PositionFromLocation(Point::FromLong(static_cast<long>(lParam)))); } break; @@ -923,7 +923,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam } case WM_CHAR: - if (((wParam >= 128) || !iscntrl(wParam)) || !lastKeyDownConsumed) { + if (((wParam >= 128) || !iscntrl(static_cast<int>(wParam))) || !lastKeyDownConsumed) { if (::IsWindowUnicode(MainHWND()) || keysAlwaysUnicode) { wchar_t wcs[2] = {static_cast<wchar_t>(wParam), 0}; if (IsUnicodeMode()) { @@ -972,7 +972,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam case WM_KEYDOWN: { //Platform::DebugPrintf("S keydown %d %x %x %x %x\n",iMessage, wParam, lParam, ::IsKeyDown(VK_SHIFT), ::IsKeyDown(VK_CONTROL)); lastKeyDownConsumed = false; - int ret = KeyDown(KeyTranslate(wParam), + int ret = KeyDown(KeyTranslate(static_cast<int>(wParam)), Platform::IsKeyDown(VK_SHIFT), Platform::IsKeyDown(VK_CONTROL), Platform::IsKeyDown(VK_MENU), @@ -1041,7 +1041,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam case WM_CONTEXTMENU: if (displayPopupMenu) { - Point pt = Point::FromLong(lParam); + Point pt = Point::FromLong(static_cast<long>(lParam)); if ((pt.x == -1) && (pt.y == -1)) { // Caused by keyboard so display menu near caret pt = PointMainCaret(); @@ -1089,10 +1089,10 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam if (static_cast<int>(wParam) < 0) { wParam = SelectionStart().Position(); } - return pdoc->LineFromPosition(wParam); + return pdoc->LineFromPosition(static_cast<int>(wParam)); case EM_EXLINEFROMCHAR: - return pdoc->LineFromPosition(lParam); + return pdoc->LineFromPosition(static_cast<int>(lParam)); case EM_GETSEL: if (wParam) { @@ -1175,7 +1175,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam return 0; #endif } - technology = wParam; + technology = static_cast<int>(wParam); // Invalidate all cached information including layout. DropGraphics(true); InvalidateStyleRedraw(); @@ -1276,7 +1276,7 @@ bool ScintillaWin::PaintContains(PRectangle rc) { contains = false; } else { // In bounding rectangle so check more accurately using region - HRGN hRgnRange = ::CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom); + HRGN hRgnRange = ::CreateRectRgn(static_cast<int>(rc.left), static_cast<int>(rc.top), static_cast<int>(rc.right), static_cast<int>(rc.bottom)); if (hRgnRange) { HRGN hRgnDest = ::CreateRectRgn(0, 0, 0, 0); if (hRgnDest) { @@ -1309,7 +1309,7 @@ void ScintillaWin::UpdateSystemCaret() { CreateSystemCaret(); } Point pos = PointMainCaret(); - ::SetCaretPos(pos.x, pos.y); + ::SetCaretPos(static_cast<int>(pos.x), static_cast<int>(pos.y)); } } @@ -1371,7 +1371,7 @@ bool ScintillaWin::ModifyScrollBars(int nMax, int nPage) { int horizEndPreferred = scrollWidth; if (horizEndPreferred < 0) horizEndPreferred = 0; - unsigned int pageWidth = rcText.Width(); + unsigned int pageWidth = static_cast<unsigned int>(rcText.Width()); if (!horizontalScrollBarVisible || Wrapping()) pageWidth = horizEndPreferred + 1; sci.fMask = SIF_PAGE | SIF_RANGE; @@ -1673,7 +1673,7 @@ void ScintillaWin::Paste() { std::vector<char> putf; // Default Scintilla behaviour in Unicode mode if (IsUnicodeMode()) { - unsigned int bytes = memUSelection.Size(); + unsigned int bytes = static_cast<unsigned int>(memUSelection.Size()); len = UTF8Length(uptr, bytes / 2); putf.resize(len + 1); UTF8FromUTF16(uptr, bytes / 2, &putf[0], len); @@ -1697,7 +1697,7 @@ void ScintillaWin::Paste() { if (memSelection) { char *ptr = static_cast<char *>(memSelection.ptr); if (ptr) { - unsigned int bytes = memSelection.Size(); + unsigned int bytes = static_cast<unsigned int>(memSelection.Size()); unsigned int len = bytes; for (unsigned int i = 0; i < bytes; i++) { if ((len == bytes) && (0 == ptr[i])) @@ -2069,8 +2069,8 @@ void ScintillaWin::ImeStartComposition() { Point pos = PointMainCaret(); COMPOSITIONFORM CompForm; CompForm.dwStyle = CFS_POINT; - CompForm.ptCurrentPos.x = pos.x; - CompForm.ptCurrentPos.y = pos.y; + CompForm.ptCurrentPos.x = static_cast<int>(pos.x); + CompForm.ptCurrentPos.y = static_cast<int>(pos.y); ::ImmSetCompositionWindow(hIMC, &CompForm); @@ -2257,7 +2257,7 @@ void ScintillaWin::ScrollMessage(WPARAM wParam) { void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) { int xPos = xOffset; PRectangle rcText = GetTextRectangle(); - int pageWidth = rcText.Width() * 2 / 3; + int pageWidth = static_cast<int>(rcText.Width() * 2 / 3); switch (LoWord(wParam)) { case SB_LINEUP: xPos -= 20; @@ -2271,7 +2271,7 @@ void ScintillaWin::HorizontalScrollMessage(WPARAM wParam) { case SB_PAGEDOWN: xPos += pageWidth; if (xPos > scrollWidth - rcText.Width()) { // Hit the end exactly - xPos = scrollWidth - rcText.Width(); + xPos = scrollWidth - static_cast<int>(rcText.Width()); } break; case SB_TOP: @@ -2469,7 +2469,7 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState, wchar_t *udata = static_cast<wchar_t *>(memUDrop.ptr); if (udata) { if (IsUnicodeMode()) { - int tlen = memUDrop.Size(); + int tlen = static_cast<int>(memUDrop.Size()); // Convert UTF-16 to UTF-8 int dataLen = UTF8Length(udata, tlen/2); data.resize(dataLen+1); @@ -2756,7 +2756,7 @@ sptr_t PASCAL ScintillaWin::CTWndProc( return 0; } else if (iMessage == WM_LBUTTONDOWN) { // This does not fire due to the hit test code - sciThis->ct.MouseClick(Point::FromLong(lParam)); + sciThis->ct.MouseClick(Point::FromLong(static_cast<long>(lParam))); sciThis->CallTipClick(); return 0; } else if (iMessage == WM_SETCURSOR) { |