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.
spOSMroute/main/gui_search.c

109 lines
3.0 KiB

/***************************************************************************
* gui_search.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"
#define SEARCH_MAXRESULT 32
void gui_search_close ();
void gui_search_refresh ();
void gui_search_next ();
void gui_search_prev ();
void gui_search_search ();
void gui_search_switch (int pos);
struct map_search_data search_data[SEARCH_MAXRESULT];
int search_data_cnt = 0;
int search_data_cur = -1;
static GUIWindow wsearch = {0};
void gui_search_show () {
if (wsearch.screen == NULL) gui_window_new (&wsearch, 220, 60, _("Search.."));
wsearch.screen_changed = 1;
// wmmenu.callback_close = (void*)gui_mainmenu_closecallback;
wsearch.screen_changed = 1;
wsearch.style = WGUI_S_VCENTER | WGUI_S_HTOP;
wsearch.title[0] = 0;
gui_show (&wsearch);
};
void gui_search_close () {
gui_close ();
};
void gui_search_refresh () {
map_refresh (view_lon, view_lat);
draw_redrawmap ();
draw ();
};
void gui_search_prev () {
d_printf ("search_data_cur:%d", search_data_cur);
gui_search_switch (search_data_cur-1);
d_printf ("search_data_cur:%d", search_data_cur);
};
void gui_search_next () {
d_printf ("search_data_cur:%d", search_data_cur);
gui_search_switch (search_data_cur+1);
d_printf ("search_data_cur:%d", search_data_cur);
};
void gui_search_search () {
char text[] = "ttttt...";
search_data_cnt = map_search (text, search_data, SEARCH_MAXRESULT);
gui_search_switch (0);
};
void gui_search_switch (int pos) {
d_printf ("gui_search_switch %d to %d", search_data_cur, pos);
search_data_cur = pos;
if (search_data_cnt <= 0) search_data_cur = -1;
else if (search_data_cur >= search_data_cnt) search_data_cur = 0;
else if (search_data_cur < 0) search_data_cur = search_data_cnt - 1;
/*
if (search_data_cur == -1) strncpy (wsearch.labels[0].text, _("0"), GUI_TEXTLEN);
else {
snprintf (wsearch.labels[0].text, GUI_TEXTLEN, _("%d of %d"), search_data_cur+1, search_data_cnt);
strncpy (wsearch.entrys[0].text, search_data[search_data_cur].name, GUI_TEXTLEN);
view_lon = search_data[search_data_cur].lon;
view_lat = search_data[search_data_cur].lat;
wsearch.screen_changed = 1;
wsearch.entrys[0].curpos = strlen (wsearch.entrys[0].text);
draw ();
} */
};