2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 //##############################################################################################################
22 //# File: gui_internal.c
23 //# Description: New "internal" GUI for use with any graphics library
24 //# Comment: Trying to make a touchscreen friendly GUI
25 //# Authors: Martin Schaller (04/2008), Stefan Klumpp (04/2008)
27 //##############################################################################################################
40 #include "navit_nls.h"
47 #include "transform.h"
53 #include "vehicleprofile.h"
64 #include "navit_nls.h"
65 #include "navigation.h"
66 #include "gui_internal.h"
71 struct widget *search_list;
72 struct widget *keyboard;
73 struct widget *button_bar;
75 void (*redisplay)(struct gui_priv *priv, struct widget *widget, void *data);
76 struct widget *redisplay_widget;
79 //##############################################################################################################
82 //# Authors: Martin Schaller (04/2008)
83 //##############################################################################################################
85 enum widget_type type;
86 struct graphics_gc *background,*text_background;
87 struct graphics_gc *foreground_frame;
88 struct graphics_gc *foreground;
90 struct graphics_image *img;
92 * A function to be invoked on actions.
93 * @li widget The widget that is receiving the button press.
96 void (*func)(struct gui_priv *priv, struct widget *widget, void *data);
101 * @brief A function to deallocate data
103 void (*data_free)(void *data);
106 * @brief a function that will be called as the widget is being destroyed.
107 * This function can act as a destructor for the widget. It allows for
108 * on deallocation actions to be specified on a per widget basis.
109 * This function will call g_free on the widget (if required).
111 void (*free) (struct gui_priv *this_, struct widget * w);
123 int bl,br,bt,bb,spx,spy;
126 * The number of widgets to layout horizontally when doing
127 * a orientation_horizontal_vertical layout
132 int (*set_attr)(void *, struct attr *);
133 int (*get_attr)(void *, enum attr_type, struct attr *, struct attr_iter *);
134 void (*remove_cb)(void *, struct callback *cb);
141 struct menu_data *menu_data;
146 * @brief A structure to store configuration values.
148 * This structure stores configuration values for how gui elements in the internal GUI
151 struct gui_config_settings {
154 * The base size (in fractions of a point) to use for text.
158 * The size (in pixels) that xs style icons should be scaled to.
162 * The size (in pixels) that s style icons (small) should be scaled to
166 * The size (in pixels) that l style icons should be scaled to
170 * The default amount of spacing (in pixels) to place between GUI elements.
177 * Indexes into the config_profiles array.
179 const int LARGE_PROFILE=0;
180 const int MEDIUM_PROFILE=1;
181 const int SMALL_PROFILE=2;
184 * The default config profiles.
186 * [0] => LARGE_PROFILE (screens 640 in one dimension)
187 * [1] => MEDIUM PROFILE (screens larger than 320 in one dimension
188 * [2] => Small profile (default)
190 static struct gui_config_settings config_profiles[]={
197 struct widget * route_table;
202 //##############################################################################################################
205 //# Authors: Martin Schaller (04/2008)
206 //##############################################################################################################
210 struct graphics *gra;
211 struct graphics_gc *background;
212 struct graphics_gc *background2;
213 struct graphics_gc *highlight_background;
214 struct graphics_gc *foreground;
215 struct graphics_gc *text_foreground;
216 struct graphics_gc *text_background;
217 struct color background_color, background2_color, text_foreground_color, text_background_color;
221 struct graphics_font *font;
222 int icon_xs, icon_s, icon_l;
224 struct widget *widgets;
228 struct widget *highlighted;
229 struct widget *highlighted_menu;
230 int clickp_valid, vehicle_valid;
231 struct pcoord clickp, vehiclep;
232 struct search_list *sl;
234 int menu_on_map_click;
239 * The setting information read from the configuration file.
240 * values of -1 indicate no value was specified in the config file.
242 struct gui_config_settings config;
243 struct event_idle *idle;
244 struct callback *motion_cb,*button_cb,*resize_cb,*keypress_cb,*idle_cb, *motion_timeout_callback;
245 struct event_timeout *motion_timeout_event;
246 struct point current;
248 struct callback * vehicle_cb;
250 * Stores information about the route.
252 struct route_data route_data;
254 struct gui_internal_data data;
255 struct callback_list *cbl;
258 struct attr osd_configuration;
264 * @brief A structure to store information about a table.
266 * The table_data widget stores pointers to extra information needed by the
269 * The table_data structure needs to be freed with data_free along with the widget.
275 * A GList pointer into a widget->children list that indicates the row
276 * currently being rendered at the top of the table.
280 * A Glist pointer into a widget->children list that indicates the row
281 * currently being rendered at the bottom of the table.
286 * A list of table_row widgets that mark the
287 * top rows for each page of the table.
288 * This is needed for the 'previous page' function of the table.
290 GList * page_headers;
293 * A container box that is the child of the table widget that contains+groups
294 * the next and previous button.
296 struct widget * button_box;
299 * A button widget to handle 'next page' requests
301 struct widget * next_button;
303 * A button widget to handle 'previous page' requests.
305 struct widget * prev_button;
309 * a pointer to the gui context.
310 * This is needed by the free function to destory the buttons.
312 struct gui_priv * this;
316 * A data structure that holds information about a column that makes up a table.
320 struct table_column_desc
324 * The computed height of a cell in the table.
329 * The computed width of a cell in the table.
335 static void gui_internal_widget_render(struct gui_priv *this, struct widget *w);
336 static void gui_internal_widget_pack(struct gui_priv *this, struct widget *w);
337 static struct widget * gui_internal_box_new(struct gui_priv *this, enum flags flags);
338 static void gui_internal_widget_append(struct widget *parent, struct widget *child);
339 static void gui_internal_widget_destroy(struct gui_priv *this, struct widget *w);
340 static void gui_internal_apply_config(struct gui_priv *this);
342 static struct widget* gui_internal_widget_table_new(struct gui_priv * this, enum flags flags, int buttons);
343 static struct widget * gui_internal_widget_table_row_new(struct gui_priv * this, enum flags flags);
344 static void gui_internal_table_render(struct gui_priv * this, struct widget * w);
345 static void gui_internal_cmd_route(struct gui_priv * this, struct widget * w,void *);
346 static void gui_internal_table_pack(struct gui_priv * this, struct widget * w);
347 static void gui_internal_table_button_next(struct gui_priv * this, struct widget * wm, void *data);
348 static void gui_internal_table_button_prev(struct gui_priv * this, struct widget * wm, void *data);
349 static void gui_internal_widget_table_clear(struct gui_priv * this,struct widget * table);
350 static struct widget * gui_internal_widget_table_row_new(struct gui_priv * this, enum flags flags);
351 static void gui_internal_table_data_free(void * d);
352 static void gui_internal_route_update(struct gui_priv * this, struct navit * navit,
354 static void gui_internal_route_screen_free(struct gui_priv * this_,struct widget * w);
355 static void gui_internal_populate_route_table(struct gui_priv * this,
356 struct navit * navit);
357 static void gui_internal_search_idle_end(struct gui_priv *this);
358 static void gui_internal_search(struct gui_priv *this, char *what, char *type, int flags);
359 static void gui_internal_search_house_number(struct gui_priv *this, struct widget *widget, void *data);
360 static void gui_internal_search_house_number_in_street(struct gui_priv *this, struct widget *widget, void *data);
361 static void gui_internal_search_street(struct gui_priv *this, struct widget *widget, void *data);
362 static void gui_internal_search_street_in_town(struct gui_priv *this, struct widget *widget, void *data);
363 static void gui_internal_search_town(struct gui_priv *this, struct widget *wm, void *data);
364 static void gui_internal_search_town_in_country(struct gui_priv *this, struct widget *wm);
365 static void gui_internal_search_country(struct gui_priv *this, struct widget *widget, void *data);
366 static void gui_internal_check_exit(struct gui_priv *this);
367 static void gui_internal_cmd_view_in_browser(struct gui_priv *this, struct widget *wm, void *data);
369 static struct widget *gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode);
370 static struct menu_data * gui_internal_menu_data(struct gui_priv *this);
372 static int gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle *vehicle);
375 * * Display image scaled to specific size
376 * * searches for scaleable and pre-scaled image
377 * * @param this Our gui context
378 * * @param name image name
379 * * @param w desired width of image
380 * * @param h desired height of image
381 * * @returns image_struct Ptr to scaled image struct or NULL if not scaled or found
383 static struct graphics_image *
384 image_new_scaled(struct gui_priv *this, char *name, int w, int h)
386 struct graphics_image *ret=NULL;
387 char *full_name=NULL;
388 char *full_path=NULL;
391 for (i = 1 ; i < 6 ; i++) {
395 full_name=g_strdup_printf("%s.svg", name);
398 full_name=g_strdup_printf("%s.svgz", name);
401 if (w != -1 && h != -1) {
402 full_name=g_strdup_printf("%s_%d_%d.png", name, w, h);
406 full_name=g_strdup_printf("%s.png", name);
409 full_name=g_strdup_printf("%s.xpm", name);
412 dbg(1,"trying '%s'\n", full_name);
416 /* needs to be checked in the driver */
417 if (!file_exists(full_name)) {
422 full_path=graphics_icon_path(full_name);
423 ret=graphics_image_new_scaled(this->gra, full_path, w, h);
424 dbg(1,"ret=%p\n", ret);
430 dbg(0,"failed to load %s with %d,%d\n", name, w, h);
435 static struct graphics_image *
436 image_new_o(struct gui_priv *this, char *name)
438 return image_new_scaled(this, name, -1, -1);
442 static struct graphics_image *
443 image_new_xs(struct gui_priv *this, char *name)
445 return image_new_scaled(this, name, this->icon_xs, this->icon_xs);
449 static struct graphics_image *
450 image_new_s(struct gui_priv *this, char *name)
452 return image_new_scaled(this, name, this->icon_s, this->icon_s);
455 static struct graphics_image *
456 image_new_l(struct gui_priv *this, char *name)
458 return image_new_scaled(this, name, this->icon_l, this->icon_l);
462 coordinates(struct pcoord *pc, char sep)
464 char latc='N',lngc='E';
465 int lat_deg,lat_min,lat_sec;
466 int lng_deg,lng_min,lng_sec;
471 transform_to_geo(pc->pro, &c, &g);
482 lat_min=fmod(g.lat*60,60);
483 lat_sec=fmod(g.lat*3600,60);
485 lng_min=fmod(g.lng*60,60);
486 lng_sec=fmod(g.lng*3600,60);
487 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);
491 gui_internal_background_render(struct gui_priv *this, struct widget *w)
493 struct point pnt=w->p;
494 if (w->state & STATE_HIGHLIGHTED)
495 graphics_draw_rectangle(this->gra, this->highlight_background, &pnt, w->w, w->h);
498 graphics_draw_rectangle(this->gra, w->background, &pnt, w->w, w->h);
501 static struct widget *
502 gui_internal_label_new(struct gui_priv *this, char *text)
508 struct widget *widget=g_new0(struct widget, 1);
509 widget->type=widget_label;
511 widget->text=g_strdup(text);
512 graphics_get_text_bbox(this->gra, this->font, text, 0x10000, 0x0, p, 0);
516 widget->h=h+this->spacing;
518 widget->w=w+this->spacing;
520 widget->flags=gravity_center;
521 widget->foreground=this->text_foreground;
522 widget->text_background=this->text_background;
527 static struct widget *
528 gui_internal_label_new_abbrev(struct gui_priv *this, char *text, int maxwidth)
530 struct widget *ret=NULL;
531 char *tmp=g_malloc(strlen(text)+3);
538 ret=gui_internal_label_new(this, tmp);
539 if (ret->w < maxwidth)
541 gui_internal_widget_destroy(this, ret);
549 static struct widget *
550 gui_internal_image_new(struct gui_priv *this, struct graphics_image *image)
552 struct widget *widget=g_new0(struct widget, 1);
553 widget->type=widget_image;
556 widget->w=image->width;
557 widget->h=image->height;
563 gui_internal_image_render(struct gui_priv *this, struct widget *w)
567 gui_internal_background_render(this, w);
570 pnt.x+=w->w/2-w->img->hot.x;
571 pnt.y+=w->h/2-w->img->hot.y;
572 graphics_draw_image(this->gra, this->foreground, &pnt, w->img);
577 gui_internal_label_render(struct gui_priv *this, struct widget *w)
579 struct point pnt=w->p;
580 gui_internal_background_render(this, w);
582 if (w->flags & gravity_right) {
583 pnt.y+=w->h-this->spacing;
584 pnt.x+=w->w-w->textw-this->spacing;
585 graphics_draw_text(this->gra, w->foreground, w->text_background, this->font, w->text, &pnt, 0x10000, 0x0);
587 pnt.y+=w->h-this->spacing;
588 graphics_draw_text(this->gra, w->foreground, w->text_background, this->font, w->text, &pnt, 0x10000, 0x0);
594 * @brief A text box is a widget that renders a text string containing newlines.
595 * The string will be broken up into label widgets at each newline with a vertical layout.
598 static struct widget *
599 gui_internal_text_new(struct gui_priv *this, char *text, enum flags flags)
601 char *s=g_strdup(text),*s2,*tok;
602 struct widget *ret=gui_internal_box_new(this, flags);
604 while ((tok=strtok(s2,"\n"))) {
605 gui_internal_widget_append(ret, gui_internal_label_new(this, tok));
608 gui_internal_widget_pack(this,ret);
613 static struct widget *
614 gui_internal_button_new_with_callback(struct gui_priv *this, char *text, struct graphics_image *image, enum flags flags, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data)
616 struct widget *ret=NULL;
617 ret=gui_internal_box_new(this, flags);
620 gui_internal_widget_append(ret, gui_internal_image_new(this, image));
622 gui_internal_widget_append(ret, gui_internal_text_new(this, text, gravity_center|orientation_vertical));
626 ret->state |= STATE_SENSITIVE;
627 ret->speech=g_strdup(text);
635 gui_internal_button_attr_update(struct gui_priv *this, struct widget *w)
642 if (w->get_attr(w->instance, w->on.type, &curr, NULL))
643 is_on=curr.u.data == w->on.u.data;
646 if (is_on != w->is_on) {
650 l=g_list_first(w->children);
654 graphics_image_free(this->gra, wi->img);
655 wi->img=image_new_xs(this, is_on ? "gui_active" : "gui_inactive");
657 if (w->is_on && w->off.type == attr_none)
658 w->state &= ~STATE_SENSITIVE;
660 w->state |= STATE_SENSITIVE;
667 gui_internal_button_attr_callback(struct gui_priv *this, struct widget *w)
669 if (gui_internal_button_attr_update(this, w))
670 gui_internal_widget_render(this, w);
673 gui_internal_button_attr_pressed(struct gui_priv *this, struct widget *w, void *data)
676 w->set_attr(w->instance, &w->off);
678 w->set_attr(w->instance, &w->on);
679 gui_internal_button_attr_update(this, w);
683 static struct widget *
684 gui_internal_button_navit_attr_new(struct gui_priv *this, char *text, enum flags flags, struct attr *on, struct attr *off)
686 struct graphics_image *image=NULL;
690 image=image_new_xs(this, "gui_inactive");
691 ret=gui_internal_button_new_with_callback(this, text, image, flags, gui_internal_button_attr_pressed, NULL);
696 ret->get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))navit_get_attr;
697 ret->set_attr=(int (*)(void *, struct attr *))navit_set_attr;
698 ret->remove_cb=(void (*)(void *, struct callback *))navit_remove_callback;
699 ret->instance=this->nav;
700 ret->cb=callback_new_attr_2(callback_cast(gui_internal_button_attr_callback), on?on->type:off->type, this, ret);
701 navit_add_callback(this->nav, ret->cb);
702 gui_internal_button_attr_update(this, ret);
706 static struct widget *
707 gui_internal_button_map_attr_new(struct gui_priv *this, char *text, enum flags flags, struct map *map, struct attr *on, struct attr *off, int deflt)
709 struct graphics_image *image=NULL;
711 image=image_new_xs(this, "gui_inactive");
714 ret=gui_internal_button_new_with_callback(this, text, image, flags, gui_internal_button_attr_pressed, NULL);
720 ret->get_attr=(int (*)(void *, enum attr_type, struct attr *, struct attr_iter *))map_get_attr;
721 ret->set_attr=(int (*)(void *, struct attr *))map_set_attr;
722 ret->remove_cb=(void (*)(void *, struct callback *))map_remove_callback;
725 ret->cb=callback_new_attr_2(callback_cast(gui_internal_button_attr_callback), on?on->type:off->type, this, ret);
726 map_add_callback(map, ret->cb);
727 gui_internal_button_attr_update(this, ret);
731 static struct widget *
732 gui_internal_button_new(struct gui_priv *this, char *text, struct graphics_image *image, enum flags flags)
734 return gui_internal_button_new_with_callback(this, text, image, flags, NULL, NULL);
738 //##############################################################################################################
741 //# Authors: Martin Schaller (04/2008)
742 //##############################################################################################################
743 static void gui_internal_clear(struct gui_priv *this)
745 struct graphics *gra=this->gra;
749 graphics_draw_rectangle(gra, this->background, &pnt, this->root.w, this->root.h);
753 static struct widget *
754 gui_internal_find_widget(struct widget *wi, struct point *p, int flags)
756 struct widget *ret,*child;
757 GList *l=wi->children;
764 if ( wi->p.x + wi->w < p->x)
766 if ( wi->p.y + wi->h < p->y)
769 if (wi->state & flags)
773 ret=gui_internal_find_widget(child, p, flags);
784 gui_internal_highlight_do(struct gui_priv *this, struct widget *found)
786 if (found == this->highlighted)
789 graphics_draw_mode(this->gra, draw_mode_begin);
790 if (this->highlighted) {
791 this->highlighted->state &= ~STATE_HIGHLIGHTED;
792 if (this->root.children && this->highlighted_menu == g_list_last(this->root.children)->data)
793 gui_internal_widget_render(this, this->highlighted);
794 this->highlighted=NULL;
795 this->highlighted_menu=NULL;
798 this->highlighted=found;
799 this->highlighted_menu=g_list_last(this->root.children)->data;
800 this->highlighted->state |= STATE_HIGHLIGHTED;
801 gui_internal_widget_render(this, this->highlighted);
802 dbg(1,"%d,%d %dx%d\n", found->p.x, found->p.y, found->w, found->h);
804 graphics_draw_mode(this->gra, draw_mode_end);
806 //##############################################################################################################
809 //# Authors: Martin Schaller (04/2008)
810 //##############################################################################################################
811 static void gui_internal_highlight(struct gui_priv *this)
813 struct widget *menu,*found=NULL;
814 if (this->current.x > -1 && this->current.y > -1) {
815 menu=g_list_last(this->root.children)->data;
816 found=gui_internal_find_widget(menu, &this->current, STATE_SENSITIVE);
818 gui_internal_highlight_do(this, found);
819 this->motion_timeout_event=NULL;
822 static struct widget *
823 gui_internal_box_new_with_label(struct gui_priv *this, enum flags flags, char *label)
825 struct widget *widget=g_new0(struct widget, 1);
828 widget->text=g_strdup(label);
829 widget->type=widget_box;
834 static struct widget *
835 gui_internal_box_new(struct gui_priv *this, enum flags flags)
837 return gui_internal_box_new_with_label(this, flags, NULL);
841 static void gui_internal_box_render(struct gui_priv *this, struct widget *w)
846 gui_internal_background_render(this, w);
848 if (w->foreground && w->border) {
851 pnt[1].x=pnt[0].x+w->w;
853 pnt[2].x=pnt[0].x+w->w;
854 pnt[2].y=pnt[0].y+w->h;
856 pnt[3].y=pnt[0].y+w->h;
858 graphics_gc_set_linewidth(w->foreground, w->border ? w->border : 1);
859 graphics_draw_lines(this->gra, w->foreground, pnt, 5);
860 graphics_gc_set_linewidth(w->foreground, 1);
867 gui_internal_widget_render(this, wc);
874 * @brief Compute the size and location for the widget.
878 static void gui_internal_box_pack(struct gui_priv *this, struct widget *w)
881 int x0,x=0,y=0,width=0,height=0,owidth=0,oheight=0,expand=0,count=0,rows=0,cols=w->cols ? w->cols : 0;
883 int orientation=w->flags & 0xffff0000;
888 if ( this->root.w > this->root.h )
898 * count the number of children
905 if (orientation == orientation_horizontal_vertical && count <= cols)
906 orientation=orientation_horizontal;
907 switch (orientation) {
908 case orientation_horizontal:
910 * For horizontal orientation:
911 * pack each child and find the largest height and
912 * compute the total width. x spacing (spx) is considered
914 * If any children want to be expanded
915 * we keep track of this
920 gui_internal_widget_pack(this, wc);
924 if (wc->flags & flags_expand)
925 expand+=wc->w ? wc->w : 1;
931 if (expand && w->w) {
932 expand=100*(w->w-width+expand)/expand;
937 case orientation_vertical:
939 * For vertical layouts:
940 * We pack each child and compute the largest width and
941 * the total height. y spacing (spy) is considered
943 * If the expand flag is set then teh expansion amount
949 gui_internal_widget_pack(this, wc);
953 if (wc->flags & flags_expand)
954 expand+=wc->h ? wc->h : 1;
960 if (expand && w->h) {
961 expand=100*(w->h-height+expand)/expand;
966 case orientation_horizontal_vertical:
968 * For horizontal_vertical orientation
970 * Compute the largest height and largest width.
971 * Layout the widgets based on having the
972 * number of columns specified by (cols)
978 gui_internal_widget_pack(this, wc);
988 rows=(count+cols-1)/cols;
991 width+=w->spx*(cols-1);
992 height+=w->spy*(rows-1);
999 * No orientation was specified.
1000 * width and height are both 0.
1001 * The width & height of this widget
1005 dbg(0,"Warning width and height of a widget are 0");
1008 if (! w->w && ! w->h) {
1009 w->w=w->bl+w->br+width;
1010 w->h=w->bt+w->bb+height;
1016 * At this stage the width and height of this
1017 * widget has been computed.
1018 * We now make a second pass assigning heights,
1019 * widths and coordinates to each child widget.
1022 if (w->flags & gravity_left)
1024 if (w->flags & gravity_xcenter)
1025 x=w->p.x+w->w/2-owidth/2;
1026 if (w->flags & gravity_right)
1027 x=w->p.x+w->w-w->br-owidth;
1028 if (w->flags & gravity_top)
1030 if (w->flags & gravity_ycenter)
1031 y=w->p.y+w->h/2-oheight/2;
1032 if (w->flags & gravity_bottom)
1033 y=w->p.y+w->h-w->bb-oheight;
1035 switch (orientation) {
1036 case orientation_horizontal:
1041 if (wc->flags & flags_fill)
1043 if (wc->flags & flags_expand) {
1046 wc->w=wc->w*expand/100;
1048 if (w->flags & gravity_top)
1050 if (w->flags & gravity_ycenter)
1052 if (w->flags & gravity_bottom)
1058 case orientation_vertical:
1063 if (wc->flags & flags_fill)
1065 if (wc->flags & flags_expand) {
1068 wc->h=wc->h*expand/100;
1070 if (w->flags & gravity_left)
1072 if (w->flags & gravity_xcenter)
1074 if (w->flags & gravity_right)
1080 case orientation_horizontal_vertical:
1090 if (wc->flags & flags_fill) {
1094 if (w->flags & gravity_left)
1096 if (w->flags & gravity_xcenter)
1097 wc->p.x=x+(width-wc->w)/2;
1098 if (w->flags & gravity_right)
1099 wc->p.x=x+width-wc->w;
1100 if (w->flags & gravity_top)
1102 if (w->flags & gravity_ycenter)
1103 wc->p.y=y+(height-wc->h)/2;
1104 if (w->flags & gravity_bottom)
1105 wc->p.y=y-height-wc->h;
1107 if (++count == cols) {
1119 * Call pack again on each child,
1120 * the child has now had its size and coordinates
1121 * set so they can repack their children.
1126 gui_internal_widget_pack(this, wc);
1132 gui_internal_widget_append(struct widget *parent, struct widget *child)
1136 if (! child->background)
1137 child->background=parent->background;
1138 parent->children=g_list_append(parent->children, child);
1141 static void gui_internal_widget_prepend(struct widget *parent, struct widget *child)
1143 if (! child->background)
1144 child->background=parent->background;
1145 parent->children=g_list_prepend(parent->children, child);
1148 static void gui_internal_widget_children_destroy(struct gui_priv *this, struct widget *w)
1156 gui_internal_widget_destroy(this, wc);
1159 g_list_free(w->children);
1163 static void gui_internal_widget_destroy(struct gui_priv *this, struct widget *w)
1165 gui_internal_widget_children_destroy(this, w);
1169 graphics_image_free(this->gra, w->img);
1175 w->data_free(w->data);
1176 if (w->cb && w->remove_cb)
1177 w->remove_cb(w->instance, w->cb);
1186 gui_internal_widget_render(struct gui_priv *this, struct widget *w)
1188 if(w->p.x > this->root.w || w->p.y > this->root.h)
1193 gui_internal_box_render(this, w);
1196 gui_internal_label_render(this, w);
1199 gui_internal_image_render(this, w);
1202 gui_internal_table_render(this,w);
1210 gui_internal_widget_pack(struct gui_priv *this, struct widget *w)
1214 gui_internal_box_pack(this, w);
1217 gui_internal_table_pack(this,w);
1223 //##############################################################################################################
1226 //# Authors: Martin Schaller (04/2008)
1227 //##############################################################################################################
1228 static void gui_internal_call_highlighted(struct gui_priv *this)
1230 if (! this->highlighted || ! this->highlighted->func)
1232 this->highlighted->reason=1;
1233 this->highlighted->func(this, this->highlighted, this->highlighted->data);
1237 gui_internal_say(struct gui_priv *this, struct widget *w, int questionmark)
1239 char *text=w->speech;
1247 text=g_strdup_printf("%s%c", text, questionmark ? '?':'\0');
1248 navit_say(this->nav, text);
1254 gui_internal_prune_menu(struct gui_priv *this, struct widget *w)
1258 gui_internal_search_idle_end(this);
1259 while ((l = g_list_last(this->root.children))) {
1261 void (*redisplay)(struct gui_priv *priv, struct widget *widget, void *data);
1262 gui_internal_say(this, w, 0);
1263 redisplay=w->menu_data->redisplay;
1264 wr=w->menu_data->redisplay_widget;
1265 if (!w->menu_data->redisplay) {
1266 gui_internal_widget_render(this, w);
1269 gui_internal_widget_destroy(this, l->data);
1270 this->root.children=g_list_remove(this->root.children, l->data);
1271 redisplay(this, wr, wr->data);
1274 gui_internal_widget_destroy(this, l->data);
1275 this->root.children=g_list_remove(this->root.children, l->data);
1280 gui_internal_prune_menu_count(struct gui_priv *this, int count, int render)
1283 gui_internal_search_idle_end(this);
1284 while ((l = g_list_last(this->root.children)) && count-- > 0) {
1285 gui_internal_widget_destroy(this, l->data);
1286 this->root.children=g_list_remove(this->root.children, l->data);
1289 gui_internal_say(this, l->data, 0);
1290 gui_internal_widget_render(this, l->data);
1295 gui_internal_back(struct gui_priv *this, struct widget *w, void *data)
1297 gui_internal_prune_menu_count(this, 1, 1);
1301 gui_internal_cmd_return(struct gui_priv *this, struct widget *wm, void *data)
1303 gui_internal_prune_menu(this, wm->data);
1307 gui_internal_cmd_main_menu(struct gui_priv *this, struct widget *wm, void *data)
1309 gui_internal_prune_menu(this, this->root.children->data);
1312 static struct widget *
1313 gui_internal_top_bar(struct gui_priv *this)
1315 struct widget *w,*wm,*wh,*wc,*wcn;
1316 int dots_len, sep_len;
1318 int width,width_used=0,use_sep=0,incomplete=0;
1319 struct graphics_gc *foreground=(this->flags & 256 ? this->background : this->text_foreground);
1321 1:Don't expand bar to screen width
1322 2:Don't show Map Icon
1323 4:Don't show Home Icon
1324 8:Show only current menu
1325 16:Don't use menu titles as button
1326 32:Show navit version
1329 256:Use background for menu headline
1330 512:Set osd_configuration and zoom to route when setting position
1333 w=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|(this->flags & 1 ? 0:flags_fill));
1334 w->bl=this->spacing;
1335 w->spx=this->spacing;
1336 w->background=this->background2;
1337 if ((this->flags & 6) == 6) {
1343 width=this->root.w-w->bl;
1344 if (! (this->flags & 2)) {
1345 wm=gui_internal_button_new_with_callback(this, NULL,
1346 image_new_s(this, "gui_map"), gravity_center|orientation_vertical,
1347 gui_internal_cmd_return, NULL);
1348 wm->speech=g_strdup(_("Back to map"));
1349 gui_internal_widget_pack(this, wm);
1350 gui_internal_widget_append(w, wm);
1353 if (! (this->flags & 4)) {
1354 wh=gui_internal_button_new_with_callback(this, NULL,
1355 image_new_s(this, "gui_home"), gravity_center|orientation_vertical,
1356 gui_internal_cmd_main_menu, NULL);
1357 wh->speech=g_strdup(_("Main Menu"));
1358 gui_internal_widget_pack(this, wh);
1359 gui_internal_widget_append(w, wh);
1362 if (!(this->flags & 6))
1364 l=g_list_last(this->root.children);
1365 wcn=gui_internal_label_new(this,".. »");
1366 wcn->foreground=foreground;
1368 gui_internal_widget_destroy(this, wcn);
1369 wcn=gui_internal_label_new(this,"»");
1370 wcn->foreground=foreground;
1372 gui_internal_widget_destroy(this, wcn);
1374 if (g_list_previous(l) || !g_list_next(l)) {
1376 wcn=gui_internal_label_new(this, wc->text);
1377 wcn->foreground=foreground;
1382 dbg(1,"%d (%s) + %d + %d + %d > %d\n", wcn->w, wc->text, width_used, w->spx, use_sep ? sep_len : 0, width);
1383 if (wcn->w + width_used + w->spx + (use_sep ? sep_len : 0) + (g_list_previous(l) ? dots_len : 0) > width) {
1385 gui_internal_widget_destroy(this, wcn);
1389 struct widget *wct=gui_internal_label_new(this, "»");
1390 wct->foreground=foreground;
1391 res=g_list_prepend(res, wct);
1392 width_used+=sep_len+w->spx;
1395 if (!(this->flags & 16)) {
1396 wcn->func=gui_internal_cmd_return;
1398 wcn->state |= STATE_SENSITIVE;
1400 res=g_list_prepend(res, wcn);
1401 if (this->flags & 8)
1404 l=g_list_previous(l);
1408 wcn=gui_internal_label_new_abbrev(this, wc->text, width-width_used-w->spx-dots_len);
1409 wcn->foreground=foreground;
1410 wcn->func=gui_internal_cmd_return;
1412 wcn->state |= STATE_SENSITIVE;
1413 res=g_list_prepend(res, wcn);
1414 l=g_list_previous(l);
1417 wcn=gui_internal_label_new(this, ".. »");
1418 wcn->foreground=foreground;
1419 wcn->func=gui_internal_cmd_return;
1421 wcn->state |= STATE_SENSITIVE;
1422 res=g_list_prepend(res, wcn);
1426 gui_internal_widget_append(w, l->data);
1429 if (this->flags & 32) {
1430 extern char *version;
1431 char *version_text=g_strdup_printf("Navit %s",version);
1432 wcn=gui_internal_label_new(this, version_text);
1433 g_free(version_text);
1434 wcn->flags=gravity_right_center|flags_expand;
1435 gui_internal_widget_append(w, wcn);
1439 gui_internal_widget_destroy(this, dots);
1444 static struct widget *
1445 gui_internal_time_help(struct gui_priv *this)
1447 struct widget *w,*wc,*wcn;
1452 w=gui_internal_box_new(this, gravity_right_center|orientation_horizontal|flags_fill);
1453 w->bl=this->spacing;
1454 w->spx=this->spacing;
1460 if (this->flags & 64) {
1461 wc=gui_internal_box_new(this, gravity_right_top|orientation_vertical|flags_fill);
1467 tm=localtime(&timep);
1468 strftime(timestr, 64, "%H:%M %d.%m.%Y", tm);
1469 wcn=gui_internal_label_new(this, timestr);
1470 gui_internal_widget_append(wc, wcn);
1471 gui_internal_widget_append(w, wc);
1473 if (this->flags & 128) {
1474 wcn=gui_internal_button_new_with_callback(this, _("Help"), image_new_l(this, "gui_help"), gravity_center|orientation_vertical|flags_fill, NULL, NULL);
1475 gui_internal_widget_append(w, wcn);
1482 * Applys the configuration values to this based on the settings
1483 * specified in the configuration file (this->config) and
1484 * the most approriate default profile based on screen resolution.
1486 * This function should be run after this->root is setup and could
1487 * be rerun after the window is resized.
1489 * @authors Steve Singer <ssinger_pg@sympatico.ca> (09/2008)
1491 static void gui_internal_apply_config(struct gui_priv *this)
1493 struct gui_config_settings * current_config=0;
1495 dbg(0,"w=%d h=%d\n", this->root.w, this->root.h);
1497 * Select default values from profile based on the screen.
1499 if((this->root.w > 320 || this->root.h > 320) && this->root.w > 240 && this->root.h > 240)
1501 if((this->root.w > 640 || this->root.h > 640) && this->root.w > 480 && this->root.h > 480 )
1503 current_config = &config_profiles[LARGE_PROFILE];
1507 current_config = &config_profiles[MEDIUM_PROFILE];
1512 current_config = &config_profiles[SMALL_PROFILE];
1516 * Apply override values from config file
1518 if(this->config.font_size == -1 )
1520 this->font_size = current_config->font_size;
1524 this->font_size = this->config.font_size;
1527 if(this->config.icon_xs == -1 )
1529 this->icon_xs = current_config->icon_xs;
1533 this->icon_xs = this->config.icon_xs;
1536 if(this->config.icon_s == -1 )
1538 this->icon_s = current_config->icon_s;
1542 this->icon_s = this->config.icon_s;
1544 if(this->config.icon_l == -1 )
1546 this->icon_l = current_config->icon_l;
1550 this->icon_l = this->config.icon_l;
1552 if(this->config.spacing == -1 )
1554 this->spacing = current_config->spacing;
1558 this->spacing = current_config->spacing;
1563 static struct widget *
1564 gui_internal_button_label(struct gui_priv *this, char *label, int mode)
1566 struct widget *wl,*wlb;
1567 struct widget *wb=gui_internal_menu_data(this)->button_bar;
1568 wlb=gui_internal_box_new(this, gravity_right_center|orientation_vertical);
1569 wl=gui_internal_label_new(this, label);
1571 wlb->foreground=this->text_foreground;
1576 gui_internal_widget_append(wlb, wl);
1578 gui_internal_widget_prepend(wb, wlb);
1580 gui_internal_widget_append(wb, wlb);
1586 static struct widget *
1587 gui_internal_menu(struct gui_priv *this, char *label)
1589 struct widget *menu,*w,*w1,*topbox;
1591 gui_internal_search_idle_end(this);
1592 topbox=gui_internal_box_new_with_label(this, 0, label);
1593 topbox->w=this->root.w;
1594 topbox->h=this->root.h;
1595 gui_internal_widget_append(&this->root, topbox);
1596 menu=gui_internal_box_new(this, gravity_left_center|orientation_vertical);
1597 menu->w=this->root.w;
1598 menu->h=this->root.h;
1599 menu->background=this->background;
1600 gui_internal_apply_config(this);
1601 this->font=graphics_font_new(this->gra,this->font_size,1);
1602 topbox->menu_data=g_new0(struct menu_data, 1);
1603 gui_internal_widget_append(topbox, menu);
1604 w=gui_internal_top_bar(this);
1605 gui_internal_widget_append(menu, w);
1606 w=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
1607 w->spx=4*this->spacing;
1609 gui_internal_widget_append(menu, w);
1610 if (this->flags & 16) {
1611 struct widget *wlb,*wb,*wm=w;
1612 wm->flags=gravity_center|orientation_vertical|flags_expand|flags_fill;
1613 w=gui_internal_box_new(this, gravity_center|orientation_horizontal|flags_expand|flags_fill);
1614 dbg(0,"topbox->menu_data=%p\n", topbox->menu_data);
1615 gui_internal_widget_append(wm, w);
1616 wb=gui_internal_box_new(this, gravity_right_center|orientation_horizontal|flags_fill);
1622 topbox->menu_data->button_bar=wb;
1623 gui_internal_widget_append(wm, wb);
1624 wlb=gui_internal_button_label(this,_("Back"),1);
1625 wlb->func=gui_internal_back;
1626 wlb->state |= STATE_SENSITIVE;
1628 if (this->flags & 192) {
1629 menu=gui_internal_box_new(this, gravity_left_center|orientation_vertical);
1630 menu->w=this->root.w;
1631 menu->h=this->root.h;
1632 w1=gui_internal_time_help(this);
1633 gui_internal_widget_append(menu, w1);
1634 w1=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_expand|flags_fill);
1635 gui_internal_widget_append(menu, w1);
1636 gui_internal_widget_append(topbox, menu);
1637 menu->background=NULL;
1642 static struct menu_data *
1643 gui_internal_menu_data(struct gui_priv *this)
1646 struct widget *menu;
1648 l=g_list_last(this->root.children);
1650 return menu->menu_data;
1654 gui_internal_menu_render(struct gui_priv *this)
1657 struct widget *menu;
1659 l=g_list_last(this->root.children);
1661 gui_internal_say(this, menu, 0);
1662 gui_internal_widget_pack(this, menu);
1663 gui_internal_widget_render(this, menu);
1667 gui_internal_cmd_set_destination(struct gui_priv *this, struct widget *wm, void *data)
1669 struct widget *w=wm->data;
1670 dbg(0,"c=%d:0x%x,0x%x\n", w->c.pro, w->c.x, w->c.y);
1671 navit_set_destination(this->nav, &w->c, w->name, 1);
1672 if (this->flags & 512) {
1674 follow.type=attr_follow;
1676 navit_set_attr(this->nav, &this->osd_configuration);
1677 navit_set_attr(this->nav, &follow);
1678 navit_zoom_to_route(this->nav, 0);
1680 gui_internal_prune_menu(this, NULL);
1684 gui_internal_cmd_set_position(struct gui_priv *this, struct widget *wm, void *data)
1686 struct widget *w=wm->data;
1687 navit_set_position(this->nav, &w->c);
1688 gui_internal_prune_menu(this, NULL);
1692 gui_internal_cmd_add_bookmark_do(struct gui_priv *this, struct widget *widget)
1695 dbg(0,"text='%s'\n", widget->text);
1696 if (widget->text && strlen(widget->text))
1697 navit_add_bookmark(this->nav, &widget->c, widget->text);
1698 g_free(widget->text);
1700 l=g_list_previous(g_list_last(this->root.children));
1701 gui_internal_prune_menu(this, l->data);
1705 gui_internal_cmd_add_bookmark_clicked(struct gui_priv *this, struct widget *widget, void *data)
1707 gui_internal_cmd_add_bookmark_do(this, widget->data);
1711 gui_internal_cmd_add_bookmark_changed(struct gui_priv *this, struct widget *wm, void *data)
1716 len=strlen(wm->text);
1717 dbg(1,"len=%d\n", len);
1718 if (len && (wm->text[len-1] == '\n' || wm->text[len-1] == '\r')) {
1719 wm->text[len-1]='\0';
1720 gui_internal_cmd_add_bookmark_do(this, wm);
1726 static struct widget * gui_internal_keyboard(struct gui_priv *this, int mode);
1729 gui_internal_cmd_add_bookmark(struct gui_priv *this, struct widget *wm, void *data)
1731 struct widget *w,*wb,*wk,*wl,*we,*wnext,*wp=wm->data;
1732 wb=gui_internal_menu(this,_("Add Bookmark"));
1733 w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
1734 gui_internal_widget_append(wb, w);
1735 we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
1736 gui_internal_widget_append(w, we);
1737 gui_internal_widget_append(we, wk=gui_internal_label_new(this, wp->name ? wp->name : wp->text));
1738 wk->state |= STATE_EDIT|STATE_CLEAR;
1739 wk->background=this->background;
1740 wk->flags |= flags_expand|flags_fill;
1741 wk->func = gui_internal_cmd_add_bookmark_changed;
1743 gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
1744 wnext->state |= STATE_SENSITIVE;
1745 wnext->func = gui_internal_cmd_add_bookmark_clicked;
1747 wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
1748 gui_internal_widget_append(w, wl);
1750 gui_internal_widget_append(w, gui_internal_keyboard(this,2));
1751 gui_internal_menu_render(this);
1756 get_direction(char *buffer, int angle, int mode)
1761 sprintf(buffer,"%d",angle);
1764 if (angle < 69 || angle > 291)
1766 if (angle > 111 && angle < 249)
1768 if (angle > 22 && angle < 158)
1770 if (angle > 202 && angle < 338)
1775 angle=(angle+15)/30;
1778 sprintf(buffer,"%d H", angle);
1786 enum item_type *types;
1788 {"bank","Bank",(enum item_type []){type_poi_bank,type_poi_bank,type_none}},
1789 {"fuel","Fuel",(enum item_type []){type_poi_fuel,type_poi_fuel,type_none}},
1790 {"hotel","Hotel",(enum item_type []) {
1791 type_poi_hotel,type_poi_camp_rv,
1792 type_poi_camping,type_poi_camping,
1793 type_poi_resort,type_poi_resort,
1794 type_poi_motel,type_poi_hostel,
1796 {"restaurant","Restaurant",(enum item_type []) {
1797 type_poi_bar,type_poi_picnic,
1798 type_poi_burgerking,type_poi_fastfood,
1799 type_poi_restaurant,type_poi_restaurant,
1801 {"shopping","Shopping",(enum item_type []) {
1802 type_poi_mall,type_poi_mall,
1803 type_poi_shop_grocery,type_poi_shop_grocery,
1805 {"hospital","Service",(enum item_type []) {
1806 type_poi_marina,type_poi_marina,
1807 type_poi_hospital,type_poi_hospital,
1808 type_poi_public_utilities,type_poi_public_utilities,
1809 type_poi_police,type_poi_autoservice,
1810 type_poi_information,type_poi_information,
1811 type_poi_personal_service,type_poi_repair_service,
1812 type_poi_restroom,type_poi_restroom,
1814 {"parking","Parking",(enum item_type []){type_poi_car_parking,type_poi_car_parking,type_none}},
1815 {"peak","Land Features",(enum item_type []){
1816 type_poi_land_feature,type_poi_rock,
1817 type_poi_dam,type_poi_dam,
1819 {"unknown","Other",(enum item_type []){
1820 type_point_unspecified,type_point_unkn-1,
1821 type_point_unkn+1,type_poi_land_feature-1,
1822 type_poi_rock+1,type_poi_fuel-1,
1823 type_poi_marina+1,type_poi_car_parking-1,
1824 type_poi_car_parking+1,type_poi_bar-1,
1825 type_poi_bank+1,type_poi_dam-1,
1826 type_poi_dam+1,type_poi_information-1,
1827 type_poi_information+1,type_poi_mall-1,
1828 type_poi_mall+1,type_poi_personal_service-1,
1829 type_poi_restaurant+1,type_poi_restroom-1,
1830 type_poi_restroom+1,type_poi_shop_grocery-1,
1831 type_poi_shop_grocery+1,type_poi_motel-1,
1832 type_poi_hostel+1,type_selected_point,
1834 {"unknown","Unknown",(enum item_type []){
1835 type_point_unkn,type_point_unkn,
1839 static void gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data);
1841 static struct widget *
1842 gui_internal_cmd_pois_selector(struct gui_priv *this, struct pcoord *c)
1844 struct widget *wl,*wb;
1846 wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
1847 for (i = 0 ; i < sizeof(selectors)/sizeof(struct selector) ; i++) {
1848 gui_internal_widget_append(wl, wb=gui_internal_button_new_with_callback(this, NULL,
1849 image_new_xs(this, selectors[i].icon), gravity_left_center|orientation_vertical,
1850 gui_internal_cmd_pois, &selectors[i]));
1857 static struct widget *
1858 gui_internal_cmd_pois_item(struct gui_priv *this, struct coord *center, struct item *item, struct coord *c, int dist)
1864 struct widget *wl,*wt;
1867 wl=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
1869 sprintf(distbuf,"%d", dist/1000);
1870 get_direction(dirbuf, transform_get_angle_delta(center, c, 0), 1);
1871 type=item_to_name(item->type);
1872 if (item_attr_get(item, attr_label, &attr)) {
1873 wl->name=g_strdup_printf("%s %s",type,attr.u.str);
1876 wl->name=g_strdup(type);
1878 text=g_strdup_printf("%s %s %s %s", distbuf, dirbuf, type, attr.u.str);
1879 wt=gui_internal_label_new(this, text);
1881 gui_internal_widget_append(wl, wt);
1888 gui_internal_cmd_pois_sort_num(gconstpointer a, gconstpointer b, gpointer user_data)
1890 const struct widget *wa=a;
1891 const struct widget *wb=b;
1892 struct widget *wac=wa->children->data;
1893 struct widget *wbc=wb->children->data;
1901 return wac->datai-wbc->datai;
1906 gui_internal_cmd_pois_item_selected(struct selector *sel, enum item_type type)
1908 enum item_type *types;
1909 if (type >= type_line)
1911 if (! sel || !sel->types)
1914 while (*types != type_none) {
1915 if (type >= types[0] && type <= types[1]) {
1923 static void gui_internal_cmd_position(struct gui_priv *this, struct widget *wm, void *data);
1926 gui_internal_cmd_pois(struct gui_priv *this, struct widget *wm, void *data)
1928 struct map_selection *sel,*selm;
1929 struct coord c,center;
1930 struct mapset_handle *h;
1932 struct map_rect *mr;
1934 int idist,dist=20000;
1935 struct widget *wi,*w,*w2,*wb;
1936 enum projection pro=wm->c.pro;
1937 struct selector *isel=wm->data;
1939 wb=gui_internal_menu(this, isel ? isel->name : _("POIs"));
1940 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
1941 gui_internal_widget_append(wb, w);
1943 gui_internal_widget_append(w, gui_internal_cmd_pois_selector(this,&wm->c));
1944 w2=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
1945 gui_internal_widget_append(w, w2);
1947 sel=map_selection_rect_new(&wm->c, dist, 18);
1950 h=mapset_open(navit_get_mapset(this->nav));
1951 while ((m=mapset_next(h, 1))) {
1952 selm=map_selection_dup_pro(sel, pro, map_projection(m));
1953 mr=map_rect_new(m, selm);
1954 dbg(2,"mr=%p\n", mr);
1956 while ((item=map_rect_get_item(mr))) {
1957 if (gui_internal_cmd_pois_item_selected(isel, item->type) &&
1958 item_coord_get_pro(item, &c, 1, pro) &&
1959 coord_rect_contains(&sel->u.c_rect, &c) &&
1960 (idist=transform_distance(pro, ¢er, &c)) < dist) {
1961 gui_internal_widget_append(w2, wi=gui_internal_cmd_pois_item(this, ¢er, item, &c, idist));
1962 wi->func=gui_internal_cmd_position;
1965 wi->state |= STATE_SENSITIVE;
1971 map_rect_destroy(mr);
1973 map_selection_destroy(selm);
1975 map_selection_destroy(sel);
1977 w2->children=g_list_sort_with_data(w2->children, gui_internal_cmd_pois_sort_num, (void *)1);
1978 gui_internal_menu_render(this);
1982 gui_internal_cmd_view_on_map(struct gui_priv *this, struct widget *wm, void *data)
1984 struct widget *w=wm->data;
1985 int highlight=(w->data == (void *)2 || w->data == (void *)3 || w->data == (void *)4);
1987 graphics_clear_selection(this->gra, NULL);
1988 graphics_add_selection(this->gra, &w->item, NULL);
1990 navit_set_center(this->nav, &w->c, 1);
1991 gui_internal_prune_menu(this, NULL);
1996 gui_internal_cmd_view_attribute_details(struct gui_priv *this, struct widget *wm, void *data)
1998 struct widget *w,*wb;
1999 struct map_rect *mr;
2005 text=g_strdup_printf("Attribute %s",wm->name);
2006 wb=gui_internal_menu(this, text);
2008 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
2009 gui_internal_widget_append(wb, w);
2010 mr=map_rect_new(wm->item.map, NULL);
2011 item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
2012 for (i = 0 ; i < wm->datai ; i++) {
2013 item_attr_get(item, attr_any, &attr);
2015 if (item_attr_get(item, attr_any, &attr)) {
2017 switch (attr.type) {
2018 case attr_osm_nodeid:
2019 url=g_strdup_printf("http://www.openstreetmap.org/browse/node/%Ld\n",*attr.u.num64);
2021 case attr_osm_wayid:
2022 url=g_strdup_printf("http://www.openstreetmap.org/browse/way/%Ld\n",*attr.u.num64);
2024 case attr_osm_relationid:
2025 url=g_strdup_printf("http://www.openstreetmap.org/browse/relation/%Ld\n",*attr.u.num64);
2031 gui_internal_widget_append(w,
2032 wb=gui_internal_button_new_with_callback(this, _("View in Browser"),
2033 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
2034 gui_internal_cmd_view_in_browser, NULL));
2038 map_rect_destroy(mr);
2039 gui_internal_menu_render(this);
2043 gui_internal_cmd_view_attributes(struct gui_priv *this, struct widget *wm, void *data)
2045 struct widget *w,*wb;
2046 struct map_rect *mr;
2052 dbg(0,"item=%p 0x%x 0x%x\n", wm->item.map,wm->item.id_hi, wm->item.id_lo);
2053 wb=gui_internal_menu(this, "Attributes");
2054 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
2055 gui_internal_widget_append(wb, w);
2056 mr=map_rect_new(wm->item.map, NULL);
2057 item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
2058 dbg(0,"item=%p\n", item);
2060 while(item_attr_get(item, attr_any, &attr)) {
2061 text=g_strdup_printf("%s:%s", attr_to_name(attr.type), attr_to_text(&attr, wm->item.map, 1));
2062 gui_internal_widget_append(w,
2063 wb=gui_internal_button_new_with_callback(this, text,
2064 NULL, gravity_left_center|orientation_horizontal|flags_fill,
2065 gui_internal_cmd_view_attribute_details, NULL));
2066 wb->name=g_strdup(text);
2072 map_rect_destroy(mr);
2073 gui_internal_menu_render(this);
2077 gui_internal_cmd_view_in_browser(struct gui_priv *this, struct widget *wm, void *data)
2079 struct map_rect *mr;
2085 dbg(0,"item=%p 0x%x 0x%x\n", wm->item.map,wm->item.id_hi, wm->item.id_lo);
2086 mr=map_rect_new(wm->item.map, NULL);
2087 item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
2088 dbg(0,"item=%p\n", item);
2090 while(item_attr_get(item, attr_url_local, &attr)) {
2092 cmd=g_strdup_printf("navit-browser.sh '%s' &",attr.u.str);
2095 map_rect_destroy(mr);
2097 cmd=g_strdup_printf("navit-browser.sh '%s' &",wm->name);
2103 dbg(0,"calling external cmd '%s' is not supported\n",cmd);
2109 /* wm->data: 0 Nothing special
2119 gui_internal_cmd_position(struct gui_priv *this, struct widget *wm, void *data)
2121 struct widget *wb,*w,*wc,*wbc;
2125 int display_attributes=(wm->data == (void *)2);
2126 int display_view_on_map=(wm->data != (void *)1);
2127 int display_items=(wm->data == (void *)1);
2128 int display_streets=(wm->data == (void *)3);
2129 int display_house_numbers=(wm->data == (void *)5);
2130 if (wm->data == (void *)4) {
2131 gui_internal_search_town_in_country(this, wm);
2135 switch ((int)wm->data) {
2140 dbg(0,"x=0x%x y=0x%x\n", c.x, c.y);
2141 transform_to_geo(wm->c.pro, &c, &g);
2152 name=wm->name ? wm->name : wm->text;
2153 wb=gui_internal_menu(this, name);
2154 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
2155 gui_internal_widget_append(wb, w);
2156 coord=coordinates(&wm->c, ' ');
2157 gui_internal_widget_append(w, gui_internal_label_new(this, coord));
2159 if (display_streets) {
2160 gui_internal_widget_append(w,
2161 wc=gui_internal_button_new_with_callback(this, _("Streets"),
2162 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
2163 gui_internal_search_street_in_town, wm));
2165 wc->selection_id=wm->selection_id;
2167 if (display_house_numbers) {
2168 gui_internal_widget_append(w,
2169 wc=gui_internal_button_new_with_callback(this, _("House numbers"),
2170 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
2171 gui_internal_search_house_number_in_street, wm));
2173 wc->selection_id=wm->selection_id;
2175 if (display_attributes) {
2176 struct map_rect *mr;
2179 mr=map_rect_new(wm->item.map, NULL);
2180 item = map_rect_get_item_byid(mr, wm->item.id_hi, wm->item.id_lo);
2182 if (item_attr_get(item, attr_description, &attr))
2183 gui_internal_widget_append(w, gui_internal_label_new(this, attr.u.str));
2184 if (item_attr_get(item, attr_url_local, &attr)) {
2185 gui_internal_widget_append(w,
2186 wb=gui_internal_button_new_with_callback(this, _("View in Browser"),
2187 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
2188 gui_internal_cmd_view_in_browser, NULL));
2191 gui_internal_widget_append(w,
2192 wb=gui_internal_button_new_with_callback(this, _("View Attributes"),
2193 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
2194 gui_internal_cmd_view_attributes, NULL));
2197 map_rect_destroy(mr);
2199 gui_internal_widget_append(w,
2200 gui_internal_button_new_with_callback(this, _("Set as destination"),
2201 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
2202 gui_internal_cmd_set_destination, wm));
2203 gui_internal_widget_append(w,
2204 gui_internal_button_new_with_callback(this, _("Set as position"),
2205 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
2206 gui_internal_cmd_set_position, wm));
2207 gui_internal_widget_append(w,
2208 wbc=gui_internal_button_new_with_callback(this, _("Add as bookmark"),
2209 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
2210 gui_internal_cmd_add_bookmark, wm));
2212 gui_internal_widget_append(w,
2213 wbc=gui_internal_button_new_with_callback(this, _("POIs"),
2214 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
2215 gui_internal_cmd_pois, NULL));
2218 gui_internal_widget_append(w,
2219 gui_internal_button_new(this, "Add to tour",
2220 image_new_o(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill));
2221 gui_internal_widget_append(w,
2222 gui_internal_button_new(this, "Add as bookmark",
2223 image_new_o(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill));
2225 if (display_view_on_map) {
2226 gui_internal_widget_append(w,
2227 gui_internal_button_new_with_callback(this, _("View on map"),
2228 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
2229 gui_internal_cmd_view_on_map, wm));
2231 if (display_items) {
2234 struct mapset_handle *h;
2235 struct map_rect *mr;
2238 struct street_data *data;
2239 struct map_selection sel;
2240 struct transformation *trans;
2241 enum projection pro;
2245 trans=navit_get_trans(this->nav);
2246 pro=transform_get_projection(trans);
2247 transform_from_geo(pro, &g, &c);
2248 ms=navit_get_mapset(this->nav);
2250 sel.u.c_rect.lu.x=c.x-dist;
2251 sel.u.c_rect.lu.y=c.y+dist;
2252 sel.u.c_rect.rl.x=c.x+dist;
2253 sel.u.c_rect.rl.y=c.y-dist;
2255 sel.range=item_range_all;
2257 while ((m=mapset_next(h,1))) {
2258 mr=map_rect_new(m, &sel);
2261 while ((item=map_rect_get_item(mr))) {
2262 data=street_get_data(item);
2263 if (transform_within_dist_item(&c, item->type, data->c, data->count, dist)) {
2264 if (item_attr_get(item, attr_label, &attr)) {
2265 label=map_convert_string(m, attr.u.str);
2266 text=g_strdup_printf("%s %s", item_to_name(item->type), label);
2267 map_convert_free(label);
2269 text=g_strdup_printf("%s", item_to_name(item->type));
2270 gui_internal_widget_append(w,
2271 wc=gui_internal_button_new_with_callback(this, text,
2272 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
2273 gui_internal_cmd_position, (void *)2));
2274 wc->c.x=data->c[0].x;
2275 wc->c.y=data->c[0].y;
2277 wc->name=g_strdup(text);
2281 street_data_free(data);
2283 map_rect_destroy(mr);
2288 gui_internal_menu_render(this);
2292 gui_internal_cmd_bookmarks(struct gui_priv *this, struct widget *wm, void *data)
2294 struct attr attr,mattr;
2295 struct map_rect *mr=NULL;
2297 char *label_full,*l,*prefix,*pos;
2298 int len,plen,hassub;
2299 struct widget *wb,*w,*wbm;
2304 wb=gui_internal_menu(this, wm->text ? wm->text : _("Bookmarks"));
2305 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
2306 w->spy=this->spacing*3;
2307 gui_internal_widget_append(wb, w);
2312 plen=strlen(prefix);
2314 if(navit_get_attr(this->nav, attr_bookmark_map, &mattr, NULL) && mattr.u.map && (mr=map_rect_new(mattr.u.map, NULL))) {
2315 hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
2316 while ((item=map_rect_get_item(mr))) {
2317 if (item->type != type_bookmark) continue;
2318 if (!item_attr_get(item, attr_label, &attr)) continue;
2319 label_full=attr.u.str;
2320 if (!strncmp(label_full, prefix, plen)) {
2321 pos=strchr(label_full+plen, '/');
2327 len=strlen(label_full);
2329 l=g_malloc(len-plen+1);
2330 strncpy(l, label_full+plen, len-plen);
2332 if (!g_hash_table_lookup(hash, l)) {
2333 wbm=gui_internal_button_new_with_callback(this, l,
2334 image_new_xs(this, hassub ? "gui_inactive" : "gui_active" ), gravity_left_center|orientation_horizontal|flags_fill,
2335 hassub ? gui_internal_cmd_bookmarks : gui_internal_cmd_position, NULL);
2336 if (item_coord_get(item, &c, 1)) {
2339 wbm->c.pro=map_projection(mattr.u.map);
2340 wbm->name=g_strdup_printf(_("Bookmark %s"),label_full);
2341 wbm->text=g_strdup(l);
2342 gui_internal_widget_append(w, wbm);
2343 g_hash_table_insert(hash, g_strdup(l), (void *)1);
2344 wbm->prefix=g_malloc(len+2);
2345 strncpy(wbm->prefix, label_full, len+1);
2346 wbm->prefix[len+1]='\0';
2348 gui_internal_widget_destroy(this, wbm);
2355 g_hash_table_destroy(hash);
2357 gui_internal_menu_render(this);
2360 static void gui_internal_keypress_do(struct gui_priv *this, char *key)
2362 struct widget *wi,*menu;
2366 menu=g_list_last(this->root.children)->data;
2367 wi=gui_internal_find_widget(menu, NULL, STATE_EDIT);
2369 if (*key == NAVIT_KEY_BACKSPACE) {
2370 dbg(0,"backspace\n");
2371 if (wi->text && wi->text[0]) {
2372 len=g_utf8_prev_char(wi->text+strlen(wi->text))-wi->text;
2374 text=g_strdup_printf("%s ", wi->text);
2377 if (wi->state & STATE_CLEAR) {
2378 dbg(0,"wi->state=0x%x\n", wi->state);
2381 wi->state &= ~STATE_CLEAR;
2382 dbg(0,"wi->state=0x%x\n", wi->state);
2384 text=g_strdup_printf("%s%s", wi->text ? wi->text : "", key);
2388 if (*key == NAVIT_KEY_BACKSPACE && wi->text) {
2389 gui_internal_widget_render(this, wi);
2394 wi->func(this, wi, wi->data);
2396 gui_internal_widget_render(this, wi);
2402 gui_internal_cmd_keypress(struct gui_priv *this, struct widget *wm, void *data)
2404 struct menu_data *md=gui_internal_menu_data(this);
2405 gui_internal_keypress_do(this, (char *) wm->data);
2406 if (md->keyboard_mode == 2)
2407 gui_internal_keyboard_do(this, md->keyboard, 10);
2408 if (md->keyboard_mode == 26)
2409 gui_internal_keyboard_do(this, md->keyboard, 34);
2413 gui_internal_search_idle_end(struct gui_priv *this)
2416 event_remove_idle(this->idle);
2419 if (this->idle_cb) {
2420 callback_destroy(this->idle_cb);
2426 gui_internal_search_idle(struct gui_priv *this, char *wm_name, struct widget *search_list, void *param)
2428 char *text=NULL,*name=NULL;
2429 struct search_list_result *res;
2431 struct item *item=NULL;
2433 static char possible_keys[256]="";
2435 res=search_list_get_result(this->sl);
2437 gchar* trunk_name = NULL;
2439 struct widget *menu=g_list_last(this->root.children)->data;
2440 struct widget *wi=gui_internal_find_widget(menu, NULL, STATE_EDIT);
2442 if (! strcmp(wm_name,"Town"))
2443 trunk_name = g_strrstr(res->town->name, wi->text);
2444 if (! strcmp(wm_name,"Street"))
2445 trunk_name = g_strrstr(name=res->street->name, wi->text);
2448 char next_char = trunk_name[strlen(wi->text)];
2450 int len = strlen(possible_keys);
2451 for(i = 0; (i<len) && (possible_keys[i] != next_char) ;i++) ;
2452 if (i==len || !len) {
2453 possible_keys[len]=trunk_name[strlen(wi->text)];
2454 possible_keys[len+1]='\0';
2457 dbg(1,"%s %s possible_keys:%s \n", wi->text, res->town->name, possible_keys);
2462 gui_internal_search_idle_end(this);
2464 struct menu_data *md=gui_internal_menu_data(this);
2465 if (md && md->keyboard) {
2466 GList *lk=md->keyboard->children;
2467 graphics_draw_mode(this->gra, draw_mode_begin);
2469 struct widget *child=lk->data;
2470 GList *lk2=child->children;
2472 struct widget *child_=lk2->data;
2473 lk2=g_list_next(lk2);
2474 if (child_->data && strcmp("\b", child_->data)) { // FIXME don't disable special keys
2475 if (strlen(possible_keys) == 0)
2476 child_->state|= STATE_HIGHLIGHTED|STATE_VISIBLE|STATE_SENSITIVE|STATE_CLEAR ;
2477 else if (g_strrstr(possible_keys, child_->data)!=NULL ) {
2478 child_->state|= STATE_HIGHLIGHTED|STATE_VISIBLE|STATE_SENSITIVE|STATE_CLEAR ;
2480 child_->state&= ~(STATE_HIGHLIGHTED|STATE_VISIBLE|STATE_SELECTED) ;
2482 gui_internal_widget_render(this,child_);
2487 gui_internal_widget_render(this,md->keyboard);
2488 graphics_draw_mode(this->gra, draw_mode_end);
2491 possible_keys[0]='\0';
2495 if (! strcmp(wm_name,"Country")) {
2496 name=res->country->name;
2497 item=&res->country->common.item;
2498 text=g_strdup_printf("%s", res->country->name);
2500 if (! strcmp(wm_name,"Town")) {
2501 name=res->town->name;
2502 item=&res->town->common.item;
2503 if (res->town->name && res->town->district)
2504 text=g_strdup_printf("%s%s%s (%s)", res->town->common.postal_mask ? res->town->common.postal_mask : "", res->town->common.postal_mask ? " ":"", res->town->name, res->town->district);
2506 text=g_strdup_printf("%s%s%s", res->town->common.postal ? res->town->common.postal_mask : "", res->town->common.postal_mask ? " ":"", res->town->name);
2508 if (! strcmp(wm_name,"Street")) {
2509 name=res->street->name;
2510 item=&res->street->common.item;
2511 text=g_strdup_printf("%s %s", res->town->name, res->street->name);
2513 dbg(1,"res->country->flag=%s\n", res->country->flag);
2514 gui_internal_widget_append(search_list,
2515 wc=gui_internal_button_new_with_callback(this, text,
2516 image_new_xs(this, res->country->flag),
2517 gravity_left_center|orientation_horizontal|flags_fill,
2518 gui_internal_cmd_position, param));
2519 wc->name=g_strdup(name);
2522 wc->selection_id=res->id;
2525 gui_internal_widget_pack(this, search_list);
2526 l=g_list_last(this->root.children);
2527 graphics_draw_mode(this->gra, draw_mode_begin);
2528 gui_internal_widget_render(this, l->data);
2529 graphics_draw_mode(this->gra, draw_mode_end);
2534 gui_internal_search_idle_start(struct gui_priv *this, char *wm_name, struct widget *search_list, void *param)
2536 this->idle_cb=callback_new_4(callback_cast(gui_internal_search_idle), this, wm_name, search_list, param);
2537 this->idle=event_add_idle(50,this->idle_cb);
2538 callback_call_0(this->idle_cb);
2544 * @param wm The widget that generated the event for the search changed,
2545 * if this was generated by a key on the virtual keyboard then
2546 * wm is the key button widget.
2549 gui_internal_search_changed(struct gui_priv *this, struct widget *wm, void *data)
2552 struct widget *search_list=gui_internal_menu_data(this)->search_list;
2553 gui_internal_widget_children_destroy(this, search_list);
2555 void *param=(void *)3;
2557 if (! strcmp(wm->name,"Country"))
2559 if (! strcmp(wm->name,"Street"))
2561 dbg(0,"%s now '%s'\n", wm->name, wm->text);
2563 gui_internal_search_idle_end(this);
2564 if (wm->text && g_utf8_strlen(wm->text, -1) >= minlen) {
2565 struct attr search_attr;
2568 if (! strcmp(wm->name,"Country"))
2569 search_attr.type=attr_country_all;
2570 if (! strcmp(wm->name,"Town"))
2571 search_attr.type=attr_town_or_district_name;
2572 if (! strcmp(wm->name,"Street"))
2573 search_attr.type=attr_street_name;
2574 if (! strcmp(wm->name,"House number"))
2575 search_attr.type=attr_house_number;
2576 search_attr.u.str=wm->text;
2577 search_list_search(this->sl, &search_attr, 1);
2578 gui_internal_search_idle_start(this, wm->name, search_list, param);
2580 l=g_list_last(this->root.children);
2581 gui_internal_widget_render(this, l->data);
2584 static struct widget *
2585 gui_internal_keyboard_key_data(struct gui_priv *this, struct widget *wkbd, char *text, void(*func)(struct gui_priv *priv, struct widget *widget, void *data), void *data, void (*data_free)(void *data), int w, int h)
2588 gui_internal_widget_append(wkbd, wk=gui_internal_button_new_with_callback(this, text,
2589 NULL, gravity_center|orientation_vertical, func, data));
2590 wk->data_free=data_free;
2591 wk->background=this->background;
2599 static struct widget *
2600 gui_internal_keyboard_key(struct gui_priv *this, struct widget *wkbd, char *text, char *key, int w, int h)
2602 return gui_internal_keyboard_key_data(this, wkbd, text, gui_internal_cmd_keypress, g_strdup(key), g_free,w,h);
2605 static void gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *data);
2607 // Some macros that make the keyboard layout easier to visualise in
2608 // the source code. The macros are #undef'd after this function.
2609 #define KEY(x) gui_internal_keyboard_key(this, wkbd, (x), (x), max_w, max_h)
2610 #define SPACER() gui_internal_keyboard_key_data(this, wkbd, "", NULL, NULL, NULL,max_w,max_h)
2611 static struct widget *
2612 gui_internal_keyboard_do(struct gui_priv *this, struct widget *wkbdb, int mode)
2614 struct widget *wkbd,*wk;
2615 struct menu_data *md=gui_internal_menu_data(this);
2616 int i, max_w=this->root.w, max_h=this->root.h;
2622 gui_internal_highlight(this);
2624 gui_internal_widget_children_destroy(this, wkbdb);
2626 wkbdb=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
2628 md->keyboard_mode=mode;
2629 wkbd=gui_internal_box_new(this, gravity_center|orientation_horizontal_vertical|flags_fill);
2630 wkbd->background=this->background;
2637 if (mode >= 0 && mode < 8) {
2638 for (i = 0 ; i < 26 ; i++) {
2639 char text[]={'A'+i,'\0'};
2642 gui_internal_keyboard_key(this, wkbd, "_"," ",max_w,max_h);
2649 wk=gui_internal_keyboard_key_data(this, wkbd, "a", gui_internal_keyboard_change, wkbd, NULL,max_w,max_h);
2651 wk=gui_internal_keyboard_key_data(this, wkbd, "1", gui_internal_keyboard_change, wkbd, NULL,max_w,max_h);
2654 wk=gui_internal_keyboard_key_data(this, wkbd, "Ä",gui_internal_keyboard_change, wkbdb,NULL,max_w,max_h);
2656 gui_internal_keyboard_key(this, wkbd, "<-","\b",max_w,max_h);
2658 if (mode >= 8 && mode < 16) {
2659 for (i = 0 ; i < 26 ; i++) {
2660 char text[]={'a'+i,'\0'};
2663 gui_internal_keyboard_key(this, wkbd, "_"," ",max_w,max_h);
2670 wk=gui_internal_keyboard_key_data(this, wkbd, "A", gui_internal_keyboard_change, wkbd, NULL,max_w,max_h);
2672 wk=gui_internal_keyboard_key_data(this, wkbd, "1", gui_internal_keyboard_change, wkbd, NULL,max_w,max_h);
2675 wk=gui_internal_keyboard_key_data(this, wkbd, "ä",gui_internal_keyboard_change,wkbdb,NULL,max_w,max_h);
2677 gui_internal_keyboard_key(this, wkbd, "<-","\b",max_w,max_h);
2679 if (mode >= 16 && mode < 24) {
2680 for (i = 0 ; i < 10 ; i++) {
2681 char text[]={'0'+i,'\0'};
2684 KEY("."); KEY("°"); KEY("'"); KEY("\""); KEY("-"); KEY("+");
2685 KEY("*"); KEY("/"); KEY("("); KEY(")"); KEY("="); KEY("?");
2687 for (i = 0 ; i < 5 ; i++) SPACER();
2695 wk=gui_internal_keyboard_key_data(this, wkbd, "A", gui_internal_keyboard_change, wkbd, NULL,max_w,max_h);
2697 wk=gui_internal_keyboard_key_data(this, wkbd, "a", gui_internal_keyboard_change, wkbd, NULL,max_w,max_h);
2700 wk=gui_internal_keyboard_key_data(this, wkbd, "Ä",gui_internal_keyboard_change,wkbdb,NULL,max_w,max_h);
2702 gui_internal_keyboard_key(this, wkbd, "<-","\b",max_w,max_h);
2704 if (mode >= 24 && mode < 32) {
2705 KEY("Ä"); KEY("Ë"); KEY("Ï"); KEY("Ö"); KEY("Ü"); KEY("Æ"); KEY("Ø"); KEY("Å");
2706 KEY("Á"); KEY("É"); KEY("Í"); KEY("Ó"); KEY("Ú"); KEY("Š"); KEY("Č"); KEY("Ž");
2707 KEY("À"); KEY("È"); KEY("Ì"); KEY("Ò"); KEY("Ù"); KEY("Ś"); KEY("Ć"); KEY("Ź");
2708 KEY("Â"); KEY("Ê"); KEY("Î"); KEY("Ô"); KEY("Û"); SPACER();
2710 wk=gui_internal_keyboard_key_data(this, wkbd, "A",gui_internal_keyboard_change,wkbdb,NULL,max_w,max_h);
2713 gui_internal_keyboard_key(this, wkbd, "<-","\b",max_w,max_h);
2715 if (mode >= 32 && mode < 40) {
2716 KEY("ä"); KEY("ë"); KEY("ï"); KEY("ö"); KEY("ü"); KEY("æ"); KEY("ø"); KEY("å");
2717 KEY("á"); KEY("é"); KEY("í"); KEY("ó"); KEY("ú"); KEY("š"); KEY("č"); KEY("ž");
2718 KEY("à"); KEY("è"); KEY("ì"); KEY("ò"); KEY("ù"); KEY("ś"); KEY("ć"); KEY("ź");
2719 KEY("â"); KEY("ê"); KEY("î"); KEY("ô"); KEY("û"); KEY("ß");
2721 wk=gui_internal_keyboard_key_data(this, wkbd, "a",gui_internal_keyboard_change,wkbdb,NULL,max_w,max_h);
2724 gui_internal_keyboard_key(this, wkbd, "<-","\b",max_w,max_h);
2726 gui_internal_widget_append(wkbdb, wkbd);
2728 gui_internal_widget_pack(this, wkbdb);
2729 gui_internal_widget_render(this, wkbdb);
2736 static struct widget *
2737 gui_internal_keyboard(struct gui_priv *this, int mode)
2739 if (! this->keyboard)
2741 return gui_internal_keyboard_do(this, NULL, mode);
2745 gui_internal_keyboard_change(struct gui_priv *this, struct widget *key, void *data)
2747 gui_internal_keyboard_do(this, key->data, key->datai);
2751 gui_internal_search_list_set_default_country(struct gui_priv *this)
2753 struct attr search_attr, country_name, country_iso2, *country_attr;
2755 struct country_search *cs;
2756 struct tracking *tracking;
2757 struct search_list_result *res;
2759 country_attr=country_default();
2760 tracking=navit_get_tracking(this->nav);
2761 if (tracking && tracking_get_attr(tracking, attr_country_id, &search_attr, NULL))
2762 country_attr=&search_attr;
2764 cs=country_search_new(country_attr, 0);
2765 item=country_search_get_item(cs);
2766 if (item && item_attr_get(item, attr_country_name, &country_name)) {
2767 search_attr.type=attr_country_all;
2768 dbg(0,"country %s\n", country_name.u.str);
2769 search_attr.u.str=country_name.u.str;
2770 search_list_search(this->sl, &search_attr, 0);
2771 while((res=search_list_get_result(this->sl)));
2772 g_free(this->country_iso2);
2773 if (item_attr_get(item, attr_country_iso2, &country_iso2))
2774 this->country_iso2=g_strdup(country_iso2.u.str);
2776 country_search_destroy(cs);
2778 dbg(0,"warning: no default country found\n");
2779 if (this->country_iso2) {
2780 dbg(0,"attempting to use country '%s'\n",this->country_iso2);
2781 search_attr.type=attr_country_iso2;
2782 search_attr.u.str=this->country_iso2;
2783 search_list_search(this->sl, &search_attr, 0);
2784 while((res=search_list_get_result(this->sl)));
2790 gui_internal_search_list_new(struct gui_priv *this)
2792 struct mapset *ms=navit_get_mapset(this->nav);
2794 this->sl=search_list_new(ms);
2795 gui_internal_search_list_set_default_country(this);
2800 gui_internal_search_list_destroy(struct gui_priv *this)
2803 search_list_destroy(this->sl);
2810 gui_internal_search(struct gui_priv *this, char *what, char *type, int flags)
2812 struct widget *wb,*wk,*w,*wr,*we,*wl,*wnext=NULL;
2814 gui_internal_search_list_new(this);
2815 wb=gui_internal_menu(this, what);
2816 w=gui_internal_box_new(this, gravity_center|orientation_vertical|flags_expand|flags_fill);
2817 gui_internal_widget_append(wb, w);
2818 wr=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
2819 gui_internal_widget_append(w, wr);
2820 we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
2821 gui_internal_widget_append(wr, we);
2823 if (!strcmp(type,"Country")) {
2824 wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_town"));
2825 wnext->func=gui_internal_search_town;
2826 } else if (!strcmp(type,"Town")) {
2827 if (this->country_iso2) {
2828 #if HAVE_API_ANDROID
2829 char country_iso2[strlen(this->country_iso2)+1];
2830 strtolower(country_iso2, this->country_iso2);
2831 country=g_strdup_printf("country_%s", country_iso2);
2833 country=g_strdup_printf("country_%s", this->country_iso2);
2836 country=strdup("gui_select_country");
2837 gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, country)));
2838 wb->state |= STATE_SENSITIVE;
2840 wb->func = gui_internal_search_country;
2842 wb->func = gui_internal_back;
2843 wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_street"));
2844 wnext->func=gui_internal_search_street;
2846 } else if (!strcmp(type,"Street")) {
2847 gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_select_town")));
2848 wb->state |= STATE_SENSITIVE;
2849 wb->func = gui_internal_back;
2850 wnext=gui_internal_image_new(this, image_new_xs(this, "gui_select_house_number"));
2851 wnext->func=gui_internal_search_house_number;
2852 } else if (!strcmp(type,"House number")) {
2853 gui_internal_widget_append(we, wb=gui_internal_image_new(this, image_new_xs(this, "gui_select_street")));
2854 wb->state |= STATE_SENSITIVE;
2855 wb->func = gui_internal_back;
2857 gui_internal_widget_append(we, wk=gui_internal_label_new(this, NULL));
2859 gui_internal_widget_append(we, wnext);
2860 wnext->state |= STATE_SENSITIVE;
2862 wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
2863 gui_internal_widget_append(wr, wl);
2864 gui_internal_menu_data(this)->search_list=wl;
2865 wk->state |= STATE_EDIT;
2866 wk->background=this->background;
2867 wk->flags |= flags_expand|flags_fill;
2868 wk->func = gui_internal_search_changed;
2869 wk->name=g_strdup(type);
2871 gui_internal_widget_append(w, gui_internal_keyboard(this,2));
2872 gui_internal_menu_render(this);
2876 gui_internal_search_house_number(struct gui_priv *this, struct widget *widget, void *data)
2878 search_list_select(this->sl, attr_street_name, 0, 0);
2879 gui_internal_search(this,_("House number"),"House number",0);
2883 gui_internal_search_house_number_in_street(struct gui_priv *this, struct widget *widget, void *data)
2885 dbg(0,"id %d\n", widget->selection_id);
2886 search_list_select(this->sl, attr_street_name, 0, 0);
2887 search_list_select(this->sl, attr_street_name, widget->selection_id, 1);
2888 gui_internal_search(this,_("House number"),"House number",0);
2892 gui_internal_search_street(struct gui_priv *this, struct widget *widget, void *data)
2894 search_list_select(this->sl, attr_town_or_district_name, 0, 0);
2895 gui_internal_search(this,_("Street"),"Street",0);
2899 gui_internal_search_street_in_town(struct gui_priv *this, struct widget *widget, void *data)
2901 dbg(0,"id %d\n", widget->selection_id);
2902 search_list_select(this->sl, attr_town_or_district_name, 0, 0);
2903 search_list_select(this->sl, attr_town_or_district_name, widget->selection_id, 1);
2904 gui_internal_search(this,_("Street"),"Street",0);
2908 gui_internal_search_town(struct gui_priv *this, struct widget *wm, void *data)
2911 search_list_select(this->sl, attr_country_all, 0, 0);
2912 g_free(this->country_iso2);
2913 this->country_iso2=NULL;
2914 gui_internal_search(this,_("Town"),"Town",0);
2918 gui_internal_search_town_in_country(struct gui_priv *this, struct widget *widget)
2920 struct search_list_common *slc;
2921 dbg(0,"id %d\n", widget->selection_id);
2922 search_list_select(this->sl, attr_country_all, 0, 0);
2923 slc=search_list_select(this->sl, attr_country_all, widget->selection_id, 1);
2925 g_free(this->country_iso2);
2926 this->country_iso2=((struct search_list_country *)slc)->iso2;
2928 gui_internal_search(this,widget->name,"Town",0);
2932 gui_internal_search_country(struct gui_priv *this, struct widget *widget, void *data)
2934 gui_internal_prune_menu_count(this, 1, 0);
2935 gui_internal_search(this,_("Country"),"Country",0);
2939 gui_internal_cmd_town(struct gui_priv *this, struct widget *wm, void *data)
2942 search_list_select(this->sl, attr_country_all, 0, 0);
2943 gui_internal_search(this,_("Town"),"Town",1);
2947 gui_internal_cmd_layout(struct gui_priv *this, struct widget *wm, void *data)
2950 struct widget *w,*wb,*wl;
2951 struct attr_iter *iter;
2954 wb=gui_internal_menu(this, _("Layout"));
2955 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
2956 w->spy=this->spacing*3;
2957 gui_internal_widget_append(wb, w);
2958 iter=navit_attr_iter_new();
2959 while(navit_get_attr(this->nav, attr_layout, &attr, iter)) {
2960 wl=gui_internal_button_navit_attr_new(this, attr.u.layout->name, gravity_left_center|orientation_horizontal|flags_fill,
2962 gui_internal_widget_append(w, wl);
2964 navit_attr_iter_destroy(iter);
2965 gui_internal_menu_render(this);
2969 gui_internal_cmd_fullscreen(struct gui_priv *this, struct widget *wm, void *data)
2971 graphics_draw_mode(this->gra, draw_mode_end);
2972 if (this->fullscreen != 2)
2973 this->fullscreen=!this->fullscreen;
2974 this->win->fullscreen(this->win, this->fullscreen != 0);
2975 graphics_draw_mode(this->gra, draw_mode_begin);
2979 gui_internal_cmd_2d(struct gui_priv *this, struct widget *wm, void *data)
2981 struct transformation *trans=navit_get_trans(this->nav);
2982 transform_set_pitch(trans, 0);
2984 gui_internal_prune_menu(this, NULL);
2988 gui_internal_cmd_3d(struct gui_priv *this, struct widget *wm, void *data)
2990 struct transformation *trans=navit_get_trans(this->nav);
2991 transform_set_pitch(trans, this->pitch);
2993 gui_internal_prune_menu(this, NULL);
2997 gui_internal_cmd_display(struct gui_priv *this, struct widget *wm, void *data)
3000 struct transformation *trans;
3002 w=gui_internal_menu(this, _("Display"));
3003 gui_internal_widget_append(w,
3004 gui_internal_button_new_with_callback(this, _("Layout"),
3005 image_new_l(this, "gui_display"), gravity_center|orientation_vertical,
3006 gui_internal_cmd_layout, NULL));
3008 if(this->fullscreen != 2) {
3009 if (this->fullscreen) {
3010 gui_internal_widget_append(w,
3011 gui_internal_button_new_with_callback(this, _("Window Mode"),
3012 image_new_l(this, "gui_leave_fullscreen"), gravity_center|orientation_vertical,
3013 gui_internal_cmd_fullscreen, NULL));
3015 gui_internal_widget_append(w,
3016 gui_internal_button_new_with_callback(this, _("Fullscreen"),
3017 image_new_l(this, "gui_fullscreen"), gravity_center|orientation_vertical,
3018 gui_internal_cmd_fullscreen, NULL));
3021 trans=navit_get_trans(this->nav);
3022 if (transform_get_pitch(trans)) {
3023 gui_internal_widget_append(w,
3024 gui_internal_button_new_with_callback(this, _("2D"),
3025 image_new_l(this, "gui_map"), gravity_center|orientation_vertical,
3026 gui_internal_cmd_2d, NULL));
3029 gui_internal_widget_append(w,
3030 gui_internal_button_new_with_callback(this, _("3D"),
3031 image_new_l(this, "gui_map"), gravity_center|orientation_vertical,
3032 gui_internal_cmd_3d, NULL));
3034 gui_internal_menu_render(this);
3038 gui_internal_cmd_quit(struct gui_priv *this, struct widget *wm, void *data)
3040 struct navit *nav=this->nav;
3042 main_remove_navit(nav);
3046 gui_internal_cmd_abort_navigation(struct gui_priv *this, struct widget *wm, void *data)
3048 navit_set_destination(this->nav, NULL, NULL, 0);
3053 gui_internal_cmd_actions(struct gui_priv *this, struct widget *wm, void *data)
3055 struct widget *w,*wc;
3058 w=gui_internal_menu(this, _("Actions"));
3059 gui_internal_widget_append(w,
3060 gui_internal_button_new_with_callback(this, _("Bookmarks"),
3061 image_new_l(this, "gui_bookmark"), gravity_center|orientation_vertical,
3062 gui_internal_cmd_bookmarks, NULL));
3063 if (this->clickp_valid) {
3064 coord=coordinates(&this->clickp, '\n');
3065 gui_internal_widget_append(w,
3066 wc=gui_internal_button_new_with_callback(this, coord,
3067 image_new_l(this, "gui_map"), gravity_center|orientation_vertical,
3068 gui_internal_cmd_position, (void *)1));
3069 wc->name=g_strdup(_("Map Point"));
3073 if (this->vehicle_valid) {
3074 coord=coordinates(&this->vehiclep, '\n');
3075 gui_internal_widget_append(w,
3076 wc=gui_internal_button_new_with_callback(this, coord,
3077 image_new_l(this, "gui_vehicle"), gravity_center|orientation_vertical,
3078 gui_internal_cmd_position, NULL));
3079 wc->name=g_strdup(_("Vehicle Position"));
3080 wc->c=this->vehiclep;
3083 gui_internal_widget_append(w,
3084 gui_internal_button_new_with_callback(this, _("Town"),
3085 image_new_l(this, "gui_town"), gravity_center|orientation_vertical,
3086 gui_internal_cmd_town, NULL));
3087 gui_internal_widget_append(w,
3088 gui_internal_button_new_with_callback(this, _("Quit"),
3089 image_new_l(this, "gui_quit"), gravity_center|orientation_vertical,
3090 gui_internal_cmd_quit, NULL));
3092 if (navit_check_route(this->nav)) {
3093 gui_internal_widget_append(w,
3094 gui_internal_button_new_with_callback(this, _("Stop\nNavigation"),
3095 image_new_l(this, "gui_stop"), gravity_center|orientation_vertical,
3096 gui_internal_cmd_abort_navigation, NULL));
3098 gui_internal_menu_render(this);
3102 gui_internal_cmd_maps(struct gui_priv *this, struct widget *wm, void *wdata)
3104 struct attr attr, on, off, description, type, data;
3105 struct widget *w,*wb,*wma;
3107 struct attr_iter *iter;
3110 wb=gui_internal_menu(this, _("Maps"));
3111 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
3112 w->spy=this->spacing*3;
3113 gui_internal_widget_append(wb, w);
3114 iter=navit_attr_iter_new();
3115 on.type=off.type=attr_active;
3118 while(navit_get_attr(this->nav, attr_map, &attr, iter)) {
3119 if (map_get_attr(attr.u.map, attr_description, &description, NULL)) {
3120 label=g_strdup(description.u.str);
3122 if (!map_get_attr(attr.u.map, attr_type, &type, NULL))
3124 if (!map_get_attr(attr.u.map, attr_data, &data, NULL))
3126 label=g_strdup_printf("%s:%s", type.u.str, data.u.str);
3128 wma=gui_internal_button_map_attr_new(this, label, gravity_left_center|orientation_horizontal|flags_fill,
3129 attr.u.map, &on, &off, 1);
3130 gui_internal_widget_append(w, wma);
3133 navit_attr_iter_destroy(iter);
3134 gui_internal_menu_render(this);
3138 gui_internal_cmd_set_active_vehicle(struct gui_priv *this, struct widget *wm, void *data)
3140 struct attr vehicle = {attr_vehicle,{wm->data}};
3141 navit_set_attr(this->nav, &vehicle);
3145 gui_internal_cmd_show_satellite_status(struct gui_priv *this, struct widget *wm, void *data)
3147 struct widget *w,*wb,*row;
3148 struct attr attr,sat_attr;
3149 struct vehicle *v=wm->data;
3152 enum attr_type types[]={attr_sat_prn, attr_sat_elevation, attr_sat_azimuth, attr_sat_snr};
3154 wb=gui_internal_menu(this, _("Show Satellite Status"));
3155 gui_internal_menu_data(this)->redisplay=gui_internal_cmd_show_satellite_status;
3156 gui_internal_menu_data(this)->redisplay_widget=wm;
3157 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
3158 gui_internal_widget_append(wb, w);
3159 w = gui_internal_widget_table_new(this,gravity_center | orientation_vertical | flags_expand | flags_fill, 0);
3160 row = gui_internal_widget_table_row_new(this,gravity_left_top);
3161 gui_internal_widget_append(row, gui_internal_label_new(this, _(" PRN ")));
3162 gui_internal_widget_append(row, gui_internal_label_new(this, _(" Elevation ")));
3163 gui_internal_widget_append(row, gui_internal_label_new(this, _(" Azimuth ")));
3164 gui_internal_widget_append(row, gui_internal_label_new(this, _(" SNR ")));
3165 gui_internal_widget_append(w,row);
3166 while (vehicle_get_attr(v, attr_position_sat_item, &attr, NULL)) {
3167 row = gui_internal_widget_table_row_new(this,gravity_left_top);
3168 for (i = 0 ; i < sizeof(types)/sizeof(enum attr_type) ; i++) {
3169 if (item_attr_get(attr.u.item, types[i], &sat_attr))
3170 str=g_strdup_printf("%d", sat_attr.u.num);
3173 gui_internal_widget_append(row, gui_internal_label_new(this, str));
3176 gui_internal_widget_append(w,row);
3178 gui_internal_widget_append(wb, w);
3179 gui_internal_menu_render(this);
3183 gui_internal_cmd_show_nmea_data(struct gui_priv *this, struct widget *wm, void *data)
3185 struct widget *w,*wb;
3187 struct vehicle *v=wm->data;
3188 wb=gui_internal_menu(this, _("Show NMEA Data"));
3189 gui_internal_menu_data(this)->redisplay=gui_internal_cmd_show_nmea_data;
3190 gui_internal_menu_data(this)->redisplay_widget=wm;
3191 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
3192 gui_internal_widget_append(wb, w);
3193 if (vehicle_get_attr(v, attr_position_nmea, &attr, NULL))
3194 gui_internal_widget_append(w, gui_internal_text_new(this, attr.u.str, gravity_left_center|orientation_vertical));
3195 gui_internal_menu_render(this);
3199 * A container to hold the selected vehicle and the desired profile in
3202 struct vehicle_and_profilename {
3203 struct vehicle *vehicle;
3208 * Figures out whether the given vehicle is the active vehicle.
3210 * @return true if the vehicle is active, false otherwise.
3213 gui_internal_is_active_vehicle(struct gui_priv *this, struct vehicle
3216 struct attr active_vehicle;
3218 if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
3219 active_vehicle.u.vehicle=NULL;
3221 return active_vehicle.u.vehicle == vehicle;
3225 save_vehicle_xml(struct vehicle *v)
3228 struct attr_iter *iter=vehicle_attr_iter_new();
3232 while (vehicle_get_attr(v, attr_any_xml, &attr, iter)) {
3233 if (attr_type_begin(attr.type) == attr_type_object_begin)
3236 printf(" %s=\"%s\"",attr_to_name(attr.type),attr_to_text(&attr, NULL, 1));
3240 printf("</vehicle>\n");
3243 vehicle_attr_iter_destroy(iter);
3248 * Reacts to a button press that changes a vehicle's active profile.
3250 * @see gui_internal_add_vehicle_profile
3253 gui_internal_cmd_set_active_profile(struct gui_priv *this, struct
3254 widget *wm, void *data)
3256 struct vehicle_and_profilename *vapn = data;
3257 struct vehicle *v = vapn->vehicle;
3258 char *profilename = vapn->profilename;
3259 struct attr vehicle_name_attr;
3260 char *vehicle_name = NULL;
3262 // Get the vehicle name
3263 vehicle_get_attr(v, attr_name, &vehicle_name_attr, NULL);
3264 vehicle_name = vehicle_name_attr.u.str;
3266 dbg(0, "Changing vehicle %s to profile %s\n", vehicle_name,
3269 // Change the profile name
3270 struct attr profilename_attr = {attr_profilename, {profilename}};
3271 if(!vehicle_set_attr(v, &profilename_attr, NULL)) {
3272 dbg(0, "Unable to set the vehicle's profile name\n");
3275 // Notify Navit that the routing should be re-done if this is the
3277 if(gui_internal_is_active_vehicle(this, v)) {
3278 struct attr vehicle = {attr_vehicle, {v}};
3279 navit_set_attr(this->nav, &vehicle);
3281 save_vehicle_xml(v);
3287 * Adds the vehicle profile to the GUI, allowing the user to pick a
3288 * profile for the currently selected vehicle.
3291 gui_internal_add_vehicle_profile(struct gui_priv *this, struct widget
3292 *parent, struct vehicle *v, struct vehicleprofile *profile)
3294 // Just here to show up in the translation file, nice and close to
3295 // where the translations are actually used.
3296 struct attr profile_attr;
3297 struct attr *attr = NULL;
3299 char *active_profile = NULL;
3302 struct vehicle_and_profilename *context = NULL;
3304 static char *__profile_translations[] = {
3305 _n("car"), _n("bike"), _n("pedestrian")
3308 // Figure out the profile name
3309 attr = attr_search(profile->attrs, NULL, attr_name);
3312 // Determine whether the profile is the active one
3313 vehicle_get_attr(v, attr_profilename, &profile_attr, NULL);
3314 active_profile = profile_attr.u.str;
3315 active = strcmp(name, active_profile) == 0;
3317 dbg(0, "Adding vehicle profile %s, active=%s/%i\n", name,
3318 active_profile, active);
3320 // Build a translatable label.
3322 label = g_strdup_printf(_("Current profile: %s"), _(name));
3324 label = g_strdup_printf(_("Change profile to: %s"), _(name));
3327 // Create the context object (the vehicle and the desired profile)
3328 context = g_new0(struct vehicle_and_profilename, 1);
3329 context->vehicle = v;
3330 context->profilename = name;
3333 gui_internal_widget_append(parent,
3334 gui_internal_button_new_with_callback(
3336 image_new_xs(this, active ? "gui_active" : "gui_inactive"),
3337 gravity_left_center|orientation_horizontal|flags_fill,
3338 gui_internal_cmd_set_active_profile, context));
3344 gui_internal_cmd_vehicle_settings(struct gui_priv *this, struct widget *wm, void *data)
3346 struct widget *w,*wb;
3348 struct vehicle *v=wm->data;
3349 struct vehicleprofile *profile = NULL;
3351 wb=gui_internal_menu(this, wm->text);
3352 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
3353 gui_internal_widget_append(wb, w);
3355 // Add the "Set as active" button if this isn't the active
3357 if (!gui_internal_is_active_vehicle(this, v)) {
3358 gui_internal_widget_append(w,
3359 gui_internal_button_new_with_callback(this, _("Set as active"),
3360 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
3361 gui_internal_cmd_set_active_vehicle, wm->data));
3364 if (vehicle_get_attr(v, attr_position_sat_item, &attr, NULL)) {
3365 gui_internal_widget_append(w,
3366 gui_internal_button_new_with_callback(this, _("Show Satellite status"),
3367 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
3368 gui_internal_cmd_show_satellite_status, wm->data));
3370 if (vehicle_get_attr(v, attr_position_nmea, &attr, NULL)) {
3371 gui_internal_widget_append(w,
3372 gui_internal_button_new_with_callback(this, _("Show NMEA data"),
3373 image_new_xs(this, "gui_active"), gravity_left_center|orientation_horizontal|flags_fill,
3374 gui_internal_cmd_show_nmea_data, wm->data));
3377 // Add all the possible vehicle profiles to the menu
3378 GList *profiles = navit_get_vehicleprofiles(this->nav);
3380 profile = (struct vehicleprofile *)profiles->data;
3381 gui_internal_add_vehicle_profile(this, w, v, profile);
3382 profiles = g_list_next(profiles);
3385 callback_list_call_attr_2(this->cbl, attr_vehicle, w, wm->data);
3386 gui_internal_menu_render(this);
3390 gui_internal_cmd_vehicle(struct gui_priv *this, struct widget *wm, void *data)
3392 struct attr attr,vattr;
3393 struct widget *w,*wb,*wl;
3394 struct attr_iter *iter;
3395 struct attr active_vehicle;
3398 wb=gui_internal_menu(this, _("Vehicle"));
3399 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
3400 w->spy=this->spacing*3;
3401 gui_internal_widget_append(wb, w);
3402 if (!navit_get_attr(this->nav, attr_vehicle, &active_vehicle, NULL))
3403 active_vehicle.u.vehicle=NULL;
3404 iter=navit_attr_iter_new();
3405 while(navit_get_attr(this->nav, attr_vehicle, &attr, iter)) {
3406 vehicle_get_attr(attr.u.vehicle, attr_name, &vattr, NULL);
3407 wl=gui_internal_button_new_with_callback(this, vattr.u.str,
3408 image_new_l(this, attr.u.vehicle == active_vehicle.u.vehicle ? "gui_active" : "gui_inactive"), gravity_left_center|orientation_horizontal|flags_fill,
3409 gui_internal_cmd_vehicle_settings, attr.u.vehicle);
3410 wl->text=g_strdup(vattr.u.str);
3411 gui_internal_widget_append(w, wl);
3413 navit_attr_iter_destroy(iter);
3414 gui_internal_menu_render(this);
3419 gui_internal_cmd_rules(struct gui_priv *this, struct widget *wm, void *data)
3421 struct widget *wb,*w;
3423 wb=gui_internal_menu(this, _("Rules"));
3424 w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
3425 w->spy=this->spacing*3;
3426 gui_internal_widget_append(wb, w);
3429 on.type=off.type=attr_tracking;
3430 gui_internal_widget_append(w,
3431 gui_internal_button_navit_attr_new(this, _("Lock on road"), gravity_left_center|orientation_horizontal|flags_fill,
3435 on.type=off.type=attr_orientation;
3436 gui_internal_widget_append(w,
3437 gui_internal_button_navit_attr_new(this, _("Northing"), gravity_left_center|orientation_horizontal|flags_fill,
3441 on.type=off.type=attr_follow_cursor;
3442 gui_internal_widget_append(w,
3443 gui_internal_button_navit_attr_new(this, _("Map follows Vehicle"), gravity_left_center|orientation_horizontal|flags_fill,
3445 gui_internal_menu_render(this);
3449 gui_internal_cmd_settings(struct gui_priv *this, struct widget *wm, void *data)
3453 w=gui_internal_menu(this, _("Settings"));
3454 gui_internal_widget_append(w,
3455 gui_internal_button_new_with_callback(this, _("Display"),
3456 image_new_l(this, "gui_display"), gravity_center|orientation_vertical,
3457 gui_internal_cmd_display, NULL));
3458 gui_internal_widget_append(w,
3459 gui_internal_button_new_with_callback(this, _("Maps"),
3460 image_new_l(this, "gui_maps"), gravity_center|orientation_vertical,
3461 gui_internal_cmd_maps, NULL));
3462 gui_internal_widget_append(w,
3463 gui_internal_button_new_with_callback(this, _("Vehicle"),
3464 image_new_l(this, "gui_vehicle"), gravity_center|orientation_vertical,
3465 gui_internal_cmd_vehicle, NULL));
3466 gui_internal_widget_append(w,
3467 gui_internal_button_new_with_callback(this, _("Rules"),
3468 image_new_l(this, "gui_rules"), gravity_center|orientation_vertical,
3469 gui_internal_cmd_rules, NULL));
3470 gui_internal_menu_render(this);
3473 //##############################################################################################################
3476 //# Authors: Martin Schaller (04/2008)
3477 //##############################################################################################################
3478 static void gui_internal_motion(void *data, struct point *p)
3481 struct gui_priv *this=data;
3482 if (!this->root.children) {
3483 navit_handle_motion(this->nav, p);
3489 if(!this->motion_timeout_callback)
3490 this->motion_timeout_callback=callback_new_1(callback_cast(gui_internal_highlight), this);
3491 if(!this->motion_timeout_event)
3492 this->motion_timeout_event=event_add_timeout(100,0, this->motion_timeout_callback);
3496 static void gui_internal_menu_root(struct gui_priv *this)
3500 graphics_draw_mode(this->gra, draw_mode_begin);
3501 w=gui_internal_menu(this, _("Main menu"));
3502 w->spx=this->spacing*10;
3503 gui_internal_widget_append(w, gui_internal_button_new_with_callback(this, _("Actions"),
3504 image_new_l(this, "gui_actions"), gravity_center|orientation_vertical,
3505 gui_internal_cmd_actions, NULL));
3506 if (this->flags & 2) {
3507 gui_internal_widget_append(w, gui_internal_button_new_with_callback(this, _("Show\nMap"),
3508 image_new_l(this, "gui_map"), gravity_center|orientation_vertical,
3509 gui_internal_cmd_settings, NULL));
3511 gui_internal_widget_append(w, gui_internal_button_new_with_callback(this, _("Settings"),
3512 image_new_l(this, "gui_settings"), gravity_center|orientation_vertical,
3513 gui_internal_cmd_settings, NULL));
3514 gui_internal_widget_append(w, gui_internal_button_new(this, _("Tools"),
3515 image_new_l(this, "gui_tools"), gravity_center|orientation_vertical));
3517 gui_internal_widget_append(w, gui_internal_button_new_with_callback(this, _("Route"),
3518 image_new_l(this, "gui_settings"), gravity_center|orientation_vertical,
3519 gui_internal_cmd_route, NULL));
3522 callback_list_call_attr_1(this->cbl, attr_gui, w);
3524 gui_internal_menu_render(this);
3525 graphics_draw_mode(this->gra, draw_mode_end);
3529 gui_internal_enter(struct gui_priv *this, int ignore)
3531 struct graphics *gra=this->gra;
3532 this->ignore_button=ignore;
3533 this->clickp_valid=this->vehicle_valid=0;
3535 navit_block(this->nav, 1);
3536 graphics_overlay_disable(gra, 1);
3539 this->root.background=this->background;
3543 gui_internal_leave(struct gui_priv *this)
3545 graphics_draw_mode(this->gra, draw_mode_end);
3549 gui_internal_cmd_menu(struct gui_priv *this, struct point *p, int ignore)
3551 struct transformation *trans;
3553 struct attr attr,attrp;
3556 gui_internal_enter(this, ignore);
3557 trans=navit_get_trans(this->nav);
3559 transform_reverse(trans, p, &c);
3560 dbg(0,"x=0x%x y=0x%x\n", c.x, c.y);
3561 this->clickp.pro=transform_get_projection(trans);
3564 this->clickp_valid=1;
3566 if (navit_get_attr(this->nav, attr_vehicle, &attr, NULL) && attr.u.vehicle
3567 && vehicle_get_attr(attr.u.vehicle, attr_position_coord_geo, &attrp, NULL)) {
3568 this->vehiclep.pro=transform_get_projection(trans);
3569 transform_from_geo(this->vehiclep.pro, attrp.u.coord_geo, &c);
3570 this->vehiclep.x=c.x;
3571 this->vehiclep.y=c.y;
3572 this->vehicle_valid=1;
3575 gui_internal_menu_root(this);
3579 gui_internal_cmd_menu2(struct gui_priv *this)
3581 gui_internal_cmd_menu(this, NULL, 1);
3586 gui_internal_cmd_log_do(struct gui_priv *this, struct widget *widget)
3588 if (widget->text && strlen(widget->text))
3589 navit_textfile_debug_log(this->nav, "type=log_entry label=\"%s\"",widget->text);
3590 g_free(widget->text);
3592 gui_internal_prune_menu(this, NULL);
3593 gui_internal_check_exit(this);
3597 gui_internal_cmd_log_clicked(struct gui_priv *this, struct widget *widget, void *data)
3599 gui_internal_cmd_log_do(this, widget->data);
3603 gui_internal_cmd_log_changed(struct gui_priv *this, struct widget *wm, void *data)
3607 len=strlen(wm->text);
3608 if (len && (wm->text[len-1] == '\n' || wm->text[len-1] == '\r')) {
3609 wm->text[len-1]='\0';
3610 gui_internal_cmd_log_do(this, wm);
3617 gui_internal_cmd_log(struct gui_priv *this)
3619 struct widget *w,*wb,*wk,*wl,*we,*wnext;
3620 gui_internal_enter(this, 1);
3621 wb=gui_internal_menu(this, "Log Message");
3622 w=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
3623 gui_internal_widget_append(wb, w);
3624 we=gui_internal_box_new(this, gravity_left_center|orientation_horizontal|flags_fill);
3625 gui_internal_widget_append(w, we);
3626 gui_internal_widget_append(we, wk=gui_internal_label_new(this, _("Message")));
3627 wk->state |= STATE_EDIT|STATE_CLEAR;
3628 wk->background=this->background;
3629 wk->flags |= flags_expand|flags_fill;
3630 wk->func = gui_internal_cmd_log_changed;
3631 gui_internal_widget_append(we, wnext=gui_internal_image_new(this, image_new_xs(this, "gui_active")));
3632 wnext->state |= STATE_SENSITIVE;
3633 wnext->func = gui_internal_cmd_log_clicked;
3635 wl=gui_internal_box_new(this, gravity_left_top|orientation_vertical|flags_expand|flags_fill);
3636 gui_internal_widget_append(w, wl);
3638 gui_internal_widget_append(w, gui_internal_keyboard(this,2));
3639 gui_internal_menu_render(this);
3640 gui_internal_leave(this);
3644 gui_internal_check_exit(struct gui_priv *this)
3646 struct graphics *gra=this->gra;
3647 if (! this->root.children) {
3648 gui_internal_search_idle_end(this);
3649 gui_internal_search_list_destroy(this);
3650 graphics_overlay_disable(gra, 0);
3651 if (!navit_block(this->nav, 0)) {
3653 navit_draw(this->nav);
3655 navit_draw_displaylist(this->nav);
3660 //##############################################################################################################
3661 //# Description: Function to handle mouse clicks and scroll wheel movement
3663 //# Authors: Martin Schaller (04/2008), Stefan Klumpp (04/2008)
3664 //##############################################################################################################
3665 static void gui_internal_button(void *data, int pressed, int button, struct point *p)
3667 struct gui_priv *this=data;
3668 struct graphics *gra=this->gra;
3670 dbg(1,"enter %d %d\n", pressed, button);
3671 // if still on the map (not in the menu, yet):
3672 dbg(1,"children=%p ignore_button=%d\n",this->root.children,this->ignore_button);
3673 if (!this->root.children || this->ignore_button) {
3674 this->ignore_button=0;
3675 // check whether the position of the mouse changed during press/release OR if it is the scrollwheel
3676 if (!navit_handle_button(this->nav, pressed, button, p, NULL)) {
3677 dbg(1,"navit has handled button\n");
3680 dbg(1,"menu_on_map_click=%d\n",this->menu_on_map_click);
3681 if (this->menu_on_map_click && button == 1)
3682 gui_internal_cmd_menu(this, p, 0);
3687 // if already in the menu:
3691 gui_internal_highlight(this);
3696 graphics_draw_mode(gra, draw_mode_begin);
3697 gui_internal_call_highlighted(this);
3698 gui_internal_highlight(this);
3699 graphics_draw_mode(gra, draw_mode_end);
3700 gui_internal_check_exit(this);
3705 gui_internal_setup_gc(struct gui_priv *this)
3707 struct color cbh={0x9fff,0x9fff,0x9fff,0xffff};
3708 struct color cf={0xbfff,0xbfff,0xbfff,0xffff};
3709 struct graphics *gra=this->gra;
3711 if (this->background)
3713 this->background=graphics_gc_new(gra);
3714 this->background2=graphics_gc_new(gra);
3715 this->highlight_background=graphics_gc_new(gra);
3716 graphics_gc_set_foreground(this->highlight_background, &cbh);
3717 this->foreground=graphics_gc_new(gra);
3718 graphics_gc_set_foreground(this->foreground, &cf);
3719 this->text_background=graphics_gc_new(gra);
3720 this->text_foreground=graphics_gc_new(gra);
3721 graphics_gc_set_foreground(this->background, &this->background_color);
3722 graphics_gc_set_foreground(this->background2, &this->background2_color);
3723 graphics_gc_set_foreground(this->text_background, &this->text_background_color);
3724 graphics_gc_set_foreground(this->text_foreground, &this->text_foreground_color);
3727 //##############################################################################################################
3730 //# Authors: Martin Schaller (04/2008)
3731 //##############################################################################################################
3732 static void gui_internal_resize(void *data, int w, int h)
3734 struct gui_priv *this=data;
3736 gui_internal_setup_gc(this);
3737 if( this->root.w==w && this->root.h==h)
3742 dbg(0,"w=%d h=%d children=%p\n", w, h, this->root.children);
3743 navit_handle_resize(this->nav, w, h);
3744 if (this->root.children) {
3745 gui_internal_prune_menu(this, NULL);
3746 gui_internal_menu_root(this);
3751 gui_internal_keynav_point(struct widget *w, int dx, int dy, struct point *p)
3766 gui_internal_keynav_find_closest(struct widget *wi, struct point *p, int dx, int dy, int *distance, struct widget **result)
3768 GList *l=wi->children;
3769 if (wi->state & STATE_SENSITIVE) {
3772 gui_internal_keynav_point(wi, -dx, -dy, &wp);
3774 dist1=(wp.x-p->x)*dx;
3777 dist1=(wp.y-p->y)*dy;
3785 dbg(1,"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);
3791 if (dist1 < *distance) {
3798 struct widget *child=l->data;
3799 gui_internal_keynav_find_closest(child, p, dx, dy, distance, result);
3805 gui_internal_keynav_highlight_next(struct gui_priv *this, int dx, int dy)
3807 struct widget *result,*menu=g_list_last(this->root.children)->data;
3810 if (this->highlighted && this->highlighted_menu == g_list_last(this->root.children)->data)
3811 gui_internal_keynav_point(this->highlighted, dx, dy, &p);
3817 gui_internal_keynav_find_closest(menu, &p, 0, 0, &distance, &result);
3819 gui_internal_keynav_point(result, dx, dy, &p);
3820 dbg(1,"result origin=%p p=%d,%d\n", result, p.x, p.y);
3825 gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
3826 dbg(1,"result=%p\n", result);
3838 gui_internal_keynav_find_closest(menu, &p, dx, dy, &distance, &result);
3839 dbg(1,"wraparound result=%p\n", result);
3841 gui_internal_highlight_do(this, result);
3843 gui_internal_say(this, result, 1);
3846 //##############################################################################################################
3849 //# Authors: Martin Schaller (04/2008)
3850 //##############################################################################################################
3851 static void gui_internal_keypress(void *data, char *key)
3853 struct gui_priv *this=data;
3856 if (!this->root.children) {
3857 transform_get_size(navit_get_trans(this->nav), &w, &h);
3862 navit_set_center_screen(this->nav, &p, 1);
3864 case NAVIT_KEY_DOWN:
3867 navit_set_center_screen(this->nav, &p, 1);
3869 case NAVIT_KEY_LEFT:
3872 navit_set_center_screen(this->nav, &p, 1);
3874 case NAVIT_KEY_RIGHT:
3877 navit_set_center_screen(this->nav, &p, 1);
3879 case NAVIT_KEY_ZOOM_IN:
3880 navit_zoom_in(this->nav, 2, NULL);
3882 case NAVIT_KEY_ZOOM_OUT:
3883 navit_zoom_out(this->nav, 2, NULL);
3885 case NAVIT_KEY_RETURN:
3886 case NAVIT_KEY_MENU:
3887 gui_internal_cmd_menu(this, NULL, 0);
3892 graphics_draw_mode(this->gra, draw_mode_begin);
3894 case NAVIT_KEY_LEFT:
3895 gui_internal_keynav_highlight_next(this,-1,0);
3897 case NAVIT_KEY_RIGHT:
3898 gui_internal_keynav_highlight_next(this,1,0);
3901 gui_internal_keynav_highlight_next(this,0,-1);
3903 case NAVIT_KEY_DOWN:
3904 gui_internal_keynav_highlight_next(this,0,1);
3906 case NAVIT_KEY_BACK:
3908 case NAVIT_KEY_RETURN:
3909 if (this->highlighted && this->highlighted_menu == g_list_last(this->root.children)->data)
3910 gui_internal_call_highlighted(this);
3912 gui_internal_keypress_do(this, key);
3915 gui_internal_keypress_do(this, key);
3917 graphics_draw_mode(this->gra, draw_mode_end);
3918 gui_internal_check_exit(this);
3922 //##############################################################################################################
3925 //# Authors: Martin Schaller (04/2008)
3926 //##############################################################################################################
3927 static int gui_internal_set_graphics(struct gui_priv *this, struct graphics *gra)
3930 struct transformation *trans=navit_get_trans(this->nav);
3932 win=graphics_get_data(gra, "window");
3935 navit_ignore_graphics_events(this->nav, 1);
3938 navit_ignore_graphics_events(this->nav, 1);
3939 transform_get_size(trans, &this->root.w, &this->root.h);
3940 this->resize_cb=callback_new_attr_1(callback_cast(gui_internal_resize), attr_resize, this);
3941 graphics_add_callback(gra, this->resize_cb);
3942 this->button_cb=callback_new_attr_1(callback_cast(gui_internal_button), attr_button, this);
3943 graphics_add_callback(gra, this->button_cb);
3944 this->motion_cb=callback_new_attr_1(callback_cast(gui_internal_motion), attr_motion, this);
3945 graphics_add_callback(gra, this->motion_cb);
3946 this->keypress_cb=callback_new_attr_1(callback_cast(gui_internal_keypress), attr_keypress, this);
3947 graphics_add_callback(gra, this->keypress_cb);
3949 // set fullscreen if needed
3950 if (this->fullscreen)
3951 this->win->fullscreen(this->win, this->fullscreen != 0);
3955 static void gui_internal_disable_suspend(struct gui_priv *this)
3957 if (this->win->disable_suspend)
3958 this->win->disable_suspend(this->win);
3961 //##############################################################################################################
3964 //# Authors: Martin Schaller (04/2008)
3965 //##############################################################################################################
3966 struct gui_methods gui_internal_methods = {
3969 gui_internal_set_graphics,
3973 gui_internal_disable_suspend,
3977 gui_internal_get_data(struct gui_priv *priv, char *command, struct attr **in, struct attr ***out)
3979 struct attr private_data = (struct attr) { attr_private_data, {(void *)&priv->data}};
3981 *out=attr_generic_add_attr(*out, &private_data);
3985 gui_internal_add_callback(struct gui_priv *priv, struct callback *cb)
3987 callback_list_add(priv->cbl, cb);
3991 gui_internal_remove_callback(struct gui_priv *priv, struct callback *cb)
3993 callback_list_remove(priv->cbl, cb);
3997 static struct gui_internal_methods gui_internal_methods_ext = {
3998 gui_internal_add_callback,
3999 gui_internal_remove_callback,
4000 gui_internal_menu_render,
4007 gui_internal_get_flags(struct widget *widget)
4009 return widget->flags;
4013 gui_internal_set_flags(struct widget *widget, enum flags flags)
4015 widget->flags=flags;
4019 gui_internal_get_state(struct widget *widget)
4021 return widget->state;
4025 gui_internal_set_state(struct widget *widget, int state)
4027 widget->state=state;
4031 gui_internal_set_func(struct widget *widget, void (*func)(struct gui_priv *priv, struct widget *widget, void *data))
4037 gui_internal_set_data(struct widget *widget, void *data)
4043 gui_internal_set_default_background(struct gui_priv *this, struct widget *widget)
4045 widget->background=this->background;
4048 static struct gui_internal_widget_methods gui_internal_widget_methods = {
4049 gui_internal_widget_append,
4050 gui_internal_button_new,
4051 gui_internal_button_new_with_callback,
4052 gui_internal_box_new,
4053 gui_internal_label_new,
4054 gui_internal_image_new,
4055 gui_internal_keyboard,
4057 gui_internal_get_flags,
4058 gui_internal_set_flags,
4059 gui_internal_get_state,
4060 gui_internal_set_state,
4061 gui_internal_set_func,
4062 gui_internal_set_data,
4063 gui_internal_set_default_background,
4066 static struct command_table commands[] = {
4067 {"menu",command_cast(gui_internal_cmd_menu2)},
4068 {"fullscreen",command_cast(gui_internal_cmd_fullscreen)},
4069 {"get_data",command_cast(gui_internal_get_data)},
4070 {"log",command_cast(gui_internal_cmd_log)},
4074 //##############################################################################################################
4077 //# Authors: Martin Schaller (04/2008)
4078 //##############################################################################################################
4079 static struct gui_priv * gui_internal_new(struct navit *nav, struct gui_methods *meth, struct attr **attrs)
4081 struct gui_priv *this;
4083 *meth=gui_internal_methods;
4084 this=g_new0(struct gui_priv, 1);
4086 if ((attr=attr_search(attrs, NULL, attr_menu_on_map_click)))
4087 this->menu_on_map_click=attr->u.num;
4089 this->menu_on_map_click=1;
4090 if ((attr=attr_search(attrs, NULL, attr_callback_list))) {
4091 dbg(0,"register\n");
4092 command_add_table(attr->u.callback_list, commands, sizeof(commands)/sizeof(struct command_table), this);
4095 if( (attr=attr_search(attrs,NULL,attr_font_size)))
4097 this->config.font_size=attr->u.num;
4101 this->config.font_size=-1;
4103 if( (attr=attr_search(attrs,NULL,attr_icon_xs)))
4105 this->config.icon_xs=attr->u.num;
4109 this->config.icon_xs=-1;
4111 if( (attr=attr_search(attrs,NULL,attr_icon_l)))
4113 this->config.icon_l=attr->u.num;
4117 this->config.icon_l=-1;
4119 if( (attr=attr_search(attrs,NULL,attr_icon_s)))
4121 this->config.icon_s=attr->u.num;
4125 this->config.icon_s=-1;
4127 if( (attr=attr_search(attrs,NULL,attr_spacing)))
4129 this->config.spacing=attr->u.num;
4133 this->config.spacing=-1;
4135 if( (attr=attr_search(attrs,NULL,attr_gui_speech)))
4137 this->speech=attr->u.num;
4139 if( (attr=attr_search(attrs,NULL,attr_keyboard)))
4140 this->keyboard=attr->u.num;
4144 if( (attr=attr_search(attrs,NULL,attr_fullscreen)))
4145 this->fullscreen=attr->u.num;
4147 if( (attr=attr_search(attrs,NULL,attr_flags)))
4148 this->flags=attr->u.num;
4149 if( (attr=attr_search(attrs,NULL,attr_background_color)))
4150 this->background_color=*attr->u.color;
4152 this->background_color=(struct color){0x0,0x0,0x0,0xffff};
4153 if( (attr=attr_search(attrs,NULL,attr_background_color2)))
4154 this->background2_color=*attr->u.color;
4156 this->background2_color=(struct color){0x4141,0x4141,0x4141,0xffff};
4157 if( (attr=attr_search(attrs,NULL,attr_text_color)))
4158 this->text_foreground_color=*attr->u.color;
4160 this->text_foreground_color=(struct color){0xffff,0xffff,0xffff,0xffff};
4161 if( (attr=attr_search(attrs,NULL,attr_columns)))
4162 this->cols=attr->u.num;
4163 if( (attr=attr_search(attrs,NULL,attr_osd_configuration)))
4164 this->osd_configuration=*attr;
4166 if( (attr=attr_search(attrs,NULL,attr_pitch)))
4167 this->pitch=attr->u.num;
4170 this->data.priv=this;
4171 this->data.gui=&gui_internal_methods_ext;
4172 this->data.widget=&gui_internal_widget_methods;
4173 this->cbl=callback_list_new();
4178 //##############################################################################################################
4181 //# Authors: Martin Schaller (04/2008)
4182 //##############################################################################################################
4183 void plugin_init(void)
4185 plugin_register_gui_type("internal", gui_internal_new);
4189 * @brief Creates a new table widget.
4191 * Creates and returns a new table widget. This function will
4192 * setup next/previous buttons as children.
4194 * @param this The graphics context.
4195 * @param flags widget sizing flags.
4196 * @returns The newly created widget
4198 struct widget * gui_internal_widget_table_new(struct gui_priv * this, enum flags flags, int buttons)
4200 struct widget * widget = g_new0(struct widget,1);
4201 struct table_data * data = NULL;
4202 widget->type=widget_table;
4203 widget->flags=flags;
4204 widget->data = g_new0(struct table_data,1);
4205 widget->data_free=gui_internal_table_data_free;
4206 data = (struct table_data*)widget->data;
4210 data->next_button = gui_internal_button_new_with_callback
4211 (this,"Next",image_new_xs(this, "gui_active") ,
4212 gravity_left_center |orientation_vertical,
4213 gui_internal_table_button_next,NULL);
4214 data->next_button->data=widget;
4217 data->prev_button = gui_internal_button_new_with_callback
4219 image_new_xs(this, "gui_active")
4220 ,gravity_right_center |orientation_vertical,
4221 gui_internal_table_button_prev,NULL);
4223 data->prev_button->data=widget;
4227 data->button_box=gui_internal_box_new(this,
4228 gravity_center|orientation_horizontal);
4229 data->button_box->children=g_list_append(data->button_box->children,
4231 data->button_box->children=g_list_append(data->button_box->children,
4233 //data->button_box->background=this->background2;
4234 data->button_box->bl=this->spacing;
4235 widget->children=g_list_append(widget->children,data->button_box);
4236 gui_internal_widget_pack(this,data->button_box);
4244 * @brief Clears all the rows from the table.
4245 * This function removes all rows from a table.
4246 * New rows can later be added to the table.
4248 void gui_internal_widget_table_clear(struct gui_priv * this,struct widget * table)
4251 struct table_data * table_data = (struct table_data* ) table->data;
4253 iter = table->children;
4255 if(iter->data != table_data->button_box) {
4256 struct widget * child = (struct widget*)iter->data;
4257 gui_internal_widget_destroy(this,child);
4258 if(table->children == iter) {
4259 table->children = g_list_remove(iter,iter->data);
4260 iter=table->children;
4263 iter = g_list_remove(iter,iter->data);
4266 iter = g_list_next(iter);
4270 table_data->top_row=NULL;
4271 table_data->bottom_row=NULL;
4272 if(table_data->page_headers)
4273 g_list_free(table_data->page_headers);
4274 table_data->page_headers=NULL;
4279 * Creates a new table_row widget.
4280 * @param this The graphics context
4281 * @param flags Sizing flags for the row
4282 * @returns The new table_row widget.
4284 struct widget * gui_internal_widget_table_row_new(struct gui_priv * this, enum flags flags)
4286 struct widget * widget = g_new0(struct widget,1);
4287 widget->type=widget_table_row;
4288 widget->flags=flags;
4295 * @brief Computes the column dimensions for the table.
4297 * @param w The table widget to compute dimensions for.
4299 * This function examines all of the rows and columns for the table w
4300 * and returns a list (GList) of table_column_desc elements that
4301 * describe each column of the table.
4303 * The caller is responsible for freeing the returned list.
4305 static GList * gui_internal_compute_table_dimensions(struct gui_priv * this,struct widget * w)
4308 GList * column_desc = NULL;
4309 GList * current_desc=NULL;
4310 GList * cur_row = w->children;
4311 struct widget * cur_row_widget=NULL;
4312 GList * cur_column=NULL;
4313 struct widget * cell_w=NULL;
4314 struct table_column_desc * current_cell=NULL;
4315 struct table_data * table_data=NULL;
4322 * Scroll through the the table and
4323 * 1. Compute the maximum width + height of each column across all rows.
4325 table_data = (struct table_data*) w->data;
4326 for(cur_row=w->children; cur_row ; cur_row = g_list_next(cur_row) )
4328 cur_row_widget = (struct widget*) cur_row->data;
4329 current_desc = column_desc;
4330 if(cur_row_widget == table_data->button_box)
4335 for(cur_column = cur_row_widget->children; cur_column;
4336 cur_column=g_list_next(cur_column))
4338 cell_w = (struct widget*) cur_column->data;
4339 gui_internal_widget_pack(this,cell_w);
4340 if(current_desc == 0)
4342 current_cell = g_new0(struct table_column_desc,1);
4343 column_desc = g_list_append(column_desc,current_cell);
4344 current_desc = g_list_last(column_desc);
4345 current_cell->height=cell_w->h;
4346 current_cell->width=cell_w->w;
4347 total_width+=cell_w->w;
4352 current_cell = current_desc->data;
4355 if(current_cell->height < height )
4357 current_cell->height = height;
4359 if(current_cell->width < width)
4361 total_width += (width-current_cell->width);
4362 current_cell->width = width;
4367 current_desc = g_list_next(current_desc);
4377 * If the width of all columns is less than the width off
4378 * the table expand each cell proportionally.
4381 if(total_width+(this->spacing*column_count) < w->w ) {
4382 for(current_desc=column_desc; current_desc; current_desc=g_list_next(current_desc)) {
4383 current_cell = (struct table_column_desc*) current_desc->data;
4384 current_cell->width= ( (current_cell->width+this->spacing)/(float)total_width) * w->w ;
4393 * @brief Computes the height and width for the table.
4395 * The height and widht are computed to display all cells in the table
4396 * at the requested height/width.
4398 * @param this The graphics context
4399 * @param w The widget to pack.
4402 void gui_internal_table_pack(struct gui_priv * this, struct widget * w)
4408 GList * column_data = gui_internal_compute_table_dimensions(this,w);
4410 struct table_column_desc * cell_desc=0;
4411 struct table_data * table_data = (struct table_data*)w->data;
4413 for(current = column_data; current; current=g_list_next(current))
4415 if(table_data->button_box == current->data )
4419 cell_desc = (struct table_column_desc *) current->data;
4420 width = width + cell_desc->width + this->spacing;
4421 if(height < cell_desc->height)
4423 height = cell_desc->height ;
4429 for(current=w->children; current; current=g_list_next(current))
4431 if(current->data!= table_data->button_box)
4436 if (table_data->button_box)
4437 gui_internal_widget_pack(this,table_data->button_box);
4441 if(w->h + w->c.y > this->root.h )
4444 * Do not allow the widget to exceed the screen.
4447 w->h = this->root.h- w->c.y - height;
4452 * Deallocate column descriptions.
4454 current = column_data;
4455 while( (current = g_list_last(current)) )
4457 current = g_list_remove(current,current->data);
4465 * @brief Renders a table widget.
4467 * @param this The graphics context
4468 * @param w The table widget to render.
4470 void gui_internal_table_render(struct gui_priv * this, struct widget * w)
4475 GList * column_desc=NULL;
4476 GList * cur_row = NULL;
4477 GList * current_desc=NULL;
4478 struct table_data * table_data = (struct table_data*)w->data;
4480 int is_first_page=1;
4481 struct table_column_desc * dim=NULL;
4483 dbg_assert(table_data);
4484 column_desc = gui_internal_compute_table_dimensions(this,w);
4488 * Skip rows that are on previous pages.
4490 cur_row = w->children;
4491 if(table_data->top_row && table_data->top_row != w->children )
4493 cur_row = table_data->top_row;
4499 * Loop through each row. Drawing each cell with the proper sizes,
4500 * at the proper positions.
4502 for(table_data->top_row=cur_row; cur_row; cur_row = g_list_next(cur_row))
4504 GList * cur_column=NULL;
4505 current_desc = column_desc;
4506 struct widget * cur_row_widget = (struct widget*)cur_row->data;
4508 x =w->p.x+this->spacing;
4509 if(cur_row_widget == table_data->button_box )
4513 dim = (struct table_column_desc*)current_desc->data;
4515 if( y + dim->height + (table_data->button_box ? table_data->button_box->h : 0) + this->spacing >= w->p.y + w->h )
4518 * No more drawing space left.
4524 for(cur_column = cur_row_widget->children; cur_column;
4525 cur_column=g_list_next(cur_column))
4527 struct widget * cur_widget = (struct widget*) cur_column->data;
4528 dim = (struct table_column_desc*)current_desc->data;
4531 cur_widget->w=dim->width;
4533 cur_widget->h=dim->height;
4535 max_height = dim->height;
4536 /* We pack the widget before rendering to ensure that the x and y
4537 * coordinates get pushed down.
4539 gui_internal_widget_pack(this,cur_widget);
4540 gui_internal_widget_render(this,cur_widget);
4542 if(dim->height > max_height)
4544 max_height = dim->height;
4548 table_data->bottom_row=cur_row;
4549 current_desc = g_list_next(current_desc);
4551 if(table_data->button_box && (is_skipped || !is_first_page) )
4553 table_data->button_box->p.y =w->p.y+w->h-table_data->button_box->h -
4555 if(table_data->button_box->p.y < y )
4557 table_data->button_box->p.y=y;
4559 table_data->button_box->p.x = w->p.x;
4560 table_data->button_box->w = w->w;
4561 // table_data->button_box->h = w->h - y;
4562 // table_data->next_button->h=table_data->button_box->h;
4563 // table_data->prev_button->h=table_data->button_box->h;
4564 // table_data->next_button->c.y=table_data->button_box->c.y;
4565 // table_data->prev_button->c.y=table_data->button_box->c.y;
4567 gui_internal_widget_pack(this,table_data->button_box);
4568 if(table_data->next_button->p.y > w->p.y + w->h + table_data->next_button->h)
4571 table_data->button_box->p.y = w->p.y + w->h -
4572 table_data->button_box->h;
4576 table_data->next_button->state|= STATE_SENSITIVE;
4580 table_data->next_button->state&= ~STATE_SENSITIVE;
4583 if(table_data->top_row != w->children)
4585 table_data->prev_button->state|= STATE_SENSITIVE;
4589 table_data->prev_button->state&= ~STATE_SENSITIVE;
4591 gui_internal_widget_render(this,table_data->button_box);
4597 * Deallocate column descriptions.
4599 current_desc = column_desc;
4600 while( (current_desc = g_list_last(current_desc)) )
4602 current_desc = g_list_remove(current_desc,current_desc->data);
4608 * @brief Displays Route information
4610 * @li The name of the active vehicle
4611 * @param wm The button that was pressed.
4615 gui_internal_cmd_route_description(struct gui_priv * this, struct widget * wm,void *v)
4619 struct widget * menu;
4620 struct widget * row;
4623 if(! this->vehicle_cb)
4626 * Register the callback on vehicle updates.
4628 this->vehicle_cb = callback_new_attr_1(callback_cast(gui_internal_route_update),
4629 attr_position_coord_geo,this);
4630 navit_add_callback(this->nav,this->vehicle_cb);
4633 this->route_data.route_table = gui_internal_widget_table_new(this,gravity_left_top | flags_fill | flags_expand |orientation_vertical,1);
4634 row = gui_internal_widget_table_row_new(this,gravity_left | orientation_horizontal | flags_fill);
4636 row = gui_internal_widget_table_row_new(this,gravity_left | orientation_horizontal | flags_fill);
4639 menu=gui_internal_menu(this,_("Route Description"));
4641 menu->free=gui_internal_route_screen_free;
4642 this->route_data.route_showing=1;
4643 this->route_data.route_table->spx = this->spacing;
4646 struct widget * box = gui_internal_box_new(this, gravity_left_top| orientation_vertical | flags_fill | flags_expand);
4648 // gui_internal_widget_append(box,gui_internal_box_new_with_label(this,"Test"));
4649 gui_internal_widget_append(box,this->route_data.route_table);
4651 box->spx = this->spacing;
4652 this->route_data.route_table->w=box->w;
4653 gui_internal_widget_append(menu,box);
4654 gui_internal_populate_route_table(this,this->nav);
4655 gui_internal_menu_render(this);
4660 line_intersection(struct coord* a1, struct coord *a2, struct coord * b1, struct coord *b2, struct coord *res)
4663 int adx=a2->x-a1->x;
4664 int ady=a2->y-a1->y;
4665 int bdx=b2->x-b1->x;
4666 int bdy=b2->y-b1->y;
4667 n = bdy * adx - bdx * ady;
4668 a = bdx * (a1->y - b1->y) - bdy * (a1->x - b1->x);
4669 b = adx * (a1->y - b1->y) - ady * (a1->x - b1->x);
4680 dbg(0,"a=%d b=%d n=%d\n", a, b, n);
4681 dbg(0,"a1=0x%x,0x%x ad %d,%d\n", a1->x, a1->y, adx, ady);
4682 dbg(0,"b1=0x%x,0x%x bd %d,%d\n", b1->x, b1->y, bdx, bdy);
4685 res->x = a1->x + a * adx / n;
4686 res->y = a1->y + a * ady / n;
4691 struct heightline *next;
4693 struct coord_rect bbox;
4698 struct diagram_point {
4699 struct diagram_point *next;
4703 static struct heightline *
4704 item_get_heightline(struct item *item)
4706 struct heightline *ret=NULL;
4707 struct street_data *sd;
4711 if (item_attr_get(item, attr_label, &attr)) {
4712 height=atoi(attr.u.str);
4713 sd=street_get_data(item);
4714 if (sd && sd->count > 1) {
4715 ret=g_malloc(sizeof(struct heightline)+sd->count*sizeof(struct coord));
4716 ret->bbox.lu=sd->c[0];
4717 ret->bbox.rl=sd->c[0];
4718 ret->count=sd->count;
4720 for (i = 0 ; i < sd->count ; i++) {
4722 coord_rect_extend(&ret->bbox, sd->c+i);
4725 street_data_free(sd);
4732 * @brief Displays Route Height Profile
4734 * @li The name of the active vehicle
4735 * @param wm The button that was pressed.
4738 static void gui_internal_cmd_route_height_profile(struct gui_priv * this, struct widget * wm,void *v)
4742 struct widget * menu, *box;
4744 struct map * map=NULL;
4745 struct map_rect * mr=NULL;
4746 struct route * route;
4747 struct item * item =NULL;
4749 struct mapset_handle *msh;
4750 int x,i,first=1,dist=0;
4751 struct coord c,last,res;
4752 struct coord_rect rbbox,dbbox;
4753 struct map_selection sel;
4754 struct heightline *heightline,*heightlines=NULL;
4755 struct diagram_point *min,*diagram_point,*diagram_points=NULL;
4758 sel.range.min=type_height_line_1;
4759 sel.range.max=type_height_line_3;
4762 menu=gui_internal_menu(this,_("Height Profile"));
4763 box = gui_internal_box_new(this, gravity_left_top| orientation_vertical | flags_fill | flags_expand);
4764 gui_internal_widget_append(menu, box);
4765 route = navit_get_route(this->nav);
4767 map = route_get_map(route);
4769 mr = map_rect_new(map,NULL);
4771 while((item = map_rect_get_item(mr))) {
4772 while (item_coord_get(item, &c, 1)) {
4778 coord_rect_extend(&sel.u.c_rect, &c);
4781 map_rect_destroy(mr);
4782 ms=navit_get_mapset(this->nav);
4784 msh=mapset_open(ms);
4785 while ((map=mapset_next(msh, 1))) {
4786 mr=map_rect_new(map, &sel);
4788 while((item = map_rect_get_item(mr))) {
4789 if (item->type >= sel.range.min && item->type <= sel.range.max) {
4790 heightline=item_get_heightline(item);
4792 heightline->next=heightlines;
4793 heightlines=heightline;
4797 map_rect_destroy(mr);
4806 map = route_get_map(route);
4808 mr = map_rect_new(map,NULL);
4809 if(mr && heightlines) {
4810 while((item = map_rect_get_item(mr))) {
4812 while (item_coord_get(item, &c, 1)) {
4816 heightline=heightlines;
4819 coord_rect_extend(&rbbox, &c);
4820 while (heightline) {
4821 if (coord_rect_overlap(&rbbox, &heightline->bbox)) {
4822 for (i = 0 ; i < heightline->count - 1; i++) {
4823 if (heightline->c[i].x != heightline->c[i+1].x || heightline->c[i].y != heightline->c[i+1].y) {
4824 if (line_intersection(heightline->c+i, heightline->c+i+1, &last, &c, &res)) {
4825 diagram_point=g_new(struct diagram_point, 1);
4826 diagram_point->c.x=dist+transform_distance(projection_mg, &last, &res);
4827 diagram_point->c.y=heightline->height;
4828 diagram_point->next=diagram_points;
4829 diagram_points=diagram_point;
4830 dbg(0,"%d %d\n", diagram_point->c.x, diagram_point->c.y);
4835 heightline=heightline->next;
4837 dist+=transform_distance(projection_mg, &last, &c);
4843 map_rect_destroy(mr);
4847 gui_internal_menu_render(this);
4849 diagram_point=diagram_points;
4850 while (diagram_point) {
4852 dbbox.lu=diagram_point->c;
4853 dbbox.rl=diagram_point->c;
4856 coord_rect_extend(&dbbox, &diagram_point->c);
4857 diagram_point=diagram_point->next;
4859 dbg(0,"%d %d %d %d\n", dbbox.lu.x, dbbox.lu.y, dbbox.rl.x, dbbox.rl.y);
4860 if (dbbox.rl.x > dbbox.lu.x && dbbox.lu.x*100/(dbbox.rl.x-dbbox.lu.x) <= 25)
4862 if (dbbox.lu.y > dbbox.rl.y && dbbox.rl.y*100/(dbbox.lu.y-dbbox.rl.y) <= 25)
4864 dbg(0,"%d,%d %dx%d\n", box->p.x, box->p.y, box->w, box->h);
4870 diagram_point=diagram_points;
4871 while (diagram_point) {
4872 if (diagram_point->c.x >= x && (!min || min->c.x > diagram_point->c.x))
4874 diagram_point=diagram_point->next;
4878 p[1].x=(min->c.x-dbbox.lu.x)*(box->w-10)/(dbbox.rl.x-dbbox.lu.x)+box->p.x+5;
4879 p[1].y=(min->c.y-dbbox.rl.y)*(box->h-10)/(dbbox.lu.y-dbbox.rl.y)+box->p.y+5;
4880 dbg(0,"%d,%d=%d,%d\n",min->c.x, min->c.y, p[1].x,p[1].y);
4881 graphics_draw_circle(this->gra, this->foreground, &p[1], 2);
4885 graphics_draw_lines(this->gra, this->foreground, p, 2);
4894 * @brief Displays Route information
4896 * @li The name of the active vehicle
4897 * @param wm The button that was pressed.
4900 void gui_internal_cmd_route(struct gui_priv * this, struct widget * wm,void *v)
4904 graphics_draw_mode(this->gra, draw_mode_begin);
4905 w=gui_internal_menu(this, _("Route"));
4906 w->spx=this->spacing*10;
4907 gui_internal_widget_append(w, gui_internal_button_new_with_callback(this, _("Description"),
4908 image_new_l(this, "gui_actions"), gravity_center|orientation_vertical,
4909 gui_internal_cmd_route_description, NULL));
4910 gui_internal_widget_append(w, gui_internal_button_new_with_callback(this, _("Height Profile"),
4911 image_new_l(this, "gui_actions"), gravity_center|orientation_vertical,
4912 gui_internal_cmd_route_height_profile, NULL));
4913 gui_internal_menu_render(this);
4914 gui_internal_menu_render(this);
4915 graphics_draw_mode(this->gra, draw_mode_end);
4922 * @brief handles the 'next page' table event.
4923 * A callback function that is invoked when the 'next page' button is pressed
4924 * to advance the contents of a table widget.
4926 * @param this The graphics context.
4927 * @param wm The button widget that was pressed.
4929 static void gui_internal_table_button_next(struct gui_priv * this, struct widget * wm, void *data)
4931 struct widget * table_widget = (struct widget * ) wm->data;
4932 struct table_data * table_data = NULL;
4938 table_data = (struct table_data*) table_widget->data;
4944 * Before advancing to the next page we need to ensure
4945 * that the current top_row is in the list of previous top_rows
4946 * so previous page can work.
4949 for(iterator=table_data->page_headers; iterator != NULL;
4950 iterator = g_list_next(iterator) )
4952 if(iterator->data == table_data->top_row)
4961 table_data->page_headers=g_list_append(table_data->page_headers,
4962 table_data->top_row);
4965 table_data->top_row = g_list_next(table_data->bottom_row);
4967 wm->state&= ~STATE_HIGHLIGHTED;
4968 gui_internal_menu_render(this);
4974 * @brief handles the 'previous page' table event.
4975 * A callback function that is invoked when the 'previous page' button is pressed
4976 * to go back in the contents of a table widget.
4978 * @param this The graphics context.
4979 * @param wm The button widget that was pressed.
4981 static void gui_internal_table_button_prev(struct gui_priv * this, struct widget * wm, void *data)
4983 struct widget * table_widget = (struct widget * ) wm->data;
4984 struct table_data * table_data = NULL;
4985 GList * current_page_top=NULL;
4990 table_data = (struct table_data*) table_widget->data;
4993 current_page_top = table_data->top_row;
4994 for(iterator = table_data->page_headers; iterator != NULL;
4995 iterator = g_list_next(iterator))
4997 if(current_page_top == iterator->data)
5001 table_data->top_row = (GList*) iterator->data;
5005 wm->state&= ~STATE_HIGHLIGHTED;
5006 gui_internal_menu_render(this);
5011 * @brief deallocates a table_data structure.
5014 void gui_internal_table_data_free(void * p)
5019 * @note button_box and its children (next_button,prev_button)
5020 * have their memory managed by the table itself.
5022 struct table_data * table_data = (struct table_data*) p;
5023 g_list_free(table_data->page_headers);
5031 * @brief Called when the route is updated.
5033 void gui_internal_route_update(struct gui_priv * this, struct navit * navit, struct vehicle *v)
5036 if(this->route_data.route_showing) {
5037 gui_internal_populate_route_table(this,navit);
5038 graphics_draw_mode(this->gra, draw_mode_begin);
5039 gui_internal_menu_render(this);
5040 graphics_draw_mode(this->gra, draw_mode_end);
5048 * @brief Called when the route screen is closed (deallocated).
5050 * The main purpose of this function is to remove the widgets from
5051 * references route_data because those widgets are about to be freed.
5053 void gui_internal_route_screen_free(struct gui_priv * this_,struct widget * w)
5056 this_->route_data.route_showing=0;
5057 this_->route_data.route_table=NULL;
5064 * @brief Populates the route table with route information
5066 * @param this The gui context
5067 * @param navit The navit object
5069 void gui_internal_populate_route_table(struct gui_priv * this,
5070 struct navit * navit)
5072 struct map * map=NULL;
5073 struct map_rect * mr=NULL;
5074 struct navigation * nav = NULL;
5075 struct item * item =NULL;
5077 struct widget * label = NULL;
5078 struct widget * row = NULL;
5079 nav = navit_get_navigation(navit);
5083 map = navigation_get_map(nav);
5085 mr = map_rect_new(map,NULL);
5087 gui_internal_widget_table_clear(this,this->route_data.route_table);
5088 while((item = map_rect_get_item(mr))) {
5089 if(item_attr_get(item,attr_navigation_long,&attr)) {
5090 label = gui_internal_label_new(this,attr.u.str);
5091 row = gui_internal_widget_table_row_new(this,
5094 | orientation_horizontal);
5095 row->children=g_list_append(row->children,label);
5096 gui_internal_widget_append(this->route_data.route_table,row);