/[zanavi_public1]/navit/navit/graphics.h
ZANavi

Contents of /navit/navit/graphics.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (show annotations) (download)
Wed Aug 22 17:01:27 2012 UTC (11 years, 7 months ago) by zoff99
File MIME type: text/plain
File size: 12154 byte(s)
ZANavi 2.0, lots of changes, everything in its own thread, more performance
1 /**
2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
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 Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef NAVIT_GRAPHICS_H
21 #define NAVIT_GRAPHICS_H
22
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif
27 struct attr;
28 struct point;
29 struct container;
30 struct color;
31 struct graphics;
32 struct graphics_gc;
33 struct graphics_font;
34 struct graphics_image;
35 struct transformation;
36 struct display_list;
37 struct mapset;
38
39 enum draw_mode_num
40 {
41 draw_mode_begin, // 0
42 draw_mode_begin_clear, // 1
43 draw_mode_end, // 2
44 draw_mode_cursor, // 3
45 draw_mode_end_lazy // 4
46 };
47
48 #include "item.h"
49
50 struct display_context
51 {
52 struct graphics *gra;
53 struct element *e;
54 struct graphics_gc *gc;
55 struct graphics_gc *gc_background;
56 struct graphics_image *img;
57 enum projection pro;
58 int mindist;
59 struct transformation *trans;
60 enum item_type type;
61 int maxlen;
62 };
63
64 //#define HASH_SIZE_GRAPHICS_ 1024
65 #define HASH_SIZE_GRAPHICS_ 2048 // inc. hash size for layer items
66
67 struct hash_entry
68 {
69 enum item_type type;
70 struct displayitem *di;
71 };
72
73 struct displaylist
74 {
75 int busy;
76 int workload;
77 struct callback *cb;
78 struct layout *layout, *layout_hashed;
79 struct display_context dc;
80 int order, order_hashed, max_offset;
81 struct mapset *ms;
82 struct mapset_handle *msh;
83 struct map *m;
84 int conv;
85 struct map_selection *sel;
86 struct map_rect *mr;
87 struct callback *idle_cb;
88 struct event_idle *idle_ev;
89 unsigned int seq;
90 struct hash_entry hash_entries[HASH_SIZE_GRAPHICS_];
91 };
92
93 struct graphics_priv;
94 struct graphics_font_priv;
95 struct graphics_image_priv;
96 struct graphics_gc_priv;
97 struct graphics_font_methods;
98 struct graphics_gc_methods;
99 struct graphics_image_methods;
100
101 struct graphics_methods
102 {
103 void (*graphics_destroy)(struct graphics_priv *gr);
104 void (*draw_mode)(struct graphics_priv *gr, enum draw_mode_num mode);
105 void (*draw_lines)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
106 struct point *p, int count);
107 void (*draw_lines2)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
108 struct point *p, int count, int order, int oneway);
109 void (*draw_lines3)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
110 struct point *p, int count, int order, int width, int dashes, struct color *c);
111 void (*draw_lines4)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
112 struct point *p, int count, int order, int width, int type, int dashes, struct color *c);
113 void (*draw_lines_dashed)(struct graphics_priv *gr,
114 struct graphics_gc_priv *gc, struct point *p, int count, int order,
115 int oneway);
116 void (*draw_polygon)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
117 struct point *p, int count);
118 void (*draw_polygon2)(struct graphics_priv *gr,
119 struct graphics_gc_priv *gc, struct point *p, int count, int order,
120 int oneway);
121 void (*draw_rectangle)(struct graphics_priv *gr,
122 struct graphics_gc_priv *gc, struct point *p, int w, int h);
123 void (*draw_circle)(struct graphics_priv *gr, struct graphics_gc_priv *gc,
124 struct point *p, int r);
125 void (*draw_text)(struct graphics_priv *gr, struct graphics_gc_priv *fg,
126 struct graphics_gc_priv *bg, struct graphics_font_priv *font,
127 char *text, struct point *p, int dx, int dy);
128 void (*draw_image)(struct graphics_priv *gr, struct graphics_gc_priv *fg,
129 struct point *p, struct graphics_image_priv *img);
130 void (*draw_bigmap)(struct graphics_priv *gr, struct graphics_gc_priv *fg,
131 int yaw, int order, float clat, float clng, int x, int y, int scx,
132 int scy, int px, int py, int valid);
133 void
134 (*draw_image_warp)(struct graphics_priv *gr,
135 struct graphics_gc_priv *fg, struct point *p, int count,
136 char *data);
137 void (*draw_restore)(struct graphics_priv *gr, struct point *p, int w,
138 int h);
139 void (*draw_drag)(struct graphics_priv *gr, struct point *p);
140 struct graphics_font_priv
141 *(*font_new)(struct graphics_priv *gr,
142 struct graphics_font_methods *meth, char *font, int size,
143 int flags);
144 struct graphics_gc_priv *(*gc_new)(struct graphics_priv *gr,
145 struct graphics_gc_methods *meth);
146 void
147 (*background_gc)(struct graphics_priv *gr,
148 struct graphics_gc_priv *gc);
149 struct graphics_priv *(*overlay_new)(const char* name, struct graphics_priv *gr,
150 struct graphics_methods *meth, struct point *p, int w, int h,
151 int alpha, int wraparound);
152 struct graphics_image_priv *(*image_new)(struct graphics_priv *gr,
153 struct graphics_image_methods *meth, char *path, int *w, int *h,
154 struct point *hot, int rotation);
155 void *(*get_data)(struct graphics_priv *gr, const char *type);
156 void (*image_free)(struct graphics_priv *gr,
157 struct graphics_image_priv *priv);
158 void (*get_text_bbox)(struct graphics_priv *gr,
159 struct graphics_font_priv *font, char *text, int dx, int dy,
160 struct point *ret, int estimate);
161 void (*overlay_disable)(struct graphics_priv *gr, int disable);
162 void (*overlay_resize)(struct graphics_priv *gr, struct point *p, int w,
163 int h, int alpha, int wraparound);
164 int (*set_attr)(struct graphics_priv *gr, struct attr *attr);
165 };
166
167 struct graphics_font_methods
168 {
169 void (*font_destroy)(struct graphics_font_priv *font);
170 };
171
172 struct graphics_font
173 {
174 struct graphics_font_priv *priv;
175 struct graphics_font_methods meth;
176 };
177
178 struct graphics_gc_methods
179 {
180 void (*gc_destroy)(struct graphics_gc_priv *gc);
181 void (*gc_set_linewidth)(struct graphics_gc_priv *gc, int width);
182 void (*gc_set_dashes)(struct graphics *gra, struct graphics_gc_priv *gc, int width, int offset,
183 int dash_list[], int order);
184 void (*gc_set_foreground)(struct graphics_gc_priv *gc, struct color *c);
185 void (*gc_set_background)(struct graphics_gc_priv *gc, struct color *c);
186 void (*gc_set_stipple)(struct graphics_gc_priv *gc,
187 struct graphics_image_priv *img);
188 };
189
190 struct graphics_gc
191 {
192 struct graphics_gc_priv *priv;
193 struct graphics_gc_methods meth;
194 struct graphics *gra;
195 };
196
197 struct graphics_image_methods
198 {
199 void (*image_destroy)(struct graphics_image_priv *img);
200 };
201
202 struct graphics_image
203 {
204 struct graphics_image_priv *priv;
205 struct graphics_image_methods meth;
206 int width;
207 int height;
208 struct point hot;
209 };
210
211 struct graphics_data_image
212 {
213 void *data;
214 int size;
215 };
216
217 /* prototypes */
218 enum attr_type;
219 enum draw_mode_num;
220 enum item_type;
221 struct attr;
222 struct attr_iter;
223 struct callback;
224 struct color;
225 struct displayitem;
226 struct displaylist;
227 struct displaylist_handle;
228 struct graphics;
229 struct graphics_font;
230 struct graphics_gc;
231 struct graphics_image;
232 struct item;
233 struct itemgra;
234 struct layout;
235 struct mapset;
236 struct point;
237 struct point_rect;
238 struct transformation;
239 int graphics_set_attr(struct graphics *gra, struct attr *attr);
240 void graphics_set_rect(struct graphics *gra, struct point_rect *pr);
241 struct graphics *graphics_new(struct attr *parent, struct attr **attrs);
242 int graphics_get_attr(struct graphics *this_, enum attr_type type,
243 struct attr *attr, struct attr_iter *iter);
244 struct graphics *graphics_overlay_new(const char* name, struct graphics *parent, struct point *p,
245 int w, int h, int alpha, int wraparound);
246 void graphics_overlay_resize(struct graphics *this_, struct point *p, int w,
247 int h, int alpha, int wraparound);
248 void graphics_init(struct graphics *this_);
249 void *graphics_get_data(struct graphics *this_, const char *type);
250 void graphics_add_callback(struct graphics *this_, struct callback *cb);
251 void graphics_remove_callback(struct graphics *this_, struct callback *cb);
252 struct graphics_font *graphics_font_new(struct graphics *gra, int size,
253 int flags);
254 struct graphics_font *graphics_named_font_new(struct graphics *gra, char *font,
255 int size, int flags);
256 void graphics_free(struct graphics *gra);
257 void graphics_font_destroy_all(struct graphics *gra);
258 struct graphics_gc *graphics_gc_new(struct graphics *gra);
259 void graphics_gc_destroy(struct graphics_gc *gc);
260 void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c);
261 void graphics_gc_set_background(struct graphics_gc *gc, struct color *c);
262 void
263 graphics_gc_set_stipple(struct graphics_gc *gc,
264 struct graphics_image *img);
265 void graphics_gc_set_linewidth(struct graphics_gc *gc, int width);
266 void graphics_gc_set_dashes(struct graphics *gra, struct graphics_gc *gc, int width, int offset,
267 int dash_list[], int n, int order);
268 struct graphics_image *graphics_image_new_scaled(struct graphics *gra,
269 char *path, int w, int h);
270 struct graphics_image *graphics_image_new_scaled_rotated(struct graphics *gra,
271 char *path, int w, int h, int rotate);
272 struct graphics_image *graphics_image_new(struct graphics *gra, char *path);
273 void graphics_image_free(struct graphics *gra, struct graphics_image *img);
274 void graphics_draw_restore(struct graphics *this_, struct point *p, int w,
275 int h);
276 void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode);
277 void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc,
278 struct point *p, int count);
279 void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc,
280 struct point *p, int r);
281 void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc,
282 struct point *p, int w, int h);
283 void graphics_draw_rectangle_rounded(struct graphics *this_,
284 struct graphics_gc *gc, struct point *plu, int w, int h, int r,
285 int fill);
286 void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1,
287 struct graphics_gc *gc2, struct graphics_font *font, char *text,
288 struct point *p, int dx, int dy);
289 void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font,
290 char *text, int dx, int dy, struct point *ret, int estimate);
291 void graphics_overlay_disable(struct graphics *this_, int disable);
292 void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc,
293 struct point *p, struct graphics_image *img);
294 int graphics_draw_drag(struct graphics *this_, struct point *p);
295 void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc);
296 void graphics_draw_text_std(struct graphics *this_, int text_size, char *text,
297 struct point *p);
298 char *graphics_icon_path(char *icon);
299 void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm,
300 struct transformation *t, char *label);
301 void graphics_displaylist_draw(struct graphics *gra,
302 struct displaylist *displaylist, struct transformation *trans,
303 struct layout *l, int flags);
304 void graphics_draw(struct graphics *gra, struct displaylist *displaylist,
305 struct mapset *mapset, struct transformation *trans, struct layout *l,
306 int async, struct callback *cb, int flags);
307 int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist);
308 struct displaylist_handle *graphics_displaylist_open(
309 struct displaylist *displaylist);
310 struct displayitem *graphics_displaylist_next(struct displaylist_handle *dlh);
311 void graphics_displaylist_close(struct displaylist_handle *dlh);
312 struct displaylist *graphics_displaylist_new(void);
313 struct item *graphics_displayitem_get_item(struct displayitem *di);
314 int graphics_displayitem_get_coord_count(struct displayitem *di);
315 char *graphics_displayitem_get_label(struct displayitem *di);
316 int graphics_displayitem_get_displayed(struct displayitem *di);
317 int graphics_displayitem_within_dist(struct displaylist *displaylist,
318 struct displayitem *di, struct point *p, int dist);
319 void graphics_add_selection(struct graphics *gra, struct item *item,
320 enum item_type type, struct displaylist *dl);
321 void graphics_remove_selection(struct graphics *gra, struct item *item,
322 enum item_type type, struct displaylist *dl);
323 void graphics_clear_selection(struct graphics *gra, struct displaylist *dl);
324 /* end of prototypes */
325 #ifdef __cplusplus
326 }
327 #endif
328
329 #endif
330

   
Visit the ZANavi Wiki