G_DEFINE_TYPE(GtkMap, gtk_map, GTK_TYPE_WIDGET);
-typedef struct _GtkMapPriv GtkMapPriv;
-
+typedef struct _GtkMapPriv GtkMapPriv;
struct _GtkMapPriv
{
PangoContext *context;
PangoLayout *layout;
PangoFontDescription *fontdesc;
+
+PangoLayout *speed_layout;
+PangoLayout *scale_layout;
+gint zoom;
+gint offsetx;
+gint offsety;
};
#define GTK_MAP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_MAP, GtkMapPriv))
#define leadx2unit(mgps) (mgps.unitx + (_lead_ratio) * pixel2unit(mgps.vel_offsetx))
#define leady2unit(mgps) (mgps.unity + (0.6f*_lead_ratio)*pixel2unit(mgps.vel_offsety))
-static void gtk_map_finalize (GObject *object);
-static void gtk_map_size_request (GtkWidget *widget, GtkRequisition *requisition);
-static void gtk_map_size_allocate (GtkWidget *widget, GtkAllocation *allocate);
-static gboolean gtk_map_expose (GtkWidget *widget, GdkEventExpose *event);
-static void gtk_map_realize (GtkWidget *widget);
-static void gtk_map_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
-static void gtk_map_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
+static void gtk_map_finalize(GObject *object);
+
+static void gtk_map_size_request(GtkWidget *widget, GtkRequisition *requisition);
+static void gtk_map_size_allocate(GtkWidget *widget, GtkAllocation *allocate);
+
+static gboolean gtk_map_expose(GtkWidget *widget, GdkEventExpose *event);
+static void gtk_map_realize(GtkWidget *widget);
+
+static void gtk_map_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+static void gtk_map_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void
gtk_map_class_init (GtkMapClass *class)
static void
gtk_map_init(GtkMap *map)
{
+GtkMapPriv *priv;
+priv=GTK_MAP_GET_PRIVATE(map);
}
GtkWidget*
gtk_map_new(void)
{
GtkMap *map;
+GtkMapPriv *priv;
GtkWidget *widget;
map=g_object_new(GTK_MAP_TYPE, NULL);
widget=GTK_WIDGET(map);
+priv=GTK_MAP_GET_PRIVATE(map);
map->heading=0;
#if 0
gtk_map_expose(GtkWidget *widget, GdkEventExpose *event)
{
GtkMap *map;
+GtkMapPriv *priv;
g_return_val_if_fail(GTK_IS_MAP(widget), FALSE);
g_return_val_if_fail(event != NULL, FALSE);
map=GTK_MAP(widget);
+priv=GTK_MAP_GET_PRIVATE(map);
gdk_draw_drawable(GDK_DRAWABLE(map->widget->window),
- map->gc[COLORABLE_MARK],
- map->pixmap,
- event->area.x + map->offsetx, event->area.y + map->offsety,
+ priv->gc[COLORABLE_MARK],
+ priv->pixmap,
+ event->area.x + priv->offsetx, event->area.y + priv->offsety,
event->area.x, event->area.y,
event->area.width, event->area.height);
map_scale_draw(GtkWidget *widget, GdkEventExpose *event)
{
GtkMap *map;
+GtkMapPriv *priv;
gchar buffer[16];
gdouble distance;
gdouble lat1, lon1, lat2, lon2;
g_return_if_fail(GTK_IS_MAP(widget));
map=GTK_MAP(widget);
+priv=GTK_MAP_GET_PRIVATE(map);
-pango_layout_set_text(scale_layout, "0", -1);
-pango_layout_get_pixel_size(scale_layout, NULL, &scale_rect.height);
-scale_rect.y = _screen_height_pixels - scale_rect.height - 1;
+pango_layout_set_text(priv->scale_layout, "0", -1);
+pango_layout_get_pixel_size(priv->scale_layout, NULL, &scale_rect.height);
+scale_rect.y = priv->screen_height_pixels - scale_rect.height - 1;
gdk_rectangle_intersect(&event->area, &scale_rect, &event->area);
static void
map_information_text(GtkWidget *widget, guint x, guint y, GdkGC *gc, gchar *msg)
{
+GtkMap *map;
+GtkMapPriv *priv;
guint width, height;
g_return_if_fail(GTK_IS_MAP(widget));
map=GTK_MAP(widget);
+priv=GTK_MAP_GET_PRIVATE(map);
-pango_layout_set_text(speed_layout, msg, -1);
-pango_layout_get_pixel_size(speed_layout, &width, &height);
+pango_layout_set_text(priv->speed_layout, msg, -1);
+pango_layout_get_pixel_size(priv->speed_layout, &width, &height);
gtk_widget_queue_draw_area(_map_widget, x - 5, y - 5, width * 3 + 15, height + 5);
gdk_window_process_all_updates();
gdk_draw_layout(_map_widget->window, gc, x, y, speed_layout);