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.
33 #include "transform.h"
34 #include "projection.h"
40 #include "navit_nls.h"
44 popup_set_no_passing(struct popup_item *item, void *param)
47 struct display_list *l=param;
48 struct segment *seg=(struct segment *)(l->data);
49 struct street_str *str=(struct street_str *)(seg->data[0]);
55 sprintf(log,"Attributes Street 0x%x updated: limit=0x%x(0x%x)", segid, 0x33, str->limit);
57 log_write(log, seg->blk_inf.file, str, sizeof(*str));
64 popup_set_destination(struct navit *nav, struct pcoord *pc)
69 char buffer_geo[1024];
72 transform_to_geo(transform_get_projection(navit_get_trans(nav)), &c, &g);
73 transform_geo_text(&g, buffer_geo);
74 sprintf(buffer,"Map Point %s", buffer_geo);
75 navit_set_destination(nav, pc, buffer);
79 popup_set_bookmark(struct navit *nav, struct pcoord *pc)
84 char buffer_geo[1024];
87 transform_to_geo(pc->pro, &c, &g);
88 transform_geo_text(&g, buffer_geo);
89 sprintf(buffer,"Map Point %s", buffer_geo);
90 if (!gui_add_bookmark(navit_get_gui(nav), pc, buffer))
91 navit_add_bookmark(nav, pc, buffer);
98 popup_set_position(struct navit *nav, struct pcoord *pc)
100 dbg(0,"%p %p\n", nav, pc);
101 navit_set_position(nav, pc);
106 popup_break_crossing(struct display_list *l)
108 struct segment *seg=(struct segment *)(l->data);
109 struct street_str *str=(struct street_str *)(seg->data[0]);
111 int segid=str->segid;
115 sprintf(log,"Coordinates Street 0x%x updated: limit=0x%x(0x%x)", segid, 0x33, str->limit);
117 log_write(log, seg->blk_inf.file, str, sizeof(*str));
122 #define popup_printf(menu, type, fmt...) popup_printf_cb(menu, type, NULL, fmt)
125 popup_printf_cb(void *menu, enum menu_type type, struct callback *cb, const char *fmt, ...)
132 str=g_strdup_vprintf(fmt, ap);
134 ret=menu_add(menu, str, type, cb);
141 popup_show_attr_val(struct map *map, void *menu, struct attr *attr)
143 char *attr_name=attr_to_name(attr->type);
146 str=attr_to_text(attr, map, 1);
147 popup_printf(menu, menu_type_menu, "%s: %s", attr_name, str);
153 popup_show_attr(void *menu, struct item *item, enum attr_type attr_type)
156 memset(&attr, 0, sizeof(attr));
158 if (item_attr_get(item, attr_type, &attr))
159 popup_show_attr_val(menu, &attr);
164 popup_show_attrs(struct map *map, void *menu, struct item *item)
167 popup_show_attr(menu, item, attr_debug);
168 popup_show_attr(menu, item, attr_address);
169 popup_show_attr(menu, item, attr_phone);
170 popup_show_attr(menu, item, attr_phone);
171 popup_show_attr(menu, item, attr_entry_fee);
172 popup_show_attr(menu, item, attr_open_hours);
176 memset(&attr, 0, sizeof(attr));
177 if (item_attr_get(item, attr_any, &attr))
178 popup_show_attr_val(map, menu, &attr);
187 popup_show_item(struct navit *nav, void *popup, struct displayitem *di)
190 void *menu, *menu_map, *menu_item;
194 label=graphics_displayitem_get_label(di);
195 item=graphics_displayitem_get_item(di);
198 menu=popup_printf(popup, menu_type_submenu, "%s '%s'", item_to_name(item->type), label);
200 menu=popup_printf(popup, menu_type_submenu, "%s", item_to_name(item->type));
201 menu_item=popup_printf(menu, menu_type_submenu, "Item");
202 popup_printf(menu_item, menu_type_menu, "type: 0x%x", item->type);
203 popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", item->id_hi, item->id_lo);
205 mr=map_rect_new(item->map,NULL);
206 item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
207 dbg(1,"item=%p\n", item);
209 popup_show_attrs(item->map, menu_item, item);
210 if (item->type < type_line) {
213 if (item_coord_get(item, &co, 1)) {
214 c=g_new(struct pcoord, 1);
215 c->pro = transform_get_projection(navit_get_trans(nav));
218 popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, c), _("Set as position"));
219 popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, c), _("Set as destination"));
220 popup_printf_cb(menu_item, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, c), _("Add as bookmark"));
224 map_rect_destroy(mr);
225 menu_map=popup_printf(menu, menu_type_submenu, "Map");
227 popup_printf(menu, menu_type_menu, "(No map)");
232 popup_display(struct navit *nav, void *popup, struct point *p)
234 struct displaylist_handle *dlh;
235 struct displaylist *display;
236 struct displayitem *di;
238 display=navit_get_displaylist(nav);
239 dlh=graphics_displaylist_open(display);
240 while ((di=graphics_displaylist_next(dlh))) {
241 if (graphics_displayitem_within_dist(di, p, 5)) {
242 popup_show_item(nav, popup, di);
245 graphics_displaylist_close(dlh);
248 static struct pcoord c;
251 popup(struct navit *nav, int button, struct point *p)
258 popup=gui_popup_new(navit_get_gui(nav));
261 transform_reverse(navit_get_trans(nav), p, &co);
262 men=popup_printf(popup, menu_type_submenu, _("Point 0x%x 0x%x"), co.x, co.y);
263 popup_printf(men, menu_type_menu, _("Screen coord : %d %d"), p->x, p->y);
264 transform_to_geo(transform_get_projection(navit_get_trans(nav)), &co, &g);
265 transform_geo_text(&g, buffer);
266 popup_printf(men, menu_type_menu, "%s", buffer);
267 popup_printf(men, menu_type_menu, "%f %f", g.lat, g.lng);
268 dbg(0,"%p %p\n", nav, &c);
269 c.pro = transform_get_projection(navit_get_trans(nav));
272 popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, &c), _("Set as position"));
273 popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, &c), _("Set as destination"));
274 popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, &c), _("Add as bookmark"));
275 popup_display(nav, popup, p);