diff options
| author | Zufu Liu <unknown> | 2020-05-27 09:19:45 +1000 |
|---|---|---|
| committer | Zufu Liu <unknown> | 2020-05-27 09:19:45 +1000 |
| commit | ca0c453005807c8c0ca7aea0ee7cc766aa761770 (patch) | |
| tree | 16fb7a3374fc109bc9188372ec2b9af29b810224 /win32/ScintillaWin.cxx | |
| parent | e5055a92d553f312bfde092f518e7fe75f134d82 (diff) | |
| download | scintilla-mirror-ca0c453005807c8c0ca7aea0ee7cc766aa761770.tar.gz | |
Backport: Bug [#2063]. Make reverse arrow cursor scale with DPI.
Backport of changeset 8265:01940b16fb7e.
Diffstat (limited to 'win32/ScintillaWin.cxx')
| -rw-r--r-- | win32/ScintillaWin.cxx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index a850812c7..dcae50140 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -266,6 +266,37 @@ public: } }; +class ReverseArrowCursor { + UINT dpi = USER_DEFAULT_SCREEN_DPI; + HCURSOR cursor {}; + +public: + ReverseArrowCursor() noexcept {} + // Deleted so ReverseArrowCursor objects can not be copied. + ReverseArrowCursor(const ReverseArrowCursor &) = delete; + ReverseArrowCursor(ReverseArrowCursor &&) = delete; + ReverseArrowCursor &operator=(const ReverseArrowCursor &) = delete; + ReverseArrowCursor &operator=(ReverseArrowCursor &&) = delete; + ~ReverseArrowCursor() { + if (cursor) { + ::DestroyCursor(cursor); + } + } + + HCURSOR Load(UINT dpi_) noexcept { + if (cursor) { + if (dpi == dpi_) { + return cursor; + } + ::DestroyCursor(cursor); + } + + dpi = dpi_; + cursor = LoadReverseArrowCursor(dpi_); + return cursor ? cursor : ::LoadCursor({}, IDC_ARROW); + } +}; + } /** @@ -284,6 +315,7 @@ class ScintillaWin : int wheelDelta; ///< Wheel delta from roll UINT dpi = USER_DEFAULT_SCREEN_DPI; + ReverseArrowCursor reverseArrowCursor; HRGN hRgnUpdate; @@ -333,6 +365,7 @@ class ScintillaWin : enum : UINT_PTR { invalidTimerID, standardTimerID, idleTimerID, fineTimerStart }; + void DisplayCursor(Window::Cursor c) override; bool DragThreshold(Point ptStart, Point ptNow) override; void StartDrag() override; static int MouseModifiers(uptr_t wParam) noexcept; @@ -650,6 +683,17 @@ HWND ScintillaWin::MainHWND() const noexcept { return HwndFromWindow(wMain); } +void ScintillaWin::DisplayCursor(Window::Cursor c) { + if (cursorMode != SC_CURSORNORMAL) { + c = static_cast<Window::Cursor>(cursorMode); + } + if (c == Window::cursorReverseArrow) { + ::SetCursor(reverseArrowCursor.Load(dpi)); + } else { + wMain.SetCursor(c); + } +} + bool ScintillaWin::DragThreshold(Point ptStart, Point ptNow) { const Point ptDifference = ptStart - ptNow; const XYPOSITION xMove = std::trunc(std::abs(ptDifference.x)); |
