diff options
Diffstat (limited to 'win32')
| -rw-r--r-- | win32/PlatWin.cxx | 8 | ||||
| -rw-r--r-- | win32/PlatWin.h | 8 | ||||
| -rw-r--r-- | win32/ScintillaWin.cxx | 13 |
3 files changed, 15 insertions, 14 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 004c4cb50..0ffa9323d 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -625,7 +625,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)); @@ -2069,9 +2069,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) { @@ -2394,7 +2394,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 01e321e4c..f4f804b2e 100644 --- a/win32/PlatWin.h +++ b/win32/PlatWin.h @@ -15,6 +15,14 @@ extern void Platform_Finalise(bool fromDllMain); RECT RectFromPRectangle(PRectangle prc) noexcept; +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 b17cf6510..3984cc461 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -155,15 +155,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; } @@ -1337,7 +1332,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)) { @@ -1426,9 +1421,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); } |
