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:
Pietro Gagliardi 2014-11-18 13:52:54 -05:00
parent 8175bd411a
commit cb2642765a
2 changed files with 14 additions and 4 deletions

View File

@ -157,14 +157,14 @@ static HIMAGELIST newCheckboxImageList(HWND hwnddc, void (*sizefunc)(HDC, int *,
dc = GetDC(hwnddc);
if (dc == NULL)
xpanic("error getting DC for making the checkbox image list", GetLastError());
(*sizefunc)(dc, &width, &height, theme);
il = ImageList_Create(width, height, ILC_COLOR32, 20, 20); // should be reasonable
(*sizefunc)(dc, width, height, theme);
il = ImageList_Create(*width, *height, ILC_COLOR32, 20, 20); // should be reasonable
if (il == NULL)
xpanic("error creating checkbox image list", GetLastError());
for (cbState = 0; cbState < checkboxnStates; cbState++) {
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)
xpanic("error adding checkbox image to image list", GetLastError());
if (DeleteObject(bitmap) == 0)

View File

@ -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)
// - TODO figure out which notification is needed
// - http://blogs.msdn.com/b/oldnewthing/archive/2006/01/03/508694.aspx
// - free all allocated resources on WM_DESTROY
#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();
break;
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) {
rsel.left = headeritem.left;