navit  0.5.1-trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups
graphics.h
Go to the documentation of this file.
1 
25 #ifndef NAVIT_GRAPHICS_H
26 #define NAVIT_GRAPHICS_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 struct attr;
32 struct point;
33 struct container;
34 struct color;
35 struct graphics;
36 struct graphics_gc;
37 struct graphics_font;
38 struct graphics_image;
39 struct transformation;
40 struct display_list;
41 struct mapset;
42 
43 /* This enum must be synchronized with the constants in NavitGraphics.java. */
46 };
47 
48 struct graphics_priv;
49 struct graphics_font_priv;
50 struct graphics_image_priv;
51 struct graphics_gc_priv;
53 struct graphics_gc_methods;
55 
58 };
59 
61  char magic[8]; /* buffer:\0 */
63  void *start;
64  int len;
65 };
66 
67 struct graphics_keyboard_priv;
68 
73  int w;
74  int h;
75  /* TODO mode is currently a copy of the respective value in the internal GUI and uses the same values.
76  * This may need to be changed to something with globally available enum, possibly with revised values.
77  * The Android implementation (the first to support a native on-screen keyboard) does not use this field
78  * due to limitations of the platform. */
79  int mode;
80  char *lang;
81  void *gui_priv;
86  struct graphics_keyboard_priv *gra_priv;
90 };
91 
93 #define IMAGE_W_H_UNSET (-1)
94 
110 struct padding {
111  int left;
112  int top;
113  int right;
114  int bottom;
115 };
116 
118  void (*graphics_destroy)(struct graphics_priv *gr);
119  void (*draw_mode)(struct graphics_priv *gr, enum draw_mode_num mode);
120  void (*draw_lines)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
121  void (*draw_polygon)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
122  void (*draw_rectangle)(struct graphics_priv *gr, 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, struct point *p, int r);
124  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);
125  void (*draw_image)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img);
126  void (*draw_image_warp)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, struct graphics_image_priv *img);
127  void (*draw_drag)(struct graphics_priv *gr, struct point *p);
128  struct graphics_font_priv *(*font_new)(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font, int size, int flags);
129  struct graphics_gc_priv *(*gc_new)(struct graphics_priv *gr, struct graphics_gc_methods *meth);
130  void (*background_gc)(struct graphics_priv *gr, struct graphics_gc_priv *gc);
131  struct graphics_priv *(*overlay_new)(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound);
145  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);
146  void *(*get_data)(struct graphics_priv *gr, const char *type);
147  void (*image_free)(struct graphics_priv *gr, struct graphics_image_priv *priv);
148  void (*get_text_bbox)(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate);
149  void (*overlay_disable)(struct graphics_priv *gr, int disable);
150  void (*overlay_resize)(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound);
151  int (*set_attr)(struct graphics_priv *gr, struct attr *attr);
154 };
155 
156 
159 };
160 
164 };
165 
167  void (*gc_destroy)(struct graphics_gc_priv *gc);
168  void (*gc_set_linewidth)(struct graphics_gc_priv *gc, int width);
169  void (*gc_set_dashes)(struct graphics_gc_priv *gc, int width, int offset, unsigned char dash_list[], int n);
170  void (*gc_set_foreground)(struct graphics_gc_priv *gc, struct color *c);
171  void (*gc_set_background)(struct graphics_gc_priv *gc, struct color *c);
172 };
173 
179 struct graphics_gc {
182  struct graphics *gra;
183 };
184 
187 };
188 
192  int width;
193  int height;
194  struct point hot;
195 };
196 
198  void *data;
199  int size;
200 };
201 
202 /* prototypes */
203 enum attr_type;
204 enum draw_mode_num;
205 enum item_type;
206 struct attr;
207 struct attr_iter;
208 struct callback;
209 struct color;
210 struct displayitem;
211 struct displaylist;
212 struct displaylist_handle;
213 struct graphics;
214 struct graphics_font;
215 struct graphics_gc;
216 struct graphics_image;
217 struct item;
218 struct itemgra;
219 struct layout;
220 struct mapset;
221 struct point;
222 struct point_rect;
223 struct transformation;
224 int graphics_set_attr(struct graphics *gra, struct attr *attr);
225 void graphics_set_rect(struct graphics *gra, struct point_rect *pr);
226 struct graphics *graphics_new(struct attr *parent, struct attr **attrs);
227 int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
228 struct graphics *graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h, int wraparound);
229 void graphics_overlay_resize(struct graphics *this_, struct point *p, int w, int h, int wraparound);
230 void graphics_init(struct graphics *this_);
231 void *graphics_get_data(struct graphics *this_, const char *type);
232 void graphics_add_callback(struct graphics *this_, struct callback *cb);
233 void graphics_remove_callback(struct graphics *this_, struct callback *cb);
234 struct graphics_font *graphics_font_new(struct graphics *gra, int size, int flags);
235 struct graphics_font *graphics_named_font_new(struct graphics *gra, char *font, int size, int flags);
236 void graphics_font_destroy(struct graphics_font *gra_font);
237 void graphics_free(struct graphics *gra);
238 void graphics_font_destroy_all(struct graphics *gra);
239 struct graphics_gc *graphics_gc_new(struct graphics *gra);
240 void graphics_gc_destroy(struct graphics_gc *gc);
241 void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c);
242 void graphics_gc_set_background(struct graphics_gc *gc, struct color *c);
243 void graphics_gc_set_linewidth(struct graphics_gc *gc, int width);
244 void graphics_gc_set_dashes(struct graphics_gc *gc, int width, int offset, unsigned char dash_list[], int n);
245 struct graphics_image *graphics_image_new_scaled(struct graphics *gra, char *path, int w, int h);
246 struct graphics_image *graphics_image_new_scaled_rotated(struct graphics *gra, char *path, int w, int h, int rotate);
247 struct graphics_image *graphics_image_new(struct graphics *gra, char *path);
248 void graphics_image_free(struct graphics *gra, struct graphics_image *img);
249 void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode);
250 void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count);
251 void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r);
252 void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h);
253 void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc *gc, struct point *plu, int w, int h, int r, int fill);
254 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);
255 void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret, int estimate);
256 void graphics_overlay_disable(struct graphics *this_, int disable);
257 int graphics_is_disabled(struct graphics *this_);
258 void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img);
259 int graphics_draw_drag(struct graphics *this_, struct point *p);
260 void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc);
261 void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p);
262 char *graphics_icon_path(const char *icon);
263 void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label);
264 void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags);
265 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);
266 int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist);
273 GList *displaylist_get_clicked_list(struct displaylist *displaylist, struct point *p, int radius);
279 int graphics_displayitem_within_dist(struct displaylist *displaylist, struct displayitem *di, struct point *p, int dist);
280 void graphics_add_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl);
281 void graphics_remove_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl);
282 void graphics_clear_selection(struct graphics *gra, struct displaylist *dl);
283 int graphics_show_native_keyboard (struct graphics *this_, struct graphics_keyboard *kbd);
284 int graphics_hide_native_keyboard (struct graphics *this_, struct graphics_keyboard *kbd);
285 
286 /* end of prototypes */
287 #ifdef __cplusplus
288 }
289 #endif
290 
291 #endif
292 
struct graphics_gc * graphics_gc_new(struct graphics *gra)
Definition: graphics.c:544
attr_type
Definition: attr.h:34
draw_mode_num
Definition: graphics.h:44
void(* draw_circle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
Definition: graphics.h:123
char * graphics_displayitem_get_label(struct displayitem *di)
Definition: graphics.c:2799
void(* draw_mode)(struct graphics_priv *gr, enum draw_mode_num mode)
Definition: graphics.h:119
int width
Definition: graphics.h:192
int mode
Definition: graphics.h:79
struct graphics_gc_priv * priv
Definition: graphics.h:180
unsigned char p[5]
Definition: mg.h:48
void(* draw_polygon)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
Definition: graphics.h:121
void graphics_font_destroy_all(struct graphics *gra)
Definition: graphics.c:527
int graphics_show_native_keyboard(struct graphics *this_, struct graphics_keyboard *kbd)
Shows the native on-screen keyboard or other input method.
Definition: graphics.c:1114
struct graphics_font * graphics_named_font_new(struct graphics *gra, char *font, int size, int flags)
Definition: graphics.c:463
struct item * graphics_displayitem_get_item(struct displayitem *di)
Definition: graphics.c:2769
tuple iter
Definition: eval.py:8
Definition: gpx2navit_txt.h:51
int right
Definition: graphics.h:113
QFont * font
Definition: graphics_qt5.cpp:85
int len
Definition: graphics.h:64
int offset
Definition: garmin_img.c:69
void graphics_gc_set_dashes(struct graphics_gc *gc, int width, int offset, unsigned char dash_list[], int n)
Definition: graphics.c:650
int height
Definition: graphics.h:193
void graphics_displaylist_close(struct displaylist_handle *dlh)
Definition: graphics.c:2733
void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc)
Definition: graphics.c:1068
void graphics_free(struct graphics *gra)
Definition: graphics.c:486
struct graphics_image * graphics_image_new_scaled_rotated(struct graphics *gra, char *path, int w, int h, int rotate)
Create a new image from file path, optionally scaled to w and h pixels and rotated.
Definition: graphics.c:796
int size
Definition: garmin_img.c:131
int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist)
Definition: graphics.c:2663
void graphics_remove_callback(struct graphics *this_, struct callback *cb)
Definition: graphics.c:443
Definition: item.h:99
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)
Definition: graphics.c:2657
void graphics_init(struct graphics *this_)
Definition: graphics.c:416
Definition: color.h:23
graphics context A graphics context encapsulates a set of drawing parameters, such as linewidth and d...
Definition: graphics.h:179
A mapset.
Definition: mapset.c:44
int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
Gets an attribute of the graphics instance.
Definition: graphics.c:327
void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r)
Definition: graphics.c:951
Definition: graphics.h:185
int graphics_set_attr(struct graphics *gra, struct attr *attr)
Sets an attribute of the graphics instance.
Definition: graphics.c:241
void * graphics_get_data(struct graphics *this_, const char *type)
Definition: graphics.c:433
struct graphics * graphics_new(struct attr *parent, struct attr **attrs)
Definition: graphics.c:266
GList * displaylist_get_clicked_list(struct displaylist *displaylist, struct point *p, int radius)
Returns list of displayitems clicked at given coordinates. The deeper item is in current layout...
Definition: graphics.c:2441
void(* image_destroy)(struct graphics_image_priv *img)
Definition: graphics.h:186
int graphics_displayitem_get_z_order(struct displayitem *di)
Definition: graphics.c:2781
item_type
Definition: item.h:29
int size
Definition: graphics.h:199
void(* gc_set_linewidth)(struct graphics_gc_priv *gc, int width)
Definition: graphics.h:168
struct graphics_keyboard_priv * gra_priv
Definition: graphics.h:86
void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count)
Definition: graphics.c:940
struct graphics_image_methods meth
Definition: graphics.h:191
char magic[8]
Definition: graphics.h:61
struct graphics * graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h, int wraparound)
Create a new graphics overlay. An overlay is a graphics object that is independent of the main graphi...
Definition: graphics.c:350
The functions to be implemented by graphics plugins.
Definition: graphics.h:110
void * data
Definition: graphics.h:198
Definition: graphics.h:166
int graphics_draw_drag(struct graphics *this_, struct point *p)
Definition: graphics.c:1059
struct displaylist_handle * graphics_displaylist_open(struct displaylist *displaylist)
Definition: graphics.c:2689
int(* set_attr)(struct graphics_priv *gr, struct attr *attr)
Definition: graphics.h:151
Definition: graphics.h:161
void graphics_clear_selection(struct graphics *gra, struct displaylist *dl)
Definition: graphics.c:3028
int bottom
Definition: graphics.h:114
int graphics_displayitem_get_displayed(struct displayitem *di)
Definition: graphics.c:2805
void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc *gc, struct point *plu, int w, int h, int r, int fill)
Definition: graphics.c:978
struct point hot
Definition: graphics.h:194
int mode
Definition: graphics_win32.c:59
void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags)
Definition: graphics.c:2585
void graphics_image_free(struct graphics *gra, struct graphics_image *img)
Definition: graphics.c:913
void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img)
Definition: graphics.c:1047
void graphics_gc_set_linewidth(struct graphics_gc *gc, int width)
Definition: graphics.c:639
void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c)
Definition: graphics.c:606
Definition: graphics.h:57
Definition: graphics.h:189
void(* image_free)(struct graphics_priv *gr, struct graphics_image_priv *priv)
Definition: graphics.h:147
void(* draw_image_warp)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, struct graphics_image_priv *img)
Definition: graphics.h:126
Definition: graphics.h:117
int w
Definition: graphics.h:73
int graphics_displayitem_get_coord_count(struct displayitem *di)
Definition: graphics.c:2788
SDL_Surface * img
Definition: graphics_egl.c:106
struct graphics_image * graphics_image_new_scaled(struct graphics *gra, char *path, int w, int h)
Create a new image from file path, optionally scaled to w and h pixels.
Definition: graphics.c:666
Definition: graphics.h:157
void(* draw_rectangle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
Definition: graphics.h:122
graphics object A graphics object serves as the target for drawing operations. It encapsulates variou...
Definition: graphics.c:70
Definition: config_.c:48
int h
Definition: graphics.h:74
Definition: graphics_android.c:37
struct graphics_image * graphics_image_new(struct graphics *gra, char *path)
Definition: graphics.c:902
void graphics_overlay_resize(struct graphics *this_, struct point *p, int w, int h, int wraparound)
Alters the size, position and wraparound for an overlay.
Definition: graphics.c:383
void(* draw_image)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
Definition: graphics.h:125
void(* gc_set_foreground)(struct graphics_gc_priv *gc, struct color *c)
Definition: graphics.h:170
void(* draw_drag)(struct graphics_priv *gr, struct point *p)
Definition: graphics.h:127
void * gui_priv
Definition: graphics.h:81
void graphics_add_callback(struct graphics *this_, struct callback *cb)
Definition: graphics.c:438
char * lang
Definition: graphics.h:80
graphics_image_type
Definition: graphics.h:56
Definition: graphics.h:45
Definition: attr.h:156
Used to select data from a map.
Definition: map.h:57
unsigned char * dash_list
Definition: graphics_egl.c:66
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)
Definition: graphics.h:124
void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode)
Start or finish a set of drawing operations.
Definition: graphics.c:929
struct map_selection * displaylist_get_selection(struct displaylist *displaylist)
Returns selection structure based on displaylist transform, projection and order. Use this function t...
Definition: graphics.c:2416
int disable
Definition: graphics_qt5.h:89
void graphics_remove_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl)
Definition: graphics.c:2992
void graphics_displaylist_destroy(struct displaylist *displaylist)
Definition: graphics.c:2753
void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h)
Definition: graphics.c:973
char * graphics_icon_path(const char *icon)
Definition: graphics.c:2047
Definition: callback.c:26
int graphics_is_disabled(struct graphics *this_)
Definition: graphics.c:1036
void graphics_set_rect(struct graphics *gra, struct point_rect *pr)
Definition: graphics.c:254
int graphics_hide_native_keyboard(struct graphics *this_, struct graphics_keyboard *kbd)
Hides the native on-screen keyboard or other input method.
Definition: graphics.c:1151
void graphics_font_destroy(struct graphics_font *gra_font)
Definition: graphics.c:472
Definition: layout.h:71
void(* font_destroy)(struct graphics_font_priv *font)
Definition: graphics.h:158
void graphics_gc_set_background(struct graphics_gc *gc, struct color *c)
Definition: graphics.c:622
float fg
Definition: graphics_egl.c:63
void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p)
Definition: graphics.c:2031
Definition: graphics.h:45
void(* graphics_destroy)(struct graphics_priv *gr)
Definition: graphics.h:118
Definition: point.h:23
void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret, int estimate)
Definition: graphics.c:1018
Definition: graphics.c:2677
struct attr ** attrs
Definition: graphics.c:79
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)
Definition: graphics.c:1006
void(* gc_set_background)(struct graphics_gc_priv *gc, struct color *c)
Definition: graphics.h:171
void(* get_text_bbox)(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate)
Definition: graphics.h:148
void graphics_gc_destroy(struct graphics_gc *gc)
Definition: graphics.c:559
int graphics_displayitem_within_dist(struct displaylist *displaylist, struct displayitem *di, struct point *p, int dist)
Definition: graphics.c:2925
void(* gc_destroy)(struct graphics_gc_priv *gc)
Definition: graphics.h:167
void(* hide_native_keyboard)(struct graphics_keyboard *kbd)
Definition: graphics.h:153
int top
Definition: graphics.h:112
struct displaylist * graphics_displaylist_new(void)
Definition: graphics.c:2744
struct graphics_gc_methods meth
Definition: graphics.h:181
Definition: point.h:28
Definition: graphics_android.c:76
struct graphics * gra
Definition: graphics.h:182
void(* overlay_resize)(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound)
Definition: graphics.h:150
void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label)
Definition: graphics.c:2277
void graphics_add_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl)
Definition: graphics.c:2981
float bg
Definition: graphics_egl.c:64
Definition: graphics.c:116
void(* overlay_disable)(struct graphics_priv *gr, int disable)
Definition: graphics.h:149
struct graphics_font_priv * priv
Definition: graphics.h:162
Definition: graphics_android.c:85
struct label_data_offset label
Definition: garmin_img.c:409
typedef int(WINAPI *FP_SetStretchBltMode)(HDC dc
enum graphics_image_type type
Definition: graphics.h:62
Definition: graphics_android.c:72
void graphics_overlay_disable(struct graphics *this_, int disable)
Definition: graphics.c:1029
char type[3]
Definition: garmin_img.c:130
int(* show_native_keyboard)(struct graphics_keyboard *kbd)
Definition: graphics.h:152
void(* background_gc)(struct graphics_priv *gr, struct graphics_gc_priv *gc)
Definition: graphics.h:130
struct graphics_font * graphics_font_new(struct graphics *gra, int size, int flags)
Definition: graphics.c:454
void(* gc_set_dashes)(struct graphics_gc_priv *gc, int width, int offset, unsigned char dash_list[], int n)
Definition: graphics.h:169
struct graphics_font_methods meth
Definition: graphics.h:163
struct displayitem * graphics_displaylist_next(struct displaylist_handle *dlh)
Definition: graphics.c:2705
struct graphics_image_priv * priv
Definition: graphics.h:190
The parameters needed to transform a map for display.
Definition: transform.c:64
flags
Definition: gui_internal.h:26
Definition: graphics.h:197
Definition: graphics.h:72
void(* draw_lines)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
Definition: graphics.h:120
unsigned short width
Definition: garmin_img.c:524
Definition: graphics.h:60
void * start
Definition: graphics.h:63
Definition: graphics.c:1168
int left
Definition: graphics.h:111
Definition: layout.h:95