aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32
diff options
context:
space:
mode:
authorMarkus Nißl <unknown>2022-09-21 14:57:21 +1000
committerMarkus Nißl <unknown>2022-09-21 14:57:21 +1000
commit9a2d8d26c2b7c67bded00126f35c631c864ce9d6 (patch)
treec8ef1bbcfc2ebb91b2e2f766882f2e02054293f1 /win32
parent76bb58830b43d2a785508c42d2197c12f807afb6 (diff)
downloadscintilla-mirror-9a2d8d26c2b7c67bded00126f35c631c864ce9d6.tar.gz
Feature [feature-requests:#1450] Implement horizontal scrolling mouse wheel
through WM_MOUSEHWHEEL.
Diffstat (limited to 'win32')
-rw-r--r--win32/ScintillaWin.cxx57
1 files changed, 33 insertions, 24 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 24f70dce9..9f1cbe53f 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -1533,6 +1533,7 @@ sptr_t ScintillaWin::MouseMessage(unsigned int iMessage, uptr_t wParam, sptr_t l
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_MOUSEWHEEL:
+ case WM_MOUSEHWHEEL:
if (!mouseWheelCaptures) {
// if the mouse wheel is not captured, test if the mouse
// pointer is over the editor window and if not, don't
@@ -1557,33 +1558,40 @@ sptr_t ScintillaWin::MouseMessage(unsigned int iMessage, uptr_t wParam, sptr_t l
if (wParam & MK_SHIFT) {
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
}
- // Either SCROLL or ZOOM. We handle the wheel steppings calculation
- wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam);
- if (std::abs(wheelDelta) >= WHEEL_DELTA && linesPerScroll > 0) {
- Sci::Line linesToScroll = linesPerScroll;
- if (linesPerScroll == WHEEL_PAGESCROLL)
- linesToScroll = LinesOnScreen() - 1;
- if (linesToScroll == 0) {
- linesToScroll = 1;
- }
- linesToScroll *= (wheelDelta / WHEEL_DELTA);
- if (wheelDelta >= 0)
- wheelDelta = wheelDelta % WHEEL_DELTA;
- else
- wheelDelta = -(-wheelDelta % WHEEL_DELTA);
-
- if (wParam & MK_CONTROL) {
- // Zoom! We play with the font sizes in the styles.
- // Number of steps/line is ignored, we just care if sizing up or down
- if (linesToScroll < 0) {
- KeyCommand(Message::ZoomIn);
+ if (iMessage == WM_MOUSEWHEEL) {
+ // Either SCROLL vertically or ZOOM. We handle the wheel steppings calculation
+ wheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam);
+ if (std::abs(wheelDelta) >= WHEEL_DELTA && linesPerScroll > 0) {
+ Sci::Line linesToScroll = linesPerScroll;
+ if (linesPerScroll == WHEEL_PAGESCROLL)
+ linesToScroll = LinesOnScreen() - 1;
+ if (linesToScroll == 0) {
+ linesToScroll = 1;
+ }
+ linesToScroll *= (wheelDelta / WHEEL_DELTA);
+ if (wheelDelta >= 0)
+ wheelDelta = wheelDelta % WHEEL_DELTA;
+ else
+ wheelDelta = -(-wheelDelta % WHEEL_DELTA);
+
+ if (wParam & MK_CONTROL) {
+ // Zoom! We play with the font sizes in the styles.
+ // Number of steps/line is ignored, we just care if sizing up or down
+ if (linesToScroll < 0) {
+ KeyCommand(Message::ZoomIn);
+ } else {
+ KeyCommand(Message::ZoomOut);
+ }
} else {
- KeyCommand(Message::ZoomOut);
+ // Scroll
+ ScrollTo(topLine + linesToScroll);
}
- } else {
- // Scroll
- ScrollTo(topLine + linesToScroll);
}
+ } else { // WM_MOUSEHWHEEL (horizontal scrolling)
+ SCROLLINFO sci { sizeof(sci), SIF_POS | SIF_RANGE, 0, 0, 0, 0, 0 };
+ GetScrollInfo(SB_HORZ, &sci);
+ sci.nPos -= GET_WHEEL_DELTA_WPARAM(wParam);
+ HorizontalScrollTo(std::clamp(sci.nPos, sci.nMin, sci.nMax));
}
return 0;
}
@@ -1987,6 +1995,7 @@ sptr_t ScintillaWin::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
case WM_MOUSEMOVE:
case WM_MOUSELEAVE:
case WM_MOUSEWHEEL:
+ case WM_MOUSEHWHEEL:
return MouseMessage(msg, wParam, lParam);
case WM_SETCURSOR: