summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-12-22 21:16:42 -0500
committerPietro Gagliardi <[email protected]>2014-12-22 21:16:42 -0500
commitd28b05c5b77debafd8dc410be0eebf28d50aba6b (patch)
treedda91eb39c1c50c5ccaf82348d98606ec8dceb81
parent7ba7222976b1260065d633855830ffd20e153bf0 (diff)
Fixed up the rest of the checkbox event handlers. Now to convert to using the drawing functions.
-rw-r--r--wintable/new/checkboxes.h22
-rw-r--r--wintable/new/draw.h2
2 files changed, 17 insertions, 7 deletions
diff --git a/wintable/new/checkboxes.h b/wintable/new/checkboxes.h
index 4308817..b7e8f0f 100644
--- a/wintable/new/checkboxes.h
+++ b/wintable/new/checkboxes.h
@@ -1,10 +1,10 @@
// 16 august 2014
enum {
- checkboxStateChecked = 1 << 0,
- checkboxStateHot = 1 << 1,
- checkboxStatePushed = 1 << 2,
- checkboxnStates = 1 << 3,
+ checkboxStateChecked = 1 << 0,
+ checkboxStateHot = 1 << 1,
+ checkboxStatePushed = 1 << 2,
+ checkboxnStates = 1 << 3,
};
// TODO actually make this
@@ -220,7 +220,7 @@ HANDLER(checkboxMouseUpHandler)
rc = lParamToRowColumn(t, lParam);
if (rc.row == -1 || rc.column == -1)
goto wrongUp;
- if (rc.row != t->checkboxMouseDownRow && rc.column != t->checkboxMouseDownColumn)
+ if (rc.row != t->checkboxMouseDownRow || rc.column != t->checkboxMouseDownColumn)
goto wrongUp;
if (t->columnTypes[rc.column] != tableColumnCheckbox)
goto wrongUp;
@@ -240,7 +240,17 @@ lastCheckbox = rc;
*lResult = 0;
return TRUE;
wrongUp:
- // TODO redraw the invalid cell
+ if (t->checkboxMouseDown) {
+ rc.row = t->checkboxMouseDownRow;
+ rc.column = t->checkboxMouseDownColumn;
+ if (rowColumnToClientRect(t, rc, &r))
+ // TODO only the checkbox rect?
+ if (InvalidateRect(t->hwnd, &r, TRUE) == 0)
+ panic("error redrawing Table checkbox rect for aborted mouse up event");
+ }
+ // if we landed on another checkbox, be sure to draw that one too
+ if (t->checkboxMouseOverLast)
+ redrawCheckboxRect(t, t->checkboxMouseOverLastPoint);
t->checkboxMouseDown = FALSE;
return FALSE; // TODO really?
}
diff --git a/wintable/new/draw.h b/wintable/new/draw.h
index e7ca331..314e2e3 100644
--- a/wintable/new/draw.h
+++ b/wintable/new/draw.h
@@ -58,7 +58,7 @@ static void drawCell(struct table *t, HDC dc, struct drawCellParams *p)
toCheckboxRect(t, &r, p->xoff);
SetDCBrushColor(dc, RGB(255, 0, 0));
if (p->row == lastCheckbox.row && p->column == lastCheckbox.column)
- SetDCBrushColor(dc, RGB(128, 0, 128));
+ SetDCBrushColor(dc, RGB(216, 0, 216));
if (t->checkboxMouseDown) {
if (p->row == t->checkboxMouseDownRow && p->column == t->checkboxMouseDownColumn)
SetDCBrushColor(dc, RGB(0, 0, 255));