X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=instimg;a=blobdiff_plain;f=src%2Fwidgets.c;h=2c08856c53ac3241b296138f70594404b64270a8;hp=7796cba3e957ed6debc17da3ea1acb50d92df7f6;hb=d9e1c38ba7dc1bb25604586a197b794983e28d78;hpb=4f312c9361b1f4c63d7697e58503cd0fb8b05fff diff --git a/src/widgets.c b/src/widgets.c index 7796cba..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; @@ -79,7 +79,7 @@ struct wgt_window *wgt_window(const char *title, int width, int height) win->dc = GetDC(win->handle); SetLastError(0); if(!SetWindowLong(win->handle, GWL_USERDATA, (long)win) && (err = GetLastError())) { - fprintf(stderr, "wgt_create_window: failed to store window user data (err: %d)\n", err); + fprintf(stderr, "wgt_create_window: failed to store window user data (err: %d)\n", (int)err); UnregisterClass(title, hinst); DestroyWindow(win->handle); return 0; @@ -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); } @@ -400,4 +403,4 @@ static struct wgt_widget *find_widget(struct wgt_window *win, HWND handle) w = w->next; } return 0; -} \ No newline at end of file +}