Core:Add:Add support for customizable background color to xmlconfig.
authorhorwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 10 Feb 2008 21:00:48 +0000 (21:00 +0000)
committerhorwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>
Sun, 10 Feb 2008 21:00:48 +0000 (21:00 +0000)
git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@856 ffa7fe5e-494d-0410-b361-a75ebd5db220

navit/src/graphics.c
navit/src/layout.c
navit/src/layout.h
navit/src/navit.dtd
navit/src/navit.xml
navit/src/xmlconfig.c

index dc2e631..125b5c2 100644 (file)
@@ -548,6 +548,10 @@ void
 graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, GList *layouts)
 {
        int order=transform_get_order(trans);
+       // FIXME find a better place to set the background color
+       graphics_gc_set_background(gra->gc[0], ((struct layout *)layouts->data)->color);
+       graphics_gc_set_foreground(gra->gc[0], ((struct layout *)layouts->data)->color);
+       gra->meth.background_gc(gra->priv, gra->gc[0]->priv);
        gra->meth.draw_mode(gra->priv, draw_mode_begin);
        xdisplay_draw(displaylist->dl, gra, layouts, order);
        gra->meth.draw_mode(gra->priv, draw_mode_end);
index b47dad4..3acec7e 100644 (file)
@@ -2,12 +2,14 @@
 #include <string.h>
 #include "layout.h"
 
-struct layout * layout_new(const char *name)
+struct layout * layout_new(const char *name, struct color *color)
 {
        struct layout *l;
 
        l = g_new0(struct layout, 1);
        l->name = g_strdup(name);
+       l->color = g_new0(struct color,1);
+       *(l->color) = *color;
        return l;
 }
 
index ddf90ba..fcf60d5 100644 (file)
@@ -37,18 +37,19 @@ struct itemtype {
        GList *elements;
 };
 
+struct color;
+
 struct layer { char *name; int details; GList *itemtypes; };
 
-struct layout { char *name; GList *layers; };
+struct layout { char *name; struct color *color; GList *layers; };
 
 /* prototypes */
 enum item_type;
-struct color;
 struct element;
 struct itemtype;
 struct layer;
 struct layout;
-struct layout *layout_new(const char *name);
+struct layout *layout_new(const char *name, struct color *color);
 struct layer *layer_new(const char *name, int details);
 void layout_add_layer(struct layout *layout, struct layer *layer);
 struct itemtype *itemtype_new(int order_min, int order_max);
index 374e0d9..3102dcf 100644 (file)
@@ -54,6 +54,7 @@
 <!ATTLIST map debug CDATA #IMPLIED>
 <!ELEMENT layout (layer*)>
 <!ATTLIST layout name CDATA #REQUIRED>
+<!ATTLIST layout color CDATA #IMPLIED>
 <!ELEMENT layer (item+)>
 <!ATTLIST layer name CDATA #REQUIRED>
 <!ATTLIST layer details CDATA #REQUIRED>
index 1dda0ad..e933a9d 100644 (file)
@@ -70,7 +70,7 @@ Change to your home coordinates.
                <map type="garmin" enabled="yes" data="/path/to/img" debug="4"/>
        </mapset>
 
-       <layout name="Tag">
+       <layout name="Tag" color= "#ffefb7">
                <layer name="sea" details="0">
                        <item type="poly_wood" order="0-">
                                <polygon color="#8ec78d" /> 
@@ -998,7 +998,7 @@ Change to your home coordinates.
                        </item>
                </layer>
        </layout>
-       <layout name="Nacht">
+       <layout name="Nacht" color="#ffefb7">
        </layout>
 </navit>
 </config>
index 1a8e3b9..f3e7688 100644 (file)
@@ -437,10 +437,12 @@ static int
 xmlconfig_layout(struct xmlstate *state)
 {
        const char *name=find_attribute(state, "name", 1);
+       struct color color = {0xffff, 0xefef, 0xb7b7, 0xffff};
 
        if (! name)
                return 0;
-       state->element_object = layout_new(name);
+       find_color(state, 1, &color);
+       state->element_object = layout_new(name, &color);
        if (! state->element_object)
                return 0;
        navit_add_layout(state->parent->element_object, state->element_object);