diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-11-04 13:12:25 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-11-04 13:12:25 +0000 |
commit | 308febaaf88c105f06acd19e68c36858f5bec9e3 (patch) | |
tree | 328209983b28157e208bc46fdd3cf4a954acdec0 /navit | |
parent | 0aab444415109930632c7313a5912d18e13d1036 (diff) | |
download | navit-308febaaf88c105f06acd19e68c36858f5bec9e3.tar.gz |
Add:Core:Make icons scaleable
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1636 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit')
-rw-r--r-- | navit/graphics.c | 2 | ||||
-rw-r--r-- | navit/graphics.h | 6 | ||||
-rw-r--r-- | navit/layout.c | 10 | ||||
-rw-r--r-- | navit/layout.h | 2 |
4 files changed, 14 insertions, 6 deletions
diff --git a/navit/graphics.c b/navit/graphics.c index 57e4e371d..a0a239918 100644 --- a/navit/graphics.c +++ b/navit/graphics.c @@ -711,7 +711,7 @@ static void xdisplay_draw_elements(struct graphics *gra, GHashTable *display_lis case element_icon: if (!img) { sprintf(path,"%s/xpm/%s", navit_sharedir, e->u.icon.src); - img=graphics_image_new(gra, path); + img=graphics_image_new_scaled(gra, path, e->u.icon.width, e->u.icon.height); if (! img) dbg(0,"failed to load icon '%s'\n", e->u.icon.src); } diff --git a/navit/graphics.h b/navit/graphics.h index 5838ee5fe..ea1d2c16c 100644 --- a/navit/graphics.h +++ b/navit/graphics.h @@ -120,15 +120,13 @@ struct item; struct layout; struct point; struct transformation; +struct callback; struct graphics *graphics_new(struct attr *parent, struct attr **attrs); int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter); struct graphics *graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h); void graphics_init(struct graphics *this_); void *graphics_get_data(struct graphics *this_, char *type); -void graphics_register_resize_callback(struct graphics *this_, void (*callback)(void *data, int w, int h), void *data); -void graphics_register_button_callback(struct graphics *this_, void (*callback)(void *data, int pressed, int button, struct point *p), void *data); -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); +void graphics_add_callback(struct graphics *this_, struct callback *cb); 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); diff --git a/navit/layout.c b/navit/layout.c index eac7c1059..7d0fd264a 100644 --- a/navit/layout.c +++ b/navit/layout.c @@ -263,7 +263,7 @@ struct icon * icon_new(struct attr *parent, struct attr **attrs) { struct element *e; - struct attr *src; + struct attr *src,*w,*h; src=attr_search(attrs, NULL, attr_src); if (! src) return NULL; @@ -271,6 +271,14 @@ icon_new(struct attr *parent, struct attr **attrs) e = g_malloc0(sizeof(*e)+strlen(src->u.str)+1); e->type=element_icon; e->u.icon.src=(char *)(e+1); + if (w=attr_search(attrs, NULL, attr_w)) + e->u.icon.width=w->u.num; + else + e->u.icon.width=-1; + if (h=attr_search(attrs, NULL, attr_h)) + e->u.icon.height=h->u.num; + else + e->u.icon.height=-1; strcpy(e->u.icon.src,src->u.str); return (struct icon *)e; diff --git a/navit/layout.h b/navit/layout.h index c8cbd34e6..22963f7bc 100644 --- a/navit/layout.h +++ b/navit/layout.h @@ -48,6 +48,8 @@ struct element { } circle; struct element_icon { char *src; + int width; + int height; } icon; } u; }; |