Exemplo n.º 1
0
void
popup(struct navit *nav, int button, struct point *p)
{
	void *popup,*men;
	char buffer[1024];
	struct coord_geo g;
	struct coord co;

	popup=gui_popup_new(navit_get_gui(nav));
	transform_reverse(navit_get_trans(nav), p, &co);
	men=popup_printf(popup, menu_type_submenu, _("Point 0x%x 0x%x"), co.x, co.y);
	popup_printf(men, menu_type_menu, _("Screen %d %d"), p->x, p->y);
	transform_to_geo(transform_get_projection(navit_get_trans(nav)), &co, &g);
	transform_geo_text(&g, buffer);	
	popup_printf(men, menu_type_menu, "%s", buffer);
	popup_printf(men, menu_type_menu, "%f %f", g.lat, g.lng);
	dbg(0,"%p %p\n", nav, &c);
	c.pro = transform_get_projection(navit_get_trans(nav));
	c.x = co.x;
	c.y = co.y;
	popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_position), nav, &c), _("Set as position"));
	popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_destination), nav, &c), _("Set as destination"));
	popup_printf_cb(men, menu_type_menu, callback_new_2(callback_cast(popup_set_bookmark), nav, &c), _("Add as bookmark"));
	popup_display(nav, popup, p);
#ifdef _WIN32
	// menu needs first to be constructed before doing the menu popup
	// therefore this work around for win32
	// needs to be fixed
	popup=gui_popup_new(navit_get_gui(nav));
#endif
}
Exemplo n.º 2
0
void
bookmarks_get_center_from_file(struct bookmarks *this_, char *file, struct coord *center)
{
	FILE *f;
	char *line = NULL;

	dbg(0,"enter\n");

	size_t line_size = 0;
	enum projection pro;

	f = fopen(file, "r");
	if (! f)
		return;
	getline(&line, &line_size, f);
	fclose(f);
	if (line)
	{
		pro = transform_get_projection(this_->trans);
		coord_parse(g_strchomp(line), pro, center);
		dbg(0,"******** get center from file *********\n");
		free(line);
	}
	return;
}
Exemplo n.º 3
0
static void
popup_show_item(struct navit *nav, void *popup, struct displayitem *di)
{
	struct map_rect *mr;
	void *menu, *menu_map, *menu_item, *menu_dist;
	char *label;
	struct item *item,*diitem;
	int count;

	label=graphics_displayitem_get_label(di);
	diitem=graphics_displayitem_get_item(di);
	count=graphics_displayitem_get_coord_count(di);

	dbg_assert(diitem);

	if (label) 
		menu=popup_printf(popup, menu_type_submenu, "%s '%s' (%d coords)", item_to_name(diitem->type), label, count);
	else
		menu=popup_printf(popup, menu_type_submenu, "%s (%d coords)", item_to_name(diitem->type), count);
	menu_item=popup_printf(menu, menu_type_submenu, "Item");
	popup_printf(menu_item, menu_type_menu, "type: 0x%x", diitem->type);
	popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", diitem->id_hi, diitem->id_lo);
	if (diitem->map) {
		struct attr type,data;
		if (!map_get_attr(diitem->map, attr_type, &type, NULL))
			type.u.str="";
		if (!map_get_attr(diitem->map, attr_data, &data, NULL))
			data.u.str="";
		popup_printf(menu_item, menu_type_menu, "map: %s:%s", type.u.str, data.u.str);
	}
	if (diitem->map) {
		mr=map_rect_new(diitem->map,NULL);
		item=map_rect_get_item_byid(mr, diitem->id_hi, diitem->id_lo);
		dbg(1,"item=%p\n", item);
		if (item) {
			popup_show_attrs(item->map, menu_item, item);
			popup_printf_cb(menu_item, menu_type_menu, callback_new_1(callback_cast(popup_item_dump), diitem), "Dump");
			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"));
				}
			}
		}
Exemplo n.º 4
0
static void
navit_projection_set(struct menu *menu, void *this__p, void *pro_p)
{
	struct navit *this_=this__p;
	enum projection pro=(enum projection) pro_p;
	struct coord_geo g;
	struct coord *c;

	c=transform_center(this_->trans);
	transform_to_geo(transform_get_projection(this_->trans), c, &g);
	transform_set_projection(this_->trans, pro);
	transform_from_geo(pro, &g, c);
	navit_draw(this_);
}
Exemplo n.º 5
0
static void
popup_set_destination(struct navit *nav, struct pcoord *pc)
{
	struct coord c;
	struct coord_geo g;
	char buffer[1024];
	char buffer_geo[1024];
	c.x = pc->x;
	c.y = pc->y;
	transform_to_geo(transform_get_projection(navit_get_trans(nav)), &c, &g);
	transform_geo_text(&g, buffer_geo);	
	sprintf(buffer,"Map Point %s", buffer_geo);
	navit_set_destination(nav, pc, buffer);
}
Exemplo n.º 6
0
static void
popup_set_destination(struct navit *nav, struct pcoord *pc)
{
	struct coord c;
	struct coord_geo g;
	char buffer[1024];
	char buffer_geo[1024];
	c.x = pc->x;
	c.y = pc->y;
	transform_to_geo(transform_get_projection(navit_get_trans(nav)), &c, &g);
	coord_format(g.lat,g.lng,DEGREES_MINUTES_SECONDS,buffer_geo,sizeof(buffer_geo));
	sprintf(buffer,"Map Point %s", buffer_geo);
	navit_set_destination(nav, pc, buffer, 1);
}
Exemplo n.º 7
0
void
bookmarks_write_center_to_file(struct bookmarks *this_, char *file)
{
	dbg(0,"EEnter\n");

	FILE *f;
	enum projection pro;
	struct coord *center;

	f = fopen(file, "w+");
	if (f)
	{
		// save (pixel-on-screen width/2 height/2) screen center
		struct coord_geo g22;
		struct coord c22;
		struct point p;

		int width, height;
		transform_get_size(this_->trans, &width, &height);
		p.x=width/2;
		p.y=height/2;

		transform_reverse(this_->trans, &p, &c22);
		//dbg(0,"%f, %f\n",a, b);
		//dbg(0,"%d, %d\n",p.x, p.y);
		// * transform_to_geo(projection_mg, &c22, &g22);
		//dbg(0,"%d, %d, %f, %f\n",c22.x, c22.y, g22.lat, g22.lng);
		// * result=g_strdup_printf("%f:%f",g22.lat,g22.lng);

		// + center = transform_center(this_->trans);
		pro = transform_get_projection(this_->trans);
		// + coord_print(pro, center, f);
		coord_print(pro, &c22, f);
		fclose(f);
		dbg(0,"******** write center to file *********\n");
	}
	else
	{
		perror(file);
	}

	dbg(0,"ready\n");

	return;
}
Exemplo n.º 8
0
static void
popup_show_item(struct navit *nav, void *popup, struct displayitem *di)
{
	struct map_rect *mr;
	void *menu, *menu_map, *menu_item;
	char *label;
	struct item *item;

	label=graphics_displayitem_get_label(di);
	item=graphics_displayitem_get_item(di);

	if (label) 
		menu=popup_printf(popup, menu_type_submenu, "%s '%s'", item_to_name(item->type), label);
	else
		menu=popup_printf(popup, menu_type_submenu, "%s", item_to_name(item->type));
	menu_item=popup_printf(menu, menu_type_submenu, "Item");
	popup_printf(menu_item, menu_type_menu, "type: 0x%x", item->type);
	popup_printf(menu_item, menu_type_menu, "id: 0x%x 0x%x", item->id_hi, item->id_lo);
	if (item->map) {
		mr=map_rect_new(item->map,NULL);
		item=map_rect_get_item_byid(mr, item->id_hi, item->id_lo);
		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"));
				}
			}
		}