aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil Hodgson <nyamatongwe@gmail.com>2023-02-27 17:46:20 +1100
committerNeil Hodgson <nyamatongwe@gmail.com>2023-02-27 17:46:20 +1100
commite76fbd3f9ba742a1ef789ae215d9a71f9e27ad17 (patch)
tree6c4d2f5f3bd6ee77ed434c86753c3b18c908ae57
parenta7641e03b04fe14776d64d51b0f8f914280bf7ca (diff)
downloadscintilla-mirror-e76fbd3f9ba742a1ef789ae215d9a71f9e27ad17.tar.gz
Remove unnecessary casts from CGFloat to XYPosition as they are both double.
-rw-r--r--cocoa/PlatCocoa.mm26
-rw-r--r--cocoa/ScintillaCocoa.mm10
-rw-r--r--cocoa/ScintillaView.mm4
3 files changed, 18 insertions, 22 deletions
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index a105eafad..5d161f810 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -74,9 +74,7 @@ NSRect PRectangleToNSRect(const PRectangle &rc) {
* Converts an NSRect as used by the system to a native Scintilla rectangle.
*/
PRectangle NSRectToPRectangle(NSRect &rc) {
- return PRectangle(static_cast<XYPOSITION>(rc.origin.x), static_cast<XYPOSITION>(rc.origin.y),
- static_cast<XYPOSITION>(NSMaxX(rc)),
- static_cast<XYPOSITION>(NSMaxY(rc)));
+ return PRectangle(rc.origin.x, rc.origin.y, NSMaxX(rc), NSMaxY(rc));
}
//--------------------------------------------------------------------------------------------------
@@ -1288,7 +1286,7 @@ void SurfaceImpl::MeasureWidths(const Font *font_, std::string_view text, XYPOSI
// Switched to MacRoman to make work so treat as single byte encoding.
for (int i=0; i<text.length(); i++) {
CGFloat xPosition = CTLineGetOffsetForStringIndex(mLine, i+1, nullptr);
- positions[i] = static_cast<XYPOSITION>(xPosition);
+ positions[i] = xPosition;
}
return;
}
@@ -1306,7 +1304,7 @@ void SurfaceImpl::MeasureWidths(const Font *font_, std::string_view text, XYPOSI
const int codeUnits = UTF16LengthFromUTF8ByteCount(byteCount);
const CGFloat xPosition = linePositions[ui];
for (unsigned int bytePos=0; (bytePos<byteCount) && (i<text.length()); bytePos++) {
- positions[i++] = static_cast<XYPOSITION>(xPosition);
+ positions[i++] = xPosition;
}
ui += codeUnits;
}
@@ -1322,14 +1320,14 @@ void SurfaceImpl::MeasureWidths(const Font *font_, std::string_view text, XYPOSI
size_t lenChar = DBCSIsLeadByte(mode.codePage, text[i]) ? 2 : 1;
CGFloat xPosition = CTLineGetOffsetForStringIndex(mLine, ui+1, NULL);
for (unsigned int bytePos=0; (bytePos<lenChar) && (i<text.length()); bytePos++) {
- positions[i++] = static_cast<XYPOSITION>(xPosition);
+ positions[i++] = xPosition;
}
ui++;
}
} else { // Single byte encoding
for (int i=0; i<text.length(); i++) {
CGFloat xPosition = CTLineGetOffsetForStringIndex(mLine, i+1, NULL);
- positions[i] = static_cast<XYPOSITION>(xPosition);
+ positions[i] = xPosition;
}
}
@@ -1405,7 +1403,7 @@ void SurfaceImpl::MeasureWidthsUTF8(const Font *font_, std::string_view text, XY
// Switched to MacRoman to make work so treat as single byte encoding.
for (int i=0; i<text.length(); i++) {
CGFloat xPosition = CTLineGetOffsetForStringIndex(mLine, i+1, nullptr);
- positions[i] = static_cast<XYPOSITION>(xPosition);
+ positions[i] = xPosition;
}
return;
}
@@ -1422,7 +1420,7 @@ void SurfaceImpl::MeasureWidthsUTF8(const Font *font_, std::string_view text, XY
const int codeUnits = UTF16LengthFromUTF8ByteCount(byteCount);
const CGFloat xPosition = linePositions[ui];
for (unsigned int bytePos=0; (bytePos<byteCount) && (i<text.length()); bytePos++) {
- positions[i++] = static_cast<XYPOSITION>(xPosition);
+ positions[i++] = xPosition;
}
ui += codeUnits;
}
@@ -1546,8 +1544,8 @@ PRectangle Window::GetPosition() const {
CGFloat screenHeight = ScreenMax();
// Invert screen positions to match Scintilla
return PRectangle(
- static_cast<XYPOSITION>(NSMinX(rect)), static_cast<XYPOSITION>(screenHeight - NSMaxY(rect)),
- static_cast<XYPOSITION>(NSMaxX(rect)), static_cast<XYPOSITION>(screenHeight - NSMinY(rect)));
+ NSMinX(rect), screenHeight - NSMaxY(rect),
+ NSMaxX(rect), screenHeight - NSMinY(rect));
} else {
return PRectangle(0, 0, 1, 1);
}
@@ -1686,8 +1684,8 @@ PRectangle Window::GetMonitorRect(Point) {
CGFloat screenHeight = rect.origin.y + rect.size.height;
// Invert screen positions to match Scintilla
PRectangle rcWork(
- static_cast<XYPOSITION>(NSMinX(rect)), static_cast<XYPOSITION>(screenHeight - NSMaxY(rect)),
- static_cast<XYPOSITION>(NSMaxX(rect)), static_cast<XYPOSITION>(screenHeight - NSMinY(rect)));
+ NSMinX(rect), screenHeight - NSMaxY(rect),
+ NSMaxX(rect), screenHeight - NSMinY(rect));
PRectangle rcMonitor(rcWork.left - rcPosition.left,
rcWork.top - rcPosition.top,
rcWork.right - rcPosition.left,
@@ -2082,7 +2080,7 @@ void ListBoxImpl::Append(char *s, int type) {
}
NSImage *img = images[@(type)];
if (img) {
- XYPOSITION widthIcon = static_cast<XYPOSITION>(img.size.width);
+ XYPOSITION widthIcon = img.size.width;
if (widthIcon > maxIconWidth) {
[colIcon setHidden: NO];
maxIconWidth = widthIcon;
diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm
index 3d4a0f622..4f4fa1b71 100644
--- a/cocoa/ScintillaCocoa.mm
+++ b/cocoa/ScintillaCocoa.mm
@@ -726,7 +726,7 @@ SCIContentView *ScintillaCocoa::ContentView() {
Scintilla::Internal::Point ScintillaCocoa::GetVisibleOriginInMain() const {
NSScrollView *scrollView = ScrollContainer();
NSRect contentRect = scrollView.contentView.bounds;
- return Point(static_cast<XYPOSITION>(contentRect.origin.x), static_cast<XYPOSITION>(contentRect.origin.y));
+ return Point(contentRect.origin.x, contentRect.origin.y);
}
//--------------------------------------------------------------------------------------------------
@@ -740,8 +740,7 @@ PRectangle ScintillaCocoa::GetClientRectangle() const {
NSScrollView *scrollView = ScrollContainer();
NSSize size = scrollView.contentView.bounds.size;
Point origin = GetVisibleOriginInMain();
- return PRectangle(origin.x, origin.y, static_cast<XYPOSITION>(origin.x+size.width),
- static_cast<XYPOSITION>(origin.y + size.height));
+ return PRectangle(origin.x, origin.y, origin.x+size.width, origin.y + size.height);
}
//--------------------------------------------------------------------------------------------------
@@ -772,7 +771,7 @@ Scintilla::Internal::Point ScintillaCocoa::ConvertPoint(NSPoint point) {
NSView *container = ContentView();
NSPoint result = [container convertPoint: point fromView: nil];
Scintilla::Internal::Point ptOrigin = GetVisibleOriginInMain();
- return Point(static_cast<XYPOSITION>(result.x - ptOrigin.x), static_cast<XYPOSITION>(result.y - ptOrigin.y));
+ return Point(result.x - ptOrigin.x, result.y - ptOrigin.y);
}
//--------------------------------------------------------------------------------------------------
@@ -1168,8 +1167,7 @@ void ScintillaCocoa::CTPaint(void *gc, NSRect rc) {
void ScintillaCocoa::CallTipMouseDown(NSPoint pt) {
NSRect rectBounds = ((__bridge NSView *)(ct.wDraw.GetID())).bounds;
- Point location(static_cast<XYPOSITION>(pt.x),
- static_cast<XYPOSITION>(rectBounds.size.height - pt.y));
+ Point location(pt.x, rectBounds.size.height - pt.y);
ct.MouseClick(location);
CallTipClick();
}
diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm
index 705f6a00e..54988f650 100644
--- a/cocoa/ScintillaView.mm
+++ b/cocoa/ScintillaView.mm
@@ -784,14 +784,14 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) {
// Only snap for positions inside the document - allow outside
// for overshoot.
long lineHeight = mOwner.backend->WndProc(Message::TextHeight, 0, 0);
- rc.origin.y = std::round(static_cast<XYPOSITION>(rc.origin.y) / lineHeight) * lineHeight;
+ rc.origin.y = std::round(rc.origin.y / lineHeight) * lineHeight;
}
// Snap to whole points - on retina displays this avoids visual debris
// when scrolling horizontally.
if ((rc.origin.x > 0) && (NSMaxX(rc) < contentRect.size.width)) {
// Only snap for positions inside the document - allow outside
// for overshoot.
- rc.origin.x = std::round(static_cast<XYPOSITION>(rc.origin.x));
+ rc.origin.x = std::round(rc.origin.x);
}
return rc;
}