Navit SVN

/work/compile/navit/src/navit/graphics.h

00001 
00020 #ifndef NAVIT_GRAPHICS_H
00021 #define NAVIT_GRAPHICS_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 struct attr;
00027 struct point;
00028 struct container;
00029 struct color;
00030 struct graphics;
00031 struct graphics_gc;
00032 struct graphics_font;
00033 struct graphics_image;
00034 struct transformation;
00035 struct display_list;
00036 struct mapset;
00037 
00038 enum draw_mode_num {
00039         draw_mode_begin, draw_mode_begin_clear, draw_mode_end, draw_mode_cursor, draw_mode_end_lazy
00040 };
00041 
00042 struct graphics_priv;
00043 struct graphics_font_priv;
00044 struct graphics_image_priv;
00045 struct graphics_gc_priv;
00046 struct graphics_font_methods;
00047 struct graphics_gc_methods;
00048 struct graphics_image_methods;
00049 
00050 struct graphics_methods {
00051         void (*graphics_destroy)(struct graphics_priv *gr);
00052         void (*draw_mode)(struct graphics_priv *gr, enum draw_mode_num mode);
00053         void (*draw_lines)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
00054         void (*draw_polygon)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count);
00055         void (*draw_rectangle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h);
00056         void (*draw_circle)(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r);
00057         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);
00058         void (*draw_image)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img);
00059         void (*draw_image_warp)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, char *data);
00060         void (*draw_restore)(struct graphics_priv *gr, struct point *p, int w, int h);
00061         void (*draw_drag)(struct graphics_priv *gr, struct point *p);
00062         struct graphics_font_priv *(*font_new)(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font,  int size, int flags);
00063         struct graphics_gc_priv *(*gc_new)(struct graphics_priv *gr, struct graphics_gc_methods *meth);
00064         void (*background_gc)(struct graphics_priv *gr, struct graphics_gc_priv *gc);
00065         struct graphics_priv *(*overlay_new)(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int alpha, int wraparound);
00066         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);
00067         void *(*get_data)(struct graphics_priv *gr, const char *type);
00068         void (*image_free)(struct graphics_priv *gr, struct graphics_image_priv *priv);
00069         void (*get_text_bbox)(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate);
00070         void (*overlay_disable)(struct graphics_priv *gr, int disable);
00071         void (*overlay_resize)(struct graphics_priv *gr, struct point *p, int w, int h, int alpha, int wraparound);
00072         int (*set_attr)(struct graphics_priv *gr, struct attr *attr);
00073 };
00074 
00075 
00076 struct graphics_font_methods {
00077         void (*font_destroy)(struct graphics_font_priv *font);
00078 };
00079 
00080 struct graphics_font {
00081         struct graphics_font_priv *priv;
00082         struct graphics_font_methods meth;
00083 };
00084 
00085 struct graphics_gc_methods {
00086         void (*gc_destroy)(struct graphics_gc_priv *gc);
00087         void (*gc_set_linewidth)(struct graphics_gc_priv *gc, int width);
00088         void (*gc_set_dashes)(struct graphics_gc_priv *gc, int width, int offset, unsigned char dash_list[], int n);
00089         void (*gc_set_foreground)(struct graphics_gc_priv *gc, struct color *c);
00090         void (*gc_set_background)(struct graphics_gc_priv *gc, struct color *c);
00091         void (*gc_set_stipple)(struct graphics_gc_priv *gc, struct graphics_image_priv *img);
00092 };
00093 
00094 struct graphics_gc {
00095         struct graphics_gc_priv *priv;
00096         struct graphics_gc_methods meth;
00097         struct graphics *gra;
00098 };
00099 
00100 struct graphics_image_methods {
00101         void (*image_destroy)(struct graphics_image_priv *img);
00102 };
00103 
00104 struct graphics_image {
00105         struct graphics_image_priv *priv;
00106         struct graphics_image_methods meth;
00107         int width;
00108         int height;
00109         struct point hot;
00110 };
00111 
00112 struct graphics_data_image {
00113         void *data;
00114         int size;
00115 };
00116 
00117 /* prototypes */
00118 enum attr_type;
00119 enum draw_mode_num;
00120 enum item_type;
00121 struct attr;
00122 struct attr_iter;
00123 struct callback;
00124 struct color;
00125 struct displayitem;
00126 struct displaylist;
00127 struct displaylist_handle;
00128 struct graphics;
00129 struct graphics_font;
00130 struct graphics_gc;
00131 struct graphics_image;
00132 struct item;
00133 struct itemgra;
00134 struct layout;
00135 struct mapset;
00136 struct point;
00137 struct point_rect;
00138 struct transformation;
00139 int graphics_set_attr(struct graphics *gra, struct attr *attr);
00140 void graphics_set_rect(struct graphics *gra, struct point_rect *pr);
00141 struct graphics *graphics_new(struct attr *parent, struct attr **attrs);
00142 int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
00143 struct graphics *graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h, int alpha, int wraparound);
00144 void graphics_overlay_resize(struct graphics *this_, struct point *p, int w, int h, int alpha, int wraparound);
00145 void graphics_init(struct graphics *this_);
00146 void *graphics_get_data(struct graphics *this_, const char *type);
00147 void graphics_add_callback(struct graphics *this_, struct callback *cb);
00148 void graphics_remove_callback(struct graphics *this_, struct callback *cb);
00149 struct graphics_font *graphics_font_new(struct graphics *gra, int size, int flags);
00150 struct graphics_font *graphics_named_font_new(struct graphics *gra, char *font, int size, int flags);
00151 void graphics_free(struct graphics *gra);
00152 void graphics_font_destroy_all(struct graphics *gra);
00153 struct graphics_gc *graphics_gc_new(struct graphics *gra);
00154 void graphics_gc_destroy(struct graphics_gc *gc);
00155 void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c);
00156 void graphics_gc_set_background(struct graphics_gc *gc, struct color *c);
00157 void graphics_gc_set_stipple(struct graphics_gc *gc, struct graphics_image *img);
00158 void graphics_gc_set_linewidth(struct graphics_gc *gc, int width);
00159 void graphics_gc_set_dashes(struct graphics_gc *gc, int width, int offset, unsigned char dash_list[], int n);
00160 struct graphics_image *graphics_image_new_scaled(struct graphics *gra, char *path, int w, int h);
00161 struct graphics_image *graphics_image_new_scaled_rotated(struct graphics *gra, char *path, int w, int h, int rotate);
00162 struct graphics_image *graphics_image_new(struct graphics *gra, char *path);
00163 void graphics_image_free(struct graphics *gra, struct graphics_image *img);
00164 void graphics_draw_restore(struct graphics *this_, struct point *p, int w, int h);
00165 void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode);
00166 void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count);
00167 void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r);
00168 void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h);
00169 void graphics_draw_rectangle_rounded(struct graphics *this_, struct graphics_gc *gc, struct point *plu, int w, int h, int r, int fill);
00170 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);
00171 void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret, int estimate);
00172 void graphics_overlay_disable(struct graphics *this_, int disable);
00173 int  graphics_is_disabled(struct graphics *this_);
00174 void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img);
00175 int graphics_draw_drag(struct graphics *this_, struct point *p);
00176 void graphics_background_gc(struct graphics *this_, struct graphics_gc *gc);
00177 void graphics_draw_text_std(struct graphics *this_, int text_size, char *text, struct point *p);
00178 char *graphics_icon_path(char *icon);
00179 void graphics_draw_itemgra(struct graphics *gra, struct itemgra *itm, struct transformation *t, char *label);
00180 void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int flags);
00181 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);
00182 int graphics_draw_cancel(struct graphics *gra, struct displaylist *displaylist);
00183 struct displaylist_handle *graphics_displaylist_open(struct displaylist *displaylist);
00184 struct displayitem *graphics_displaylist_next(struct displaylist_handle *dlh);
00185 void graphics_displaylist_close(struct displaylist_handle *dlh);
00186 struct displaylist *graphics_displaylist_new(void);
00187 void graphics_displaylist_destroy(struct displaylist *displaylist);
00188 struct map_selection *displaylist_get_selection(struct displaylist *displaylist);
00189 GList *displaylist_get_clicked_list(struct displaylist *displaylist, struct point *p, int radius);
00190 struct item *graphics_displayitem_get_item(struct displayitem *di);
00191 int graphics_displayitem_get_coord_count(struct displayitem *di);
00192 char *graphics_displayitem_get_label(struct displayitem *di);
00193 int graphics_displayitem_get_displayed(struct displayitem *di);
00194 int graphics_displayitem_get_z_order(struct displayitem *di);
00195 int graphics_displayitem_within_dist(struct displaylist *displaylist, struct displayitem *di, struct point *p, int dist);
00196 void graphics_add_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl);
00197 void graphics_remove_selection(struct graphics *gra, struct item *item, enum item_type type, struct displaylist *dl);
00198 void graphics_clear_selection(struct graphics *gra, struct displaylist *dl);
00199 /* end of prototypes */
00200 #ifdef __cplusplus
00201 }
00202 #endif
00203 
00204 #endif
00205