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

122 lines
4.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_city ();
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};
GUIItem *ws_entryname = NULL;
GUIItem *ws_labelname = NULL;
GUIItem *ws_entrystreet = NULL;
GUIItem *ws_labelstreet = NULL;
GUIItem *ws_btnok = NULL;
GUIItem *ws_btncancel = NULL;
GUIItem *ws_list = NULL;
GUIItem *ws_map = NULL; /* need to finish working on: gui_images and map_view */
void gui_search_show () {
if (wsearch.screen == NULL) gui_window_new (&wsearch, 220, 260, _("Search.."));
wsearch.screen_changed = 1;
wsearch.style = WGUI_S_VCENTER | WGUI_S_HCENTER;
wsearch.title[0] = 0;
/* Name Ok Button */
if (ws_labelname == NULL) ws_labelname = gui_label_new (_("City:"), 5, 10);
gui_window_item_add (&wsearch, ws_labelname);
if (ws_entryname == NULL) ws_entryname = gui_entry_new (_(""), 50, 10, 100, 20);
gui_window_item_add (&wsearch, ws_entryname);
GUI_ENTRY_T (ws_entryname)->callback_enter = gui_search_city;
if (ws_btnok == NULL) ws_btnok = gui_button_new (_("Ok"), 165, 5, 50, 20);
GUI_BUTTON_T (ws_btnok)->callback_clicked = (void*) gui_search_close;
gui_window_item_add (&wsearch, ws_btnok);
/* street Cancel Button */
if (ws_labelstreet == NULL) ws_labelstreet = gui_label_new (_("Street:"), 5, 35);
gui_window_item_add (&wsearch, ws_labelstreet);
if (ws_entrystreet == NULL) ws_entrystreet = gui_entry_new (_(""), 50, 30, 100, 20);
gui_window_item_add (&wsearch, ws_entrystreet);
if (ws_btncancel == NULL) ws_btncancel = gui_button_new (_("Cancel"), 165, 30, 50, 20);
GUI_BUTTON_T (ws_btncancel)->callback_clicked = (void*) gui_search_close;
gui_window_item_add (&wsearch, ws_btncancel);
/* result list */
if (ws_list == NULL) ws_list = gui_list_new (5, 55, 210, 100);
gui_window_item_add (&wsearch, ws_list);
gui_show (&wsearch);
};
void gui_search_close () {
gui_close ();
};
void gui_search_city () {
int i;
char text[] = "gui_search_city";
search_data_cnt = map_search (text, search_data, SEARCH_MAXRESULT);
for (i = 0; i < search_data_cnt; i++)
d_printf (" %-3d:%s",i , search_data->name[i]);
};
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 ();
} */
};