2 * Copyright (C) 2009-2010 Andy Spencer <andy753421@gmail.com>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "gis-object.h"
24 GisPoint *gis_point_new()
26 return g_new0(GisPoint, 1);
29 void gis_point_set_lle(GisPoint *self, gdouble lat, gdouble lon, gdouble elev)
36 void gis_point_free(GisPoint *self)
43 G_DEFINE_TYPE(GisObject, gis_object, G_TYPE_OBJECT);
44 static void gis_object_init(GisObject *self) { }
45 static void gis_object_class_init(GisObjectClass *klass) { }
49 G_DEFINE_TYPE(GisMarker, gis_marker, GIS_TYPE_OBJECT);
50 static void gis_marker_init(GisMarker *self) { }
52 static void gis_marker_finalize(GObject *_self);
53 static void gis_marker_class_init(GisMarkerClass *klass)
55 G_OBJECT_CLASS(klass)->finalize = gis_marker_finalize;
58 GisMarker *gis_marker_new(const gchar *label)
60 static const int RADIUS = 4;
61 static const int WIDTH = 100;
62 static const int HEIGHT = 20;
64 GisMarker *self = g_object_new(GIS_TYPE_MARKER, NULL);
66 self->yoff = HEIGHT-RADIUS;
67 self->label = g_strdup(label);
68 self->cairo = cairo_create(cairo_image_surface_create(
69 CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT));
70 cairo_set_source_rgba(self->cairo, 1, 1, 1, 1);
71 cairo_arc(self->cairo, self->xoff, self->yoff, RADIUS, 0, 2*G_PI);
72 cairo_fill(self->cairo);
73 cairo_move_to(self->cairo, self->xoff+4, self->yoff-8);
74 cairo_set_font_size(self->cairo, 10);
75 cairo_show_text(self->cairo, self->label);
79 static void gis_marker_finalize(GObject *_self)
81 GisMarker *self = GIS_MARKER(_self);
82 cairo_surface_destroy(cairo_get_target(self->cairo));
83 cairo_destroy(self->cairo);
90 G_DEFINE_TYPE(GisCallback, gis_callback, GIS_TYPE_OBJECT);
91 static void gis_callback_init(GisCallback *self) { }
92 static void gis_callback_class_init(GisCallbackClass *klass) { }
94 GisCallback *gis_callback_new(GisCallbackFunc callback, gpointer user_data)
96 GisCallback *self = g_object_new(GIS_TYPE_CALLBACK, NULL);
97 self->callback = callback;
98 self->user_data = user_data;