Started the work to handle checkboxes. For now, we draw just a red rectangle; when we do events this will change color dynamically. When I hook up the control to its parent, I will move from these rectangles to the actual checkbox images. In the meantime, fix some pointer bugs in imagelist_windows.c as well.
This commit is contained in:
parent
8175bd411a
commit
cb2642765a
|
@ -157,14 +157,14 @@ static HIMAGELIST newCheckboxImageList(HWND hwnddc, void (*sizefunc)(HDC, int *,
|
||||||
dc = GetDC(hwnddc);
|
dc = GetDC(hwnddc);
|
||||||
if (dc == NULL)
|
if (dc == NULL)
|
||||||
xpanic("error getting DC for making the checkbox image list", GetLastError());
|
xpanic("error getting DC for making the checkbox image list", GetLastError());
|
||||||
(*sizefunc)(dc, &width, &height, theme);
|
(*sizefunc)(dc, width, height, theme);
|
||||||
il = ImageList_Create(width, height, ILC_COLOR32, 20, 20); // should be reasonable
|
il = ImageList_Create(*width, *height, ILC_COLOR32, 20, 20); // should be reasonable
|
||||||
if (il == NULL)
|
if (il == NULL)
|
||||||
xpanic("error creating checkbox image list", GetLastError());
|
xpanic("error creating checkbox image list", GetLastError());
|
||||||
for (cbState = 0; cbState < checkboxnStates; cbState++) {
|
for (cbState = 0; cbState < checkboxnStates; cbState++) {
|
||||||
HBITMAP bitmap;
|
HBITMAP bitmap;
|
||||||
|
|
||||||
bitmap = makeCheckboxImageListEntry(dc, width, height, cbState, drawfunc, theme);
|
bitmap = makeCheckboxImageListEntry(dc, *width, *height, cbState, drawfunc, theme);
|
||||||
if (ImageList_Add(il, bitmap, NULL) == -1)
|
if (ImageList_Add(il, bitmap, NULL) == -1)
|
||||||
xpanic("error adding checkbox image to image list", GetLastError());
|
xpanic("error adding checkbox image to image list", GetLastError());
|
||||||
if (DeleteObject(bitmap) == 0)
|
if (DeleteObject(bitmap) == 0)
|
||||||
|
|
|
@ -44,6 +44,7 @@ enum {
|
||||||
// - space to toggle (TODO); + or = to set; - to clear (see http://msdn.microsoft.com/en-us/library/windows/desktop/bb775941%28v=vs.85%29.aspx)
|
// - space to toggle (TODO); + or = to set; - to clear (see http://msdn.microsoft.com/en-us/library/windows/desktop/bb775941%28v=vs.85%29.aspx)
|
||||||
// - TODO figure out which notification is needed
|
// - TODO figure out which notification is needed
|
||||||
// - http://blogs.msdn.com/b/oldnewthing/archive/2006/01/03/508694.aspx
|
// - http://blogs.msdn.com/b/oldnewthing/archive/2006/01/03/508694.aspx
|
||||||
|
// - free all allocated resources on WM_DESTROY
|
||||||
|
|
||||||
#define tableWindowClass L"gouitable"
|
#define tableWindowClass L"gouitable"
|
||||||
|
|
||||||
|
@ -623,7 +624,16 @@ static void drawItem(struct table *t, HDC dc, intptr_t i, LONG y, LONG height, R
|
||||||
abort();
|
abort();
|
||||||
break;
|
break;
|
||||||
case tableColumnCheckbox:
|
case tableColumnCheckbox:
|
||||||
;// TODO
|
// TODO replace all this
|
||||||
|
rsel.left = headeritem.left + xoff;
|
||||||
|
rsel.top = y;
|
||||||
|
rsel.right = rsel.left + t->checkboxWidth;
|
||||||
|
rsel.bottom = rsel.top + t->checkboxHeight;
|
||||||
|
if (SetDCBrushColor(dc, RGB(255, 0, 0)) == CLR_INVALID)
|
||||||
|
abort();
|
||||||
|
if (FillRect(dc, &rsel, GetStockObject(DC_BRUSH)) == 0)
|
||||||
|
abort();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (t->selected == i && t->focusedColumn == j) {
|
if (t->selected == i && t->focusedColumn == j) {
|
||||||
rsel.left = headeritem.left;
|
rsel.left = headeritem.left;
|
||||||
|
|
Loading…
Reference in New Issue