summaryrefslogtreecommitdiff
path: root/navit/gui/internal
diff options
context:
space:
mode:
Diffstat (limited to 'navit/gui/internal')
-rw-r--r--navit/gui/internal/CMakeLists.txt1
-rw-r--r--navit/gui/internal/gui_internal.c3471
-rw-r--r--navit/gui/internal/gui_internal.h85
-rw-r--r--navit/gui/internal/gui_internal_bookmark.c313
-rw-r--r--navit/gui/internal/gui_internal_bookmark.h13
-rw-r--r--navit/gui/internal/gui_internal_command.c1352
-rw-r--r--navit/gui/internal/gui_internal_command.h8
-rw-r--r--navit/gui/internal/gui_internal_gesture.c145
-rw-r--r--navit/gui/internal/gui_internal_gesture.h8
-rw-r--r--navit/gui/internal/gui_internal_html.c504
-rw-r--r--navit/gui/internal/gui_internal_html.h5
-rw-r--r--navit/gui/internal/gui_internal_keyboard.c560
-rw-r--r--navit/gui/internal/gui_internal_keyboard.h31
-rw-r--r--navit/gui/internal/gui_internal_menu.c373
-rw-r--r--navit/gui/internal/gui_internal_menu.h12
-rw-r--r--navit/gui/internal/gui_internal_poi.c792
-rw-r--r--navit/gui/internal/gui_internal_poi.h57
-rw-r--r--navit/gui/internal/gui_internal_priv.h228
-rw-r--r--navit/gui/internal/gui_internal_search.c635
-rw-r--r--navit/gui/internal/gui_internal_search.h10
-rw-r--r--navit/gui/internal/gui_internal_widget.c1497
-rw-r--r--navit/gui/internal/gui_internal_widget.h193
22 files changed, 0 insertions, 10293 deletions
diff --git a/navit/gui/internal/CMakeLists.txt b/navit/gui/internal/CMakeLists.txt
deleted file mode 100644
index 230e315d6..000000000
--- a/navit/gui/internal/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-module_add_library(gui_internal gui_internal.c gui_internal_bookmark.c gui_internal_command.c gui_internal_gesture.c gui_internal_html.c gui_internal_menu.c gui_internal_poi.c gui_internal_search.c gui_internal_widget.c gui_internal_keyboard.c)
diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c
deleted file mode 100644
index 0a62ae010..000000000
--- a/navit/gui/internal/gui_internal.c
+++ /dev/null
@@ -1,3471 +0,0 @@
-/**
- * Navit, a modular navigation system.
- * Copyright (C) 2005-2010 Navit Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * This program 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, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-//##############################################################################################################
-//#
-//# File: gui_internal.c
-//# Description: New "internal" GUI for use with any graphics library
-//# Comment: Trying to make a touchscreen friendly GUI
-//# Authors: Martin Schaller (04/2008), Stefan Klumpp (04/2008)
-//#
-//##############################################################################################################
-
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-#include <glib.h>
-#include <time.h>
-#include "config.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_API_WIN32_BASE
-#include <windows.h>
-#endif
-#ifndef _MSC_VER
-#include <sys/time.h>
-#endif /* _MSC_VER */
-#include "item.h"
-#include "xmlconfig.h"
-#include "file.h"
-#include "navit.h"
-#include "navit_nls.h"
-#include "gui.h"
-#include "coord.h"
-#include "point.h"
-#include "plugin.h"
-#include "graphics.h"
-#include "transform.h"
-#include "color.h"
-#include "map.h"
-#include "callback.h"
-#include "vehicle.h"
-#include "vehicleprofile.h"
-#include "window.h"
-#include "config_.h"
-#include "keys.h"
-#include "mapset.h"
-#include "route.h"
-#include "navit/search.h"
-#include "track.h"
-#include "country.h"
-#include "config.h"
-#include "event.h"
-#include "navit_nls.h"
-#include "navigation.h"
-#include "gui_internal.h"
-#include "command.h"
-#include "util.h"
-#include "bookmarks.h"
-#include "linguistics.h"
-#include "debug.h"
-#include "fib.h"
-#include "types.h"
-#include "gui_internal_widget.h"
-#include "gui_internal_priv.h"
-#include "gui_internal_html.h"
-#include "gui_internal_bookmark.h"
-#include "gui_internal_menu.h"
-#include "gui_internal_search.h"
-#include "gui_internal_gesture.h"
-#include "gui_internal_poi.h"
-#include "gui_internal_command.h"
-#include "gui_internal_keyboard.h"
-
-
-/**
- * Indexes into the config_profiles array.
- */
-const int LARGE_PROFILE=0;
-const int MEDIUM_PROFILE=1;
-const int SMALL_PROFILE=2;
-
-/**
- * The default config profiles.
- *
- * [0] => LARGE_PROFILE (screens 640 in one dimension)
- * [1] => MEDIUM PROFILE (screens larger than 320 in one dimension
- * [2] => Small profile (default)
- */
-static struct gui_config_settings config_profiles[]={
- {545,32,48,96,10}
- , {300,32,48,64,3}
- ,{200,16,32,48,2}
-};
-
-static void gui_internal_cmd_view_in_browser(struct gui_priv *this, struct widget *wm, void *data);
-
-static int gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle *vehicle);
-
-/**
- * @brief Displays an image scaled to a specific size
- *
- * Searches for scaleable and pre-scaled image
- *
- * @param this Our gui context
- * @param name image name
- * @param w desired width of image
- * @param h desired height of image
- *
- * @return image_struct Ptr to scaled image struct or NULL if not scaled or found
- */
-static struct graphics_image *
-image_new_scaled(struct gui_priv *this, const char *name, int w, int h)
-{
- struct graphics_image *ret=NULL;
- char *full_path=NULL;
- full_path=graphics_icon_path(name);
- ret=graphics_image_new_scaled(this->gra, full_path, w, h);
- dbg(lvl_debug,"Trying to load image '%s' (w=%d, h=%d): %s\n", name, w, h, ret ? "OK" : "NOT FOUND");
- g_free(full_path);
- if (!ret) {
- dbg(lvl_error,"Failed to load image for '%s' (w=%d, h=%d)\n", name, w, h);
- full_path=graphics_icon_path("unknown");
- ret=graphics_image_new_scaled(this->gra, full_path, w, h);
- g_free(full_path);
- }
- return ret;
-}
-
-#if 0
-static struct graphics_image *
-image_new_o(struct gui_priv *this, char *name)
-{
- return image_new_scaled(this, name, -1, -1);
-}
-#endif
-
-/**
- * @brief Displays an image scaled to xs (extra small) size
- *
- * This image size can be too small to click it on some devices.
- *
- * @param this Our gui context
- * @param name image name
- *
- * @return image_struct Ptr to scaled image struct or NULL if not scaled or found
- */
-struct graphics_image *
-image_new_xs(struct gui_priv *this, const char *name)
-{
- return image_new_scaled(this, name, this->icon_xs, this->icon_xs);
-}
-
-/**
- * @brief Displays an image scaled to s (small) size
- *
- * @param this Our gui context
- * @param name image name
- *
- * @return image_struct Ptr to scaled image struct or NULL if not scaled or found
- */
-struct graphics_image *
-image_new_s(struct gui_priv *this, const char *name)
-{
- return image_new_scaled(this, name, this->icon_s, this->icon_s);
-}
-
-/**
- * @brief Displays an image scaled to l (large) size
- * @param this Our gui context
- * @param name image name
- *
- * @return image_struct Ptr to scaled image struct or NULL if not scaled or found
- */
-struct graphics_image *
-image_new_l(struct gui_priv *this, const char *name)
-{
- return image_new_scaled(this, name, this->icon_l, this->icon_l);
-}
-
-
-
-static int
-gui_internal_button_attr_update(struct gui_priv *this, struct widget *w)
-{
- struct widget *wi;
- int is_on=0;
- struct attr curr;
- GList *l;
-
- if (w->get_attr(w->instance, w->on.type, &curr, NULL))
- is_on=curr.u.data == w->on.u.data;
- else
- is_on=w->deflt;
- if (is_on != w->is_on) {
- if (w->redraw)
- this->redraw=1;
- w->is_on=is_on;
- l=g_list_first(w->children);
- if (l) {
- wi=l->data;
- if (wi->img)
- graphics_image_free(this->gra, wi->img);
- wi->img=image_new_xs(this, is_on ? "gui_active" : "gui_inactive");
- }
- if (w->is_on && w->off.type == attr_none)
- w->state &= ~STATE_SENSITIVE;
- else
- w->state |= STATE_SENSITIVE;
- return 1;
- }
- return 0;
-}
-
-static void
-gui_internal_button_attr_callback(struct gui_priv *this, struct widget *w)
-{
- if (gui_internal_button_attr_update(this, w))
- gui_internal_widget_render(this, w);
-}
-static void
-gui_internal_button_attr_pressed(struct gui_priv *this, struct widget *w, void *data)
-{
- if (w->is_on)
- w->set_attr(w->instance, &w->off);
- else
- w->set_attr(w->instance, &w->on);
- gui_internal_button_attr_update(this, w);
-
-}
-
-struct widget *
-gui_internal_button_navit_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct attr *on, struct attr *off)
-{
- struct graphics_image *image=NULL;
- struct widget *ret;
- if (!on && !off)
- return NULL;
- image=image_new_xs(this, "gui_inactive");
- ret=gui_internal_button_new_with_callback(this, text, image, flags, gui_internal_button_attr_pressed, NULL);
- if (on)
- ret->on=*on;
- if (off)
- ret->off=*off;
- ret->get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))navit_get_attr;
- ret->set_attr=(int (*)(void *, struct attr *))navit_set_attr;
- ret->remove_cb=(void (*)(void *, struct callback *))navit_remove_callback;
- ret->instance=this->nav;
- ret->cb=callback_new_attr_2(callback_cast(gui_internal_button_attr_callback), on?on->type:off->type, this, ret);
- navit_add_callback(this->nav, ret->cb);
- gui_internal_button_attr_update(this, ret);
- return ret;
-}
-
-struct widget *
-gui_internal_button_map_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct map *map, struct attr *on, struct attr *off, int deflt)
-{
- struct graphics_image *image=NULL;
- struct widget *ret;
- image=image_new_xs(this, "gui_inactive");
- if (!on && !off)
- return NULL;
- ret=gui_internal_button_new_with_callback(this, text, image, flags, gui_internal_button_attr_pressed, NULL);
- if (on)
- ret->on=*on;
- if (off)
- ret->off=*off;
- ret->deflt=deflt;
- ret->get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))map_get_attr;
- ret->set_attr=(int (*)(void *, struct attr *))map_set_attr;
- ret->remove_cb=(void (*)(void *, struct callback *))map_remove_callback;
- ret->instance=map;
- ret->redraw=1;
- ret->cb=callback_new_attr_2(callback_cast(gui_internal_button_attr_callback), on?on->type:off->type, this, ret);
- map_add_callback(map, ret->cb);
- gui_internal_button_attr_update(this, ret);
- return ret;
-}
-
-
-
-
-
-
-/*
- * @brief Calculate movement vector and timing of the gesture.
- * @param in this gui context
- * @param in msec time in milliseconds to find gesture within
- * @param out p0 pointer to the point object, where gesture starting point coordinates should be placed. Can be NULL.
- * @param out dx pointer to variable to store horizontal movement of the gesture.
- * @param out dy pointer to variable to store vertical movement of the gesture.
- * @return amount of time the actual movement took.
- */
-/* FIXME where is the implementation? */
-
-
-static void gui_internal_motion_cb(struct gui_priv *this)
-{
- this->motion_timeout_event=NULL;
- gui_internal_gesture_ring_add(this, &(this->current));
-
- /* Check for scrollable table below the highligted item if there's a movement with the button pressed */
- if (this->pressed && this->highlighted) {
- struct widget *wt=NULL;
- struct widget *wr=NULL;
- int dx,dy;
-
- /* Guard against accidental scrolling when user is likely going to swipe */
- gui_internal_gesture_get_vector(this, 1000, NULL, &dx, &dy);
- if(abs(dx)>abs(dy) || abs(dy)<this->icon_s)
- return;
-
- if(this->highlighted)
- for(wr=this->highlighted;wr && wr->type!=widget_table_row;wr=wr->parent);
- if(wr)
- wt=wr->parent;
-
- if(wt && wt->type==widget_table && (wt->state & STATE_SCROLLABLE)) {
- struct table_data *td=wt->data;
- GList *top=NULL;
- GList *btm=NULL;
- GList *ttop, *tbtm;
-
-
-
- if(!wr || !wr->h)
- return;
-
- if(this->current.y < wr->p.y && wr!=td->top_row->data ) {
- int n=(wr->p.y-this->current.y)/wr->h+1;
-
- btm=td->bottom_row;
- top=td->top_row;
-
- while(n-->0 && (tbtm=gui_internal_widget_table_next_row(btm))!=NULL && (ttop=gui_internal_widget_table_next_row(top))!=NULL) {
- top=ttop;
- btm=tbtm;
- if(top->data==wr)
- break;
- }
- this->pressed=2;
- } else if (this->current.y > wr->p.y + wr->h ) {
- int y=wt->p.y+wt->h-wr->h;
- int n;
-
- if(td->scroll_buttons.button_box && td->scroll_buttons.button_box->p.y!=0)
- y=td->scroll_buttons.button_box->p.y - td->scroll_buttons.button_box->h;
-
- if(y>this->current.y)
- y=this->current.y;
-
- n=(y - wr->p.y )/wr->h;
-
- btm=td->bottom_row;
- top=td->top_row;
-
- while(n-->0 && (ttop=gui_internal_widget_table_prev_row(top))!=NULL && (tbtm=gui_internal_widget_table_prev_row(btm))!=NULL) {
- btm=tbtm;
- top=ttop;
- if(btm->data==wr)
- break;
- }
- this->pressed=2;
- }
- if( top && btm && (td->top_row!=top || td->bottom_row!=btm) ) {
- gui_internal_table_hide_rows(wt->data);
- td->top_row=top;
- td->bottom_row=btm;
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_widget_render(this,wt);
- graphics_draw_mode(this->gra, draw_mode_end);
- }
-
- return;
- }
- }
-
- /* Else, just move highlight after pointer if there's nothing to scroll */
- gui_internal_highlight(this);
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void gui_internal_call_highlighted(struct gui_priv *this)
-{
- if (! this->highlighted || ! this->highlighted->func)
- return;
- this->highlighted->reason=gui_internal_reason_click;
- this->highlighted->func(this, this->highlighted, this->highlighted->data);
-}
-
-void
-gui_internal_say(struct gui_priv *this, struct widget *w, int questionmark)
-{
- char *text=w->speech;
- if (! this->speech)
- return;
- if (!text)
- text=w->text;
- if (!text)
- text=w->name;
- if (text) {
- text=g_strdup_printf("%s%c", text, questionmark ? '?':'\0');
- navit_say(this->nav, text);
- g_free(text);
- }
-}
-
-
-
-
-
-void
-gui_internal_back(struct gui_priv *this, struct widget *w, void *data)
-{
- gui_internal_prune_menu_count(this, 1, 1);
-}
-
-void
-gui_internal_cmd_return(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_prune_menu(this, wm->data);
-}
-
-
-
-void
-gui_internal_cmd_main_menu(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w=this->root.children->data;
- if (w && w->menu_data && w->menu_data->href && !strcmp(w->menu_data->href,"#Main Menu"))
- gui_internal_prune_menu(this, w);
- else
- gui_internal_html_main_menu(this);
-}
-
-
-struct widget *
-gui_internal_time_help(struct gui_priv *this)
-{
- struct widget *w,*wc,*wcn;
- char timestr[64];
- struct tm *tm;
- time_t timep;
-
- w=gui_internal_box_new(this, gravity_right_center|orientation_horizontal|flags_fill);
- w->bl=this->spacing;
- w->spx=this->spacing;
- w->spx=10;
- w->bl=10;
- w->br=10;
- w->bt=6;
- w->bb=6;
- if (this->flags & 64) {
- wc=gui_internal_box_new(this, gravity_right_top|orientation_vertical|flags_fill);
- wc->bl=10;
- wc->br=20;
- wc->bt=6;
- wc->bb=6;
- timep=time(NULL);
- tm=localtime(&timep);
- strftime(timestr, 64, "%H:%M %d.%m.%Y", tm);
- wcn=gui_internal_label_new(this, timestr);
- gui_internal_widget_append(wc, wcn);
- gui_internal_widget_append(w, wc);
- }
- if (this->flags & 128) {
- wcn=gui_internal_button_new_with_callback(this, _("Help"), image_new_l(this, "gui_help"), gravity_center|orientation_vertical|flags_fill, NULL, NULL);
- gui_internal_widget_append(w, wcn);
- }
- return w;
-}
-
-
-/**
- * Applies the configuration values to this based on the settings
- * specified in the configuration file (this->config) and
- * the most approriate default profile based on screen resolution.
- *
- * This function should be run after this->root is setup and could
- * be rerun after the window is resized.
- *
- * @author Steve Singer <ssinger_pg@sympatico.ca> (09/2008)
- */
-void
-gui_internal_apply_config(struct gui_priv *this)
-{
- struct gui_config_settings * current_config=0;
-
- dbg(lvl_debug,"w=%d h=%d\n", this->root.w, this->root.h);
- /*
- * Select default values from profile based on the screen.
- */
- if((this->root.w > 320 || this->root.h > 320) && this->root.w > 240 && this->root.h > 240)
- {
- if((this->root.w > 640 || this->root.h > 640) && this->root.w > 480 && this->root.h > 480 )
- {
- current_config = &config_profiles[LARGE_PROFILE];
- }
- else
- {
- current_config = &config_profiles[MEDIUM_PROFILE];
- }
- }
- else
- {
- current_config = &config_profiles[SMALL_PROFILE];
- }
-
- /*
- * Apply override values from config file
- */
- if(this->config.font_size == -1 )
- {
- this->font_size = current_config->font_size;
- }
- else
- {
- this->font_size = this->config.font_size;
- }
-
- if(this->config.icon_xs == -1 )
- {
- this->icon_xs = current_config->icon_xs;
- }
- else
- {
- this->icon_xs = this->config.icon_xs;
- }
-
- if(this->config.icon_s == -1 )
- {
- this->icon_s = current_config->icon_s;
- }
- else
- {
- this->icon_s = this->config.icon_s;
- }
- if(this->config.icon_l == -1 )
- {
- this->icon_l = current_config->icon_l;
- }
- else
- {
- this->icon_l = this->config.icon_l;
- }
- if(this->config.spacing == -1 )
- {
- this->spacing = current_config->spacing;
- }
- else
- {
- this->spacing = current_config->spacing;
- }
- if (!this->fonts[0]) {
- int i,sizes[]={100,66,50};
- for (i = 0 ; i < 3 ; i++) {
- if (this->font_name)
- this->fonts[i]=graphics_named_font_new(this->gra,this->font_name,this->font_size*sizes[i]/100,1);
- else
- this->fonts[i]=graphics_font_new(this->gra,this->font_size*sizes[i]/100,1);
- }
- }
-
-}
-
-
-
-
-
-static void
-gui_internal_cmd_set_destination(struct gui_priv *this, struct widget *wm, void *data)
-{
- char *name=data;
- dbg(lvl_info,"c=%d:0x%x,0x%x\n", wm->c.pro, wm->c.x, wm->c.y);
- navit_set_destination(this->nav, &wm->c, name, 1);
- if (this->flags & 512) {
- struct attr follow;
- follow.type=attr_follow;
- follow.u.num=180;
- navit_set_attr(this->nav, &this->osd_configuration);
- navit_set_attr(this->nav, &follow);
- navit_zoom_to_route(this->nav, 0);
- }
- gui_internal_prune_menu(this, NULL);
-}
-
-static void
-gui_internal_cmd_insert_destination_do(struct gui_priv *this, struct widget *wm, void *data) {
- char *name=data;
- int dstcount=navit_get_destination_count(this->nav)+1;
- int pos,i;
- struct pcoord *dst=g_alloca(dstcount*sizeof(struct pcoord));
- dstcount=navit_get_destinations(this->nav,dst,dstcount);
-
- pos=dstcount-wm->datai;
- if(pos<0)
- pos=0;
-
- for(i=dstcount;i>pos;i--)
- dst[i]=dst[i-1];
-
- dst[pos]=wm->c;
- navit_add_destination_description(this->nav,&wm->c,(char*)data);
- navit_set_destinations(this->nav,dst,dstcount+1,name,1);
- gui_internal_prune_menu(this, NULL);
-}
-
-/*
- * @brief Displays a waypoint list to the user.
- *
- * This display a waypoint list to the user. When the user chooses an item from the list, the callback
- * function passed as {@code cmd} will be called.
- *
- * Widget passed as wm parameter of the called cmd function will have item set to user chosen waypoint item. Its data will be set
- * to zero-based choosen waypoint number, counting from the route end. Coordinates to wm->c will be copied from wm_->c if wm_ is not null. Otherwise,
- * waypoint coordinates will be copied to wm->c.
- *
- * @param this gui context
- * @param title Menu title
- * @param hint Text to display above the waypoint list describing the action to be performed, can be NULL
- * @param wm_ The called widget pointer. Can be NULL.
- * @param cmd Callback function which will be called on item selection
- * @param data data argument to be passed to the callback function
- */
-void
-gui_internal_select_waypoint(struct gui_priv *this, const char *title, const char *hint, struct widget *wm_, void(*cmd)(struct gui_priv *priv, struct widget *widget, void *data),void *data)
-{
- struct widget *wb,*w,*wtable,*row,*wc;
- struct map *map;
- struct map_rect *mr;
- struct item *item;
- char *text;
- int i;
- int dstcount=navit_get_destination_count(this->nav)+1;
-
- map=route_get_map(navit_get_route(this->nav));
- if(!map)
- return;
- mr = map_rect_new(map, NULL);
- if(!mr)
- return;
-
- wb=gui_internal_menu(this, title);
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- if(hint)
- gui_internal_widget_append(w, gui_internal_label_new(this, hint));
- wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- gui_internal_widget_append(w,wtable);
-
- i=0;
- while((item = map_rect_get_item(mr))!=NULL) {
- struct attr attr;
- if(item->type!=type_waypoint && item->type!=type_route_end)
- continue;
- if (item_attr_get(item, attr_label, &attr)) {
- text=g_strdup_printf(_("Waypoint %s"), map_convert_string_tmp(item->map, attr.u.str));
- } else
- continue;
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row, wc=gui_internal_button_new_with_callback(this, text,
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- cmd, data));
- wc->item=*item;
- if(wm_)
- wc->c=wm_->c;
- else {
- struct coord c;
- item_coord_get(item,&c,1);
- wc->c.x=c.x;
- wc->c.y=c.y;
- wc->c.pro=map_projection(item->map);
- }
- i++;
- wc->datai=dstcount-i;
- g_free(text);
- }
- map_rect_destroy(mr);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_insert_destination(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_select_waypoint(this, data, _("Select waypoint to insert the new one before"), wm, gui_internal_cmd_insert_destination_do, data);
-}
-
-
-
-static void
-gui_internal_cmd_set_position(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr v;
- if(data) {
- v.type=attr_vehicle;
- v.u.vehicle=NULL;
- navit_set_attr(this->nav, &v);
- }
- navit_set_position(this->nav, &wm->c);
- gui_internal_prune_menu(this, NULL);
-}
-
-
-
-
-
-
-/**
- * @brief Generic notification function for Editable widgets to call Another widget notification function when Enter is pressed in editable field.
- * The Editable widget should have data member pointing to the Another widget.
- */
-void
-gui_internal_call_linked_on_finish(struct gui_priv *this, struct widget *wm, void *data)
-{
- if (wm->reason==gui_internal_reason_keypress_finish && data) {
- struct widget *w=data;
- if(w->func)
- w->func(this, w, w->data);
- }
-}
-
-struct widget * gui_internal_keyboard(struct gui_priv *this, int mode);
-
-
-struct widget * gui_internal_keyboard_show_native(struct gui_priv *this, struct widget *w, int mode, char *lang);
-
-
-static void
-gui_internal_cmd_delete_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_delete_bookmark(mattr.u.bookmarks,wm->text);
- l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
- gui_internal_prune_menu(this, l->data);
-}
-
-
-
-
-/**
- * Get a utf-8 string, return the same prepared for case insensitive search. Result should be g_free()d after use.
- */
-char *
-removecase(char *s)
-{
- char *r;
- r=linguistics_casefold(s);
- return r;
-}
-
-static void
-gui_internal_cmd_view_on_map(struct gui_priv *this, struct widget *wm, void *data)
-{
- if (wm->item.type != type_none) {
- enum item_type type;
- if (wm->item.type < type_line)
- type=type_selected_point;
- else if (wm->item.type < type_area)
- type=type_selected_point;
- else
- type=type_selected_area;
- graphics_clear_selection(this->gra, NULL);
- graphics_add_selection(this->gra, &wm->item, type, NULL);
- }
- navit_set_center(this->nav, &wm->c, 1);
- gui_internal_prune_menu(this, NULL);
-}
-
-
-static void
-gui_internal_cmd_view_attribute_details(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb;
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- char *text,*url;
- int i;
-
- text=g_strdup_printf("Attribute %s",wm->name);
- wb=gui_internal_menu(this, text);
- g_free(text);
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- mr=map_rect_new(wm->item.map, NULL);
- item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
- for (i = 0 ; i < wm->datai ; i++) {
- item_attr_get(item, attr_any, &attr);
- }
- if (item_attr_get(item, attr_any, &attr)) {
- url=NULL;
- switch (attr.type) {
- case attr_osm_nodeid:
- url=g_strdup_printf("http://www.openstreetmap.org/browse/node/"LONGLONG_FMT"\n",*attr.u.num64);
- break;
- case attr_osm_wayid:
- url=g_strdup_printf("http://www.openstreetmap.org/browse/way/"LONGLONG_FMT"\n",*attr.u.num64);
- break;
- case attr_osm_relationid:
- url=g_strdup_printf("http://www.openstreetmap.org/browse/relation/"LONGLONG_FMT"\n",*attr.u.num64);
- break;
- default:
- break;
- }
- if (url) {
- gui_internal_widget_append(w,
- wb=gui_internal_button_new_with_callback(this, _("View in Browser"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_in_browser, NULL));
- wb->name=url;
- }
- }
- map_rect_destroy(mr);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_view_attributes(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb;
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- char *text;
- int count=0;
-
- dbg(lvl_info,"item=%p 0x%x 0x%x\n", wm->item.map,wm->item.id_hi, wm->item.id_lo);
- wb=gui_internal_menu(this, "Attributes");
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- mr=map_rect_new(wm->item.map, NULL);
- item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
- dbg(lvl_info,"item=%p\n", item);
- if (item) {
- text=g_strdup_printf("%s:%s", _("Item type"), item_to_name(item->type));
- gui_internal_widget_append(w,
- wb=gui_internal_button_new(this, text,
- NULL, gravity_left_center|orientation_horizontal|flags_fill));
- wb->name=g_strdup(text);
- wb->item=wm->item;
- g_free(text);
- while(item_attr_get(item, attr_any, &attr)) {
- char *attrtxt;
- text=g_strdup_printf("%s:%s", attr_to_name(attr.type), attrtxt=attr_to_text(&attr, wm->item.map, 1));
- g_free(attrtxt);
- gui_internal_widget_append(w,
- wb=gui_internal_button_new_with_callback(this, text,
- NULL, gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_attribute_details, NULL));
- wb->name=g_strdup(text);
- wb->item=wm->item;
- wb->datai=count++;
- g_free(text);
- }
- text=g_strdup_printf("%s:0x%x,0x%x", "ID", item->id_hi, item->id_lo);
- gui_internal_widget_append(w,
- wb=gui_internal_button_new(this, text,
- NULL, gravity_left_center|orientation_horizontal|flags_fill));
- wb->name=text;
- wb->item=wm->item;
- }
- map_rect_destroy(mr);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_view_in_browser(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- char *cmd=NULL;
-
- if (!wm->name) {
- dbg(lvl_info,"item=%p 0x%x 0x%x\n", wm->item.map,wm->item.id_hi, wm->item.id_lo);
- mr=map_rect_new(wm->item.map, NULL);
- item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
- dbg(lvl_info,"item=%p\n", item);
- if (item) {
- while(item_attr_get(item, attr_url_local, &attr)) {
- if (! cmd)
- cmd=g_strdup_printf("navit-browser.sh '%s' &",map_convert_string_tmp(item->map,attr.u.str));
- }
- }
- map_rect_destroy(mr);
- } else {
- cmd=g_strdup_printf("navit-browser.sh '%s' &",wm->name);
- }
- if (cmd) {
-#ifdef HAVE_SYSTEM
- system(cmd);
-#else
- dbg(lvl_error,"Error: External commands were disabled during compilation, cannot call '%s'.\n",cmd);
-#endif
- g_free(cmd);
- }
-}
-
-
-/*
- * @brief Transfers search results to a map.
- *
- * @param this The graphics context.
- * @param wm called widget.
- * @param data event data (pointer to the table widget containing results, or NULL to clean the result map without adding any new data).
- */
-static void
-gui_internal_cmd_results_to_map(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w;
- struct mapset *ms;
- struct map *map;
- struct map_rect *mr;
- struct item *item;
- GList *l;
- struct coord_rect r;
- struct attr a;
- int count;
-
- ms=navit_get_mapset(this->nav);
-
- if(!ms)
- return;
-
- map=mapset_get_map_by_name(ms, "search_results");
- if(!map) {
- struct attr *attrs[10], attrmap;
- enum attr_type types[]={attr_position_longitude,attr_position_latitude,attr_label,attr_none};
- int i;
-
- attrs[0]=g_new0(struct attr,1);
- attrs[0]->type=attr_type;
- attrs[0]->u.str="csv";
-
- attrs[1]=g_new0(struct attr,1);
- attrs[1]->type=attr_name;
- attrs[1]->u.str="search_results";
-
- attrs[2]=g_new0(struct attr,1);
- attrs[2]->type=attr_charset;
- attrs[2]->u.str="utf-8";
-
- attrs[3]=g_new0(struct attr,1);
- attrs[3]->type=attr_item_type;
- attrs[3]->u.num=type_found_item;
-
- attrs[4]=g_new0(struct attr,1);
- attrs[4]->type=attr_attr_types;
- attrs[4]->u.attr_types=types;
- attrs[5]=NULL;
-
- attrmap.type=attr_map;
- map=attrmap.u.map=map_new(NULL,attrs);
- if(map)
- mapset_add_attr(ms,&attrmap);
-
- for(i=0;attrs[i];i++)
- g_free(attrs[i]);
-
- }
-
- if(!map)
- return;
-
-
- mr = map_rect_new(map, NULL);
-
- if(!mr)
- return;
-
- /* Clean the map */
- while((item = map_rect_get_item(mr))!=NULL) {
- item_type_set(item,type_none);
- }
-
- this->results_map_population=0;
-
- /* Find the table to pupulate the map */
- for(w=data; w && w->type!=widget_table;w=w->parent);
-
- if(!w) {
- map_rect_destroy(mr);
- dbg(lvl_warning,"Can't find the results table - only map clean up is done.\n");
- return;
- }
-
- /* Populate the map with search results*/
- for(l=w->children, count=0;l;l=g_list_next(l)) {
- struct widget *wr=l->data;
- if(wr->type==widget_table_row) {
- struct widget *wi=wr->children->data;
- struct item* it;
- if(wi->name==NULL)
- continue;
- dbg(lvl_info,"%s\n",wi->name);
- it=map_rect_create_item(mr,type_found_item);
- if(it) {
- struct coord c;
- struct attr a;
- c.x=wi->c.x;
- c.y=wi->c.y;
- item_coord_set(it, &c, 1, change_mode_modify);
- a.type=attr_label;
- a.u.str=wi->name;
- item_attr_set(it, &a, change_mode_modify);
- if(!count++)
- r.lu=r.rl=c;
- else
- coord_rect_extend(&r,&c);
- }
- }
- }
- map_rect_destroy(mr);
- if(!count)
- return;
- a.type=attr_orientation;
- a.u.num=0;
- navit_set_attr(this->nav,&a);
- navit_zoom_to_rect(this->nav,&r);
- gui_internal_prune_menu(this, NULL);
- this->results_map_population=count;
-}
-
-/*
- * @brief Removes search results from a map.
- *
- * @param this The graphics context.
- * @param wm called widget.
- * @param data event data
- */
-static void
-gui_internal_cmd_results_map_clean(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_cmd_results_to_map(this,wm,NULL);
- gui_internal_prune_menu(this, NULL);
- navit_draw(this->nav);
-}
-
-static void
-gui_internal_cmd_delete_waypoint(struct gui_priv *this, struct widget *wm, void *data)
-{
- int dstcount=navit_get_destination_count(this->nav);
- int i;
- struct map_rect *mr;
- struct item *item;
- struct pcoord *dst=g_alloca(dstcount*sizeof(struct pcoord));
- dstcount=navit_get_destinations(this->nav,dst,dstcount);
- mr=map_rect_new(wm->item.map, NULL);
- i=0;
- while((item=map_rect_get_item(mr))!=NULL) {
- struct coord c;
- if(item->type!=type_waypoint && item->type!=type_route_end)
- continue;
- if(item_is_equal_id(*item,wm->item))
- continue;
- item_coord_get_pro(item,&c,1,projection_mg);
- dst[i].x=c.x;
- dst[i].y=c.y;
- dst[i].pro=projection_mg;
- i++;
- }
- map_rect_destroy(mr);
- navit_set_destinations(this->nav,dst,i,NULL,1);
- gui_internal_prune_menu(this, NULL);
-}
-
-
-/**
- * @brief Displays the commands available for a location.
- *
- * This displays the available commands for the given location in a dialog from which the user can
- * choose an action. The location can be supplied either in projected coordinates via the {@code pc_in}
- * argument or in WGS84 coordinates (i.e. latitude and longitude in degrees) via the {@code g_in}
- * argument. One of these must be supplied, the other should be {@code NULL}.
- *
- * @param this The internal GUI instance
- * @param pc_in Projected coordinates of the position
- * @param g_in WGS84 coordinates of the position
- * @param wm
- * @param name The display name for the position
- * @param flags Flags specifying the operations available from the GUI
- */
-/* meaning of the bits in "flags":
- * 1: "Streets"
- * 2: "House numbers"
- * 4: "View in Browser", "View Attributes"
- * 8: "Set as dest."
- * 16: "Set as pos."
- * 32: "Add as bookm."
- * 64: "POIs"
- * 128: "View on Map"
- * 256: POIs around this point, "Drop search results from the map"
- * 512: "Cut/Copy... bookmark"
- * 1024: "Jump to attributes of top item within this->radius pixels of this point (implies flags|=256)"
- * 2048: "Show search results on the map"
- * TODO define constants for these values
- */
-void
-gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, struct coord_geo *g_in, struct widget *wm, const char *name, int flags)
-{
- struct widget *wb,*w,*wtable,*row,*wc,*wbc,*wclosest=NULL;
- struct coord_geo g;
- struct pcoord pc;
- struct coord c;
- char *coord;
-
- if (pc_in) {
- pc=*pc_in;
- c.x=pc.x;
- c.y=pc.y;
- dbg(lvl_info,"x=0x%x y=0x%x\n", c.x, c.y);
- transform_to_geo(pc.pro, &c, &g);
- } else if (g_in) {
- struct attr attr;
- if (!navit_get_attr(this->nav, attr_projection, &attr, NULL))
- return;
- g=*g_in;
- pc.pro=attr.u.projection;
- transform_from_geo(pc.pro, &g, &c);
- pc.x=c.x;
- pc.y=c.y;
- } else
- return;
-
- wb=gui_internal_menu(this, name);
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- coord=gui_internal_coordinates(&pc, ' ');
- gui_internal_widget_append(w, gui_internal_label_new(this, coord));
- g_free(coord);
- wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- gui_internal_widget_append(w,wtable);
-
- if ((flags & 1) && wm) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wc=gui_internal_button_new_with_callback(this, _("Streets"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_search_street_in_town, wm));
- wc->item=wm->item;
- wc->selection_id=wm->selection_id;
- }
- if ((flags & 2) && wm) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wc=gui_internal_button_new_with_callback(this, _("House numbers"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_search_house_number_in_street, wm));
- wc->item=wm->item;
- wc->selection_id=wm->selection_id;
- }
- if ((flags & 4) && wm) {
- struct map_rect *mr;
- struct item *item;
- struct attr attr;
- mr=map_rect_new(wm->item.map, NULL);
- item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
- if (item) {
- if (item_attr_get(item, attr_description, &attr))
- gui_internal_widget_append(w, gui_internal_label_new(this, map_convert_string_tmp(item->map,attr.u.str)));
- if (item_attr_get(item, attr_url_local, &attr)) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wb=gui_internal_button_new_with_callback(this, _("View in Browser"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_in_browser, NULL));
- wb->item=wm->item;
- }
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wb=gui_internal_button_new_with_callback(this, _("View Attributes"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_attributes, NULL));
- wb->item=wm->item;
- }
- map_rect_destroy(mr);
- }
- if (flags & 8) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Set as destination"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_set_destination, g_strdup(name)));
- wbc->data_free=g_free_func;
- wbc->c=pc;
- if(navit_get_destination_count(this->nav)>=1) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Visit before..."),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_insert_destination, g_strdup(name)));
- wbc->data_free=g_free_func;
- wbc->c=pc;
- }
- }
- if (flags & 16) {
- const char *text;
- struct attr vehicle, source;
- int deactivate=0;
- if (navit_get_attr(this->nav, attr_vehicle, &vehicle, NULL) && vehicle.u.vehicle &&
- !(vehicle_get_attr(vehicle.u.vehicle, attr_source, &source, NULL) && source.u.str && !strcmp("demo://",source.u.str)))
- deactivate=1;
-
- text=deactivate? _("Set as position (and deactivate vehicle)") : _("Set as position");
-
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, text,
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_set_position, (void*)(long)deactivate));
- wbc->c=pc;
- }
- if (flags & 32) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Add as bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_add_bookmark2, g_strdup(name)));
- wbc->data_free=g_free_func;
- wbc->c=pc;
- }
-#ifndef _MSC_VER
-//POIs are not operational under MSVC yet
- if (flags & 64) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("POIs"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_pois, NULL));
- wbc->c=pc;
- }
-#endif /* _MSC_VER */
-#if 0
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- gui_internal_button_new(this, "Add to tour",
- image_new_o(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill));
-#endif
- if (flags & 128) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("View on map"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_view_on_map, NULL));
- wbc->c=pc;
- if ((flags & 4) && wm)
- wbc->item=wm->item;
- else
- wbc->item.type=type_none;
- }
- if(flags & 256 && this->results_map_population) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Remove search results from the map"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_results_map_clean, NULL));
- wbc->data=wm;
- }
- if(flags & 2048) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Show results on the map"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_results_to_map, NULL));
- wbc->data=wm;
- }
- if ((flags & 256) || (flags & 1024)) {
- struct displaylist_handle *dlh;
- struct displaylist *display;
- struct attr attr;
- struct point p;
- struct transformation *trans;
-
- char *text;
- struct map_selection *sel;
- GList *l, *ll;
-
- c.x=pc.x;
- c.y=pc.y;
-
- trans=navit_get_trans(this->nav);
- transform(trans,pc.pro,&c,&p,1,0,0,0);
- display=navit_get_displaylist(this->nav);
- dlh=graphics_displaylist_open(display);
- sel=displaylist_get_selection(display);
- l=displaylist_get_clicked_list(display, &p, this->radius);
- for(ll=l;ll;ll=g_list_next(ll)) {
- struct displayitem *di;
- struct item *item;
- struct map_rect *mr;
- struct item *itemo;
-
- di=(struct displayitem*)ll->data;
- item=graphics_displayitem_get_item(di);
-
- mr=map_rect_new(item->map, sel);
- itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- if(!itemo) {
- map_rect_destroy(mr);
- continue;
- }
- if (item_attr_get(itemo, attr_label, &attr)) {
- text=g_strdup(map_convert_string_tmp(itemo->map, attr.u.str));
- } else
- text=g_strdup(item_to_name(item->type));
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row, wc=gui_internal_cmd_pois_item(this, NULL, itemo, NULL, NULL, -1, text));
- wc->c=pc;
- g_free(wc->name);
- wc->name=g_strdup(text);
- wc->item=*itemo;
- g_free(text);
- map_rect_destroy(mr);
- if(!wclosest)
- wclosest=wc;
-
- }
- g_list_free(l);
- map_selection_destroy(sel);
- graphics_displaylist_close(dlh);
- }
- if (flags & 512) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Cut Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_cut_bookmark, NULL));
- wbc->text=g_strdup(wm->text);
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Copy Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_copy_bookmark, NULL));
- wbc->text=g_strdup(wm->text);
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Rename Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_rename_bookmark, NULL));
- wbc->text=g_strdup(wm->text);
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Paste Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_paste_bookmark, NULL));
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Delete Bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_delete_bookmark, NULL));
- wbc->text=g_strdup(wm->text);
- }
-
- if (wm && (wm->item.type==type_waypoint || wm->item.type==type_route_end)) {
- gui_internal_widget_append(wtable,row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- wbc=gui_internal_button_new_with_callback(this, _("Delete waypoint"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_delete_waypoint, NULL));
- wbc->item=wm->item;
- }
-
- gui_internal_menu_render(this);
-
- if((flags & 1024) && wclosest)
- gui_internal_cmd_view_attributes(this,wclosest,wclosest->data);
-}
-
-
-/* wm->data: 0 Nothing special
- 1 Map Point
- 2 Item
- 3 Town
- 4 County
- 5 Street
- 6 House number
- 7 Bookmark
- 8 Former destination
- 9 Item from the POI list
-*/
-
-void
-gui_internal_cmd_position(struct gui_priv *this, struct widget *wm, void *data)
-{
- int flags;
-
- if(!data)
- data=wm->data;
-
- switch ((long) data) {
- case 0:
- flags=8|16|32|64|128|256;
- break;
- case 1:
- flags=8|16|32|64|256;
- break;
- case 2:
- flags=4|8|16|32|64|128;
- break;
- case 3:
- flags=1|4|8|16|32|64|128|2048;
- flags &= this->flags_town;
- break;
- case 4:
- gui_internal_search_town_in_country(this, wm);
- return;
- case 5:
- flags=2|8|16|32|64|128|2048;
- flags &= this->flags_street;
- break;
- case 6:
- flags=8|16|32|64|128|2048;
- flags &= this->flags_house_number;
- break;
- case 7:
- flags=8|16|64|128|512;
- break;
- case 8:
- flags=8|16|32|64|128;
- break;
- case 9:
- flags=4|8|16|32|64|128|2048;
- break;
- default:
- return;
- }
- switch (flags) {
- case 2:
- gui_internal_search_house_number_in_street(this, wm, NULL);
- return;
- case 8:
- gui_internal_cmd_set_destination(this, wm, NULL);
- return;
- }
- gui_internal_cmd_position_do(this, &wm->c, NULL, wm, wm->name ? wm->name : wm->text, flags);
-}
-
-
-
-
-
-/**
- * The "Bookmarks" section of the OSD
- *
- */
-void
-gui_internal_cmd_bookmarks(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr attr,mattr;
- struct item *item;
- char *label_full,*prefix=0;
- int plen=0,hassub,found=0;
- struct widget *wb,*w,*wbm;
- struct coord c;
- struct widget *tbl, *row;
-
- if (data)
- prefix=g_strdup(data);
- else {
- if (wm && wm->prefix)
- prefix=g_strdup(wm->prefix);
- }
- if ( prefix )
- plen=strlen(prefix);
-
- gui_internal_prune_menu_count(this, 1, 0);
- wb=gui_internal_menu(this, _("Bookmarks"));
- wb->background=this->background;
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- //w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
-
- if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
- if (!plen) {
- bookmarks_move_root(mattr.u.bookmarks);
- } else {
- if (!strcmp(prefix,"..")) {
- bookmarks_move_up(mattr.u.bookmarks);
- g_free(prefix);
- prefix=g_strdup(bookmarks_item_cwd(mattr.u.bookmarks));
- if (prefix) {
- plen=strlen(prefix);
- } else {
- plen=0;
- }
- } else {
- bookmarks_move_down(mattr.u.bookmarks,prefix);
- }
-
- // "Back" button, when inside a bookmark folder
-
- if (plen) {
- wbm=gui_internal_button_new_with_callback(this, "..",
- image_new_xs(this, "gui_inactive"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_bookmarks, NULL);
- wbm->prefix=g_strdup("..");
- gui_internal_widget_append(w, wbm);
-
- // load bookmark folder as Waypoints, if any
- if (bookmarks_get_bookmark_count(mattr.u.bookmarks) > 0){
- wbm=gui_internal_button_new_with_callback(this, _("Bookmarks as waypoints"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_load_bookmarks_as_waypoints, NULL);
- wbm->prefix=g_strdup(prefix);
- gui_internal_widget_append(w, wbm);
- }
-
- // save Waypoints in bookmark folder, if route exists
- if (navit_get_destination_count(this->nav) > 0){
- if (bookmarks_get_bookmark_count(mattr.u.bookmarks)==0){
- wbm=gui_internal_button_new_with_callback(this, _("Save waypoints"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_replace_bookmarks_from_waypoints, NULL);
- }else{
- wbm=gui_internal_button_new_with_callback(this, _("Replace with waypoints"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_replace_bookmarks_from_waypoints, NULL);
- }
- wbm->prefix=g_strdup(prefix);
- gui_internal_widget_append(w, wbm);
- }
-
- // delete empty folder
- if (bookmarks_get_bookmark_count(mattr.u.bookmarks)==0){
- gui_internal_widget_append(w,
- wbm=gui_internal_button_new_with_callback(this, _("Delete Folder"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_delete_bookmark_folder, NULL));
- wbm->prefix=g_strdup(prefix);
- }
-
- }
- }
-
- // Adds the Bookmark folders
- wbm=gui_internal_button_new_with_callback(this, _("Add Bookmark folder"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_add_bookmark_folder2, NULL);
- gui_internal_widget_append(w, wbm);
-
- // Pastes the Bookmark
- wbm=gui_internal_button_new_with_callback(this, _("Paste bookmark"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_paste_bookmark, NULL);
- gui_internal_widget_append(w, wbm);
-
- bookmarks_item_rewind(mattr.u.bookmarks);
-
- tbl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- gui_internal_widget_append(w,tbl);
-
- while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
- if (!item_attr_get(item, attr_label, &attr)) continue;
- label_full=map_convert_string_tmp(item->map,attr.u.str);
- dbg(lvl_info,"full_labled: %s\n",label_full);
-
- // hassub == 1 if the item type is a sub-folder
- if (item->type == type_bookmark_folder) {
- hassub=1;
- } else {
- hassub=0;
- }
-
- row=gui_internal_widget_table_row_new(this,gravity_left| flags_fill| orientation_horizontal);
- gui_internal_widget_append(tbl, row);
- wbm=gui_internal_button_new_with_callback(this, label_full,
- image_new_xs(this, hassub ? "gui_inactive" : "gui_active" ), gravity_left_center|orientation_horizontal|flags_fill,
- hassub ? gui_internal_cmd_bookmarks : gui_internal_cmd_position, NULL);
-
- gui_internal_widget_append(row,wbm);
- if (item_coord_get(item, &c, 1)) {
- wbm->c.x=c.x;
- wbm->c.y=c.y;
- wbm->c.pro=bookmarks_get_projection(mattr.u.bookmarks);
- wbm->name=g_strdup_printf(_("Bookmark %s"),label_full);
- wbm->text=g_strdup(label_full);
- if (!hassub) {
- wbm->data=(void*)7;//Mark us as a bookmark
- }
- wbm->prefix=g_strdup(label_full);
- } else {
- gui_internal_widget_destroy(this, row);
- }
- }
- }
-
- g_free(prefix);
-
- if (found)
- gui_internal_check_exit(this);
- else
- gui_internal_menu_render(this);
-}
-
-
-
-
-static void
-gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int rotary);
-
-static int
-gui_internal_keynav_find_next(struct widget *wi, struct widget *current_highlight, struct widget **result);
-
-static int
-gui_internal_keynav_find_prev(struct widget *wi, struct widget *current_highlight, struct widget **result);
-
-static struct widget*
-gui_internal_keynav_find_next_sensitive_child(struct widget *wi);
-
-void
-gui_internal_keypress_do(struct gui_priv *this, char *key)
-{
- struct widget *wi,*menu,*search_list;
- int len=0;
- char *text=NULL;
-
- menu=g_list_last(this->root.children)->data;
- wi=gui_internal_find_widget(menu, NULL, STATE_EDIT);
- if (wi) {
- /* select first item of the searchlist */
- if (*key == NAVIT_KEY_RETURN) {
- search_list=gui_internal_menu_data(this)->search_list;
- if(search_list) {
- GList *l=gui_internal_widget_table_top_row(this, search_list);
- if (l && l->data) {
- struct widget *w=l->data;
- this->current.x=w->p.x+w->w/2;
- this->current.y=w->p.y+w->h/2;
- gui_internal_highlight(this);
- }
- } else {
- wi->reason=gui_internal_reason_keypress_finish;
- wi->func(this, wi, wi->data);
- }
- return;
- } else if (*key == NAVIT_KEY_BACKSPACE) {
- dbg(lvl_debug,"backspace\n");
- if (wi->text && wi->text[0]) {
- len=g_utf8_prev_char(wi->text+strlen(wi->text))-wi->text;
- wi->text[len]='\0';
- text=g_strdup(wi->text);
- }
- } else {
- if (wi->state & STATE_CLEAR) {
- dbg(lvl_info,"wi->state=0x%x\n", wi->state);
- g_free(wi->text);
- wi->text=NULL;
- wi->state &= ~STATE_CLEAR;
- dbg(lvl_info,"wi->state=0x%x\n", wi->state);
- }
- text=g_strdup_printf("%s%s", wi->text ? wi->text : "", key);
-
- gui_internal_keyboard_to_lower_case(this);
- }
- g_free(wi->text);
- wi->text=text;
-
- if(!wi->text || !*wi->text)
- gui_internal_keyboard_to_upper_case(this);
-
- if (wi->func) {
- wi->reason=gui_internal_reason_keypress;
- wi->func(this, wi, wi->data);
- }
- gui_internal_widget_render(this, wi);
- }
-}
-
-
-
-
-char *
-gui_internal_cmd_match_expand(char *pattern, struct attr **in)
-{
- char p,*ret=g_strdup(pattern),*r=ret,*a;
- int len;
- while ((p=*pattern++)) {
- switch (p) {
- case '*':
- *r='\0';
- a=attr_to_text(*in++,NULL,0);
- len=strlen(ret)+strlen(a)+strlen(pattern)+1;
- r=g_malloc(len);
- strcpy(r, ret);
- strcat(r, a);
- g_free(ret);
- g_free(a);
- ret=r;
- r=ret+strlen(ret);
- break;
- case '\\':
- p=*pattern++;
- default:
- *r++=p;
- }
- }
- *r++='\0';
- return ret;
-}
-
-static int
-gui_internal_match(const char *pattern, const char *string)
-{
- char p,s;
- while ((p=*pattern++)) {
- switch (p) {
- case '*':
- while ((s=*string)) {
- if (gui_internal_match(pattern,string))
- return 1;
- string++;
- }
- break;
- case '\\':
- p=*pattern++;
- default:
- if (*string++ != p)
- return 0;
- }
- }
- return 1;
-}
-
-int
-gui_internal_set(char *remove, char *add)
-{
- char *gui_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal.txt", NULL);
- char *gui_file_new=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal_new.txt", NULL);
- FILE *fo=fopen(gui_file_new,"w");
- FILE *fi=fopen(gui_file,"r");
- char *line=NULL;
- int ret;
- size_t size=0;
- if (fi != NULL){
- while (getline(&line,&size,fi) > 0) {
- int len=strlen(line);
- if (len > 0 && line[len-1] == '\n')
- line[len-1]='\0';
- dbg(lvl_debug,"line=%s\n",line);
- if (!gui_internal_match(remove, line))
- fprintf(fo,"%s\n",line);
- }
- if (line)
- free(line);
- fclose(fi);
- }
- if (add)
- fprintf(fo,"%s;\n",add);
- fclose(fo);
- unlink(gui_file);
- ret=(rename(gui_file_new, gui_file)==0);
- g_free(gui_file_new);
- g_free(gui_file);
-
- return ret;
-}
-
-
-
-static void
-gui_internal_window_closed(struct gui_priv *this)
-{
- gui_internal_cmd2_quit(this, NULL, NULL, NULL, NULL);
-}
-
-
-static void
-gui_internal_cmd_map_download_do(struct gui_priv *this, struct widget *wm, void *data)
-{
- char *text=g_strdup_printf(_("Download %s"),wm->name);
- struct widget *w, *wb;
- struct map *map=data;
- double bllon,bllat,trlon,trlat;
-
- wb=gui_internal_menu(this, text);
- g_free(text);
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
- if (sscanf(wm->prefix,"%lf,%lf,%lf,%lf",&bllon,&bllat,&trlon,&trlat) == 4) {
- struct coord_geo g;
- struct map_selection sel;
- struct map_rect *mr;
- struct item *item;
-
- sel.next=NULL;
- sel.order=255;
- g.lng=bllon;
- g.lat=trlat;
- transform_from_geo(projection_mg, &g, &sel.u.c_rect.lu);
- g.lng=trlon;
- g.lat=bllat;
- transform_from_geo(projection_mg, &g, &sel.u.c_rect.rl);
- sel.range.min=type_none;
- sel.range.max=type_last;
- mr=map_rect_new(map, &sel);
- while ((item=map_rect_get_item(mr))) {
- dbg(lvl_info,"item\n");
- }
- map_rect_destroy(mr);
- }
-
- dbg(lvl_info,"bbox=%s\n",wm->prefix);
- gui_internal_menu_render(this);
-}
-
-void
-gui_internal_cmd_map_download(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr on, off, download_enabled, download_disabled;
- struct widget *w,*wb,*wma;
- struct map *map=data;
- FILE *f;
- char *search,buffer[256];
- int found,sp_match=0;
-
- dbg(lvl_debug,"wm=%p prefix=%s\n",wm,wm->prefix);
-
- search=wm->prefix;
- if (search) {
- found=0;
- while(search[sp_match] == ' ')
- sp_match++;
- sp_match++;
- } else {
- found=1;
- }
- on.type=off.type=attr_active;
- on.u.num=1;
- off.u.num=0;
- wb=gui_internal_menu(this, wm->name?wm->name:_("Map Download"));
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
- if (!search) {
- wma=gui_internal_button_map_attr_new(this, _("Active"), gravity_left_center|orientation_horizontal|flags_fill, map, &on, &off, 1);
- gui_internal_widget_append(w, wma);
- }
-
- download_enabled.type=download_disabled.type=attr_update;
- download_enabled.u.num=1;
- download_disabled.u.num=0;
- wma=gui_internal_button_map_attr_new(this
- , _("Download Enabled")
- , gravity_left_center|orientation_horizontal|flags_fill
- , map
- , &download_enabled
- , &download_disabled
- , 0);
- gui_internal_widget_append(w, wma);
-
-
- f=fopen("maps/areas.tsv","r");
- while (f && fgets(buffer, sizeof(buffer), f)) {
- char *nl,*description,*description_size,*bbox,*size=NULL;
- int sp=0;
- if ((nl=strchr(buffer,'\n')))
- *nl='\0';
- if ((nl=strchr(buffer,'\r')))
- *nl='\0';
- while(buffer[sp] == ' ')
- sp++;
- if ((bbox=strchr(buffer,'\t')))
- *bbox++='\0';
- if (bbox && (size=strchr(bbox,'\t')))
- *size++='\0';
- if (search && !strcmp(buffer, search)) {
- wma=gui_internal_button_new_with_callback(this, _("Download completely"), NULL,
- gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download_do, map);
- wma->name=g_strdup(buffer+sp);
- wma->prefix=g_strdup(bbox);
- gui_internal_widget_append(w, wma);
- found=1;
- } else if (sp < sp_match)
- found=0;
- if (sp == sp_match && found && buffer[sp]) {
- description=g_strdup(buffer+sp);
- if (size)
- description_size=g_strdup_printf("%s (%s)",description,size);
- else
- description_size=g_strdup(description);
- wma=gui_internal_button_new_with_callback(this, description_size, NULL,
- gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download, map);
- g_free(description_size);
- wma->prefix=g_strdup(buffer);
- wma->name=description;
- gui_internal_widget_append(w, wma);
- }
- }
-
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_set_active_vehicle(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr vehicle = {attr_vehicle,{wm->data}};
- navit_set_attr(this->nav, &vehicle);
-}
-
-static void
-gui_internal_cmd_show_satellite_status(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb,*row;
- struct attr attr,sat_attr;
- struct vehicle *v=wm->data;
- char *str;
- int i;
- enum attr_type types[]={attr_sat_prn, attr_sat_elevation, attr_sat_azimuth, attr_sat_snr};
-
- wb=gui_internal_menu(this, _("Show Satellite Status"));
- gui_internal_menu_data(this)->redisplay=gui_internal_cmd_show_satellite_status;
- gui_internal_menu_data(this)->redisplay_widget=wm;
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- w = gui_internal_widget_table_new(this,gravity_center | orientation_vertical | flags_expand | flags_fill, 0);
- row = gui_internal_widget_table_row_new(this,gravity_left_top);
- gui_internal_widget_append(row, gui_internal_label_new(this, " PRN "));
- gui_internal_widget_append(row, gui_internal_label_new(this, _(" Elevation ")));
- gui_internal_widget_append(row, gui_internal_label_new(this, _(" Azimuth ")));
- gui_internal_widget_append(row, gui_internal_label_new(this, " SNR "));
- gui_internal_widget_append(w,row);
- while (vehicle_get_attr(v, attr_position_sat_item, &attr, NULL)) {
- row = gui_internal_widget_table_row_new(this,gravity_left_top);
- for (i = 0 ; i < sizeof(types)/sizeof(enum attr_type) ; i++) {
- if (item_attr_get(attr.u.item, types[i], &sat_attr))
- str=g_strdup_printf("%ld", sat_attr.u.num);
- else
- str=g_strdup("");
- gui_internal_widget_append(row, gui_internal_label_new(this, str));
- g_free(str);
- }
- gui_internal_widget_append(w,row);
- }
- gui_internal_widget_append(wb, w);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd_show_nmea_data(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb;
- struct attr attr;
- struct vehicle *v=wm->data;
- wb=gui_internal_menu(this, _("Show NMEA Data"));
- gui_internal_menu_data(this)->redisplay=gui_internal_cmd_show_nmea_data;
- gui_internal_menu_data(this)->redisplay_widget=wm;
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- if (vehicle_get_attr(v, attr_position_nmea, &attr, NULL))
- gui_internal_widget_append(w, gui_internal_text_new(this, attr.u.str, gravity_left_center|orientation_vertical));
- gui_internal_menu_render(this);
-}
-
-/**
- * A container to hold the selected vehicle and the desired profile in
- * one data item.
- */
-struct vehicle_and_profilename {
- struct vehicle *vehicle;
- char *profilename;
-};
-
-/**
- * Figures out whether the given vehicle is the active vehicle.
- *
- * @return true if the vehicle is active, false otherwise.
- */
-static int
-gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle
- *vehicle)
-{
- struct attr active_vehicle;
-
- if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
- active_vehicle.u.vehicle=NULL;
-
- return active_vehicle.u.vehicle == vehicle;
-}
-
-static void
-save_vehicle_xml(struct vehicle *v)
-{
- struct attr attr;
- struct attr_iter *iter=vehicle_attr_iter_new();
- int childs=0;
- printf("<vehicle");
- while (vehicle_get_attr(v, attr_any_xml, &attr, iter)) {
- if (ATTR_IS_OBJECT(attr.type))
- childs=1;
- else {
- char *attrtxt;
- printf(" %s=\"%s\"",attr_to_name(attr.type),attrtxt=attr_to_text(&attr, NULL, 1));
- g_free(attrtxt);
- }
- }
- if (childs) {
- printf(">\n");
- printf("</vehicle>\n");
- } else
- printf(" />\n");
- vehicle_attr_iter_destroy(iter);
-}
-
-
-/**
- * Reacts to a button press that changes a vehicle's active profile.
- *
- * @see gui_internal_add_vehicle_profile
- */
-static void
-gui_internal_cmd_set_active_profile(struct gui_priv *this, struct
- widget *wm, void *data)
-{
- struct vehicle_and_profilename *vapn = data;
- struct vehicle *v = vapn->vehicle;
- char *profilename = vapn->profilename;
- struct attr vehicle_name_attr;
- char *vehicle_name = NULL;
- struct attr profilename_attr;
- struct attr vehicle;
-
- // Get the vehicle name
- vehicle_get_attr(v, attr_name, &vehicle_name_attr, NULL);
- vehicle_name = vehicle_name_attr.u.str;
-
- dbg(lvl_debug, "Changing vehicle %s to profile %s\n", vehicle_name,
- profilename);
-
- // Change the profile name
- profilename_attr.type = attr_profilename;
- profilename_attr.u.str = profilename;
- if(!vehicle_set_attr(v, &profilename_attr)) {
- dbg(lvl_error, "Unable to set the vehicle's profile name\n");
- }
-
- navit_set_vehicleprofile_name(this->nav,profilename);
-
- save_vehicle_xml(v);
-
- // Notify Navit that the routing should be re-done if this is the
- // active vehicle.
- if (gui_internal_is_active_vehicle(this, v)) {
- vehicle.u.vehicle=v;
- }
- else {
-
- vehicle.u.vehicle=NULL;
- }
-
- vehicle.type=attr_vehicle;
- navit_set_attr(this->nav, &vehicle);
-
-
- gui_internal_prune_menu_count(this, 1, 0);
- gui_internal_menu_vehicle_settings(this, v, vehicle_name);
-}
-
-/**
- * Adds the vehicle profile to the GUI, allowing the user to pick a
- * profile for the currently selected vehicle.
- */
-static void
-gui_internal_add_vehicle_profile(struct gui_priv *this, struct widget
- *parent, struct vehicle *v, struct vehicleprofile *profile)
-{
- // Just here to show up in the translation file, nice and close to
- // where the translations are actually used.
- struct attr profile_attr;
- struct attr *attr = NULL;
- char *name = NULL;
- char *active_profile = NULL;
- char *label = NULL;
- int active;
- struct vehicle_and_profilename *context = NULL;
-
-#ifdef ONLY_FOR_TRANSLATION
- char *translations[] = {_n("car"), _n("bike"), _n("pedestrian")};
-#endif
-
- // Figure out the profile name
- attr = attr_search(profile->attrs, NULL, attr_name);
- if (!attr) {
- dbg(lvl_error, "Adding vehicle profile failed. attr==NULL");
- return;
- }
- name = attr->u.str;
-
- // Determine whether the profile is the active one
- if (vehicle_get_attr(v, attr_profilename, &profile_attr, NULL))
- active_profile = profile_attr.u.str;
- active = active_profile != NULL && !strcmp(name, active_profile);
-
- dbg(lvl_debug, "Adding vehicle profile %s, active=%s/%i\n", name,
- active_profile, active);
-
- // Build a translatable label.
- if(active) {
- label = g_strdup_printf(_("Current profile: %s"), _(name));
- } else {
- label = g_strdup_printf(_("Change profile to: %s"), _(name));
- }
-
- // Create the context object (the vehicle and the desired profile)
- context = g_new0(struct vehicle_and_profilename, 1);
- context->vehicle = v;
- context->profilename = name;
-
- // Add the button
- gui_internal_widget_append(parent,
- gui_internal_button_new_with_callback(
- this, label,
- image_new_xs(this, active ? "gui_active" : "gui_inactive"),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_set_active_profile, context));
-
- free(label);
-}
-
-void
-gui_internal_menu_vehicle_settings(struct gui_priv *this, struct vehicle *v, char *name)
-{
- struct widget *w,*wb,*row;
- struct attr attr;
- struct vehicleprofile *profile = NULL;
- GList *profiles;
-
- wb=gui_internal_menu(this, name);
- w=gui_internal_widget_table_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill,1);
- gui_internal_widget_append(wb, w);
-
- // Add the "Set as active" button if this isn't the active
- // vehicle.
- if (!gui_internal_is_active_vehicle(this, v)) {
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- gui_internal_button_new_with_callback(this, _("Set as active"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_set_active_vehicle, v));
- }
-
- if (vehicle_get_attr(v, attr_position_sat_item, &attr, NULL)) {
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- gui_internal_button_new_with_callback(this, _("Show Satellite status"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_show_satellite_status, v));
- }
- if (vehicle_get_attr(v, attr_position_nmea, &attr, NULL)) {
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row,
- gui_internal_button_new_with_callback(this, _("Show NMEA data"),
- image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_show_nmea_data, v));
- }
-
- // Add all the possible vehicle profiles to the menu
- profiles = navit_get_vehicleprofiles(this->nav);
- while(profiles) {
- profile = (struct vehicleprofile *)profiles->data;
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_add_vehicle_profile(this, row, v, profile);
- profiles = g_list_next(profiles);
- }
-
- callback_list_call_attr_2(this->cbl, attr_vehicle, w, v);
- gui_internal_menu_render(this);
-}
-
-void
-gui_internal_cmd_vehicle_settings(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_menu_vehicle_settings(this, wm->data, wm->text);
-}
-
-
-
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void gui_internal_motion(void *data, struct point *p)
-{
-
- struct gui_priv *this=data;
- if (!this->root.children) {
- navit_handle_motion(this->nav, p);
- return;
- }
- if (!this->pressed)
- return;
- this->current=*p;
- if(!this->motion_timeout_callback)
- this->motion_timeout_callback=callback_new_1(callback_cast(gui_internal_motion_cb), this);
- if(!this->motion_timeout_event)
- this->motion_timeout_event=event_add_timeout(30,0, this->motion_timeout_callback);
-}
-
-void
-gui_internal_evaluate(struct gui_priv *this, const char *command)
-{
- if (command)
- command_evaluate(&this->self, command);
-}
-
-
-void
-gui_internal_enter(struct gui_priv *this, int ignore)
-{
- struct graphics *gra=this->gra;
- if (ignore != -1)
- this->ignore_button=ignore;
-
- navit_block(this->nav, 1);
- graphics_overlay_disable(gra, 1);
- this->root.p.x=0;
- this->root.p.y=0;
- this->root.background=this->background;
-}
-
-void
-gui_internal_leave(struct gui_priv *this)
-{
- graphics_draw_mode(this->gra, draw_mode_end);
-}
-
-void
-gui_internal_set_click_coord(struct gui_priv *this, struct point *p)
-{
- struct coord c;
- struct coord_geo g;
- struct attr attr;
- struct transformation *trans;
- attr_free(this->click_coord_geo);
- this->click_coord_geo=NULL;
- if (p) {
- trans=navit_get_trans(this->nav);
- transform_reverse(trans, p, &c);
- dbg(lvl_debug,"x=0x%x y=0x%x\n", c.x, c.y);
- this->clickp.pro=transform_get_projection(trans);
- this->clickp.x=c.x;
- this->clickp.y=c.y;
- transform_to_geo(this->clickp.pro, &c, &g);
- attr.u.coord_geo=&g;
- attr.type=attr_click_coord_geo;
- this->click_coord_geo=attr_dup(&attr);
- }
-}
-
-static void
-gui_internal_set_position_coord(struct gui_priv *this)
-{
- struct transformation *trans;
- struct attr attr,attrp;
- struct coord c;
-
- attr_free(this->position_coord_geo);
- this->position_coord_geo=NULL;
- if (navit_get_attr(this->nav, attr_vehicle, &attr, NULL) && attr.u.vehicle
- && vehicle_get_attr(attr.u.vehicle, attr_position_coord_geo, &attrp, NULL)) {
- trans=navit_get_trans(this->nav);
- this->position_coord_geo=attr_dup(&attrp);
- this->vehiclep.pro=transform_get_projection(trans);
- transform_from_geo(this->vehiclep.pro, attrp.u.coord_geo, &c);
- this->vehiclep.x=c.x;
- this->vehiclep.y=c.y;
- }
-}
-
-void
-gui_internal_enter_setup(struct gui_priv *this)
-{
- if (!this->mouse_button_clicked_on_map)
- gui_internal_set_position_coord(this);
-}
-
-void
-gui_internal_cmd_menu(struct gui_priv *this, int ignore, char *href)
-{
- dbg(lvl_debug,"enter\n");
- gui_internal_enter(this, ignore);
- gui_internal_enter_setup(this);
- // draw menu
- if (href)
- gui_internal_html_load_href(this, href, 0);
- else
- gui_internal_html_main_menu(this);
-}
-
-
-
-static void
-gui_internal_cmd_log_do(struct gui_priv *this, struct widget *widget)
-{
- if (widget->text && strlen(widget->text)) {
- if (this->position_coord_geo)
- navit_textfile_debug_log_at(this->nav, &this->vehiclep, "type=log_entry label=\"%s\"",widget->text);
- else
- navit_textfile_debug_log(this->nav, "type=log_entry label=\"%s\"",widget->text);
- }
- g_free(widget->text);
- widget->text=NULL;
- gui_internal_prune_menu(this, NULL);
- gui_internal_check_exit(this);
-}
-
-void
-gui_internal_cmd_log_clicked(struct gui_priv *this, struct widget *widget, void *data)
-{
- gui_internal_cmd_log_do(this, widget->data);
-}
-
-
-void
-gui_internal_check_exit(struct gui_priv *this)
-{
- struct graphics *gra=this->gra;
- if (! this->root.children) {
- gui_internal_search_idle_end(this);
- gui_internal_search_list_destroy(this);
- graphics_overlay_disable(gra, 0);
- if (!navit_block(this->nav, 0)) {
- if (this->redraw)
- navit_draw(this->nav);
- else
- navit_draw_displaylist(this->nav);
- }
- }
-}
-
-static int
-gui_internal_get_attr(struct gui_priv *this, enum attr_type type, struct attr *attr)
-{
- switch (type) {
- case attr_active:
- attr->u.num=this->root.children != NULL;
- break;
- case attr_click_coord_geo:
- if (!this->click_coord_geo)
- return 0;
- *attr=*this->click_coord_geo;
- break;
- case attr_position_coord_geo:
- if (!this->position_coord_geo)
- return 0;
- *attr=*this->position_coord_geo;
- break;
- case attr_pitch:
- attr->u.num=this->pitch;
- break;
- case attr_button:
- attr->u.num=this->mouse_button_clicked_on_map;
- break;
- case attr_navit:
- attr->u.navit=this->nav;
- break;
- case attr_fullscreen:
- attr->u.num=(this->fullscreen > 0);
- break;
- default:
- return 0;
- }
- attr->type=type;
- return 1;
-}
-
-static int
-gui_internal_add_attr(struct gui_priv *this, struct attr *attr)
-{
- switch (attr->type) {
- case attr_xml_text:
- g_free(this->html_text);
- this->html_text=g_strdup(attr->u.str);
- return 1;
- default:
- return 0;
- }
-}
-
-static int
-gui_internal_set_attr(struct gui_priv *this, struct attr *attr)
-{
- switch (attr->type) {
- case attr_fullscreen:
- if ((this->fullscreen > 0) != (attr->u.num > 0)) {
- graphics_draw_mode(this->gra, draw_mode_end);
- this->win->fullscreen(this->win, attr->u.num > 0);
- graphics_draw_mode(this->gra, draw_mode_begin);
- }
- this->fullscreen=attr->u.num;
- return 1;
- case attr_menu_on_map_click:
- this->menu_on_map_click=attr->u.num;
- return 1;
- case attr_on_map_click:
- g_free(this->on_map_click);
- this->on_map_click=g_strdup(attr->u.str);
- return 1;
- default:
- dbg(lvl_error,"Unknown attribute: %s\n",attr_to_name(attr->type));
- return 1;
- }
-}
-
-static void gui_internal_dbus_signal(struct gui_priv *this, struct point *p)
-{
- struct displaylist_handle *dlh;
- struct displaylist *display;
- struct displayitem *di;
- struct attr cb,**attr_list=NULL;
- int valid=0;
-
- display=navit_get_displaylist(this->nav);
- dlh=graphics_displaylist_open(display);
- while ((di=graphics_displaylist_next(dlh))) {
- struct item *item=graphics_displayitem_get_item(di);
- if (item_is_point(*item) && graphics_displayitem_get_displayed(di) &&
- graphics_displayitem_within_dist(display, di, p, this->radius)) {
- struct map_rect *mr=map_rect_new(item->map, NULL);
- struct item *itemo=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- struct attr attr;
- if (itemo && item_attr_get(itemo, attr_data, &attr))
- attr_list=attr_generic_add_attr(attr_list, &attr);
- map_rect_destroy(mr);
- }
- }
- graphics_displaylist_close(dlh);
- if (attr_list && navit_get_attr(this->nav, attr_callback_list, &cb, NULL))
- callback_list_call_attr_4(cb.u.callback_list, attr_command, "dbus_send_signal", attr_list, NULL, &valid);
- attr_list_free(attr_list);
-}
-
-/**
- * @brief Converts one geo coordinate in human readable form to double value.
- *
- * @author Martin Bruns (05/2012), mdankov
- */
-static int
-gui_internal_coordinate_parse(char *s, char plus, char minus, double *x)
-{
- int sign=0;
- char *degree, *minute, *second;
- double tmp;
-
- if(!s)
- return 0;
-
- if (strchr(s, minus)!=NULL)
- sign=-1;
- else if (strchr(s, plus)!=NULL)
- sign=1;
-
- if(!sign)
- return 0;
-
-
- /* Can't just use strtok here because ° is multibyte sequence in utf8 */
- degree=s;
- minute=strstr(s,"°");
- if(minute) {
- *minute=0;
- minute+=strlen("°");
- }
-
- sscanf(degree, "%lf", x);
-
- if(strchr(degree, plus) || strchr(degree, minus)) {
- dbg(lvl_debug,"degree %c/%c found\n",plus,minus);
- } else {/* DEGREES_MINUTES */
- if(!minute)
- return 0;
- minute = strtok(minute,"'");
- sscanf(minute, "%lf", &tmp);
- *x+=tmp/60;
- if(strchr(minute, plus) || strchr(minute, minus)) {
- dbg(lvl_debug,"minute %c/%c found\n",plus,minus);
- } else { /* DEGREES_MINUTES_SECONDS */
- second=strtok(NULL,"");
- if(!second)
- return 0;
- sscanf(second, "%lf", &tmp);
- *x+=tmp/3600;
- }
- }
- *x *= sign;
- return 1;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Bruns (05/2012)
-//##############################################################################################################
-static void
-gui_internal_cmd_enter_coord_do(struct gui_priv *this, struct widget *widget)
-{
- char *lat, *lng;
- char *widgettext;
- double latitude, longitude;
- dbg(lvl_debug,"text entered:%s\n", widget->text);
-
- /* possible entry can be identical to coord_format output but only space between lat and lng is allowed */
- widgettext=g_ascii_strup(widget->text,-1);
-
- lat=strtok(widgettext," ");
- lng=strtok(NULL,"");
-
- if(!lat || !lng){
- g_free(widgettext);
- return;
- }
- if( gui_internal_coordinate_parse(lat, 'N', 'S', &latitude) && gui_internal_coordinate_parse(lng, 'E', 'W', &longitude) ) {
- g_free(widgettext);
- widgettext=g_strdup_printf("%lf %lf", longitude, latitude);
- pcoord_parse(widgettext, projection_mg, &widget->c );
- } else if(!pcoord_parse(widget->text, projection_mg, &widget->c )) {
- g_free(widgettext);
- return;
- }
- g_free(widgettext);
-
- gui_internal_cmd_position(this, widget, (void*)8);
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Bruns (05/2012)
-//##############################################################################################################
-void
-gui_internal_cmd_enter_coord_clicked(struct gui_priv *this, struct widget *widget, void *data)
-{
- dbg(lvl_debug,"entered\n");
- gui_internal_cmd_enter_coord_do(this, widget->data);
-}
-
-/**
- * @brief Handles mouse clicks and scroll wheel movement
- *
- * @author Martin Schaller (04/2008), Stefan Klumpp (04/2008)
- */
-static void gui_internal_button(void *data, int pressed, int button, struct point *p)
-{
- struct gui_priv *this=data;
- struct graphics *gra=this->gra;
-
- dbg(lvl_debug,"enter %d %d\n", pressed, button);
- // if still on the map (not in the menu, yet):
- dbg(lvl_debug,"children=%p ignore_button=%d\n",this->root.children,this->ignore_button);
- if (!this->root.children || this->ignore_button) {
-
- this->ignore_button=0;
- // check whether the position of the mouse changed during press/release OR if it is the scrollwheel
- if (!navit_handle_button(this->nav, pressed, button, p, NULL)) {
- dbg(lvl_debug,"navit has handled button\n");
- return;
- }
- dbg(lvl_debug,"menu_on_map_click=%d\n",this->menu_on_map_click);
- if (button != 1)
- return;
- if (this->on_map_click || this->menu_on_map_click) {
- this->mouse_button_clicked_on_map=1;
- gui_internal_set_click_coord(this, p);
- gui_internal_set_position_coord(this);
- if (this->on_map_click)
- command_evaluate(&this->self, this->on_map_click);
- else
- gui_internal_cmd_menu(this, 0, NULL);
- this->mouse_button_clicked_on_map=0;
- } else if (this->signal_on_map_click) {
- gui_internal_dbus_signal(this, p);
- return;
- }
- return;
- }
-
-
- /*
- * If already in the menu:
- */
-
- if (pressed) {
- this->pressed=1;
- this->current=*p;
- gui_internal_gesture_ring_clear(this);
- gui_internal_gesture_ring_add(this, p);
- gui_internal_highlight(this);
- } else {
- int dx,dy;
- gui_internal_gesture_ring_add(this, p);
- gui_internal_gesture_get_vector(this, 300, NULL, &dx, &dy);
- this->current.x=-1;
- this->current.y=-1;
- graphics_draw_mode(gra, draw_mode_begin);
- if(!gui_internal_gesture_do(this) && this->pressed!=2 && abs(dx)<this->icon_s && abs(dy)<this->icon_s)
- gui_internal_call_highlighted(this);
- this->pressed=0;
- if (!event_main_loop_has_quit()) {
- gui_internal_highlight(this);
- graphics_draw_mode(gra, draw_mode_end);
- gui_internal_check_exit(this);
- }
- }
-}
-
-static void
-gui_internal_setup(struct gui_priv *this)
-{
- struct color cbh={0x9fff,0x9fff,0x9fff,0xffff};
- struct color cf={0xbfff,0xbfff,0xbfff,0xffff};
- struct graphics *gra=this->gra;
- unsigned char *buffer;
- char *gui_file;
- int size;
-
- if (this->background)
- return;
- this->background=graphics_gc_new(gra);
- this->background2=graphics_gc_new(gra);
- this->highlight_background=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->highlight_background, &cbh);
- this->foreground=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->foreground, &cf);
- this->text_background=graphics_gc_new(gra);
- this->text_foreground=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->background, &this->background_color);
- graphics_gc_set_foreground(this->background2, &this->background2_color);
- graphics_gc_set_foreground(this->text_background, &this->text_background_color);
- graphics_gc_set_foreground(this->text_foreground, &this->text_foreground_color);
- gui_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/gui_internal.txt", NULL);
- if (file_get_contents(gui_file,&buffer,&size)) {
- char *command=g_malloc(size+1);
- strncpy(command,(const char *)buffer,size);
- command[size]=0;
- command_evaluate(&this->self, command);
- g_free(command);
- g_free(buffer);
- }
- g_free(gui_file);
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void gui_internal_resize(void *data, int w, int h)
-{
- struct gui_priv *this=data;
- int changed=0;
-
- gui_internal_setup(this);
-
- if (this->root.w != w || this->root.h != h) {
- this->root.w=w;
- this->root.h=h;
- changed=1;
- }
- /*
- * If we're drawing behind system bars on Android, watching for actual size changes will not catch
- * fullscreen toggle events. As a workaround, always assume a size change if padding is supplied.
- */
- if (!changed && this->gra && graphics_get_data(this->gra, "padding"))
- changed = 1;
- dbg(lvl_debug,"w=%d h=%d children=%p\n", w, h, this->root.children);
- navit_handle_resize(this->nav, w, h);
- if (this->root.children) {
- if (changed) {
- gui_internal_html_main_menu(this);
- } else {
- gui_internal_menu_render(this);
- }
- }
-}
-
-static void
-gui_internal_keynav_point(struct widget *w, int dx, int dy, struct point *p)
-{
- p->x=w->p.x+w->w/2;
- p->y=w->p.y+w->h/2;
- if (dx < 0)
- p->x=w->p.x;
- if (dx > 0)
- p->x=w->p.x+w->w;
- if (dy < 0)
- p->y=w->p.y;
- if (dy > 0)
- p->y=w->p.y+w->h;
-}
-
-static struct widget*
-gui_internal_keynav_find_next_sensitive_child(struct widget *wi) {
- GList *l=wi->children;
- if (wi->state & STATE_OFFSCREEN)
- return NULL;
- if (wi->state & STATE_SENSITIVE)
- return wi;
- while (l) {
- struct widget* tmp = gui_internal_keynav_find_next_sensitive_child(l->data);
- if (tmp)
- return tmp;
- l=g_list_next(l);
- }
- return NULL;
-}
-
-static int
-gui_internal_keynav_find_next(struct widget *wi, struct widget *current_highlight, struct widget **result) {
- GList *l=wi->children;
- if (wi == current_highlight)
- return 1;
- while (l) {
- struct widget *child=l->data;
- l=g_list_next(l);
- if (gui_internal_keynav_find_next(child, current_highlight, result)) {
- while (l) {
- struct widget *new = gui_internal_keynav_find_next_sensitive_child(l->data);
- if (new) {
- *result = new;
- /* Found one! */
- return 0;
- }
- l=g_list_next(l);
- }
- /* Try parent */
- return 1;
- }
- }
- return 0;
-}
-
-#define RESULT_FOUND 1
-#define NO_RESULT_YET 0
-
-static int
-gui_internal_keynav_find_prev(struct widget *wi, struct widget *current_highlight, struct widget **result) {
- if (wi == current_highlight && *result) {
- // Reached current widget; last widget found is the result.
- return RESULT_FOUND;
- }
- // If widget is off-screen, do not recurse into it.
- if (wi->state & STATE_OFFSCREEN)
- return NO_RESULT_YET;
- if (wi->state & STATE_SENSITIVE)
- *result= wi;
- GList *l=wi->children;
- while (l) {
- struct widget *child=l->data;
- if (gui_internal_keynav_find_prev(child, current_highlight, result) == RESULT_FOUND) {
- return RESULT_FOUND;
- }
- l=g_list_next(l);
- }
- // If no sensitive widget is found before "current_highlight", return the last sensitive widget when
- // recursion terminates.
- return NO_RESULT_YET;
-}
-
-static void
-gui_internal_keynav_find_closest(struct widget *wi, struct point *p, int dx, int dy, int *distance, struct widget **result)
-{
- GList *l=wi->children;
- // Skip hidden elements
- if (wi->p.x==0 && wi->p.y==0 && wi->w==0 && wi->h==0)
- return;
- if ((wi->state & STATE_SENSITIVE) ) {
- int dist1,dist2;
- struct point wp;
- gui_internal_keynav_point(wi, -dx, -dy, &wp);
- if (dx) {
- dist1=(wp.x-p->x)*dx;
- dist2=wp.y-p->y;
- } else if (dy) {
- dist1=(wp.y-p->y)*dy;
- dist2=wp.x-p->x;
- } else {
- dist2=wp.x-p->x;
- dist1=wp.y-p->y;
- if (dist1 < 0)
- dist1=-dist1;
- }
- dbg(lvl_debug,"checking %d,%d %d %d against %d,%d-%d,%d result %d,%d\n", p->x, p->y, dx, dy, wi->p.x, wi->p.y, wi->p.x+wi->w, wi->p.y+wi->h, dist1, dist2);
- if (dist1 >= 0) {
- if (dist2 < 0)
- dist1-=dist2;
- else
- dist1+=dist2;
- if (dist1 < *distance) {
- *result=wi;
- *distance=dist1;
- }
- }
- }
- while (l) {
- struct widget *child=l->data;
- gui_internal_keynav_find_closest(child, p, dx, dy, distance, result);
- l=g_list_next(l);
- }
-}
-
-/**
- * @brief Move keyboard focus to the next widget.
- *
- * Move keyboard focus to the appropriate next widget, depending on the direction of focus
- * movement.
- *
- * @param this GUI context
- * @param this dx horizontal movement (-1=left, +1=right), unless rotary==1
- * @param this dy vertical movement (+1=up, -1=down)
- * @param rotary (0/1) input from rotary encoder - dx indicates forwards/backwards movement
- * through all widgets
- */
-static void
-gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy, int rotary)
-{
- struct widget *result,*menu=g_list_last(this->root.children)->data;
- struct widget *current_highlight = NULL;
- struct point p;
- int distance;
- if (this->highlighted && this->highlighted_menu == menu) {
- gui_internal_keynav_point(this->highlighted, dx, dy, &p);
- current_highlight = this->highlighted;
- }
- else {
- p.x=0;
- p.y=0;
- distance=INT_MAX;
- result=NULL;
- gui_internal_keynav_find_closest(menu, &p, 0, 0, &distance, &result);
- if (result) {
- gui_internal_keynav_point(result, dx, dy, &p);
- dbg(lvl_debug,"result origin=%p p=%d,%d\n", result, p.x, p.y);
- current_highlight = result;
- }
- }
- result=NULL;
- distance=INT_MAX;
- if (rotary && dx > 0)
- gui_internal_keynav_find_next(menu, current_highlight, &result);
- else if (rotary && dx < 0)
- gui_internal_keynav_find_prev(menu, current_highlight, &result);
- else
- gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
- dbg(lvl_debug,"result=%p\n", result);
- if (! result) {
- if (dx < 0) {
- p.x=this->root.w;
- if (rotary) p.y = this->root.h;
- }
- if (dx > 0) {
- p.x=0;
- if (rotary) p.y = 0;
- }
- if (dy < 0)
- p.y=this->root.h;
- if (dy > 0)
- p.y=0;
- result=NULL;
- distance=INT_MAX;
- gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
- dbg(lvl_debug,"wraparound result=%p\n", result);
- }
- gui_internal_highlight_do(this, result);
- if (result)
- gui_internal_say(this, result, 1);
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static void gui_internal_keypress(void *data, char *key)
-{
- struct gui_priv *this=data;
- int w,h;
- struct point p;
- if (!this->root.children) {
- transform_get_size(navit_get_trans(this->nav), &w, &h);
- switch (*key) {
- case NAVIT_KEY_UP:
- p.x=w/2;
- p.y=0;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case NAVIT_KEY_DOWN:
- p.x=w/2;
- p.y=h;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case NAVIT_KEY_LEFT:
- p.x=0;
- p.y=h/2;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case NAVIT_KEY_RIGHT:
- p.x=w;
- p.y=h/2;
- navit_set_center_screen(this->nav, &p, 1);
- break;
- case NAVIT_KEY_ZOOM_IN:
- navit_zoom_in(this->nav, 2, NULL);
- break;
- case NAVIT_KEY_ZOOM_OUT:
- navit_zoom_out(this->nav, 2, NULL);
- break;
- case NAVIT_KEY_RETURN:
- case NAVIT_KEY_MENU:
- gui_internal_set_click_coord(this, NULL);
- gui_internal_cmd_menu(this, 0, NULL);
- break;
- }
- return;
- }
- graphics_draw_mode(this->gra, draw_mode_begin);
- switch (*key) {
- case NAVIT_KEY_PAGE_DOWN:
- gui_internal_keynav_highlight_next(this,1,0,1);
- break;
- case NAVIT_KEY_PAGE_UP:
- gui_internal_keynav_highlight_next(this,-1,0,1);
- break;
- case NAVIT_KEY_LEFT:
- gui_internal_keynav_highlight_next(this,-1,0,0);
- break;
- case NAVIT_KEY_RIGHT:
- gui_internal_keynav_highlight_next(this,1,0,0);
- break;
- case NAVIT_KEY_UP:
- gui_internal_keynav_highlight_next(this,0,-1,0);
- break;
- case NAVIT_KEY_DOWN:
- gui_internal_keynav_highlight_next(this,0,1,0);
- break;
- case NAVIT_KEY_BACK:
- if (g_list_length(this->root.children) > 1)
- gui_internal_back(this, NULL, NULL);
- else
- gui_internal_prune_menu(this, NULL);
- break;
- case NAVIT_KEY_RETURN:
- if (this->highlighted && this->highlighted_menu == g_list_last(this->root.children)->data)
- gui_internal_call_highlighted(this);
- else
- gui_internal_keypress_do(this, key);
- break;
- default:
- gui_internal_keypress_do(this, key);
- }
- if (!event_main_loop_has_quit()) {
- graphics_draw_mode(this->gra, draw_mode_end);
- gui_internal_check_exit(this);
- }
-}
-
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static int gui_internal_set_graphics(struct gui_priv *this, struct graphics *gra)
-{
- struct window *win;
- struct transformation *trans=navit_get_trans(this->nav);
-
- win=graphics_get_data(gra, "window");
- if (! win) {
- dbg(lvl_error, "failed to obtain window from graphics plugin, cannot set graphics\n");
- return 1;
- }
- navit_ignore_graphics_events(this->nav, 1);
- this->gra=gra;
- this->win=win;
- navit_ignore_graphics_events(this->nav, 1);
- transform_get_size(trans, &this->root.w, &this->root.h);
- this->resize_cb=callback_new_attr_1(callback_cast(gui_internal_resize), attr_resize, this);
- graphics_add_callback(gra, this->resize_cb);
- this->button_cb=callback_new_attr_1(callback_cast(gui_internal_button), attr_button, this);
- graphics_add_callback(gra, this->button_cb);
- this->motion_cb=callback_new_attr_1(callback_cast(gui_internal_motion), attr_motion, this);
- graphics_add_callback(gra, this->motion_cb);
- this->keypress_cb=callback_new_attr_1(callback_cast(gui_internal_keypress), attr_keypress, this);
- graphics_add_callback(gra, this->keypress_cb);
- this->window_closed_cb=callback_new_attr_1(callback_cast(gui_internal_window_closed), attr_window_closed, this);
- graphics_add_callback(gra, this->window_closed_cb);
-
- // set fullscreen if needed
- if (this->fullscreen)
- this->win->fullscreen(this->win, this->fullscreen != 0);
- /* Was resize callback already issued? */
- if (navit_get_ready(this->nav) & 2)
- gui_internal_setup(this);
- return 0;
-}
-
-static void gui_internal_disable_suspend(struct gui_priv *this)
-{
- if (this->win->disable_suspend)
- this->win->disable_suspend(this->win);
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-struct gui_methods gui_internal_methods = {
- NULL,
- NULL,
- gui_internal_set_graphics,
- NULL,
- NULL,
- NULL,
- gui_internal_disable_suspend,
- gui_internal_get_attr,
- gui_internal_add_attr,
- gui_internal_set_attr,
-};
-
-
-static void
-gui_internal_add_callback(struct gui_priv *priv, struct callback *cb)
-{
- callback_list_add(priv->cbl, cb);
-}
-
-static void
-gui_internal_remove_callback(struct gui_priv *priv, struct callback *cb)
-{
- callback_list_remove(priv->cbl, cb);
-}
-
-
-static struct gui_internal_methods gui_internal_methods_ext = {
- gui_internal_add_callback,
- gui_internal_remove_callback,
- gui_internal_menu_render,
- image_new_xs,
- image_new_l,
-};
-
-
-static enum flags
-gui_internal_get_flags(struct widget *widget)
-{
- return widget->flags;
-}
-
-static void
-gui_internal_set_flags(struct widget *widget, enum flags flags)
-{
- widget->flags=flags;
-}
-
-static int
-gui_internal_get_state(struct widget *widget)
-{
- return widget->state;
-}
-
-static void
-gui_internal_set_state(struct widget *widget, int state)
-{
- widget->state=state;
-}
-
-static void
-gui_internal_set_func(struct widget *widget, void (*func)(struct gui_priv *priv, struct widget *widget, void *data))
-{
- widget->func=func;
-}
-
-static void
-gui_internal_set_data(struct widget *widget, void *data)
-{
- widget->data=data;
-}
-
-static void
-gui_internal_set_default_background(struct gui_priv *this, struct widget *widget)
-{
- widget->background=this->background;
-}
-
-static struct gui_internal_widget_methods gui_internal_widget_methods = {
- gui_internal_widget_append,
- gui_internal_button_new,
- gui_internal_button_new_with_callback,
- gui_internal_box_new,
- gui_internal_label_new,
- gui_internal_image_new,
- gui_internal_keyboard,
- gui_internal_menu,
- gui_internal_get_flags,
- gui_internal_set_flags,
- gui_internal_get_state,
- gui_internal_set_state,
- gui_internal_set_func,
- gui_internal_set_data,
- gui_internal_set_default_background,
-};
-
-/**
- * @brief finds the intersection point of 2 lines
- *
- * @param coord a1, a2, b1, b2 : coords of the start and
- * end of the first and the second line
- * @param coord res, will become the coords of the intersection if found
- * @return : TRUE if intersection found, otherwise FALSE
- */
-int
-line_intersection(struct coord* a1, struct coord *a2, struct coord * b1, struct coord *b2, struct coord *res)
-{
- int n, a, b;
- int adx=a2->x-a1->x;
- int ady=a2->y-a1->y;
- int bdx=b2->x-b1->x;
- int bdy=b2->y-b1->y;
- n = bdy * adx - bdx * ady;
- a = bdx * (a1->y - b1->y) - bdy * (a1->x - b1->x);
- b = adx * (a1->y - b1->y) - ady * (a1->x - b1->x);
- if (n < 0) {
- n = -n;
- a = -a;
- b = -b;
- }
- if (a < 0 || b < 0)
- return FALSE;
- if (a > n || b > n)
- return FALSE;
- if (n == 0) {
- dbg(lvl_info,"a=%d b=%d n=%d\n", a, b, n);
- dbg(lvl_info,"a1=0x%x,0x%x ad %d,%d\n", a1->x, a1->y, adx, ady);
- dbg(lvl_info,"b1=0x%x,0x%x bd %d,%d\n", b1->x, b1->y, bdx, bdy);
- dbg(lvl_info,"No intersection found, lines assumed parallel ?\n");
- return FALSE;
- }
- res->x = a1->x + a * adx / n;
- res->y = a1->y + a * ady / n;
- return TRUE;
-}
-
-struct heightline *
-item_get_heightline(struct item *item)
-{
- struct heightline *ret=NULL;
- struct street_data *sd;
- struct attr attr;
- int i,height;
-
- if (item_attr_get(item, attr_label, &attr)) {
- height=atoi(attr.u.str);
- sd=street_get_data(item);
- if (sd && sd->count > 1) {
- ret=g_malloc(sizeof(struct heightline)+sd->count*sizeof(struct coord));
- ret->bbox.lu=sd->c[0];
- ret->bbox.rl=sd->c[0];
- ret->count=sd->count;
- ret->height=height;
- for (i = 0 ; i < sd->count ; i++) {
- ret->c[i]=sd->c[i];
- coord_rect_extend(&ret->bbox, sd->c+i);
- }
- }
- street_data_free(sd);
- }
- return ret;
-}
-
-/**
- * @brief Called when the route is updated.
- */
-void
-gui_internal_route_update(struct gui_priv * this, struct navit * navit, struct vehicle *v)
-{
-
- if(this->route_data.route_showing) {
- gui_internal_populate_route_table(this,navit);
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
- }
-
-
-}
-
-
-/**
- * @brief Called when the route screen is closed (deallocated).
- *
- * The main purpose of this function is to remove the widgets from
- * references route_data because those widgets are about to be freed.
- */
-void
-gui_internal_route_screen_free(struct gui_priv * this_,struct widget * w)
-{
- if(this_) {
- this_->route_data.route_showing=0;
- this_->route_data.route_table=NULL;
- g_free(w);
- }
-
-}
-
-/**
- * @brief Populates the route table with route information
- *
- * @param this The gui context
- * @param navit The navit object
- */
-void
-gui_internal_populate_route_table(struct gui_priv * this, struct navit * navit)
-{
- struct map * map=NULL;
- struct map_rect * mr=NULL;
- struct navigation * nav = NULL;
- struct item * item =NULL;
- struct attr attr,route;
- struct widget * label = NULL;
- struct widget * row = NULL;
- struct coord c;
- nav = navit_get_navigation(navit);
- if(!nav) {
- return;
- }
- map = navigation_get_map(nav);
- if(map)
- mr = map_rect_new(map,NULL);
- if(mr) {
- GList *toprow;
- struct item topitem={0};
- toprow=gui_internal_widget_table_top_row(this, this->route_data.route_table);
- if(toprow && toprow->data)
- topitem=((struct widget*)toprow->data)->item;
- gui_internal_widget_table_clear(this,this->route_data.route_table);
- if (navit_get_attr(navit, attr_route, &route, NULL)) {
- struct attr destination_length, destination_time;
- char *length=NULL,*time=NULL,*length_time;
- if (route_get_attr(route.u.route, attr_destination_length, &destination_length, NULL))
- length=attr_to_text_ext(&destination_length, NULL, attr_format_with_units, attr_format_default, NULL);
- if (route_get_attr(route.u.route, attr_destination_time, &destination_time, NULL))
- time=attr_to_text_ext(&destination_time, NULL, attr_format_with_units, attr_format_default, NULL);
- row = gui_internal_widget_table_row_new(this,
- gravity_left
- | flags_fill
- | orientation_horizontal);
- gui_internal_widget_append(this->route_data.route_table,row);
- length_time=g_strdup_printf("%s %s",length,time);
- label = gui_internal_label_new(this,length_time);
- g_free(length_time);
- g_free(length);
- g_free(time);
- gui_internal_widget_append(row,label);
- }
- while((item = map_rect_get_item(mr))) {
- if(item_attr_get(item,attr_navigation_long,&attr)) {
- row = gui_internal_widget_table_row_new(this,
- gravity_left
- | flags_fill
- | orientation_horizontal);
- gui_internal_widget_append(this->route_data.route_table,row);
-
- label = gui_internal_label_new(this,map_convert_string_tmp(item->map,attr.u.str));
- gui_internal_widget_append(row,label);
-
- label->item=*item;
- row->item=*item;
- item_coord_get(item, &c, 1);
- label->c.x=c.x;
- label->c.y=c.y;
- label->c.pro=map_projection(map);
- label->func=gui_internal_cmd_position;
- label->state|=STATE_SENSITIVE;
- label->data=(void*)2;
- if(toprow && item->id_hi==topitem.id_hi && item->id_lo==topitem.id_lo && item->map==topitem.map)
- gui_internal_widget_table_set_top_row(this, this->route_data.route_table, row);
- }
-
- }
- map_rect_destroy(mr);
- }
-}
-
-/*
- * Command interface wrapper for commands which can be used both from gui html and to enter internal gui (for example, from osd or dbus).
- * Set first command argument to integer 1, if this command was called by mouse click from oustside of gui (default). Set it to 0
- * if command is called by some other means (dbus signal, for example). If first argument is non integer, it's passed on
- * to actual handler.
- *
- */
-
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-static struct gui_priv * gui_internal_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs, struct gui *gui)
-{
- struct color color_white={0xffff,0xffff,0xffff,0xffff};
- struct color color_black={0x0,0x0,0x0,0xffff};
- struct color back2_color={0x4141,0x4141,0x4141,0xffff};
-
- struct gui_priv *this;
- struct attr *attr;
- *meth=gui_internal_methods;
- this=g_new0(struct gui_priv, 1);
- this->nav=nav;
-
- this->self.type=attr_gui;
- this->self.u.gui=gui;
-
- if ((attr=attr_search(attrs, NULL, attr_menu_on_map_click)))
- this->menu_on_map_click=attr->u.num;
- else
- this->menu_on_map_click=1;
-
- if ((attr=attr_search(attrs, NULL, attr_on_map_click)))
- this->on_map_click=g_strdup(attr->u.str);
-
- if ((attr=attr_search(attrs, NULL, attr_signal_on_map_click)))
- this->signal_on_map_click=attr->u.num;
- gui_internal_command_init(this, attrs);
-
- if( (attr=attr_search(attrs,NULL,attr_font_size)))
- {
- this->config.font_size=attr->u.num;
- }
- else
- {
- this->config.font_size=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_icon_xs)))
- {
- this->config.icon_xs=attr->u.num;
- }
- else
- {
- this->config.icon_xs=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_icon_l)))
- {
- this->config.icon_l=attr->u.num;
- }
- else
- {
- this->config.icon_l=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_icon_s)))
- {
- this->config.icon_s=attr->u.num;
- }
- else
- {
- this->config.icon_s=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_spacing)))
- {
- this->config.spacing=attr->u.num;
- }
- else
- {
- this->config.spacing=-1;
- }
- if( (attr=attr_search(attrs,NULL,attr_gui_speech)))
- {
- this->speech=attr->u.num;
- }
- if( (attr=attr_search(attrs,NULL,attr_keyboard)))
- this->keyboard=attr->u.num;
- else
- this->keyboard=1;
-
- if( (attr=attr_search(attrs,NULL,attr_fullscreen)))
- this->fullscreen=attr->u.num;
-
- if( (attr=attr_search(attrs,NULL,attr_flags)))
- this->flags=attr->u.num;
- if( (attr=attr_search(attrs,NULL,attr_background_color)))
- this->background_color=*attr->u.color;
- else
- this->background_color=color_black;
- if( (attr=attr_search(attrs,NULL,attr_background_color2)))
- this->background2_color=*attr->u.color;
- else
- this->background2_color=back2_color;
- if( (attr=attr_search(attrs,NULL,attr_text_color)))
- this->text_foreground_color=*attr->u.color;
- else
- this->text_foreground_color=color_white;
- if( (attr=attr_search(attrs,NULL,attr_text_background)))
- this->text_background_color=*attr->u.color;
- else
- this->text_background_color=color_black;
- if( (attr=attr_search(attrs,NULL,attr_columns)))
- this->cols=attr->u.num;
- if( (attr=attr_search(attrs,NULL,attr_osd_configuration)))
- this->osd_configuration=*attr;
-
- if( (attr=attr_search(attrs,NULL,attr_pitch)))
- this->pitch=attr->u.num;
- else
- this->pitch=20;
- if( (attr=attr_search(attrs,NULL,attr_flags_town)))
- this->flags_town=attr->u.num;
- else
- this->flags_town=-1;
- if( (attr=attr_search(attrs,NULL,attr_flags_street)))
- this->flags_street=attr->u.num;
- else
- this->flags_street=-1;
- if( (attr=attr_search(attrs,NULL,attr_flags_house_number)))
- this->flags_house_number=attr->u.num;
- else
- this->flags_house_number=-1;
- if( (attr=attr_search(attrs,NULL,attr_radius)))
- this->radius=attr->u.num;
- else
- this->radius=10;
- if( (attr=attr_search(attrs,NULL,attr_font)))
- this->font_name=g_strdup(attr->u.str);
-
- if((attr=attr_search(attrs, NULL, attr_hide_impossible_next_keys)))
- this->hide_keys = attr->u.num;
- else
- this->hide_keys = 0;
-
- this->data.priv=this;
- this->data.gui=&gui_internal_methods_ext;
- this->data.widget=&gui_internal_widget_methods;
- this->cbl=callback_list_new();
-
- return this;
-}
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-void plugin_init(void)
-{
- plugin_register_category_gui("internal", gui_internal_new);
-}
diff --git a/navit/gui/internal/gui_internal.h b/navit/gui/internal/gui_internal.h
deleted file mode 100644
index 1a5cd13d3..000000000
--- a/navit/gui/internal/gui_internal.h
+++ /dev/null
@@ -1,85 +0,0 @@
-struct widget;
-struct graphics_image;
-struct gui_priv;
-
-#define STATE_INVISIBLE 1
-#define STATE_SELECTED 2
-#define STATE_HIGHLIGHTED 4
-#define STATE_SENSITIVE 8
-#define STATE_EDIT 16
-#define STATE_CLEAR 32
-#define STATE_EDITABLE 64
-#define STATE_SCROLLABLE 128
-#define STATE_OFFSCREEN 256
-
-#define GESTURE_RINGSIZE 100
-
-enum widget_type {
- widget_box=1,
- widget_button,
- widget_label,
- widget_image,
- widget_table,
- widget_table_row
-};
-
-enum flags {
- gravity_none=0x00,
- gravity_left=1,
- gravity_xcenter=2,
- gravity_right=4,
- gravity_top=8,
- gravity_ycenter=16,
- gravity_bottom=32,
- gravity_left_top=gravity_left|gravity_top,
- gravity_top_center=gravity_xcenter|gravity_top,
- gravity_right_top=gravity_right|gravity_top,
- gravity_left_center=gravity_left|gravity_ycenter,
- gravity_center=gravity_xcenter|gravity_ycenter,
- gravity_right_center=gravity_right|gravity_ycenter,
- gravity_left_bottom=gravity_left|gravity_bottom,
- gravity_bottom_center=gravity_xcenter|gravity_bottom,
- gravity_right_bottom=gravity_right|gravity_bottom,
- flags_expand=0x100,
- flags_fill=0x200,
- flags_swap=0x400,
- flags_scrollx=0x800,
- flags_scrolly=0x1000,
- orientation_horizontal=0x10000,
- orientation_vertical=0x20000,
- orientation_horizontal_vertical=0x40000,
-};
-
-
-struct gui_internal_methods {
- void (*add_callback)(struct gui_priv *priv, struct callback *cb);
- void (*remove_callback)(struct gui_priv *priv, struct callback *cb);
- void (*menu_render)(struct gui_priv *this);
- struct graphics_image * (*image_new_xs)(struct gui_priv *this, const char *name);
- struct graphics_image * (*image_new_l)(struct gui_priv *this, const char *name);
-};
-
-struct gui_internal_widget_methods {
- void (*append)(struct widget *parent, struct widget *child);
- struct widget * (*button_new)(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags);
- struct widget * (*button_new_with_callback)(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
- struct widget * (*box_new)(struct gui_priv *this, enum flags flags);
- struct widget * (*label_new)(struct gui_priv *this, const char *text);
- struct widget * (*image_new)(struct gui_priv *this, struct graphics_image *image);
- struct widget * (*keyboard)(struct gui_priv *this, int mode);
- struct widget * (*menu)(struct gui_priv *this, const char *label);
- enum flags (*get_flags)(struct widget *widget);
- void (*set_flags)(struct widget *widget, enum flags flags);
- int (*get_state)(struct widget *widget);
- void (*set_state)(struct widget *widget, int state);
- void (*set_func)(struct widget *widget, void (*func)(struct gui_priv *priv, struct widget *widget, void *data));
- void (*set_data)(struct widget *widget, void *data);
- void (*set_default_background)(struct gui_priv *this, struct widget *widget);
-
-};
-
-struct gui_internal_data {
- struct gui_priv *priv;
- struct gui_internal_methods *gui;
- struct gui_internal_widget_methods *widget;
-};
diff --git a/navit/gui/internal/gui_internal_bookmark.c b/navit/gui/internal/gui_internal_bookmark.c
deleted file mode 100644
index eed0de123..000000000
--- a/navit/gui/internal/gui_internal_bookmark.c
+++ /dev/null
@@ -1,313 +0,0 @@
-#include <glib.h>
-#include <stdlib.h>
-#include "color.h"
-#include "coord.h"
-#include "point.h"
-#include "callback.h"
-#include "graphics.h"
-#include "debug.h"
-#include "navit.h"
-#include "navit_nls.h"
-#include "bookmarks.h"
-#include "gui_internal.h"
-#include "gui_internal_widget.h"
-#include "gui_internal_priv.h"
-#include "gui_internal_menu.h"
-#include "gui_internal_keyboard.h"
-#include "gui_internal_bookmark.h"
-
-static void
-gui_internal_cmd_add_bookmark_do(struct gui_priv *this, struct widget *widget)
-{
- GList *l;
- struct attr attr;
- dbg(lvl_debug,"text='%s'\n", widget->text);
- if (widget->text && strlen(widget->text)){
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_bookmark(attr.u.bookmarks, &widget->c, widget->text);
- }
- g_free(widget->text);
- widget->text=NULL;
- l=g_list_previous(g_list_last(this->root.children));
- gui_internal_prune_menu(this, l->data);
-}
-
-static void
-gui_internal_cmd_add_bookmark_folder_do(struct gui_priv *this, struct widget *widget)
-{
- GList *l;
- struct attr attr;
- dbg(lvl_debug,"text='%s'\n", widget->text);
- if (widget->text && strlen(widget->text)){
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_bookmark(attr.u.bookmarks, NULL, widget->text);
- }
- g_free(widget->text);
- widget->text=NULL;
- l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
- gui_internal_prune_menu(this, l->data);
-}
-
-static void
-gui_internal_cmd_add_bookmark_clicked(struct gui_priv *this, struct widget *widget, void *data)
-{
- gui_internal_cmd_add_bookmark_do(this, widget->data);
-}
-
-static void
-gui_internal_cmd_add_bookmark_folder_clicked(struct gui_priv *this, struct widget *widget, void *data)
-{
- gui_internal_cmd_add_bookmark_folder_do(this, widget->data);
-}
-
-static void
-gui_internal_cmd_rename_bookmark_clicked(struct gui_priv *this, struct widget *widget,void *data)
-{
- struct widget *w=(struct widget*)widget->data;
- GList *l;
- struct attr attr;
- dbg(lvl_debug,"text='%s'\n", w->text);
- if (w->text && strlen(w->text)){
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_rename_bookmark(attr.u.bookmarks, w->name, w->text);
- }
- g_free(w->text);
- g_free(w->name);
- w->text=NULL;
- w->name=NULL;
- l=g_list_previous(g_list_previous(g_list_previous(g_list_last(this->root.children))));
- gui_internal_prune_menu(this, l->data);
-}
-
-void
-gui_internal_cmd_add_bookmark2(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb,*wk,*wl,*we,*wnext;
- char *name=data;
- wb=gui_internal_menu(this,_("Add Bookmark"));
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- wk->c=wm->c;
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_add_bookmark_clicked;
- wnext->data=wk;
- wk->data=wnext;
- wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wl);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- gui_internal_menu_render(this);
-}
-
-void
-gui_internal_cmd_add_bookmark_folder2(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb,*wk,*wl,*we,*wnext;
- char *name=data;
- wb=gui_internal_menu(this,_("Add Bookmark folder"));
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- wk->c=wm->c;
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_add_bookmark_folder_clicked;
- wnext->data=wk;
- wk->data=wnext;
- wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wl);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- gui_internal_menu_render(this);
-}
-
-void
-gui_internal_cmd_rename_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w,*wb,*wk,*wl,*we,*wnext;
- char *name=wm->text;
- wb=gui_internal_menu(this,_("Rename"));
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, name));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- wk->c=wm->c;
- wk->name=g_strdup(name);
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_rename_bookmark_clicked;
- wnext->data=wk;
- wk->data=wnext;
- wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wl);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- gui_internal_menu_render(this);
-}
-
-void
-gui_internal_cmd_cut_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_cut_bookmark(mattr.u.bookmarks,wm->text);
- l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
- gui_internal_prune_menu(this, l->data);
-}
-
-void
-gui_internal_cmd_copy_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_copy_bookmark(mattr.u.bookmarks,wm->text);
- l=g_list_previous(g_list_previous(g_list_last(this->root.children)));
- gui_internal_prune_menu(this, l->data);
-}
-
-void
-gui_internal_cmd_paste_bookmark(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_paste_bookmark(mattr.u.bookmarks);
- l=g_list_previous(g_list_last(this->root.children));
- if(l)
- gui_internal_prune_menu(this, l->data);
-}
-
-void
-gui_internal_cmd_delete_bookmark_folder(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
- GList *l;
- navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL);
- bookmarks_move_up(mattr.u.bookmarks);
- bookmarks_delete_bookmark(mattr.u.bookmarks,wm->prefix);
- l=g_list_first(this->root.children);
- gui_internal_prune_menu(this, l->data);
-}
-
-void
-gui_internal_cmd_load_bookmarks_as_waypoints(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
-
- if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
- struct attr attr;
- struct item *item;
- struct coord c;
- struct pcoord *pc;
- enum projection pro=bookmarks_get_projection(mattr.u.bookmarks);
- int i, bm_count;
-
- navit_set_destination(this->nav, NULL, NULL, 0);
-
- bm_count=bookmarks_get_bookmark_count(mattr.u.bookmarks);
- pc=g_alloca(bm_count*sizeof(struct pcoord));
- bookmarks_item_rewind(mattr.u.bookmarks);
- i=0;
- while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
- if (!item_attr_get(item, attr_label, &attr))
- continue;
- if (item->type == type_bookmark) {
- if (item_coord_get(item, &c, 1)) {
- pc[i].x=c.x;
- pc[i].y=c.y;
- pc[i].pro=pro;
- navit_add_destination_description(this->nav,&pc[i],attr.u.str);
- i++;
- }
- }
- }
- bm_count=i;
-
- if (bm_count>0){
- navit_set_destinations(this->nav, pc, bm_count, wm->prefix, 1);
- if (this->flags & 512) {
- struct attr follow;
- follow.type=attr_follow;
- follow.u.num=180;
- navit_set_attr(this->nav, &this->osd_configuration);
- navit_set_attr(this->nav, &follow);
- navit_zoom_to_route(this->nav, 0);
- }
- }
- }
-
- gui_internal_prune_menu(this, NULL);
-}
-
-void
-gui_internal_cmd_replace_bookmarks_from_waypoints(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct attr mattr;
-
- if(navit_get_attr(this->nav, attr_bookmarks, &mattr, NULL) ) {
- struct attr attr;
- char *desc=NULL;
- struct pcoord *pc;
- int i, bm_count;
-
- if (bookmarks_get_bookmark_count(mattr.u.bookmarks)>0){
- struct item *item;
- bookmarks_item_rewind(mattr.u.bookmarks);
-
- while ((item=bookmarks_get_item(mattr.u.bookmarks))) {
-
- if (!item_attr_get(item, attr_label, &attr))
- continue;
-
- if (item->type == type_bookmark)
- bookmarks_delete_bookmark(mattr.u.bookmarks, attr.u.str);
-
- bookmarks_move_down(mattr.u.bookmarks,wm->prefix);
- }
- }
- bookmarks_item_rewind(mattr.u.bookmarks);
-
- bm_count=navit_get_destination_count(this->nav);
- pc=g_alloca(bm_count*sizeof(struct pcoord));
- navit_get_destinations(this->nav, pc, bm_count);
-
- for (i=0; i<bm_count; i++){
- char *tmp=navit_get_destination_description(this->nav, i);
- desc=g_strdup_printf("%s WP%d", tmp, i+1);
- g_free(tmp);
- navit_get_attr(this->nav, attr_bookmarks, &attr, NULL);
- bookmarks_add_bookmark(attr.u.bookmarks, &pc[i], desc);
- bookmarks_move_down(mattr.u.bookmarks,wm->prefix);
- g_free(desc);
- }
- }
-
- gui_internal_prune_menu(this, NULL);
-}
diff --git a/navit/gui/internal/gui_internal_bookmark.h b/navit/gui/internal/gui_internal_bookmark.h
deleted file mode 100644
index c1d42e7d1..000000000
--- a/navit/gui/internal/gui_internal_bookmark.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* prototypes */
-struct gui_priv;
-struct widget;
-void gui_internal_cmd_add_bookmark2(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_cmd_add_bookmark_folder2(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_cmd_rename_bookmark(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_cmd_cut_bookmark(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_cmd_copy_bookmark(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_cmd_paste_bookmark(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_cmd_delete_bookmark_folder(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_cmd_load_bookmarks_as_waypoints(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_cmd_replace_bookmarks_from_waypoints(struct gui_priv *this, struct widget *wm, void *data);
-/* end of prototypes */
diff --git a/navit/gui/internal/gui_internal_command.c b/navit/gui/internal/gui_internal_command.c
deleted file mode 100644
index a91f69f5f..000000000
--- a/navit/gui/internal/gui_internal_command.c
+++ /dev/null
@@ -1,1352 +0,0 @@
-#include <glib.h>
-#include <stdlib.h>
-#include <math.h>
-#include "config.h"
-#ifdef HAVE_API_WIN32_BASE
-#include <windows.h>
-#endif
-#include "color.h"
-#include "coord.h"
-#include "point.h"
-#include "callback.h"
-#include "graphics.h"
-#include "debug.h"
-#include "navit.h"
-#include "navit_nls.h"
-#include "command.h"
-#include "attr.h"
-#include "xmlconfig.h"
-#include "event.h"
-#include "config_.h"
-#include "map.h"
-#include "mapset.h"
-#include "transform.h"
-#include "search.h"
-#include "route.h"
-#include "vehicle.h"
-#include "vehicleprofile.h"
-#include "layout.h"
-#include "util.h"
-#include "gui_internal.h"
-#include "gui_internal_widget.h"
-#include "gui_internal_priv.h"
-#include "gui_internal_html.h"
-#include "gui_internal_menu.h"
-#include "gui_internal_keyboard.h"
-#include "gui_internal_search.h"
-#include "gui_internal_poi.h"
-#include "gui_internal_command.h"
-#if HAS_IFADDRS
-#include <ifaddrs.h>
-#include <arpa/inet.h>
-#endif
-
-extern char *version;
-
-/**
- * @brief Converts a WGS84 coordinate pair to its string representation.
- *
- * This function takes a coordinate pair with latitude and longitude in degrees and converts them to a
- * string of the form {@code 45°28'0" N 9°11'26" E}.
- *
- * @param gc A WGS84 coordinate pair
- * @param sep The separator character to insert between latitude and longitude
- *
- * @return The coordinates as a formatted string
- */
-static char *
-coordinates_geo(const struct coord_geo *gc, char sep)
-{
- char latc='N',lngc='E';
- int lat_deg,lat_min,lat_sec;
- int lng_deg,lng_min,lng_sec;
- struct coord_geo g=*gc;
-
- if (g.lat < 0) {
- g.lat=-g.lat;
- latc='S';
- }
- if (g.lng < 0) {
- g.lng=-g.lng;
- lngc='W';
- }
- lat_sec=fmod(g.lat*3600+0.5,60);
- lat_min=fmod(g.lat*60-lat_sec/60.0+0.5,60);
- lat_deg=g.lat-lat_min/60.0-lat_sec/3600.0+0.5;
- lng_sec=fmod(g.lng*3600+0.5,60);
- lng_min=fmod(g.lng*60-lng_sec/60.0+0.5,60);
- lng_deg=g.lng-lng_min/60.0-lng_sec/3600.0+0.5;;
-
- return g_strdup_printf("%d°%d'%d\" %c%c%d°%d'%d\" %c",lat_deg,lat_min,lat_sec,latc,sep,lng_deg,lng_min,lng_sec,lngc);
-}
-
-/**
- * @brief Converts a coordinate pair to its WGS84 string representation.
- *
- * This function takes a coordinate pair, transforms it to WGS84 and converts it to a string of the form
- * {@code 45°28'0" N 9°11'26" E}.
- *
- * @param gc A coordinate pair
- * @param sep The separator character to insert between latitude and longitude
- *
- * @return The coordinates as a formatted string
- */
-char *
-gui_internal_coordinates(struct pcoord *pc, char sep)
-{
- struct coord_geo g;
- struct coord c;
- c.x=pc->x;
- c.y=pc->y;
- transform_to_geo(pc->pro, &c, &g);
- return coordinates_geo(&g, sep);
-
-}
-
-enum escape_mode {
- escape_mode_none=0,
- escape_mode_string=1,
- escape_mode_quote=2,
- escape_mode_html=4,
- escape_mode_html_quote=8,
- escape_mode_html_apos=16,
-};
-
-/* todo &=&amp;, < = &lt; */
-
-static char *
-gui_internal_escape(enum escape_mode mode, char *in)
-{
- int len=mode & escape_mode_string ? 3:1;
- char *dst,*out,*src=in;
- char *quot="&quot;";
- char *apos="&apos;";
- while (*src) {
- if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
- len++;
- if (*src == '"' && mode == escape_mode_html_quote)
- len+=strlen(quot);
- else if (*src == '\'' && mode == escape_mode_html_apos)
- len+=strlen(apos);
- else
- len++;
- src++;
- }
- src=in;
- out=dst=g_malloc(len);
- if (mode & escape_mode_string)
- *dst++='"';
- while (*src) {
- if ((*src == '"' || *src == '\\') && (mode & (escape_mode_string | escape_mode_quote)))
- *dst++='\\';
- if (*src == '"' && mode == escape_mode_html_quote) {
- strcpy(dst,quot);
- src++;
- dst+=strlen(quot);
- } else if (*src == '\'' && mode == escape_mode_html_apos) {
- strcpy(dst,apos);
- src++;
- dst+=strlen(apos);
- } else
- *dst++=*src++;
- }
- if (mode & escape_mode_string)
- *dst++='"';
- *dst++='\0';
- return out;
-}
-
-static void
-gui_internal_cmd_escape(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr escaped;
- if (!in || !in[0]) {
- dbg(lvl_error,"first parameter missing or wrong type\n");
- return;
- }
- if (!out) {
- dbg(lvl_error,"output missing\n");
- return;
- }
- if (ATTR_IS_STRING(in[0]->type)) {
- escaped.type=in[0]->type;
- escaped.u.str=gui_internal_escape(escape_mode_string,in[0]->u.str);
- } else if (ATTR_IS_INT(in[0]->type)) {
- escaped.type=attr_type_string_begin;
- escaped.u.str=g_strdup_printf("%ld",in[0]->u.num);
- } else {
- dbg(lvl_error,"first parameter wrong type\n");
- return;
- }
- dbg(lvl_debug,"in %s result %s\n",in[0]->u.str,escaped.u.str);
- *out=attr_generic_add_attr(*out, attr_dup(&escaped));
- g_free(escaped.u.str);
-}
-
-static void
-gui_internal_cmd2_about(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *menu,*wb,*w;
- char *text;
-
- graphics_draw_mode(this->gra, draw_mode_begin);
- menu=gui_internal_menu(this, _("About Navit"));
- menu->spx=this->spacing*10;
- wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand);
- gui_internal_widget_append(menu, wb);
-
- //Icon
- gui_internal_widget_append(wb, w=gui_internal_image_new(this, image_new_xs(this, "navit")));
- w->flags=gravity_top_center|orientation_horizontal|flags_fill;
-
- //app name
- text=g_strdup_printf("%s",PACKAGE_NAME);
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_top_center|orientation_horizontal|flags_expand;
- g_free(text);
-
- //Version
- text=g_strdup_printf("%s",version);
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_top_center|orientation_horizontal|flags_expand;
- g_free(text);
-
- //Site
- text=g_strdup_printf("http://www.navit-project.org/");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_top_center|orientation_horizontal|flags_expand;
- g_free(text);
-
- //Authors
- text=g_strdup_printf("%s:",_("By"));
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("Martin Schaller");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("Michael Farmbauer");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("Alexander Atanasov");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("Pierre Grandin");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
-
- //Contributors
- text=g_strdup_printf("%s",_("And all the Navit Team"));
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- text=g_strdup_printf("%s",_("members and contributors."));
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
-
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
-}
-
-static void
-gui_internal_cmd2_waypoints(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- gui_internal_select_waypoint(this, _("Waypoints"), NULL, NULL, gui_internal_cmd_position, (void*)2);
-}
-
-static void
-gui_internal_cmd_enter_coord(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *w, *wb, *wk, *wr, *we, *wnext, *row;
- wb=gui_internal_menu(this, _("Enter Coordinates"));
- w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wr);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(wr, we);
-
-/*
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
-
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);*/
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, _("Latitude Longitude")));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_enter_coord_clicked;
- wnext->data=wk;
- wk->data=wnext;
- row=gui_internal_text_new(this, _("Enter coordinates, for example:"), gravity_top_center|flags_fill|orientation_vertical);
- gui_internal_widget_append(wr,row);
- row=gui_internal_text_new(this, "52.5219N 19.4127E", gravity_top_center|flags_fill|orientation_vertical);
- gui_internal_widget_append(wr,row);
- row=gui_internal_text_new(this, "52°31.3167N 19°24.7667E", gravity_top_center|flags_fill|orientation_vertical);
- gui_internal_widget_append(wr,row);
- row=gui_internal_text_new(this, "52°31'19N 19°24'46E", gravity_top_center|flags_fill|orientation_vertical);
- gui_internal_widget_append(wr,row);
-
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_DEGREE));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_DEGREE, NULL);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd2_town(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- if (this->sl)
- search_list_select(this->sl, attr_country_all, 0, 0);
- gui_internal_search(this,_("Town"),"Town",1);
-}
-
-static void
-gui_internal_cmd2_setting_vehicle(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr attr,attr2,vattr;
- struct widget *w,*wb,*wl;
- struct attr_iter *iter;
- struct attr active_vehicle;
-
- iter=navit_attr_iter_new();
- if (navit_get_attr(this->nav, attr_vehicle, &attr, iter) && !navit_get_attr(this->nav, attr_vehicle, &attr2, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
- navit_attr_iter_destroy(iter);
- gui_internal_menu_vehicle_settings(this, attr.u.vehicle, vattr.u.str);
- return;
- }
- navit_attr_iter_destroy(iter);
-
- wb=gui_internal_menu(this, _("Vehicle"));
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
- if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
- active_vehicle.u.vehicle=NULL;
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
- vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
- wl=gui_internal_button_new_with_callback(this, vattr.u.str,
- image_new_xs(this, attr.u.vehicle == active_vehicle.u.vehicle ? "gui_active" : "gui_inactive"), gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_vehicle_settings, attr.u.vehicle);
- wl->text=g_strdup(vattr.u.str);
- gui_internal_widget_append(w, wl);
- }
- navit_attr_iter_destroy(iter);
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd2_setting_rules(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *wb,*w;
- struct attr on,off;
- wb=gui_internal_menu(this, _("Rules"));
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*3;
- gui_internal_widget_append(wb, w);
- on.u.num=1;
- off.u.num=0;
- on.type=off.type=attr_tracking;
- gui_internal_widget_append(w,
- gui_internal_button_navit_attr_new(this, _("Lock on road"), gravity_left_center|orientation_horizontal|flags_fill,
- &on, &off));
- on.u.num=0;
- off.u.num=-1;
- on.type=off.type=attr_orientation;
- gui_internal_widget_append(w,
- gui_internal_button_navit_attr_new(this, _("Northing"), gravity_left_center|orientation_horizontal|flags_fill,
- &on, &off));
- on.u.num=1;
- off.u.num=0;
- on.type=off.type=attr_follow_cursor;
- gui_internal_widget_append(w,
- gui_internal_button_navit_attr_new(this, _("Map follows Vehicle"), gravity_left_center|orientation_horizontal|flags_fill,
- &on, &off));
- on.u.num=1;
- off.u.num=0;
- on.type=off.type=attr_waypoints_flag;
- gui_internal_widget_append(w,
- gui_internal_button_navit_attr_new(this, _("Plan with Waypoints"), gravity_left_center|orientation_horizontal|flags_fill,
- &on, &off));
- gui_internal_menu_render(this);
-}
-
-static void
-gui_internal_cmd2_setting_maps(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr attr, on, off, description, type, data, url, active;
- struct widget *w,*wb,*row,*wma;
- char *label;
- struct attr_iter *iter;
-
- wb=gui_internal_menu(this, _("Maps"));
- //w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- //w->spy=this->spacing*3;
- w = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- gui_internal_widget_append(wb, w);
- iter=navit_attr_iter_new();
- on.type=off.type=attr_active;
- on.u.num=1;
- off.u.num=0;
- while(navit_get_attr(this->nav, attr_map, &attr, iter)) {
- if (map_get_attr(attr.u.map, attr_description, &description, NULL)) {
- label=g_strdup(description.u.str);
- } else {
- if (!map_get_attr(attr.u.map, attr_type, &type, NULL))
- type.u.str="";
- if (!map_get_attr(attr.u.map, attr_data, &data, NULL))
- data.u.str="";
- label=g_strdup_printf("%s:%s", type.u.str, data.u.str);
- }
- if (map_get_attr(attr.u.map, attr_url, &url, NULL)) {
- if (!map_get_attr(attr.u.map, attr_active, &active, NULL))
- active.u.num=1;
- wma=gui_internal_button_new_with_callback(this, label, image_new_xs(this, active.u.num ? "gui_active" : "gui_inactive"),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_map_download, attr.u.map);
- } else {
- wma=gui_internal_button_map_attr_new(this, label, gravity_left_center|orientation_horizontal|flags_fill,
- attr.u.map, &on, &off, 1);
- }
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- gui_internal_widget_append(row, wma);
- g_free(label);
- }
- navit_attr_iter_destroy(iter);
- gui_internal_menu_render(this);
-
-}
-
-static void
-gui_internal_cmd2_setting_layout(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr attr;
- struct widget *w,*wb,*wl,*row;
- struct attr_iter *iter;
-
-
- wb=gui_internal_menu(this, _("Layout"));
- w=gui_internal_widget_table_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill,1);
- gui_internal_widget_append(wb, w);
- iter=navit_attr_iter_new();
- while(navit_get_attr(this->nav, attr_layout, &attr, iter)) {
- gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,gravity_left|orientation_horizontal|flags_fill));
- wl=gui_internal_button_navit_attr_new(this, attr.u.layout->name, gravity_left_center|orientation_horizontal|flags_fill,
- &attr, NULL);
- gui_internal_widget_append(row, wl);
- }
- navit_attr_iter_destroy(iter);
- gui_internal_menu_render(this);
-}
-
-/*
- * @brief Displays Route Height Profile
- *
- * displays a heightprofile if a route is active and
- * some heightinfo is provided by means of a map
- *
- * the name of the file providing the heightlines must
- * comply with *.heightlines.bin
- *
- */
-static void
-gui_internal_cmd2_route_height_profile(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget * menu, *box;
- struct map * map=NULL;
- struct map_rect * mr=NULL;
- struct route * route;
- struct item * item =NULL;
- struct mapset *ms;
- struct mapset_handle *msh;
- int x,i,first=1,dist=0;
- int diagram_points_count = 0;
- struct coord c,last,res;
- struct coord_rect rbbox,dbbox;
- struct map_selection sel;
- struct heightline *heightline,*heightlines=NULL;
- struct diagram_point *min,*diagram_point,*diagram_points=NULL;
- struct point p[2];
- sel.next=NULL;
- sel.order=18;
- sel.range.min=type_height_line_1;
- sel.range.max=type_height_line_3;
-
- menu=gui_internal_menu(this,_("Height Profile"));
- box = gui_internal_box_new(this, gravity_left_top| orientation_vertical | flags_fill | flags_expand);
- gui_internal_widget_append(menu, box);
- route = navit_get_route(this->nav);
- if (route)
- map = route_get_map(route);
- if(map)
- mr = map_rect_new(map,NULL);
- if(mr) {
- while((item = map_rect_get_item(mr))) {
- while (item_coord_get(item, &c, 1)) {
- if (first) {
- first=0;
- sel.u.c_rect.lu=c;
- sel.u.c_rect.rl=c;
- } else
- coord_rect_extend(&sel.u.c_rect, &c);
- }
- }
- map_rect_destroy(mr);
- mr = NULL;
- ms=navit_get_mapset(this->nav);
- if (!first && ms) {
- int heightmap_installed = FALSE;
- msh=mapset_open(ms);
- while ((map=mapset_next(msh, 1))) {
- struct attr data_attr;
- if (map_get_attr(map, attr_data, &data_attr, NULL)){
- dbg(lvl_debug,"map name = %s\n",data_attr.u.str);
- if (strstr(data_attr.u.str,".heightlines.bin")){
- dbg(lvl_info,"reading heightlines from map %s\n",data_attr.u.str);
- mr=map_rect_new(map, &sel);
- heightmap_installed = TRUE;
- }
- else {
- dbg(lvl_debug,"ignoring map %s\n",data_attr.u.str);
- }
- }
- if (mr) {
- while((item = map_rect_get_item(mr))) {
- if (item->type >= sel.range.min && item->type <= sel.range.max) {
- heightline=item_get_heightline(item);
- if (heightline) {
- heightline->next=heightlines;
- heightlines=heightline;
- }
- }
- }
- map_rect_destroy(mr);
- mr = NULL;
- }
- }
- mapset_close(msh);
- if (!heightmap_installed){
- char *text;
- struct widget *w;
- text=g_strdup_printf("%s",_("please install a map *.heightlines.bin to provide elevationdata"));
- gui_internal_widget_append(box, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- gui_internal_menu_render(this);
- return;
- }
- }
- }
- map=NULL;
- mr=NULL;
- if (route)
- map = route_get_map(route);
- if(map)
- mr = map_rect_new(map,NULL);
- if(mr && heightlines) {
- while((item = map_rect_get_item(mr))) {
- first=1;
- while (item_coord_get(item, &c, 1)) {
- if (first)
- first=0;
- else {
- heightline=heightlines;
- rbbox.lu=last;
- rbbox.rl=last;
- coord_rect_extend(&rbbox, &c);
- while (heightline) {
- if (coord_rect_overlap(&rbbox, &heightline->bbox)) {
- for (i = 0 ; i < heightline->count - 1; i++) {
- if (heightline->c[i].x != heightline->c[i+1].x || heightline->c[i].y != heightline->c[i+1].y) {
- if (line_intersection(heightline->c+i, heightline->c+i+1, &last, &c, &res)) {
- diagram_point=g_new(struct diagram_point, 1);
- diagram_point->c.x=dist+transform_distance(projection_mg, &last, &res);
- diagram_point->c.y=heightline->height;
- diagram_point->next=diagram_points;
- diagram_points=diagram_point;
- diagram_points_count ++;
- dbg(lvl_debug,"%d %d\n", diagram_point->c.x, diagram_point->c.y);
- }
- }
- }
- }
- heightline=heightline->next;
- }
- dist+=transform_distance(projection_mg, &last, &c);
- }
- last=c;
- }
- }
- }
- while (heightlines){
- heightline=heightlines;
- heightlines=heightlines->next;
- g_free(heightline);
- }
- if(mr)
- map_rect_destroy(mr);
-
- if(diagram_points_count < 2){
- char *text;
- struct widget *w;
- text=g_strdup_printf("%s",_("The route must cross at least 2 heightlines"));
- gui_internal_widget_append(box, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- gui_internal_menu_render(this);
- if(diagram_points)
- g_free(diagram_points);
- return;
- }
-
- gui_internal_menu_render(this);
- first=1;
- diagram_point=diagram_points;
- while (diagram_point) {
- if (first) {
- dbbox.lu=diagram_point->c;
- dbbox.rl=diagram_point->c;
- first=0;
- } else
- coord_rect_extend(&dbbox, &diagram_point->c);
- diagram_point=diagram_point->next;
- }
- dbg(lvl_debug,"%d %d %d %d\n", dbbox.lu.x, dbbox.lu.y, dbbox.rl.x, dbbox.rl.y);
- if (dbbox.rl.x > dbbox.lu.x && dbbox.lu.x*100/(dbbox.rl.x-dbbox.lu.x) <= 25)
- dbbox.lu.x=0;
- if (dbbox.lu.y > dbbox.rl.y && dbbox.rl.y*100/(dbbox.lu.y-dbbox.rl.y) <= 25)
- dbbox.rl.y=0;
- dbg(lvl_debug,"%d,%d %dx%d\n", box->p.x, box->p.y, box->w, box->h);
- x=dbbox.lu.x;
- first=1;
- if (diagram_points_count > 1 && dbbox.rl.x != dbbox.lu.x && dbbox.lu.y != dbbox.rl.y){
- for (;;) {
- min=NULL;
- diagram_point=diagram_points;
- while (diagram_point) {
- if (diagram_point->c.x >= x && (!min || min->c.x > diagram_point->c.x))
- min=diagram_point;
- diagram_point=diagram_point->next;
- }
- if (! min)
- break;
- p[1].x=(min->c.x-dbbox.lu.x)*(box->w-10)/(dbbox.rl.x-dbbox.lu.x)+box->p.x+5;
- p[1].y=(box->h)-5-(min->c.y-dbbox.rl.y)*(box->h-10)/(dbbox.lu.y-dbbox.rl.y)+box->p.y;
- dbg(lvl_debug,"%d,%d=%d,%d\n",min->c.x, min->c.y, p[1].x,p[1].y);
- graphics_draw_circle(this->gra, this->foreground, &p[1], 2);
- if (first)
- first=0;
- else
- graphics_draw_lines(this->gra, this->foreground, p, 2);
- p[0]=p[1];
- x=min->c.x+1;
- }
- }
- while (diagram_points){
- diagram_point=diagram_points;
- diagram_points=diagram_points->next;
- g_free(diagram_point);
- }
-}
-
-static void
-gui_internal_cmd2_route_description(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
-
-
- struct widget * menu;
- struct widget * box;
-
-
- if(! this->vehicle_cb)
- {
- /**
- * Register the callback on vehicle updates.
- */
- this->vehicle_cb = callback_new_attr_1(callback_cast(gui_internal_route_update),
- attr_position_coord_geo,this);
- navit_add_callback(this->nav,this->vehicle_cb);
- }
-
- this->route_data.route_table = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
-
- menu=gui_internal_menu(this,_("Route Description"));
-
- menu->wfree=gui_internal_route_screen_free;
- this->route_data.route_showing=1;
- this->route_data.route_table->spx = this->spacing;
-
-
- box = gui_internal_box_new(this, gravity_left_top| orientation_vertical | flags_fill | flags_expand);
-
- gui_internal_widget_append(box,this->route_data.route_table);
- box->w=menu->w;
- box->spx = this->spacing;
- this->route_data.route_table->w=box->w;
- gui_internal_widget_append(menu,box);
- gui_internal_populate_route_table(this,this->nav);
- gui_internal_menu_render(this);
-
-}
-
-static void
-gui_internal_cmd2_pois(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *w;
- struct poi_param *param;
- struct attr pro;
- struct coord c;
-
- dbg(lvl_debug,"enter\n");
- if (!in || !in[0])
- return;
- if (!ATTR_IS_COORD_GEO(in[0]->type))
- return;
- if (!navit_get_attr(this->nav, attr_projection, &pro, NULL))
- return;
- w=g_new0(struct widget,1);
- param=g_new0(struct poi_param,1);
- if (in[1] && ATTR_IS_STRING(in[1]->type)) {
- gui_internal_poi_param_set_filter(param, in[1]->u.str);
- if (in[2] && ATTR_IS_INT(in[2]->type))
- param->AddressFilterType=in[2]->u.num;
- }
-
- transform_from_geo(pro.u.projection,in[0]->u.coord_geo,&c);
- w->c.x=c.x;
- w->c.y=c.y;
- w->c.pro=pro.u.projection;
- gui_internal_cmd_pois(this, w, param);
- g_free(w);
- gui_internal_poi_param_free(param);
-}
-
-static void
-gui_internal_cmd2_locale(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *menu,*wb,*w;
- char *text;
-
- graphics_draw_mode(this->gra, draw_mode_begin);
- menu=gui_internal_menu(this, _("Show Locale"));
- menu->spx=this->spacing*10;
- wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(menu, wb);
- text=g_strdup_printf("LANG=%1$s (1=%3$s 2=%2$s)",getenv("LANG"),"2","1");
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_left_center|orientation_horizontal|flags_fill;
- g_free(text);
-#ifdef HAVE_API_WIN32_BASE
- {
- char country[32],lang[32];
-#ifdef HAVE_API_WIN32_CE
- wchar_t wcountry[32],wlang[32];
-
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, wlang, sizeof(wlang));
- WideCharToMultiByte(CP_ACP,0,wlang,-1,lang,sizeof(lang),NULL,NULL);
-#else
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVLANGNAME, lang, sizeof(lang));
-#endif
- text=g_strdup_printf("LOCALE_SABBREVLANGNAME=%s",lang);
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_left_center|orientation_horizontal|flags_fill;
- g_free(text);
-#ifdef HAVE_API_WIN32_CE
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, wcountry, sizeof(wcountry));
- WideCharToMultiByte(CP_ACP,0,wcountry,-1,country,sizeof(country),NULL,NULL);
-#else
- GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVCTRYNAME, country, sizeof(country));
-#endif
- text=g_strdup_printf("LOCALE_SABBREVCTRYNAME=%s",country);
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_left_center|orientation_horizontal|flags_fill;
- g_free(text);
- }
-#endif
-
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
-}
-
-/**
- * @brief display basic networking information
- *
- * @return nothing
- *
- * This function displays basic networking information, currently
- * only the interface name and the associated IP address(es).
- * Currently only works on non Windows systems.
- *
- */
-static void
-gui_internal_cmd2_network_info(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
-#if HAS_IFADDRS
- struct widget *menu,*wb,*w;
- char *text;
-
- graphics_draw_mode(this->gra, draw_mode_begin);
- menu=gui_internal_menu(this, _("Network info"));
- menu->spx=this->spacing*10;
- wb=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(menu, wb);
-
- struct ifaddrs *addrs, *tmp;
- getifaddrs(&addrs);
- tmp = addrs;
-
- while (tmp)
- {
- if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_INET)
- {
- struct sockaddr_in *pAddr = (struct sockaddr_in *)tmp->ifa_addr;
- if(g_ascii_strncasecmp(tmp->ifa_name,"lo",2 ) ) {
- text=g_strdup_printf("%s: %s", tmp->ifa_name, inet_ntoa(pAddr->sin_addr));
- gui_internal_widget_append(wb, w=gui_internal_label_new(this, text));
- w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
- g_free(text);
- }
- }
- tmp = tmp->ifa_next;
- }
- freeifaddrs(addrs);
-
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
-#else
- dbg(lvl_error, "Cannot show network info: ifaddr.h not found\n");
-#endif
-}
-
-static void
-gui_internal_cmd_formerdests(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct widget *wb,*w,*wbm,*tbl=NULL;
- struct map *formerdests;
- struct map_rect *mr_formerdests;
- struct item *item;
- struct attr attr;
- char *label_full;
- enum projection projection;
-
- if(!navit_get_attr(this->nav, attr_former_destination_map, &attr, NULL))
- return;
-
- formerdests=attr.u.map;
- if(!formerdests)
- return;
-
- mr_formerdests=map_rect_new(formerdests, NULL);
- if(!mr_formerdests)
- return;
-
- projection = map_projection(formerdests);
-
- gui_internal_prune_menu_count(this, 1, 0);
- wb=gui_internal_menu(this, _("Former Destinations"));
- wb->background=this->background;
-
- w=gui_internal_box_new(this,
- gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- w->spy=this->spacing*2;
- gui_internal_widget_append(wb, w);
- while ((item=map_rect_get_item(mr_formerdests))) {
- struct coord c;
- struct widget *row;
- if (item->type!=type_former_destination) continue;
- if (!item_attr_get(item, attr_label, &attr)) continue;
- if(!tbl) {
- tbl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand | orientation_vertical,1);
- gui_internal_widget_append(w,tbl);
- }
- row=gui_internal_widget_table_row_new(this,gravity_left| flags_fill| orientation_vertical);
- gui_internal_widget_prepend(tbl, row);
- label_full=attr.u.str;
- wbm=gui_internal_button_new_with_callback(this, label_full,
- image_new_xs(this, "gui_active"),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_position, NULL);
- gui_internal_widget_append(row,wbm);
- if (item_coord_get(item, &c, 1)) {
- wbm->c.x=c.x;
- wbm->c.y=c.y;
- wbm->c.pro=projection;
- wbm->name=g_strdup(label_full);
- wbm->text=g_strdup(label_full);
- wbm->data=(void*)8; //Mark us as a former destination
- wbm->prefix=g_strdup(label_full);
- }
- }
- if (!tbl){
- wbm=gui_internal_text_new(this, _("- No former destinations available -"),
- gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, wbm);
- }
- gui_internal_menu_render(this);
- map_rect_destroy(mr_formerdests);
-}
-
-static void
-gui_internal_cmd2_bookmarks(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *str=NULL;
- if (in && in[0] && ATTR_IS_STRING(in[0]->type)) {
- str=in[0]->u.str;
- }
-
- gui_internal_cmd_bookmarks(this, NULL, str);
-}
-
-static void
-gui_internal_cmd2_abort_navigation(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- navit_set_destination(this->nav, NULL, NULL, 0);
-}
-
-static void
-gui_internal_cmd2_back(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_back(this, NULL, NULL);
- graphics_draw_mode(this->gra, draw_mode_end);
- gui_internal_check_exit(this);
-}
-
-static void
-gui_internal_cmd2_back_to_map(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- gui_internal_prune_menu(this, NULL);
- gui_internal_check_exit(this);
-}
-
-
-static void
-gui_internal_get_data(struct gui_priv *priv, char *command, struct attr **in, struct attr ***out)
-{
- struct attr private_data = { attr_private_data, {(void *)&priv->data}};
- if (out)
- *out=attr_generic_add_attr(*out, &private_data);
-}
-
-static void
-gui_internal_cmd_log(struct gui_priv *this)
-{
- struct widget *w,*wb,*wk,*wl,*we,*wnext;
- gui_internal_enter(this, 1);
- gui_internal_set_click_coord(this, NULL);
- gui_internal_enter_setup(this);
- wb=gui_internal_menu(this, "Log Message");
- w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(w, we);
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, _("Message")));
- wk->state |= STATE_EDIT|STATE_EDITABLE|STATE_CLEAR;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_call_linked_on_finish;
- gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wnext->state |= STATE_SENSITIVE;
- wnext->func = gui_internal_cmd_log_clicked;
- wnext->data=wk;
- wk->data=wnext;
- wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wl);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, w, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- gui_internal_menu_render(this);
- gui_internal_leave(this);
-}
-
-static void
-gui_internal_cmd_menu2(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *href=NULL;
- int i=0, ignore=0, replace=0;
-
- if (in && in[i] && ATTR_IS_INT(in[i]->type))
- ignore=in[i++]->u.num;
-
- if (in && in[i] && ATTR_IS_STRING(in[i]->type)) {
- href=in[i++]->u.str;
- if (in[i] && ATTR_IS_INT(in[i]->type))
- replace=in[i++]->u.num;
- }
-
- if (this->root.children) {
- if (!href)
- return;
- gui_internal_html_load_href(this, href, replace);
- return;
- }
- gui_internal_cmd_menu(this, ignore, href);
-}
-
-static void
-gui_internal_cmd2_position(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- const char *name=_("Position");
- int flags=-1;
-
- dbg(lvl_debug,"enter\n");
- if (!in || !in[0])
- return;
- if (!ATTR_IS_COORD_GEO(in[0]->type))
- return;
- if (in[1] && ATTR_IS_STRING(in[1]->type)) {
- name=in[1]->u.str;
- if (in[2] && ATTR_IS_INT(in[2]->type))
- flags=in[2]->u.num;
- }
- dbg(lvl_debug,"flags=0x%x\n",flags);
- gui_internal_cmd_position_do(this, NULL, in[0]->u.coord_geo, NULL, name, flags);
-}
-
-static void
-gui_internal_cmd_redraw_map(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- this->redraw=1;
-}
-
-static void
-gui_internal_cmd2_refresh(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *href=g_strdup(this->href);
- gui_internal_html_load_href(this, href, 1);
- g_free(href);
-}
-
-static void
-gui_internal_cmd2_set(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *pattern,*command=NULL;
- if (!in || !in[0] || !ATTR_IS_STRING(in[0]->type)) {
- dbg(lvl_error,"first parameter missing or wrong type\n");
- return;
- }
- pattern=in[0]->u.str;
- dbg(lvl_debug,"pattern %s\n",pattern);
- if (in[1]) {
- command=gui_internal_cmd_match_expand(pattern, in+1);
- dbg(lvl_debug,"expand %s\n",command);
- gui_internal_set(pattern, command);
- command_evaluate(&this->self, command);
- g_free(command);
- } else {
- gui_internal_set(pattern, NULL);
- }
-
-}
-
-void
-gui_internal_cmd2_quit(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- struct attr navit;
- gui_internal_prune_menu(this, NULL);
- navit.type=attr_navit;
- navit.u.navit=this->nav;
- config_remove_attr(config, &navit);
- event_main_loop_quit();
-}
-
-static char *
-gui_internal_append_attr(char *str, enum escape_mode mode, char *pre, struct attr *attr, char *post)
-{
- char *astr=NULL;
- if (ATTR_IS_STRING(attr->type))
- astr=gui_internal_escape(mode, attr->u.str);
- else if (ATTR_IS_COORD_GEO(attr->type)) {
- char *str2=coordinates_geo(attr->u.coord_geo, '\n');
- astr=gui_internal_escape(mode, str2);
- g_free(str2);
- } else if (ATTR_IS_INT(attr->type))
- astr=g_strdup_printf("%ld",attr->u.num);
- else
- astr=g_strdup_printf("Unsupported type %s",attr_to_name(attr->type));
- str=g_strconcat_printf(str,"%s%s%s",pre,astr,post);
- g_free(astr);
- return str;
-}
-
-static void
-gui_internal_cmd_write(struct gui_priv * this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *str=NULL;
- dbg(lvl_debug,"enter %s %p %p %p\n",function,in,out,valid);
- if (!in)
- return;
- while (*in) {
- str=gui_internal_append_attr(str, escape_mode_none, "", *in, "");
- in++;
- }
- if (str) {
- str=g_strdup_printf("<html>%s</html>\n",str);
-#if 0
- dbg(lvl_debug,"%s\n",str);
-#endif
- gui_internal_html_parse_text(this, str);
- }
- g_free(str);
-}
-
-static void
-gui_internal_onclick(struct attr ***in, char **onclick, char *set)
-{
- struct attr **i=*in;
- char *c,*str=NULL,*args=NULL,*sep="";
-
- if (!*i || !ATTR_IS_STRING((*i)->type) || !(*i)->u.str)
- goto error;
- str=g_strdup((*i)->u.str);
- i++;
- c=str;
- while (*c) {
- if (c[0] == '%' && c[1] == '{') {
- char format[4],*end=strchr(c+2,'}'),*replacement=NULL,*new_str;
- int is_arg;
- if (!end) {
- dbg(lvl_error,"Missing closing brace in format string %s\n",c);
- goto error;
- }
- if (end-c > sizeof(format)) {
- dbg(lvl_error,"Invalid format string %s\n",c);
- goto error;
- }
- strncpy(format, c+2, end-c-2);
- format[end-c-2]='\0';
- is_arg=end[1] == '*';
- c[0]='\0';
- if (!strcmp(format,"d")) {
- replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
- if (is_arg) {
- args=g_strconcat_printf(args, "%s%s", args ? "," : "", replacement);
- g_free(replacement);
- replacement=g_strdup("");
- }
-
- }
- if (!strcmp(format,"se")) {
- replacement=gui_internal_append_attr(NULL, escape_mode_string, "", *i++, "");
- if (is_arg) {
- char *arg=gui_internal_escape(escape_mode_string, replacement);
- args=g_strconcat_printf(args, "%s%s", args ? "," : "", arg);
- g_free(replacement);
- g_free(arg);
- replacement=g_strdup("");
- }
- }
- if (!replacement) {
- dbg(lvl_error,"Unsupported format string %s\n",format);
- goto error;
- }
- new_str=g_strconcat(str, replacement, end+1, NULL);
- c=new_str+strlen(str)+strlen(replacement);
- g_free(str);
- g_free(replacement);
- str=new_str;
- }
- c++;
- }
- *in=i;
- if (*onclick && strlen(*onclick))
- sep=";";
- if (str && strlen(str)) {
- char *old=*onclick;
- if (set) {
- char *setstr=gui_internal_escape(escape_mode_string,str);
- char *argssep="";
- if (args && strlen(args))
- argssep=",";
- *onclick=g_strconcat(old,sep,set,"(",setstr,argssep,args,")",NULL);
- } else {
- *onclick=g_strconcat(old,sep,str,NULL);
- }
- g_free(old);
- }
-error:
- g_free(str);
- g_free(args);
- return;
-}
-
-static void
-gui_internal_cmd_img(struct gui_priv * this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *str=g_strdup("<img"),*suffix=NULL,*onclick=g_strdup(""),*html;
-
- if (ATTR_IS_STRING((*in)->type)) {
- if ((*in)->u.str && strlen((*in)->u.str))
- str=gui_internal_append_attr(str, escape_mode_string|escape_mode_html, " class=", *in, "");
- in++;
- } else {
- dbg(lvl_error,"argument error: class argument not string\n");
- goto error;
- }
- if (ATTR_IS_STRING((*in)->type) && (*in)->u.str) {
- if ((*in)->u.str && strlen((*in)->u.str)) {
- str=gui_internal_append_attr(str, escape_mode_string|escape_mode_html, " src=", *in, "");
- }
- in++;
- } else {
- dbg(lvl_error,"argument error: image argument not string\n");
- goto error;
- }
- if (ATTR_IS_STRING((*in)->type) && (*in)->u.str) {
- if ((*in)->u.str && strlen((*in)->u.str)) {
- suffix=gui_internal_append_attr(NULL, escape_mode_html, ">", *in, "</img>");
- } else {
- suffix=g_strdup("/>");
- }
- in++;
- } else {
- dbg(lvl_error,"argument error: text argument not string\n");
- goto error;
- }
- gui_internal_onclick(&in,&onclick,NULL);
- gui_internal_onclick(&in,&onclick,"set");
- gui_internal_onclick(&in,&onclick,NULL);
- if (strlen(onclick)) {
- char *tmp=gui_internal_escape(escape_mode_html_apos, onclick);
- str=g_strconcat_printf(str," onclick='%s'",tmp);
- g_free(tmp);
- }
- g_free(onclick);
- html=g_strdup_printf("<html>%s%s</html>\n",str,suffix);
- dbg(lvl_debug,"return %s",html);
- gui_internal_html_parse_text(this, html);
- g_free(html);
-error:
- g_free(suffix);
- g_free(str);
- return;
-}
-
-static void
-gui_internal_cmd_debug(struct gui_priv * this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- char *str;
- dbg(lvl_debug,"begin\n");
- if (in) {
- while (*in) {
- str=attr_to_text(*in, NULL, 0);
- dbg(lvl_debug,"%s:%s\n",attr_to_name((*in)->type),str);
- in++;
- g_free(str);
- }
- }
- dbg(lvl_debug,"done\n");
-}
-
-static void
-gui_internal_cmd2(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
-{
- int entering=0;
- int ignore=1;
- if (in && in[0] && ATTR_IS_INT(in[0]->type)) {
- ignore=in[0]->u.num;
- in++;
- }
-
- if(!this->root.children) {
- entering=1;
- gui_internal_apply_config(this);
- gui_internal_enter(this, ignore);
- gui_internal_enter_setup(this);
- }
-
- if(!strcmp(function, "bookmarks"))
- gui_internal_cmd2_bookmarks(this, function, in, out, valid);
- else if(!strcmp(function, "formerdests"))
- gui_internal_cmd_formerdests(this, function, in, out, valid);
- else if(!strcmp(function, "locale"))
- gui_internal_cmd2_locale(this, function, in, out, valid);
- else if(!strcmp(function, "network_info"))
- gui_internal_cmd2_network_info(this, function, in, out, valid);
- else if(!strcmp(function, "position"))
- gui_internal_cmd2_position(this, function, in, out, valid);
- else if(!strcmp(function, "pois"))
- gui_internal_cmd2_pois(this, function, in, out, valid);
- else if(!strcmp(function, "route_description"))
- gui_internal_cmd2_route_description(this, function, in, out, valid);
- else if(!strcmp(function, "route_height_profile"))
- gui_internal_cmd2_route_height_profile(this, function, in, out, valid);
- else if(!strcmp(function, "setting_layout"))
- gui_internal_cmd2_setting_layout(this, function, in, out, valid);
- else if(!strcmp(function, "setting_maps"))
- gui_internal_cmd2_setting_maps(this, function, in, out, valid);
- else if(!strcmp(function, "setting_rules"))
- gui_internal_cmd2_setting_rules(this, function, in, out, valid);
- else if(!strcmp(function, "setting_vehicle"))
- gui_internal_cmd2_setting_vehicle(this, function, in, out, valid);
- else if(!strcmp(function, "town"))
- gui_internal_cmd2_town(this, function, in, out, valid);
- else if(!strcmp(function, "enter_coord"))
- gui_internal_cmd_enter_coord(this, function, in, out, valid);
- else if(!strcmp(function, "waypoints"))
- gui_internal_cmd2_waypoints(this, function, in, out, valid);
- else if(!strcmp(function, "about"))
- gui_internal_cmd2_about(this, function, in, out, valid);
-
- if(entering)
- graphics_draw_mode(this->gra, draw_mode_end);
-}
-
-static struct command_table commands[] = {
- {"E",command_cast(gui_internal_cmd_escape)},
- {"abort_navigation",command_cast(gui_internal_cmd2_abort_navigation)},
- {"back",command_cast(gui_internal_cmd2_back)},
- {"back_to_map",command_cast(gui_internal_cmd2_back_to_map)},
- {"bookmarks",command_cast(gui_internal_cmd2)},
- {"debug",command_cast(gui_internal_cmd_debug)},
- {"formerdests",command_cast(gui_internal_cmd2)},
- {"get_data",command_cast(gui_internal_get_data)},
- {"img",command_cast(gui_internal_cmd_img)},
- {"locale",command_cast(gui_internal_cmd2)},
- {"log",command_cast(gui_internal_cmd_log)},
- {"menu",command_cast(gui_internal_cmd_menu2)},
- {"position",command_cast(gui_internal_cmd2_position)},
- {"pois",command_cast(gui_internal_cmd2)},
- {"redraw_map",command_cast(gui_internal_cmd_redraw_map)},
- {"refresh",command_cast(gui_internal_cmd2_refresh)},
- {"route_description",command_cast(gui_internal_cmd2)},
- {"route_height_profile",command_cast(gui_internal_cmd2)},
- {"set",command_cast(gui_internal_cmd2_set)},
- {"setting_layout",command_cast(gui_internal_cmd2)},
- {"setting_maps",command_cast(gui_internal_cmd2)},
- {"setting_rules",command_cast(gui_internal_cmd2)},
- {"setting_vehicle",command_cast(gui_internal_cmd2)},
- {"town",command_cast(gui_internal_cmd2)},
- {"enter_coord",command_cast(gui_internal_cmd2)},
- {"quit",command_cast(gui_internal_cmd2_quit)},
- {"waypoints",command_cast(gui_internal_cmd2)},
- {"write",command_cast(gui_internal_cmd_write)},
- {"about",command_cast(gui_internal_cmd2)},
-#if HAS_IFADDRS
- {"network_info",command_cast(gui_internal_cmd2)},
-#endif
-};
-
-void
-gui_internal_command_init(struct gui_priv *this, struct attr **attrs)
-{
- struct attr *attr;
- if ((attr=attr_search(attrs, NULL, attr_callback_list))) {
- command_add_table(attr->u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), this);
- }
-}
-
-
diff --git a/navit/gui/internal/gui_internal_command.h b/navit/gui/internal/gui_internal_command.h
deleted file mode 100644
index ff8a70f9c..000000000
--- a/navit/gui/internal/gui_internal_command.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* prototypes */
-struct attr;
-struct gui_priv;
-struct pcoord;
-char *gui_internal_coordinates(struct pcoord *pc, char sep);
-void gui_internal_cmd2_quit(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid);
-void gui_internal_command_init(struct gui_priv *this, struct attr **attrs);
-/* end of prototypes */
diff --git a/navit/gui/internal/gui_internal_gesture.c b/navit/gui/internal/gui_internal_gesture.c
deleted file mode 100644
index d01a80f1d..000000000
--- a/navit/gui/internal/gui_internal_gesture.c
+++ /dev/null
@@ -1,145 +0,0 @@
-#include <glib.h>
-#include <stdlib.h>
-#include "config.h"
-#ifdef HAVE_API_WIN32_BASE
-#include <windows.h>
-#endif
-#ifndef _MSC_VER
-#include <sys/time.h>
-#endif /* _MSC_VER */
-#include "color.h"
-#include "coord.h"
-#include "point.h"
-#include "callback.h"
-#include "graphics.h"
-#include "debug.h"
-#include "navit.h"
-#include "types.h"
-#include "navit_nls.h"
-#include "event.h"
-#include "search.h"
-#include "country.h"
-#include "track.h"
-#include "gui_internal.h"
-#include "gui_internal_widget.h"
-#include "gui_internal_priv.h"
-#include "gui_internal_html.h"
-#include "gui_internal_menu.h"
-#include "gui_internal_gesture.h"
-
-void
-gui_internal_gesture_ring_clear(struct gui_priv *this)
-{
- this->gesture_ring_last=this->gesture_ring_first=0;
-};
-
-static struct gesture_elem *
-gui_internal_gesture_ring_get(struct gui_priv *this, int i)
-{
- int n=(this->gesture_ring_last-i+GESTURE_RINGSIZE)%GESTURE_RINGSIZE;
- if(n==this->gesture_ring_first)
- return NULL;
- return this->gesture_ring+n;
-};
-
-void
-gui_internal_gesture_ring_add(struct gui_priv *this, struct point *p)
-{
- long long msec;
-#ifndef HAVE_API_WIN32_CE
- struct timeval tv;
- gettimeofday(&tv,NULL);
- msec=((long long)tv.tv_sec)*1000+tv.tv_usec/1000;
-#else
- msec=GetTickCount();
-#endif
- this->gesture_ring_last++;
- this->gesture_ring_last%=GESTURE_RINGSIZE;
- if(this->gesture_ring_last==this->gesture_ring_first) {
- this->gesture_ring_first++;
- this->gesture_ring_first%=GESTURE_RINGSIZE;
- }
- this->gesture_ring[this->gesture_ring_last].p=*p;
- this->gesture_ring[this->gesture_ring_last].msec=msec;
- dbg(lvl_info,"msec="LONGLONG_FMT" x=%d y=%d\n",msec,p->x,p->y);
-};
-
-int
-gui_internal_gesture_get_vector(struct gui_priv *this, long long msec, struct point *p0, int *dx, int *dy)
-{
- struct gesture_elem *g;
- int x,y,dt;
- int i;
-
- dt=0;
-
- if(dx) *dx=0;
- if(dy) *dy=0;
- if(p0) {
- p0->x=-1;
- p0->y=-1;
- }
-
- g=gui_internal_gesture_ring_get(this,0);
- if(!g)
- return 0;
- x=g->p.x;
- y=g->p.y;
- if(p0) {
- *p0=g->p;
- }
- msec=g->msec;
- dbg(lvl_info,LONGLONG_FMT" %d %d\n",g->msec, g->p.x, g->p.y);
- for(i=1;(g=gui_internal_gesture_ring_get(this,i))!=NULL;i++) {
- if( msec-g->msec > 1000 )
- break;
- dt=msec-g->msec;
- if(dx) *dx=x-g->p.x;
- if(dy) *dy=y-g->p.y;
- if(p0) {
- *p0=g->p;
- }
- dbg(lvl_info,LONGLONG_FMT" %d %d\n",g->msec, g->p.x, g->p.y);
- }
- return dt;
-}
-
-int
-gui_internal_gesture_do(struct gui_priv *this)
-{
- int dt;
- int dx,dy;
-
- dt=gui_internal_gesture_get_vector(this, 1000, NULL, &dx, &dy);
-
- if( abs(dx) > this->icon_s*3 && abs(dy) < this->icon_s ) {
- struct widget *wt;
- dbg(lvl_debug,"horizontal dx=%d dy=%d\n",dx,dy);
-
- /* Prevent swiping if widget was scrolled beforehand */
- if(this->pressed==2)
- return 0;
-
- for(wt=this->highlighted;wt && wt->type!=widget_table;wt=wt->parent);
- if(!wt || wt->type!=widget_table || !wt->data)
- return 0;
- if(this->highlighted) {
- this->highlighted->state &= ~STATE_HIGHLIGHTED;
- this->highlighted=NULL;
- }
- if(dx<0)
- gui_internal_table_button_next(this,NULL,wt);
- else
- gui_internal_table_button_prev(this,NULL,wt);
- return 1;
- } else if( abs(dy) > this->icon_s*3 && abs(dx) < this->icon_s ) {
- dbg(lvl_debug,"vertical dx=%d dy=%d\n",dx,dy);
- } else if (dt>300 && abs(dx) <this->icon_s && abs(dy) <this->icon_s ) {
- dbg(lvl_debug,"longtap dx=%d dy=%d\n",dx,dy);
- } else {
- dbg(lvl_debug,"none dx=%d dy=%d\n",dx,dy);
- }
-
- return 0;
-
-};
diff --git a/navit/gui/internal/gui_internal_gesture.h b/navit/gui/internal/gui_internal_gesture.h
deleted file mode 100644
index f28c85d06..000000000
--- a/navit/gui/internal/gui_internal_gesture.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* prototypes */
-struct gui_priv;
-struct point;
-void gui_internal_gesture_ring_clear(struct gui_priv *this);
-void gui_internal_gesture_ring_add(struct gui_priv *this, struct point *p);
-int gui_internal_gesture_get_vector(struct gui_priv *this, long long msec, struct point *p0, int *dx, int *dy);
-int gui_internal_gesture_do(struct gui_priv *this);
-/* end of prototypes */
diff --git a/navit/gui/internal/gui_internal_html.c b/navit/gui/internal/gui_internal_html.c
deleted file mode 100644
index 9b42fbdec..000000000
--- a/navit/gui/internal/gui_internal_html.c
+++ /dev/null
@@ -1,504 +0,0 @@
-#include <glib.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include "callback.h"
-#include "debug.h"
-#include "coord.h"
-#include "point.h"
-#include "color.h"
-#include "graphics.h"
-#include "xmlconfig.h"
-#include "navit_nls.h"
-#include "gui.h"
-#include "command.h"
-struct gui_priv;
-#include "gui_internal.h"
-#include "gui_internal_widget.h"
-#include "gui_internal_priv.h"
-#include "gui_internal_html.h"
-#include "gui_internal_keyboard.h"
-#include "gui_internal_menu.h"
-
-
-
-struct form {
- char *onsubmit;
-};
-
-struct html_tag_map {
- char *tag_name;
- enum html_tag tag;
-} html_tag_map[] = {
- {"a",html_tag_a},
- {"h1",html_tag_h1},
- {"html",html_tag_html},
- {"img",html_tag_img},
- {"script",html_tag_script},
- {"form",html_tag_form},
- {"input",html_tag_input},
- {"div",html_tag_div},
-};
-
-
-static const char *
-find_attr(const char **names, const char **values, const char *name)
-{
- while (*names) {
- if (!g_ascii_strcasecmp(*names, name))
- return *values;
- names+=XML_ATTR_DISTANCE;
- values+=XML_ATTR_DISTANCE;
- }
- return NULL;
-}
-
-static char *
-find_attr_dup(const char **names, const char **values, const char *name)
-{
- return g_strdup(find_attr(names, values, name));
-}
-
-void
-gui_internal_html_main_menu(struct gui_priv *this)
-{
- gui_internal_prune_menu(this, NULL);
- gui_internal_html_load_href(this, "#Main Menu", 0);
-}
-
-static void
-gui_internal_html_command(struct gui_priv *this, struct widget *w, void *data)
-{
- gui_internal_evaluate(this,w->command);
-}
-
-static void
-gui_internal_html_submit_set(struct gui_priv *this, struct widget *w, struct form *form)
-{
- GList *l;
- if (w->form == form && w->name) {
- struct attr *attr=attr_new_from_text(w->name, w->text?w->text:"");
- if (attr)
- gui_set_attr(this->self.u.gui, attr);
- attr_free(attr);
- }
- l=w->children;
- while (l) {
- w=l->data;
- gui_internal_html_submit_set(this, w, form);
- l=g_list_next(l);
- }
-
-}
-
-static void
-gui_internal_html_submit(struct gui_priv *this, struct widget *w, void *data)
-{
- struct widget *menu;
- GList *l;
-
- dbg(lvl_debug,"enter form %p %s\n",w->form,w->form->onsubmit);
- l=g_list_last(this->root.children);
- menu=l->data;
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_highlight_do(this, NULL);
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
- gui_internal_html_submit_set(this, menu, w->form);
- gui_internal_evaluate(this,w->form->onsubmit);
-}
-
-void
-gui_internal_html_load_href(struct gui_priv *this, char *href, int replace)
-{
- if (replace)
- gui_internal_prune_menu_count(this, 1, 0);
- if (href && href[0] == '#') {
- dbg(lvl_debug,"href=%s\n",href);
- g_free(this->href);
- this->href=g_strdup(href);
- gui_internal_html_menu(this, this->html_text, href+1);
- }
-}
-
-void
-gui_internal_html_href(struct gui_priv *this, struct widget *w, void *data)
-{
- gui_internal_html_load_href(this, w->command, 0);
-}
-
-struct div_flags_map {
- char *attr;
- char *val;
- enum flags flags;
-} div_flags_map[] = {
- {"gravity","none",gravity_none},
- {"gravity","left",gravity_left},
- {"gravity","xcenter",gravity_xcenter},
- {"gravity","right",gravity_right},
- {"gravity","top",gravity_top},
- {"gravity","ycenter",gravity_ycenter},
- {"gravity","bottom",gravity_bottom},
- {"gravity","left_top",gravity_left_top},
- {"gravity","top_center",gravity_top_center},
- {"gravity","right_top",gravity_right_top},
- {"gravity","left_center",gravity_left_center},
- {"gravity","center",gravity_center},
- {"gravity","right_center",gravity_right_center},
- {"gravity","left_bottom",gravity_left_bottom},
- {"gravity","bottom_center",gravity_bottom_center},
- {"gravity","right_bottom",gravity_right_bottom},
- {"expand","1",flags_expand},
- {"fill","1",flags_fill},
- {"orientation","horizontal",orientation_horizontal},
- {"orientation","vertical",orientation_vertical},
- {"orientation","horizontal_vertical",orientation_horizontal_vertical},
-};
-
-static enum flags
-div_flag(const char **names, const char **values, char *name)
-{
- int i;
- enum flags ret=0;
- const char *value=find_attr(names, values, name);
- if (!value)
- return ret;
- for (i = 0 ; i < sizeof(div_flags_map)/sizeof(struct div_flags_map); i++) {
- if (!strcmp(div_flags_map[i].attr,name) && !strcmp(div_flags_map[i].val,value))
- ret|=div_flags_map[i].flags;
- }
- return ret;
-}
-
-static enum flags
-div_flags(const char **names, const char **values)
-{
- enum flags flags;
- flags = div_flag(names, values, "gravity");
- flags |= div_flag(names, values, "orientation");
- flags |= div_flag(names, values, "expand");
- flags |= div_flag(names, values, "fill");
- return flags;
-}
-
-static struct widget *
-html_image(struct gui_priv *this, const char **names, const char **values)
-{
- const char *src, *size;
- struct graphics_image *img=NULL;
-
- src=find_attr(names, values, "src");
- if (!src)
- return NULL;
- size=find_attr(names, values, "size");
- if (!size) {
- const char *class=find_attr(names, values, "class");
- if (class && !strcasecmp(class,"centry"))
- size="xs";
- else
- size="l";
- }
- if (!strcmp(size,"l"))
- img=image_new_l(this, src);
- else if (!strcmp(size,"s"))
- img=image_new_s(this, src);
- else if (!strcmp(size,"xs"))
- img=image_new_xs(this, src);
- if (!img)
- return NULL;
- return gui_internal_image_new(this, img);
-}
-
-static void
-gui_internal_html_start(xml_context *dummy, const char *tag_name, const char **names, const char **values, void *data, GError **error)
-{
- struct gui_priv *this=data;
- int i;
- enum html_tag tag=html_tag_none;
- struct html *html=&this->html[this->html_depth];
- const char *cond, *type, *font_size;
-
- if (!g_ascii_strcasecmp(tag_name,"text") || !g_ascii_strcasecmp(tag_name,"p"))
- return;
- html->skip=0;
- html->command=NULL;
- html->name=NULL;
- html->href=NULL;
- html->refresh_cond=NULL;
- html->w=NULL;
- html->container=NULL;
- html->font_size=0;
- cond=find_attr(names, values, "cond");
-
- if (cond && !this->html_skip) {
- if (!command_evaluate_to_boolean(&this->self, cond, NULL))
- html->skip=1;
- }
-
- for (i=0 ; i < sizeof(html_tag_map)/sizeof(struct html_tag_map); i++) {
- if (!g_ascii_strcasecmp(html_tag_map[i].tag_name, tag_name)) {
- tag=html_tag_map[i].tag;
- break;
- }
- }
- html->tag=tag;
- html->class=find_attr_dup(names, values, "class");
- if (!this->html_skip && !html->skip) {
- switch (tag) {
- case html_tag_a:
- html->name=find_attr_dup(names, values, "name");
- if (html->name) {
- html->skip=this->html_anchor ? strcmp(html->name,this->html_anchor) : 0;
- if (!html->skip)
- this->html_anchor_found=1;
- }
- html->command=find_attr_dup(names, values, "onclick");
- html->href=find_attr_dup(names, values, "href");
- html->refresh_cond=find_attr_dup(names, values, "refresh_cond");
- break;
- case html_tag_img:
- html->command=find_attr_dup(names, values, "onclick");
- html->w=html_image(this, names, values);
- break;
- case html_tag_form:
- this->form=g_new0(struct form, 1);
- this->form->onsubmit=find_attr_dup(names, values, "onsubmit");
- break;
- case html_tag_input:
- type=find_attr_dup(names, values, "type");
- if (!type)
- break;
- if (!strcmp(type,"image")) {
- html->w=html_image(this, names, values);
- if (html->w) {
- html->w->state|=STATE_SENSITIVE;
- html->w->func=gui_internal_html_submit;
- }
- }
- if (!strcmp(type,"text") || !strcmp(type,"password")) {
- const char *value=find_attr(names, values, "value");
- html->w=gui_internal_label_new(this, value);
- html->w->background=this->background;
- html->w->flags |= div_flags(names, values);
- html->w->state|=STATE_EDITABLE;
- if (!this->editable) {
- this->editable=html->w;
- html->w->state|=STATE_EDIT;
- }
- this->keyboard_required=1;
- if (!strcmp(type,"password"))
- html->w->flags2 |= 1;
- }
- if (html->w) {
- html->w->form=this->form;
- html->w->name=find_attr_dup(names, values, "name");
- }
- break;
- case html_tag_div:
- html->w=gui_internal_box_new(this, div_flags(names, values));
- font_size=find_attr(names, values, "font");
- if (font_size)
- html->font_size=atoi(font_size);
- html->container=this->html_container;
- this->html_container=html->w;
- break;
- default:
- break;
- }
- }
- this->html_skip+=html->skip;
- this->html_depth++;
-}
-
-static void
-gui_internal_html_end(xml_context *dummy, const char *tag_name, void *data, GError **error)
-{
- struct gui_priv *this=data;
- struct html *html;
- struct html *parent=NULL;
-
- if (!g_ascii_strcasecmp(tag_name,"text") || !g_ascii_strcasecmp(tag_name,"p"))
- return;
- this->html_depth--;
- html=&this->html[this->html_depth];
- if (this->html_depth > 0)
- parent=&this->html[this->html_depth-1];
-
-
- if (!this->html_skip) {
- if (html->command && html->w) {
- html->w->state |= STATE_SENSITIVE;
- html->w->command=html->command;
- html->w->func=gui_internal_html_command;
- html->command=NULL;
- }
- if (parent && (parent->href || parent->command) && html->w) {
- html->w->state |= STATE_SENSITIVE;
- if (parent->command) {
- html->w->command=g_strdup(parent->command);
- html->w->func=gui_internal_html_command;
- } else {
- html->w->command=g_strdup(parent->href);
- html->w->func=gui_internal_html_href;
- }
- }
- switch (html->tag) {
- case html_tag_div:
- this->html_container=html->container;
- case html_tag_img:
- case html_tag_input:
- gui_internal_widget_append(this->html_container, html->w);
- break;
- case html_tag_form:
- this->form=NULL;
- break;
- default:
- break;
- }
- }
- this->html_skip-=html->skip;
- g_free(html->command);
- g_free(html->name);
- g_free(html->href);
- g_free(html->class);
- g_free(html->refresh_cond);
-}
-
-static void
-gui_internal_refresh_callback_called(struct gui_priv *this, struct menu_data *menu_data)
-{
- if (gui_internal_menu_data(this) == menu_data) {
- char *href=g_strdup(menu_data->href);
- gui_internal_html_load_href(this, href, 1);
- g_free(href);
- }
-}
-
-static void
-gui_internal_set_refresh_callback(struct gui_priv *this, char *cond)
-{
- dbg(lvl_info,"cond=%s\n",cond);
- if (cond) {
- enum attr_type type;
- struct object_func *func;
- struct menu_data *menu_data=gui_internal_menu_data(this);
- dbg(lvl_info,"navit=%p\n",this->nav);
- type=command_evaluate_to_attr(&this->self, cond, NULL, &menu_data->refresh_callback_obj);
- if (type == attr_none) {
- dbg(lvl_error,"can't get type of '%s'\n",cond);
- return;
- }
- func=object_func_lookup(menu_data->refresh_callback_obj.type);
- if (!func)
- dbg(lvl_error,"'%s' has no functions\n",cond);
- if (func && !func->add_attr)
- dbg(lvl_error,"'%s' has no add_attr function\n",cond);
- if (!func || !func->add_attr)
- return;
- menu_data->refresh_callback.type=attr_callback;
- menu_data->refresh_callback.u.callback=callback_new_attr_2(callback_cast(gui_internal_refresh_callback_called),type,this,menu_data);
- func->add_attr(menu_data->refresh_callback_obj.u.data, &menu_data->refresh_callback);
- }
-}
-
-static void
-gui_internal_html_text(xml_context *dummy, const char *text, gsize len, void *data, GError **error)
-{
- struct gui_priv *this=data;
- struct widget *w;
- int depth=this->html_depth-1;
- struct html *html=&this->html[depth];
- gchar *text_stripped;
-
- if (this->html_skip)
- return;
- while (isspace(text[0])) {
- text++;
- len--;
- }
- while (len > 0 && isspace(text[len-1]))
- len--;
-
- text_stripped = g_strndup(text, len);
- if (html->tag == html_tag_html && depth > 2) {
- if (this->html[depth-1].tag == html_tag_script) {
- html=&this->html[depth-2];
- }
- }
- switch (html->tag) {
- case html_tag_a:
- if (html->name && len) {
- if (html->class && !strcasecmp(html->class,"clist"))
- this->html_container=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill /* |flags_scrolly */);
- else
- this->html_container=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(gui_internal_menu(this, _(text_stripped)), this->html_container);
- gui_internal_menu_data(this)->href=g_strdup(this->href);
- gui_internal_set_refresh_callback(this, html->refresh_cond);
- this->html_container->spx=this->spacing*10;
- }
- break;
- case html_tag_h1:
- if (!this->html_container) {
- this->html_container=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(gui_internal_menu(this, _(text_stripped)), this->html_container);
- this->html_container->spx=this->spacing*10;
- }
- break;
- case html_tag_img:
- if (len) {
- if (html->class && !strcasecmp(html->class, "centry"))
- w=gui_internal_box_new(this, gravity_left_top|orientation_horizontal|flags_fill);
- else
- w=gui_internal_box_new(this, gravity_center|orientation_vertical);
- gui_internal_widget_append(w, html->w);
- gui_internal_widget_append(w, gui_internal_text_new(this, _(text_stripped), gravity_left_top|orientation_vertical|flags_fill));
- html->w=w;
- }
- break;
- case html_tag_div:
- if (len) {
- gui_internal_widget_append(html->w, gui_internal_text_font_new(this, _(text_stripped), html->font_size, gravity_center|orientation_vertical));
- }
- break;
- case html_tag_script:
- dbg(lvl_debug,"execute %s\n",text_stripped);
- gui_internal_evaluate(this,text_stripped);
- break;
- default:
- break;
- }
- g_free(text_stripped);
-}
-
-void
-gui_internal_html_parse_text(struct gui_priv *this, char *doc)
-{
- xml_parse_text(doc, this, gui_internal_html_start, gui_internal_html_end, gui_internal_html_text);
-}
-
-void
-gui_internal_html_menu(struct gui_priv *this, const char *document, char *anchor)
-{
- char *doc=g_strdup(document);
- graphics_draw_mode(this->gra, draw_mode_begin);
- this->html_container=NULL;
- this->html_depth=0;
- this->html_anchor=anchor;
- this->html_anchor_found=0;
- this->form=NULL;
- this->keyboard_required=0;
- this->editable=NULL;
- callback_list_call_attr_2(this->cbl,attr_gui,anchor,&doc);
- gui_internal_html_parse_text(this, doc);
- g_free(doc);
- if (this->keyboard_required) {
- this->html_container->flags=gravity_center|orientation_vertical|flags_expand|flags_fill;
- if (this->keyboard)
- gui_internal_widget_append(this->html_container, gui_internal_keyboard(this, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"))));
- else
- gui_internal_keyboard_show_native(this, this->html_container, VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG")), getenv("LANG"));
- }
- gui_internal_menu_render(this);
- graphics_draw_mode(this->gra, draw_mode_end);
-}
-
diff --git a/navit/gui/internal/gui_internal_html.h b/navit/gui/internal/gui_internal_html.h
deleted file mode 100644
index 2333162a9..000000000
--- a/navit/gui/internal/gui_internal_html.h
+++ /dev/null
@@ -1,5 +0,0 @@
-void gui_internal_html_main_menu(struct gui_priv *this);
-void gui_internal_html_load_href(struct gui_priv *this, char *href, int replace);
-void gui_internal_html_href(struct gui_priv *this, struct widget *w, void *data);
-void gui_internal_html_parse_text(struct gui_priv *this, char *doc);
-void gui_internal_html_menu(struct gui_priv *this, const char *document, char *anchor);
diff --git a/navit/gui/internal/gui_internal_keyboard.c b/navit/gui/internal/gui_internal_keyboard.c
deleted file mode 100644
index 7ef1c3d36..000000000
--- a/navit/gui/internal/gui_internal_keyboard.c
+++ /dev/null
@@ -1,560 +0,0 @@
-#include <glib.h>
-#include <stdlib.h>
-#include "color.h"
-#include "coord.h"
-#include "point.h"
-#include "callback.h"
-#include "graphics.h"
-#include "debug.h"
-#include "gui_internal.h"
-#include "gui_internal_widget.h"
-#include "gui_internal_priv.h"
-#include "gui_internal_menu.h"
-#include "gui_internal_keyboard.h"
-
-/**
- * @brief Switch keyboard mode to uppercase if it's in lowercase mode and {@code VKBD_MODE_2} is set.
- *
- * Called when there's no input left in the input field.
- *
- * @param this The internal GUI instance
- */
-void
-gui_internal_keyboard_to_upper_case(struct gui_priv *this)
-{
- struct menu_data *md;
-
- if (!this->keyboard)
- return;
-
- md=gui_internal_menu_data(this);
-
- if (md->keyboard_mode == (VKBD_LATIN_LOWER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_UPPER | VKBD_FLAG_2);
- if (md->keyboard_mode == (VKBD_UMLAUT_LOWER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_UPPER | VKBD_FLAG_2);
- if (md->keyboard_mode == (VKBD_CYRILLIC_LOWER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_UPPER | VKBD_FLAG_2);
-}
-
-/**
- * @brief Switch keyboard mode to lowercase if it's in uppercase mode and {@code VKBD_MODE_2} is set.
- *
- * Called on each alphanumeric input.
- *
- * @param this The internal GUI instance
- */
-void
-gui_internal_keyboard_to_lower_case(struct gui_priv *this)
-{
- struct menu_data *md;
-
- if (!this->keyboard)
- return;
-
- md=gui_internal_menu_data(this);
-
- if (md->keyboard_mode == (VKBD_LATIN_UPPER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_LATIN_LOWER | VKBD_FLAG_2);
- if (md->keyboard_mode == (VKBD_UMLAUT_UPPER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_UMLAUT_LOWER | VKBD_FLAG_2);
- if (md->keyboard_mode == (VKBD_CYRILLIC_UPPER | VKBD_FLAG_2))
- gui_internal_keyboard_do(this, md->keyboard, VKBD_CYRILLIC_LOWER | VKBD_FLAG_2);
-}
-
-/**
- * @brief Processes a key press on the internal GUI keyboard
- *
- * If the keyboard is currently in uppercase mode and {@code VKBD_MODE_2} is set, it is tswitched to
- * the corresponding lowercase mode in {@code gui_internal_keypress_do}.
- *
- * @param this The internal GUI instance
- * @param wm
- * @param data Not used
- */
-static void
-gui_internal_cmd_keypress(struct gui_priv *this, struct widget *wm, void *data)
-{
- gui_internal_keypress_do(this, (char *) wm->data);
-}
-
-static struct widget *
-gui_internal_keyboard_key_data(struct gui_priv *this, struct widget *wkbd, char *text, int font, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data, void (*data_free)(void *data), int w, int h)
-{
- struct widget *wk;
- gui_internal_widget_append(wkbd, wk=gui_internal_button_font_new_with_callback(this, text, font,
- NULL, gravity_center|orientation_vertical, func, data));
- wk->data_free=data_free;
- wk->background=this->background;
- wk->bl=0;
- wk->br=0;
- wk->bt=0;
- wk->bb=0;
- wk->w=w;
- wk->h=h;
- return wk;
-}
-
-static struct widget *
-gui_internal_keyboard_key(struct gui_priv *this, struct widget *wkbd, char *text, char *key, int w, int h)
-{
- return gui_internal_keyboard_key_data(this, wkbd, text, 0, gui_internal_cmd_keypress, g_strdup(key), g_free_func,w,h);
-}
-
-static void gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *data);
-
-
-/**
- * @struct gui_internal_keyb_mode
- * @brief Describes a keyboard mode
- */
-/**
- * @var gui_internal_keyb_modes
- * @brief A list of all available keyboard modes
- */
-struct gui_internal_keyb_mode {
- char title[16]; /**< Label to be displayed on keys that switch to it */
- int font; /**< Font size of label */
- int case_mode; /**< Mode to switch to when case CHANGE() key is pressed. */
- int umlaut_mode; /**< Mode to switch to when UMLAUT() key is pressed. */
-} gui_internal_keyb_modes[]= {
- /* 0: VKBD_LATIN_UPPER */ {"ABC", 2, VKBD_LATIN_LOWER, VKBD_UMLAUT_UPPER},
- /* 8: VKBD_LATIN_LOWER */ {"abc", 2, VKBD_LATIN_UPPER, VKBD_UMLAUT_LOWER},
- /*16: VKBD_NUMERIC */ {"123", 2, VKBD_LATIN_UPPER, VKBD_UMLAUT_UPPER},
- /*24: VKBD_UMLAUT_UPPER */ {"ÄÖÜ", 2, VKBD_UMLAUT_LOWER, VKBD_LATIN_UPPER},
- /*32: VKBD_UMLAUT_LOWER */ {"äöü", 2, VKBD_UMLAUT_UPPER, VKBD_LATIN_LOWER},
- /*40: VKBD_CYRILLIC_UPPER*/ {"АБВ", 2, VKBD_CYRILLIC_LOWER, VKBD_LATIN_UPPER},
- /*48: VKBD_CYRILLIC_LOWER*/ {"абв", 2, VKBD_CYRILLIC_UPPER, VKBD_LATIN_LOWER},
- /*56: VKBD_DEGREE */ {"DEG", 2, VKBD_FLAG_2, VKBD_FLAG_2}
-};
-
-
-// Some macros that make the keyboard layout easier to visualise in
-// the source code. The macros are #undef'd after this function.
-#define KEY(x) gui_internal_keyboard_key(this, wkbd, (x), (x), max_w, max_h)
-#define SPACER() gui_internal_keyboard_key_data(this, wkbd, "", 0, NULL, NULL, NULL,max_w,max_h)
-#define MODE(x) gui_internal_keyboard_key_data(this, wkbd, \
- gui_internal_keyb_modes[(x)/8].title, \
- gui_internal_keyb_modes[(x)/8].font, \
- gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h) \
- -> datai = (mode & VKBD_MASK_7) | ((x) & VKBD_LAYOUT_MASK)
-#define SWCASE() MODE(gui_internal_keyb_modes[mode/8].case_mode)
-#define UMLAUT() MODE(gui_internal_keyb_modes[mode/8].umlaut_mode)
-/**
- * @brief Creates a new keyboard widget or switches the layout of an existing widget
- *
- * This is an internal helper function that is not normally called directly. To create a new keyboard
- * widget, GUI widgets should call {@link gui_internal_keyboard(struct gui_priv *, struct widget *, int)}.
- *
- * @param this The internal GUI instance
- * @param wkbdb The existing keyboard widget whose layout is to be switched, or {@code NULL} to create a
- * new keyboard widget
- * @param mode The new keyboard mode, see {@link gui_internal_keyboard(struct gui_priv *, struct widget *, int)}
- * for a description of possible values
- *
- * @return {@code wkbdb} if a non-NULL value was passed, else a new keyboard widget will be returned.
- */
-struct widget *
-gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
-{
- struct widget *wkbd,*wk;
- struct menu_data *md=gui_internal_menu_data(this);
- int i, max_w=this->root.w, max_h=this->root.h;
- int render=0;
- char *space="_";
- char *backspace="←";
- char *hide="▼";
- char *unhide="▲";
-
- if (wkbdb) {
- this->current.x=-1;
- this->current.y=-1;
- gui_internal_highlight(this);
- if (md->keyboard_mode & VKBD_FLAG_1024)
- render=2;
- else
- render=1;
- gui_internal_widget_children_destroy(this, wkbdb);
- } else
- wkbdb=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
- md->keyboard=wkbdb;
- md->keyboard_mode=mode;
- wkbd=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
- wkbd->background=this->background;
- wkbd->cols=8;
- wkbd->spx=0;
- wkbd->spy=0;
- max_w=max_w/8;
- max_h=max_h/8; // Allows 3 results in the list when searching for Towns
- wkbd->p.y=max_h*2;
- if (((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_UPPER) || ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_LOWER)) { // Russian/Ukrainian/Belarussian layout needs more space...
- max_h=max_h*4/5;
- max_w=max_w*8/9;
- wkbd->cols=9;
- }
-
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_UPPER) {
- for (i = 0 ; i < 26 ; i++) {
- char text[]={'A'+i,'\0'};
- KEY(text);
- }
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
- if (!(mode & VKBD_MASK_7)) {
- KEY("-");
- KEY("'");
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- } else {
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- SWCASE();
- MODE(VKBD_NUMERIC);
-
- }
- UMLAUT();
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_LATIN_LOWER) {
- for (i = 0 ; i < 26 ; i++) {
- char text[]={'a'+i,'\0'};
- KEY(text);
- }
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
- if (!(mode & VKBD_MASK_7)) {
- KEY("-");
- KEY("'");
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- } else {
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- SWCASE();
-
- MODE(VKBD_NUMERIC);
- }
- UMLAUT();
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_NUMERIC) {
- for (i = 0 ; i < 10 ; i++) {
- char text[]={'0'+i,'\0'};
- KEY(text);
- }
- /* ("8") ("9")*/KEY("."); KEY("°"); KEY("'"); KEY("\"");KEY("-"); KEY("+");
- KEY("*"); KEY("/"); KEY("("); KEY(")"); KEY("="); KEY("?"); KEY(":"); SPACER();
-
-
-
- if (!(mode & VKBD_MASK_7)) {
- SPACER();
- KEY("-");
- KEY("'");
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- SPACER();
- SPACER();
- } else {
- SPACER();
- MODE(VKBD_CYRILLIC_UPPER);
- MODE(VKBD_CYRILLIC_LOWER);
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
- MODE(VKBD_LATIN_UPPER);
- MODE(VKBD_LATIN_LOWER);
- }
- UMLAUT();
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_UMLAUT_UPPER) {
- KEY("Ä"); KEY("Ë"); KEY("Ï"); KEY("Ö"); KEY("Ü"); KEY("Æ"); KEY("Ø"); KEY("Å");
- KEY("Á"); KEY("É"); KEY("Í"); KEY("Ó"); KEY("Ú"); KEY("Š"); KEY("Č"); KEY("Ž");
- KEY("À"); KEY("È"); KEY("Ì"); KEY("Ò"); KEY("Ù"); KEY("Ś"); KEY("Ć"); KEY("Ź");
- KEY("Â"); KEY("Ê"); KEY("Î"); KEY("Ô"); KEY("Û"); SPACER();
-
- UMLAUT();
-
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_UMLAUT_LOWER) {
- KEY("ä"); KEY("ë"); KEY("ï"); KEY("ö"); KEY("ü"); KEY("æ"); KEY("ø"); KEY("å");
- KEY("á"); KEY("é"); KEY("í"); KEY("ó"); KEY("ú"); KEY("š"); KEY("č"); KEY("ž");
- KEY("à"); KEY("è"); KEY("ì"); KEY("ò"); KEY("ù"); KEY("ś"); KEY("ć"); KEY("ź");
- KEY("â"); KEY("ê"); KEY("î"); KEY("ô"); KEY("û"); KEY("ß");
-
- UMLAUT();
-
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_UPPER) {
- KEY("А"); KEY("Б"); KEY("В"); KEY("Г"); KEY("Д"); KEY("Е"); KEY("Ж"); KEY("З"); KEY("И");
- KEY("Й"); KEY("К"); KEY("Л"); KEY("М"); KEY("Н"); KEY("О"); KEY("П"); KEY("Р"); KEY("С");
- KEY("Т"); KEY("У"); KEY("Ф"); KEY("Х"); KEY("Ц"); KEY("Ч"); KEY("Ш"); KEY("Щ"); KEY("Ъ");
- KEY("Ы"); KEY("Ь"); KEY("Э"); KEY("Ю"); KEY("Я"); KEY("Ё"); KEY("І"); KEY("Ї"); KEY("Ў");
- SPACER(); SPACER(); SPACER();
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
-
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
-
- SWCASE();
-
- MODE(VKBD_NUMERIC);
-
- SPACER();
-
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_CYRILLIC_LOWER) {
- KEY("а"); KEY("б"); KEY("в"); KEY("г"); KEY("д"); KEY("е"); KEY("ж"); KEY("з"); KEY("и");
- KEY("й"); KEY("к"); KEY("л"); KEY("м"); KEY("н"); KEY("о"); KEY("п"); KEY("р"); KEY("с");
- KEY("т"); KEY("у"); KEY("ф"); KEY("х"); KEY("ц"); KEY("ч"); KEY("ш"); KEY("щ"); KEY("ъ");
- KEY("ы"); KEY("ь"); KEY("э"); KEY("ю"); KEY("я"); KEY("ё"); KEY("і"); KEY("ї"); KEY("ў");
- SPACER(); SPACER(); SPACER();
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
-
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
-
- SWCASE();
-
- MODE(VKBD_NUMERIC);
-
- SPACER();
-
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
-
-
- if(md->search_list && md->search_list->type==widget_table) {
- struct table_data *td=(struct table_data*)(md->search_list->data);
- td->scroll_buttons.button_box_hide = !(mode & VKBD_FLAG_1024);
- }
-
- if ((mode & VKBD_LAYOUT_MASK) == VKBD_DEGREE) { /* special case for coordinates input screen (enter_coord) */
- KEY("0"); KEY("1"); KEY("2"); KEY("3"); KEY("4"); SPACER(); KEY("N"); KEY("S");
- KEY("5"); KEY("6"); KEY("7"); KEY("8"); KEY("9"); SPACER(); KEY("E"); KEY("W");
- KEY("°"); KEY("."); KEY("'");
- gui_internal_keyboard_key(this, wkbd, space," ",max_w,max_h);
- SPACER();
-
- wk=gui_internal_keyboard_key_data(this, wkbd, hide, 0, gui_internal_keyboard_change, wkbdb, NULL,max_w,max_h);
- wk->datai = mode | VKBD_FLAG_1024;
-
- SPACER();
- gui_internal_keyboard_key(this, wkbd, backspace,"\b",max_w,max_h);
- }
-
- if (mode & VKBD_FLAG_1024) {
- char *text=NULL;
- int font=0;
- struct widget *wkl;
- mode &= ~VKBD_FLAG_1024;
- text=gui_internal_keyb_modes[mode/8].title;
- font=gui_internal_keyb_modes[mode/8].font;
- wk=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_fill);
- wk->func=gui_internal_keyboard_change;
- wk->data=wkbdb;
- wk->background=this->background;
- wk->bl=0;
- wk->br=0;
- wk->bt=0;
- wk->bb=0;
- wk->w=max_w;
- wk->h=max_h;
- wk->datai=mode;
- wk->state |= STATE_SENSITIVE;
- gui_internal_widget_append(wk, wkl=gui_internal_label_new(this, unhide));
- wkl->background=NULL;
- gui_internal_widget_append(wk, wkl=gui_internal_label_font_new(this, text, font));
- wkl->background=NULL;
- gui_internal_widget_append(wkbd, wk);
- if (render)
- render=2;
- }
- gui_internal_widget_append(wkbdb, wkbd);
- if (render == 1) {
- gui_internal_widget_pack(this, wkbdb);
- gui_internal_widget_render(this, wkbdb);
- } else if (render == 2) {
- gui_internal_menu_reset_pack(this);
- gui_internal_menu_render(this);
- }
- return wkbdb;
-}
-#undef KEY
-#undef SPACER
-#undef SWCASE
-#undef UMLAUT
-#undef MODE
-
-/**
- * @brief Creates a keyboard widget.
- *
- * This function creates a widget to display the internal GUI keyboard.
- *
- * The {@code mode} argument specifies the type of keyboard which should initially be displayed. Refer
- * to {@link enum vkbd_mode} for a list of possible modes and their meaning.
- *
- * @param this The internal GUI instance
- * @param mode The mode for the keyboard
- *
- * @return A new keyboard widget
- */
-struct widget *
-gui_internal_keyboard(struct gui_priv *this, int mode)
-{
- if (! this->keyboard)
- return NULL;
- return gui_internal_keyboard_do(this, NULL, mode);
-}
-
-static void
-gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *data)
-{
- gui_internal_keyboard_do(this, key->data, key->datai);
-}
-
-/**
- * @brief Returns the default keyboard mode for a country.
- *
- * The return value can be passed to {@link gui_internal_keyboard(struct gui_priv *, int)} and related
- * functions.
- *
- * @param lang The two-letter country code
- *
- * @return {@code VKBD_CYRILLIC_UPPER} for countries using the Cyrillic alphabet,
- * {@code VKBD_LATIN_UPPER} otherwise
- */
-int
-gui_internal_keyboard_init_mode(char *lang)
-{
- int ret=0;
- /* do not crash if lang is NULL, which may be returned by getenv*/
- if(lang == NULL)
- return VKBD_LATIN_UPPER;
-
- /* Converting to upper case here is required for Android */
- lang=g_ascii_strup(lang,-1);
- /*
- * Set cyrillic keyboard for countries using Cyrillic alphabet
- */
- if (strstr(lang,"RU"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"UA"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"BY"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"RS"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"BG"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"MK"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"KZ"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"KG"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"TJ"))
- ret = VKBD_CYRILLIC_UPPER;
- else if (strstr(lang,"MN"))
- ret = VKBD_CYRILLIC_UPPER;
- g_free(lang);
- return ret;
-}
-
-
-/**
- * @brief Hides the platform's native on-screen keyboard or other input method
- *
- * This function is called as the {@code wfree} method of the placeholder widget for the platform's
- * native on-screen keyboard. It is a wrapper around the corresponding method of the graphics plugin,
- * which takes care of all platform-specific actions to hide the on-screen input method it previously
- * displayed.
- *
- * A call to this function indicates that Navit no longer needs the input method and is about to destroy
- * its placeholder widget. Navit will subsequently reclaim any screen real estate it may have previously
- * reserved for the input method.
- *
- * This function will free the {@code struct graphics_keyboard} pointed to by {@code w->data}
- *
- * @param this The internal GUI instance
- * @param w The placeholder widget
- */
-static void gui_internal_keyboard_hide_native(struct gui_priv *this_, struct widget *w) {
- struct graphics_keyboard *kbd = (struct graphics_keyboard *) w->data;
-
- if (kbd) {
- graphics_hide_native_keyboard(this_->gra, kbd);
- g_free(kbd->lang);
- g_free(kbd->gui_priv);
- } else
- dbg(lvl_warning, "no graphics_keyboard found, cleanup failed\n");
- g_free(w);
-}
-
-
-/**
- * @brief Shows the platform's native on-screen keyboard or other input method
- *
- * This method is a wrapper around the corresponding method of the graphics plugin, which takes care of
- * all platform-specific details. In particular, it is up to the graphics plugin to determine how to
- * handle the request: it may show its on-screen keyboard or another input method (such as stroke
- * recognition). It may choose to simply ignore the request, which will typically occur when a hardware
- * keyboard (or other hardware input) is available.
- *
- * The platform's native input method may obstruct parts of Navit's UI. To prevent parts of the UI from
- * becoming unreachable, this method will insert an empty box widget in the appropriate size at the
- * appropriate position, provided the graphics plugin reports the correct values. Otherwise a zero-size
- * widget is inserted. If the graphics driver decides not to display an on-screen input method, no
- * widget will be created and the return value will be {@code NULL}.
- *
- * The widget's {@code wfree} function, to be called when the widget is destroyed, will be used to hide
- * the platform keyboard when it is no longer needed.
- *
- * @param this The internal GUI instance
- * @param w The parent of the widget requiring text input
- * @param mode The requested keyboard mode
- * @param lang The language for text input, used to select a keyboard layout
- *
- * @return The placeholder widget for the on-screen keyboard, may be {@code NULL}
- */
-struct widget * gui_internal_keyboard_show_native(struct gui_priv *this, struct widget *w, int mode, char *lang) {
- struct widget *ret = NULL;
- struct menu_data *md = gui_internal_menu_data(this);
- struct graphics_keyboard *kbd = g_new0(struct graphics_keyboard, 1);
- int res;
-
- kbd->mode = mode;
- if (lang)
- kbd->lang = g_strdup(lang);
- res = graphics_show_native_keyboard(this->gra, kbd);
-
- switch(res) {
- case -1:
- dbg(lvl_error, "graphics has no show_native_keyboard method, cannot display keyboard\n");
- /* no break */
- case 0:
- g_free(kbd);
- return NULL;
- }
-
- ret = gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
- md->keyboard = ret;
- md->keyboard_mode=mode;
- ret->wfree = gui_internal_keyboard_hide_native;
- if (kbd->h < 0) {
- ret->h = w->h;
- ret->hmin = w->hmin;
- } else
- ret->h = kbd->h;
- if (kbd->w < 0) {
- ret->w = w->w;
- ret->wmin = w->wmin;
- } else
- ret->w = kbd->w;
- dbg(lvl_error, "ret->w=%d, ret->h=%d\n", ret->w, ret->h);
- ret->data = (void *) kbd;
- gui_internal_widget_append(w, ret);
- dbg(lvl_error, "return\n");
- return ret;
-}
diff --git a/navit/gui/internal/gui_internal_keyboard.h b/navit/gui/internal/gui_internal_keyboard.h
deleted file mode 100644
index 9b9039224..000000000
--- a/navit/gui/internal/gui_internal_keyboard.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Modes for the on-screen keyboard
- */
-enum vkbd_mode {
- /* layouts */
- VKBD_LATIN_UPPER = 0, /*!< Latin uppercase characters */
- VKBD_LATIN_LOWER = 8, /*!< Latin lowercase characters */
- VKBD_NUMERIC = 16, /*!< Numeric keyboard */
- VKBD_UMLAUT_UPPER = 24, /*!< Extended Latin uppercase characters */
- VKBD_UMLAUT_LOWER = 32, /*!< Extended Latin lowercase characters */
- VKBD_CYRILLIC_UPPER = 40, /*!< Cyrillic uppercase characters */
- VKBD_CYRILLIC_LOWER = 48, /*!< Cyrillic lowercase characters */
- VKBD_DEGREE = 56, /*!< Numeric keyboard with extra characters (NESW, degree, minute) for coordinate input */
-
- /* modifiers and masks */
- VKBD_FLAG_2 = 2, /* FIXME seems to show alpha/num switch (VKBD_NUMERIC and VKBD_LATIN_* only) and switches to lowercase after first character */
- VKBD_MASK_7 = 7, /* FIXME modifiers for layout? */
- VKBD_FLAG_1024 = 1024, /* FIXME what is this for? Seems to have to do something with scroll box visibility */
- VKBD_LAYOUT_MASK = ~7, /* when XORed with the mode, preserves only the layout FIXME document properly */
-};
-
-/* prototypes */
-struct gui_priv;
-struct widget;
-struct widget *gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode);
-struct widget *gui_internal_keyboard(struct gui_priv *this, int mode);
-struct widget *gui_internal_keyboard_show_native(struct gui_priv *this, struct widget *w, int mode, char *lang);
-int gui_internal_keyboard_init_mode(char *lang);
-void gui_internal_keyboard_to_upper_case(struct gui_priv *this);
-void gui_internal_keyboard_to_lower_case(struct gui_priv *this);
-/* end of prototypes */
diff --git a/navit/gui/internal/gui_internal_menu.c b/navit/gui/internal/gui_internal_menu.c
deleted file mode 100644
index 33def9983..000000000
--- a/navit/gui/internal/gui_internal_menu.c
+++ /dev/null
@@ -1,373 +0,0 @@
-#include <glib.h>
-#include "color.h"
-#include "coord.h"
-#include "point.h"
-#include "callback.h"
-#include "graphics.h"
-#include "debug.h"
-#include "navit.h"
-#include "navit_nls.h"
-#include "xmlconfig.h"
-#include "gui_internal.h"
-#include "gui_internal_widget.h"
-#include "gui_internal_priv.h"
-#include "gui_internal_html.h"
-#include "gui_internal_search.h"
-#include "gui_internal_menu.h"
-
-extern char *version;
-
-static void
-gui_internal_menu_destroy(struct gui_priv *this, struct widget *w)
-{
- struct menu_data *menu_data=w->menu_data;
- if (menu_data) {
- if (menu_data->refresh_callback_obj.type) {
- struct object_func *func;
- func=object_func_lookup(menu_data->refresh_callback_obj.type);
- if (func && func->remove_attr)
- func->remove_attr(menu_data->refresh_callback_obj.u.data, &menu_data->refresh_callback);
- }
- if (menu_data->refresh_callback.u.callback)
- callback_destroy(menu_data->refresh_callback.u.callback);
-
- g_free(menu_data->href);
- g_free(menu_data);
- }
- gui_internal_widget_destroy(this, w);
- this->root.children=g_list_remove(this->root.children, w);
-}
-
-static void
-gui_internal_prune_menu_do(struct gui_priv *this, struct widget *w, int render)
-{
- GList *l;
- struct widget *wr,*wd;
- gui_internal_search_idle_end(this);
- while ((l = g_list_last(this->root.children))) {
- wd=l->data;
- if (wd == w) {
- void (*redisplay)(struct gui_priv *priv, struct widget *widget, void *data);
- if (!render)
- return;
- gui_internal_say(this, w, 0);
- redisplay=w->menu_data->redisplay;
- wr=w->menu_data->redisplay_widget;
- if (!w->menu_data->redisplay && !w->menu_data->href) {
- gui_internal_widget_render(this, w);
- return;
- }
- if (redisplay) {
- gui_internal_menu_destroy(this, w);
- redisplay(this, wr, wr->data);
- } else {
- char *href=g_strdup(w->menu_data->href);
- gui_internal_menu_destroy(this, w);
- gui_internal_html_load_href(this, href, 0);
- g_free(href);
- }
- return;
- }
- gui_internal_menu_destroy(this, wd);
- }
-}
-
-void
-gui_internal_prune_menu(struct gui_priv *this, struct widget *w)
-{
- gui_internal_prune_menu_do(this, w, 1);
-}
-
-void
-gui_internal_prune_menu_count(struct gui_priv *this, int count, int render)
-{
- GList *l=g_list_last(this->root.children);
- struct widget *w=NULL;
- while (l && count-- > 0)
- l=g_list_previous(l);
- if (l) {
- w=l->data;
- gui_internal_prune_menu_do(this, w, render);
- }
-}
-
-
-/**
- * @brief Initializes a GUI screen
- *
- * This method initializes the internal GUI's screen on which all other elements (such as HTML menus,
- * dialogs or others) are displayed.
- *
- * It sets up a view hierarchy, which includes a title bar and a client area to hold widgets defined by
- * the caller.
- *
- * @param this The GUI instance
- * @param label The label to display in the top bar
- *
- * @return The container for caller-defined widgets
- */
-struct widget *
-gui_internal_menu(struct gui_priv *this, const char *label)
-{
- struct widget *menu,*w,*w1,*topbox;
- struct padding *padding = NULL;
-
- if (this->gra) {
- padding = graphics_get_data(this->gra, "padding");
- } else
- dbg(lvl_warning, "cannot get padding: this->gra is NULL\n");
-
- gui_internal_search_idle_end(this);
- topbox=gui_internal_box_new_with_label(this, 0, label);
- topbox->w=this->root.w;
- topbox->h=this->root.h;
- gui_internal_widget_append(&this->root, topbox);
- menu=gui_internal_box_new(this, gravity_left_center|orientation_vertical);
-
- if (padding) {
- menu->p.x = padding->left;
- menu->p.y = padding->top;
- menu->w = topbox->w - padding->left - padding->right;
- menu->h = topbox->h - padding->top - padding->bottom;
- } else {
- menu->p.x = 0;
- menu->p.y = 0;
- menu->w = topbox->w;
- menu->h = topbox->h;
- }
- menu->background=this->background;
- gui_internal_apply_config(this);
- topbox->menu_data=g_new0(struct menu_data, 1);
- gui_internal_widget_append(topbox, menu);
- w=gui_internal_top_bar(this);
- gui_internal_widget_append(menu, w);
- w=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
- w->spx=4*this->spacing;
- w->w=menu->w;
- gui_internal_widget_append(menu, w);
- if (this->flags & 16 && !(this->flags & 1024)) {
- struct widget *wlb,*wb,*wm=w;
- wm->flags=gravity_center|orientation_vertical|flags_expand|flags_fill;
- w=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_expand|flags_fill);
- dbg(lvl_info,"topbox->menu_data=%p\n", topbox->menu_data);
- gui_internal_widget_append(wm, w);
- wb=gui_internal_box_new(this, gravity_right_center|orientation_horizontal|flags_fill);
- wb->bl=6;
- wb->br=6;
- wb->bb=6;
- wb->bt=6;
- wb->spx=6;
- topbox->menu_data->button_bar=wb;
- gui_internal_widget_append(wm, wb);
- wlb=gui_internal_button_label(this,_("Back"),1);
- wlb->func=gui_internal_back;
- wlb->state |= STATE_SENSITIVE;
- }
- if (this->flags & 192) {
- menu=gui_internal_box_new(this, gravity_left_center|orientation_vertical);
- if (padding) {
- menu->p.x = padding->left;
- menu->p.y = padding->top;
- menu->w = topbox->w - padding->left - padding->right;
- menu->h = topbox->h - padding->top - padding->bottom;
- } else {
- menu->p.x = 0;
- menu->p.y = 0;
- menu->w = topbox->w;
- menu->h = topbox->h;
- }
- w1=gui_internal_time_help(this);
- gui_internal_widget_append(menu, w1);
- w1=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(menu, w1);
- gui_internal_widget_append(topbox, menu);
- menu->background=NULL;
- }
- gui_internal_widget_pack(this, topbox);
- gui_internal_widget_reset_pack(this, topbox);
- topbox->w=this->root.w;
- topbox->h=this->root.h;
- if (padding) {
- menu->p.x = padding->left;
- menu->p.y = padding->top;
- menu->w = topbox->w - padding->left - padding->right;
- menu->h = topbox->h - padding->top - padding->bottom;
- } else {
- menu->p.x = 0;
- menu->p.y = 0;
- menu->w = topbox->w;
- menu->h = topbox->h;
- }
- return w;
-}
-
-struct menu_data *
-gui_internal_menu_data(struct gui_priv *this)
-{
- GList *l;
- struct widget *menu;
-
- l=g_list_last(this->root.children);
- menu=l->data;
- return menu->menu_data;
-}
-
-void
-gui_internal_menu_reset_pack(struct gui_priv *this)
-{
- GList *l;
- struct widget *top_box;
-
- l=g_list_last(this->root.children);
- top_box=l->data;
- gui_internal_widget_reset_pack(this, top_box);
-}
-
-void
-gui_internal_menu_render(struct gui_priv *this)
-{
- GList *l;
- struct widget *menu;
-
- l=g_list_last(this->root.children);
- menu=l->data;
- gui_internal_say(this, menu, 0);
- gui_internal_widget_pack(this, menu);
- gui_internal_widget_render(this, menu);
-}
-
-struct widget *
-gui_internal_top_bar(struct gui_priv *this)
-{
- struct widget *w,*wm,*wh,*wc,*wcn;
- int dots_len, sep_len;
- GList *res=NULL,*l;
- int width,width_used=0,use_sep=0,incomplete=0;
- struct graphics_gc *foreground=(this->flags & 256 ? this->background : this->text_foreground);
-/* flags
- 1:Don't expand bar to screen width
- 2:Don't show Map Icon
- 4:Don't show Home Icon
- 8:Show only current menu
- 16:Don't use menu titles as button
- 32:Show navit version
- 64:Show time
- 128:Show help
- 256:Use background for menu headline
- 512:Set osd_configuration and zoom to route when setting position
- 1024:Don't show back button
- 2048:No highlighting of keyboard
- 4096:Center menu title
-*/
-
- w=gui_internal_box_new(this, (this->flags & 4096 ? gravity_center : gravity_left_center)|orientation_horizontal|(this->flags & 1 ? 0:flags_fill));
- w->bl=this->spacing;
- w->spx=this->spacing;
- w->background=this->background2;
- if ((this->flags & 6) == 6) {
- w->bl=10;
- w->br=10;
- w->bt=6;
- w->bb=6;
- }
- width=this->root.w-w->bl;
- if (! (this->flags & 2)) {
- wm=gui_internal_button_new_with_callback(this, NULL,
- image_new_s(this, "gui_map"), gravity_center|orientation_vertical,
- gui_internal_cmd_return, NULL);
- wm->speech=g_strdup(_("Back to map"));
- gui_internal_widget_pack(this, wm);
- gui_internal_widget_append(w, wm);
- width-=wm->w;
- }
- if (! (this->flags & 4)) {
- wh=gui_internal_button_new_with_callback(this, NULL,
- image_new_s(this, "gui_home"), gravity_center|orientation_vertical,
- gui_internal_cmd_main_menu, NULL);
- wh->speech=g_strdup(_("Main Menu"));
- gui_internal_widget_pack(this, wh);
- gui_internal_widget_append(w, wh);
- width-=wh->w;
- }
- if (!(this->flags & 6))
- width-=w->spx;
- l=g_list_last(this->root.children);
- wcn=gui_internal_label_new(this,".. »");
- wcn->foreground=foreground;
- dots_len=wcn->w;
- gui_internal_widget_destroy(this, wcn);
- wcn=gui_internal_label_new(this,"»");
- wcn->foreground=foreground;
- sep_len=wcn->w;
- gui_internal_widget_destroy(this, wcn);
- while (l) {
- if (g_list_previous(l) || !g_list_next(l)) {
- wc=l->data;
- wcn=gui_internal_label_new(this, wc->text);
- wcn->foreground=foreground;
- if (g_list_next(l))
- use_sep=1;
- else
- use_sep=0;
- dbg(lvl_debug,"%d (%s) + %d + %d + %d > %d\n", wcn->w, wc->text, width_used, w->spx, use_sep ? sep_len : 0, width);
- if (wcn->w + width_used + w->spx + (use_sep ? sep_len : 0) + (g_list_previous(l) ? dots_len : 0) > width) {
- incomplete=1;
- gui_internal_widget_destroy(this, wcn);
- break;
- }
- if (use_sep) {
- struct widget *wct=gui_internal_label_new(this, "»");
- wct->foreground=foreground;
- res=g_list_prepend(res, wct);
- width_used+=sep_len+w->spx;
- }
- width_used+=wcn->w;
- if (!(this->flags & 16)) {
- wcn->func=gui_internal_cmd_return;
- wcn->data=wc;
- wcn->state |= STATE_SENSITIVE;
- }
- res=g_list_prepend(res, wcn);
- if (this->flags & 8)
- break;
- }
- l=g_list_previous(l);
- }
- if (incomplete) {
- if (! res) {
- wcn=gui_internal_label_new_abbrev(this, wc->text, width-width_used-w->spx-dots_len);
- wcn->foreground=foreground;
- wcn->func=gui_internal_cmd_return;
- wcn->data=wc;
- wcn->state |= STATE_SENSITIVE;
- res=g_list_prepend(res, wcn);
- l=g_list_previous(l);
- wc=l?l->data:NULL;
- }
- if(wc) {
- wcn=gui_internal_label_new(this, ".. »");
- wcn->foreground=foreground;
- wcn->func=gui_internal_cmd_return;
- wcn->data=wc;
- wcn->state |= STATE_SENSITIVE;
- res=g_list_prepend(res, wcn);
- }
- }
- l=res;
- while (l) {
- gui_internal_widget_append(w, l->data);
- l=g_list_next(l);
- }
- if (this->flags & 32) {
- char *version_text=g_strdup_printf("Navit %s",version);
- wcn=gui_internal_label_new(this, version_text);
- g_free(version_text);
- wcn->flags=gravity_right_center|flags_expand;
- gui_internal_widget_append(w, wcn);
- }
-#if 0
- if (dots)
- gui_internal_widget_destroy(this, dots);
-#endif
- return w;
-}
diff --git a/navit/gui/internal/gui_internal_menu.h b/navit/gui/internal/gui_internal_menu.h
deleted file mode 100644
index 57e37d91c..000000000
--- a/navit/gui/internal/gui_internal_menu.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* prototypes */
-struct gui_priv;
-struct menu_data;
-struct widget;
-void gui_internal_prune_menu(struct gui_priv *this, struct widget *w);
-void gui_internal_prune_menu_count(struct gui_priv *this, int count, int render);
-struct widget *gui_internal_menu(struct gui_priv *this, const char *label);
-struct menu_data *gui_internal_menu_data(struct gui_priv *this);
-void gui_internal_menu_reset_pack(struct gui_priv *this);
-void gui_internal_menu_render(struct gui_priv *this);
-struct widget *gui_internal_top_bar(struct gui_priv *this);
-/* end of prototypes */
diff --git a/navit/gui/internal/gui_internal_poi.c b/navit/gui/internal/gui_internal_poi.c
deleted file mode 100644
index cb31ecc95..000000000
--- a/navit/gui/internal/gui_internal_poi.c
+++ /dev/null
@@ -1,792 +0,0 @@
-#include <glib.h>
-#include <stdlib.h>
-#include "color.h"
-#include "coord.h"
-#include "point.h"
-#include "callback.h"
-#include "graphics.h"
-#include "debug.h"
-#include "navit.h"
-#include "navit_nls.h"
-#include "item.h"
-#include "xmlconfig.h"
-#include "map.h"
-#include "mapset.h"
-#include "layout.h"
-#include "route.h"
-#include "transform.h"
-#include "linguistics.h"
-#include "fib.h"
-#include "util.h"
-#include "gui_internal.h"
-#include "gui_internal_widget.h"
-#include "gui_internal_priv.h"
-#include "gui_internal_html.h"
-#include "gui_internal_menu.h"
-#include "gui_internal_keyboard.h"
-#include "gui_internal_poi.h"
-
-
-struct item_data {
- int dist;
- char *label;
- struct item item;
- struct coord c;
-};
-
-struct selector {
- char *icon;
- char *name;
- enum item_type *types;
-};
-static enum item_type selectors_BankTypes[]={type_poi_bank,type_poi_bank, type_poi_atm,type_poi_atm, type_none};
-static enum item_type selectors_FuelTypes[]={type_poi_fuel,type_poi_fuel,type_none};
-static enum item_type selectors_BusTrainTypes[]={type_poi_rail_station,type_poi_rail_station,
- type_poi_rail_halt,type_poi_rail_tram_stop,type_poi_bus_station,type_poi_bus_stop,type_none};
-static enum item_type selectors_HotelTypes[]={type_poi_hotel,type_poi_camp_rv,type_poi_camping,type_poi_camping,
- type_poi_resort,type_poi_resort,type_poi_motel,type_poi_hostel,type_none};
-static enum item_type selectors_RestaurantTypes[]={type_poi_bar,type_poi_picnic,type_poi_burgerking,type_poi_fastfood,
- type_poi_restaurant,type_poi_restaurant,type_poi_cafe,type_poi_cafe,type_poi_pub,type_poi_pub,type_none};
-static enum item_type selectors_ShoppingTypes[]={type_poi_mall,type_poi_mall,type_poi_shop_grocery,type_poi_shop_grocery,
- type_poi_shopping,type_poi_shopping,type_poi_shop_butcher,type_poi_shop_baker,type_poi_shop_fruit,
- type_poi_shop_fruit,type_poi_shop_beverages,type_poi_shop_beverages,type_none};
-static enum item_type selectors_ServiceTypes[]={type_poi_marina,type_poi_marina,type_poi_hospital,type_poi_hospital,
- type_poi_public_utilities,type_poi_public_utilities,type_poi_police,type_poi_autoservice,type_poi_information,
- type_poi_information,type_poi_pharmacy,type_poi_pharmacy,type_poi_personal_service,type_poi_repair_service,
- type_poi_restroom,type_poi_restroom,type_none};
-static enum item_type selectors_ParkingTypes[]={type_poi_car_parking,type_poi_car_parking,type_none};
-static enum item_type selectors_LandFeaturesTypes[]={type_poi_land_feature,type_poi_rock,type_poi_dam,type_poi_dam,
- type_poi_peak,type_poi_peak,type_none};
-static enum item_type selectors_OtherTypes[]={type_point_unspecified,type_poi_land_feature-1,type_poi_rock+1,type_poi_fuel-1,
- type_poi_marina+1,type_poi_shopping-1,type_poi_shopping+1,type_poi_car_parking-1,type_poi_car_parking+1,
- type_poi_bar-1,type_poi_bank+1,type_poi_dam-1,type_poi_dam+1,type_poi_information-1,type_poi_information+1,
- type_poi_mall-1,type_poi_mall+1,type_poi_personal_service-1,type_poi_pharmacy+1,type_poi_repair_service-1,
- type_poi_repair_service+1,type_poi_restaurant-1,type_poi_restaurant+1,type_poi_restroom-1,type_poi_restroom+1,
- type_poi_shop_grocery-1,type_poi_shop_grocery+1,type_poi_peak-1,type_poi_peak+1,type_poi_motel-1,type_poi_hostel+1,
- type_poi_shop_butcher-1,type_poi_shop_baker+1,type_poi_shop_fruit-1,type_poi_shop_fruit+1,type_poi_shop_beverages-1,
- type_poi_shop_beverages+1,type_poi_pub-1,type_poi_atm+1,type_line-1,type_none};
-/*static enum item_type selectors_UnknownTypes[]={type_point_unkn,type_point_unkn,type_none};*/
-struct selector selectors[]={
- {"bank","Bank",selectors_BankTypes},
- {"fuel","Fuel",selectors_FuelTypes},
- {"bus_stop","Bus&Train",selectors_BusTrainTypes},
- {"hotel","Hotel",selectors_HotelTypes},
- {"restaurant","Restaurant",selectors_RestaurantTypes},
- {"shopping","Shopping",selectors_ShoppingTypes},
- {"hospital","Service",selectors_ServiceTypes},
- {"parking","Parking",selectors_ParkingTypes},
- {"peak","Land Features",selectors_LandFeaturesTypes},
- {"unknown","Other",selectors_OtherTypes},
-/* {"unknown","Unknown",selectors_UnknownTypes},*/
-};
-/**
- * @brief Get icon for given POI type.
- *
- * @param this pointer to gui context
- * @param type POI type
- * @return Pointer to graphics_image object, or NULL if no picture available.
- */
-
-static struct graphics_image *
-gui_internal_poi_icon(struct gui_priv *this, struct item *item)
-{
- struct attr layout;
- struct attr icon_src;
- GList *layer;
- navit_get_attr(this->nav, attr_layout, &layout, NULL);
- layer=layout.u.layout->layers;
- while(layer) {
- GList *itemgra=((struct layer *)layer->data)->itemgras;
- while(itemgra) {
- GList *types=((struct itemgra *)itemgra->data)->type;
- while(types) {
- if((long)types->data==item->type) {
- GList *element=((struct itemgra *)itemgra->data)->elements;
- while(element) {
- struct element * el=element->data;
- if(el->type==element_icon) {
- char *src;
- char *icon;
- struct graphics_image *img;
- if(item_is_custom_poi(*item)) {
- struct map_rect *mr=map_rect_new(item->map, NULL);
- item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
- if(item_attr_get(item, attr_icon_src, &icon_src)) {
- src=el->u.icon.src;
- if(!src || !src[0])
- src="%s";
- icon=g_strdup_printf(src,map_convert_string_tmp(item->map,icon_src.u.str));
- }
- else {
- icon=g_strdup(el->u.icon.src);
- }
- }
- else {
- icon=g_strdup(el->u.icon.src);
- }
- char *dot=g_strrstr(icon,".");
- dbg(lvl_debug,"%s %s\n", item_to_name(item->type),icon);
- if(dot)
- *dot=0;
- img=image_new_xs(this,icon);
- g_free(icon);
- if(img)
- return img;
- }
- element=g_list_next(element);
- }
- }
- types=g_list_next(types);
- }
- itemgra=g_list_next(itemgra);
- }
- layer=g_list_next(layer);
- }
- return NULL;
-}
-
-/**
- * @brief Free poi_param structure.
- *
- * @param p reference to the object to be freed.
- */
-
-void
-gui_internal_poi_param_free(void *p)
-{
- if(((struct poi_param *)p)->filterstr)
- g_free(((struct poi_param *)p)->filterstr);
- if(((struct poi_param *)p)->filter)
- g_list_free(((struct poi_param *)p)->filter);
- g_free(p);
-};
-
-/**
- * @brief Clone poi_param structure.
- *
- * @param p reference to the object to be cloned.
- * @return Cloned object reference.
- */
-
-static struct poi_param *
-gui_internal_poi_param_clone(struct poi_param *p)
-{
- struct poi_param *r=g_new(struct poi_param,1);
- GList *l=p->filter;
- memcpy(r,p,sizeof(struct poi_param));
- r->filter=NULL;
- r->filterstr=NULL;
- if(p->filterstr) {
- char *last=g_list_last(l)->data;
- int len=(last - p->filterstr) + strlen(last)+1;
- r->filterstr=g_memdup(p->filterstr,len);
- }
- while(l) {
- r->filter=g_list_append(r->filter, r->filterstr + ((char*)(l->data) - p->filterstr) );
- l=g_list_next(l);
- }
- return r;
-};
-
-/**
- * @brief Set POIs filter data in poi_param structure.
- * @param param poi_param structure with unset filter data.
- * @param text filter text.
- */
-
-void
-gui_internal_poi_param_set_filter(struct poi_param *param, char *text)
-{
- char *s1, *s2;
-
- param->filterstr=removecase(text);
- s1=param->filterstr;
- do {
- s2=g_utf8_strchr(s1,-1,' ');
- if(s2)
- *s2++=0;
- param->filter=g_list_append(param->filter,s1);
- if(s2) {
- while(*s2==' ')
- s2++;
- }
- s1=s2;
- } while(s2 && *s2);
-}
-
-static struct widget *
-gui_internal_cmd_pois_selector(struct gui_priv *this, struct pcoord *c, int pagenb)
-{
- struct widget *wl,*wb;
- int nitems,nrows;
- int i;
- //wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal_vertical|flags_fill);
- wl->background=this->background;
- wl->w=this->root.w;
- wl->cols=this->root.w/this->icon_s;
- nitems=sizeof(selectors)/sizeof(struct selector);
- nrows=nitems/wl->cols + (nitems%wl->cols>0);
- wl->h=this->icon_l*nrows;
- for (i = 0 ; i < nitems ; i++) {
- struct poi_param *p=g_new0(struct poi_param,1);
- p->sel = 1;
- p->selnb = i;
- p->pagenb = pagenb;
- p->dist = 0;
- p->filter=NULL;
- p->filterstr=NULL;
- gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL,
- image_new_s(this, selectors[i].icon), gravity_left_center|orientation_vertical,
- gui_internal_cmd_pois, p));
- wb->c=*c;
- wb->data_free=gui_internal_poi_param_free;
- wb->bt=10;
- }
-
- gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL,
- image_new_s(this, "gui_search"), gravity_left_center|orientation_vertical,
- gui_internal_cmd_pois_filter, NULL));
- wb->c=*c;
- wb->bt=10;
-
- gui_internal_widget_pack(this,wl);
- return wl;
-}
-
-/**
- * @brief Widget to display POI item.
- *
- * @param this pointer to gui context
- * @param center reference to the standing point where angle to be counted from
- * @param item POI item reference
- * @param c POI coordinates
- * @param dist precomputed distance to POI (or -1 if it's not to be displayed)
- * @param name POI name
- * @return Pointer to new widget.
- */
-
-static void
-format_dist(int dist, char *distbuf)
-{
- if (dist > 10000)
- sprintf(distbuf,"%d ", dist/1000);
- else if (dist>0)
- sprintf(distbuf,"%d.%d ", dist/1000, (dist%1000)/100);
-}
-
-struct widget *
-gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct item *item, struct coord *c, struct route *route, int dist, char* name)
-{
- char distbuf[32]="";
- char dirbuf[32]="";
- char routedistbuf[32]="";
- char *type;
- struct widget *wl;
- char *text;
- struct graphics_image *icon;
-
- format_dist(dist,distbuf);
- if(c) {
- int len;
- get_compass_direction(dirbuf, transform_get_angle_delta(center, c, 0), 1);
- len=strlen(dirbuf);
- dirbuf[len]=' ';
- dirbuf[len+1]=0;
- if (route) {
- route_get_distances(route, c, 1, &dist);
- if (dist != INT_MAX)
- format_dist(dist, routedistbuf);
- }
- }
-
-
- type=item_to_name(item->type);
-
- icon=gui_internal_poi_icon(this,item);
- if(!icon && item->type==type_house_number)
- icon=image_new_xs(this,"post");
- if(!icon) {
- icon=image_new_xs(this,"gui_inactive");
- text=g_strdup_printf("%s%s%s%s %s", distbuf, dirbuf, routedistbuf, type, name);
- } else if(strlen(name)>0)
- text=g_strdup_printf("%s%s%s%s", distbuf, dirbuf, routedistbuf, name);
- else
- text=g_strdup_printf("%s%s%s%s", distbuf, dirbuf, routedistbuf, type);
-
- wl=gui_internal_button_new_with_callback(this, text, icon, gravity_left_center|orientation_horizontal|flags_fill, NULL, NULL);
- wl->datai=dist;
- g_free(text);
- if (name[0]) {
- wl->name=g_strdup_printf("%s %s",type,name);
- } else {
- wl->name=g_strdup(type);
- }
- wl->func=gui_internal_cmd_position;
- wl->data=(void *)9;
- wl->item=*item;
- wl->state|= STATE_SENSITIVE;
- return wl;
-}
-
-/**
- * @brief Get string representation of item address suitable for doing search and for display in POI list.
- *
- * @param item reference to item.
- * @return Pointer to string representation of address. To be g_free()d after use.
- */
-
-char *
-gui_internal_compose_item_address_string(struct item *item, int prependPostal)
-{
- char *s=g_strdup("");
- struct attr attr;
- if(prependPostal && item_attr_get(item, attr_postal, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_house_number, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_street_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_street_name_systematic, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_district_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_town_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_county_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
- if(item_attr_get(item, attr_country_name, &attr))
- s=g_strjoin(" ",s,map_convert_string_tmp(item->map,attr.u.str),NULL);
-
- if(item_attr_get(item, attr_address, &attr))
- s=g_strjoin(" ",s,"|",map_convert_string_tmp(item->map,attr.u.str),NULL);
- return s;
-}
-
-static int
-gui_internal_cmd_pois_item_selected(struct poi_param *param, struct item *item)
-{
- enum item_type *types;
- struct selector *sel = param->sel? &selectors[param->selnb]: NULL;
- enum item_type type=item->type;
- struct attr attr;
- int match=0;
- if (type >= type_line && param->filter==NULL)
- return 0;
- if (! sel || !sel->types) {
- match=1;
- } else {
- types=sel->types;
- while (*types != type_none) {
- if (item->type >= types[0] && item->type <= types[1]) {
- return 1;
- }
- types+=2;
- }
- }
- if(type == type_house_number && !param->filter)
- return 0;
- if (param->filter) {
- char *long_name, *s;
- GList *f;
- int i;
- if (param->AddressFilterType>0) {
- s=gui_internal_compose_item_address_string(item,param->AddressFilterType==2?1:0);
- } else if (item_attr_get(item, attr_label, &attr)) {
- s=g_strdup_printf("%s %s", item_to_name(item->type), map_convert_string_tmp(item->map,attr.u.str));
- } else {
- s=g_strdup(item_to_name(item->type));
- }
- long_name=removecase(s);
- g_free(s);
-
- match=0;
- for(i=0;i<3 && !match;i++) {
- char *long_name_exp=linguistics_expand_special(long_name, i);
- for(s=long_name_exp,f=param->filter;f && s;f=g_list_next(f)) {
- s=strstr(s,f->data);
- if(!s) {
- break;
- }
- s=g_utf8_strchr(s,-1,' ');
- }
- g_free(long_name_exp);
- if(!f)
- match=1;
- }
- g_free(long_name);
- }
- return match;
-}
-
-/**
- * @brief Event handler for POIs list "more" element.
- *
- * @param this The graphics context.
- * @param wm called widget.
- * @param data event data.
- */
-static void
-gui_internal_cmd_pois_more(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w=g_new0(struct widget,1);
- w->data=wm->data;
- w->c=wm->c;
- w->w=wm->w;
- wm->data_free=NULL;
- gui_internal_back(this, NULL, NULL);
- gui_internal_cmd_pois(this, w, w->data);
- free(w);
-}
-
-
-/**
- * @brief Event to apply POIs text filter.
- *
- * @param this The graphics context.
- * @param wm called widget.
- * @param data event data (pointer to editor widget containg filter text).
- */
-static void
-gui_internal_cmd_pois_filter_do(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *w=data;
- struct poi_param *param;
-
- if(!w->text)
- return;
-
- if(w->data) {
- param=gui_internal_poi_param_clone(w->data);
- param->pagenb=0;
- } else {
- param=g_new0(struct poi_param,1);
- }
- if(!strcmp(wm->name,"AddressFilter"))
- param->AddressFilterType=1;
- else if(!strcmp(wm->name,"AddressFilterZip"))
- param->AddressFilterType=2;
- else
- param->AddressFilterType=0;
-
- gui_internal_poi_param_set_filter(param, w->text);
-
- gui_internal_cmd_pois(this,w,param);
- gui_internal_poi_param_free(param);
-}
-
-/**
- * @brief POIs filter dialog.
- * Event to handle '\r' '\n' keys pressed.
- *
- */
-
-static void
-gui_internal_cmd_pois_filter_changed(struct gui_priv *this, struct widget *wm, void *data)
-{
- if (wm->text && wm->reason==gui_internal_reason_keypress_finish) {
- gui_internal_cmd_pois_filter_do(this, wm, wm);
- }
-}
-
-
-/**
- * @brief POIs filter dialog.
- *
- * @param this The graphics context.
- * @param wm called widget.
- * @param data event data.
- */
-void
-gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct widget *wb, *w, *wr, *wk, *we;
- int keyboard_mode;
- keyboard_mode = VKBD_FLAG_2 | gui_internal_keyboard_init_mode(getenv("LANG"));
- wb=gui_internal_menu(this,"Filter");
- w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wr);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(wr, we);
-
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, NULL));
- wk->state |= STATE_EDIT|STATE_EDITABLE;
- wk->func=gui_internal_cmd_pois_filter_changed;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->name=g_strdup("POIsFilter");
- wk->c=wm->c;
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
- wb->state |= STATE_SENSITIVE;
- wb->func = gui_internal_cmd_pois_filter_do;
- wb->name=g_strdup("NameFilter");
- wb->data=wk;
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "post")));
- wb->state |= STATE_SENSITIVE;
- wb->name=g_strdup("AddressFilter");
- wb->func = gui_internal_cmd_pois_filter_do;
- wb->data=wk;
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "zipcode")));
- wb->state |= STATE_SENSITIVE;
- wb->name=g_strdup("AddressFilterZip");
- wb->func = gui_internal_cmd_pois_filter_do;
- wb->data=wk;
-
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, keyboard_mode));
- else
- gui_internal_keyboard_show_native(this, w, keyboard_mode, getenv("LANG"));
- gui_internal_menu_render(this);
-
-
-}
-
-/**
- * @brief Do POI search specified by poi_param and display POIs found
- *
- * @param this The graphics context.
- * @param wm called widget.
- * @param data event data, reference to poi_param or NULL.
- */
-void
-gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data)
-{
- struct map_selection *sel,*selm;
- struct coord c,center;
- struct mapset_handle *h;
- struct map *m;
- struct map_rect *mr;
- struct item *item;
- struct widget *wi,*w,*w2,*wb, *wtable, *row;
- enum projection pro=wm->c.pro;
- struct poi_param *param;
- int param_free=0;
- int idist,dist;
- struct selector *isel;
- int pagenb;
- int prevdist;
- // Starting value and increment of count of items to be extracted
- const int pagesize = 50;
- int maxitem, it = 0, i;
- struct item_data *items;
- struct fibheap* fh = fh_makekeyheap();
- int cnt = 0;
- struct table_data *td;
- struct widget *wl,*wt;
- char buffer[32];
- struct poi_param *paramnew;
- struct attr route;
-dbg(lvl_debug,"POIs...");
- if(data) {
- param = data;
- } else {
- param = g_new0(struct poi_param,1);
- param_free=1;
- }
- if (navit_get_attr(this->nav, attr_route, &route, NULL)) {
- struct attr route_status;
- if (!route_get_attr(route.u.route, attr_route_status, &route_status, NULL) ||
- (route_status.u.num != route_status_path_done_new &&
- route_status.u.num != route_status_path_done_incremental))
- route.u.route=NULL;
- } else
- route.u.route=NULL;
- dist=10000*(param->dist+1);
- isel = param->sel? &selectors[param->selnb]: NULL;
- pagenb = param->pagenb;
- prevdist=param->dist*10000;
- maxitem = pagesize*(pagenb+1);
- items= g_new0( struct item_data, maxitem);
-
-
- dbg(lvl_debug, "Params: sel = %i, selnb = %i, pagenb = %i, dist = %i, filterstr = %s, AddressFilterType= %d\n",
- param->sel, param->selnb, param->pagenb, param->dist, param->filterstr, param->AddressFilterType);
-
- wb=gui_internal_menu(this, isel ? isel->name : _("POIs"));
- w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- if (!isel && !param->filter)
- gui_internal_widget_append(w, gui_internal_cmd_pois_selector(this,&wm->c,pagenb));
- w2=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, w2);
-
- sel=map_selection_rect_new(&wm->c,dist*transform_scale(abs(wm->c.y)+dist*1.5),18);
- center.x=wm->c.x;
- center.y=wm->c.y;
- h=mapset_open(navit_get_mapset(this->nav));
- while ((m=mapset_next(h, 1))) {
- selm=map_selection_dup_pro(sel, pro, map_projection(m));
- mr=map_rect_new(m, selm);
- dbg(lvl_debug,"mr=%p\n", mr);
- if (mr) {
- while ((item=map_rect_get_item(mr))) {
- if (gui_internal_cmd_pois_item_selected(param, item) &&
- item_coord_get_pro(item, &c, 1, pro) &&
- coord_rect_contains(&sel->u.c_rect, &c) &&
- (idist=transform_distance(pro, &center, &c)) < dist) {
- struct item_data *data;
- struct attr attr;
- char *label;
- item_attr_rewind(item);
- if (item->type==type_house_number) {
- label=gui_internal_compose_item_address_string(item,1);
- } else if (item_attr_get(item, attr_label, &attr)) {
- label=map_convert_string(item->map,attr.u.str);
- // Buildings which label is equal to addr:housenumber value
- // are duplicated by item_house_number. Don't include such
- // buildings into the list. This is true for OSM maps created with
- // maptool patched with #859 latest patch.
- // FIXME: For non-OSM maps, we probably would better don't skip these items.
- if(item->type==type_poly_building && item_attr_get(item, attr_house_number, &attr) ) {
- if(strcmp(label,map_convert_string_tmp(item->map,attr.u.str))==0) {
- g_free(label);
- continue;
- }
- }
-
- } else {
- label=g_strdup("");
- }
-
- if(it>=maxitem) {
- data = fh_extractmin(fh);
- g_free(data->label);
- data->label=NULL;
- } else {
- data = &items[it++];
- }
- data->label=label;
- data->item = *item;
- data->c = c;
- data->dist = idist;
- // Key expression is a workaround to fight
- // probable heap collisions when two objects
- // are at the same distance. But it destroys
- // right order of POIs 2048 km away from cener
- // and if table grows more than 1024 rows.
- fh_insertkey(fh, -((idist<<10) + cnt++), data);
- if (it == maxitem)
- dist = (-fh_minkey(fh))>>10;
- }
- }
- map_rect_destroy(mr);
- }
- map_selection_destroy(selm);
- }
- map_selection_destroy(sel);
- mapset_close(h);
-
- wtable = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
- td=wtable->data;
-
- gui_internal_widget_append(w2,wtable);
-
- // Move items from heap to the table
- for(i=0;;i++)
- {
- int key = fh_minkey(fh);
- struct item_data *data = fh_extractmin(fh);
- if (data == NULL)
- {
- dbg(lvl_debug, "Empty heap: maxitem = %i, it = %i, dist = %i\n", maxitem, it, dist);
- break;
- }
- dbg(lvl_debug, "dist1: %i, dist2: %i\n", data->dist, (-key)>>10);
- if(i==(it-pagesize*pagenb) && data->dist>prevdist)
- prevdist=data->dist;
- wi=gui_internal_cmd_pois_item(this, &center, &data->item, &data->c, route.u.route, data->dist, data->label);
- wi->c.x=data->c.x;
- wi->c.y=data->c.y;
- wi->c.pro=pro;
- wi->background=this->background;
- row = gui_internal_widget_table_row_new(this,
- gravity_left
- | flags_fill
- | orientation_horizontal);
- gui_internal_widget_append(row,wi);
- row->datai=data->dist;
- gui_internal_widget_prepend(wtable,row);
- g_free(data->label);
- }
-
- fh_deleteheap(fh);
- free(items);
-
- // Add an entry for more POI
- row = gui_internal_widget_table_row_new(this,
- gravity_left
- | flags_fill
- | orientation_horizontal);
- row->datai=100000000; // Really far away for Earth, but won't work for bigger planets.
- gui_internal_widget_append(wtable,row);
- wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(row,wl);
- if (it == maxitem) {
- paramnew=gui_internal_poi_param_clone(param);
- paramnew->pagenb++;
- paramnew->count=it;
- snprintf(buffer, sizeof(buffer), "Get more (up to %d items)...", (paramnew->pagenb+1)*pagesize);
- wt=gui_internal_label_new(this, buffer);
- gui_internal_widget_append(wl, wt);
- wt->func=gui_internal_cmd_pois_more;
- wt->data=paramnew;
- wt->data_free=gui_internal_poi_param_free;
- wt->state |= STATE_SENSITIVE;
- wt->c = wm->c;
- } else {
- static int dist[]={1,5,10,0};
- wt=gui_internal_label_new(this, "Set distance to");
- gui_internal_widget_append(wl, wt);
- for(i=0;dist[i];i++) {
- paramnew=gui_internal_poi_param_clone(param);
- paramnew->dist+=dist[i];
- paramnew->count=it;
- snprintf(buffer, sizeof(buffer), " %i ", 10*(paramnew->dist+1));
- wt=gui_internal_label_new(this, buffer);
- gui_internal_widget_append(wl, wt);
- wt->func=gui_internal_cmd_pois_more;
- wt->data=paramnew;
- wt->data_free=gui_internal_poi_param_free;
- wt->state |= STATE_SENSITIVE;
- wt->c = wm->c;
- }
- wt=gui_internal_label_new(this, "km.");
- gui_internal_widget_append(wl, wt);
-
- }
- // Rendering now is needed to have table_data->bottomrow filled in.
- gui_internal_menu_render(this);
- td=wtable->data;
- if(td->bottom_row!=NULL)
- {
-#if 0
- while(((struct widget*)td->bottom_row->data)->datai<=prevdist
- && (td->next_button->state & STATE_SENSITIVE))
- {
- gui_internal_table_button_next(this, td->next_button, NULL);
- }
-#else
- int firstrow=g_list_index(wtable->children, td->top_row->data);
- while(firstrow>=0) {
- int currow=g_list_index(wtable->children, td->bottom_row->data) - firstrow;
- if(currow<0) {
- dbg(lvl_debug,"Can't find bottom row in children list. Stop paging.\n");
- break;
- }
- if(currow>=param->count)
- break;
- if(!(td->scroll_buttons.next_button->state & STATE_SENSITIVE)) {
- dbg(lvl_debug,"Reached last page but item %i not found. Stop paging.\n",param->count);
- break;
- }
- gui_internal_table_button_next(this, td->scroll_buttons.next_button, NULL);
- }
-#endif
- }
- gui_internal_menu_render(this);
- if(param_free)
- g_free(param);
-}
-
diff --git a/navit/gui/internal/gui_internal_poi.h b/navit/gui/internal/gui_internal_poi.h
deleted file mode 100644
index 665f44a70..000000000
--- a/navit/gui/internal/gui_internal_poi.h
+++ /dev/null
@@ -1,57 +0,0 @@
-
-/**
- * POI search/filtering parameters.
- *
- */
-
-struct poi_param {
-
- /**
- * =1 if selnb is defined, 0 otherwize.
- */
- unsigned char sel;
-
- /**
- * Index to struct selector selectors[], shows what type of POIs is defined.
- */
- unsigned char selnb;
- /**
- * Page number to display.
- */
- unsigned char pagenb;
- /**
- * Radius (number of 10-kilometer intervals) to search for POIs.
- */
- unsigned char dist;
- /**
- * Should filter phrase be compared to postal address of the POI.
- * =0 - name filter, =1 - address filter, =2 - address filter, including postal code
- */
- unsigned char AddressFilterType;
- /**
- * Filter string, casefold()ed and divided into substrings at the spaces, which are replaced by ASCII 0*.
- */
- char *filterstr;
- /**
- * list of pointers to individual substrings of filterstr.
- */
- GList *filter;
- /**
- * Number of POIs in this list
- */
- int count;
-};
-
-/* prototypes */
-struct coord;
-struct gui_priv;
-struct item;
-struct poi_param;
-struct widget;
-void gui_internal_poi_param_free(void *p);
-void gui_internal_poi_param_set_filter(struct poi_param *param, char *text);
-struct widget *gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct item *item, struct coord *c, struct route *route, int dist, char *name);
-char *gui_internal_compose_item_address_string(struct item *item, int prependPostal);
-void gui_internal_cmd_pois_filter(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data);
-/* end of prototypes */
diff --git a/navit/gui/internal/gui_internal_priv.h b/navit/gui/internal/gui_internal_priv.h
deleted file mode 100644
index 37b09d62a..000000000
--- a/navit/gui/internal/gui_internal_priv.h
+++ /dev/null
@@ -1,228 +0,0 @@
-/**
- * @brief A structure to store configuration values.
- *
- * This structure stores configuration values for how gui elements in the internal GUI
- * should be drawn.
- */
-struct gui_config_settings {
-
- /**
- * The base size (in fractions of a point) to use for text.
- */
- int font_size;
- /**
- * The size (in pixels) that xs style icons should be scaled to.
- * This icon size is typically used in various lists and should be set to value which allows a list row to be easily cliked or dragged.
- */
- int icon_xs;
- /**
- * The size (in pixels) that s style icons (small) should be scaled to, used for the menu top row icons
- */
- int icon_s;
- /**
- * The size (in pixels) that l style icons should be scaled to, used for icons defined in the menu html
- */
- int icon_l;
- /**
- * The default amount of spacing (in pixels) to place between GUI elements.
- */
- int spacing;
-
-};
-
-struct route_data {
- struct widget * route_table;
- int route_showing;
-};
-
-/**
- * Private data for the internal GUI.
- *
- * @author Martin Schaller (04/2008)
- */
-struct gui_priv {
- struct navit *nav;
- struct attr self;
- struct window *win;
- struct graphics *gra;
- struct graphics_gc *background;
- struct graphics_gc *background2;
- struct graphics_gc *highlight_background;
- struct graphics_gc *foreground;
- struct graphics_gc *text_foreground;
- struct graphics_gc *text_background;
- struct color background_color, background2_color, text_foreground_color, text_background_color;
- int spacing;
- int font_size;
- char *font_name;
- int fullscreen;
- struct graphics_font *fonts[3];
- int icon_xs; /**< The size (in pixels) that xs style icons should be scaled to.
- * This icon size can be too small to click it on some devices.
- */
- int icon_s; /**< The size (in pixels) that s style icons (small) should be scaled to */
- int icon_l; /**< The size (in pixels) that l style icons should be scaled to */
- int pressed;
- struct widget *widgets;
- int widgets_count;
- int redraw;
- struct widget root;
- struct widget *highlighted,*editable;
- struct widget *highlighted_menu;
- struct pcoord clickp, vehiclep;
- struct attr *click_coord_geo, *position_coord_geo;
- struct search_list *sl;
- int ignore_button;
- int menu_on_map_click;
- char *on_map_click;
- int signal_on_map_click;
- char *country_iso2;
- int speech;
- int keyboard; /**< Whether the internal GUI keyboard is enabled */
- int keyboard_required; /**< Whether keyboard input is needed. This is only used by the
- * HTML menu, text entry dialogs do not use this member.
- */
- struct gui_config_settings config; /**< The setting information read from the configuration file.
- * values of -1 indicate no value was specified in the config file.
- */
- struct event_idle *idle;
- struct callback *motion_cb,*button_cb,*resize_cb,*keypress_cb,*window_closed_cb,*idle_cb, *motion_timeout_callback;
- struct event_timeout *motion_timeout_event;
- struct point current;
-
- struct callback * vehicle_cb;
- struct route_data route_data; /**< Stores information about the route. */
-
- struct gui_internal_data data;
- struct callback_list *cbl;
- int flags;
- int cols;
- struct attr osd_configuration; /**< The OSD configuration, a set of flags controlling which OSD
- * items will be visible.
- */
- int pitch; /**< The pitch for the 3D map view. */
- int flags_town,flags_street,flags_house_number;
- int radius;
- int mouse_button_clicked_on_map;
-/* html */
- char *html_text;
- int html_depth;
- struct widget *html_container;
- int html_skip;
- char *html_anchor;
- char *href;
- int html_anchor_found;
- struct form *form;
- struct html {
- int skip;
- enum html_tag {
- html_tag_none,
- html_tag_a,
- html_tag_h1,
- html_tag_html,
- html_tag_img,
- html_tag_script,
- html_tag_form,
- html_tag_input,
- html_tag_div,
- } tag;
- char *command;
- char *name;
- char *href;
- char *refresh_cond;
- char *class;
- int font_size;
- struct widget *w;
- struct widget *container;
- } html[10];
-
-/* gestures */
-
- struct gesture_elem {
- long long msec;
- struct point p;
- } gesture_ring[GESTURE_RINGSIZE];
- int gesture_ring_last, gesture_ring_first;
-
- int hide_keys; //Flag to set the keyboard mode 1: hide impossible keys on search; 0: highlight them.
- int results_map_population;
-};
-
-struct menu_data {
- struct widget *search_list;
- struct widget *keyboard;
- struct widget *button_bar;
- struct widget *menu;
- int keyboard_mode;
- void (*redisplay)(struct gui_priv *priv, struct widget *widget, void *data);
- struct widget *redisplay_widget;
- char *href;
- struct attr refresh_callback_obj,refresh_callback;
-};
-
-struct heightline {
- struct heightline *next;
- int height;
- struct coord_rect bbox;
- int count;
- struct coord c[0];
-};
-
-struct diagram_point {
- struct diagram_point *next;
- struct coord c;
-};
-/* prototypes */
-enum flags;
-struct attr;
-struct coord;
-struct coord_geo;
-struct graphics_image;
-struct gui_priv;
-struct heightline;
-struct item;
-struct map;
-struct navit;
-struct pcoord;
-struct point;
-struct vehicle;
-struct widget;
-struct graphics_image *image_new_xs(struct gui_priv *this, const char *name);
-struct graphics_image *image_new_s(struct gui_priv *this, const char *name);
-struct graphics_image *image_new_l(struct gui_priv *this, const char *name);
-struct widget *gui_internal_button_navit_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct attr *on, struct attr *off);
-struct widget *gui_internal_button_map_attr_new(struct gui_priv *this, const char *text, enum flags flags, struct map *map, struct attr *on, struct attr *off, int deflt);
-void gui_internal_say(struct gui_priv *this, struct widget *w, int questionmark);
-void gui_internal_back(struct gui_priv *this, struct widget *w, void *data);
-void gui_internal_cmd_return(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_cmd_main_menu(struct gui_priv *this, struct widget *wm, void *data);
-struct widget *gui_internal_time_help(struct gui_priv *this);
-void gui_internal_apply_config(struct gui_priv *this);
-void gui_internal_select_waypoint(struct gui_priv *this, const char *title, const char *hint, struct widget *wm_, void (*cmd)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
-void gui_internal_call_linked_on_finish(struct gui_priv *this, struct widget *wm, void *data);
-char *removecase(char *s);
-void gui_internal_cmd_position_do(struct gui_priv *this, struct pcoord *pc_in, struct coord_geo *g_in, struct widget *wm, const char *name, int flags);
-void gui_internal_cmd_position(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_cmd_bookmarks(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_keypress_do(struct gui_priv *this, char *key);
-char *gui_internal_cmd_match_expand(char *pattern, struct attr **in);
-int gui_internal_set(char *remove, char *add);
-void gui_internal_cmd_map_download(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_menu_vehicle_settings(struct gui_priv *this, struct vehicle *v, char *name);
-void gui_internal_cmd_vehicle_settings(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_evaluate(struct gui_priv *this, const char *command);
-void gui_internal_enter(struct gui_priv *this, int ignore);
-void gui_internal_leave(struct gui_priv *this);
-void gui_internal_set_click_coord(struct gui_priv *this, struct point *p);
-void gui_internal_enter_setup(struct gui_priv *this);
-void gui_internal_cmd_menu(struct gui_priv *this, int ignore, char *href);
-void gui_internal_cmd_log_clicked(struct gui_priv *this, struct widget *widget, void *data);
-void gui_internal_check_exit(struct gui_priv *this);
-void gui_internal_cmd_enter_coord_clicked(struct gui_priv *this, struct widget *widget, void *data);
-int line_intersection(struct coord *a1, struct coord *a2, struct coord *b1, struct coord *b2, struct coord *res);
-struct heightline *item_get_heightline(struct item *item);
-void gui_internal_route_update(struct gui_priv *this, struct navit *navit, struct vehicle *v);
-void gui_internal_route_screen_free(struct gui_priv *this_, struct widget *w);
-void gui_internal_populate_route_table(struct gui_priv *this, struct navit *navit);
-void plugin_init(void);
-/* end of prototypes */
diff --git a/navit/gui/internal/gui_internal_search.c b/navit/gui/internal/gui_internal_search.c
deleted file mode 100644
index ceeeb7438..000000000
--- a/navit/gui/internal/gui_internal_search.c
+++ /dev/null
@@ -1,635 +0,0 @@
-#include <glib.h>
-#include <stdlib.h>
-#include "config.h"
-#include "color.h"
-#include "coord.h"
-#include "point.h"
-#include "callback.h"
-#include "graphics.h"
-#include "debug.h"
-#include "navit.h"
-#include "navit_nls.h"
-#include "event.h"
-#include "search.h"
-#include "country.h"
-#include "track.h"
-#include "linguistics.h"
-#include "gui_internal.h"
-#include "gui_internal_widget.h"
-#include "gui_internal_priv.h"
-#include "gui_internal_html.h"
-#include "gui_internal_menu.h"
-#include "gui_internal_keyboard.h"
-#include "gui_internal_search.h"
-
-static void
-gui_internal_search_country(struct gui_priv *this, struct widget *widget, void *data)
-{
- gui_internal_prune_menu_count(this, 1, 0);
- gui_internal_search(this,_("Country"),"Country",0);
-}
-
-static void
-gui_internal_search_town(struct gui_priv *this, struct widget *wm, void *data)
-{
- if (this->sl)
- search_list_select(this->sl, attr_country_all, 0, 0);
- g_free(this->country_iso2);
- this->country_iso2=NULL;
- gui_internal_search(this,_("Town"),"Town",0);
-}
-
-static void
-gui_internal_search_street(struct gui_priv *this, struct widget *widget, void *data)
-{
- search_list_select(this->sl, attr_town_or_district_name, 0, 0);
- gui_internal_search(this,_("Street"),"Street",0);
-}
-
-static void
-gui_internal_search_house_number(struct gui_priv *this, struct widget *widget, void *data)
-{
- search_list_select(this->sl, attr_street_name, 0, 0);
- gui_internal_search(this,_("House number"),"House number",0);
-}
-
-void
-gui_internal_search_idle_end(struct gui_priv *this)
-{
- if (this->idle) {
- event_remove_idle(this->idle);
- this->idle=NULL;
- }
- if (this->idle_cb) {
- callback_destroy(this->idle_cb);
- this->idle_cb=NULL;
- }
-}
-
-static int
-gui_internal_search_cmp(gconstpointer _a, gconstpointer _b)
-{
- struct widget *a=(struct widget *)_a, *b=(struct widget *)_b;
- char *sa,*sb;
- int r;
- if(!b)
- if((!a || a->type!=widget_table_row || !a->text) && (!b || b->type!=widget_table_row || !b->text))
- return 0;
- if(!a || a->type!=widget_table_row || !a->text)
- return -1;
- if(!b || b->type!=widget_table_row || !b->text)
- return 1;
- r=a->datai-b->datai;
- if(r<0)
- return -1;
- if(r>0)
- return 1;
- sa=removecase(a->text);
- sb=removecase(b->text);
- r=strcmp(sa,sb);
- dbg(lvl_debug,"%s %s %d\n",sa,sb,r);
- g_free(sa);
- g_free(sb);
- return r;
-}
-
-static char *
-postal_str(struct search_list_result *res, int level)
-{
- char *ret=NULL;
- if (res->town->common.postal)
- ret=res->town->common.postal;
- if (res->town->common.postal_mask)
- ret=res->town->common.postal_mask;
- if (level == 1)
- return ret;
- if (res->street->common.postal)
- ret=res->street->common.postal;
- if (res->street->common.postal_mask)
- ret=res->street->common.postal_mask;
- if (level == 2)
- return ret;
- if (res->house_number->common.postal)
- ret=res->house_number->common.postal;
- if (res->house_number->common.postal_mask)
- ret=res->house_number->common.postal_mask;
- return ret;
-}
-
-static char *
-get_string_from_attr_list(struct attr **attrs, enum attr_type type, char *dflt)
-{
- struct attr attr;
- if(attr_generic_get_attr(attrs,NULL,type,&attr,NULL))
- return attr.u.str;
- else
- return dflt;
-}
-
-static char *
-district_str(struct search_list_result *res, int level, enum attr_type district, char *dflt)
-{
- char *ret=dflt;
-
- ret=get_string_from_attr_list(res->town->common.attrs, district, ret);
- if (level == 1)
- return ret;
-
- ret=get_string_from_attr_list(res->street->common.attrs, district, ret);
-
- if (level == 2)
- return ret;
-
- ret=get_string_from_attr_list(res->house_number->common.attrs, district, ret);
-
- return ret;
-}
-
-static char *
-town_display_label(struct search_list_result *res, int level, int flags)
-{
- char *town=district_str(res, level,attr_town_name,"");
- char *district=district_str(res, level,attr_district_name,NULL);
- char *postal=postal_str(res, level);
- char *postal_sep=" ";
- char *district_begin=" (";
- char *district_end=")";
- char *county_sep = ", ";
- char *county = res->town->common.county_name;
-
- if (!postal)
- postal_sep=postal="";
- if (!district || (flags & 1))
- district_begin=district_end=district="";
- if (!county || !strcmp(county, town))
- county_sep=county="";
-
- if(level==1 ) {
- if(flags & 2) {
- int n=0;
- char *s[10]={NULL};
-
- s[n]=district_str(res, level, attr_state_name, NULL);
- if(s[n])
- n++;
- s[n]=district_str(res, level, attr_county_name, NULL);
- if(s[n])
- n++;
- s[n]=district_str(res, level, attr_municipality_name, NULL);
- if(s[n])
- n++;
-
- return g_strjoinv(", ",s);
- }
- county=county_sep="";
- }
-
- return g_strdup_printf("%s%s%s%s%s%s%s%s", postal, postal_sep, town, district_begin, district, district_end, county_sep, county);
-}
-
-static void
-gui_internal_find_next_possible_key(char *search_text, char *wm_name, char *possible_keys, char *item_name)
-{
- gchar* trunk_name;
- if (item_name) {
-
- trunk_name = linguistics_expand_special(item_name,1);
- if(!trunk_name){
- trunk_name = g_strrstr(item_name, search_text);
- }
-
- if (trunk_name) {
- int next_char_pos = strlen(search_text);
- char next_char = trunk_name[next_char_pos];
- int i;
- int len = strlen(possible_keys);
-
- for(i = 0; (i<len) && (possible_keys[i] != next_char) ;i++) ;
-
- if ((i==len || !len) && !strncmp(trunk_name, search_text, next_char_pos)) {
- possible_keys[len]=trunk_name[next_char_pos];
- possible_keys[len+1]='\0';
- }
- dbg(lvl_info,"searching for %s, found: %s, currently possible_keys: %s \n", search_text, item_name, possible_keys);
- }
- }
-}
-
-static void
-gui_internal_highlight_possible_keys(struct gui_priv *this, char *possible_keys)
-{
- struct menu_data *md;
- int first_available_key_found = 0;
-
- if (!this->keyboard)
- return;
-
- md=gui_internal_menu_data(this);
- if (md && md->keyboard && !(this->flags & 2048)) {
- GList *lk=md->keyboard->children;
- graphics_draw_mode(this->gra, draw_mode_begin);
- while (lk) {
- struct widget *child=lk->data;
- GList *lk2=child->children;
- while (lk2) {
- struct widget *child_=lk2->data;
- lk2=g_list_next(lk2);
- // The data_free part is an evil hack based on the observation that
- // regular keys have set it to non-NULL whereas special keys appear
- // to have it set to NULL.
- if (child_->data && strcmp("\b", child_->data) && child_->data_free) {
- if ( (strlen(possible_keys) == 0) ||
- (g_strrstr(possible_keys, child_->data)!=NULL ) ) {
- if(this->hide_keys){
- child_->state|= STATE_SENSITIVE|STATE_CLEAR ;
- child_->state&= ~(STATE_INVISIBLE);
- }else{
- child_->state|= STATE_SENSITIVE|STATE_CLEAR|STATE_HIGHLIGHTED ;
- }
- // Select and highlight the first possible button.
- if (!first_available_key_found) {
- gui_internal_highlight_do(this, child_);
- first_available_key_found=1;
- }
- } else {
- if(this->hide_keys){
- child_->state&= ~(STATE_SELECTED|STATE_SENSITIVE) ;
- child_->state|= STATE_INVISIBLE;
- }else{
- child_->state&= ~(STATE_HIGHLIGHTED);
- }
- }
- gui_internal_widget_render(this,child_);
- }
- }
- lk=g_list_next(lk);
- }
- gui_internal_widget_render(this,md->keyboard);
- graphics_draw_mode(this->gra, draw_mode_end);
- }
-
-}
-
-static int
-gui_internal_get_match_quality(char *item_name, char* search_text, int is_house_number_without_street)
-{
- enum match_quality {
- full_string_match, word_match, substring_match, housenum_but_no_street_match }
- match_quality;
- if (is_house_number_without_street) {
- match_quality=housenum_but_no_street_match;
- } else if(item_name) {
- int i;
- char *folded_name=linguistics_casefold(item_name);
- char *folded_query=linguistics_casefold(search_text);
- match_quality=substring_match;
-
- for(i=0; i<3 ;i++) {
- char *exp=linguistics_expand_special(folded_name,i);
- char *p;
- if(!exp)
- continue;
- if(!strcmp(exp,folded_query)) {
- dbg(lvl_debug,"exact match for the whole string %s\n", exp);
- match_quality=full_string_match;
- g_free(exp);
- break;
- }
- if((p=strstr(exp,folded_query))!=NULL) {
- p+=strlen(folded_query);
- if(!*p||strchr(LINGUISTICS_WORD_SEPARATORS_ASCII,*p)) {
- dbg(lvl_debug,"exact matching word found inside string %s\n",exp);
- match_quality=word_match;
- }
- }
- g_free(exp);
- }
- g_free(folded_name);
- g_free(folded_query);
- }
- return match_quality;
-}
-
-static struct widget*
-gui_internal_create_resultlist_entry(struct gui_priv *this, struct search_list_result *res, char *result_main_label, char *result_sublabel, void *param, char *widget_name, struct item *item)
-{
- struct widget *resultlist_entry;
- if(result_sublabel) {
- struct widget *entry_sublabel;
- resultlist_entry=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(resultlist_entry,
- gui_internal_image_new(this, image_new_xs(this, res->country->flag)));
- entry_sublabel=gui_internal_box_new(this, gravity_left_center|orientation_vertical|flags_fill);
- gui_internal_widget_append(resultlist_entry, entry_sublabel);
- gui_internal_widget_append(entry_sublabel, gui_internal_label_new(this, result_main_label));
- gui_internal_widget_append(entry_sublabel, gui_internal_label_font_new(this, result_sublabel, 1));
- resultlist_entry->func=gui_internal_cmd_position;
- resultlist_entry->data=param;
- resultlist_entry->state |= STATE_SENSITIVE;
- resultlist_entry->speech=g_strdup(result_main_label);
- } else {
- resultlist_entry=gui_internal_button_new_with_callback(this, result_main_label,
- image_new_xs(this, res->country->flag),
- gravity_left_center|orientation_horizontal|flags_fill,
- gui_internal_cmd_position, param);
- }
- resultlist_entry->name=widget_name;
- if (res->c)
- resultlist_entry->c=*res->c;
- resultlist_entry->selection_id=res->id;
- if (item)
- resultlist_entry->item=*item;
-
- return resultlist_entry;
-}
-
-/**
- * @brief List of possible next keys/characters given the current result list of the incremental search.
- */
-char possible_keys_incremental_search[256]="";
-
-static void
-gui_internal_search_idle(struct gui_priv *this, char *wm_name, struct widget *search_list, void *param)
-{
- char *result_main_label=NULL,*result_sublabel=NULL,*item_name=NULL, *widget_name=NULL, *search_text;
- struct search_list_result *res;
- struct item *item=NULL;
- struct widget *search_input=NULL;
- struct widget *menu, *resultlist_row, *resultlist_entry;
-
- res=search_list_get_result(this->sl);
- if (!res) {
- gui_internal_search_idle_end(this);
- gui_internal_highlight_possible_keys(this, possible_keys_incremental_search);
- return;
- }
-
- if (! strcmp(wm_name,"Country")) {
- item_name=res->country->name;
- item=&res->country->common.item;
- result_main_label=g_strdup_printf("%s", res->country->name);
- } else if (! strcmp(wm_name,"Town")) {
- item=&res->town->common.item;
- item_name=res->town->common.town_name;
- result_main_label=town_display_label(res, 1, 0);
- result_sublabel=town_display_label(res, 1, 2);
- } else if (! strcmp(wm_name,"Street")) {
- item_name=res->street->name;
- item=&res->street->common.item;
- result_main_label=g_strdup(res->street->name);
- result_sublabel=town_display_label(res, 2, 1);
- } else if (! strcmp(wm_name,"House number")) {
- item_name=res->house_number->house_number;
- result_main_label=g_strdup_printf("%s, %s", item_name, res->street->name);
- result_sublabel=town_display_label(res, 3, 0);
- widget_name=g_strdup(result_main_label);
- }
- if(!item_name) {
- dbg(lvl_error, "Skipping nameless item in search (search type: %s). Please report this as a bug.\n", wm_name);
- return;
- }
-
- if(!widget_name)
- widget_name=g_strdup(item_name);
-
- menu=g_list_last(this->root.children)->data;
- search_input=gui_internal_find_widget(menu, NULL, STATE_EDIT);
- dbg_assert(search_input);
- search_text=search_input->text;
-
- gui_internal_find_next_possible_key(search_text, wm_name, possible_keys_incremental_search, item_name);
-
- resultlist_row=gui_internal_widget_table_row_new(this, gravity_left|orientation_horizontal|flags_fill);
- if (!result_sublabel)
- resultlist_row->text=g_strdup(result_main_label);
- else
- resultlist_row->text=g_strdup_printf("%s %s",item_name,result_sublabel);
- int is_house_number_without_street=!strcmp(wm_name,"House number") && !res->street->name;
- resultlist_row->datai=gui_internal_get_match_quality(item_name, search_text, is_house_number_without_street);
- gui_internal_widget_insert_sorted(search_list, resultlist_row, gui_internal_search_cmp);
-
- resultlist_entry=gui_internal_create_resultlist_entry(
- this, res, result_main_label, result_sublabel, param, widget_name, item);
- gui_internal_widget_append(resultlist_row, resultlist_entry);
- gui_internal_widget_pack(this, search_list);
- graphics_draw_mode(this->gra, draw_mode_begin);
- gui_internal_widget_render(this, menu);
- graphics_draw_mode(this->gra, draw_mode_end);
-
- g_free(result_main_label);
- g_free(result_sublabel);
-}
-
-static void
-gui_internal_search_idle_start(struct gui_priv *this, char *wm_name, struct widget *search_list, void *param)
-{
- this->idle_cb=callback_new_4(callback_cast(gui_internal_search_idle), this, wm_name, search_list, param);
- this->idle=event_add_idle(50,this->idle_cb);
- callback_call_0(this->idle_cb);
-}
-
-static void
-gui_internal_search_changed(struct gui_priv *this, struct widget *wm, void *data)
-{
- GList *l;
- struct widget *search_list=gui_internal_menu_data(this)->search_list;
- void *param=(void *)3;
-
- gui_internal_widget_table_clear(this, search_list);
- possible_keys_incremental_search[0]='\0';
-
- if (! strcmp(wm->name,"Country"))
- param=(void *)4;
- if (! strcmp(wm->name,"Street"))
- param=(void *)5;
- if (! strcmp(wm->name,"House number"))
- param=(void *)6;
- dbg(lvl_debug,"%s now '%s'\n", wm->name, wm->text);
-
- gui_internal_search_idle_end(this);
- if (wm->text && g_utf8_strlen(wm->text, -1) > 0) {
- struct attr search_attr;
-
- dbg(lvl_debug,"process\n");
- if (! strcmp(wm->name,"Country"))
- search_attr.type=attr_country_all;
- if (! strcmp(wm->name,"Town"))
- search_attr.type=attr_town_or_district_name;
- if (! strcmp(wm->name,"Street"))
- search_attr.type=attr_street_name;
- if (! strcmp(wm->name,"House number"))
- search_attr.type=attr_house_number;
- search_attr.u.str=wm->text;
- search_list_search(this->sl, &search_attr, 1);
- gui_internal_search_idle_start(this, wm->name, search_list, param);
- } else {
- // If not enough content is entered, we highlight all keys.
- gui_internal_highlight_possible_keys(this, "");
- }
- l=g_list_last(this->root.children);
- gui_internal_widget_render(this, l->data);
-}
-
-static void
-gui_internal_search_list_set_default_country(struct gui_priv *this)
-{
- struct attr search_attr, country_name, country_iso2, *country_attr;
- struct item *item;
- struct country_search *cs;
- struct tracking *tracking;
- struct search_list_result *res;
-
- country_attr=country_default();
- tracking=navit_get_tracking(this->nav);
- if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
- country_attr=&search_attr;
- if (country_attr) {
- cs=country_search_new(country_attr, 0);
- item=country_search_get_item(cs);
- if (item && item_attr_get(item, attr_country_name, &country_name)) {
- search_attr.type=attr_country_all;
- dbg(lvl_debug,"country %s\n", country_name.u.str);
- search_attr.u.str=country_name.u.str;
- search_list_search(this->sl, &search_attr, 0);
- while((res=search_list_get_result(this->sl)));
- if(this->country_iso2) {
- g_free(this->country_iso2);
- this->country_iso2=NULL;
- }
- if (item_attr_get(item, attr_country_iso2, &country_iso2))
- this->country_iso2=g_strdup(country_iso2.u.str);
- }
- country_search_destroy(cs);
- } else {
- dbg(lvl_error,"warning: no default country found\n");
- if (this->country_iso2) {
- dbg(lvl_debug,"attempting to use country '%s'\n",this->country_iso2);
- search_attr.type=attr_country_iso2;
- search_attr.u.str=this->country_iso2;
- search_list_search(this->sl, &search_attr, 0);
- while((res=search_list_get_result(this->sl)));
- }
- }
-}
-
-static void
-gui_internal_search_list_new(struct gui_priv *this)
-{
- struct mapset *ms=navit_get_mapset(this->nav);
- if (! this->sl) {
- this->sl=search_list_new(ms);
- gui_internal_search_list_set_default_country(this);
- }
-}
-
-void
-gui_internal_search_list_destroy(struct gui_priv *this)
-{
- if (this->sl) {
- search_list_destroy(this->sl);
- this->sl=NULL;
- }
-}
-
-void
-gui_internal_search(struct gui_priv *this, const char *what, const char *type, int flags)
-{
- struct widget *wb,*wk,*w,*wr,*we,*wl,*wnext=NULL;
- char *country;
- int keyboard_mode;
- gui_internal_search_list_new(this);
- keyboard_mode = VKBD_FLAG_2 | gui_internal_keyboard_init_mode(this->country_iso2 ? this->country_iso2 : getenv("LANG"));
- wb=gui_internal_menu(this, what);
- w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wb, w);
- wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(w, wr);
- we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
- gui_internal_widget_append(wr, we);
- if (!strcmp(type,"Country")) {
- wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_town"));
- wnext->func=gui_internal_search_town;
- } else if (!strcmp(type,"Town")) {
- if (this->country_iso2) {
-#ifdef HAVE_API_ANDROID
- char country_iso2[strlen(this->country_iso2)+1];
- strtolower(country_iso2, this->country_iso2);
- country=g_strdup_printf("country_%s", country_iso2);
-#else
- country=g_strdup_printf("country_%s", this->country_iso2);
-#endif
- } else
- country=g_strdup("gui_select_country");
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, country)));
- wb->state |= STATE_SENSITIVE;
- if (flags)
- wb->func = gui_internal_search_country;
- else
- wb->func = gui_internal_back;
- wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_street"));
- wnext->func=gui_internal_search_street;
- g_free(country);
- } else if (!strcmp(type,"Street")) {
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_select_town")));
- wb->state |= STATE_SENSITIVE;
- wb->func = gui_internal_back;
- wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_house_number"));
- wnext->func=gui_internal_search_house_number;
- } else if (!strcmp(type,"House number")) {
- gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_select_street")));
- wb->state |= STATE_SENSITIVE;
- wb->func = gui_internal_back;
- keyboard_mode = VKBD_NUMERIC | VKBD_FLAG_2;
- }
- gui_internal_widget_append(we, wk=gui_internal_label_new(this, NULL));
- if (wnext) {
- gui_internal_widget_append(we, wnext);
- wnext->state |= STATE_SENSITIVE;
- }
- wl=gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);//gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
- gui_internal_widget_append(wr, wl);
- gui_internal_menu_data(this)->search_list=wl;
- wk->state |= STATE_EDIT|STATE_EDITABLE;
- wk->background=this->background;
- wk->flags |= flags_expand|flags_fill;
- wk->func = gui_internal_search_changed;
- wk->name=g_strdup(type);
- if (this->keyboard)
- gui_internal_widget_append(w, gui_internal_keyboard(this, keyboard_mode));
- else
- gui_internal_keyboard_show_native(this, w, keyboard_mode, getenv("LANG"));
- gui_internal_menu_render(this);
-}
-
-void
-gui_internal_search_house_number_in_street(struct gui_priv *this, struct widget *widget, void *data)
-{
- dbg(lvl_info,"id %d\n", widget->selection_id);
- search_list_select(this->sl, attr_street_name, 0, 0);
- search_list_select(this->sl, attr_street_name, widget->selection_id, 1);
- gui_internal_search(this,_("House number"),"House number",0);
-}
-
-void
-gui_internal_search_street_in_town(struct gui_priv *this, struct widget *widget, void *data)
-{
- dbg(lvl_info,"id %d\n", widget->selection_id);
- search_list_select(this->sl, attr_town_or_district_name, 0, 0);
- search_list_select(this->sl, attr_town_or_district_name, widget->selection_id, 1);
- gui_internal_search(this,_("Street"),"Street",0);
-}
-
-void
-gui_internal_search_town_in_country(struct gui_priv *this, struct widget *widget)
-{
- struct search_list_common *slc;
- dbg(lvl_info,"id %d\n", widget->selection_id);
- search_list_select(this->sl, attr_country_all, 0, 0);
- slc=search_list_select(this->sl, attr_country_all, widget->selection_id, 1);
- if (slc) {
- g_free(this->country_iso2);
- this->country_iso2=g_strdup(((struct search_list_country *)slc)->iso2);
- }
- gui_internal_search(this,widget->name,"Town",0);
-}
-
diff --git a/navit/gui/internal/gui_internal_search.h b/navit/gui/internal/gui_internal_search.h
deleted file mode 100644
index 6add28327..000000000
--- a/navit/gui/internal/gui_internal_search.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* prototypes */
-struct gui_priv;
-struct widget;
-void gui_internal_search_idle_end(struct gui_priv *this);
-void gui_internal_search_list_destroy(struct gui_priv *this);
-void gui_internal_search(struct gui_priv *this, const char *what, const char *type, int flags);
-void gui_internal_search_house_number_in_street(struct gui_priv *this, struct widget *widget, void *data);
-void gui_internal_search_street_in_town(struct gui_priv *this, struct widget *widget, void *data);
-void gui_internal_search_town_in_country(struct gui_priv *this, struct widget *widget);
-/* end of prototypes */
diff --git a/navit/gui/internal/gui_internal_widget.c b/navit/gui/internal/gui_internal_widget.c
deleted file mode 100644
index 3e1993025..000000000
--- a/navit/gui/internal/gui_internal_widget.c
+++ /dev/null
@@ -1,1497 +0,0 @@
-#include <glib.h>
-#include "color.h"
-#include "coord.h"
-#include "point.h"
-#include "callback.h"
-#include "graphics.h"
-#include "debug.h"
-#include "navit_nls.h"
-#include "gui_internal.h"
-#include "gui_internal_widget.h"
-#include "gui_internal_priv.h"
-#include "gui_internal_menu.h"
-
-static void gui_internal_scroll_buttons_init(struct gui_priv *this, struct widget *widget, struct scroll_buttons *sb);
-
-static void
-gui_internal_background_render(struct gui_priv *this, struct widget *w)
-{
- struct point pnt=w->p;
- if (w->state & STATE_HIGHLIGHTED)
- graphics_draw_rectangle(this->gra, this->highlight_background, &pnt, w->w, w->h);
- else {
- if (w->background)
- graphics_draw_rectangle(this->gra, w->background, &pnt, w->w, w->h);
- }
-}
-
-struct widget *
-gui_internal_label_font_new(struct gui_priv *this, const char *text, int font)
-{
- struct point p[4];
- int w=0;
- int h=0;
-
- struct widget *widget=g_new0(struct widget, 1);
- widget->type=widget_label;
- widget->font_idx=font;
- if (text) {
- widget->text=g_strdup(text);
- graphics_get_text_bbox(this->gra, this->fonts[font], widget->text, 0x10000, 0x0, p, 0);
- w=p[2].x-p[0].x;
- h=p[0].y-p[2].y;
- }
- widget->h=h+this->spacing;
- widget->texth=h;
- widget->w=w+this->spacing;
- widget->textw=w;
- widget->flags=gravity_center;
- widget->foreground=this->text_foreground;
- widget->text_background=this->text_background;
-
- return widget;
-}
-
-struct widget *
-gui_internal_label_new(struct gui_priv *this, const char *text)
-{
- return gui_internal_label_font_new(this, text, 0);
-}
-
-struct widget *
-gui_internal_label_new_abbrev(struct gui_priv *this, const char *text, int maxwidth)
-{
- struct widget *ret=NULL;
- char *tmp=g_malloc(strlen(text)+3);
- const char *p;
- p=text+strlen(text);
- while ((p=g_utf8_find_prev_char(text, p)) >= text) {
- int i=p-text;
- strcpy(tmp, text);
- strcpy(tmp+i,"..");
- ret=gui_internal_label_new(this, tmp);
- if (ret->w < maxwidth)
- break;
- gui_internal_widget_destroy(this, ret);
- ret=NULL;
- }
- if(!ret)
- ret=gui_internal_label_new(this, "");
- g_free(tmp);
- return ret;
-}
-
-struct widget *
-gui_internal_image_new(struct gui_priv *this, struct graphics_image *image)
-{
- struct widget *widget=g_new0(struct widget, 1);
- widget->type=widget_image;
- widget->img=image;
- if (image) {
- widget->w=image->width;
- widget->h=image->height;
- }
- return widget;
-}
-
-static void
-gui_internal_image_render(struct gui_priv *this, struct widget *w)
-{
- struct point pnt;
-
- gui_internal_background_render(this, w);
- if (w->img) {
- pnt=w->p;
- pnt.x+=w->w/2-w->img->hot.x;
- pnt.y+=w->h/2-w->img->hot.y;
- graphics_draw_image(this->gra, this->foreground, &pnt, w->img);
- }
-}
-
-/**
- * @brief Renders a label.
- *
- * @param this The internal GUI instance
- * @param w The widget to render
- */
-static void
-gui_internal_label_render(struct gui_priv *this, struct widget *w)
-{
- struct point pnt=w->p;
- gui_internal_background_render(this, w);
- if (w->state & STATE_EDIT)
- graphics_draw_rectangle(this->gra, this->highlight_background, &pnt, w->w, w->h);
- if (w->text) {
- char *text;
- char *startext=(char*)g_alloca(strlen(w->text)+1);
- text=w->text;
- if (w->flags2 & 1) {
- int i;
- for (i = 0 ; i < strlen(text); i++)
- startext[i]='*';
- startext[i]='\0';
- text=startext;
- }
- if (w->flags & gravity_right) {
- pnt.y+=w->h-this->spacing;
- pnt.x+=w->w-w->textw-this->spacing;
- graphics_draw_text(this->gra, w->foreground, w->text_background, this->fonts[w->font_idx], text, &pnt, 0x10000, 0x0);
- } else {
- pnt.y+=w->h-this->spacing;
- graphics_draw_text(this->gra, w->foreground, w->text_background, this->fonts[w->font_idx], text, &pnt, 0x10000, 0x0);
- }
- }
-}
-
-/**
- * @brief Creates a text box.
- *
- * A text box is a widget that renders a text string containing newlines.
- * The string will be broken up into label widgets at each newline with a vertical layout.
- *
- * @param this The internal GUI instance
- * @param text The text to be displayed in the text box
- * @param font The font to use for the text
- * @param flags
- */
-struct widget *
-gui_internal_text_font_new(struct gui_priv *this, const char *text, int font, enum flags flags)
-{
- char *s=g_strdup(text),*s2,*tok;
- struct widget *ret=gui_internal_box_new(this, flags);
- s2=s;
- while ((tok=strtok(s2,"\n"))) {
- gui_internal_widget_append(ret, gui_internal_label_font_new(this, tok, font));
- s2=NULL;
- }
- gui_internal_widget_pack(this,ret);
- g_free(s);
- return ret;
-}
-
-struct widget *
-gui_internal_text_new(struct gui_priv *this, const char *text, enum flags flags)
-{
- return gui_internal_text_font_new(this, text, 0, flags);
-}
-
-
-struct widget *
-gui_internal_button_font_new_with_callback(struct gui_priv *this, const char *text, int font, struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data)
-{
- struct widget *ret=NULL;
- ret=gui_internal_box_new(this, flags);
- if (ret) {
- if (image && !(flags & flags_swap))
- gui_internal_widget_append(ret, gui_internal_image_new(this, image));
- if (text)
- gui_internal_widget_append(ret, gui_internal_text_font_new(this, text, font, gravity_center|orientation_vertical));
- if (image && (flags & flags_swap))
- gui_internal_widget_append(ret, gui_internal_image_new(this, image));
- ret->func=func;
- ret->data=data;
- if (func) {
- ret->state |= STATE_SENSITIVE;
- ret->speech=g_strdup(text);
- }
- }
- return ret;
-
-}
-
-struct widget *
-gui_internal_button_new_with_callback(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data)
-{
- return gui_internal_button_font_new_with_callback(this, text, 0, image, flags, func, data);
-}
-
-struct widget *
-gui_internal_button_new(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags)
-{
- return gui_internal_button_new_with_callback(this, text, image, flags, NULL, NULL);
-}
-
-struct widget *
-gui_internal_find_widget(struct widget *wi, struct point *p, int flags)
-{
- struct widget *ret,*child;
- GList *l=wi->children;
-
- if (p) {
- if (wi->p.x > p->x )
- return NULL;
- if (wi->p.y > p->y )
- return NULL;
- if ( wi->p.x + wi->w < p->x)
- return NULL;
- if ( wi->p.y + wi->h < p->y)
- return NULL;
- }
- if (wi->state & flags)
- return wi;
- while (l) {
- child=l->data;
- ret=gui_internal_find_widget(child, p, flags);
- if (ret) {
- return ret;
- }
- l=g_list_next(l);
- }
- return NULL;
-
-}
-
-void
-gui_internal_highlight_do(struct gui_priv *this, struct widget *found)
-{
- if (found == this->highlighted)
- return;
-
- graphics_draw_mode(this->gra, draw_mode_begin);
- if (this->highlighted) {
- this->highlighted->state &= ~STATE_HIGHLIGHTED;
- if (this->root.children && this->highlighted_menu == g_list_last(this->root.children)->data)
- gui_internal_widget_render(this, this->highlighted);
- this->highlighted=NULL;
- this->highlighted_menu=NULL;
- }
- if (found) {
- this->highlighted=found;
- this->highlighted_menu=g_list_last(this->root.children)->data;
- this->highlighted->state |= STATE_HIGHLIGHTED;
- gui_internal_widget_render(this, this->highlighted);
- dbg(lvl_debug,"%d,%d %dx%d\n", found->p.x, found->p.y, found->w, found->h);
- }
- graphics_draw_mode(this->gra, draw_mode_end);
-}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-void
-gui_internal_highlight(struct gui_priv *this)
-{
- struct widget *menu,*found=NULL;
- if (this->current.x > -1 && this->current.y > -1) {
- menu=g_list_last(this->root.children)->data;
- found=gui_internal_find_widget(menu, &this->current, STATE_SENSITIVE);
- if (!found) {
- found=gui_internal_find_widget(menu, &this->current, STATE_EDITABLE);
- if (found) {
- if (this->editable && this->editable != found) {
- this->editable->state &= ~ STATE_EDIT;
- gui_internal_widget_render(this, this->editable);
- }
- found->state |= STATE_EDIT;
- gui_internal_widget_render(this, found);
- this->editable=found;
- found=NULL;
- }
- }
- }
- gui_internal_highlight_do(this, found);
- this->motion_timeout_event=NULL;
-}
-
-
-struct widget *
-gui_internal_box_new_with_label(struct gui_priv *this, enum flags flags, const char *label)
-{
- struct widget *widget=g_new0(struct widget, 1);
-
- if (label)
- widget->text=g_strdup(label);
- widget->type=widget_box;
- widget->flags=flags;
- return widget;
-}
-
-struct widget *
-gui_internal_box_new(struct gui_priv *this, enum flags flags)
-{
- return gui_internal_box_new_with_label(this, flags, NULL);
-}
-
-
-static void gui_internal_box_render(struct gui_priv *this, struct widget *w)
-{
- struct widget *wc;
- GList *l;
-
- gui_internal_background_render(this, w);
- if (w->foreground && w->border) {
- struct point pnt[5];
- pnt[0]=w->p;
- pnt[1].x=pnt[0].x+w->w;
- pnt[1].y=pnt[0].y;
- pnt[2].x=pnt[0].x+w->w;
- pnt[2].y=pnt[0].y+w->h;
- pnt[3].x=pnt[0].x;
- pnt[3].y=pnt[0].y+w->h;
- pnt[4]=pnt[0];
- graphics_gc_set_linewidth(w->foreground, w->border ? w->border : 1);
- graphics_draw_lines(this->gra, w->foreground, pnt, 5);
- graphics_gc_set_linewidth(w->foreground, 1);
- }
-
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_render(this, wc);
- l=g_list_next(l);
- }
- if (w->scroll_buttons)
- gui_internal_widget_render(this, w->scroll_buttons->button_box);
-}
-
-
-/**
- * @brief Computes the size and location for the widget.
- *
- * @param this The internal GUI instance
- * @param w The widget to render
- */
-static void gui_internal_box_pack(struct gui_priv *this, struct widget *w)
-{
- struct widget *wc;
- int x0,x=0,y=0,width=0,height=0,owidth=0,oheight=0,expand=0,expandd=1,count=0,rows=0,cols=w->cols ? w->cols : 0;
- int hb=w->scroll_buttons?w->scroll_buttons->button_box->h:0;
- GList *l;
- int orientation=w->flags & 0xffff0000;
-
- if (!cols)
- cols=this->cols;
- if (!cols) {
- if ( this->root.w > this->root.h )
- cols=3;
- else
- cols=2;
- width=0;
- height=0;
- }
-
-
- /*
- * count the number of children
- */
- l=w->children;
- while (l) {
- count++;
- l=g_list_next(l);
- }
- if (orientation == orientation_horizontal_vertical && count <= cols)
- orientation=orientation_horizontal;
- switch (orientation) {
- case orientation_horizontal:
- /*
- * For horizontal orientation:
- * pack each child and find the largest height and
- * compute the total width. x spacing (spx) is considered
- *
- * If any children want to be expanded
- * we keep track of this
- */
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_pack(this, wc);
- if (height < wc->h)
- height=wc->h;
- width+=wc->w;
- if (wc->flags & flags_expand)
- expand+=wc->w ? wc->w : 1;
- l=g_list_next(l);
- if (l)
- width+=w->spx;
- }
- owidth=width;
- if (expand && w->w) {
- expandd=w->w-width+expand;
- owidth=w->w;
- } else
- expandd=expand=1;
- break;
- case orientation_vertical:
- /*
- * For vertical layouts:
- * We pack each child and compute the largest width and
- * the total height. y spacing (spy) is considered
- *
- * If the expand flag is set then teh expansion amount
- * is computed.
- */
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_pack(this, wc);
- if (width < wc->w)
- width=wc->w;
- height+=wc->h;
- if (wc->flags & flags_expand)
- expand+=wc->h ? wc->h : 1;
- l=g_list_next(l);
- if (l)
- height+=w->spy;
- }
- oheight=height;
- if (expand && w->h) {
- expandd=w->h-hb-height+expand;
- oheight=w->h-hb;
- } else
- expandd=expand=1;
- break;
- case orientation_horizontal_vertical:
- /*
- * For horizontal_vertical orientation
- * pack the children.
- * Compute the largest height and largest width.
- * Layout the widgets based on having the
- * number of columns specified by (cols)
- */
- count=0;
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_pack(this, wc);
- if (height < wc->h)
- height=wc->h;
- if (width < wc->w)
- width=wc->w;
- l=g_list_next(l);
- count++;
- }
- if (count < cols)
- cols=count;
- rows=(count+cols-1)/cols;
- width*=cols;
- height*=rows;
- width+=w->spx*(cols-1);
- height+=w->spy*(rows-1);
- owidth=width;
- oheight=height;
- expandd=expand=1;
- break;
- default:
- /*
- * No orientation was specified.
- * width and height are both 0.
- * The width & height of this widget
- * will be used.
- */
- if(!w->w && !w->h)
- dbg(lvl_error,"Warning width and height of a widget are 0");
- break;
- }
- if (! w->w && ! w->h) {
- w->w=w->bl+w->br+width;
- w->h=w->bt+w->bb+height+hb;
- w->packed=1;
- }
-#if 0
- if (expand < 100)
- expand=100;
-#endif
-
- /*
- * At this stage the width and height of this
- * widget has been computed.
- * We now make a second pass assigning heights,
- * widths and coordinates to each child widget.
- */
-
- if (w->flags & gravity_left)
- x=w->p.x+w->bl;
- if (w->flags & gravity_xcenter)
- x=w->p.x+w->w/2-owidth/2;
- if (w->flags & gravity_right)
- x=w->p.x+w->w-w->br-owidth;
- if (w->flags & gravity_top)
- y=w->p.y+w->bt;
- if (w->flags & gravity_ycenter)
- y=w->p.y+(w->h-hb)/2-oheight/2;
- if (w->flags & gravity_bottom)
- y=w->p.y+(w->h-hb)-w->bb-oheight;
- l=w->children;
- switch (orientation) {
- case orientation_horizontal:
- l=w->children;
- while (l) {
- wc=l->data;
- wc->p.x=x;
- if (wc->flags & flags_fill)
- wc->h=w->h-hb;
- if (wc->flags & flags_expand) {
- if (! wc->w)
- wc->w=1;
- wc->w=wc->w*expandd/expand;
- }
- if (w->flags & gravity_top)
- wc->p.y=y;
- if (w->flags & gravity_ycenter)
- wc->p.y=y-wc->h/2;
- if (w->flags & gravity_bottom)
- wc->p.y=y-wc->h;
- x+=wc->w+w->spx;
- l=g_list_next(l);
- }
- break;
- case orientation_vertical:
- l=w->children;
- while (l) {
- wc=l->data;
- wc->p.y=y;
- if (wc->flags & flags_fill)
- wc->w=w->w;
- if (wc->flags & flags_expand) {
- if (! wc->h)
- wc->h=1;
- wc->h=wc->h*expandd/expand;
- }
- if (w->flags & gravity_left)
- wc->p.x=x;
- if (w->flags & gravity_xcenter)
- wc->p.x=x-wc->w/2;
- if (w->flags & gravity_right)
- wc->p.x=x-wc->w;
- y+=wc->h+w->spy;
- l=g_list_next(l);
- }
- break;
- case orientation_horizontal_vertical:
- l=w->children;
- x0=x;
- count=0;
- width/=cols;
- height/=rows;
- while (l) {
- wc=l->data;
- wc->p.x=x;
- wc->p.y=y;
- if (wc->flags & flags_fill) {
- wc->w=width;
- wc->h=height;
- }
- if (w->flags & gravity_left)
- wc->p.x=x;
- if (w->flags & gravity_xcenter)
- wc->p.x=x+(width-wc->w)/2;
- if (w->flags & gravity_right)
- wc->p.x=x+width-wc->w;
- if (w->flags & gravity_top)
- wc->p.y=y;
- if (w->flags & gravity_ycenter)
- wc->p.y=y+(height-wc->h)/2;
- if (w->flags & gravity_bottom)
- wc->p.y=y-height-wc->h;
- x+=width;
- if (++count == cols) {
- count=0;
- x=x0;
- y+=height;
- }
- l=g_list_next(l);
- }
- break;
- default:
- break;
- }
- if ((w->flags & flags_scrolly) && y > w->h+w->p.y && !w->scroll_buttons) {
- w->scroll_buttons=g_new0(struct scroll_buttons, 1);
- gui_internal_scroll_buttons_init(this, w, w->scroll_buttons);
- w->scroll_buttons->button_box->w=w->w;
- w->scroll_buttons->button_box->p.x=w->p.x;
- w->scroll_buttons->button_box->p.y=w->p.y+w->h-w->scroll_buttons->button_box->h;
- gui_internal_widget_pack(this, w->scroll_buttons->button_box);
- dbg(lvl_debug,"needs buttons %d vs %d\n",y,w->h);
- gui_internal_box_pack(this, w);
- return;
- }
- /*
- * Call pack again on each child,
- * the child has now had its size and coordinates
- * set so they can repack their children.
- */
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_pack(this, wc);
- l=g_list_next(l);
- }
-}
-
-void
-gui_internal_widget_reset_pack(struct gui_priv *this, struct widget *w)
-{
- struct widget *wc;
- GList *l;
-
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_reset_pack(this, wc);
- l=g_list_next(l);
- }
- if (w->packed) {
- w->w=0;
- w->h=0;
- }
-}
-
-/**
- * @brief Adds a child widget to a parent widget, making it the last child.
- *
- * @param parent The parent widget
- * @param child The child widget
- */
-void
-gui_internal_widget_append(struct widget *parent, struct widget *child)
-{
- if (! child)
- return;
- if (! child->background)
- child->background=parent->background;
- parent->children=g_list_append(parent->children, child);
- child->parent=parent;
-}
-
-/**
- * @brief Adds a child widget to a parent widget, making it the first child.
- *
- * @param parent The parent widget
- * @param child The child widget
- */
-void
-gui_internal_widget_prepend(struct widget *parent, struct widget *child)
-{
- if (! child->background)
- child->background=parent->background;
- parent->children=g_list_prepend(parent->children, child);
- child->parent=parent;
-}
-
-/**
- * @brief Adds a child widget to a parent widget.
- *
- * Placement of the child widget among its siblings depends on the comparison function {@code func}.
- *
- * @param parent The parent widget
- * @param child The child widget
- * @param func The comparison function
- */
-void
-gui_internal_widget_insert_sorted(struct widget *parent, struct widget *child, GCompareFunc func)
-{
- if (! child->background)
- child->background=parent->background;
-
- parent->children=g_list_insert_sorted(parent->children, child, func);
- child->parent=parent;
-}
-
-
-/**
- * @brief Destroys all child widgets.
- *
- * This function is recursive, destroying all widgets in the child hierarchy of {@code w}.
- *
- * @param this The internal GUI instance
- * @param w The widget whose children are to be destroyed
- */
-void
-gui_internal_widget_children_destroy(struct gui_priv *this, struct widget *w)
-{
- GList *l;
- struct widget *wc;
-
- l=w->children;
- while (l) {
- wc=l->data;
- gui_internal_widget_destroy(this, wc);
- l=g_list_next(l);
- }
- g_list_free(w->children);
- w->children=NULL;
-}
-
-
-/**
- * @brief Destroys a widget.
- *
- * This function also takes care of recursively destroying the entire child widget hierarchy of
- * {@code w} prior to destroying {@code w} itself.
- *
- * @param this The internal GUI instance
- * @param w The widget to destroy
- */
-void
-gui_internal_widget_destroy(struct gui_priv *this, struct widget *w)
-{
- gui_internal_widget_children_destroy(this, w);
- g_free(w->command);
- g_free(w->speech);
- g_free(w->text);
- if (w->img)
- graphics_image_free(this->gra, w->img);
- if (w->prefix)
- g_free(w->prefix);
- if (w->name)
- g_free(w->name);
- if (w->data_free)
- w->data_free(w->data);
- if (w->cb && w->remove_cb)
- w->remove_cb(w->instance, w->cb);
- if (w==this->highlighted)
- this->highlighted=NULL;
- if(w->wfree)
- w->wfree(this,w);
- else
- g_free(w);
-}
-
-
-void
-gui_internal_widget_render(struct gui_priv *this, struct widget *w)
-{
- if(w->p.x > this->root.w || w->p.y > this->root.h || w->state & STATE_INVISIBLE)
- return;
-
- switch (w->type) {
- case widget_box:
- gui_internal_box_render(this, w);
- break;
- case widget_label:
- gui_internal_label_render(this, w);
- break;
- case widget_image:
- gui_internal_image_render(this, w);
- break;
- case widget_table:
- gui_internal_table_render(this,w);
- break;
- default:
- break;
- }
-}
-
-void
-gui_internal_widget_pack(struct gui_priv *this, struct widget *w)
-{
- switch (w->type) {
- case widget_box:
- gui_internal_box_pack(this, w);
- break;
- case widget_table:
- gui_internal_table_pack(this,w);
- default:
- break;
- }
-}
-
-struct widget *
-gui_internal_button_label(struct gui_priv *this, const char *label, int mode)
-{
- struct widget *wl,*wlb;
- struct widget *wb=gui_internal_menu_data(this)->button_bar;
- wlb=gui_internal_box_new(this, gravity_right_center|orientation_vertical);
- wl=gui_internal_label_new(this, label);
- wlb->border=1;
- wlb->foreground=this->text_foreground;
- wlb->bl=20;
- wlb->br=20;
- wlb->bb=6;
- wlb->bt=6;
- gui_internal_widget_append(wlb, wl);
- if (mode == 1)
- gui_internal_widget_prepend(wb, wlb);
- if (mode == -1)
- gui_internal_widget_append(wb, wlb);
-
- return wlb;
-}
-
-static void
-gui_internal_scroll_buttons_init(struct gui_priv *this, struct widget *widget, struct scroll_buttons *sb)
-{
- sb->next_button = gui_internal_button_new_with_callback(this, _("Next"), image_new_xs(this, "gui_arrow_right"),
- gravity_center|orientation_horizontal|flags_swap, gui_internal_table_button_next, widget);
- sb->prev_button = gui_internal_button_new_with_callback(this, _("Prev"), image_new_xs(this, "gui_arrow_left"),
- gravity_center|orientation_horizontal, gui_internal_table_button_prev, widget);
-
- sb->button_box=gui_internal_box_new(this, gravity_center|orientation_horizontal);
- sb->button_box->background=this->background;
- if(this->hide_keys){
- sb->prev_button->state |= STATE_INVISIBLE;
- sb->next_button->state |= STATE_INVISIBLE;
- }
- sb->prev_button->state &= ~STATE_SENSITIVE;
- sb->next_button->state &= ~STATE_SENSITIVE;
- gui_internal_widget_append(sb->button_box, sb->prev_button);
- gui_internal_widget_append(sb->button_box, sb->next_button);
-
- sb->button_box->bl=this->spacing;
- gui_internal_widget_pack(this,sb->button_box);
-}
-
-/**
- * @brief Creates a new table widget.
- *
- * Creates and returns a new table widget. This function will
- * setup next/previous buttons as children.
- *
- * @param this The graphics context.
- * @param flags widget sizing flags.
- * @return The newly created widget
- */
-struct widget * gui_internal_widget_table_new(struct gui_priv * this, enum flags flags, int buttons)
-{
- struct widget * widget = g_new0(struct widget,1);
- struct table_data * data = NULL;
- widget->type=widget_table;
- widget->flags=flags;
- widget->state=STATE_SCROLLABLE;
- widget->data=g_new0(struct table_data,1);
- widget->data_free=gui_internal_table_data_free;
-
- // We have to set background here explicitly
- // because it will be used by inner elements created later in this
- // function (navigation buttons). Else that elements won't have
- // any background.
- widget->background=this->background;
- data = (struct table_data*)widget->data;
-
- if (buttons) {
- gui_internal_scroll_buttons_init(this, widget, &data->scroll_buttons);
- gui_internal_widget_append(widget, data->scroll_buttons.button_box);
- }
-
- return widget;
-
-}
-
-/**
- * @brief Clears all the rows from the table.
- *
- * This function removes all rows from a table.
- * New rows can later be added to the table.
- *
- * @param this The internal GUI instance
- * @param table The table widget
- */
-void gui_internal_widget_table_clear(struct gui_priv * this,struct widget * table)
-{
- GList * iter;
- struct table_data * table_data = (struct table_data* ) table->data;
-
- iter = table->children;
- while(iter ) {
- if(iter->data != table_data->scroll_buttons.button_box) {
- struct widget * child = (struct widget*)iter->data;
- gui_internal_widget_destroy(this,child);
- if(table->children == iter) {
- table->children = g_list_remove(iter,iter->data);
- iter=table->children;
- }
- else
- iter = g_list_remove(iter,iter->data);
- }
- else {
- iter = g_list_next(iter);
- }
-
- }
- table_data->top_row=NULL;
- table_data->bottom_row=NULL;
-}
-
-/**
- * @brief Moves GList pointer to the next table row, skipping other table children (button box, for example).
- *
- * @param row GList pointer into the children list
- *
- * @return GList pointer to the next row in the children list, or NULL if there are no any rows left.
- */
-GList *
-gui_internal_widget_table_next_row(GList * row)
-{
- while((row=g_list_next(row))!=NULL) {
- if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
- break;
- }
- return row;
-}
-
-/**
- * @brief Moves GList pointer to the previous table row, skipping other table children (button box, for example).
- *
- * @param row GList pointer into the children list
- *
- * @return GList pointer to the previous row in the children list, or NULL if there are no any rows left.
- */
-GList *
-gui_internal_widget_table_prev_row(GList * row)
-{
- while((row=g_list_previous(row))!=NULL) {
- if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
- break;
- }
- return row;
-}
-
-/**
- * @brief Moves GList pointer to the first table row, skipping other table children (button box, for example).
- *
- * @param row GList pointer into the children list
- *
- * @return GList pointer to the first row in the children list, or NULL if table is empty.
- */
-GList *
-gui_internal_widget_table_first_row(GList * row)
-{
- if(!row)
- return NULL;
-
- if(row->data && ((struct widget *)(row->data))->type == widget_table_row)
- return row;
-
- return gui_internal_widget_table_next_row(row);
-}
-
-/**
- * @brief Gets GList pointer to the table row drawn on the top of the screen.
- *
- * @return GList pointer to the top row in the children list, or NULL.
- */
-GList *
-gui_internal_widget_table_top_row(struct gui_priv *this, struct widget * table)
-{
- if(table && table->type==widget_table) {
- struct table_data *d=table->data;
- return gui_internal_widget_table_first_row(d->top_row);
- }
- return NULL;
-}
-
-/**
- * @brief Sets internal top row pointer of the table to point to a given row widget.
- *
- * @return GList pointer to the top row in the children list of the table.
- */
-GList *
-gui_internal_widget_table_set_top_row(struct gui_priv *this, struct widget * table, struct widget *row)
-{
- if(table && table->type==widget_table) {
- struct table_data *d=table->data;
- d->top_row=table->children;
- while(d->top_row && d->top_row->data!=row)
- d->top_row=g_list_next(d->top_row);
- if(!d->top_row)
- d->top_row=gui_internal_widget_table_first_row(table->children);
- return d->top_row;
- }
- return NULL;
-}
-
-
-/**
- * @brief Creates a new table_row widget.
- *
- * @param this The graphics context
- * @param flags Sizing flags for the row
- *
- * @return The new table_row widget.
- */
-struct widget *
-gui_internal_widget_table_row_new(struct gui_priv * this, enum flags flags)
-{
- struct widget * widget = g_new0(struct widget,1);
- widget->type=widget_table_row;
- widget->flags=flags;
- return widget;
-}
-
-
-
-/**
- * @brief Computes the column dimensions for the table.
- *
- * @param this The internal GUI instance
- * @param w The table widget to compute dimensions for.
- *
- * This function examines all of the rows and columns for the table w
- * and returns a list (GList) of table_column_desc elements that
- * describe each column of the table.
- *
- * The caller is responsible for freeing the returned list.
- */
-static GList *
-gui_internal_compute_table_dimensions(struct gui_priv * this,struct widget * w)
-{
-
- GList * column_desc = NULL;
- GList * current_desc=NULL;
- GList * cur_row = w->children;
- struct widget * cur_row_widget=NULL;
- GList * cur_column=NULL;
- struct widget * cell_w=NULL;
- struct table_column_desc * current_cell=NULL;
- struct table_data * table_data=NULL;
- int height=0;
- int width=0;
- int total_width=0;
- int column_count=0;
-
- /*
- * Scroll through the the table and
- * 1. Compute the maximum width + height of each column across all rows.
- */
- table_data = (struct table_data*) w->data;
- for(cur_row=w->children; cur_row ; cur_row = g_list_next(cur_row) )
- {
- cur_row_widget = (struct widget*) cur_row->data;
- current_desc = column_desc;
- if(cur_row_widget == table_data->scroll_buttons.button_box)
- {
- continue;
- }
- column_count=0;
- for(cur_column = cur_row_widget->children; cur_column;
- cur_column=g_list_next(cur_column))
- {
- cell_w = (struct widget*) cur_column->data;
- gui_internal_widget_pack(this,cell_w);
- if(current_desc == 0)
- {
- current_cell = g_new0(struct table_column_desc,1);
- column_desc = g_list_append(column_desc,current_cell);
- current_desc = g_list_last(column_desc);
- current_cell->height=cell_w->h;
- current_cell->width=cell_w->w;
- total_width+=cell_w->w;
-
- }
- else
- {
- current_cell = current_desc->data;
- height = cell_w->h;
- width = cell_w->w;
- if(current_cell->height < height )
- {
- current_cell->height = height;
- }
- if(current_cell->width < width)
- {
- total_width += (width-current_cell->width);
- current_cell->width = width;
-
-
-
- }
- current_desc = g_list_next(current_desc);
- }
- column_count++;
-
- }/* column loop */
-
- } /*row loop */
-
-
- /*
- * If the width of all columns is less than the width off
- * the table expand each cell proportionally.
- *
- */
- if(total_width+(this->spacing*column_count) < w->w ) {
- for(current_desc=column_desc; current_desc; current_desc=g_list_next(current_desc)) {
- current_cell = (struct table_column_desc*) current_desc->data;
- current_cell->width= ( (current_cell->width+this->spacing)/(float)total_width) * w->w ;
- }
- }
-
- return column_desc;
-}
-
-
-/**
- * @brief Computes the height and width for the table.
- *
- * The height and width are computed to display all cells in the table
- * at the requested height/width.
- *
- * @param this The graphics context
- * @param w The widget to pack.
- */
-void
-gui_internal_table_pack(struct gui_priv * this, struct widget * w)
-{
-
- int height=0;
- int width=0;
- int count=0;
- GList * column_data = gui_internal_compute_table_dimensions(this,w);
- GList * current=0;
- struct table_column_desc * cell_desc=0;
- struct table_data * table_data = (struct table_data*)w->data;
-
- for(current = column_data; current; current=g_list_next(current))
- {
- if(table_data->scroll_buttons.button_box == current->data )
- {
- continue;
- }
- cell_desc = (struct table_column_desc *) current->data;
- width = width + cell_desc->width + this->spacing;
- if(height < cell_desc->height)
- {
- height = cell_desc->height ;
- }
- }
-
-
-
- for(current=w->children; current; current=g_list_next(current))
- {
- if(current->data!= table_data->scroll_buttons.button_box)
- {
- count++;
- }
- }
-
- w->w = width;
- if(w->w + w->c.x > this->root.w)
- {
- w->w = this->root.w - w->c.x;
- }
-
-
- if(w->h + w->c.y > this->root.h )
- {
- /*
- * Do not allow the widget to exceed the screen.
- *
- */
- w->h = this->root.h- w->c.y - height;
- }
-
- if (table_data->scroll_buttons.button_box)
- {
- gui_internal_widget_pack(this,table_data->scroll_buttons.button_box);
- }
-
-
- /*
- * Deallocate column descriptions.
- */
- g_list_foreach(column_data,(GFunc)g_free,NULL);
- g_list_free(column_data);
-}
-
-
-
-
-/**
- * @brief Invalidates coordinates for previously rendered table widget rows.
- *
- * @param table_data Data from the table object.
- */
-void
-gui_internal_table_hide_rows(struct table_data * table_data)
-{
- GList*cur_row;
- for(cur_row=table_data->top_row; cur_row ; cur_row = g_list_next(cur_row))
- {
- struct widget * cur_row_widget = (struct widget*)cur_row->data;
- if (cur_row_widget->type!=widget_table_row)
- continue;
- cur_row_widget->p.x=0;
- cur_row_widget->p.y=0;
- cur_row_widget->w=0;
- cur_row_widget->h=0;
- if(cur_row==table_data->bottom_row)
- break;
- }
-}
-
-
-/**
- * @brief Renders a table widget.
- *
- * @param this The graphics context
- * @param w The table widget to render.
- */
-void
-gui_internal_table_render(struct gui_priv * this, struct widget * w)
-{
-
- int x;
- int y;
- GList * column_desc=NULL;
- GList * cur_row = NULL;
- GList * current_desc=NULL;
- struct table_data * table_data = (struct table_data*)w->data;
- int drawing_space_left=1;
- int is_first_page;
- struct table_column_desc * dim=NULL;
-
- dbg_assert(table_data);
- column_desc = gui_internal_compute_table_dimensions(this,w);
- if(!column_desc)
- return;
- y=w->p.y;
- gui_internal_table_hide_rows(table_data);
- /*
- * Skip rows that are on previous pages.
- */
- if(table_data->top_row && table_data->top_row != w->children && !table_data->scroll_buttons.button_box_hide)
- {
- cur_row = table_data->top_row;
- is_first_page=0;
- } else {
- cur_row = w->children;
- table_data->top_row=NULL;
- is_first_page=1;
- }
-
- /* First, let's mark all columns as off-screen that are in rows which are *before*
- * our current page.
- * */
- GList *row = w->children;
- while (row != cur_row) {
- struct widget * cur_row_widget = (struct widget*)row->data;
- GList * cur_column=NULL;
- if(cur_row_widget == table_data->scroll_buttons.button_box)
- {
- row = g_list_next(row);
- continue;
- }
- for(cur_column = cur_row_widget->children; cur_column;
- cur_column=g_list_next(cur_column))
- {
- struct widget * cur_widget = (struct widget*) cur_column->data;
- if(this->hide_keys){
- cur_widget->state |= STATE_INVISIBLE;
- cur_widget->state &= ~STATE_SENSITIVE;
- }else{
- cur_widget->state |= STATE_OFFSCREEN;
- }
- }
- row = g_list_next(row);
- }
-
- /*
- * Loop through each row. Drawing each cell with the proper sizes,
- * at the proper positions.
- */
- for(table_data->top_row=cur_row; cur_row; cur_row = g_list_next(cur_row))
- {
- int max_height=0, bbox_height=0;
- struct widget * cur_row_widget;
- GList * cur_column=NULL;
- current_desc = column_desc;
- cur_row_widget = (struct widget*)cur_row->data;
- x =w->p.x+this->spacing;
- if(cur_row_widget == table_data->scroll_buttons.button_box)
- {
- continue;
- }
- dim = (struct table_column_desc*)current_desc->data;
-
- if (table_data->scroll_buttons.button_box && !table_data->scroll_buttons.button_box_hide)
- bbox_height=table_data->scroll_buttons.button_box->h;
-
- if( y + dim->height + bbox_height + this->spacing >= w->p.y + w->h )
- {
- drawing_space_left=0;
- }
- for(cur_column = cur_row_widget->children; cur_column;
- cur_column=g_list_next(cur_column))
- {
- struct widget * cur_widget = (struct widget*) cur_column->data;
- if (drawing_space_left) {
- cur_widget->p.x=x;
- cur_widget->w=dim->width;
- cur_widget->p.y=y;
- cur_widget->h=dim->height;
- x=x+cur_widget->w;
- max_height = dim->height;
- /* We pack the widget before rendering to ensure that the x and y
- * coordinates get pushed down.
- */
- if(this->hide_keys){
- cur_widget->state &= ~STATE_INVISIBLE;
- cur_widget->state |= STATE_SENSITIVE;
- }else{
- cur_widget->state &= ~STATE_OFFSCREEN;
- }
- gui_internal_widget_pack(this,cur_widget);
- gui_internal_widget_render(this,cur_widget);
-
- if(dim->height > max_height)
- {
- max_height = dim->height;
- }
- } else {
- /* Deactivate contents that we don't have space for. */
- if(this->hide_keys){
- cur_widget->state |= STATE_INVISIBLE;
- cur_widget->state &= ~STATE_SENSITIVE;
- }else{
- cur_widget->state |= STATE_OFFSCREEN;
- }
- }
- }
-
- if (drawing_space_left) {
- /* Row object should have its coordinates in actual
- * state to be able to pass mouse clicks to Column objects
- */
- cur_row_widget->p.x=w->p.x;
- cur_row_widget->w=w->w;
- cur_row_widget->p.y=y;
- cur_row_widget->h=max_height;
- y = y + max_height;
- table_data->bottom_row=cur_row;
- current_desc = g_list_next(current_desc);
- }
- }
-
- /* By default, hide all scroll buttons. */
- if(this->hide_keys){
- table_data->scroll_buttons.next_button->state|= STATE_INVISIBLE;
- table_data->scroll_buttons.prev_button->state|= STATE_INVISIBLE;
- }
- table_data->scroll_buttons.next_button->state&= ~STATE_SENSITIVE;
- table_data->scroll_buttons.prev_button->state&= ~STATE_SENSITIVE;
-
- if(table_data->scroll_buttons.button_box && (!drawing_space_left || !is_first_page) && !table_data->scroll_buttons.button_box_hide )
- {
- table_data->scroll_buttons.button_box->p.y =w->p.y+w->h-table_data->scroll_buttons.button_box->h -
- this->spacing;
- if(table_data->scroll_buttons.button_box->p.y < y )
- {
- table_data->scroll_buttons.button_box->p.y=y;
- }
- table_data->scroll_buttons.button_box->p.x = w->p.x;
- table_data->scroll_buttons.button_box->w = w->w;
- gui_internal_widget_pack(this,table_data->scroll_buttons.button_box);
- if(table_data->scroll_buttons.next_button->p.y > w->p.y + w->h + table_data->scroll_buttons.next_button->h)
- {
- table_data->scroll_buttons.button_box->p.y = w->p.y + w->h -
- table_data->scroll_buttons.button_box->h;
- }
- if(!drawing_space_left)
- {
- table_data->scroll_buttons.next_button->state|= STATE_SENSITIVE;
- table_data->scroll_buttons.next_button->state&= ~STATE_INVISIBLE;
- }
-
- if(table_data->top_row != w->children)
- {
- table_data->scroll_buttons.prev_button->state|= STATE_SENSITIVE;
- table_data->scroll_buttons.prev_button->state&= ~STATE_INVISIBLE;
- }
- gui_internal_widget_render(this,table_data->scroll_buttons.button_box);
- }
-
- /*
- * Deallocate column descriptions.
- */
- g_list_foreach(column_desc,(GFunc)g_free,NULL);
- g_list_free(column_desc);
-}
-
-/**
- * @brief Handles the 'next page' table event.
- *
- * A callback function that is invoked when the 'next page' button is pressed
- * to advance the contents of a table widget.
- *
- * @param this The graphics context.
- * @param wm The button widget that was pressed.
- * @param data
- */
-void
-gui_internal_table_button_next(struct gui_priv * this, struct widget * wm, void *data)
-{
- struct widget * table_widget=NULL;
- struct table_data * table_data = NULL;
-
- if(wm)
- table_widget = (struct widget * ) wm->data;
- else
- table_widget = data;
-
- if(table_widget && table_widget->type==widget_table)
- table_data = (struct table_data*) table_widget->data;
-
- if(table_data)
- {
- GList *l=g_list_next(table_data->bottom_row);
- if(l) {
- gui_internal_table_hide_rows(table_data);
- table_data->top_row=l;
- }
- }
-
- if(wm)
- wm->state&= ~STATE_HIGHLIGHTED;
-
- gui_internal_menu_render(this);
-}
-
-
-
-/**
- * @brief Handles the 'previous page' table event.
- *
- * A callback function that is invoked when the 'previous page' button is pressed
- * to go back in the contents of a table widget.
- *
- * @param this The graphics context.
- * @param wm The button widget that was pressed.
- */
-void
-gui_internal_table_button_prev(struct gui_priv * this, struct widget * wm, void *data)
-{
- struct widget * table_widget = NULL;
- struct table_data * table_data = NULL;
-
- if(wm)
- table_widget=(struct widget * ) wm->data;
- else
- table_widget=(struct widget * ) data;
-
- if(table_widget && table_widget->type==widget_table)
- table_data = (struct table_data*) table_widget->data;
-
- if(table_data) {
- int bottomy=table_widget->p.y+table_widget->h;
- int n;
- GList *top=table_data->top_row;
- struct widget *w=(struct widget*)top->data;
- if(table_data->scroll_buttons.button_box->p.y!=0) {
- bottomy=table_data->scroll_buttons.button_box->p.y;
- }
- n=(bottomy-w->p.y)/w->h;
- while(n-- > 0 && (top=g_list_previous(top))!=NULL);
- gui_internal_table_hide_rows(table_data);
- table_data->top_row=top;
- }
- if(wm)
- wm->state&= ~STATE_HIGHLIGHTED;
- gui_internal_menu_render(this);
-}
-
-
-/**
- * @brief Deallocates a table_data structure.
- *
- * @note button_box and its children (next_button,prev_button)
- * have their memory managed by the table itself.
- *
- * @param p The table_data structure
- */
-void gui_internal_table_data_free(void * p)
-{
- g_free(p);
-}
diff --git a/navit/gui/internal/gui_internal_widget.h b/navit/gui/internal/gui_internal_widget.h
deleted file mode 100644
index 33f03e478..000000000
--- a/navit/gui/internal/gui_internal_widget.h
+++ /dev/null
@@ -1,193 +0,0 @@
-enum gui_internal_reason {
- gui_internal_reason_click=1,
- gui_internal_reason_keypress,
- gui_internal_reason_keypress_finish
-};
-
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
-struct widget {
- enum widget_type type;
- struct graphics_gc *background,*text_background;
- struct graphics_gc *foreground_frame;
- struct graphics_gc *foreground;
- char *text;
- struct graphics_image *img;
- /**
- * A function to be invoked on actions.
- * @li widget The widget that is receiving the button press.
- *
- */
- void (*func)(struct gui_priv *priv, struct widget *widget, void *data);
- enum gui_internal_reason reason;
- int datai;
- void *data;
- /**
- * @brief A function to deallocate data
- */
- void (*data_free)(void *data);
-
- /**
- * @brief a function that will be called as the widget is being destroyed.
- * This function can act as a destructor for the widget. It allows for
- * on deallocation actions to be specified on a per widget basis.
- * This function will call g_free on the widget (if required).
- */
- void (*wfree) (struct gui_priv *this_, struct widget * w);
- char *prefix;
- char *name;
- char *speech;
- char *command;
- struct pcoord c;
- struct item item;
- int selection_id;
- int state;
- struct point p;
- int wmin,hmin;
- int w,h;
- int textw,texth;
- int font_idx;
- int bl,br,bt,bb,spx,spy;
- int border;
- int packed;
- /**
- * The number of widgets to layout horizontally when doing
- * a orientation_horizontal_vertical layout
- */
- int cols;
- enum flags flags;
- int flags2;
- void *instance;
- int (*set_attr)(void *, struct attr *);
- int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
- void (*remove_cb)(void *, struct callback *cb);
- struct callback *cb;
- struct attr on;
- struct attr off;
- int deflt;
- int is_on;
- int redraw;
- struct menu_data *menu_data;
- struct form *form;
- GList *children;
- struct widget *parent;
- struct scroll_buttons *scroll_buttons;
-};
-
-struct scroll_buttons {
- /**
- * Button box should not be displayed if button_box_hide is not zero.
- */
- int button_box_hide;
- /**
- * A container box that is the child of the table widget that contains+groups
- * the next and previous button.
- */
- struct widget * button_box;
- /**
- * A button widget to handle 'next page' requests
- */
- struct widget * next_button;
- /**
- * A button widget to handle 'previous page' requests.
- */
- struct widget * prev_button;
- /**
- * a pointer to the gui context.
- * This is needed by the free function to destroy the buttons.
- */
- struct gui_priv * this;
-};
-
-/**
- * @brief A structure to store information about a table.
- *
- * The table_data widget stores pointers to extra information needed by the
- * table widget.
- *
- * The table_data structure needs to be freed with data_free along with the widget.
- *
- */
-struct table_data
-{
- /**
- * A GList pointer into a widget->children list that indicates the row
- * currently being rendered at the top of the table.
- */
- GList * top_row;
- /**
- * A Glist pointer into a widget->children list that indicates the row
- * currently being rendered at the bottom of the table.
- */
- GList * bottom_row;
-
- struct scroll_buttons scroll_buttons;
-
-};
-
-/**
- * A data structure that holds information about a column that makes up a table.
- *
- *
- */
-struct table_column_desc
-{
-
- /**
- * The computed height of a cell in the table.
- */
- int height;
-
- /**
- * The computed width of a cell in the table.
- */
- int width;
-};
-/* prototypes */
-enum flags;
-struct graphics_image;
-struct gui_priv;
-struct point;
-struct table_data;
-struct widget;
-struct widget *gui_internal_label_font_new(struct gui_priv *this, const char *text, int font);
-struct widget *gui_internal_label_new(struct gui_priv *this, const char *text);
-struct widget *gui_internal_label_new_abbrev(struct gui_priv *this, const char *text, int maxwidth);
-struct widget *gui_internal_image_new(struct gui_priv *this, struct graphics_image *image);
-struct widget *gui_internal_text_font_new(struct gui_priv *this, const char *text, int font, enum flags flags);
-struct widget *gui_internal_text_new(struct gui_priv *this, const char *text, enum flags flags);
-struct widget *gui_internal_button_font_new_with_callback(struct gui_priv *this, const char *text, int font, struct graphics_image *image, enum flags flags, void (*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
-struct widget *gui_internal_button_new_with_callback(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags, void (*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data);
-struct widget *gui_internal_button_new(struct gui_priv *this, const char *text, struct graphics_image *image, enum flags flags);
-struct widget *gui_internal_find_widget(struct widget *wi, struct point *p, int flags);
-void gui_internal_highlight_do(struct gui_priv *this, struct widget *found);
-void gui_internal_highlight(struct gui_priv *this);
-struct widget *gui_internal_box_new_with_label(struct gui_priv *this, enum flags flags, const char *label);
-struct widget *gui_internal_box_new(struct gui_priv *this, enum flags flags);
-void gui_internal_widget_reset_pack(struct gui_priv *this, struct widget *w);
-void gui_internal_widget_append(struct widget *parent, struct widget *child);
-void gui_internal_widget_prepend(struct widget *parent, struct widget *child);
-void gui_internal_widget_insert_sorted(struct widget *parent, struct widget *child, GCompareFunc func);
-void gui_internal_widget_children_destroy(struct gui_priv *this, struct widget *w);
-void gui_internal_widget_destroy(struct gui_priv *this, struct widget *w);
-void gui_internal_widget_render(struct gui_priv *this, struct widget *w);
-void gui_internal_widget_pack(struct gui_priv *this, struct widget *w);
-struct widget *gui_internal_button_label(struct gui_priv *this, const char *label, int mode);
-struct widget *gui_internal_widget_table_new(struct gui_priv *this, enum flags flags, int buttons);
-void gui_internal_widget_table_clear(struct gui_priv *this, struct widget *table);
-GList *gui_internal_widget_table_next_row(GList *row);
-GList *gui_internal_widget_table_prev_row(GList *row);
-GList *gui_internal_widget_table_first_row(GList *row);
-GList *gui_internal_widget_table_top_row(struct gui_priv *this, struct widget *table);
-GList *gui_internal_widget_table_set_top_row(struct gui_priv *this, struct widget * table, struct widget *row);
-struct widget *gui_internal_widget_table_row_new(struct gui_priv *this, enum flags flags);
-void gui_internal_table_pack(struct gui_priv *this, struct widget *w);
-void gui_internal_table_hide_rows(struct table_data *table_data);
-void gui_internal_table_render(struct gui_priv *this, struct widget *w);
-void gui_internal_table_button_next(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_table_button_prev(struct gui_priv *this, struct widget *wm, void *data);
-void gui_internal_table_data_free(void *p);
-/* end of prototypes */