[2/3] richedit: Zoom in and out with mouse wheel with control held. (Fixes bug 16713)
Dylan Smith
dylan.ah.smith at gmail.com
Tue Jan 13 12:39:32 CST 2009
It is possible to zoom in and out using the scroll wheel in native
richedit controls, so this was implemented in conformance to the test I
just added for this functionality.
---
dlls/riched20/editor.c | 29 +++++++++++++++++++++++------
dlls/riched20/tests/editor.c | 12 ++++++------
2 files changed, 29 insertions(+), 12 deletions(-)
-------------- next part --------------
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index d022e17..3b25295 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -4096,18 +4096,35 @@ static LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
{
int gcWheelDelta;
UINT pulScrollLines;
+ BOOL ctrl_is_down;
if ((editor->nEventMask & ENM_MOUSEEVENTS) &&
!ME_FilterEvent(editor, msg, &wParam, &lParam))
return 0;
- SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
- gcWheelDelta = -GET_WHEEL_DELTA_WPARAM(wParam);
-
- if (abs(gcWheelDelta) >= WHEEL_DELTA && pulScrollLines)
+ ctrl_is_down = GetKeyState(VK_CONTROL) & 0x8000;
+
+ gcWheelDelta = GET_WHEEL_DELTA_WPARAM(wParam);
+
+ if (abs(gcWheelDelta) >= WHEEL_DELTA)
{
- /* FIXME follow the original */
- ME_ScrollDown(editor,pulScrollLines * (gcWheelDelta / WHEEL_DELTA) * 8);
+ if (ctrl_is_down) {
+ int numerator;
+ if (!editor->nZoomNumerator || !editor->nZoomDenominator)
+ {
+ numerator = 100;
+ } else {
+ numerator = editor->nZoomNumerator * 100 / editor->nZoomDenominator;
+ }
+ numerator = numerator + (gcWheelDelta / WHEEL_DELTA) * 10;
+ if (numerator >= 10 && numerator <= 500)
+ ME_SetZoom(editor, numerator, 100);
+ } else {
+ SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
+ /* FIXME follow the original */
+ if (pulScrollLines)
+ ME_ScrollDown(editor,pulScrollLines * (-gcWheelDelta / WHEEL_DELTA) * 8);
+ }
}
break;
}
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 7f99489..4165f5e 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -6292,8 +6292,8 @@ static void test_zoom(void)
release_key(VK_CONTROL);
ret = SendMessage(hwnd, EM_GETZOOM, (WPARAM)&numerator, (LPARAM)&denominator);
- todo_wine ok(numerator == 110, "incorrect numerator is %d\n", numerator);
- todo_wine ok(denominator == 100, "incorrect denominator is %d\n", denominator);
+ ok(numerator == 110, "incorrect numerator is %d\n", numerator);
+ ok(denominator == 100, "incorrect denominator is %d\n", denominator);
ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret);
/* Test how much the mouse wheel can zoom in and out. */
@@ -6307,7 +6307,7 @@ static void test_zoom(void)
release_key(VK_CONTROL);
ret = SendMessage(hwnd, EM_GETZOOM, (WPARAM)&numerator, (LPARAM)&denominator);
- todo_wine ok(numerator == 500, "incorrect numerator is %d\n", numerator);
+ ok(numerator == 500, "incorrect numerator is %d\n", numerator);
ok(denominator == 100, "incorrect denominator is %d\n", denominator);
ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret);
@@ -6335,7 +6335,7 @@ static void test_zoom(void)
release_key(VK_CONTROL);
ret = SendMessage(hwnd, EM_GETZOOM, (WPARAM)&numerator, (LPARAM)&denominator);
- todo_wine ok(numerator == 10, "incorrect numerator is %d\n", numerator);
+ ok(numerator == 10, "incorrect numerator is %d\n", numerator);
ok(denominator == 100, "incorrect denominator is %d\n", denominator);
ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret);
@@ -6364,8 +6364,8 @@ static void test_zoom(void)
release_key(VK_CONTROL);
ret = SendMessage(hwnd, EM_GETZOOM, (WPARAM)&numerator, (LPARAM)&denominator);
- todo_wine ok(numerator == 394, "incorrect numerator is %d\n", numerator);
- todo_wine ok(denominator == 100, "incorrect denominator is %d\n", denominator);
+ ok(numerator == 394, "incorrect numerator is %d\n", numerator);
+ ok(denominator == 100, "incorrect denominator is %d\n", denominator);
ok(ret == TRUE, "EM_GETZOOM failed (%d).\n", ret);
/* Test bounds checking on EM_SETZOOM */
More information about the wine-patches
mailing list