Contents of /branches/ports/maemo/src/canvas.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 137 - (show annotations)
Sat Mar 21 22:37:16 2009 UTC (15 years, 2 months ago) by achadwick
File MIME type: text/plain
File size: 5258 byte(s)
Merge to tags/trunk-0.6.14 (-r89:HEAD). Will commit build fixes separately.
1 /*
2 * Copyright (C) 2008 Till Harbaum <till@harbaum.org>.
3 *
4 * This file is part of OSM2Go.
5 *
6 * OSM2Go is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * OSM2Go is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with OSM2Go. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef CANVAS_H
21 #define CANVAS_H
22
23 typedef enum {
24 CANVAS_GROUP_BG=0, // background layer (wms overlay)
25 CANVAS_GROUP_POLYGONS, // polygons (forrests, buildings, lakes) */
26 CANVAS_GROUP_WAYS_HL, // highlighting of ways
27 CANVAS_GROUP_WAYS_OL, // outlines for ways (e.g. for highways)
28 CANVAS_GROUP_WAYS, // ways
29 CANVAS_GROUP_WAYS_INT, // interior of ways with outlines
30 CANVAS_GROUP_WAYS_DIR, // direction arrows for ways
31 CANVAS_GROUP_NODES_HL, // highlighting for nodes
32 CANVAS_GROUP_NODES, // nodes
33 CANVAS_GROUP_TRACK, // (GPS) track
34 CANVAS_GROUP_GPS, // current GPS position
35 CANVAS_GROUP_FRISKET, // the (white) frisket limiting the view
36 CANVAS_GROUP_DRAW, // "cursor" functionality
37 CANVAS_GROUPS
38 } canvas_group_t;
39
40 #define CANVAS_HIGHLIGHTS ((1<<CANVAS_GROUP_WAYS_HL) | (1<<CANVAS_GROUP_NODES_HL))
41
42 /* only objects in the "selectable" groups are returned by item_at */
43 #define CANVAS_SELECTABLE ((1<<CANVAS_GROUP_POLYGONS) | (1<<CANVAS_GROUP_WAYS) | (1<<CANVAS_GROUP_WAYS_OL) | (1<<CANVAS_GROUP_WAYS_INT) | (1<<CANVAS_GROUP_NODES) | CANVAS_HIGHLIGHTS)
44
45
46 #if CANVAS_GROUPS >= 16
47 #error "More than 16 canvas groups needs adjustment e.g. in map.h"
48 #endif
49
50 #if defined(USE_GOOCANVAS)
51
52 #include <goocanvas.h>
53
54 typedef GooCanvasItem canvas_item_t;
55 typedef GooCanvasPoints canvas_points_t;
56
57 typedef struct {
58 GtkWidget *widget;
59 GooCanvasItem *group[CANVAS_GROUPS];
60 } canvas_t;
61
62 typedef gulong canvas_color_t;
63
64 #define CANVAS_COLOR(r,g,b,a) ((((guint) (r) & 0xff) << 24) \
65 | (((guint) (g) & 0xff) << 16) \
66 | (((guint) (b) & 0xff) << 8) \
67 | ((guint) (a) & 0xff))
68
69
70
71 #else
72 #error "No canvas type defined!"
73 #endif
74
75 typedef enum { CANVAS_UNIT_METER = 0, CANVAS_UNIT_PIXEL } canvas_unit_t;
76
77 /***** creating/destroying the canvas ******/
78 canvas_t *canvas_new(canvas_color_t color);
79 GtkWidget *canvas_get_widget(canvas_t *canvas);
80
81 /****** manipulating the canvas ******/
82 void canvas_set_antialias(canvas_t *canvas, gboolean antialias);
83 void canvas_erase(canvas_t *canvas, gint group_mask);
84 void canvas_window2world(canvas_t *canvas, gint x, gint y, gint *wx, gint *wy);
85 canvas_item_t *canvas_get_item_at(canvas_t *canvas, gint x, gint y);
86 void canvas_set_zoom(canvas_t *canvas, gdouble zoom);
87 gdouble canvas_get_zoom(canvas_t *canvas);
88 gdouble canvas_get_viewport_width(canvas_t *canvas, canvas_unit_t unit);
89 gdouble canvas_get_viewport_height(canvas_t *canvas, canvas_unit_t unit);
90 void canvas_scroll_to(canvas_t *canvas, canvas_unit_t unit, gint sx, gint sy);
91 void canvas_scroll_get(canvas_t *canvas, canvas_unit_t unit, gint *sx, gint *sy);
92 void canvas_set_bounds(canvas_t *canvas, gint minx, gint miny,
93 gint maxx, gint maxy);
94
95
96 /***** creating/destroying items ******/
97 canvas_item_t *canvas_circle_new(canvas_t *canvas, canvas_group_t group,
98 gint x, gint y, gint radius, gint border,
99 canvas_color_t fill_col, canvas_color_t border_col);
100 canvas_item_t *canvas_polyline_new(canvas_t *canvas, canvas_group_t group,
101 canvas_points_t *points, gint width, canvas_color_t color);
102 canvas_item_t *canvas_polygon_new(canvas_t *canvas, canvas_group_t group,
103 canvas_points_t *points, gint width, canvas_color_t color,
104 canvas_color_t fill);
105 canvas_item_t *canvas_image_new(canvas_t *canvas, canvas_group_t group,
106 GdkPixbuf *pix, gint x, gint y,
107 float hscale, float vscale);
108 canvas_points_t *canvas_points_new(gint points);
109 void canvas_point_set_pos(canvas_points_t *points, gint index, lpos_t *lpos);
110 void canvas_points_free(canvas_points_t *points);
111 void canvas_item_destroy(canvas_item_t *item);
112
113 /****** manipulating items ******/
114 void canvas_item_set_pos(canvas_item_t *item, lpos_t *lpos, gint radius);
115 void canvas_item_set_points(canvas_item_t *item, canvas_points_t *points);
116 void canvas_item_set_zoom_max(canvas_item_t *item, float zoom_max);
117 void canvas_item_set_dashed(canvas_item_t *item, gint line_width, gint dash_length);
118 void canvas_item_to_bottom(canvas_item_t *item);
119 void canvas_item_set_user_data(canvas_item_t *item, void *data);
120 void *canvas_item_get_user_data(canvas_item_t *item);
121 void canvas_item_destroy_connect(canvas_item_t *item,
122 GCallback c_handler, gpointer data);
123 void canvas_image_move(canvas_item_t *item, gint x, gint y,
124 float hscale, float vscale);
125 gint canvas_item_get_segment(canvas_item_t *item, gint x, gint y);
126 void canvas_item_get_segment_pos(canvas_item_t *item, gint seg,
127 gint *x0, gint *y0, gint *x1, gint *y1);
128
129 #endif // CANVAS_H