Added vertical scroll. The drawing code will now need updating...
This commit is contained in:
parent
2013a3a753
commit
2da55f35a6
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue