From cb2642765a4058c4cfabf844bda50dbf60d1264e Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 18 Nov 2014 13:52:54 -0500 Subject: [PATCH] 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. --- wintable/imagelist_windows.c | 6 +++--- wintable/main.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/wintable/imagelist_windows.c b/wintable/imagelist_windows.c index 2527d16..e194f49 100644 --- a/wintable/imagelist_windows.c +++ b/wintable/imagelist_windows.c @@ -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) diff --git a/wintable/main.c b/wintable/main.c index 5f45610..1de3a3f 100644 --- a/wintable/main.c +++ b/wintable/main.c @@ -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;