summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--navit/attr_def.h1
-rw-r--r--navit/graphics.c639
-rw-r--r--navit/graphics.h3
-rw-r--r--navit/graphics/cogl/graphics_cogl.c2
-rw-r--r--navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c32
-rw-r--r--navit/graphics/null/graphics_null.c2
-rw-r--r--navit/graphics/opengl/graphics_opengl.c2
-rw-r--r--navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp2
-rw-r--r--navit/graphics/sdl/graphics_sdl.c2
-rw-r--r--navit/layout.c6
-rw-r--r--navit/layout.h2
-rw-r--r--navit/navit.c1
-rw-r--r--navit/navit.dtd1
-rw-r--r--navit/navit.xml2
14 files changed, 400 insertions, 297 deletions
diff --git a/navit/attr_def.h b/navit/attr_def.h
index 74334995..6487aea5 100644
--- a/navit/attr_def.h
+++ b/navit/attr_def.h
@@ -131,6 +131,7 @@ ATTR(on_eof)
ATTR(command)
ATTR(src)
ATTR(path)
+ATTR(font)
ATTR2(0x0003ffff,type_string_end)
ATTR(order)
ATTR2(0x00050000,type_double_start)
diff --git a/navit/graphics.c b/navit/graphics.c
index ee7929e5..7cf75f13 100644
--- a/navit/graphics.c
+++ b/navit/graphics.c
@@ -56,25 +56,26 @@ struct graphics
{
struct graphics_priv *priv;
struct graphics_methods meth;
+ char *default_font;
struct graphics_font *font[16];
struct graphics_gc *gc[3];
struct attr **attrs;
struct callback_list *cbl;
int ready;
};
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+
+
struct displaylist {
GHashTable *dl;
};
-//##############################################################################################################
-//# Description: Creates a new graphics object
-//# Comment: attr type required
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+
+/**
+ * Creates a new graphics object
+ * attr type required
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
struct graphics * graphics_new(struct attr *parent, struct attr **attrs)
{
struct graphics *this_;
@@ -95,21 +96,23 @@ struct graphics * graphics_new(struct attr *parent, struct attr **attrs)
return this_;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
{
return attr_generic_get_attr(this_->attrs, type, attr, iter);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
struct graphics * graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h)
{
struct graphics *this_;
@@ -118,11 +121,12 @@ struct graphics * graphics_overlay_new(struct graphics *parent, struct point *p,
return this_;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_init(struct graphics *this_)
{
this_->gc[0]=graphics_gc_new(this_);
@@ -137,51 +141,56 @@ void graphics_init(struct graphics *this_)
this_->meth.background_gc(this_->priv, this_->gc[0]->priv);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void * graphics_get_data(struct graphics *this_, char *type)
{
return (this_->meth.get_data(this_->priv, type));
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_register_resize_callback(struct graphics *this_, void (*callback)(void *data, int w, int h), void *data)
{
this_->meth.register_resize_callback(this_->priv, callback, data);
}
-//##############################################################################################################
-//# Description:
-//# Comment: Called in navit.c
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * Called in navit.c
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_register_button_callback(struct graphics *this_, void (*callback)(void *data, int pressed, int button, struct point *p), void *data)
{
this_->meth.register_button_callback(this_->priv, callback, data);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_register_motion_callback(struct graphics *this_, void (*callback)(void *data, struct point *p), void *data)
{
this_->meth.register_motion_callback(this_->priv, callback, data);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_register_keypress_callback(struct graphics *this_, void (*callback)(void *data, char *key), void *data)
{
this_->meth.register_keypress_callback(this_->priv, callback, data);
@@ -192,25 +201,44 @@ void graphics_add_callback(struct graphics *this_, struct callback *cb)
callback_list_add(this_->cbl, cb);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
struct graphics_font * graphics_font_new(struct graphics *gra, int size, int flags)
{
struct graphics_font *this_;
this_=g_new0(struct graphics_font,1);
- this_->priv=gra->meth.font_new(gra->priv, &this_->meth, size, flags);
+ this_->priv=gra->meth.font_new(gra->priv, &this_->meth, gra->default_font, size, flags);
return this_;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * Free all loaded fonts.
+ * Used when switching layouts.
+ * @param gra The graphics instance
+ * @returns nothing
+ * @author Sarah Nordstrom (05/2008)
+ */
+void graphics_font_destroy_all(struct graphics *gra)
+{
+ int i;
+ for(i = 0 ; i < sizeof(gra->font) / sizeof(gra->font[0]); i++) {
+ if(!gra->font[i]) continue;
+ gra->font[i]->meth.font_destroy(gra->font[i]->priv);
+ gra->font[i] = NULL;
+ }
+}
+
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
struct graphics_gc * graphics_gc_new(struct graphics *gra)
{
struct graphics_gc *this_;
@@ -220,63 +248,72 @@ struct graphics_gc * graphics_gc_new(struct graphics *gra)
return this_;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_gc_destroy(struct graphics_gc *gc)
{
gc->meth.gc_destroy(gc->priv);
g_free(gc);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c)
{
gc->meth.gc_set_foreground(gc->priv, c);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_gc_set_background(struct graphics_gc *gc, struct color *c)
{
gc->meth.gc_set_background(gc->priv, c);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_gc_set_linewidth(struct graphics_gc *gc, int width)
{
gc->meth.gc_set_linewidth(gc->priv, width);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_gc_set_dashes(struct graphics_gc *gc, int width, int offset, unsigned char dash_list[], int n)
{
if (gc->meth.gc_set_dashes)
gc->meth.gc_set_dashes(gc->priv, width, offset, dash_list, n);
}
-//##############################################################################################################
-//# Description: Create a new image from file path scaled to w and h pixels
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * Create a new image from file path scaled to w and h pixels
+ * @param gra the graphics instance
+ * @param path path of the image to load
+ * @param w width to rescale to
+ * @param h height to rescale to
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
struct graphics_image * graphics_image_new_scaled(struct graphics *gra, char *path, int w, int h)
{
struct graphics_image *this_;
@@ -292,21 +329,24 @@ struct graphics_image * graphics_image_new_scaled(struct graphics *gra, char *pa
return this_;
}
-//##############################################################################################################
-//# Description: Create a new image from file path
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * Create a new image from file path
+ * @param gra the graphics instance
+ * @param path path of the image to load
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
struct graphics_image * graphics_image_new(struct graphics *gra, char *path)
{
return graphics_image_new_scaled(gra, path, -1, -1);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_image_free(struct graphics *gra, struct graphics_image *img)
{
if (gra->meth.image_free)
@@ -314,92 +354,101 @@ void graphics_image_free(struct graphics *gra, struct graphics_image *img)
g_free(img);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_draw_restore(struct graphics *this_, struct point *p, int w, int h)
{
this_->meth.draw_restore(this_->priv, p, w, h);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_draw_mode(struct graphics *this_, enum draw_mode_num mode)
{
this_->meth.draw_mode(this_->priv, mode);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count)
{
this_->meth.draw_lines(this_->priv, gc->priv, p, count);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r)
{
this_->meth.draw_circle(this_->priv, gc->priv, p, r);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h)
{
this_->meth.draw_rectangle(this_->priv, gc->priv, p, w, h);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
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)
{
this_->meth.draw_text(this_->priv, gc1->priv, gc2 ? gc2->priv : NULL, font->priv, text, p, dx, dy);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_get_text_bbox(struct graphics *this_, struct graphics_font *font, char *text, int dx, int dy, struct point *ret)
{
this_->meth.get_text_bbox(this_->priv, font->priv, text, dx, dy, ret);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_overlay_disable(struct graphics *this_, int disable)
{
if (this_->meth.overlay_disable)
this_->meth.overlay_disable(this_->priv, disable);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img)
{
this_->meth.draw_image(this_->priv, gc->priv, p, img->priv);
@@ -455,11 +504,12 @@ static void graphics_popup(struct display_list *list, struct popup_item **popup)
}
#endif
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
struct displayitem {
struct item item;
char *label;
@@ -468,11 +518,12 @@ struct displayitem {
struct point pnt[0];
};
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
static int xdisplay_free_list(gpointer key, gpointer value, gpointer user_data)
{
GList *h, *l;
@@ -489,21 +540,23 @@ static int xdisplay_free_list(gpointer key, gpointer value, gpointer user_data)
return TRUE;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
static void xdisplay_free(GHashTable *display_list)
{
g_hash_table_foreach_remove(display_list, xdisplay_free_list, NULL);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void display_add(struct displaylist *displaylist, struct item *item, int count, struct point *pnt, char *label)
{
struct displayitem *di;
@@ -535,11 +588,12 @@ void display_add(struct displaylist *displaylist, struct item *item, int count,
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
static void label_line(struct graphics *gra, struct graphics_gc *fg, struct graphics_gc *bg, struct graphics_font *font, struct point *p, int count, char *label)
{
int i,x,y,tl;
@@ -576,11 +630,12 @@ static void label_line(struct graphics *gra, struct graphics_gc *fg, struct grap
}
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
static void xdisplay_draw_elements(struct graphics *gra, GHashTable *display_list, struct itemtype *itm)
{
struct element *e;
@@ -679,11 +734,12 @@ static void xdisplay_draw_elements(struct graphics *gra, GHashTable *display_lis
graphics_gc_destroy(gc);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
static void xdisplay_draw_layer(GHashTable *display_list, struct graphics *gra, struct layer *lay, int order)
{
GList *itms;
@@ -698,11 +754,12 @@ static void xdisplay_draw_layer(GHashTable *display_list, struct graphics *gra,
}
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
static void xdisplay_draw(GHashTable *display_list, struct graphics *gra, struct layout *l, int order)
{
GList *lays;
@@ -716,18 +773,20 @@ static void xdisplay_draw(GHashTable *display_list, struct graphics *gra, struct
}
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
extern void *route_selection;
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
static void do_draw_map(struct displaylist *displaylist, struct transformation *t, struct map *m, int order)
{
enum projection pro;
@@ -792,11 +851,12 @@ static void do_draw_map(struct displaylist *displaylist, struct transformation *
map_selection_destroy(sel);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
static void do_draw(struct displaylist *displaylist, struct transformation *t, GList *mapsets, int order)
{
struct mapset *ms;
@@ -813,21 +873,23 @@ static void do_draw(struct displaylist *displaylist, struct transformation *t, G
mapset_close(h);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
int graphics_ready(struct graphics *this_)
{
return this_->ready;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l, int callback)
{
int order=transform_get_order(trans);
@@ -837,6 +899,7 @@ void graphics_displaylist_draw(struct graphics *gra, struct displaylist *display
// FIXME find a better place to set the background color
graphics_gc_set_background(gra->gc[0], &l->color);
graphics_gc_set_foreground(gra->gc[0], &l->color);
+ gra->default_font = g_strdup(l->font);
gra->meth.background_gc(gra->priv, gra->gc[0]->priv);
gra->meth.draw_mode(gra->priv, draw_mode_begin);
gra->meth.draw_rectangle(gra->priv, gra->gc[0]->priv, &p, 32767, 32767);
@@ -846,11 +909,12 @@ void graphics_displaylist_draw(struct graphics *gra, struct displaylist *display
gra->meth.draw_mode(gra->priv, draw_mode_end);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_displaylist_move(struct displaylist *displaylist, int dx, int dy)
{
struct displaylist_handle *dlh;
@@ -867,11 +931,12 @@ void graphics_displaylist_move(struct displaylist *displaylist, int dx, int dy)
graphics_displaylist_close(dlh);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_draw(struct graphics *gra, struct displaylist *displaylist, GList *mapsets, struct transformation *trans, struct layout *l)
{
int order=transform_get_order(trans);
@@ -908,20 +973,22 @@ void graphics_draw(struct graphics *gra, struct displaylist *displaylist, GList
gra->ready=1;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
struct displaylist_handle {
GList *hl_head,*hl,*l;
};
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
struct displaylist_handle * graphics_displaylist_open(struct displaylist *displaylist)
{
struct displaylist_handle *ret;
@@ -932,11 +999,12 @@ struct displaylist_handle * graphics_displaylist_open(struct displaylist *displa
return ret;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
struct displayitem * graphics_displaylist_next(struct displaylist_handle *dlh)
{
struct displayitem *ret;
@@ -951,22 +1019,24 @@ struct displayitem * graphics_displaylist_next(struct displaylist_handle *dlh)
return ret;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
void graphics_displaylist_close(struct displaylist_handle *dlh)
{
g_list_free(dlh->hl_head);
g_free(dlh);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
struct displaylist * graphics_displaylist_new(void)
{
struct displaylist *ret=g_new(struct displaylist, 1);
@@ -976,31 +1046,34 @@ struct displaylist * graphics_displaylist_new(void)
return ret;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
struct item * graphics_displayitem_get_item(struct displayitem *di)
{
return &di->item;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
char * graphics_displayitem_get_label(struct displayitem *di)
{
return di->label;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
static int within_dist_point(struct point *p0, struct point *p1, int dist)
{
if (p0->x == 32767 || p0->y == 32767 || p1->x == 32767 || p1->y == 32767)
@@ -1013,11 +1086,12 @@ static int within_dist_point(struct point *p0, struct point *p1, int dist)
return 0;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
static int within_dist_line(struct point *p, struct point *line_p0, struct point *line_p1, int dist)
{
int vx,vy,wx,wy;
@@ -1041,11 +1115,12 @@ static int within_dist_line(struct point *p, struct point *line_p0, struct point
return within_dist_point(p, &line_p, dist);
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
static int within_dist_polyline(struct point *p, struct point *line_pnt, int count, int dist, int close)
{
int i;
@@ -1059,11 +1134,12 @@ static int within_dist_polyline(struct point *p, struct point *line_pnt, int cou
return 0;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
static int within_dist_polygon(struct point *p, struct point *poly_pnt, int count, int dist)
{
int i, j, c = 0;
@@ -1078,11 +1154,12 @@ static int within_dist_polygon(struct point *p, struct point *poly_pnt, int coun
return c;
}
-//##############################################################################################################
-//# Description:
-//# Comment:
-//# Authors: Martin Schaller (04/2008)
-//##############################################################################################################
+/**
+ * FIXME
+ * @param <>
+ * @returns <>
+ * @author Martin Schaller (04/2008)
+*/
int graphics_displayitem_within_dist(struct displayitem *di, struct point *p, int dist)
{
if (di->item.type < type_line) {
diff --git a/navit/graphics.h b/navit/graphics.h
index 1a5d1d99..cb462caa 100644
--- a/navit/graphics.h
+++ b/navit/graphics.h
@@ -56,7 +56,7 @@ struct graphics_methods {
void (*draw_image)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img);
void (*draw_image_warp)(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, int count, char *data);
void (*draw_restore)(struct graphics_priv *gr, struct point *p, int w, int h);
- struct graphics_font_priv *(*font_new)(struct graphics_priv *gr, struct graphics_font_methods *meth, int size, int flags);
+ struct graphics_font_priv *(*font_new)(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font, int size, int flags);
struct graphics_gc_priv *(*gc_new)(struct graphics_priv *gr, struct graphics_gc_methods *meth);
void (*background_gc)(struct graphics_priv *gr, struct graphics_gc_priv *gc);
struct graphics_priv *(*overlay_new)(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h);
@@ -133,6 +133,7 @@ void graphics_register_button_callback(struct graphics *this_, void (*callback)(
void graphics_register_motion_callback(struct graphics *this_, void (*callback)(void *data, struct point *p), void *data);
void graphics_register_keypress_callback(struct graphics *this_, void (*callback)(void *data, char *key), void *data);
struct graphics_font *graphics_font_new(struct graphics *gra, int size, int flags);
+void graphics_font_destroy_all(struct graphics *gra);
struct graphics_gc *graphics_gc_new(struct graphics *gra);
void graphics_gc_destroy(struct graphics_gc *gc);
void graphics_gc_set_foreground(struct graphics_gc *gc, struct color *c);
diff --git a/navit/graphics/cogl/graphics_cogl.c b/navit/graphics/cogl/graphics_cogl.c
index 08b0c88b..1d201d2e 100644
--- a/navit/graphics/cogl/graphics_cogl.c
+++ b/navit/graphics/cogl/graphics_cogl.c
@@ -84,7 +84,7 @@ static struct graphics_font_methods font_methods = {
font_destroy
};
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size)
+static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *fontfamily, int size)
{
return NULL;
}
diff --git a/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c b/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
index aaa96e42..35223545 100644
--- a/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
+++ b/navit/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c
@@ -113,12 +113,12 @@ graphics_destroy(struct graphics_priv *gr)
* List of font families to use, in order of preference
*/
static char *fontfamilies[]={
- "Liberation Mono",
+ "Liberation Sans",
"Arial",
- "DejaVu Sans",
"NcrBI4nh",
"luximbi",
"FreeSans",
+ "DejaVu Sans",
NULL,
};
@@ -136,8 +136,14 @@ static struct graphics_font_methods font_methods = {
* Load a new font using the fontconfig library.
* First search for each of the font families and require and exact match on family
* If no font found, let fontconfig pick the best match
- */
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size, int flags)
+ * @param graphics_priv FIXME
+ * @param graphics_font_methods FIXME
+ * @param fontfamily the preferred font family
+ * @param size requested size of fonts
+ * @param flags extra flags for the font (bold,etc)
+ * @returns <>
+*/
+static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *fontfamily, int size, int flags)
{
struct graphics_font_priv *font=g_new(struct graphics_font_priv, 1);
@@ -150,10 +156,24 @@ static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct grap
gr->library_init=1;
}
found=0;
+ dbg(2," about to search for fonts, prefered = %s\n",fontfamily);
for (exact=1;!found && exact>=0;exact--) {
- family=fontfamilies;
+ if(fontfamily) {
+ /* prepend the font passed so we look for it first */
+ family = malloc(sizeof(fontfamilies)+sizeof(fontfamily));
+ if(!family) {
+ dbg(0,"Out of memory while creating the font families table\n");
+ return NULL;
+ }
+ memcpy(family, &fontfamily, sizeof(fontfamily));
+ memcpy(family+1, fontfamilies, sizeof(fontfamilies));
+ } else {
+ family=fontfamilies;
+ }
+
+
while (*family && !found) {
- dbg(1, "Looking for font family %s. exact=%d\n", *family, exact);
+ dbg(2, "Looking for font family %s. exact=%d\n", *family, exact);
FcPattern *required = FcPatternBuild(NULL, FC_FAMILY, FcTypeString, *family, NULL);
if (flags)
FcPatternAddInteger(required,FC_WEIGHT,FC_WEIGHT_BOLD);
diff --git a/navit/graphics/null/graphics_null.c b/navit/graphics/null/graphics_null.c
index a4c20bd0..8ca83530 100644
--- a/navit/graphics/null/graphics_null.c
+++ b/navit/graphics/null/graphics_null.c
@@ -55,7 +55,7 @@ static struct graphics_font_methods font_methods = {
font_destroy
};
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size)
+static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *fontfamily, int size)
{
*meth=font_methods;
return &graphics_font_priv;
diff --git a/navit/graphics/opengl/graphics_opengl.c b/navit/graphics/opengl/graphics_opengl.c
index 154a1fca..a7163035 100644
--- a/navit/graphics/opengl/graphics_opengl.c
+++ b/navit/graphics/opengl/graphics_opengl.c
@@ -99,7 +99,7 @@ static struct graphics_font_methods font_methods = {
font_destroy
};
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size)
+static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *fontfamily, int size)
{
#if 0
char **filename=fontlist;
diff --git a/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp b/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
index 79cd9149..e58f4c45 100644
--- a/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
+++ b/navit/graphics/qt_qpainter/graphics_qt_qpainter.cpp
@@ -308,7 +308,7 @@ static struct graphics_font_methods font_methods = {
//# Comment:
//# Authors: Martin Schaller (04/2008)
//##############################################################################################################
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size, int flags)
+static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *fontfamily, int size, int flags)
{
*meth=font_methods;
return &graphics_font_priv;
diff --git a/navit/graphics/sdl/graphics_sdl.c b/navit/graphics/sdl/graphics_sdl.c
index ab92064b..8d8debaa 100644
--- a/navit/graphics/sdl/graphics_sdl.c
+++ b/navit/graphics/sdl/graphics_sdl.c
@@ -228,7 +228,7 @@ static struct graphics_font_methods font_methods = {
font_destroy
};
-static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, int size, int flags)
+static struct graphics_font_priv *font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *fontfamily, int size, int flags)
{
struct graphics_font_priv *gf=g_new(struct graphics_font_priv, 1);
diff --git a/navit/layout.c b/navit/layout.c
index 653d2b51..e4f55718 100644
--- a/navit/layout.c
+++ b/navit/layout.c
@@ -26,13 +26,15 @@ struct layout * layout_new(struct attr *parent, struct attr **attrs)
{
struct layout *l;
struct color def_color = {0xffff, 0xefef, 0xb7b7, 0xffff};
- struct attr *name_attr,*color_attr,*order_delta_attr;
-
+ struct attr *name_attr,*color_attr,*order_delta_attr,*font_attr;
if (! (name_attr=attr_search(attrs, NULL, attr_name)))
return NULL;
l = g_new0(struct layout, 1);
l->name = g_strdup(name_attr->u.str);
+ if ((font_attr=attr_search(attrs, NULL, attr_font))) {
+ l->font = g_strdup(font_attr->u.str);
+ }
if ((color_attr=attr_search(attrs, NULL, attr_color)))
l->color = *color_attr->u.color;
else
diff --git a/navit/layout.h b/navit/layout.h
index 5d970523..e6417d8b 100644
--- a/navit/layout.h
+++ b/navit/layout.h
@@ -62,7 +62,7 @@ struct color;
struct layer { char *name; int details; GList *itemtypes; };
-struct layout { char *name; struct color color; GList *layers; int order_delta; };
+struct layout { char *name; char *font; struct color color; GList *layers; int order_delta; };
/* prototypes */
enum item_type;
diff --git a/navit/navit.c b/navit/navit.c
index 6af9f4c1..2ad6f443 100644
--- a/navit/navit.c
+++ b/navit/navit.c
@@ -1262,6 +1262,7 @@ navit_set_attr(struct navit *this_, struct attr *attr)
case attr_layout:
if(this_->layout_current!=attr->u.layout) {
this_->layout_current=attr->u.layout;
+ graphics_font_destroy_all(this_->gra);
navit_draw(this_);
attr_updated=1;
}
diff --git a/navit/navit.dtd b/navit/navit.dtd
index 3102dcf5..6ae33f16 100644
--- a/navit/navit.dtd
+++ b/navit/navit.dtd
@@ -55,6 +55,7 @@
<!ELEMENT layout (layer*)>
<!ATTLIST layout name CDATA #REQUIRED>
<!ATTLIST layout color CDATA #IMPLIED>
+<!ATTLIST layout font CDATA #IMPLIED>
<!ELEMENT layer (item+)>
<!ATTLIST layer name CDATA #REQUIRED>
<!ATTLIST layer details CDATA #REQUIRED>
diff --git a/navit/navit.xml b/navit/navit.xml
index e368e418..a65437a6 100644
--- a/navit/navit.xml
+++ b/navit/navit.xml
@@ -119,7 +119,7 @@ Change to your home coordinates.
<map type="garmin" enabled="yes" data="/path/to/img" debug="4"/>
</mapset>
- <layout name="Car" color= "#ffefb7">
+ <layout name="Car" color= "#ffefb7" font="Liberation Sans">
<layer name="polygons">
<item type="image" order="0-">
<image />