You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
285 lines
7.0 KiB
285 lines
7.0 KiB
/***************************************************************************
|
|
* gui_mainmenu.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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "osmroute.h"
|
|
#include "draw.h"
|
|
#include "gui.h"
|
|
#include "system.h"
|
|
#include "routing.h"
|
|
|
|
|
|
enum {
|
|
MMENWIN_UNDEF = 0,
|
|
MMENWIN_SEARCH,
|
|
MMENWIN_MAPREFRESH,
|
|
MMENWIN_IDXREFRESH,
|
|
MMENWIN_GPSCONFIG,
|
|
MMENWIN_GPSSTARTSTOP,
|
|
MMENWIN_MAPCONFIG,
|
|
MMENWIN_CLOSE,
|
|
MMENWIN_SETDEST,
|
|
MMENWIN_DEBUG,
|
|
MMENWIN_QUIT
|
|
};
|
|
|
|
void gui_mainmenu_close ();
|
|
void gui_mainmenu_search ();
|
|
void gui_mainmenu_quit ();
|
|
void gui_mainmenu_refresh ();
|
|
void gui_mainmenu_refreshidx ();
|
|
void gui_mainmenu_gpsconfig ();
|
|
void gui_mainmenu_gpsstartstop ();
|
|
void gui_mainmenu_mapconfig ();
|
|
void gui_mainmenu_setdest ();
|
|
void gui_mainmenu_debug ();
|
|
|
|
static GUIWindow wmmenu = {0};
|
|
|
|
void gui_mainmenu_show () {
|
|
int item = 0;
|
|
|
|
if (wmmenu.screen == NULL) gui_window_new (&wmmenu, 175, 200, _("OSMroute Menu"));
|
|
wmmenu.screen_changed = 1;
|
|
wmmenu.style = WGUI_S_VCENTER | WGUI_S_HCENTER;
|
|
|
|
/* add buttons */
|
|
strncpy (wmmenu.buttons[item].caption, _("Close"), GUI_TEXTLEN);
|
|
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_close;
|
|
wmmenu.buttons[item].id = MMENWIN_CLOSE;
|
|
wmmenu.buttons[item].w = 80;
|
|
wmmenu.buttons[item].h = 25;
|
|
wmmenu.buttons[item].x = 5;
|
|
wmmenu.buttons[item].y = 170;
|
|
|
|
strncpy (wmmenu.buttons[++item].caption, _("Quit"), GUI_TEXTLEN);
|
|
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_quit;
|
|
wmmenu.buttons[item].id = MMENWIN_QUIT;
|
|
wmmenu.buttons[item].w = 80;
|
|
wmmenu.buttons[item].h = 25;
|
|
wmmenu.buttons[item].x = 90;
|
|
wmmenu.buttons[item].y = 170;
|
|
|
|
strncpy (wmmenu.buttons[++item].caption, _("GPS Config"), GUI_TEXTLEN);
|
|
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_gpsconfig;
|
|
wmmenu.buttons[item].id = MMENWIN_GPSCONFIG;
|
|
wmmenu.buttons[item].w = 80;
|
|
wmmenu.buttons[item].h = 25;
|
|
wmmenu.buttons[item].x = 5;
|
|
wmmenu.buttons[item].y = 140;
|
|
|
|
strncpy (wmmenu.buttons[++item].caption, _("GPS On/Off"), GUI_TEXTLEN);
|
|
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_gpsstartstop;
|
|
wmmenu.buttons[item].id = MMENWIN_GPSSTARTSTOP;
|
|
wmmenu.buttons[item].w = 80;
|
|
wmmenu.buttons[item].h = 25;
|
|
wmmenu.buttons[item].x = 5;
|
|
wmmenu.buttons[item].y = 110;
|
|
|
|
strncpy (wmmenu.buttons[++item].caption, _("MAP Config"), GUI_TEXTLEN);
|
|
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_mapconfig;
|
|
wmmenu.buttons[item].id = MMENWIN_MAPCONFIG;
|
|
wmmenu.buttons[item].w = 80;
|
|
wmmenu.buttons[item].h = 25;
|
|
wmmenu.buttons[item].x = 90;
|
|
wmmenu.buttons[item].y = 140;
|
|
|
|
strncpy (wmmenu.buttons[++item].caption, _("MAP Refresh"), GUI_TEXTLEN);
|
|
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_refresh;
|
|
wmmenu.buttons[item].id = MMENWIN_MAPREFRESH;
|
|
wmmenu.buttons[item].w = 80;
|
|
wmmenu.buttons[item].h = 25;
|
|
wmmenu.buttons[item].x = 90;
|
|
wmmenu.buttons[item].y = 110;
|
|
|
|
strncpy (wmmenu.buttons[++item].caption, _("Debug"), GUI_TEXTLEN);
|
|
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_debug;
|
|
wmmenu.buttons[item].id = MMENWIN_DEBUG;
|
|
wmmenu.buttons[item].w = 80;
|
|
wmmenu.buttons[item].h = 25;
|
|
wmmenu.buttons[item].x = 5;
|
|
wmmenu.buttons[item].y = 80;
|
|
|
|
strncpy (wmmenu.buttons[++item].caption, _("IDX Refresh"), GUI_TEXTLEN);
|
|
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_refreshidx;
|
|
wmmenu.buttons[item].id = MMENWIN_IDXREFRESH;
|
|
wmmenu.buttons[item].w = 80;
|
|
wmmenu.buttons[item].h = 25;
|
|
wmmenu.buttons[item].x = 90;
|
|
wmmenu.buttons[item].y = 80;
|
|
|
|
strncpy (wmmenu.buttons[++item].caption, _("Set Destination"), GUI_TEXTLEN);
|
|
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_setdest;
|
|
wmmenu.buttons[item].id = MMENWIN_SETDEST;
|
|
wmmenu.buttons[item].w = 165;
|
|
wmmenu.buttons[item].h = 25;
|
|
wmmenu.buttons[item].x = 5;
|
|
wmmenu.buttons[item].y = 15;
|
|
|
|
strncpy (wmmenu.buttons[++item].caption, _("Search"), GUI_TEXTLEN);
|
|
wmmenu.buttons[item].callback_clicked = (void*)gui_mainmenu_search;
|
|
wmmenu.buttons[item].id = MMENWIN_SEARCH;
|
|
wmmenu.buttons[item].w = 165;
|
|
wmmenu.buttons[item].h = 25;
|
|
wmmenu.buttons[item].x = 5;
|
|
wmmenu.buttons[item].y = 45;
|
|
|
|
gui_show (&wmmenu);
|
|
};
|
|
|
|
|
|
void gui_mainmenu_close () {
|
|
gui_close ();
|
|
};
|
|
|
|
|
|
void gui_mainmenu_search () {
|
|
gui_close ();
|
|
gui_search_show ();
|
|
};
|
|
|
|
|
|
void gui_mainmenu_setdest () {
|
|
static int _setdest = 0;
|
|
struct map_pos p;
|
|
|
|
if (_setdest) {
|
|
d_printf ("set destination routing stop");
|
|
route_stop();
|
|
}
|
|
else {
|
|
d_printf ("set destination routing start");
|
|
_setdest = 1;
|
|
gui_close ();
|
|
p.lon = view_lon;
|
|
p.lat = view_lat;
|
|
route_start (p);
|
|
_setdest = 0;
|
|
}
|
|
};
|
|
|
|
|
|
void gui_mainmenu_gpsconfig () {
|
|
gui_close ();
|
|
#ifdef HAVE_WINAPI
|
|
gps_wince_settings ();
|
|
#else
|
|
#ifdef HAVE_GTK
|
|
gpssetting_wnd_show (main_wnd);
|
|
#endif
|
|
#endif
|
|
config_save ();
|
|
};
|
|
|
|
|
|
void gui_mainmenu_gpsstartstop () {
|
|
gui_close ();
|
|
if (gps_isrunning () != 0) gps_stop ();
|
|
else gps_start ();
|
|
};
|
|
|
|
|
|
void gui_mainmenu_mapconfig () {
|
|
char *fn;
|
|
|
|
gui_close ();
|
|
#if defined (SPOSMROUTE) && (HAVE_GTK)
|
|
fn = dialog_getfilename ("mapdata", "mapdata", 0);
|
|
if (fn) {
|
|
int i;
|
|
for (i = strlen (fn)-1; i > 0; i--)
|
|
if (fn[i] == '\\' || fn[i] == '/') {
|
|
fn[i+1] = '\0';
|
|
break;
|
|
}
|
|
}
|
|
#else
|
|
#if defined(HAVE_WINCE)
|
|
fn = select_dir_dialog ("MapData", cfg.datapath);
|
|
#else
|
|
fn = NULL;
|
|
#endif
|
|
#endif
|
|
if (fn) {
|
|
d_printf ("config: changed data path from '%s' to '%s'.", cfg.mappath, fn);
|
|
map_clear();
|
|
strncpy (cfg.mappath, fn, LEN_FILENAME);
|
|
map_clear();
|
|
draw_redrawmap ();
|
|
}
|
|
config_save ();
|
|
};
|
|
|
|
|
|
void gui_mainmenu_refresh () {
|
|
gui_close ();
|
|
if (select_enabled) {
|
|
struct map_pos s, e;
|
|
|
|
s.lon = view_lon;
|
|
s.lat = view_lat;
|
|
e = select_pos;
|
|
|
|
map_refreshblock (s, e, 100.0);
|
|
}
|
|
else {
|
|
map_refresh (view_lon, view_lat);
|
|
}
|
|
};
|
|
|
|
|
|
void gui_mainmenu_refreshidx () {
|
|
char lfn[LEN_FILENAME];
|
|
#ifndef _WINDOWSCE_
|
|
char rfn[LEN_FILENAME] = "search.mapidx";
|
|
#endif
|
|
gui_close ();
|
|
|
|
map_search_get_filename (lfn, LEN_FILENAME);
|
|
#ifndef _WINDOWSCE_
|
|
map_webload (rfn, lfn, NULL);
|
|
#endif
|
|
map_search_sort ();
|
|
draw_redrawmap ();
|
|
};
|
|
|
|
|
|
void gui_mainmenu_quit () {
|
|
gui_close ();
|
|
#ifdef _WINDOWSCE_
|
|
wince_taskbar (hMainWnd, TRUE);
|
|
#endif
|
|
route_stop ();
|
|
map_save_all ();
|
|
config_save ();
|
|
exit (0);
|
|
};
|
|
|
|
|
|
void gui_mainmenu_debug() {
|
|
gui_close ();
|
|
if (view_flags & DRAW_DEBUG) draw_del_flag (DRAW_DEBUG);
|
|
else if (!(view_flags & DRAW_DEBUG)) draw_set_flag (DRAW_DEBUG);
|
|
};
|
|
|
|
|