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

Contents of /navit/navit/graphics.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 40 - (show annotations) (download)
Wed Mar 4 14:00:54 2015 UTC (4 years, 7 months ago) by zoff99
File MIME type: text/plain
File size: 12033 byte(s)
new market version, lots of fixes
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 struct hash_entry
67 {
68 enum item_type type;
69 struct displayitem *di;
70 };
71
72 struct displaylist
73 {
74 int busy;
75 int workload;
76 struct callback *cb;
77 struct layout *layout, *layout_hashed;
78 struct display_context dc;
79 int order, order_hashed, max_offset;
80 struct mapset *ms;
81 struct mapset_handle *msh;
82 struct map *m;
83 int conv;
84 struct map_selection *sel;
85 struct map_rect *mr;
86 struct callback *idle_cb;
87 struct event_idle *idle_ev;
88 unsigned int seq;
89 struct hash_entry hash_entries[HASH_SIZE_GRAPHICS_];
90 };
91
92 struct graphics_priv;
93 struct graphics_font_priv;
94 struct graphics_image_priv;
95 struct graphics_gc_priv;
96 struct graphics_font_methods;
97 struct graphics_gc_methods;
98 struct graphics_image_methods;
99
100 struct graphics_methods
101 {
102 void (*graphics_destroy)(struct graphics_priv *gr);
103 void (*draw_mode)(struct graphics_priv *gr, enum draw_mode_num mode);
104 void (*draw_lines)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
105 void (*draw_lines2)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int order, int oneway);
106 void (*draw_lines3)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int order, int width, int dashes, struct color *c, int clinedrawing_mode_active, int with_end);
107 void (*draw_lines4)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int order, int width, int type, int dashes, struct color *c, int with_end);
108 void (*draw_lines_dashed)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int order, int oneway);
109 void (*draw_polygon)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
110 void (*draw_polygon2)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int order, int oneway);
111 void (*draw_rectangle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h);
112 void (*draw_circle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r);
113 void (*draw_text)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy);
114 void (*draw_image)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img);
115 void (*draw_bigmap)(struct graphics_priv *gr, struct graphics_gc_priv *fg, int yaw, int order, float clat, float clng, int x, int y, int scx, int scy, int px, int py, int valid);
116 void
117 (*draw_image_warp)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, char *data);
118 void (*draw_restore)(struct graphics_priv *gr, struct point *p, int w, int h);
119 void (*draw_drag)(struct graphics_priv *gr, struct point *p);
120 struct graphics_font_priv
121 *(*font_new)(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font, int size, int flags);
122 struct graphics_gc_priv *(*gc_new)(struct graphics_priv *gr, struct graphics_gc_methods *meth);
123 void
124 (*background_gc)(struct graphics_priv *gr, struct graphics_gc_priv *gc);
125 struct graphics_priv *(*overlay_new)(const char* name, struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int alpha, int wraparound);
126 struct graphics_image_priv *(*image_new)(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation);
127 void *(*get_data)(struct graphics_priv *gr, const char *type);
128 void (*image_free)(struct graphics_priv *gr, struct graphics_image_priv *priv);
129 void (*get_text_bbox)(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate);
130 void (*overlay_disable)(struct graphics_priv *gr, int disable);
131 void (*overlay_resize)(struct graphics_priv *gr, struct point *p, int w, int h, int alpha, int wraparound);
132 int (*set_attr)(struct graphics_priv *gr, struct attr *attr);
133 };
134
135 struct graphics_font_methods
136 {
137 void (*font_destroy)(struct graphics_font_priv *font);
138 };
139
140 struct graphics_font
141 {
142 struct graphics_font_priv *priv;
143 struct graphics_font_methods meth;
144 };
145
146 struct graphics_gc_methods
147 {
148 void (*gc_destroy)(struct graphics_gc_priv *gc);
149 void (*gc_set_linewidth)(struct graphics_gc_priv *gc, int width);
150 void (*gc_set_dashes)(struct graphics *gra, struct graphics_gc_priv *gc, int width, int offset, int dash_list[], int order);
151 void (*gc_set_foreground)(struct graphics_gc_priv *gc, struct color *c);
152 void (*gc_set_background)(struct graphics_gc_priv *gc, struct color *c);
153 void (*gc_set_stipple)(struct graphics_gc_priv *gc, struct graphics_image_priv *img);
154 };
155
156 struct graphics_gc
157 {
158 struct graphics_gc_priv *priv;
159 struct graphics_gc_methods meth;
160 struct graphics *gra;
161 };
162
163 struct graphics_image_methods
164 {
165 void (*image_destroy)(struct graphics_image_priv *img);
166 };
167
168 struct graphics_image
169 {
170 struct graphics_image_priv *priv;
171 struct graphics_image_methods meth;
172 int width;
173 int height;
174 struct point hot;
175 };
176
177 struct graphics_data_image
178 {
179 void *data;
180 int size;
181 };
182
183 /* prototypes */
184 enum attr_type;
185 enum draw_mode_num;
186 enum item_type;
187 struct attr;
188 struct attr_iter;
189 struct callback;
190 struct color;
191 struct displayitem;
192 struct displaylist;
193 struct displaylist_handle;
194 struct graphics;
195 struct graphics_font;
196 struct graphics_gc;
197 struct graphics_image;
198 struct item;
199 struct itemgra;
200 struct layout;
201 struct mapset;
202 struct point;
203 struct point_rect;
204 struct transformation;
205 int graphics_set_attr(struct graphics *gra, struct attr *attr);
206 void graphics_set_rect(struct graphics *gra, struct point_rect *pr);
207 struct graphics *graphics_new(struct attr *parent, struct attr **attrs);
208 int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
209 struct graphics *graphics_overlay_new(const char* name, struct graphics *parent, struct point *p, int w, int h, int alpha, int wraparound);
210 void graphics_overlay_resize(struct graphics *this_, struct point *p, int w, int h, int alpha, int wraparound);
211 void graphics_init(struct graphics *this_);
212 void *graphics_get_data(struct graphics *this_, const char *type);
213 void graphics_add_callback(struct graphics *this_, struct callback *cb);
214 void graphics_remove_callback(struct graphics *this_, struct callback *cb);
215 struct graphics_font *graphics_font_new(struct graphics *gra, int size, int flags);
216 struct graphics_font *graphics_named_font_new(struct graphics *gra, char *font, int size, int flags);
217 void graphics_free(struct graphics *gra);
218 void graphics_font_destroy_all(struct graphics *gra);
219 struct graphics_gc *graphics_gc_new(struct graphics *gra);
220 void graphics_gc_destroy(struct graphics_gc *gc);
221 void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c);
222 void graphics_gc_set_background(struct graphics_gc *gc, struct color *c);
223 void
224 graphics_gc_set_stipple(struct graphics_gc *gc, struct graphics_image *img);
225 void graphics_gc_set_linewidth(struct graphics_gc *gc, int width);
226 void graphics_gc_set_dashes(struct graphics *gra, struct graphics_gc *gc, int width, int offset, int dash_list[], int n, int order);
227 struct graphics_image *graphics_image_new_scaled(struct graphics *gra, char *path, int w, int h);
228 struct graphics_image *graphics_image_new_scaled_rotated(struct graphics *gra, char *path, int w, int h, int rotate);
229 struct graphics_image *graphics_image_new(struct graphics *gra, char *path);
230 void graphics_image_free(struct graphics *gra, struct graphics_image *img);
231 void graphics_draw_restore(struct graphics *this_, struct point *p, int w, int h);
232 void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode);
233 void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count);
234 void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r);
235 void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h);
236 void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc *gc, struct point *plu, int w, int h, int r, int fill);
237 void graphics_draw_text(struct graphics *this_, struct graphics_gc *gc1, struct graphics_gc *gc2, struct graphics_font *font, char *text, struct point *p, int dx, int dy);
238 void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret, int estimate);
239 void graphics_overlay_disable(struct graphics *this_, int disable);
240 void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img);
241 int graphics_draw_drag(struct graphics *this_, struct point *p);
242 void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc);
243 void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p);
244 char *graphics_icon_path(char *icon);
245 void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label);
246 void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags);
247 void graphics_draw(struct graphics *gra, struct displaylist *displaylist, struct mapset *mapset, struct transformation *trans, struct layout *l, int async, struct callback *cb, int flags);
248 int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist);
249 struct displaylist_handle *graphics_displaylist_open(struct displaylist *displaylist);
250 struct displayitem *graphics_displaylist_next(struct displaylist_handle *dlh);
251 void graphics_displaylist_close(struct displaylist_handle *dlh);
252 struct displaylist *graphics_displaylist_new(void);
253 struct item *graphics_displayitem_get_item(struct displayitem *di);
254 int graphics_displayitem_get_coord_count(struct displayitem *di);
255 char *graphics_displayitem_get_label(struct displayitem *di);
256 int graphics_displayitem_get_displayed(struct displayitem *di);
257 int graphics_displayitem_within_dist(struct displaylist *displaylist, struct displayitem *di, struct point *p, int dist);
258 void graphics_add_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl);
259 void graphics_remove_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl);
260 void graphics_clear_selection(struct graphics *gra, struct displaylist *dl);
261 /* end of prototypes */
262 #ifdef __cplusplus
263 }
264 #endif
265
266 #endif
267

   
Visit the ZANavi Wiki