diff options
| author | Pietro Gagliardi <[email protected]> | 2014-12-21 18:45:37 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-12-21 18:45:37 -0500 |
| commit | 2cf116883096bf809db292db26eef889ad39d4db (patch) | |
| tree | 45b216f69ac3ff0df30481e3a744f7f00836a047 | |
| parent | 9e66dc006edec187b7be9e62b3e2d15abfe86de4 (diff) | |
Started writing the code for handling mouse moves and checkbox hovers.
| -rw-r--r-- | wintable/new/checkboxes.h | 31 | ||||
| -rw-r--r-- | wintable/new/draw.h | 7 | ||||
| -rw-r--r-- | wintable/new/events.h | 4 | ||||
| -rw-r--r-- | wintable/new/main.c | 2 |
4 files changed, 44 insertions, 0 deletions
diff --git a/wintable/new/checkboxes.h b/wintable/new/checkboxes.h index 1320fa1..6d8a86d 100644 --- a/wintable/new/checkboxes.h +++ b/wintable/new/checkboxes.h @@ -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; +} diff --git a/wintable/new/draw.h b/wintable/new/draw.h index 47e6914..42e6e4f 100644 --- a/wintable/new/draw.h +++ b/wintable/new/draw.h @@ -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; } diff --git a/wintable/new/events.h b/wintable/new/events.h index edef132..a814638 100644 --- a/wintable/new/events.h +++ b/wintable/new/events.h @@ -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, }; diff --git a/wintable/new/main.c b/wintable/new/main.c index 316c760..43e4391 100644 --- a/wintable/new/main.c +++ b/wintable/new/main.c @@ -75,6 +75,8 @@ struct table { HTHEME theme; int checkboxWidth; int checkboxHeight; + BOOL checkboxMouseOverLast; + LPARAM checkboxMouseOverLastPoint; }; #include "util.h" |
