aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/Platform.h4
-rw-r--r--win32/PlatWin.cxx8
-rw-r--r--win32/PlatWin.h8
-rw-r--r--win32/ScintillaWin.cxx13
4 files changed, 17 insertions, 16 deletions
diff --git a/include/Platform.h b/include/Platform.h
index 7a621c65e..cdaf65140 100644
--- a/include/Platform.h
+++ b/include/Platform.h
@@ -104,7 +104,7 @@ public:
constexpr explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) noexcept : x(x_), y(y_) {
}
- static Point FromInts(int x_, int y_) noexcept {
+ static constexpr Point FromInts(int x_, int y_) noexcept {
return Point(static_cast<XYPOSITION>(x_), static_cast<XYPOSITION>(y_));
}
@@ -139,7 +139,7 @@ public:
left(left_), top(top_), right(right_), bottom(bottom_) {
}
- static PRectangle FromInts(int left_, int top_, int right_, int bottom_) noexcept {
+ static constexpr PRectangle FromInts(int left_, int top_, int right_, int bottom_) noexcept {
return PRectangle(static_cast<XYPOSITION>(left_), static_cast<XYPOSITION>(top_),
static_cast<XYPOSITION>(right_), static_cast<XYPOSITION>(bottom_));
}
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 348cbb255..2c537d766 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -622,7 +622,7 @@ void SurfaceGDI::Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesi
BrushColour(back);
std::vector<POINT> outline;
for (size_t i=0; i<npts; i++) {
- POINT pt = {static_cast<LONG>(pts[i].x), static_cast<LONG>(pts[i].y)};
+ POINT pt = POINTFromPoint(pts[i]);
outline.push_back(pt);
}
::Polygon(hdc, &outline[0], static_cast<int>(npts));
@@ -2474,9 +2474,9 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei
hinstanceParent,
this);
- POINT locationw = {static_cast<LONG>(location.x), static_cast<LONG>(location.y)};
+ POINT locationw = POINTFromPoint(location);
::MapWindowPoints(hwndParent, NULL, &locationw, 1);
- location = Point::FromInts(locationw.x, locationw.y);
+ location = PointFromPOINT(locationw);
}
void ListBoxX::SetFont(Font &font) {
@@ -2799,7 +2799,7 @@ void ListBoxX::ResizeToCursor() {
PRectangle rc = GetPosition();
POINT ptw;
::GetCursorPos(&ptw);
- const Point pt = Point::FromInts(ptw.x, ptw.y) + dragOffset;
+ const Point pt = PointFromPOINT(ptw) + dragOffset;
switch (resizeHit) {
case HTLEFT:
diff --git a/win32/PlatWin.h b/win32/PlatWin.h
index 6fb8ff5f1..001a834cc 100644
--- a/win32/PlatWin.h
+++ b/win32/PlatWin.h
@@ -19,6 +19,14 @@ constexpr RECT RectFromPRectangle(PRectangle prc) noexcept {
return rc;
}
+constexpr POINT POINTFromPoint(Point pt) noexcept {
+ return POINT{ static_cast<LONG>(pt.x), static_cast<LONG>(pt.y) };
+}
+
+constexpr Point PointFromPOINT(POINT pt) noexcept {
+ return Point::FromInts(pt.x, pt.y);
+}
+
constexpr HWND HwndFromWindowID(WindowID wid) noexcept {
return static_cast<HWND>(wid);
}
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 232352224..8844e01c5 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -156,15 +156,10 @@ void SetWindowID(HWND hWnd, int identifier) noexcept {
::SetWindowLongPtr(hWnd, GWLP_ID, identifier);
}
-Point PointFromPOINT(POINT pt) noexcept {
- return Point::FromInts(pt.x, pt.y);
-}
Point PointFromLParam(sptr_t lpoint) noexcept {
return Point::FromInts(GET_X_LPARAM(lpoint), GET_Y_LPARAM(lpoint));
}
-constexpr POINT POINTFromPoint(Point pt) noexcept {
- return POINT{ static_cast<LONG>(pt.x), static_cast<LONG>(pt.y) };
-}
+
bool KeyboardIsKeyDown(int key) noexcept {
return (::GetKeyState(key) & 0x80000000) != 0;
}
@@ -1347,7 +1342,7 @@ Window::Cursor ScintillaWin::ContextCursor() {
sptr_t ScintillaWin::ShowContextMenu(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
Point pt = PointFromLParam(lParam);
- POINT rpt = { static_cast<int>(pt.x), static_cast<int>(pt.y) };
+ POINT rpt = POINTFromPoint(pt);
::ScreenToClient(MainHWND(), &rpt);
const Point ptClient = PointFromPOINT(rpt);
if (ShouldDisplayPopup(ptClient)) {
@@ -1436,9 +1431,7 @@ sptr_t ScintillaWin::MouseMessage(unsigned int iMessage, uptr_t wParam, sptr_t l
// handle the message but pass it on.
RECT rc;
GetWindowRect(MainHWND(), &rc);
- POINT pt;
- pt.x = GET_X_LPARAM(lParam);
- pt.y = GET_Y_LPARAM(lParam);
+ const POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
if (!PtInRect(&rc, pt))
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
}