fixed checkbox..

master
steffen 13 years ago
parent a1fb6bc179
commit 1cab6b20ac

@ -1,4 +1,4 @@
/* $Id: gui.c,v 1.21 2013/03/11 23:08:39 steffen Exp $ */
/* $Id: gui.c,v 1.22 2013/03/29 00:14:55 steffen Exp $ */
/***************************************************************************
* gui.c
*
@ -29,7 +29,6 @@
GUIWindow *currentwin = NULL;
#define GUI_ITEM_IS_INSIDE(__item__,__pos__) gui_is_inside(__item__->x, __item__->y, __item__->w, __item__->h, __pos__)
int gui_is_inside (int x, int y, int w, int h, iPoint pos) {
if (x <= pos.x && x+w >= pos.x && y <= pos.y && y+h >= pos.y) return 1;
else return 0;

@ -167,6 +167,9 @@ extern int gui_event (GUIEvent event);
extern void gui_event_addmousepos (GUIEvent *event, iPoint pos, int neg);
extern void gui_set_focus (GUIItem *item);
#define GUI_ITEM_IS_INSIDE(__item__,__pos__) gui_is_inside(__item__->x, __item__->y, __item__->w, __item__->h, __pos__)
extern int gui_is_inside (int x, int y, int w, int h, iPoint pos);
extern void gui_window_new (GUIWindow *win, int w, int h, char *title);
extern void gui_window_close (GUIWindow *win);
extern void gui_window_item_add (GUIWindow *win, GUIItem *item);

@ -1,4 +1,4 @@
/* $Id: gui_checkbox.c,v 1.1 2013/03/10 23:32:28 steffen Exp $ */
/* $Id: gui_checkbox.c,v 1.2 2013/03/29 00:14:55 steffen Exp $ */
/***************************************************************************
* gui_checkbox.c
*
@ -58,8 +58,8 @@ GUIItem *gui_checkbox_new (char *text, int initialvalue, int x, int y) {
else strncpy (checkbox->text, text, GUI_TEXTLEN);
item->x = x;
item->y = y;
item->w = x + 15;
item->y = y + 15;
item->w = 15;
item->h = 15;
checkbox->checked = initialvalue;
checkbox->callback_changed = NULL;
@ -78,6 +78,7 @@ int gui_checkbox_event (GUIItem *item, GUIEvent *event) {
errorexit (-1);
}
d_printf ("checkbox:%s %d,%d,%d,%d %d,%d", checkbox->text, item->x, item->y, item->w, item->h, event->mousepos.x, event->mousepos.y);
if (event->event == EGUI_MOUSEPRESSED) {
checkbox->checked = !checkbox->checked;
if (checkbox->callback_changed != NULL) {

Loading…
Cancel
Save