summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-12-22 00:42:24 -0500
committerPietro Gagliardi <[email protected]>2014-12-22 00:42:24 -0500
commitcc165b48ff08ac93202446f5a10bb1ce4f095857 (patch)
tree7235d1ef9169cb2bacc827f679dcfcf9bd322540
parent2cf116883096bf809db292db26eef889ad39d4db (diff)
More checkbox mouse movement code.
-rw-r--r--wintable/new/checkboxes.h35
1 files changed, 24 insertions, 11 deletions
diff --git a/wintable/new/checkboxes.h b/wintable/new/checkboxes.h
index 6d8a86d..11dea56 100644
--- a/wintable/new/checkboxes.h
+++ b/wintable/new/checkboxes.h
@@ -133,31 +133,44 @@ static void loadCheckboxThemeData(struct table *t)
panic("error releasing Table DC for loading checkbox theme data");
}
-HANDLER(checkboxMouseMoveHandler)
+static void redrawCheckboxRect(struct table *t, LPARAM lParam)
{
struct rowcol rc;
RECT r;
+ POINT pt;
+ rc = lParamToRowColumn(t, lParam);
+ if (rc.row == -1 && rc.column == -1)
+ return;
+ if (t->columnTypes[rc.column] != tableColumnCheckbox)
+ return;
+ if (!rowColumnToClientRect(t, rc, &r))
+ return;
+ // TODO only the checkbox rect?
+ if (InvalidateRect(t->hwnd, &r, TRUE) == 0)
+ panic("error redrawing Table checkbox rect for mouse events");
+}
+
+HANDLER(checkboxMouseMoveHandler)
+{
+ // don't actually check to see if the mouse is in the checkbox rect
+ // if there's scrolling without mouse movement, that will change
+ // instead, drawCell() will handle it
if (!t->checkboxMouseOverLast) {
t->checkboxMouseOverLast = TRUE;
retrack(t);
- }
- // TODO redraw old cell
- // TODO we could probably optimize these by only checking the checkbox rects
+ } else
+ redrawCheckboxRect(t, t->checkboxMouseOverLastPoint);
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");
+ redrawCheckboxRect(t, t->checkboxMouseOverLastPoint);
*lResult = 0;
return TRUE;
}
HANDLER(checkboxMouseLeaveHandler)
{
- // TODO redraw old cell
+ if (t->checkboxMouseOverLast)
+ redrawCheckboxRect(t, t->checkboxMouseOverLastPoint);
// TODO remember what I wanted to do here in the case of a held mouse button
t->checkboxMouseOverLast = FALSE;
*lResult = 0;