/*************************************************************************** * gui_buttons.c * * 2011-03-10 * Copyright (C) 2011 Steffen Pohle * steffen@gulpe.de ****************************************************************************/ /* * 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" enum { BTNWIN_UNDEF = 0, BTNWIN_ZOUT, BTNWIN_ZIN, BTNWIN_GPS, BTNWIN_MENU, BTNWIN_FAV }; static GUIWindow wbutton = {0}; void gui_buttons_closecallback (); void gui_buttons_draw (GUIButton *btn); void gui_buttons_zoomin(); void gui_buttons_zoomout(); void gui_buttons_gps(); void gui_buttons_menu(); void gui_buttons_fav(); void gui_buttons_show () { d_printf ("GUI: buttons show screen:%p", wbutton.screen); if (wbutton.screen == NULL) guiwindow_new (&wbutton, 192, 32); wbutton.screen_changed = 1; wbutton.callback_close = (void*)gui_buttons_closecallback; wbutton.style = WGUI_S_VCENTER | WGUI_S_HTOP; /* add buttons */ strncpy (wbutton.buttons[0].caption, _("+"), GUI_TEXTLEN); wbutton.buttons[0].callback_clicked = (void*)gui_buttons_zoomin; wbutton.buttons[0].callback_draw = (void*)gui_buttons_draw; wbutton.buttons[0].id = BTNWIN_ZIN; wbutton.buttons[0].w = 31; wbutton.buttons[0].h = 31; wbutton.buttons[0].x = 0; wbutton.buttons[0].y = 0; strncpy (wbutton.buttons[1].caption, _("-"), GUI_TEXTLEN); wbutton.buttons[1].callback_clicked = (void*)gui_buttons_zoomout; wbutton.buttons[1].callback_draw = (void*)gui_buttons_draw; wbutton.buttons[1].id = BTNWIN_ZOUT; wbutton.buttons[1].w = 31; wbutton.buttons[1].h = 31; wbutton.buttons[1].x = 40; wbutton.buttons[1].y = 0; strncpy (wbutton.buttons[2].caption, _("GPS"), GUI_TEXTLEN); wbutton.buttons[2].callback_clicked = (void*)gui_buttons_gps; wbutton.buttons[2].callback_draw = (void*)gui_buttons_draw; wbutton.buttons[2].id = BTNWIN_GPS; wbutton.buttons[2].w = 31; wbutton.buttons[2].h = 31; wbutton.buttons[2].x = 80; wbutton.buttons[2].y = 0; strncpy (wbutton.buttons[3].caption, _("M"), GUI_TEXTLEN); wbutton.buttons[3].callback_clicked = (void*)gui_buttons_menu; wbutton.buttons[3].callback_draw = (void*)gui_buttons_draw; wbutton.buttons[3].id = BTNWIN_MENU; wbutton.buttons[3].w = 31; wbutton.buttons[3].h = 31; wbutton.buttons[3].x = 120; wbutton.buttons[3].y = 0; strncpy (wbutton.buttons[4].caption, _("Fav"), GUI_TEXTLEN); wbutton.buttons[4].callback_clicked = (void*)gui_buttons_fav; wbutton.buttons[4].callback_draw = (void*)gui_buttons_draw; wbutton.buttons[4].id = BTNWIN_FAV; wbutton.buttons[4].w = 31; wbutton.buttons[4].h = 31; wbutton.buttons[4].x = 160; wbutton.buttons[4].y = 0; gui_show (&wbutton); }; void gui_buttons_closecallback () { d_printf ("GUI: buttons close"); guiwindow_close (&wbutton); }; void gui_buttons_draw (GUIButton *btn) { int j; if (btn->id == BTNWIN_GPS) { j = gps_isrunning (); if (j == 0) btn->col = &color[COLOR_white][2]; else if (j < 0) btn->col = &color[COLOR_red][2]; else if (view_flags & DRAW_GPSFOLLOW) btn->col = &color[COLOR_green][3]; else btn->col = &color[COLOR_green][2]; } gui_button_draw (btn); }; void gui_buttons_zoomin() { draw_setscale (-1); }; void gui_buttons_zoomout() { draw_setscale (+1); }; void gui_buttons_gps() { if (gps_isrunning () <= 0) { gps_start (); main_wnd_update(); } else { if (view_flags & DRAW_GPSFOLLOW) { draw_del_flag (DRAW_GPSFOLLOW); } else { draw_set_flag (DRAW_GPSFOLLOW); } if (gps_file_get_state () > GPSF_NONE) gpswin_show (); } }; void gui_buttons_menu() { gui_close (); gui_mainmenu_show (); }; void gui_buttons_fav () { gui_close (); gui_fav_show (); };