if (map_drag_id>0)
return;
-if (_home.valid)
- map_draw_position_icon(&_home);
-
if(_show_poi)
map_render_all_pois(buf_width_pixels, buf_height_pixels);
+if (_home.valid)
+ map_draw_position_icon(&_home, "home");
+
+if (_dest.valid)
+ map_draw_position_icon(&_dest, "destination");
+
if(_show_tracks>0)
map_render_paths();
}
return FALSE;
}
-/**
- * Draw given pixbuf on map, centered on x,y
- */
void
-map_draw_pixbuf(guint unitx, guint unity, GdkPixbuf *p)
+map_draw_pixbuf_on_buffer(gint x, gint y, GdkPixbuf *p)
{
-gint x,y;
-x = unit2bufx(unitx);
-y = unit2bufy(unity);
+if ((x < 0) || (y < 0))
+ return;
if ((x > buf_width_pixels) || (y > buf_height_pixels))
return;
}
/**
- * Draw an icon on given Position.
- *
- * XXX: don't hardcode as home.png !
+ * Draw given pixbuf on map, centered on x,y
*/
void
-map_draw_position_icon(Position *pos)
+map_draw_pixbuf(guint unitx, guint unity, GdkPixbuf *p)
{
-guint x,y, x1,y1;
+gint x,y;
+x=unit2bufx(unitx);
+y=unit2bufy(unity);
+
+map_draw_pixbuf_on_buffer(x, y, p);
+}
+
+/**
+ * Draw an icon at given Position.
+ *
+ */
+static void
+map_draw_position_icon(Position *pos, const gchar *icon)
+{
+gint x, y;
+guint ux, uy;
+gchar buffer[128];
GdkPixbuf *p;
-latlon2unit(pos->lat, pos->lon, x, y);
-x1=unit2bufx(x);
-y1=unit2bufy(y);
+latlon2unit(pos->lat, pos->lon, ux, uy);
+x=unit2bufx(ux);
+y=unit2bufy(uy);
-if ((x1 > buf_width_pixels) || (y1 > buf_height_pixels))
+if ((x < 0) || (y < 0))
return;
-p=gdk_pixbuf_new_from_file(DATADIR "/pixmaps/mapper/home.png", NULL);
-if (p) {
- map_draw_pixbuf(x,y,p);
- g_object_unref(p);
-}
+if ((x > buf_width_pixels) || (y > buf_height_pixels))
+ return;
+
+g_snprintf(buffer, sizeof(buffer), "%s/pixmaps/mapper/%s.png", DATADIR, icon);
+p=gdk_pixbuf_new_from_file(buffer, NULL);
+if (!p)
+ return;
+map_draw_pixbuf_on_buffer(x, y, p);
+g_object_unref(p);
}
/**
void map_render_waypoint(guint x1, guint y1, GdkGC *gc);
void map_render_paths(void);
void map_force_redraw(void);
-void map_draw_position_icon(Position *pos);
+void map_draw_position_icon(Position *pos, const gchar *icon);
GdkPixmap *map_pixmap_get(void);
void map_center_unit(guint new_center_unitx, guint new_center_unity);