From: John Tsiombikas Date: Tue, 7 Jan 2020 13:22:25 +0000 (+0200) Subject: correct window background color, and checkbox horizontal size X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=instimg;a=commitdiff_plain;h=d9e1c38ba7dc1bb25604586a197b794983e28d78 correct window background color, and checkbox horizontal size calculation --- diff --git a/src/widgets.c b/src/widgets.c index 8ed6d89..2c08856 100644 --- a/src/widgets.c +++ b/src/widgets.c @@ -59,7 +59,7 @@ struct wgt_window *wgt_window(const char *title, int width, int height) memset(&wc, 0, sizeof wc); wc.hInstance = hinst; - wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH); + wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE); wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hIcon = LoadIcon(0, IDI_APPLICATION); wc.lpszClassName = win->cname; @@ -232,6 +232,7 @@ struct wgt_widget *wgt_checkbox(struct wgt_window *win, const char *text, int on { struct wgt_widget *w; struct wgt_rect textsz; + int check_width; if(!(w = calloc(1, sizeof *w))) { fprintf(stderr, "wgt_checkbox: failed to allocate widget structure\n"); @@ -239,9 +240,11 @@ struct wgt_widget *wgt_checkbox(struct wgt_window *win, const char *text, int on } w->win = win; + check_width = GetSystemMetrics(SM_CXMENUCHECK); + if(width < 0 || height < 0) { wgt_string_size(win, text, &textsz); - if(width < 0) width = textsz.width + 32; /* XXX */ + if(width < 0) width = textsz.width + check_width + 10; if(height < 0) height = textsz.height; } @@ -257,7 +260,7 @@ struct wgt_widget *wgt_checkbox(struct wgt_window *win, const char *text, int on w->rect.width = width; w->rect.height = height; - w->cb_modify = modfunc; + w->cb_click = modfunc; /* BN_CLICKED is sent for checkbox state changes */ w->next = win->wlist; win->wlist = w; return w; @@ -383,7 +386,7 @@ static LRESULT WINAPI event_handler(HWND wnd, unsigned int msg, WPARAM wparam, L default: break; } - + default: return DefWindowProc(wnd, msg, wparam, lparam); }