ATTR(zoom)
ATTR(retry_interval)
ATTR(projection)
+ATTR(offroad)
+ATTR(vocabulary_name)
+ATTR(vocabulary_name_systematic)
+ATTR(vocabulary_distances)
+ATTR(announce_name_systematic_first)
ATTR2(0x00028000,type_boolean_begin)
/* boolean */
ATTR(overwrite)
};
struct navigation {
- struct mapset *ms;
struct map *map;
struct item_hash *hash;
struct navigation_itm *first;
};
struct navigation *
-navigation_new(struct mapset *ms)
+navigation_new(struct attr **attrs)
{
int i,j;
struct navigation *ret=g_new0(struct navigation, 1);
- ret->ms=ms;
ret->hash=item_hash_new();
ret->callback=callback_list_new();
ret->callback_speech=callback_list_new();
return ret;
}
-void
-navigation_set_mapset(struct navigation *this_, struct mapset *ms)
-{
- this_->ms=ms;
-}
-
int
navigation_set_announce(struct navigation *this_, enum item_type type, int *level)
{
/* prototypes */
enum attr_type;
enum item_type;
+struct attr;
struct callback;
struct map;
-struct mapset;
struct navigation;
struct route;
-struct navigation *navigation_new(struct mapset *ms);
-void navigation_set_mapset(struct navigation *this_, struct mapset *ms);
+struct navigation *navigation_new(struct attr **attrs);
int navigation_set_announce(struct navigation *this_, enum item_type type, int *level);
void navigation_update(struct navigation *this_, struct route *route);
void navigation_flush(struct navigation *this_);
mapset_add(ms, map);
map_set_active(map, 0);
}
- navigation_set_mapset(this_->navigation, ms);
}
navit_add_bookmarks_from_file(this_);
navit_add_former_destinations_from_file(this_);
return navit_set_gui(this_, attr->u.gui);
case attr_graphics:
return navit_set_graphics(this_, attr->u.graphics);
+ case attr_route:
+ this_->route=attr->u.route;
+ route_set_projection(this_->route, transform_get_projection(this_->trans));
+ break;
+ case attr_navigation:
+ this_->navigation=attr->u.navigation;
+ break;
default:
return 0;
}
}
void
-navit_route_add(struct navit *this_, struct route *route)
-{
- this_->route=route;
- route_set_projection(route, transform_get_projection(this_->trans));
-}
-
-void
-navit_navigation_add(struct navit *this_, struct navigation *navigation)
-{
- this_->navigation=navigation;
-}
-
-void
navit_set_speech(struct navit *this_, struct speech *speech)
{
this_->speech=speech;
}
static void
-popup_show_item(void *popup, struct displayitem *di)
+popup_show_item(struct navit *nav, void *popup, struct displayitem *di)
{
struct map_rect *mr;
void *menu, *menu_map, *menu_item;
dbg(1,"item=%p\n", item);
if (item) {
popup_show_attrs(item->map, menu_item, item);
+ if (item->type < type_line) {
+ struct coord co;
+ struct pcoord *c;
+ if (item_coord_get(item, &co, 1)) {
+ c=g_new(struct pcoord, 1);
+ c->pro = transform_get_projection(navit_get_trans(nav));
+ c->x = co.x;
+ c->y = co.y;
+ popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, c), _("Set as position"));
+ popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, c), _("Set as destination"));
+ popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, c), _("Add as bookmark"));
+ }
+ }
}
map_rect_destroy(mr);
menu_map=popup_printf(menu, menu_type_submenu, "Map");
dlh=graphics_displaylist_open(display);
while ((di=graphics_displaylist_next(dlh))) {
if (graphics_displayitem_within_dist(di, p, 5)) {
- popup_show_item(popup, di);
+ popup_show_item(nav, popup, di);
}
}
graphics_displaylist_close(dlh);
}
struct route *
-route_new(struct mapset *ms)
+route_new(struct attr **attrs)
{
struct route *this=g_new0(struct route, 1);
if (!this) {
printf("%s:Out of memory\n", __FUNCTION__);
return NULL;
}
- this->ms=ms;
return this;
}
struct street_data;
struct tracking;
struct transformation;
-struct route *route_new(struct mapset *ms);
+struct route *route_new(struct attr **attrs);
void route_set_mapset(struct route *this, struct mapset *ms);
struct mapset *route_get_mapset(struct route *this);
struct route_info *route_get_pos(struct route *this);
attrs=convert_to_attrs(state);
state->element_object = graphics_new(type, attrs);
if (! state->element_object) {
- dbg(0,"Failed to create graphics '%s'\n", type);
+ dbg(0,"Failed to create graphics object '%s'\n", type);
return 0;
}
graphics_attr.type=attr_graphics;
attrs=convert_to_attrs(state);
state->element_object = gui_new(state->parent->element_object, type, attrs);
if (! state->element_object) {
- dbg(0,"Failed to create gui '%s'\n", type);
+ dbg(0,"Failed to create gui object '%s'\n", type);
return 0;
}
gui_attr.type=attr_gui;
static int
xmlconfig_route(struct xmlstate *state)
{
- state->element_object = route_new(NULL);
- navit_route_add(state->parent->element_object, state->element_object);
- return 1;
+ struct attr **attrs;
+ struct attr route_attr;
+
+ attrs=convert_to_attrs(state);
+ state->element_object = route_new(attrs);
+ if (! state->element_object) {
+ dbg(0,"Failed to create route object\n");
+ return 0;
+ }
+ route_attr.type=attr_route;
+ route_attr.u.route=state->element_object;
+ return navit_add_attr(state->parent->element_object, &route_attr, NULL);
}
static int
static int
xmlconfig_navigation(struct xmlstate *state)
{
- state->element_object = navigation_new(NULL);
- navit_navigation_add(state->parent->element_object, state->element_object);
- return 1;
+ struct attr **attrs;
+ struct attr navigation_attr;
+
+ attrs=convert_to_attrs(state);
+ state->element_object = navigation_new(attrs);
+ if (! state->element_object) {
+ dbg(0,"Failed to create navigation object\n");
+ return 0;
+ }
+ navigation_attr.type=attr_navigation;
+ navigation_attr.u.navigation=state->element_object;
+ return navit_add_attr(state->parent->element_object, &navigation_attr, NULL);
}
static int