Add:osd_core:Initial support for on-screen-buttons
[navit-package] / navit / graphics.h
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 #endif
26 struct point;
27 struct container;
28 struct color;
29 struct graphics;
30 struct graphics_gc;
31 struct graphics_font;
32 struct graphics_image;
33 struct transformation;
34 struct display_list;
35
36 enum draw_mode_num {
37         draw_mode_begin, draw_mode_end, draw_mode_cursor
38 };
39
40 struct graphics_priv;
41 struct graphics_font_priv;
42 struct graphics_image_priv;
43 struct graphics_gc_priv;
44 struct graphics_font_methods;
45 struct graphics_gc_methods;
46 struct graphics_image_methods;
47
48 struct graphics_methods {
49         void (*graphics_destroy)(struct graphics_priv *gr);
50         void (*draw_mode)(struct graphics_priv *gr, enum draw_mode_num mode);
51         void (*draw_lines)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
52         void (*draw_polygon)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
53         void (*draw_rectangle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h);
54         void (*draw_circle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r);
55         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);
56         void (*draw_image)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img);
57         void (*draw_image_warp)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, char *data);
58         void (*draw_restore)(struct graphics_priv *gr, struct point *p, int w, int h);
59         struct graphics_font_priv *(*font_new)(struct graphics_priv *gr, struct graphics_font_methods *meth, int size, int flags);
60         struct graphics_gc_priv *(*gc_new)(struct graphics_priv *gr, struct graphics_gc_methods *meth);
61         void (*background_gc)(struct graphics_priv *gr, struct graphics_gc_priv *gc);
62         struct graphics_priv *(*overlay_new)(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h);
63         struct graphics_image_priv *(*image_new)(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot);
64         void *(*get_data)(struct graphics_priv *gr, char *type);
65         void (*register_resize_callback)(struct graphics_priv *gr, void (*callback)(void *data, int w, int h), void *data);
66         void (*register_button_callback)(struct graphics_priv *gr, void (*callback)(void *data, int pressed, int button, struct point *p), void *data);
67         void (*register_motion_callback)(struct graphics_priv *gr, void (*callback)(void *data, struct point *p), void *data);
68         void (*image_free)(struct graphics_priv *gr, struct graphics_image_priv *priv);
69         void (*get_text_bbox)(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret);
70         void (*overlay_disable)(struct graphics_priv *gr, int disable);
71         void (*register_keypress_callback)(struct graphics_priv *gr, void (*callback)(void *data, int key), void *data);
72 };
73
74
75 struct graphics_font_methods {
76         void (*font_destroy)(struct graphics_font_priv *font);
77 };
78
79 struct graphics_font {
80         struct graphics_font_priv *priv;
81         struct graphics_font_methods meth;
82 };
83
84 struct graphics_gc_methods {
85         void (*gc_destroy)(struct graphics_gc_priv *gc);
86         void (*gc_set_linewidth)(struct graphics_gc_priv *gc, int width);
87         void (*gc_set_dashes)(struct graphics_gc_priv *gc, int width, int offset, unsigned char dash_list[], int n);
88         void (*gc_set_foreground)(struct graphics_gc_priv *gc, struct color *c);
89         void (*gc_set_background)(struct graphics_gc_priv *gc, struct color *c);
90 };
91
92 struct graphics_gc {
93         struct graphics_gc_priv *priv;
94         struct graphics_gc_methods meth;
95 };
96
97 struct graphics_image_methods {
98         void (*image_destroy)(struct graphics_image_priv *img);
99 };
100
101 struct graphics_image {
102         struct graphics_image_priv *priv;
103         struct graphics_image_methods meth;
104         int width;
105         int height;
106         struct point hot;
107 };
108
109 /* prototypes */
110 enum attr_type;
111 enum draw_mode_num;
112 struct attr;
113 struct attr_iter;
114 struct color;
115 struct displayitem;
116 struct displaylist;
117 struct displaylist_handle;
118 struct graphics;
119 struct graphics_font;
120 struct graphics_gc;
121 struct graphics_image;
122 struct item;
123 struct layout;
124 struct point;
125 struct transformation;
126 struct graphics *graphics_new(struct attr *parent, struct attr **attrs);
127 int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
128 struct graphics *graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h);
129 void graphics_init(struct graphics *this_);
130 void *graphics_get_data(struct graphics *this_, char *type);
131 void graphics_register_resize_callback(struct graphics *this_, void (*callback)(void *data, int w, int h), void *data);
132 void graphics_register_button_callback(struct graphics *this_, void (*callback)(void *data, int pressed, int button, struct point *p), void *data);
133 void graphics_register_motion_callback(struct graphics *this_, void (*callback)(void *data, struct point *p), void *data);
134 void graphics_register_keypress_callback(struct graphics *this_, void (*callback)(void *data, int key), void *data);
135 struct graphics_font *graphics_font_new(struct graphics *gra, int size, int flags);
136 struct graphics_gc *graphics_gc_new(struct graphics *gra);
137 void graphics_gc_destroy(struct graphics_gc *gc);
138 void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c);
139 void graphics_gc_set_background(struct graphics_gc *gc, struct color *c);
140 void graphics_gc_set_linewidth(struct graphics_gc *gc, int width);
141 void graphics_gc_set_dashes(struct graphics_gc *gc, int width, int offset, unsigned char dash_list[], int n);
142 struct graphics_image * graphics_image_new_scaled(struct graphics *gra, char *path, int w, int h);
143 struct graphics_image *graphics_image_new(struct graphics *gra, char *path);
144 void graphics_image_free(struct graphics *gra, struct graphics_image *img);
145 void graphics_draw_restore(struct graphics *this_, struct point *p, int w, int h);
146 void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode);
147 void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count);
148 void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r);
149 void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h);
150 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);
151 void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret);
152 void graphics_overlay_disable(struct graphics *this_, int disable);
153 void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img);
154 void display_add(struct displaylist *displaylist, struct item *item, int count, struct point *pnt, char *label);
155 int graphics_ready(struct graphics *this_);
156 void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int callback);
157 void graphics_displaylist_move(struct displaylist *displaylist, int dx, int dy);
158 void graphics_draw(struct graphics *gra, struct displaylist *displaylist, GList *mapsets, struct transformation *trans, struct layout *l);
159 struct displaylist_handle *graphics_displaylist_open(struct displaylist *displaylist);
160 struct displayitem *graphics_displaylist_next(struct displaylist_handle *dlh);
161 void graphics_displaylist_close(struct displaylist_handle *dlh);
162 struct displaylist *graphics_displaylist_new(void);
163 struct item *graphics_displayitem_get_item(struct displayitem *di);
164 char *graphics_displayitem_get_label(struct displayitem *di);
165 int graphics_displayitem_within_dist(struct displayitem *di, struct point *p, int dist);
166 /* end of prototypes */
167 #ifdef __cplusplus
168 }
169 #endif
170
171 #endif
172