diff options
author | Neil <nyamatongwe@gmail.com> | 2014-05-03 20:21:13 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2014-05-03 20:21:13 +1000 |
commit | 97ae63fa3914ac9894a319c0c75eeeffe96b16e9 (patch) | |
tree | 7cc80911f2b6338a9ea84744577c535c16346c2d | |
parent | 850baf30484384711aa410d3596531f49c15e1ac (diff) | |
download | scintilla-mirror-97ae63fa3914ac9894a319c0c75eeeffe96b16e9.tar.gz |
Replacing the int-based constructors for Point and PRectangle with FromInts
static methods as there were too many failures with mixed types and not-quite
matching types.
-rw-r--r-- | include/Platform.h | 17 | ||||
-rw-r--r-- | src/CallTip.cxx | 12 | ||||
-rw-r--r-- | src/Editor.cxx | 40 | ||||
-rw-r--r-- | src/Indicator.cxx | 4 | ||||
-rw-r--r-- | src/LineMarker.cxx | 82 | ||||
-rw-r--r-- | src/XPM.cxx | 2 | ||||
-rw-r--r-- | win32/PlatWin.cxx | 18 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 22 |
8 files changed, 99 insertions, 98 deletions
diff --git a/include/Platform.h b/include/Platform.h index c9156fc0c..4bba252f2 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -103,9 +103,9 @@ public: explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) { } - 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_)) { + + static Point FromInts(int x_, int y_) { + return Point(static_cast<XYPOSITION>(x_), static_cast<XYPOSITION>(y_)); } // Other automatically defined methods (assignment, copy constructor, destructor) are fine @@ -128,13 +128,10 @@ public: explicit PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) : left(left_), top(top_), right(right_), bottom(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_)) { + + static PRectangle FromInts(int left_, int top_, int right_, int bottom_) { + return PRectangle(static_cast<XYPOSITION>(left_), static_cast<XYPOSITION>(top_), + static_cast<XYPOSITION>(right_), static_cast<XYPOSITION>(bottom_)); } // Other automatically defined methods (assignment, copy constructor, destructor) are fine diff --git a/src/CallTip.cxx b/src/CallTip.cxx index c1a3582f3..f6f3f10ea 100644 --- a/src/CallTip.cxx +++ b/src/CallTip.cxx @@ -125,16 +125,16 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s, if (upArrow) { // Up arrow Point pts[] = { - Point(centreX - halfWidth, centreY + quarterWidth), - Point(centreX + halfWidth, centreY + quarterWidth), - Point(centreX, centreY - halfWidth + quarterWidth), + Point::FromInts(centreX - halfWidth, centreY + quarterWidth), + Point::FromInts(centreX + halfWidth, centreY + quarterWidth), + Point::FromInts(centreX, centreY - halfWidth + quarterWidth), }; surface->Polygon(pts, ELEMENTS(pts), colourBG, colourBG); } else { // Down arrow Point pts[] = { - Point(centreX - halfWidth, centreY - quarterWidth), - Point(centreX + halfWidth, centreY - quarterWidth), - Point(centreX, centreY + halfWidth - quarterWidth), + Point::FromInts(centreX - halfWidth, centreY - quarterWidth), + Point::FromInts(centreX + halfWidth, centreY - quarterWidth), + Point::FromInts(centreX, centreY + halfWidth - quarterWidth), }; surface->Polygon(pts, ELEMENTS(pts), colourBG, colourBG); } diff --git a/src/Editor.cxx b/src/Editor.cxx index 1e1d7bf07..f1e019b07 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1164,13 +1164,13 @@ void Editor::MoveCaretInsideView(bool ensureVisible) { Point pt = PointMainCaret(); if (pt.y < rcClient.top) { MovePositionTo(SPositionFromLocation( - Point(lastXChosen - xOffset, static_cast<int>(rcClient.top)), + Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top)), false, false, UserVirtualSpace()), Selection::noSel, ensureVisible); } else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) { int yOfLastLineFullyDisplayed = static_cast<int>(rcClient.top) + (LinesOnScreen() - 1) * vs.lineHeight; MovePositionTo(SPositionFromLocation( - Point(lastXChosen - xOffset, static_cast<int>(rcClient.top) + yOfLastLineFullyDisplayed), + Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top) + yOfLastLineFullyDisplayed), false, false, UserVirtualSpace()), Selection::noSel, ensureVisible); } @@ -2423,8 +2423,8 @@ ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground, } void Editor::DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight) { - Point from(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0); - PRectangle rcCopyArea(start + 1, static_cast<int>(rcSegment.top), start + 2, static_cast<int>(rcSegment.bottom)); + Point from = Point::FromInts(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0); + PRectangle rcCopyArea = PRectangle::FromInts(start + 1, static_cast<int>(rcSegment.top), start + 2, static_cast<int>(rcSegment.bottom)); surface->Copy(rcCopyArea, from, highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide); } @@ -3364,7 +3364,7 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) { // for scroll bars and Visual Studio for its selection margin. The colour of this pattern is half // way between the chrome colour and the chrome highlight colour making a nice transition // between the window chrome and the content area. And it works in low colour depths. - PRectangle rcPattern(0, 0, patternSize, patternSize); + PRectangle rcPattern = PRectangle::FromInts(0, 0, patternSize, patternSize); // Initialize default colours based on the chrome colour scheme. Typically the highlight is white. ColourDesired colourFMFill = vs.selbar; @@ -3389,7 +3389,7 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) { pixmapSelPatternOffset1->FillRectangle(rcPattern, colourFMStripes); for (int y = 0; y < patternSize; y++) { for (int x = y % 2; x < patternSize; x+=2) { - PRectangle rcPixel(x, y, x+1, y+1); + PRectangle rcPixel = PRectangle::FromInts(x, y, x + 1, y + 1); pixmapSelPattern->FillRectangle(rcPixel, colourFMStripes); pixmapSelPatternOffset1->FillRectangle(rcPixel, colourFMFill); } @@ -3400,13 +3400,13 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) { // 1 extra pixel in height so can handle odd/even positions and so produce a continuous line pixmapIndentGuide->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID()); pixmapIndentGuideHighlight->InitPixMap(1, vs.lineHeight + 1, surfaceWindow, wMain.GetID()); - PRectangle rcIG(0, 0, 1, vs.lineHeight); + PRectangle rcIG = PRectangle::FromInts(0, 0, 1, vs.lineHeight); pixmapIndentGuide->FillRectangle(rcIG, vs.styles[STYLE_INDENTGUIDE].back); pixmapIndentGuide->PenColour(vs.styles[STYLE_INDENTGUIDE].fore); pixmapIndentGuideHighlight->FillRectangle(rcIG, vs.styles[STYLE_BRACELIGHT].back); pixmapIndentGuideHighlight->PenColour(vs.styles[STYLE_BRACELIGHT].fore); for (int stripe = 1; stripe < vs.lineHeight + 1; stripe += 2) { - PRectangle rcPixel(0, stripe, 1, stripe+1); + PRectangle rcPixel = PRectangle::FromInts(0, stripe, 1, stripe + 1); pixmapIndentGuide->FillRectangle(rcPixel, vs.styles[STYLE_INDENTGUIDE].fore); pixmapIndentGuideHighlight->FillRectangle(rcPixel, vs.styles[STYLE_BRACELIGHT].fore); } @@ -3711,8 +3711,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { DrawCarets(surface, vs, lineDoc, xStart, rcLine, ll, subLine); if (bufferedDraw) { - Point from(vs.textStart-leftTextOverlap, 0); - PRectangle rcCopyArea(vs.textStart-leftTextOverlap, yposScreen, + Point from = Point::FromInts(vs.textStart-leftTextOverlap, 0); + PRectangle rcCopyArea = PRectangle::FromInts(vs.textStart - leftTextOverlap, yposScreen, static_cast<int>(rcClient.right - vs.rightMarginWidth), yposScreen + vs.lineHeight); surfaceWindow->Copy(rcCopyArea, from, *pixmapLine); @@ -3899,7 +3899,7 @@ long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { ll.containsCaret = false; - PRectangle rcLine( + PRectangle rcLine = PRectangle::FromInts( pfr->rc.left, ypos, pfr->rc.right - 1, @@ -5014,17 +5014,17 @@ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) { int topStutterLine = topLine + caretYSlop; int bottomStutterLine = pdoc->LineFromPosition(PositionFromLocation( - Point(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll()))) + Point::FromInts(lastXChosen - xOffset, direction * vs.lineHeight * LinesToScroll()))) - caretYSlop - 1; if (stuttered && (direction < 0 && currentLine > topStutterLine)) { topLineNew = topLine; - newPos = SPositionFromLocation(Point(lastXChosen - xOffset, vs.lineHeight * caretYSlop), + newPos = SPositionFromLocation(Point::FromInts(lastXChosen - xOffset, vs.lineHeight * caretYSlop), false, false, UserVirtualSpace()); } else if (stuttered && (direction > 0 && currentLine < bottomStutterLine)) { topLineNew = topLine; - newPos = SPositionFromLocation(Point(lastXChosen - xOffset, vs.lineHeight * (LinesToScroll() - caretYSlop)), + newPos = SPositionFromLocation(Point::FromInts(lastXChosen - xOffset, vs.lineHeight * (LinesToScroll() - caretYSlop)), false, false, UserVirtualSpace()); } else { @@ -5033,7 +5033,7 @@ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) { topLineNew = Platform::Clamp( topLine + direction * LinesToScroll(), 0, MaxScrollPos()); newPos = SPositionFromLocation( - Point(lastXChosen - xOffset, static_cast<int>(pt.y) + direction * (vs.lineHeight * LinesToScroll())), + Point::FromInts(lastXChosen - xOffset, static_cast<int>(pt.y) + direction * (vs.lineHeight * LinesToScroll())), false, false, UserVirtualSpace()); } @@ -5232,7 +5232,7 @@ void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { int newY = static_cast<int>(pt.y) + (1 + skipLines) * direction * vs.lineHeight; SelectionPosition posNew = SPositionFromLocation( - Point(lastXChosen - xOffset, newY), false, false, UserVirtualSpace()); + Point::FromInts(lastXChosen - xOffset, newY), false, false, UserVirtualSpace()); if (direction < 0) { // Line wrapping may lead to a location on the same line, so @@ -8058,19 +8058,19 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_POSITIONFROMPOINT: - return PositionFromLocation(Point(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), + return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), false, false); case SCI_POSITIONFROMPOINTCLOSE: - return PositionFromLocation(Point(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), + return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), true, false); case SCI_CHARPOSITIONFROMPOINT: - return PositionFromLocation(Point(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), + return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), false, true); case SCI_CHARPOSITIONFROMPOINTCLOSE: - return PositionFromLocation(Point(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), + return PositionFromLocation(Point::FromInts(static_cast<int>(wParam) - vs.ExternalMarginWidth(), static_cast<int>(lParam)), true, true); case SCI_GOTOLINE: diff --git a/src/Indicator.cxx b/src/Indicator.cxx index ba20dd941..63735d480 100644 --- a/src/Indicator.cxx +++ b/src/Indicator.cxx @@ -20,7 +20,7 @@ using namespace Scintilla; static PRectangle PixelGridAlign(const PRectangle &rc) { // Move left and right side to nearest pixel to avoid blurry visuals - return PRectangle(int(rc.left + 0.5), int(rc.top), int(rc.right + 0.5), int(rc.bottom)); + return PRectangle::FromInts(int(rc.left + 0.5), int(rc.top), int(rc.right + 0.5), int(rc.bottom)); } void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) { @@ -148,7 +148,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r } else if (style == INDIC_DOTS) { int x = static_cast<int>(rc.left); while (x < static_cast<int>(rc.right)) { - PRectangle rcDot(x, ymid, x+1, ymid+1); + PRectangle rcDot = PRectangle::FromInts(x, ymid, x + 1, ymid + 1); surface->FillRectangle(rcDot, fore); x += 2; } diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx index ced622b75..938288b1f 100644 --- a/src/LineMarker.cxx +++ b/src/LineMarker.cxx @@ -42,7 +42,7 @@ void LineMarker::SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned c } static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) { - PRectangle rc( + PRectangle rc = PRectangle::FromInts( centreX - armSize, centreY - armSize, centreX + armSize + 1, @@ -51,7 +51,7 @@ static void DrawBox(Surface *surface, int centreX, int centreY, int armSize, Col } static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore, ColourDesired back) { - PRectangle rcCircle( + PRectangle rcCircle = PRectangle::FromInts( centreX - armSize, centreY - armSize, centreX + armSize + 1, @@ -60,14 +60,14 @@ static void DrawCircle(Surface *surface, int centreX, int centreY, int armSize, } static void DrawPlus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) { - PRectangle rcV(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1); + PRectangle rcV = PRectangle::FromInts(centreX, centreY - armSize + 2, centreX + 1, centreY + armSize - 2 + 1); surface->FillRectangle(rcV, fore); - PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1); + PRectangle rcH = PRectangle::FromInts(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY + 1); surface->FillRectangle(rcH, fore); } static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, ColourDesired fore) { - PRectangle rcH(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY+1); + PRectangle rcH = PRectangle::FromInts(centreX - armSize + 2, centreY, centreX + armSize - 2 + 1, centreY + 1); surface->FillRectangle(rcH, fore); } @@ -131,7 +131,7 @@ 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( + PRectangle rcCircle = PRectangle::FromInts( centreX - dimOn2, centreY - dimOn2, centreX + dimOn2, @@ -139,43 +139,43 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac surface->Ellipse(rcCircle, fore, back); } else if (markType == SC_MARK_ARROW) { Point pts[] = { - Point(centreX - dimOn4, centreY - dimOn2), - Point(centreX - dimOn4, centreY + dimOn2), - Point(centreX + dimOn2 - dimOn4, centreY), + Point::FromInts(centreX - dimOn4, centreY - dimOn2), + Point::FromInts(centreX - dimOn4, centreY + dimOn2), + Point::FromInts(centreX + dimOn2 - dimOn4, centreY), }; surface->Polygon(pts, ELEMENTS(pts), fore, back); } else if (markType == SC_MARK_ARROWDOWN) { Point pts[] = { - Point(centreX - dimOn2, centreY - dimOn4), - Point(centreX + dimOn2, centreY - dimOn4), - Point(centreX, centreY + dimOn2 - dimOn4), + Point::FromInts(centreX - dimOn2, centreY - dimOn4), + Point::FromInts(centreX + dimOn2, centreY - dimOn4), + Point::FromInts(centreX, centreY + dimOn2 - dimOn4), }; surface->Polygon(pts, ELEMENTS(pts), fore, back); } else if (markType == SC_MARK_PLUS) { Point pts[] = { - Point(centreX - armSize, centreY - 1), - Point(centreX - 1, centreY - 1), - Point(centreX - 1, centreY - armSize), - Point(centreX + 1, centreY - armSize), - Point(centreX + 1, centreY - 1), - Point(centreX + armSize, centreY -1), - Point(centreX + armSize, centreY +1), - Point(centreX + 1, centreY + 1), - Point(centreX + 1, centreY + armSize), - Point(centreX - 1, centreY + armSize), - Point(centreX - 1, centreY + 1), - Point(centreX - armSize, centreY + 1), + Point::FromInts(centreX - armSize, centreY - 1), + Point::FromInts(centreX - 1, centreY - 1), + Point::FromInts(centreX - 1, centreY - armSize), + Point::FromInts(centreX + 1, centreY - armSize), + Point::FromInts(centreX + 1, centreY - 1), + Point::FromInts(centreX + armSize, centreY -1), + Point::FromInts(centreX + armSize, centreY +1), + Point::FromInts(centreX + 1, centreY + 1), + Point::FromInts(centreX + 1, centreY + armSize), + Point::FromInts(centreX - 1, centreY + armSize), + Point::FromInts(centreX - 1, centreY + 1), + Point::FromInts(centreX - armSize, centreY + 1), }; surface->Polygon(pts, ELEMENTS(pts), fore, back); } else if (markType == SC_MARK_MINUS) { Point pts[] = { - Point(centreX - armSize, centreY - 1), - Point(centreX + armSize, centreY -1), - Point(centreX + armSize, centreY +1), - Point(centreX - armSize, centreY + 1), + Point::FromInts(centreX - armSize, centreY - 1), + Point::FromInts(centreX + armSize, centreY -1), + Point::FromInts(centreX + armSize, centreY +1), + Point::FromInts(centreX - armSize, centreY + 1), }; surface->Polygon(pts, ELEMENTS(pts), fore, back); @@ -363,14 +363,14 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac } } else if (markType == SC_MARK_SHORTARROW) { Point pts[] = { - Point(centreX, centreY + dimOn2), - Point(centreX + dimOn2, centreY), - Point(centreX, centreY - dimOn2), - Point(centreX, centreY - dimOn4), - Point(centreX - dimOn4, centreY - dimOn4), - Point(centreX - dimOn4, centreY + dimOn4), - Point(centreX, centreY + dimOn4), - Point(centreX, centreY + dimOn2), + Point::FromInts(centreX, centreY + dimOn2), + Point::FromInts(centreX + dimOn2, centreY), + Point::FromInts(centreX, centreY - dimOn2), + Point::FromInts(centreX, centreY - dimOn4), + Point::FromInts(centreX - dimOn4, centreY - dimOn4), + Point::FromInts(centreX - dimOn4, centreY + dimOn4), + Point::FromInts(centreX, centreY + dimOn4), + Point::FromInts(centreX, centreY + dimOn2), }; surface->Polygon(pts, ELEMENTS(pts), fore, back); } else if (markType == SC_MARK_LEFTRECT) { @@ -380,11 +380,11 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac } else if (markType == SC_MARK_BOOKMARK) { int halfHeight = minDim / 3; Point pts[] = { - Point(static_cast<int>(rc.left), centreY-halfHeight), - Point(static_cast<int>(rc.right) - 3, centreY - halfHeight), - Point(static_cast<int>(rc.right) - 3 - halfHeight, centreY), - Point(static_cast<int>(rc.right) - 3, centreY + halfHeight), - Point(static_cast<int>(rc.left), centreY + halfHeight), + Point::FromInts(static_cast<int>(rc.left), centreY-halfHeight), + Point::FromInts(static_cast<int>(rc.right) - 3, centreY - halfHeight), + Point::FromInts(static_cast<int>(rc.right) - 3 - halfHeight, centreY), + Point::FromInts(static_cast<int>(rc.right) - 3, centreY + halfHeight), + Point::FromInts(static_cast<int>(rc.left), centreY + halfHeight), }; surface->Polygon(pts, ELEMENTS(pts), fore, back); } else { // SC_MARK_FULLRECT diff --git a/src/XPM.cxx b/src/XPM.cxx index b3c9b338f..c2b308acb 100644 --- a/src/XPM.cxx +++ b/src/XPM.cxx @@ -47,7 +47,7 @@ ColourDesired XPM::ColourFromCode(int ch) const { void XPM::FillRun(Surface *surface, int code, int startX, int y, int x) { if ((code != codeTransparent) && (startX != x)) { - PRectangle rc(startX, y, x, y+1); + PRectangle rc = PRectangle::FromInts(startX, y, x, y + 1); surface->FillRectangle(rc, ColourFromCode(code)); } } diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 180d2d1a7..082a177e6 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -1878,7 +1878,7 @@ bool Window::HasFocus() { PRectangle Window::GetPosition() { RECT rc; ::GetWindowRect(reinterpret_cast<HWND>(wid), &rc); - return PRectangle(rc.left, rc.top, rc.right, rc.bottom); + return PRectangle::FromInts(rc.left, rc.top, rc.right, rc.bottom); } void Window::SetPosition(PRectangle rc) { @@ -1943,7 +1943,7 @@ PRectangle Window::GetClientPosition() { RECT rc={0,0,0,0}; if (wid) ::GetClientRect(reinterpret_cast<HWND>(wid), &rc); - return PRectangle(rc.left, rc.top, rc.right, rc.bottom); + return PRectangle::FromInts(rc.left, rc.top, rc.right, rc.bottom); } void Window::Show(bool show) { @@ -2235,7 +2235,7 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei POINT locationw = {static_cast<LONG>(location.x), static_cast<LONG>(location.y)}; ::MapWindowPoints(hwndParent, NULL, &locationw, 1); - location = Point(locationw.x, locationw.y); + location = Point::FromInts(locationw.x, locationw.y); } void ListBoxX::SetFont(Font &font) { @@ -2415,7 +2415,7 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { if (technology == SCWIN_TECH_GDI) { surfaceItem->Init(pDrawItem->hDC, pDrawItem->hwndItem); long left = pDrawItem->rcItem.left + static_cast<int>(ItemInset.x + ImageInset.x); - PRectangle rcImage(left, pDrawItem->rcItem.top, + PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top, left + images.GetWidth(), pDrawItem->rcItem.bottom); surfaceItem->DrawRGBAImage(rcImage, pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels()); @@ -2443,7 +2443,7 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { surfaceItem->Init(pDCRT, pDrawItem->hwndItem); pDCRT->BeginDraw(); long left = pDrawItem->rcItem.left + static_cast<long>(ItemInset.x + ImageInset.x); - PRectangle rcImage(left, pDrawItem->rcItem.top, + PRectangle rcImage = PRectangle::FromInts(left, pDrawItem->rcItem.top, left + images.GetWidth(), pDrawItem->rcItem.bottom); surfaceItem->DrawRGBAImage(rcImage, pimage->GetWidth(), pimage->GetHeight(), pimage->Pixels()); @@ -2520,7 +2520,7 @@ void ListBoxX::SetList(const char *list, char separator, char typesep) { void ListBoxX::AdjustWindowRect(PRectangle *rc) { RECT rcw = RectFromPRectangle(*rc); ::AdjustWindowRectEx(&rcw, WS_THICKFRAME, false, WS_EX_WINDOWEDGE); - *rc = PRectangle(rcw.left, rcw.top, rcw.right, rcw.bottom); + *rc = PRectangle::FromInts(rcw.left, rcw.top, rcw.right, rcw.bottom); } int ListBoxX::ItemHeight() const { @@ -2537,14 +2537,14 @@ int ListBoxX::MinClientWidth() const { } POINT ListBoxX::MinTrackSize() const { - PRectangle rc(0, 0, MinClientWidth(), ItemHeight()); + PRectangle rc = PRectangle::FromInts(0, 0, MinClientWidth(), ItemHeight()); AdjustWindowRect(&rc); POINT ret = {static_cast<LONG>(rc.Width()), static_cast<LONG>(rc.Height())}; return ret; } POINT ListBoxX::MaxTrackSize() const { - PRectangle rc(0, 0, + PRectangle rc = PRectangle::FromInts(0, 0, Platform::Maximum(MinClientWidth(), maxCharWidth * maxItemCharacters + static_cast<int>(TextInset.x) * 2 + TextOffset() + ::GetSystemMetrics(SM_CXVSCROLL)), @@ -2578,7 +2578,7 @@ void ListBoxX::ResizeToCursor() { PRectangle rc = GetPosition(); POINT ptw; ::GetCursorPos(&ptw); - Point pt(ptw.x, ptw.y); + Point pt = Point::FromInts(ptw.x, ptw.y); pt.x += dragOffset.x; pt.y += dragOffset.y; diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 9288eb21b..b19ebeb3c 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -121,6 +121,10 @@ static void SetWindowID(HWND hWnd, int identifier) { ::SetWindowLongPtr(hWnd, GWLP_ID, identifier); } +static Point PointFromPOINT(POINT pt) { + return Point::FromInts(pt.x, pt.y); +} + class ScintillaWin; // Forward declaration for COM interface subobjects typedef void VFunction(void); @@ -567,7 +571,7 @@ LRESULT ScintillaWin::WndPaint(uptr_t wParam) { pps = &ps; ::BeginPaint(MainHWND(), pps); } - rcPaint = PRectangle(pps->rcPaint.left, pps->rcPaint.top, pps->rcPaint.right, pps->rcPaint.bottom); + rcPaint = PRectangle::FromInts(pps->rcPaint.left, pps->rcPaint.top, pps->rcPaint.right, pps->rcPaint.bottom); PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); if (technology == SC_TECHNOLOGY_DEFAULT) { @@ -906,11 +910,11 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam POINT pt; if (0 != ::GetCursorPos(&pt)) { ::ScreenToClient(MainHWND(), &pt); - if (PointInSelMargin(Point(pt.x, pt.y))) { - DisplayCursor(GetMarginCursor(Point(pt.x, pt.y))); - } else if (PointInSelection(Point(pt.x, pt.y)) && !SelectionEmpty()) { + if (PointInSelMargin(PointFromPOINT(pt))) { + DisplayCursor(GetMarginCursor(PointFromPOINT(pt))); + } else if (PointInSelection(PointFromPOINT(pt)) && !SelectionEmpty()) { DisplayCursor(Window::cursorArrow); - } else if (PointIsHotspot(Point(pt.x, pt.y))) { + } else if (PointIsHotspot(PointFromPOINT(pt))) { DisplayCursor(Window::cursorHand); } else { DisplayCursor(Window::cursorText); @@ -1047,7 +1051,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam pt = PointMainCaret(); POINT spt = {static_cast<int>(pt.x), static_cast<int>(pt.y)}; ::ClientToScreen(MainHWND(), &spt); - pt = Point(spt.x, spt.y); + pt = PointFromPOINT(spt); } ContextMenu(pt); return 0; @@ -2429,7 +2433,7 @@ STDMETHODIMP ScintillaWin::DragOver(DWORD grfKeyState, POINTL pt, PDWORD pdwEffe // Update the cursor. POINT rpt = {pt.x, pt.y}; ::ScreenToClient(MainHWND(), &rpt); - SetDragPosition(SPositionFromLocation(Point(rpt.x, rpt.y), false, false, UserVirtualSpace())); + SetDragPosition(SPositionFromLocation(PointFromPOINT(rpt), false, false, UserVirtualSpace())); return S_OK; } catch (...) { @@ -2511,7 +2515,7 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState, POINT rpt = {pt.x, pt.y}; ::ScreenToClient(MainHWND(), &rpt); - SelectionPosition movePos = SPositionFromLocation(Point(rpt.x, rpt.y), false, false, UserVirtualSpace()); + SelectionPosition movePos = SPositionFromLocation(PointFromPOINT(rpt), false, false, UserVirtualSpace()); DropAt(movePos, &data[0], data.size() - 1, *pdwEffect == DROPEFFECT_MOVE, hrRectangular == S_OK); @@ -2751,7 +2755,7 @@ sptr_t PASCAL ScintillaWin::CTWndProc( pt.x = static_cast<short>(LOWORD(lParam)); pt.y = static_cast<short>(HIWORD(lParam)); ScreenToClient(hWnd, &pt); - sciThis->ct.MouseClick(Point(pt.x, pt.y)); + sciThis->ct.MouseClick(PointFromPOINT(pt)); sciThis->CallTipClick(); return 0; } else if (iMessage == WM_LBUTTONDOWN) { |