gboolean gl;
GdkRectangle scale_rect;
+ GdkRectangle center_rect;
RepoData *curr_repo;
gboolean show_markers;
gboolean show_marker_labels;
gboolean show_speed;
+ gboolean show_center;
gboolean click_to_center;
gboolean zoom_in_on_2button;
static void gtk_map_mark_draw(GtkWidget *widget, GdkEventExpose *event);
static void gtk_map_speed_draw(GtkWidget *widget, GdkEventExpose *event);
+static void gtk_map_center_mark_draw(GtkWidget *widget, GdkEventExpose *event);
+
static void gtk_map_render_buffer(GtkWidget *widget, GdkEventExpose *event);
static void gtk_map_render_markers(GtkWidget *widget, GdkEventExpose *event);
static void gtk_map_render_paths(GtkWidget *widget, GdkEventExpose *event);
priv->max_center.unity=GTK_MAP_WORLD_SIZE_UNITS-grid2unit(priv->screen_grids_halfheight) - 1;
BOUND(priv->center.unitx, priv->min_center.unitx, priv->max_center.unitx);
BOUND(priv->center.unity, priv->min_center.unity, priv->max_center.unity);
-priv->base_tilex = grid2tile((gint) pixel2grid((gint) unit2pixel((gint) priv->center.unitx)) - (gint) priv->screen_grids_halfwidth);
-priv->base_tiley = grid2tile(pixel2grid(unit2pixel(priv->center.unity)) - priv->screen_grids_halfheight);
+priv->base_tilex=grid2tile((gint) pixel2grid((gint) unit2pixel((gint) priv->center.unitx)) - (gint) priv->screen_grids_halfwidth);
+priv->base_tiley=grid2tile(pixel2grid(unit2pixel(priv->center.unity)) - priv->screen_grids_halfheight);
+
+priv->center_rect.x=(priv->screen_width_pixels/2)-8;
+priv->center_rect.y=(priv->screen_height_pixels/2)-8;
+priv->center_rect.width=16;
+priv->center_rect.height=16;
}
/******************************************************************************/
priv->show_velvec=TRUE;
priv->show_markers=TRUE;
priv->show_location=TRUE;
+priv->show_center=TRUE;
priv->button_down=FALSE;
priv->click_to_center=FALSE;
switch (prop_id) {
case PROP_CENTER_MODE:
- priv->center_mode=g_value_get_int(value);
+ gtk_map_set_center_mode(map, g_value_get_int(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
color.blue=0xffff;
gdk_gc_set_rgb_fg_color(priv->gc_break, &color);
+priv->gc_mark=gdk_gc_new(widget->window);
+color.red=0;
+color.green=0;
+color.blue=0xffff;
+gdk_gc_set_rgb_fg_color(priv->gc_mark, &color);
+
g_signal_connect(G_OBJECT(map), "button_press_event", G_CALLBACK(gtk_map_button_press_cb), NULL);
g_signal_connect(G_OBJECT(map), "button_release_event",G_CALLBACK(gtk_map_button_release_cb), NULL);
g_signal_connect(G_OBJECT(map), "scroll_event", G_CALLBACK(gtk_map_scroll_event_cb), NULL);
map=GTK_MAP(widget);
priv=GTK_MAP_GET_PRIVATE(map);
-g_debug("Expose");
+g_debug("Expose: %d,%d %d,%d", event->area.x, event->area.y, event->area.width, event->area.height);
#ifdef WITH_CAIRO
priv->ct=gdk_cairo_create(widget->window);
if (priv->show_scale)
gtk_map_scale_draw(widget, event);
+if (priv->show_center)
+ gtk_map_center_mark_draw(widget, event);
+
#ifdef WITH_CAIRO
cairo_destroy(priv->ct);
priv->ct=NULL;
return TRUE;
}
+static void
+gtk_map_center_mark_draw(GtkWidget *widget, GdkEventExpose *event)
+{
+GtkMap *map;
+GtkMapPriv *priv;
+
+map=GTK_MAP(widget);
+priv=GTK_MAP_GET_PRIVATE(map);
+
+g_debug("CenterMark: %d %d %d %d", priv->center_rect.x, priv->center_rect.y, priv->center_rect.width, priv->center_rect.height);
+
+if (!gdk_rectangle_intersect(&event->area, &priv->center_rect, NULL))
+ return;
+
+#ifdef WITH_CAIRO
+cairo_save(priv->ct);
+cairo_rectangle(priv->ct, priv->center_rect.x, priv->center_rect.y, priv->center_rect.width, priv->center_rect.height);
+cairo_set_source_rgb(priv->ct, 0.8, 0.8, 1);
+cairo_fill_preserve(priv->ct);
+cairo_set_source_rgba(priv->ct, 1, 1, 1, 0.5);
+cairo_stroke(priv->ct);
+cairo_restore(priv->ct);
+#else
+gdk_draw_rectangle(widget->window, priv->gc_mark, FALSE, priv->center_rect.x, priv->center_rect.y, priv->center_rect.width, priv->center_rect.height);
+#endif
+}
+
static void
gtk_map_mark_draw(GtkWidget *widget, GdkEventExpose *event)
{
/******************************************************************************/
+gboolean
+gtk_map_set_center_mode(GtkWidget *widget, GtkMapCenterMode mode)
+{
+GtkMap *map;
+GtkMapPriv *priv;
+GtkMapCenterMode omode;
+
+g_return_val_if_fail(GTK_IS_MAP(widget), FALSE);
+
+map=GTK_MAP(widget);
+priv=GTK_MAP_GET_PRIVATE(map);
+
+omode=priv->center_mode;
+
+/* If we have a track, then we can center on it */
+if (priv->current_track) {
+ priv->center_mode=mode;
+ if (omode!=mode)
+ g_signal_emit(widget, gtk_map_signals[MAP_CENTER_MODE_CHANGED], 0, NULL);
+ return TRUE;
+} else if (mode==CENTER_MANUAL) {
+ priv->center_mode=mode;
+ if (omode!=mode)
+ g_signal_emit(widget, gtk_map_signals[MAP_CENTER_MODE_CHANGED], 0, NULL);
+ return TRUE;
+} else {
+ priv->center_mode=CENTER_MANUAL;
+ if (omode!=CENTER_MANUAL)
+ g_signal_emit(widget, gtk_map_signals[MAP_CENTER_MODE_CHANGED], 0, NULL);
+ return FALSE;
+}
+
+}
+
void
gtk_map_set_center(GtkWidget *widget, guint unitx, guint unity)
{
guint new_x, new_y;
guint j, k, base_new_x, base_old_x, old_x, old_y, iox, ioy;
-g_return_val_if_fail(GTK_IS_MAP(widget), FALSE);
+g_return_if_fail(GTK_IS_MAP(widget));
map=GTK_MAP(widget);
priv=GTK_MAP_GET_PRIVATE(map);
priv->menu=NULL;
}
+void
+gtk_map_get_menu_latlon(GtkWidget *widget, gdouble *lat, gdouble *lon)
+{
+GtkMap *map;
+GtkMapPriv *priv;
+
+g_return_if_fail(GTK_IS_MAP(widget));
+map=GTK_MAP(widget);
+priv=GTK_MAP_GET_PRIVATE(map);
+
+*lat=priv->menu_lat;
+*lat=priv->menu_lon;
+}
+
/******************************************************************************/
void