More checkbox mouse code. This implements tracking.
This commit is contained in:
parent
20b6a3cf2a
commit
d75795f968
|
@ -85,7 +85,7 @@ struct table {
|
||||||
int checkboxWidth;
|
int checkboxWidth;
|
||||||
int checkboxHeight;
|
int checkboxHeight;
|
||||||
BOOL lastmouse;
|
BOOL lastmouse;
|
||||||
int lastmouseX;
|
int lastmouseX; // unadjusted coordinates
|
||||||
int lastmouseY;
|
int lastmouseY;
|
||||||
BOOL mouseDown; // TRUE if over a checkbox; the next two decide which ones
|
BOOL mouseDown; // TRUE if over a checkbox; the next two decide which ones
|
||||||
intptr_t mouseDownRow;
|
intptr_t mouseDownRow;
|
||||||
|
@ -205,6 +205,18 @@ static intptr_t hitTestColumn(struct table *t, int x)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void retrack(struct table *t)
|
||||||
|
{
|
||||||
|
TRACKMOUSEEVENT tm;
|
||||||
|
|
||||||
|
ZeroMemory(&tm, sizeof (TRACKMOUSEEVENT));
|
||||||
|
tm.cbSize = sizeof (TRACKMOUSEEVENT);
|
||||||
|
tm.dwFlags = TME_LEAVE; // TODO also TME_NONCLIENT?
|
||||||
|
tm.hwndTrack = t->hwnd;
|
||||||
|
if (_TrackMouseEvent(&tm) == 0)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
static void addColumn(struct table *t, WPARAM wParam, LPARAM lParam)
|
static void addColumn(struct table *t, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
HDITEMW item;
|
HDITEMW item;
|
||||||
|
@ -648,8 +660,8 @@ static void drawItem(struct table *t, HDC dc, intptr_t i, LONG y, LONG height, R
|
||||||
if (i == t->mouseDownRow && j == t->mouseDownColumn)
|
if (i == t->mouseDownRow && j == t->mouseDownColumn)
|
||||||
c = RGB(0, 0, 255);
|
c = RGB(0, 0, 255);
|
||||||
} else if (t->lastmouse) {
|
} else if (t->lastmouse) {
|
||||||
pt.x = t->lastmouseX;
|
pt.x = t->lastmouseX - t->hpos; // because t->lastmouseX is in client coordinates
|
||||||
pt.y = t->lastmouseY;
|
pt.y = t->lastmouseY; // ...but so are the vertical coordinates of rsel
|
||||||
if (PtInRect(&rsel, pt) != 0)
|
if (PtInRect(&rsel, pt) != 0)
|
||||||
c = RGB(0, 255, 0);
|
c = RGB(0, 255, 0);
|
||||||
}
|
}
|
||||||
|
@ -766,6 +778,7 @@ if (ImageList_GetIconSize(t->imagelist, &unused, &(t->imagelistHeight)) == 0)abo
|
||||||
}
|
}
|
||||||
t->checkboxes = makeCheckboxImageList(t->hwnd, &(t->theme), &(t->checkboxWidth), &(t->checkboxHeight));
|
t->checkboxes = makeCheckboxImageList(t->hwnd, &(t->theme), &(t->checkboxWidth), &(t->checkboxHeight));
|
||||||
t->focusedColumn = -1;
|
t->focusedColumn = -1;
|
||||||
|
retrack(t);
|
||||||
SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) t);
|
SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) t);
|
||||||
}
|
}
|
||||||
// even if we did the above, fall through
|
// even if we did the above, fall through
|
||||||
|
@ -818,6 +831,22 @@ if (ImageList_GetIconSize(t->imagelist, &unused, &(t->imagelistHeight)) == 0)abo
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
// TODO other mouse buttons?
|
// TODO other mouse buttons?
|
||||||
|
case WM_MOUSEMOVE:
|
||||||
|
t->lastmouse = TRUE;
|
||||||
|
t->lastmouseX = GET_X_LPARAM(lParam);
|
||||||
|
t->lastmouseY = GET_Y_LPARAM(lParam);
|
||||||
|
// TODO redraw row being hovered over
|
||||||
|
return 0;
|
||||||
|
case WM_MOUSELEAVE:
|
||||||
|
t->lastmouse = FALSE;
|
||||||
|
retrack(t);
|
||||||
|
// TODO redraw row mouse is currently over
|
||||||
|
// TODO split into its own function
|
||||||
|
if (t->mouseDown) {
|
||||||
|
t->mouseDown = FALSE;
|
||||||
|
redrawRow(t, t->mouseDownRow);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
case WM_SETFOCUS:
|
case WM_SETFOCUS:
|
||||||
case WM_KILLFOCUS:
|
case WM_KILLFOCUS:
|
||||||
// all we need to do here is redraw the highlight
|
// all we need to do here is redraw the highlight
|
||||||
|
|
Loading…
Reference in New Issue