From 475db83d4c4117c634febefc4a3607c3cff7d2b3 Mon Sep 17 00:00:00 2001 From: steffen Date: Sun, 17 Feb 2013 00:52:20 +0000 Subject: [PATCH] splitting into different files.. --- gui/Makefile | 8 +- gui/gui.c | 259 +---------------------------------------------- gui/gui.h | 4 +- gui/gui_button.c | 48 +++++++++ gui/gui_entry.c | 112 ++++++++++++++++++++ gui/gui_image.c | 30 ++++++ gui/gui_label.c | 42 ++++++++ gui/gui_list.c | 98 ++++++++++++++++++ gui/gui_window.c | 92 +++++++++++++++++ 9 files changed, 432 insertions(+), 261 deletions(-) create mode 100644 gui/gui_button.c create mode 100644 gui/gui_entry.c create mode 100644 gui/gui_image.c create mode 100644 gui/gui_label.c create mode 100644 gui/gui_list.c create mode 100644 gui/gui_window.c diff --git a/gui/Makefile b/gui/Makefile index 8e1cf22..7293799 100644 --- a/gui/Makefile +++ b/gui/Makefile @@ -1,6 +1,12 @@ include ../Makefile.rules -OBJ = gui.o +OBJ = gui.o \ + gui_window.o \ + gui_button.o \ + gui_list.o \ + gui_entry.o \ + gui_label.o \ + gui_image.o SRC = $(OBJ:%.o=%.c) diff --git a/gui/gui.c b/gui/gui.c index de6782d..0e41af7 100644 --- a/gui/gui.c +++ b/gui/gui.c @@ -1,4 +1,4 @@ -/* $Id: gui.c,v 1.3 2013/02/16 20:29:16 steffen Exp $ */ +/* $Id: gui.c,v 1.4 2013/02/17 00:52:20 steffen Exp $ */ /*************************************************************************** * gui.c * @@ -198,260 +198,3 @@ int gui_event (GUIEvent event) { return 1; }; - -/*************************************************************************** - * basic windows functions - ***************************************************************************/ -void guiwindow_new (GUIWindow *win, int w, int h, char *title) { - int i; - - for (i = 0; i < GUI_MAX_ITEM; i++) { - win->items[i]->item = NULL; - win->items[i]->type = GUI_NONE; - } - - strncpy (win->title, title, GUI_TEXTLEN); - - win->screen = NULL; - win->screen_changed = 1; - win->h = h; - win->w = w; - win->focus = NULL; - - d_printf ("guiwindow_new %p width:%d height:%d", win, w, h); -}; - - -/* - * set focus - */ - - - -/* - * closes the window, but does not free the memory. - */ -void guiwindow_close (GUIWindow *win) { - int i; - - for (i = 0; i < GUI_WIN_BUTTONS; i++) { - win->buttons[i].caption[0] = '\0'; - win->buttons[i].id = 0; - win->buttons[i].callback_clicked = NULL; - win->buttons[i].callback_draw = NULL; - } - for (i = 0; i < GUI_WIN_LABELS; i++) { - win->labels[i].text[0] = '\0'; - win->labels[i].textcol = &color[COLOR_white][2]; - win->labels[i].id = 0; - } - for (i = 0; i < GUI_WIN_ENTRYS; i++) { - win->entrys[i].text[0] = '\0'; - win->entrys[i].callback_enter = NULL; - win->entrys[i].callback_changed = NULL; - win->entrys[i].id = 0; - } - for (i = 0; i < GUI_WIN_CHECKBOXES; i++) { - win->checkboxes[i].text[0] = '\0'; - win->checkboxes[i].callback_changed = NULL; - win->checkboxes[i].id = 0; - } - - win->title[0] = 0; - - gfx_img_free (win->screen); - win->screen = NULL; - win->screen_changed = 1; - win->h = 0; - win->w = 0; -}; - - - -/**************************************************************************** - **************************************************************************** - ** gui elements - ** - **/ - -/**************************************************************************** - * button - */ -void gui_button_draw (GUIButton *button) { - struct line_style ls; - - ls.width = 1.0; - ls.c = ls.borderc = color[COLOR_white][3]; - - draw_polygonstart (); - draw_polygonadd (button->x, button->y); - draw_polygonadd (button->x, button->y + button->h); - draw_polygonadd (button->x + button->w, button->y + button->h); - draw_polygonadd (button->x + button->w, button->y); - draw_polygonfinish (currentwin->screen, ls, *button->col, 1); - gfx_draw_text (currentwin->screen, button->x + 2, button->y + 2, button->caption, button->textcol); -}; - - -/**************************************************************************** - * label - */ -void gui_label_draw (GUILabel *label) { - struct line_style ls; - - ls.width = 1.0; - ls.c = ls.borderc = color[COLOR_white][3]; - - gfx_draw_text (currentwin->screen, label->x, label->y, label->text, label->textcol); -}; - - -/**************************************************************************** - * entry - */ -void gui_entry_draw (GUIEntry *entry) { - char text1[GUI_TEXTLEN]; - char text2[GUI_TEXTLEN]; - struct line_style ls; - - ls.width = 1.0; - if (currentwin->focus == entry) - ls.c = ls.borderc = color[COLOR_white][3]; - else - ls.c = ls.borderc = color[COLOR_white][2]; - gfx_draw_line (currentwin->screen, entry->x, entry->y+entry->h, entry->x+entry->w, entry->y+entry->h, ls); - gfx_draw_line (currentwin->screen, entry->x, entry->y+entry->h, entry->x, entry->y+entry->h-2, ls); - gfx_draw_line (currentwin->screen, entry->x+entry->w, entry->y+entry->h, entry->x+entry->w, entry->y+entry->h-2, ls); - - if (entry->curpos >= strlen (entry->text)) { - entry->curpos = strlen (entry->text); - snprintf (text1, GUI_TEXTLEN, "%s|", entry->text); - } - else if (entry->curpos <= 0) { - entry->curpos = 0; - snprintf (text1, GUI_TEXTLEN, "|%s", entry->text); - } - else { - strncpy (text2, entry->text, entry->curpos); - snprintf (text1, GUI_TEXTLEN, "%s|%s", text2, entry->text+entry->curpos); - } - gfx_draw_text (currentwin->screen, entry->x+2, entry->y, text1, &color[COLOR_white][3]); -}; - - -/* - * event handling - */ -void gui_entry_event (GUIEntry *entry, GUIEvent *event) { - char text1[GUI_TEXTLEN]; - - if (event->event == EGUI_MOUSERELEASED - && entry->x <= event->mousepos.x && entry->x+entry->w >= event->mousepos.x - && entry->y <= event->mousepos.y && entry->y+entry->h >= event->mousepos.y) { - d_printf ("gui_entry_event set focus"); - currentwin->focus = entry; - } - - else if (event->event == EGUI_KEYRELEASED) { - d_printf ("gui_entry_event: curpos:%d len:%d text:%s char:%x", entry->curpos, strlen (entry->text), entry->text, event->keyval); - if (event->keyval == 0xff08) { // backspace -// strncpy (text1, entry->text, entry->curpos-1); -// snprintf (text2, GUI_TEXTLEN, "%s%s", text1, entry->text+entry->curpos); -// strncpy (entry->text, text2, GUI_TEXTLEN); -// entry->curpos--; - entry->text[0] = 0; - entry->curpos = 0; - } - else if (event->keyval == 0xff1b) { // esc - gui_close (); - } - else if (event->keyval == 0xff0d) { // enter - if (entry->callback_enter) entry->callback_enter (); - } - else if (event->keyval == 0xff51) { // left -// entry->curpos--; - } - else if (event->keyval == 0xff53) { // right -// entry->curpos++; - } - else if ((event->keyval & 0xff00) == 0xff00) { - // ignore all the rest - } - else { - strncpy (text1, entry->text, GUI_TEXTLEN ); - snprintf (entry->text, GUI_TEXTLEN, "%s%c", text1, event->keyval); - entry->curpos++; - } - } - currentwin->screen_changed = 1; - return; -}; - - -/**************************************************************************** - * list - */ -void gui_list_draw (GUIList *list) { - struct line_style ls; - int max, i, x, y, j; - - ls.width = 1.0; - if (currentwin->focus == list) - ls.c = ls.borderc = color[COLOR_white][3]; - else - ls.c = ls.borderc = color[COLOR_white][2]; - gfx_draw_line (currentwin->screen, list->x, list->y, list->x+list->w, list->y, ls); - gfx_draw_line (currentwin->screen, list->x+list->w, list->y, list->x+list->w, list->y+list->h, ls); - gfx_draw_line (currentwin->screen, list->x+list->w, list->y+list->h, list->x, list->y+list->h, ls); - gfx_draw_line (currentwin->screen, list->x, list->y+list->h, list->x, list->y, ls); - - if (list->data == NULL) return; - for (max = 0; list->data[max] != NULL; max++); - - /* range to display */ - i = max - list->h/16; - if (i < list->vs) list->vs = i; - if (list->vs < 0) list->vs = 0; - - for (i = list->vs; i < (list->vs + list->h/16) && i < max; i++) { - if (i == list->selected) gfx_draw_text (currentwin->screen, list->x + 5, list->y + 5 + 16 * (i - list->vs), list->data[i], &color[COLOR_red][1]); - else gfx_draw_text (currentwin->screen, list->x + 5, list->y + 5 + 16 * (i - list->vs), list->data[i], &color[COLOR_white][3]); - } - - ls.c = ls.borderc = color[COLOR_white][3]; - for (i = -1; i < 2; i += 2) { - if (i < 0) y = list->y + list->h; - else y = list->y; - x = list->x + list->w; - for (j = 0; j <= 5; j++) { - gfx_draw_line (currentwin->screen, x - 5, y, x-j, y + i*5, ls); - gfx_draw_line (currentwin->screen, x - 5 -j, y+ i*5, x-5, y, ls); - } - } -}; - - -/* - * event handling - */ -void gui_list_event (GUIList *list, GUIEvent *event) { - int x = event->mousepos.x - list->x; - int y = event->mousepos.y - list->y; - int i; - - /* set focus */ - if (event->event == EGUI_MOUSERELEASED && x >= 0 && x <= list->w && y >= 0 && y <= list->h) { - currentwin->focus = list; - - if (y <= 5 && x >= list->w - 10) list->vs--; - else if (y >= list->h - 5 && x >= list->w - 10) list->vs++; - else { /* select entry */ - i = (y-5)/16 + list->vs; - list->selected = i; - if (list->callback_selectitem) list->callback_selectitem (i); - d_printf ("selected nr: %d", i); - } - } - currentwin->screen_changed = 1; - draw (); -}; diff --git a/gui/gui.h b/gui/gui.h index 5bc8402..f81d1c7 100644 --- a/gui/gui.h +++ b/gui/gui.h @@ -148,8 +148,8 @@ extern void gui_draw (); extern void gui_close (); extern int gui_event (GUIEvent event); -extern void guiwindow_new (GUIWindow *win, int w, int h, char *title); -extern void guiwindow_close (GUIWindow *win); +extern void gui_window_new (GUIWindow *win, int w, int h, char *title); +extern void gui_window_close (GUIWindow *win); /* button functions */ extern void gui_button_draw (GUIButton *button); diff --git a/gui/gui_button.c b/gui/gui_button.c new file mode 100644 index 0000000..7508c49 --- /dev/null +++ b/gui/gui_button.c @@ -0,0 +1,48 @@ +/* $Id: gui_button.c,v 1.1 2013/02/17 00:52:20 steffen Exp $ */ +/*************************************************************************** + * gui_button.c + * + * Copyright (C) 2013 Steffen Pohle + * steffen@gulpe.de + *************************************************************************** + * basic windows functions + ***************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * main.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + + +#include "osmroute.h" +#include "draw.h" +#include "gui.h" +#include "system.h" + +/**************************************************************************** + * button + */ +void gui_button_draw (GUIButton *button) { + struct line_style ls; + + ls.width = 1.0; + ls.c = ls.borderc = color[COLOR_white][3]; + + draw_polygonstart (); + draw_polygonadd (button->x, button->y); + draw_polygonadd (button->x, button->y + button->h); + draw_polygonadd (button->x + button->w, button->y + button->h); + draw_polygonadd (button->x + button->w, button->y); + draw_polygonfinish (currentwin->screen, ls, *button->col, 1); + gfx_draw_text (currentwin->screen, button->x + 2, button->y + 2, button->caption, button->textcol); +}; diff --git a/gui/gui_entry.c b/gui/gui_entry.c new file mode 100644 index 0000000..a7b68c6 --- /dev/null +++ b/gui/gui_entry.c @@ -0,0 +1,112 @@ +/* $Id: gui_entry.c,v 1.1 2013/02/17 00:52:20 steffen Exp $ */ +/*************************************************************************** + * gui_entry.c + * + * Copyright (C) 2013 Steffen Pohle + * steffen@gulpe.de + *************************************************************************** + * basic windows functions + ***************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * main.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "osmroute.h" +#include "draw.h" +#include "gui.h" +#include "system.h" + +/**************************************************************************** + * entry + */ +void gui_entry_draw (GUIEntry *entry) { + char text1[GUI_TEXTLEN]; + char text2[GUI_TEXTLEN]; + struct line_style ls; + + ls.width = 1.0; + if (currentwin->focus == entry) + ls.c = ls.borderc = color[COLOR_white][3]; + else + ls.c = ls.borderc = color[COLOR_white][2]; + gfx_draw_line (currentwin->screen, entry->x, entry->y+entry->h, entry->x+entry->w, entry->y+entry->h, ls); + gfx_draw_line (currentwin->screen, entry->x, entry->y+entry->h, entry->x, entry->y+entry->h-2, ls); + gfx_draw_line (currentwin->screen, entry->x+entry->w, entry->y+entry->h, entry->x+entry->w, entry->y+entry->h-2, ls); + + if (entry->curpos >= strlen (entry->text)) { + entry->curpos = strlen (entry->text); + snprintf (text1, GUI_TEXTLEN, "%s|", entry->text); + } + else if (entry->curpos <= 0) { + entry->curpos = 0; + snprintf (text1, GUI_TEXTLEN, "|%s", entry->text); + } + else { + strncpy (text2, entry->text, entry->curpos); + snprintf (text1, GUI_TEXTLEN, "%s|%s", text2, entry->text+entry->curpos); + } + gfx_draw_text (currentwin->screen, entry->x+2, entry->y, text1, &color[COLOR_white][3]); +}; + + +/* + * event handling + */ +void gui_entry_event (GUIEntry *entry, GUIEvent *event) { + char text1[GUI_TEXTLEN]; + + if (event->event == EGUI_MOUSERELEASED + && entry->x <= event->mousepos.x && entry->x+entry->w >= event->mousepos.x + && entry->y <= event->mousepos.y && entry->y+entry->h >= event->mousepos.y) { + d_printf ("gui_entry_event set focus"); + currentwin->focus = entry; + } + + else if (event->event == EGUI_KEYRELEASED) { + d_printf ("gui_entry_event: curpos:%d len:%d text:%s char:%x", entry->curpos, strlen (entry->text), entry->text, event->keyval); + if (event->keyval == 0xff08) { // backspace +// strncpy (text1, entry->text, entry->curpos-1); +// snprintf (text2, GUI_TEXTLEN, "%s%s", text1, entry->text+entry->curpos); +// strncpy (entry->text, text2, GUI_TEXTLEN); +// entry->curpos--; + entry->text[0] = 0; + entry->curpos = 0; + } + else if (event->keyval == 0xff1b) { // esc + gui_close (); + } + else if (event->keyval == 0xff0d) { // enter + if (entry->callback_enter) entry->callback_enter (); + } + else if (event->keyval == 0xff51) { // left +// entry->curpos--; + } + else if (event->keyval == 0xff53) { // right +// entry->curpos++; + } + else if ((event->keyval & 0xff00) == 0xff00) { + // ignore all the rest + } + else { + strncpy (text1, entry->text, GUI_TEXTLEN ); + snprintf (entry->text, GUI_TEXTLEN, "%s%c", text1, event->keyval); + entry->curpos++; + } + } + currentwin->screen_changed = 1; + return; +}; + + diff --git a/gui/gui_image.c b/gui/gui_image.c new file mode 100644 index 0000000..6441593 --- /dev/null +++ b/gui/gui_image.c @@ -0,0 +1,30 @@ +/* $Id: gui_image.c,v 1.1 2013/02/17 00:52:20 steffen Exp $ */ +/*************************************************************************** + * gui_image.c + * + * Copyright (C) 2013 Steffen Pohle + * steffen@gulpe.de + *************************************************************************** + * basic windows functions + ***************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * main.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + + +#include "osmroute.h" +#include "draw.h" +#include "gui.h" +#include "system.h" diff --git a/gui/gui_label.c b/gui/gui_label.c new file mode 100644 index 0000000..d7112fc --- /dev/null +++ b/gui/gui_label.c @@ -0,0 +1,42 @@ +/* $Id: gui_label.c,v 1.1 2013/02/17 00:52:20 steffen Exp $ */ +/*************************************************************************** + * gui_label.c + * + * Copyright (C) 2013 Steffen Pohle + * steffen@gulpe.de + *************************************************************************** + * basic windows functions + ***************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * main.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + + +#include "osmroute.h" +#include "draw.h" +#include "gui.h" +#include "system.h" + +/**************************************************************************** + * label + */ +void gui_label_draw (GUILabel *label) { + struct line_style ls; + + ls.width = 1.0; + ls.c = ls.borderc = color[COLOR_white][3]; + + gfx_draw_text (currentwin->screen, label->x, label->y, label->text, label->textcol); +}; diff --git a/gui/gui_list.c b/gui/gui_list.c new file mode 100644 index 0000000..369c402 --- /dev/null +++ b/gui/gui_list.c @@ -0,0 +1,98 @@ +/* $Id: gui_list.c,v 1.1 2013/02/17 00:52:20 steffen Exp $ */ +/*************************************************************************** + * gui_list.c + * + * Copyright (C) 2013 Steffen Pohle + * steffen@gulpe.de + *************************************************************************** + * basic windows functions + ***************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * main.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "osmroute.h" +#include "draw.h" +#include "gui.h" +#include "system.h" + + +/**************************************************************************** + * list + */ +void gui_list_draw (GUIList *list) { + struct line_style ls; + int max, i, x, y, j; + + ls.width = 1.0; + if (currentwin->focus == list) + ls.c = ls.borderc = color[COLOR_white][3]; + else + ls.c = ls.borderc = color[COLOR_white][2]; + gfx_draw_line (currentwin->screen, list->x, list->y, list->x+list->w, list->y, ls); + gfx_draw_line (currentwin->screen, list->x+list->w, list->y, list->x+list->w, list->y+list->h, ls); + gfx_draw_line (currentwin->screen, list->x+list->w, list->y+list->h, list->x, list->y+list->h, ls); + gfx_draw_line (currentwin->screen, list->x, list->y+list->h, list->x, list->y, ls); + + if (list->data == NULL) return; + for (max = 0; list->data[max] != NULL; max++); + + /* range to display */ + i = max - list->h/16; + if (i < list->vs) list->vs = i; + if (list->vs < 0) list->vs = 0; + + for (i = list->vs; i < (list->vs + list->h/16) && i < max; i++) { + if (i == list->selected) gfx_draw_text (currentwin->screen, list->x + 5, list->y + 5 + 16 * (i - list->vs), list->data[i], &color[COLOR_red][1]); + else gfx_draw_text (currentwin->screen, list->x + 5, list->y + 5 + 16 * (i - list->vs), list->data[i], &color[COLOR_white][3]); + } + + ls.c = ls.borderc = color[COLOR_white][3]; + for (i = -1; i < 2; i += 2) { + if (i < 0) y = list->y + list->h; + else y = list->y; + x = list->x + list->w; + for (j = 0; j <= 5; j++) { + gfx_draw_line (currentwin->screen, x - 5, y, x-j, y + i*5, ls); + gfx_draw_line (currentwin->screen, x - 5 -j, y+ i*5, x-5, y, ls); + } + } +}; + + +/* + * event handling + */ +void gui_list_event (GUIList *list, GUIEvent *event) { + int x = event->mousepos.x - list->x; + int y = event->mousepos.y - list->y; + int i; + + /* set focus */ + if (event->event == EGUI_MOUSERELEASED && x >= 0 && x <= list->w && y >= 0 && y <= list->h) { + currentwin->focus = list; + + if (y <= 5 && x >= list->w - 10) list->vs--; + else if (y >= list->h - 5 && x >= list->w - 10) list->vs++; + else { /* select entry */ + i = (y-5)/16 + list->vs; + list->selected = i; + if (list->callback_selectitem) list->callback_selectitem (i); + d_printf ("selected nr: %d", i); + } + } + currentwin->screen_changed = 1; + draw (); +}; diff --git a/gui/gui_window.c b/gui/gui_window.c new file mode 100644 index 0000000..c3bd7fe --- /dev/null +++ b/gui/gui_window.c @@ -0,0 +1,92 @@ +/* $Id: gui_window.c,v 1.1 2013/02/17 00:52:20 steffen Exp $ */ +/*************************************************************************** + * gui_window.c + * + * Copyright (C) 2013 Steffen Pohle + * steffen@gulpe.de + *************************************************************************** + * basic windows functions + ***************************************************************************/ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * main.c is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + + +#include "osmroute.h" +#include "draw.h" +#include "gui.h" +#include "system.h" + +/* + * reset all window data, do not allocate anything + */ +void gui_window_new (GUIWindow *win, int w, int h, char *title) { + int i; + + for (i = 0; i < GUI_MAX_ITEM; i++) { + win->items[i]->item = NULL; + win->items[i]->type = GUI_NONE; + } + + strncpy (win->title, title, GUI_TEXTLEN); + + win->screen = NULL; + win->screen_changed = 1; + win->h = h; + win->w = w; + win->focus = NULL; + + d_printf ("guiwindow_new %p width:%d height:%d", win, w, h); +}; + + +/* + * closes the window, but does not free the memory. + */ +void gui_window_close (GUIWindow *win) { + int i; + + for (i = 0; i < GUI_WIN_BUTTONS; i++) { + win->buttons[i].caption[0] = '\0'; + win->buttons[i].id = 0; + win->buttons[i].callback_clicked = NULL; + win->buttons[i].callback_draw = NULL; + } + for (i = 0; i < GUI_WIN_LABELS; i++) { + win->labels[i].text[0] = '\0'; + win->labels[i].textcol = &color[COLOR_white][2]; + win->labels[i].id = 0; + } + for (i = 0; i < GUI_WIN_ENTRYS; i++) { + win->entrys[i].text[0] = '\0'; + win->entrys[i].callback_enter = NULL; + win->entrys[i].callback_changed = NULL; + win->entrys[i].id = 0; + } + for (i = 0; i < GUI_WIN_CHECKBOXES; i++) { + win->checkboxes[i].text[0] = '\0'; + win->checkboxes[i].callback_changed = NULL; + win->checkboxes[i].id = 0; + } + + win->title[0] = 0; + + gfx_img_free (win->screen); + win->screen = NULL; + win->screen_changed = 1; + win->h = 0; + win->w = 0; +}; +