Began the work for actually doing checkbox events in the new Windows Table. Currently it mostly responds correctly to mouse presses and releases; it just needs to be hit-tested properly.
This commit is contained in:
parent
cb2642765a
commit
896239371e
|
@ -84,6 +84,12 @@ struct table {
|
||||||
intptr_t focusedColumn;
|
intptr_t focusedColumn;
|
||||||
int checkboxWidth;
|
int checkboxWidth;
|
||||||
int checkboxHeight;
|
int checkboxHeight;
|
||||||
|
BOOL lastmouse;
|
||||||
|
int lastmouseX;
|
||||||
|
int lastmouseY;
|
||||||
|
BOOL mouseDown; // TRUE if over a checkbox; the next two decide which ones
|
||||||
|
intptr_t mouseDownRow;
|
||||||
|
intptr_t mouseDownColumn;
|
||||||
};
|
};
|
||||||
|
|
||||||
static LONG rowHeight(struct table *t)
|
static LONG rowHeight(struct table *t)
|
||||||
|
@ -520,6 +526,10 @@ static void selectItem(struct table *t, WPARAM wParam, LPARAM lParam)
|
||||||
if (t->selected >= t->count)
|
if (t->selected >= t->count)
|
||||||
t->selected = -1;
|
t->selected = -1;
|
||||||
t->focusedColumn = hitTestColumn(t, x);
|
t->focusedColumn = hitTestColumn(t, x);
|
||||||
|
// TODO only if inside a checkbox
|
||||||
|
t->mouseDown = TRUE;
|
||||||
|
t->mouseDownRow = t->selected;
|
||||||
|
t->mouseDownColumn = t->focusedColumn;
|
||||||
finishSelect(t, prev);
|
finishSelect(t, prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,6 +567,7 @@ static void drawItem(struct table *t, HDC dc, intptr_t i, LONG y, LONG height, R
|
||||||
intptr_t j;
|
intptr_t j;
|
||||||
LRESULT xoff;
|
LRESULT xoff;
|
||||||
IMAGELISTDRAWPARAMS ip;
|
IMAGELISTDRAWPARAMS ip;
|
||||||
|
POINT pt;
|
||||||
|
|
||||||
// TODO verify these two
|
// TODO verify these two
|
||||||
background = (HBRUSH) (COLOR_WINDOW + 1);
|
background = (HBRUSH) (COLOR_WINDOW + 1);
|
||||||
|
@ -629,8 +640,21 @@ static void drawItem(struct table *t, HDC dc, intptr_t i, LONG y, LONG height, R
|
||||||
rsel.top = y;
|
rsel.top = y;
|
||||||
rsel.right = rsel.left + t->checkboxWidth;
|
rsel.right = rsel.left + t->checkboxWidth;
|
||||||
rsel.bottom = rsel.top + t->checkboxHeight;
|
rsel.bottom = rsel.top + t->checkboxHeight;
|
||||||
if (SetDCBrushColor(dc, RGB(255, 0, 0)) == CLR_INVALID)
|
{ COLORREF c;
|
||||||
|
|
||||||
|
c = RGB(255, 0, 0);
|
||||||
|
if (t->mouseDown) {
|
||||||
|
if (i == t->mouseDownRow && j == t->mouseDownColumn)
|
||||||
|
c = RGB(0, 0, 255);
|
||||||
|
} else if (t->lastmouse) {
|
||||||
|
pt.x = t->lastmouseX;
|
||||||
|
pt.y = t->lastmouseY;
|
||||||
|
if (PtInRect(&rsel, pt) != 0)
|
||||||
|
c = RGB(0, 255, 0);
|
||||||
|
}
|
||||||
|
if (SetDCBrushColor(dc, c) == CLR_INVALID)
|
||||||
abort();
|
abort();
|
||||||
|
}
|
||||||
if (FillRect(dc, &rsel, GetStockObject(DC_BRUSH)) == 0)
|
if (FillRect(dc, &rsel, GetStockObject(DC_BRUSH)) == 0)
|
||||||
abort();
|
abort();
|
||||||
break;
|
break;
|
||||||
|
@ -785,6 +809,14 @@ if (ImageList_GetIconSize(t->imagelist, &unused, &(t->imagelistHeight)) == 0)abo
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
selectItem(t, wParam, lParam);
|
selectItem(t, wParam, lParam);
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_LBUTTONUP:
|
||||||
|
// TODO toggle checkbox
|
||||||
|
if (t->mouseDown) {
|
||||||
|
t->mouseDown = FALSE;
|
||||||
|
redrawRow(t, t->mouseDownRow);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
// TODO other mouse buttons?
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
// all we need to do here is redraw the highlight
|
// all we need to do here is redraw the highlight
|
||||||
|
|
Loading…
Reference in New Issue