summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-12-09 20:47:03 -0500
committerPietro Gagliardi <[email protected]>2014-12-09 20:47:03 -0500
commitcb199cca7795565efd5b434e8507a59db589fce1 (patch)
tree5825028a9fd02577b805dc86c481b7f36a5a47de
parentdd37255fa1362073efa9bf91287456cba9ad4cf5 (diff)
Started readding hscroll code; just recomputeHScroll() for now.
-rw-r--r--wintable/new/api.h1
-rw-r--r--wintable/new/header.h2
-rw-r--r--wintable/new/hscroll.h44
-rw-r--r--wintable/new/main.c1
-rw-r--r--wintable/new/resize.h1
5 files changed, 49 insertions, 0 deletions
diff --git a/wintable/new/api.h b/wintable/new/api.h
index 6ebf800..d3ec3f7 100644
--- a/wintable/new/api.h
+++ b/wintable/new/api.h
@@ -9,6 +9,7 @@ static void addColumn(struct table *t, WPARAM wParam, LPARAM lParam)
if (t->columnTypes[t->nColumns - 1] >= nTableColumnTypes)
panic("invalid column type passed to tableAddColumn");
headerAddColumn(t, (WCHAR *) lParam);
+ recomputeHScroll(t);
}
HANDLER(apiHandlers)
diff --git a/wintable/new/header.h b/wintable/new/header.h
index 9d92ef7..0f23a9a 100644
--- a/wintable/new/header.h
+++ b/wintable/new/header.h
@@ -61,6 +61,8 @@ HANDLER(headerNotifyHandler)
return FALSE;
if (nmhdr->code != HDN_ITEMCHANGED)
return FALSE;
+ // TODO should this be last?
+ recomputeHScroll(t);
// TODO make more intelligent
InvalidateRect(t->hwnd, NULL, TRUE);
// TODO UpdateWindow()?
diff --git a/wintable/new/hscroll.h b/wintable/new/hscroll.h
new file mode 100644
index 0000000..061cd7b
--- /dev/null
+++ b/wintable/new/hscroll.h
@@ -0,0 +1,44 @@
+// 9 december 2014
+
+static void hscrollto(struct table *t, intptr_t pos)
+{
+ // TODO
+}
+
+static void hscrollby(struct table *t, intptr_t delta)
+{
+ // TODO
+}
+
+static void hscroll(struct table *t, WPARAM wParam, LPARAM lParam)
+{
+ // TODO
+}
+
+static void recomputeHScroll(struct table *t)
+{
+ SCROLLINFO si;
+ HDITEMW item;
+ intptr_t i, width;
+ RECT r;
+
+ width = 0;
+ // TODO count dividers?
+ for (i = 0; i < t->nColumns; i++) {
+ ZeroMemory(&item, sizeof (HDITEMW));
+ item.mask = HDI_WIDTH;
+ if (SendMessageW(t->header, HDM_GETITEM, (WPARAM) i, (LPARAM) (&item)) == FALSE)
+ panic("error getting Table column width for recomputeHScroll()");
+ width += item.cxy;
+ }
+ if (GetClientRect(t->hwnd, &r) == 0)
+ panic("error getting Table client rect for recomputeHScroll()");
+ ZeroMemory(&si, sizeof (SCROLLINFO));
+ si.cbSize = sizeof (SCROLLINFO);
+ si.fMask = SIF_PAGE | SIF_RANGE;
+ si.nPage = r.right - r.left;
+ si.nMin = 0;
+ si.nMax = width - 1; // endpoint inclusive
+ SetScrollInfo(t->hwnd, SB_HORZ, &si, TRUE);
+ // TODO what happens if the above call renders the current scroll position moot?
+}
diff --git a/wintable/new/main.c b/wintable/new/main.c
index 8e15f0f..2a0ccba 100644
--- a/wintable/new/main.c
+++ b/wintable/new/main.c
@@ -57,6 +57,7 @@ struct table {
#include "util.h"
#include "coord.h"
#include "events.h"
+#include "hscroll.h"
#include "header.h"
#include "children.h"
#include "resize.h"
diff --git a/wintable/new/resize.h b/wintable/new/resize.h
index a71fb00..bea7158 100644
--- a/wintable/new/resize.h
+++ b/wintable/new/resize.h
@@ -14,6 +14,7 @@ HANDLER(resizeHandler)
if ((wp->flags & SWP_NOSIZE) != 0)
return FALSE;
repositionHeader(t);
+ recomputeHScroll(t);
*lResult = 0;
return TRUE;
}