summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wintable/new/main.c2
-rw-r--r--wintable/new/resize.h18
-rw-r--r--wintable/new/vscroll.h51
3 files changed, 71 insertions, 0 deletions
diff --git a/wintable/new/main.c b/wintable/new/main.c
index 509fff0..330d721 100644
--- a/wintable/new/main.c
+++ b/wintable/new/main.c
@@ -68,6 +68,7 @@ struct table {
#include "events.h"
#include "scroll.h"
#include "hscroll.h"
+#include "vscroll.h"
#include "header.h"
#include "children.h"
#include "resize.h"
@@ -81,6 +82,7 @@ static const handlerfunc handlers[] = {
drawHandlers,
apiHandlers,
hscrollHandler,
+ vscrollHandler,
NULL,
};
diff --git a/wintable/new/resize.h b/wintable/new/resize.h
index 365146c..00087de 100644
--- a/wintable/new/resize.h
+++ b/wintable/new/resize.h
@@ -7,15 +7,33 @@
HANDLER(resizeHandler)
{
WINDOWPOS *wp;
+ RECT client;
+ intptr_t height;
if (uMsg != WM_WINDOWPOSCHANGED)
return FALSE;
wp = (WINDOWPOS *) lParam;
if ((wp->flags & SWP_NOSIZE) != 0)
return FALSE;
+
+ // TODO does wp store the window rect or the client rect?
+ if (GetClientRect(t->hwnd, &client) == 0)
+ panic("error getting Table client rect in resizeHandler()");
+ // TODO do this before calling updateTableWidth() (which calls repositionHeader()?)?
+ client.top -= t->headerHeight;
+
+ // update the width...
// this will call repositionHeader(); there's a good reason... (see comments)
// TODO when I clean that mess up, remove this comment
updateTableWidth(t);
+
+ // ...and the height
+ // TODO find out if order matters
+ height = client.bottom - client.top;
+ t->vpagesize = height / rowht(t);
+ // do a dummy scroll to reflect those changes
+ vscrollby(t, 0);
+
*lResult = 0;
return TRUE;
}
diff --git a/wintable/new/vscroll.h b/wintable/new/vscroll.h
new file mode 100644
index 0000000..bcab488
--- /dev/null
+++ b/wintable/new/vscroll.h
@@ -0,0 +1,51 @@
+// 9 december 2014
+
+// forward declaration needed here
+static void repositionHeader(struct table *);
+
+static struct scrollParams vscrollParams(struct table *t)
+{
+ struct scrollParams p;
+
+ ZeroMemory(&p, sizeof (struct scrollParams));
+ p.pos = &(t->vscrollpos);
+ p.pagesize = t->vpagesize;
+ p.length = t->count;
+ p.scale = rowht(t);
+ p.post = NULL;
+ return p;
+}
+
+static void vscrollto(struct table *t, intptr_t pos)
+{
+ struct scrollParams p;
+
+ p = vscrollParams(t);
+ scrollto(t, SB_VERT, &p, pos);
+}
+
+static void vscrollby(struct table *t, intptr_t delta)
+{
+ struct scrollParams p;
+
+ p = vscrollParams(t);
+ scrollby(t, SB_VERT, &p, delta);
+}
+
+static void vscroll(struct table *t, WPARAM wParam, LPARAM lParam)
+{
+ struct scrollParams p;
+
+ p = vscrollParams(t);
+ scroll(t, SB_VERT, &p, wParam, lParam);
+}
+
+// TODO WM_MOUSEWHEEL
+HANDLER(vscrollHandler)
+{
+ if (uMsg != WM_VSCROLL)
+ return FALSE;
+ vscroll(t, wParam, lParam);
+ *lResult = 0;
+ return TRUE;
+}