summaryrefslogtreecommitdiff
path: root/wintable/new/scroll.h
diff options
context:
space:
mode:
Diffstat (limited to 'wintable/new/scroll.h')
-rw-r--r--wintable/new/scroll.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/wintable/new/scroll.h b/wintable/new/scroll.h
index 81b49c5..1f333a8 100644
--- a/wintable/new/scroll.h
+++ b/wintable/new/scroll.h
@@ -6,6 +6,7 @@ struct scrollParams {
intptr_t length;
intptr_t scale;
void (*post)(struct table *);
+ int *wheelCarry;
};
static void scrollto(struct table *t, int which, struct scrollParams *p, intptr_t pos)
@@ -104,3 +105,26 @@ static void scroll(struct table *t, int which, struct scrollParams *p, WPARAM wP
}
scrollto(t, which, p, pos);
}
+
+static void wheelscroll(struct table *t, int which, struct scrollParams *p, WPARAM wParam, LPARAM lParam)
+{
+ int delta;
+ int lines;
+ UINT scrollAmount;
+
+ delta = GET_WHEEL_DELTA_WPARAM(wParam);
+ // TODO make a note of what the appropriate hscroll constant is
+ if (SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, &scrollAmount, 0) == 0)
+ // TODO use scrollAmount == 3 instead?
+ panic("error getting wheel scroll amount in wheelscroll()");
+ if (scrollAmount == WHEEL_PAGESCROLL)
+ scrollAmount = p->pagesize;
+ if (scrollAmount == 0) // no mouse wheel scrolling (or t->pagesize == 0)
+ return;
+ // the rest of this is basically http://blogs.msdn.com/b/oldnewthing/archive/2003/08/07/54615.aspx and http://blogs.msdn.com/b/oldnewthing/archive/2003/08/11/54624.aspx
+ // see those pages for information on subtleties
+ delta += *(p->wheelCarry);
+ lines = delta * ((int) scrollAmount) / WHEEL_DELTA;
+ *(p->wheelCarry) = delta - lines * WHEEL_DELTA / ((int) scrollAmount);
+ scrollby(t, which, p, -lines);
+}