/* $Id: gui_window.c,v 1.6 2013/02/27 22:21:35 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] = NULL; if (title == NULL) win->title[0] = 0; else strncpy (win->title, title, GUI_TEXTLEN); win->screen = NULL; win->screen_changed = 1; win->h = h; win->w = w; win->focus = NULL; d_printf ("gui_window_new [%s] %p width:%d height:%d", title, win, w, h); }; /* * closes the window, but does not free the memory. */ void gui_window_close (GUIWindow *win) { d_printf ("gui_window_close [%s] %p", win->title, win); /* delete screen so we know it's disabled.. */ if (win->screen) gfx_img_free (win->screen); win->screen = NULL; win->screen_changed = 1; if (currentwin == win) currentwin = NULL; }; /* * add pointer to item to the window data structure.. * the items will have to be hold inside the application */ void gui_window_item_add (GUIWindow *win, GUIItem *item) { int i, ifree = -1; if (item == NULL || win == NULL) return; for (i = 0; i < GUI_MAX_ITEM; i++) { if (win->items[i] == NULL && ifree == -1) ifree = i; if (win->items[i] == item) { d_printf ("item already added to item list."); ifree = i; } } if (ifree == -1) { d_printf ("no free item slot"); exit (1); } win->items[ifree] = item; d_printf ("gui_window_item_add win:%p ifree:%d item:%p", win, ifree, item); };