summaryrefslogtreecommitdiff
path: root/wintable/main.c
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-11-15 20:36:56 -0500
committerPietro Gagliardi <[email protected]>2014-11-15 20:36:56 -0500
commit93046dc868b57c1de084500fcff1b5996f283977 (patch)
treeab9f5a152d3bbced68c691c17c907215232738ea /wintable/main.c
parentf11b1141fbda7b236982b1ecfad160c80736b07b (diff)
Split the code to compute the last visible item in the new Windows Table into its own function. This is needed for keyboard vertical scrolling.
Diffstat (limited to 'wintable/main.c')
-rw-r--r--wintable/main.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/wintable/main.c b/wintable/main.c
index edea173..503a755 100644
--- a/wintable/main.c
+++ b/wintable/main.c
@@ -148,6 +148,17 @@ static void repositionHeader(struct table *t)
t->headerHeight = headerpos.cy;
}
+// cliprect and rowHeight must be specified here to avoid recomputing things multiple times
+static intptr_t lastVisible(struct table *t, RECT cliprect, LONG rowHeight)
+{
+ intptr_t last;
+
+ last = ((cliprect.bottom + rowHeight - 1) / rowHeight) + t->firstVisible;
+ if (last >= t->count)
+ last = t->count;
+ return last;
+}
+
static intptr_t hitTestColumn(struct table *t, int x)
{
HDITEMW item;
@@ -623,9 +634,7 @@ static void drawItems(struct table *t, HDC dc, RECT cliprect)
first = (cliprect.top / height) + t->firstVisible;
if (first < 0)
first = 0;
- last = ((cliprect.bottom + height - 1) / height) + t->firstVisible;
- if (last >= t->count)
- last = t->count;
+ last = lastVisible(t, cliprect, height);
// now for the first y, discount firstVisible
y = (first - t->firstVisible) * height;