struct log *log;
struct route *route;
struct navigation *navigation;
+ struct coord *coord;
+ struct pcoord *pcoord;
} u;
};
ATTR(route)
ATTR(navigation)
ATTR2(0x0008ffff,type_object_end)
+ATTR2(0x00090000,type_coord_begin)
+ATTR2(0x0009ffff,type_coord_end)
+ATTR2(0x000a0000,type_pcoord_begin)
+ATTR(destination)
+ATTR2(0x000affff,type_pcoord_end)
return callback_new(func, 1, p);
}
+static inline struct callback *callback_new_attr_2(void (*func)(void), enum attr_type type, void *p1, void *p2)
+{
+ void *p[2];
+ p[0]=p1;
+ p[1]=p2;
+ return callback_new_attr(func, type, 2, p);
+}
+
static inline struct callback *callback_new_2(void (*func)(void), void *p1, void *p2)
{
void *p[2];
this_->meth.draw_rectangle(this_->priv, gc->priv, p, w, h);
}
+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);
+}
+
+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);
+}
#include "attr.h"
#include "popup.h"
if (gra->meth.draw_image_warp)
gra->meth.draw_image_warp(gra->priv, gra->gc[0]->priv, di->pnt, di->count, di->label);
else
- dbg(0,"draw_image_warp not supported by graphics driver drawing '%s'\ņ", di->label);
+ dbg(0,"draw_image_warp not supported by graphics driver drawing '%s'\n", di->label);
break;
default:
printf("Unhandled element type %d\n", e->type);
struct graphics_gc;
struct graphics_image;
struct item;
-struct point;
struct layout;
+struct point;
+struct transformation;
struct graphics *graphics_new(const char *type, struct attr **attrs);
struct graphics *graphics_overlay_new(struct graphics *parent, struct point *p, int w, int h);
void graphics_init(struct graphics *this_);
void graphics_draw_lines(struct graphics *this_, struct graphics_gc *gc, struct point *p, int count);
void graphics_draw_circle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int r);
void graphics_draw_rectangle(struct graphics *this_, struct graphics_gc *gc, struct point *p, int w, int h);
+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);
+void graphics_draw_image(struct graphics *this_, struct graphics_gc *gc, struct point *p, struct graphics_image *img);
void display_add(struct displaylist *displaylist, struct item *item, int count, struct point *pnt, char *label);
int graphics_ready(struct graphics *this_);
void graphics_displaylist_draw(struct graphics *gra, struct displaylist *displaylist, struct transformation *trans, struct layout *l);
p2[3]=127;
}
}
+ x=overlay->p.x;
+ if (x < 0)
+ x+=parent->width;
+ y=overlay->p.y;
+ if (y < 0)
+ y+=parent->height;
if (window) {
if (overlay->background_ready)
- gdk_draw_drawable(parent->drawable, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], overlay->background, 0, 0, overlay->p.x, overlay->p.y, overlay->width, overlay->height);
+ gdk_draw_drawable(parent->drawable, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], overlay->background, 0, 0, x, y, overlay->width, overlay->height);
}
else {
- gdk_draw_drawable(overlay->background, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], parent->drawable, overlay->p.x, overlay->p.y, 0, 0, overlay->width, overlay->height);
+ gdk_draw_drawable(overlay->background, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], parent->drawable, x, y, 0, 0, overlay->width, overlay->height);
overlay->background_ready=1;
}
- gdk_draw_pixbuf(parent->drawable, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], pixbuf2, 0, 0, overlay->p.x, overlay->p.y, overlay->width, overlay->height, GDK_RGB_DITHER_NONE, 0, 0);
+ gdk_draw_pixbuf(parent->drawable, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], pixbuf2, 0, 0, x, y, overlay->width, overlay->height, GDK_RGB_DITHER_NONE, 0, 0);
if (window)
- gdk_draw_drawable(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], parent->drawable, overlay->p.x, overlay->p.y, overlay->p.x, overlay->p.y, overlay->width, overlay->height);
+ gdk_draw_drawable(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE(widget)], parent->drawable, x, y, x, y, overlay->width, overlay->height);
#if 0
gdk_draw_drawable(gr->gra->drawable,
gr->gra->widget->style->fg_gc[GTK_WIDGET_STATE(gr->gra->widget)],
int button_pressed,moved,popped;
guint button_timeout, motion_timeout;
struct log *textfile_debug_log;
+ struct pcoord destination;
+ int destination_valid;
};
struct gui *main_loop_gui;
void
navit_set_destination(struct navit *this_, struct pcoord *c, char *description)
{
+ if (c) {
+ this_->destination=*c;
+ this_->destination_valid=1;
+ } else
+ this_->destination_valid=0;
navit_append_coord(this_, "destination.txt", c, "former_destination", description, this_->destinations, NULL, callback_cast(navit_set_destination_from_destination));
+ callback_list_call_attr_1(this_->attr_cbl, attr_destination, this_);
if (this_->route) {
route_set_destination(this_->route, c);
if (this_->navigation)
offset=ftell(f);
}
fclose(f);
- if (route && flag)
+ if (route && flag) {
+ this_->destination=c;
+ this_->destination_valid=1;
route_set_destination(route, &c);
+ }
}
}
case attr_layout:
attr->u.str=g_strdup(this_->layout_current->name);
break;
+ case attr_destination:
+ if (! this_->destination_valid)
+ return 0;
+ attr->u.pcoord=&this_->destination;
+ break;
default:
return 0;
}
#include <math.h>
#include <stdio.h>
#include <glib.h>
+#include <string.h>
#include "config.h"
#include "item.h"
#include "point.h"
}
static void
-osd_compass_draw(struct compass *this, struct vehicle *v)
+format_distance(char *buffer, double distance)
+{
+ if (distance >= 100000)
+ sprintf(buffer,"%.0f km", distance/1000);
+ else if (distance >= 10000)
+ sprintf(buffer,"%.1f km", distance/1000);
+ else
+ sprintf(buffer,"%.2f km", distance/1000);
+}
+
+static void
+osd_compass_draw(struct compass *this, struct navit *nav, struct vehicle *v)
{
struct point p;
- struct coord *pos, *dest;
- double *vehicle_dir,dir,distance;
- int dx,dy;
+ struct attr attr_dir, destination_attr, position_attr;
+ double dir;
char buffer[16];
+ struct coord c1, c2;
+ enum projection pro;
+ dbg(0,"enter 0x%x 0x%x 0x%x\n", this, nav, v);
graphics_draw_mode(this->gr, draw_mode_begin);
p.x=0;
p.y=0;
p.x=30;
p.y=30;
graphics_draw_circle(this->gr, this->white, &p, 50);
- if (v) {
- vehicle_dir=vehicle_dir_get(v);
- handle(this->gr, this->white, &p, 20, -*vehicle_dir);
-#if 0 /* FIXME */
- dest=route_get_destination(co->route);
- if (dest) {
- pos=vehicle_pos_get(co->vehicle);
- dx=dest->x-pos->x;
- dy=dest->y-pos->y;
- dir=atan2(dx,dy)*180.0/M_PI;
-#if 0
- printf("dx %d dy %d dir=%f vehicle_dir=%f\n", dx, dy, dir, *vehicle_dir);
-#endif
- if (! co->flags->orient_north)
- dir-=*vehicle_dir;
- handle(comp->gr, comp->green, &p, 20, dir);
+ if (v && vehicle_position_attr_get(v, attr_position_direction, &attr_dir)) {
+ handle(this->gr, this->white, &p, 20, -*attr_dir.u.numd);
+ }
+ dbg(0,"calling navit_get_attr\n");
+ if (navit_get_attr(nav, attr_destination, &destination_attr) && v && vehicle_position_attr_get(v, attr_position_coord_geo, &position_attr)) {
+ pro=destination_attr.u.pcoord->pro;
+ transform_from_geo(pro, position_attr.u.coord_geo, &c1);
+ c2.x=destination_attr.u.pcoord->x;
+ c2.y=destination_attr.u.pcoord->y;
+ dir=atan2(c2.x-c1.x,c2.y-c1.y)*180.0/M_PI;
+ handle(this->gr, this->green, &p, 20, dir);
+ format_distance(buffer, transform_distance(pro, &c1, &c2));
p.x=8;
p.y=72;
- distance=transform_distance(pos, dest)/1000.0;
- if (distance >= 100)
- sprintf(buffer,"%.0f km", distance);
- else if (distance >= 10)
- sprintf(buffer,"%.1f km", distance);
- else
- sprintf(buffer,"%.2f km", distance);
-
- comp->gr->draw_text(comp->gr, comp->green, NULL, comp->font, buffer, &p, 0x10000, 0);
- }
-#endif
+ graphics_draw_text(this->gr, this->green, NULL, this->font, buffer, &p, 0x10000, 0);
}
graphics_draw_mode(this->gr, draw_mode_end);
}
static void
osd_compass_init(struct compass *this, struct navit *nav)
{
- struct point p;
struct graphics *navit_gr;
struct color c;
navit_gr=navit_get_graphics(nav);
graphics_gc_set_foreground(this->green, &c);
graphics_gc_set_linewidth(this->green, 2);
- osd_compass_draw(this, NULL);
+ this->font=graphics_font_new(this->gr, 200);
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_compass_draw), attr_position_coord_geo, this));
+
+ osd_compass_draw(this, nav, NULL);
}
static struct osd_priv *
attr=attr_search(attrs, NULL, attr_y);
if (attr)
this->p.y=attr->u.num;
- navit_add_callback(nav, callback_new_attr_1(osd_compass_init, attr_navit, this));
+ navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_compass_init), attr_navit, this));
return (struct osd_priv *) this;
}
--- /dev/null
+/* XPM */
+static char *flag_bk_wh[]={
+"22 22 3 1 0 21",
+" c None",
+"+ c #ffffff",
+"* c #000000",
+"+++++++ ",
+"+***+++++++++ ",
+"+***+++***+++++++++ ",
+"+***+++***+++***+++ ",
+"++++******+++***+++ ",
+"++++***+++******+++ ",
+"++++***+++***+++**+ ",
+"+***++++++***+++**+ ",
+"+***+++***++++++**+ ",
+"+***+++***+++***+++ ",
+"++++******+++***+++ ",
+"++++***+++******+++ ",
+"++++++++++***+++**+ ",
+"+ +++++++++**+ ",
+"+ ++++++ ",
+"+ ",
+"+ ",
+"+ ",
+"+ ",
+"+ ",
+"+ ",
+"+ "};