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));