Stored the checkbox width/height in the new Windows Table. This will be needed for hit-testing checkboxes.

This commit is contained in:
Pietro Gagliardi 2014-11-14 22:41:25 -05:00
parent ee13093136
commit f11b1141fb
2 changed files with 9 additions and 8 deletions

View File

@ -148,9 +148,8 @@ static HBITMAP makeCheckboxImageListEntry(HDC dc, int width, int height, int cbS
return bitmap; return bitmap;
} }
static HIMAGELIST newCheckboxImageList(HWND hwnddc, void (*sizefunc)(HDC, int *, int *, HTHEME), void (*drawfunc)(HDC, RECT *, int, HTHEME), HTHEME theme) static HIMAGELIST newCheckboxImageList(HWND hwnddc, void (*sizefunc)(HDC, int *, int *, HTHEME), void (*drawfunc)(HDC, RECT *, int, HTHEME), HTHEME theme, int *width, int *height)
{ {
int width, height;
int cbState; int cbState;
HDC dc; HDC dc;
HIMAGELIST il; HIMAGELIST il;
@ -176,7 +175,7 @@ static HIMAGELIST newCheckboxImageList(HWND hwnddc, void (*sizefunc)(HDC, int *,
return il; return il;
} }
HIMAGELIST makeCheckboxImageList(HWND hwnddc, HTHEME *theme) HIMAGELIST makeCheckboxImageList(HWND hwnddc, HTHEME *theme, int *width, int *height)
{ {
if (*theme != NULL) { if (*theme != NULL) {
HRESULT res; HRESULT res;
@ -190,7 +189,7 @@ HIMAGELIST makeCheckboxImageList(HWND hwnddc, HTHEME *theme)
if (*theme == NULL) // try to open the theme if (*theme == NULL) // try to open the theme
*theme = OpenThemeData(hwnddc, L"button"); *theme = OpenThemeData(hwnddc, L"button");
if (*theme != NULL) // use the theme if (*theme != NULL) // use the theme
return newCheckboxImageList(hwnddc, themeSize, themeImage, *theme); return newCheckboxImageList(hwnddc, themeSize, themeImage, *theme, width, height);
// couldn't open; fall back // couldn't open; fall back
return newCheckboxImageList(hwnddc, dfcSize, dfcImage, *theme); return newCheckboxImageList(hwnddc, dfcSize, dfcImage, *theme, width, height);
} }

View File

@ -16,7 +16,7 @@
#include <uxtheme.h> #include <uxtheme.h>
#include <string.h> #include <string.h>
#include <wchar.h> #include <wchar.h>
extern HIMAGELIST makeCheckboxImageList(HWND hwnddc, HTHEME *theme); extern HIMAGELIST makeCheckboxImageList(HWND hwnddc, HTHEME *theme, int *, int *);
enum { enum {
checkboxStateChecked = 1 << 0, checkboxStateChecked = 1 << 0,
checkboxStateHot = 1 << 1, checkboxStateHot = 1 << 1,
@ -81,6 +81,8 @@ struct table {
HTHEME theme; HTHEME theme;
int *columnTypes; int *columnTypes;
intptr_t focusedColumn; intptr_t focusedColumn;
int checkboxWidth;
int checkboxHeight;
}; };
static LONG rowHeight(struct table *t) static LONG rowHeight(struct table *t)
@ -684,7 +686,7 @@ if (ImageList_AddIcon(t->imagelist, icon) == -1)abort();
if (ImageList_GetIconSize(t->imagelist, &unused, &(t->imagelistHeight)) == 0)abort(); if (ImageList_GetIconSize(t->imagelist, &unused, &(t->imagelistHeight)) == 0)abort();
} }
} }
t->checkboxes = makeCheckboxImageList(t->hwnd, &(t->theme)); t->checkboxes = makeCheckboxImageList(t->hwnd, &(t->theme), &(t->checkboxWidth), &(t->checkboxHeight));
t->focusedColumn = -1; t->focusedColumn = -1;
SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) t); SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) t);
} }
@ -758,7 +760,7 @@ if (ImageList_GetIconSize(t->imagelist, &unused, &(t->imagelistHeight)) == 0)abo
case WM_THEMECHANGED: case WM_THEMECHANGED:
if (ImageList_Destroy(t->checkboxes) == 0) if (ImageList_Destroy(t->checkboxes) == 0)
abort(); abort();
t->checkboxes = makeCheckboxImageList(t->hwnd, &(t->theme)); t->checkboxes = makeCheckboxImageList(t->hwnd, &(t->theme), &(t->checkboxWidth), &(t->checkboxHeight));
resize(t); // TODO needed? resize(t); // TODO needed?
redrawAll(t); redrawAll(t);
// now defer back to DefWindowProc() in case other things are needed // now defer back to DefWindowProc() in case other things are needed