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

Contents of /navit/navit/graphics.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (hide annotations) (download)
Mon Feb 4 17:41:59 2013 UTC (6 years, 8 months ago) by zoff99
File MIME type: text/plain
File size: 11975 byte(s)
new map version, lots of fixes and experimental new features
1 zoff99 2 /**
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 zoff99 27 extern "C"
25     {
26 zoff99 2 #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 zoff99 27 enum draw_mode_num
40     {
41 zoff99 30 draw_mode_begin, // 0
42     draw_mode_begin_clear, // 1
43     draw_mode_end, // 2
44     draw_mode_cursor, // 3
45 zoff99 31 draw_mode_end_lazy
46     // 4
47 zoff99 2 };
48    
49 zoff99 27 #include "item.h"
50    
51     struct display_context
52     {
53     struct graphics *gra;
54     struct element *e;
55     struct graphics_gc *gc;
56     struct graphics_gc *gc_background;
57     struct graphics_image *img;
58     enum projection pro;
59     int mindist;
60     struct transformation *trans;
61     enum item_type type;
62     int maxlen;
63     };
64    
65     //#define HASH_SIZE_GRAPHICS_ 1024
66     #define HASH_SIZE_GRAPHICS_ 2048 // inc. hash size for layer items
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 zoff99 2 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 zoff99 27 struct graphics_methods
102     {
103 zoff99 2 void (*graphics_destroy)(struct graphics_priv *gr);
104     void (*draw_mode)(struct graphics_priv *gr, enum draw_mode_num mode);
105 zoff99 31 void (*draw_lines)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
106     void (*draw_lines2)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int order, int oneway);
107     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);
108     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);
109     void (*draw_lines_dashed)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int order, int oneway);
110     void (*draw_polygon)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
111     void (*draw_polygon2)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int order, int oneway);
112     void (*draw_rectangle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h);
113     void (*draw_circle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r);
114     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);
115     void (*draw_image)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img);
116     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);
117 zoff99 27 void
118 zoff99 31 (*draw_image_warp)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, char *data);
119     void (*draw_restore)(struct graphics_priv *gr, struct point *p, int w, int h);
120 zoff99 2 void (*draw_drag)(struct graphics_priv *gr, struct point *p);
121 zoff99 27 struct graphics_font_priv
122 zoff99 31 *(*font_new)(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font, int size, int flags);
123     struct graphics_gc_priv *(*gc_new)(struct graphics_priv *gr, struct graphics_gc_methods *meth);
124 zoff99 27 void
125 zoff99 31 (*background_gc)(struct graphics_priv *gr, struct graphics_gc_priv *gc);
126     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);
127     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);
128 zoff99 2 void *(*get_data)(struct graphics_priv *gr, const char *type);
129 zoff99 31 void (*image_free)(struct graphics_priv *gr, struct graphics_image_priv *priv);
130     void (*get_text_bbox)(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate);
131 zoff99 2 void (*overlay_disable)(struct graphics_priv *gr, int disable);
132 zoff99 31 void (*overlay_resize)(struct graphics_priv *gr, struct point *p, int w, int h, int alpha, int wraparound);
133 zoff99 2 int (*set_attr)(struct graphics_priv *gr, struct attr *attr);
134     };
135    
136 zoff99 27 struct graphics_font_methods
137     {
138 zoff99 2 void (*font_destroy)(struct graphics_font_priv *font);
139     };
140    
141 zoff99 27 struct graphics_font
142     {
143 zoff99 2 struct graphics_font_priv *priv;
144     struct graphics_font_methods meth;
145     };
146    
147 zoff99 27 struct graphics_gc_methods
148     {
149 zoff99 2 void (*gc_destroy)(struct graphics_gc_priv *gc);
150     void (*gc_set_linewidth)(struct graphics_gc_priv *gc, int width);
151 zoff99 31 void (*gc_set_dashes)(struct graphics *gra, struct graphics_gc_priv *gc, int width, int offset, int dash_list[], int order);
152 zoff99 2 void (*gc_set_foreground)(struct graphics_gc_priv *gc, struct color *c);
153     void (*gc_set_background)(struct graphics_gc_priv *gc, struct color *c);
154 zoff99 31 void (*gc_set_stipple)(struct graphics_gc_priv *gc, struct graphics_image_priv *img);
155 zoff99 2 };
156    
157 zoff99 27 struct graphics_gc
158     {
159 zoff99 2 struct graphics_gc_priv *priv;
160     struct graphics_gc_methods meth;
161     struct graphics *gra;
162     };
163    
164 zoff99 27 struct graphics_image_methods
165     {
166 zoff99 2 void (*image_destroy)(struct graphics_image_priv *img);
167     };
168    
169 zoff99 27 struct graphics_image
170     {
171 zoff99 2 struct graphics_image_priv *priv;
172     struct graphics_image_methods meth;
173     int width;
174     int height;
175     struct point hot;
176     };
177    
178 zoff99 27 struct graphics_data_image
179     {
180 zoff99 2 void *data;
181     int size;
182     };
183    
184     /* prototypes */
185     enum attr_type;
186     enum draw_mode_num;
187     enum item_type;
188     struct attr;
189     struct attr_iter;
190     struct callback;
191     struct color;
192     struct displayitem;
193     struct displaylist;
194     struct displaylist_handle;
195     struct graphics;
196     struct graphics_font;
197     struct graphics_gc;
198     struct graphics_image;
199     struct item;
200     struct itemgra;
201     struct layout;
202     struct mapset;
203     struct point;
204     struct point_rect;
205     struct transformation;
206     int graphics_set_attr(struct graphics *gra, struct attr *attr);
207     void graphics_set_rect(struct graphics *gra, struct point_rect *pr);
208     struct graphics *graphics_new(struct attr *parent, struct attr **attrs);
209 zoff99 31 int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
210     struct graphics *graphics_overlay_new(const char* name, struct graphics *parent, struct point *p, int w, int h, int alpha, int wraparound);
211     void graphics_overlay_resize(struct graphics *this_, struct point *p, int w, int h, int alpha, int wraparound);
212 zoff99 2 void graphics_init(struct graphics *this_);
213     void *graphics_get_data(struct graphics *this_, const char *type);
214     void graphics_add_callback(struct graphics *this_, struct callback *cb);
215     void graphics_remove_callback(struct graphics *this_, struct callback *cb);
216 zoff99 31 struct graphics_font *graphics_font_new(struct graphics *gra, int size, int flags);
217     struct graphics_font *graphics_named_font_new(struct graphics *gra, char *font, int size, int flags);
218 zoff99 2 void graphics_free(struct graphics *gra);
219     void graphics_font_destroy_all(struct graphics *gra);
220     struct graphics_gc *graphics_gc_new(struct graphics *gra);
221     void graphics_gc_destroy(struct graphics_gc *gc);
222     void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c);
223     void graphics_gc_set_background(struct graphics_gc *gc, struct color *c);
224 zoff99 27 void
225 zoff99 31 graphics_gc_set_stipple(struct graphics_gc *gc, struct graphics_image *img);
226 zoff99 2 void graphics_gc_set_linewidth(struct graphics_gc *gc, int width);
227 zoff99 31 void graphics_gc_set_dashes(struct graphics *gra, struct graphics_gc *gc, int width, int offset, int dash_list[], int n, int order);
228     struct graphics_image *graphics_image_new_scaled(struct graphics *gra, char *path, int w, int h);
229     struct graphics_image *graphics_image_new_scaled_rotated(struct graphics *gra, char *path, int w, int h, int rotate);
230 zoff99 2 struct graphics_image *graphics_image_new(struct graphics *gra, char *path);
231     void graphics_image_free(struct graphics *gra, struct graphics_image *img);
232 zoff99 31 void graphics_draw_restore(struct graphics *this_, struct point *p, int w, int h);
233 zoff99 2 void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode);
234 zoff99 31 void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count);
235     void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r);
236     void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h);
237     void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc *gc, struct point *plu, int w, int h, int r, int fill);
238     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);
239     void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret, int estimate);
240 zoff99 2 void graphics_overlay_disable(struct graphics *this_, int disable);
241 zoff99 31 void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img);
242 zoff99 2 int graphics_draw_drag(struct graphics *this_, struct point *p);
243     void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc);
244 zoff99 31 void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p);
245 zoff99 2 char *graphics_icon_path(char *icon);
246 zoff99 31 void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label);
247     void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags);
248     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);
249 zoff99 2 int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist);
250 zoff99 31 struct displaylist_handle *graphics_displaylist_open(struct displaylist *displaylist);
251 zoff99 2 struct displayitem *graphics_displaylist_next(struct displaylist_handle *dlh);
252     void graphics_displaylist_close(struct displaylist_handle *dlh);
253     struct displaylist *graphics_displaylist_new(void);
254     struct item *graphics_displayitem_get_item(struct displayitem *di);
255     int graphics_displayitem_get_coord_count(struct displayitem *di);
256     char *graphics_displayitem_get_label(struct displayitem *di);
257     int graphics_displayitem_get_displayed(struct displayitem *di);
258 zoff99 31 int graphics_displayitem_within_dist(struct displaylist *displaylist, struct displayitem *di, struct point *p, int dist);
259     void graphics_add_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl);
260     void graphics_remove_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl);
261 zoff99 2 void graphics_clear_selection(struct graphics *gra, struct displaylist *dl);
262     /* end of prototypes */
263     #ifdef __cplusplus
264     }
265     #endif
266    
267     #endif
268    

   
Visit the ZANavi Wiki