Started writing the code for handling mouse moves and checkbox hovers.
This commit is contained in:
parent
9e66dc006e
commit
2cf1168830
|
@ -132,3 +132,34 @@ static void loadCheckboxThemeData(struct table *t)
|
|||
if (ReleaseDC(t->hwnd, dc) == 0)
|
||||
panic("error releasing Table DC for loading checkbox theme data");
|
||||
}
|
||||
|
||||
HANDLER(checkboxMouseMoveHandler)
|
||||
{
|
||||
struct rowcol rc;
|
||||
RECT r;
|
||||
|
||||
if (!t->checkboxMouseOverLast) {
|
||||
t->checkboxMouseOverLast = TRUE;
|
||||
retrack(t);
|
||||
}
|
||||
// TODO redraw old cell
|
||||
// TODO we could probably optimize these by only checking the checkbox rects
|
||||
t->checkboxMouseOverLastPoint = lParam;
|
||||
rc = lParamToRowColumn(t, t->checkboxMouseOverLastPoint);
|
||||
if (rc.row != -1 && rc.column != -1)
|
||||
if (t->columnTypes[rc.column] == tableColumnCheckbox)
|
||||
if (rowColumnToClientRect(t, rc, &r))
|
||||
if (InvalidateRect(t->hwnd, &r, TRUE) == 0)
|
||||
panic("error queueing Table checkbox for redraw after mouse over");
|
||||
*lResult = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HANDLER(checkboxMouseLeaveHandler)
|
||||
{
|
||||
// TODO redraw old cell
|
||||
// TODO remember what I wanted to do here in the case of a held mouse button
|
||||
t->checkboxMouseOverLast = FALSE;
|
||||
*lResult = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ static void drawCell(struct table *t, HDC dc, struct drawCellParams *p)
|
|||
int n;
|
||||
HBRUSH background;
|
||||
int textColor;
|
||||
POINT pt;
|
||||
|
||||
// TODO verify these two
|
||||
background = (HBRUSH) (COLOR_WINDOW + 1);
|
||||
|
@ -56,6 +57,12 @@ static void drawCell(struct table *t, HDC dc, struct drawCellParams *p)
|
|||
case tableColumnCheckbox:
|
||||
toCheckboxRect(t, &r, p->xoff);
|
||||
SetDCBrushColor(dc, RGB(255, 0, 0));
|
||||
if (t->checkboxMouseOverLast) {
|
||||
pt.x = GET_X_LPARAM(t->checkboxMouseOverLastPoint);
|
||||
pt.y = GET_Y_LPARAM(t->checkboxMouseOverLastPoint);
|
||||
if (PtInRect(&r, pt) != 0)
|
||||
SetDCBrushColor(dc, RGB(0, 255, 0));
|
||||
}
|
||||
FillRect(dc, &r, GetStockObject(DC_BRUSH));
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// 5 december 2014
|
||||
|
||||
// TODO handler functions don't work here because you can't have more than one for the mouse ones...
|
||||
|
||||
static const handlerfunc keyDownHandlers[] = {
|
||||
keyDownSelectHandler,
|
||||
NULL,
|
||||
|
@ -14,10 +16,12 @@ static const handlerfunc charHandlers[] = {
|
|||
};
|
||||
|
||||
static const handlerfunc mouseMoveHandlers[] = {
|
||||
checkboxMouseMoveHandler,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const handlerfunc mouseLeaveHandlers[] = {
|
||||
checkboxMouseLeaveHandler,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
|
|
@ -75,6 +75,8 @@ struct table {
|
|||
HTHEME theme;
|
||||
int checkboxWidth;
|
||||
int checkboxHeight;
|
||||
BOOL checkboxMouseOverLast;
|
||||
LPARAM checkboxMouseOverLastPoint;
|
||||
};
|
||||
|
||||
#include "util.h"
|
||||
|
|
Loading…
Reference in New Issue