|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* $Id: gui.c,v 1.4 2013/02/17 00:52:20 steffen Exp $ */
|
|
|
|
|
/* $Id: gui.c,v 1.5 2013/02/18 00:06:44 steffen Exp $ */
|
|
|
|
|
/***************************************************************************
|
|
|
|
|
* gui.c
|
|
|
|
|
*
|
|
|
|
|
@ -83,24 +83,31 @@ void gui_draw () {
|
|
|
|
|
draw_polygonfinish (currentwin->screen, ls, color[COLOR_white][0], 1);
|
|
|
|
|
gfx_draw_text (currentwin->screen, 4, 0, currentwin->title, &color[COLOR_white][3]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < GUI_WIN_BUTTONS; i++) if (currentwin->buttons[i].id != 0) {
|
|
|
|
|
if (currentwin->buttons[i].callback_draw != NULL)
|
|
|
|
|
currentwin->buttons[i].callback_draw (¤twin->buttons[i]);
|
|
|
|
|
else gui_button_draw (¤twin->buttons[i]);
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < GUI_WIN_LABELS; i++) if (currentwin->labels[i].id != 0) {
|
|
|
|
|
gui_label_draw (¤twin->labels[i]);
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < GUI_WIN_ENTRYS; i++) if (currentwin->entrys[i].id != 0) {
|
|
|
|
|
gui_entry_draw (¤twin->entrys[i]);
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < GUI_WIN_LISTS; i++) if (currentwin->lists[i].id != 0) {
|
|
|
|
|
gui_list_draw (¤twin->lists[i]);
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < GUI_WIN_CHECKBOXES; i++) if (currentwin->checkboxes[i].id != 0) {
|
|
|
|
|
// gui_draw_label (¤twin->labels[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* draw items.. */
|
|
|
|
|
for (i = 0; i < GUI_MAX_ITEM; i++)
|
|
|
|
|
switch (currentwin->items[i].type) {
|
|
|
|
|
case (GUI_BUTTON): {
|
|
|
|
|
GUIButton *button = (GUIButton *) currentwin->items[i].item;
|
|
|
|
|
if (button->callback_draw != NULL) button->callback_draw (button);
|
|
|
|
|
else gui_button_draw (button);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case (GUI_LABEL):
|
|
|
|
|
gui_label_draw ((GUILabel*)currentwin->items[i].item);
|
|
|
|
|
break;
|
|
|
|
|
case (GUI_ENTRY):
|
|
|
|
|
gui_entry_draw ((GUIEntry*)currentwin->items[i].item);
|
|
|
|
|
break;
|
|
|
|
|
case (GUI_LIST):
|
|
|
|
|
gui_list_draw ((GUIList*)currentwin->items[i].item);
|
|
|
|
|
break;
|
|
|
|
|
// case (GUI_ENTRY):
|
|
|
|
|
// gui_entry_draw ((GUIEntry*)currentwin->items[i].item);
|
|
|
|
|
// break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
currentwin->screen_changed = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -140,59 +147,66 @@ int gui_event (GUIEvent event) {
|
|
|
|
|
|
|
|
|
|
if (event_called) return 1;
|
|
|
|
|
event_called = 1;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < GUI_WIN_BUTTONS; i++) {
|
|
|
|
|
// if (currentwin->buttons[i].id != 0)
|
|
|
|
|
// d_printf ("%d %d,%d %d,%d - %d,%d", currentwin->buttons[i].id, currentwin->buttons[i].x, currentwin->buttons[i].y, currentwin->buttons[i].w, currentwin->buttons[i].h, event.mousepos.x, event.mousepos.y);
|
|
|
|
|
if (currentwin->buttons[i].id != 0
|
|
|
|
|
&& currentwin->buttons[i].x <= event.mousepos.x && currentwin->buttons[i].x+currentwin->buttons[i].w >= event.mousepos.x
|
|
|
|
|
&& currentwin->buttons[i].y <= event.mousepos.y && currentwin->buttons[i].y+currentwin->buttons[i].h >= event.mousepos.y) {
|
|
|
|
|
if (currentwin->buttons[i].callback_clicked != NULL && event.event == EGUI_MOUSEPRESSED) {
|
|
|
|
|
d_printf ("GUI BUTTON PRESSED: %d:%s", currentwin->buttons[i].id, currentwin->buttons[i].caption);
|
|
|
|
|
currentwin->buttons[i].callback_clicked (event.mousepos.x-currentwin->buttons[i].x, event.mousepos.y-currentwin->buttons[i].y);
|
|
|
|
|
event_called = 0;
|
|
|
|
|
currentwin->screen_changed = 1;
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < GUI_MAX_ITEM; i++)
|
|
|
|
|
switch (currentwin->items[i].type) {
|
|
|
|
|
case (GUI_BUTTON): {
|
|
|
|
|
GUIButton *button = (GUIButton *) currentwin->items[i].item;
|
|
|
|
|
if (button->x <= event.mousepos.x &&
|
|
|
|
|
button->x+button->w >= event.mousepos.x &&
|
|
|
|
|
button->y <= event.mousepos.y &&
|
|
|
|
|
button->y+button->h >= event.mousepos.y) {
|
|
|
|
|
if (button->callback_clicked != NULL && event.event == EGUI_MOUSEPRESSED) {
|
|
|
|
|
d_printf ("GUI BUTTON PRESSED: %s", button->caption);
|
|
|
|
|
button->callback_clicked (event.mousepos.x-button->x, event.mousepos.y-button->y);
|
|
|
|
|
currentwin->screen_changed = 1;
|
|
|
|
|
event_called = 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case (GUI_LABEL):
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case (GUI_ENTRY): {
|
|
|
|
|
GUIEntry *entry = (GUIEntry*) currentwin->items[i].item;
|
|
|
|
|
if (entry->x <= event.mousepos.x &&
|
|
|
|
|
entry->x+entry->w >= event.mousepos.x &&
|
|
|
|
|
entry->y <= event.mousepos.y &&
|
|
|
|
|
entry->y+entry->h >= event.mousepos.y) {
|
|
|
|
|
gui_entry_event (entry, &event);
|
|
|
|
|
event_called = 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case (GUI_LIST): {
|
|
|
|
|
GUIList *list = (GUIList *) currentwin->items[i].item;
|
|
|
|
|
if (list->x <= event.mousepos.x &&
|
|
|
|
|
list->x+list->w >= event.mousepos.x &&
|
|
|
|
|
list->y <= event.mousepos.y &&
|
|
|
|
|
list->y+list->h >= event.mousepos.y) {
|
|
|
|
|
gui_list_event (list, &event);
|
|
|
|
|
event_called = 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < GUI_WIN_LABELS; i++) if (currentwin->labels[i].id != 0) {
|
|
|
|
|
// gui_event_label (¤twin->labels[i]);
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < GUI_WIN_ENTRYS; i++) if (currentwin->entrys[i].id != 0) {
|
|
|
|
|
if (currentwin->entrys[i].id != 0
|
|
|
|
|
&& currentwin->entrys[i].x <= event.mousepos.x && currentwin->entrys[i].x+currentwin->entrys[i].w >= event.mousepos.x
|
|
|
|
|
&& currentwin->entrys[i].y <= event.mousepos.y && currentwin->entrys[i].y+currentwin->entrys[i].h >= event.mousepos.y) {
|
|
|
|
|
gui_entry_event (¤twin->entrys[i], &event);
|
|
|
|
|
event_called = 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < GUI_WIN_LISTS; i++) if (currentwin->lists[i].id != 0) {
|
|
|
|
|
if (currentwin->lists[i].x <= event.mousepos.x && currentwin->lists[i].x+currentwin->lists[i].w >= event.mousepos.x
|
|
|
|
|
&& currentwin->lists[i].y <= event.mousepos.y && currentwin->lists[i].y+currentwin->lists[i].h >= event.mousepos.y) {
|
|
|
|
|
gui_list_event (¤twin->lists[i], &event);
|
|
|
|
|
event_called = 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < GUI_WIN_CHECKBOXES; i++) if (currentwin->checkboxes[i].id != 0) {
|
|
|
|
|
// gui_event_label (¤twin->labels[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentwin->focus != NULL) {
|
|
|
|
|
for (i = 0; i < GUI_WIN_ENTRYS; i++) if (currentwin->focus == ¤twin->entrys[i]) {
|
|
|
|
|
gui_entry_event (¤twin->entrys[i], &event);
|
|
|
|
|
event_called = 0;
|
|
|
|
|
return 1;
|
|
|
|
|
if (currentwin->focus != NULL)
|
|
|
|
|
switch (currentwin->focus->type) {
|
|
|
|
|
case (GUI_BUTTON):
|
|
|
|
|
gui_entry_event ((GUIEntry*)currentwin->focus->item, &event);
|
|
|
|
|
break;
|
|
|
|
|
case (GUI_LIST):
|
|
|
|
|
gui_list_event ((GUIList*)currentwin->focus->item, &event);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
for (i = 0; i < GUI_WIN_LISTS; i++) if (currentwin->focus == ¤twin->lists[i]) {
|
|
|
|
|
gui_list_event (¤twin->lists[i], &event);
|
|
|
|
|
event_called = 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
event_called = 0;
|
|
|
|
|
return 1;
|
|
|
|
|
|