Added cell focusing to the new Windows Table. Checkbox columns need keyboard accessibility too. For now, focus is only applied with a mouse click.
This commit is contained in:
parent
7409ce424e
commit
8f0f1ad3b5
|
@ -76,6 +76,7 @@ struct table {
|
||||||
HIMAGELIST checkboxes;
|
HIMAGELIST checkboxes;
|
||||||
HTHEME theme;
|
HTHEME theme;
|
||||||
int *columnTypes;
|
int *columnTypes;
|
||||||
|
intptr_t focusedColumn;
|
||||||
};
|
};
|
||||||
|
|
||||||
static LONG rowHeight(struct table *t)
|
static LONG rowHeight(struct table *t)
|
||||||
|
@ -141,6 +142,25 @@ static void repositionHeader(struct table *t)
|
||||||
t->headerHeight = headerpos.cy;
|
t->headerHeight = headerpos.cy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static intptr_t hitTestColumn(struct table *t, int x)
|
||||||
|
{
|
||||||
|
HDITEMW item;
|
||||||
|
intptr_t i;
|
||||||
|
|
||||||
|
// TODO count dividers
|
||||||
|
for (i = 0; i < t->nColumns; i++) {
|
||||||
|
ZeroMemory(&item, sizeof (HDITEMW));
|
||||||
|
item.mask = HDI_WIDTH;
|
||||||
|
if (SendMessageW(t->header, HDM_GETITEM, (WPARAM) i, (LPARAM) (&item)) == FALSE)
|
||||||
|
abort();
|
||||||
|
if (x < item.cxy)
|
||||||
|
return i;
|
||||||
|
x -= item.cxy; // not yet
|
||||||
|
}
|
||||||
|
// no column
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static void addColumn(struct table *t, WPARAM wParam, LPARAM lParam)
|
static void addColumn(struct table *t, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
HDITEMW item;
|
HDITEMW item;
|
||||||
|
@ -334,6 +354,7 @@ static void selectItem(struct table *t, WPARAM wParam, LPARAM lParam)
|
||||||
t->selected = y;
|
t->selected = y;
|
||||||
if (t->selected >= t->count)
|
if (t->selected >= t->count)
|
||||||
t->selected = -1;
|
t->selected = -1;
|
||||||
|
t->focusedColumn = hitTestColumn(t, x);
|
||||||
finishSelect(t);
|
finishSelect(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,6 +555,14 @@ static void drawItem(struct table *t, HDC dc, intptr_t i, LONG y, LONG height, R
|
||||||
case tableColumnCheckbox:
|
case tableColumnCheckbox:
|
||||||
;// TODO
|
;// TODO
|
||||||
}
|
}
|
||||||
|
if (t->selected == i && t->focusedColumn == j) {
|
||||||
|
rsel.left = headeritem.left;
|
||||||
|
rsel.top = y;
|
||||||
|
rsel.right = headeritem.right;
|
||||||
|
rsel.bottom = y + height;
|
||||||
|
if (DrawFocusRect(dc, &rsel) == 0)
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -633,6 +662,7 @@ if (ImageList_GetIconSize(t->imagelist, &unused, &(t->imagelistHeight)) == 0)abo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t->checkboxes = makeCheckboxImageList(t->hwnd, &(t->theme));
|
t->checkboxes = makeCheckboxImageList(t->hwnd, &(t->theme));
|
||||||
|
t->focusedColumn = -1;
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue