struct attr **attrs;
struct callback_list *cbl;
struct point_rect r;
+ GList *selection;
};
struct display_context
static void draw_circle(struct point *pnt, int diameter, int scale, int start, int len, struct point *res, int *pos, int dir);
+static void graphics_process_selection(struct graphics *gra, struct displaylist *dl);
+
void
graphics_set_rect(struct graphics *gra, struct point_rect *pr)
{
h=g_hash_table_new_full(displayitem_hash, displayitem_equal, g_free, NULL);
g_hash_table_insert(displaylist->dl, GINT_TO_POINTER(item->type), h);
}
- g_hash_table_replace(h, di, NULL);
+ g_hash_table_replace(h, di, di);
}
event_remove_idle(displaylist->idle_ev);
displaylist->idle_ev=NULL;
displaylist->busy=0;
+ graphics_process_selection(displaylist->dc.gra, displaylist);
if (! cancel)
graphics_displaylist_draw(displaylist->dc.gra, displaylist, displaylist->dc.trans, displaylist->layout, 1);
map_rect_destroy(displaylist->mr);
}
return within_dist_polygon(p, pa, count, dist);
}
+
+
+static enum item_type
+graphics_selection_type(enum item_type type)
+{
+ if (type < type_line)
+ return type_selected_point;
+ if (type < type_area)
+ return type_selected_line;
+ return type_selected_area;
+
+}
+
+
+static void
+graphics_process_selection_item(struct displaylist *dl, struct item *item)
+{
+ struct displayitem di,*di_res;
+ GHashTable *h;
+
+ di.item=*item;
+ di.label=NULL;
+ di.displayed=0;
+ di.count=0;
+ h=g_hash_table_lookup(dl->dl, GINT_TO_POINTER(di.item.type));
+ if (h) {
+ di_res=g_hash_table_lookup(h, &di);
+ if (di_res) {
+ di.item.type=graphics_selection_type(di.item.type);
+ display_add(dl, &di.item, di_res->count, di_res->c, NULL);
+ }
+ }
+}
+
+void
+graphics_add_selection(struct graphics *gra, struct item *item, struct displaylist *dl)
+{
+ struct item *item_dup=g_new(struct item, 1);
+ *item_dup=*item;
+ gra->selection=g_list_append(gra->selection, item_dup);
+ if (dl)
+ graphics_process_selection_item(dl, item_dup);
+}
+
+void
+graphics_remove_selection(struct graphics *gra, struct item *item, struct displaylist *dl)
+{
+ GList *curr;
+ int found;
+
+ for (;;) {
+ curr=gra->selection;
+ found=0;
+ while (curr) {
+ struct item *sitem=curr->data;
+ if (item_is_equal(*item,*sitem)) {
+ if (dl) {
+ struct displayitem di;
+ GHashTable *h;
+ di.item=*sitem;
+ di.label=NULL;
+ di.displayed=0;
+ di.count=0;
+ di.item.type=graphics_selection_type(di.item.type);
+ h=g_hash_table_lookup(dl->dl, GINT_TO_POINTER(di.item.type));
+ if (h)
+ g_hash_table_remove(h, &di);
+ }
+ g_free(sitem);
+ gra->selection=g_list_remove(gra->selection, curr->data);
+ found=1;
+ break;
+ }
+ }
+ if (!found)
+ return;
+ }
+}
+
+void
+graphics_clear_selection(struct graphics *gra, struct displaylist *dl)
+{
+ while (gra->selection)
+ graphics_remove_selection(gra, (struct item *)gra->selection->data, dl);
+}
+
+static void
+graphics_process_selection(struct graphics *gra, struct displaylist *dl)
+{
+ GList *curr;
+
+ curr=gra->selection;
+ while (curr) {
+ struct item *item=curr->data;
+ graphics_process_selection_item(dl, item);
+ curr=g_list_next(curr);
+ }
+}
enum draw_mode_num;
struct attr;
struct attr_iter;
+struct callback;
struct color;
struct displayitem;
struct displaylist;
struct graphics_gc;
struct graphics_image;
struct item;
+struct itemgra;
struct layout;
struct point;
+struct point_rect;
struct transformation;
-struct callback;
-struct itemgra;
void graphics_set_rect(struct graphics *gra, struct point_rect *pr);
-void graphics_resize(struct graphics *gra, int w, int h);
struct graphics *graphics_new(struct attr *parent, struct attr **attrs);
int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
struct graphics *graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h, int alpha, int wraparound);
void graphics_add_callback(struct graphics *this_, struct callback *cb);
void graphics_remove_callback(struct graphics *this_, struct callback *cb);
struct graphics_font *graphics_font_new(struct graphics *gra, int size, int flags);
-void graphics_font_destroy_all(struct graphics *gra);
+void graphics_font_destroy_all(struct graphics *gra);
struct graphics_gc *graphics_gc_new(struct graphics *gra);
void graphics_gc_destroy(struct graphics_gc *gc);
void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c);
void graphics_gc_set_background(struct graphics_gc *gc, struct color *c);
void graphics_gc_set_linewidth(struct graphics_gc *gc, int width);
void graphics_gc_set_dashes(struct graphics_gc *gc, int width, int offset, unsigned char dash_list[], int n);
-struct graphics_image * graphics_image_new_scaled(struct graphics *gra, char *path, int w, int h);
-struct graphics_image * graphics_image_new_scaled_rotated(struct graphics *gra, char *path, int w, int h, int rotate);
+struct graphics_image *graphics_image_new_scaled(struct graphics *gra, char *path, int w, int h);
+struct graphics_image *graphics_image_new_scaled_rotated(struct graphics *gra, char *path, int w, int h, int rotate);
struct graphics_image *graphics_image_new(struct graphics *gra, char *path);
void graphics_image_free(struct graphics *gra, struct graphics_image *img);
void graphics_draw_restore(struct graphics *this_, struct point *p, int w, int h);
void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count);
void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r);
void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h);
+void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc *gc, struct point *plu, int w, int h, int r, int fill);
void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1, struct graphics_gc *gc2, struct graphics_font *font, char *text, struct point *p, int dx, int dy);
void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret, int estimate);
void graphics_overlay_disable(struct graphics *this_, int disable);
void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img);
int graphics_draw_drag(struct graphics *this_, struct point *p);
void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc);
-int graphics_ready(struct graphics *this_);
-void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int callback);
-void graphics_displaylist_move(struct displaylist *displaylist, int dx, int dy);
void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t);
+void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int callback);
void graphics_draw(struct graphics *gra, struct displaylist *displaylist, GList *mapsets, struct transformation *trans, struct layout *l, int async, struct callback *cb);
int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist);
struct displaylist_handle *graphics_displaylist_open(struct displaylist *displaylist);
struct item *graphics_displayitem_get_item(struct displayitem *di);
char *graphics_displayitem_get_label(struct displayitem *di);
int graphics_displayitem_within_dist(struct displaylist *displaylist, struct displayitem *di, struct point *p, int dist);
+void graphics_add_selection(struct graphics *gra, struct item *item, struct displaylist *dl);
+void graphics_remove_selection(struct graphics *gra, struct item *item, struct displaylist *dl);
+void graphics_clear_selection(struct graphics *gra, struct displaylist *dl);
/* end of prototypes */
#ifdef __cplusplus
}
char *speech;
struct pcoord c;
struct item item;
+ int selection_id;
int state;
struct point p;
int wmin,hmin;
gui_internal_cmd_view_on_map(struct gui_priv *this, struct widget *wm, void *data)
{
struct widget *w=wm->data;
+ int highlight=(w->data == (void *)2 || w->data == (void *)3 || w->data == (void *)4);
+ if (highlight) {
+ graphics_clear_selection(this->gra, NULL);
+ graphics_add_selection(this->gra, &w->item, NULL);
+ }
navit_set_center(this->nav, &w->c);
gui_internal_prune_menu(this, NULL);
}
char *text=NULL,*name=NULL;
struct search_list_result *res;
struct widget *wc;
+ struct item *item=NULL;
GList *l;
res=search_list_get_result(this->sl);
if (! strcmp(wm_name,"Country")) {
name=res->country->name;
+ item=&res->country->item;
text=g_strdup_printf("%s", res->country->name);
}
if (! strcmp(wm_name,"Town")) {
name=res->town->name;
+ item=&res->town->item;
text=g_strdup(name);
}
if (! strcmp(wm_name,"Street")) {
name=res->street->name;
+ item=&res->street->item;
text=g_strdup_printf("%s %s", res->town->name, res->street->name);
}
#if 0
wc->name=g_strdup(name);
if (res->c)
wc->c=*res->c;
- wc->item.id_lo=res->id;
+ wc->selection_id=res->id;
+ if (item)
+ wc->item=*item;
gui_internal_widget_pack(this, search_list);
l=g_list_last(this->root.children);
graphics_draw_mode(this->gra, draw_mode_begin);
static void
gui_internal_search_street_in_town(struct gui_priv *this, struct widget *widget, void *data)
{
- dbg(0,"id %d\n", widget->item.id_lo);
+ dbg(0,"id %d\n", widget->selection_id);
search_list_select(this->sl, attr_town_name, 0, 0);
- search_list_select(this->sl, attr_town_name, widget->item.id_lo, 1);
+ search_list_select(this->sl, attr_town_name, widget->selection_id, 1);
gui_internal_search(this,_("Street"),"Street",0);
}
gui_internal_search_town_in_country(struct gui_priv *this, struct widget *widget)
{
struct search_list_common *slc;
- dbg(0,"id %d\n", widget->item.id_lo);
+ dbg(0,"id %d\n", widget->selection_id);
search_list_select(this->sl, attr_country_all, 0, 0);
- slc=search_list_select(this->sl, attr_country_all, widget->item.id_lo, 1);
+ slc=search_list_select(this->sl, attr_country_all, widget->selection_id, 1);
if (slc) {
g_free(this->country_iso2);
this->country_iso2=((struct search_list_country *)slc)->iso2;
ITEM(house_number)
ITEM(route_start)
ITEM(route_end)
+ITEM(selected_point)
/* Line */
ITEM2(0x80000000,line)
ITEM2(0x80000001,line_unspecified)
ITEM(street_turn_restriction_only)
ITEM(border_city)
ITEM(border_county)
+ITEM(selected_line)
/* Area */
ITEM2(0xc0000000,area)
ITEM2(0xc0000001,area_unspecified)
ITEM(poly_wetland)
ITEM(poly_aeroway_runway)
ITEM(map_information)
+ITEM(selected_area)
ITEM2(0xffffffff,last)