Added click to select items. Also finished the implementation of WM_SETFONT.
This commit is contained in:
parent
42ca7ced99
commit
4e0dc24dc6
|
@ -60,6 +60,32 @@ static LONG rowHeight(struct table *t)
|
||||||
return tm.tmHeight;
|
return tm.tmHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void redrawAll(struct table *t)
|
||||||
|
{
|
||||||
|
if (InvalidateRect(t->hwnd, NULL, TRUE) == 0)
|
||||||
|
abort();
|
||||||
|
if (UpdateWindow(t->hwnd) == 0)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void selectItem(struct table *t, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
LONG h;
|
||||||
|
|
||||||
|
x = GET_X_LPARAM(lParam);
|
||||||
|
y = GET_Y_LPARAM(lParam);
|
||||||
|
h = rowHeight(t);
|
||||||
|
y += t->firstVisible * h;
|
||||||
|
y /= h;
|
||||||
|
t->selected = y;
|
||||||
|
if (t->selected >= t->count)
|
||||||
|
t->selected = -1;
|
||||||
|
// TODO update only the old and new selected items
|
||||||
|
redrawAll(t);
|
||||||
|
// TODO scroll to the selected item if it's not entirely visible
|
||||||
|
}
|
||||||
|
|
||||||
static void vscrollto(struct table *t, intptr_t newpos)
|
static void vscrollto(struct table *t, intptr_t newpos)
|
||||||
{
|
{
|
||||||
SCROLLINFO si;
|
SCROLLINFO si;
|
||||||
|
@ -271,8 +297,11 @@ t->selected = 5;t->count=100;//TODO
|
||||||
t->font = (HFONT) wParam;
|
t->font = (HFONT) wParam;
|
||||||
if (t->font == NULL)
|
if (t->font == NULL)
|
||||||
t->font = t->defaultFont;
|
t->font = t->defaultFont;
|
||||||
if (LOWORD(lParam) != FALSE)
|
if (LOWORD(lParam) != FALSE) {
|
||||||
; // TODO
|
// the scrollbar page size will change so redraw that too
|
||||||
|
resize(t);
|
||||||
|
redrawAll(t);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case WM_GETFONT:
|
case WM_GETFONT:
|
||||||
return (LRESULT) t->font;
|
return (LRESULT) t->font;
|
||||||
|
@ -285,6 +314,9 @@ t->selected = 5;t->count=100;//TODO
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
resize(t);
|
resize(t);
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_LBUTTONDOWN:
|
||||||
|
selectItem(t, wParam, lParam);
|
||||||
|
return 0;
|
||||||
default:
|
default:
|
||||||
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue