Parent Directory | Revision Log
Map widget update
1 | /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ |
2 | /* vim:set et sw=4 ts=4 cino=t0,(0: */ |
3 | /* |
4 | * osm-gps-map.h |
5 | * Copyright (C) Marcus Bauer 2008 <marcus.bauer@gmail.com> |
6 | * Copyright (C) John Stowers 2009 <john.stowers@gmail.com> |
7 | * Copyright (C) Till Harbaum 2009 <till@harbaum.org> |
8 | * |
9 | * Contributions by |
10 | * Everaldo Canuto 2009 <everaldo.canuto@gmail.com> |
11 | * |
12 | * This is free software: you can redistribute it and/or modify it |
13 | * under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; version 2. |
15 | * |
16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU General Public License for more details. |
20 | * |
21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
23 | */ |
24 | |
25 | #ifndef _OSM_GPS_MAP_H_ |
26 | #define _OSM_GPS_MAP_H_ |
27 | |
28 | #include "config.h" |
29 | |
30 | #include <glib.h> |
31 | #include <glib-object.h> |
32 | #include <gtk/gtk.h> |
33 | #include <gdk-pixbuf/gdk-pixbuf.h> |
34 | |
35 | G_BEGIN_DECLS |
36 | |
37 | #define OSM_TYPE_GPS_MAP (osm_gps_map_get_type ()) |
38 | #define OSM_GPS_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), OSM_TYPE_GPS_MAP, OsmGpsMap)) |
39 | #define OSM_GPS_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), OSM_TYPE_GPS_MAP, OsmGpsMapClass)) |
40 | #define OSM_IS_GPS_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), OSM_TYPE_GPS_MAP)) |
41 | #define OSM_IS_GPS_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), OSM_TYPE_GPS_MAP)) |
42 | #define OSM_GPS_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), OSM_TYPE_GPS_MAP, OsmGpsMapClass)) |
43 | |
44 | typedef struct _OsmGpsMapClass OsmGpsMapClass; |
45 | typedef struct _OsmGpsMap OsmGpsMap; |
46 | typedef struct _OsmGpsMapPrivate OsmGpsMapPrivate; |
47 | |
48 | struct _OsmGpsMapClass |
49 | { |
50 | GtkDrawingAreaClass parent_class; |
51 | }; |
52 | |
53 | struct _OsmGpsMap |
54 | { |
55 | GtkDrawingArea parent_instance; |
56 | OsmGpsMapPrivate *priv; |
57 | }; |
58 | |
59 | typedef struct { |
60 | float rlat; |
61 | float rlon; |
62 | } coord_t; |
63 | |
64 | typedef enum { |
65 | OSM_GPS_MAP_SOURCE_NULL, |
66 | OSM_GPS_MAP_SOURCE_OPENSTREETMAP, |
67 | OSM_GPS_MAP_SOURCE_OPENSTREETMAP_RENDERER, |
68 | OSM_GPS_MAP_SOURCE_OPENAERIALMAP, |
69 | OSM_GPS_MAP_SOURCE_MAPS_FOR_FREE, |
70 | OSM_GPS_MAP_SOURCE_OPENCYCLEMAP, |
71 | OSM_GPS_MAP_SOURCE_OSM_PUBLIC_TRANSPORT, |
72 | OSM_GPS_MAP_SOURCE_GOOGLE_STREET, |
73 | OSM_GPS_MAP_SOURCE_GOOGLE_SATELLITE, |
74 | OSM_GPS_MAP_SOURCE_GOOGLE_HYBRID, |
75 | OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_STREET, |
76 | OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_SATELLITE, |
77 | OSM_GPS_MAP_SOURCE_VIRTUAL_EARTH_HYBRID, |
78 | OSM_GPS_MAP_SOURCE_YAHOO_STREET, |
79 | OSM_GPS_MAP_SOURCE_YAHOO_SATELLITE, |
80 | OSM_GPS_MAP_SOURCE_YAHOO_HYBRID, |
81 | OSM_GPS_MAP_SOURCE_OSMC_TRAILS, |
82 | |
83 | OSM_GPS_MAP_SOURCE_LAST |
84 | } OsmGpsMapSource_t; |
85 | |
86 | typedef enum { |
87 | OSM_GPS_MAP_KEY_FULLSCREEN, |
88 | OSM_GPS_MAP_KEY_ZOOMIN, |
89 | OSM_GPS_MAP_KEY_ZOOMOUT, |
90 | OSM_GPS_MAP_KEY_UP, |
91 | OSM_GPS_MAP_KEY_DOWN, |
92 | OSM_GPS_MAP_KEY_LEFT, |
93 | OSM_GPS_MAP_KEY_RIGHT, |
94 | OSM_GPS_MAP_KEY_MAX |
95 | } OsmGpsMapKey_t; |
96 | |
97 | #define OSM_GPS_MAP_INVALID (0.0/0.0) |
98 | #define OSM_GPS_MAP_CACHE_DISABLED "none://" |
99 | #define OSM_GPS_MAP_CACHE_AUTO "auto://" |
100 | #define OSM_GPS_MAP_CACHE_FRIENDLY "friendly://" |
101 | |
102 | typedef struct { |
103 | gint x, y, w, h; |
104 | } OsmGpsMapRect_t; |
105 | |
106 | typedef enum { |
107 | OSD_NONE = 0, |
108 | OSD_BG, |
109 | OSD_UP, |
110 | OSD_DOWN, |
111 | OSD_LEFT, |
112 | OSD_RIGHT, |
113 | OSD_IN, |
114 | OSD_OUT, |
115 | OSD_CUSTOM // first custom buttom |
116 | } osd_button_t; |
117 | |
118 | typedef void (*OsmGpsMapOsdCallback)(osd_button_t but, gpointer data); |
119 | #define OSM_GPS_MAP_OSD_CALLBACK(f) ((OsmGpsMapOsdCallback) (f)) |
120 | |
121 | /* the osd structure mainly contains various callbacks */ |
122 | /* required to draw and update the OSD */ |
123 | typedef struct osm_gps_map_osd_s { |
124 | GtkWidget *widget; // the main map widget (to get its stlye info) |
125 | |
126 | void(*render)(struct osm_gps_map_osd_s *); |
127 | void(*draw)(struct osm_gps_map_osd_s *, GdkDrawable *); |
128 | osd_button_t(*check)(struct osm_gps_map_osd_s *,gboolean,gint, gint); /* check if x/y lies within OSD */ |
129 | gboolean(*busy)(struct osm_gps_map_osd_s *); |
130 | void(*free)(struct osm_gps_map_osd_s *); |
131 | |
132 | OsmGpsMapOsdCallback cb; |
133 | gpointer data; |
134 | |
135 | gpointer priv; |
136 | } osm_gps_map_osd_t; |
137 | |
138 | typedef enum { |
139 | OSM_GPS_MAP_BALLOON_EVENT_TYPE_DRAW, |
140 | OSM_GPS_MAP_BALLOON_EVENT_TYPE_CLICK, |
141 | OSM_GPS_MAP_BALLOON_EVENT_TYPE_REMOVED, |
142 | OSM_GPS_MAP_BALLOON_EVENT_TYPE_SIZE_REQUEST, |
143 | } osm_gps_map_balloon_event_type_t; |
144 | |
145 | typedef struct { |
146 | osm_gps_map_balloon_event_type_t type; |
147 | union { |
148 | struct { |
149 | OsmGpsMapRect_t *rect; |
150 | cairo_t *cr; |
151 | } draw; |
152 | |
153 | struct { |
154 | int x, y; |
155 | gboolean down; |
156 | } click; |
157 | } data; |
158 | } osm_gps_map_balloon_event_t; |
159 | |
160 | typedef void (*OsmGpsMapBalloonCallback)(osm_gps_map_balloon_event_t *event, gpointer data); |
161 | #define OSM_GPS_MAP_BALLOON_CALLBACK(f) ((OsmGpsMapBalloonCallback) (f)) |
162 | |
163 | GType osm_gps_map_get_type (void) G_GNUC_CONST; |
164 | |
165 | GtkWidget* osm_gps_map_new (void); |
166 | |
167 | char* osm_gps_map_get_default_cache_directory (void); |
168 | |
169 | const char* osm_gps_map_source_get_friendly_name (OsmGpsMapSource_t source); |
170 | const char* osm_gps_map_source_get_repo_uri (OsmGpsMapSource_t source); |
171 | const char* osm_gps_map_source_get_image_format (OsmGpsMapSource_t source); |
172 | int osm_gps_map_source_get_min_zoom (OsmGpsMapSource_t source); |
173 | int osm_gps_map_source_get_max_zoom (OsmGpsMapSource_t source); |
174 | gboolean osm_gps_map_source_is_valid (OsmGpsMapSource_t source); |
175 | |
176 | void osm_gps_map_download_maps (OsmGpsMap *map, coord_t *pt1, coord_t *pt2, int zoom_start, int zoom_end); |
177 | void osm_gps_map_get_bbox (OsmGpsMap *map, coord_t *pt1, coord_t *pt2); |
178 | void osm_gps_map_set_mapcenter (OsmGpsMap *map, float latitude, float longitude, int zoom); |
179 | void osm_gps_map_set_center (OsmGpsMap *map, float latitude, float longitude); |
180 | int osm_gps_map_set_zoom (OsmGpsMap *map, int zoom); |
181 | int osm_gps_map_zoom_in (OsmGpsMap *map); |
182 | int osm_gps_map_zoom_out (OsmGpsMap *map); |
183 | void osm_gps_map_add_track (OsmGpsMap *map, GSList *track); |
184 | void osm_gps_map_replace_track (OsmGpsMap *map, GSList *old_track, GSList *new_track); |
185 | void osm_gps_map_clear_tracks (OsmGpsMap *map); |
186 | void osm_gps_map_add_image (OsmGpsMap *map, float latitude, float longitude, GdkPixbuf *image); |
187 | void osm_gps_map_add_image_with_alignment (OsmGpsMap *map, float latitude, float longitude, GdkPixbuf *image, float xalign, float yalign); |
188 | gboolean osm_gps_map_remove_image (OsmGpsMap *map, GdkPixbuf *image); |
189 | void osm_gps_map_clear_images (OsmGpsMap *map); |
190 | void osm_gps_map_draw_gps (OsmGpsMap *map, float latitude, float longitude, float heading); |
191 | void osm_gps_map_clear_gps (OsmGpsMap *map); |
192 | coord_t osm_gps_map_get_co_ordinates (OsmGpsMap *map, int pixel_x, int pixel_y); |
193 | void osm_gps_map_screen_to_geographic (OsmGpsMap *map, gint pixel_x, gint pixel_y, gfloat *latitude, gfloat *longitude); |
194 | void osm_gps_map_geographic_to_screen (OsmGpsMap *map, gfloat latitude, gfloat longitude, gint *pixel_x, gint *pixel_y); |
195 | void osm_gps_map_scroll (OsmGpsMap *map, gint dx, gint dy); |
196 | float osm_gps_map_get_scale (OsmGpsMap *map); |
197 | void osm_gps_map_set_keyboard_shortcut (OsmGpsMap *map, OsmGpsMapKey_t key, guint keyval); |
198 | |
199 | #ifdef ENABLE_OSD |
200 | void osm_gps_map_register_osd(OsmGpsMap *map, osm_gps_map_osd_t *osd); |
201 | void osm_gps_map_redraw (OsmGpsMap *map); |
202 | osm_gps_map_osd_t *osm_gps_map_osd_get(OsmGpsMap *map); |
203 | void osm_gps_map_repaint (OsmGpsMap *map); |
204 | coord_t *osm_gps_map_get_gps (OsmGpsMap *map); |
205 | #endif |
206 | |
207 | |
208 | G_END_DECLS |
209 | |
210 | #endif /* _OSM_GPS_MAP_H_ */ |