Ticket #897: osd_reconfigure.diff

File osd_reconfigure.diff, 78.8 KB (added by tegzed, 10 years ago)

Runtime reconfiguration support for OSDs

  • osd.h

     
    6969void osd_std_resize(struct osd_item *item);
    7070void osd_std_draw(struct osd_item *item);
    7171struct osd* osd_get_osd_by_name(char *name);
     72struct osd_priv* osd_get_osd_priv_by_name(char *name);
     73
    7274int osd_set_attr(struct osd *osd, struct attr* attr);
    7375/* end of prototypes */
    7476
  • osd.c

     
    7171        return g_hash_table_lookup(osd_hash, name);
    7272}
    7373
     74struct osd_priv*
     75osd_get_osd_priv_by_name(char *name)
     76{
     77        struct osd* o = g_hash_table_lookup(osd_hash, name);
     78        if(o) {
     79                return o->priv;
     80        }
     81        return NULL;
     82}
     83
    7484int
    7585osd_set_attr(struct osd *osd, struct attr* attr)
    7686{
  • osd/core/osd_core.c

     
    7272}
    7373#endif /* MSC_VER */
    7474
     75struct osd_priv_common {
     76        struct osd_item osd_item;
     77        struct osd_priv *data;
     78};
     79
    7580struct odometer;
    7681
    77 static void osd_odometer_reset(struct odometer *this);
     82static void osd_odometer_reset(struct osd_priv_common *opc);
    7883static void osd_cmd_odometer_reset(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid);
    79 static void osd_odometer_draw(struct odometer *this, struct navit *nav, struct vehicle *v);
     84static void osd_odometer_draw(struct osd_priv_common *opc, struct navit *nav, struct vehicle *v);
    8085static struct osd_text_item * oti_new(struct osd_text_item * parent);
     86int osd_button_set_attr(struct osd_priv_common *opc, struct attr* attr);
    8187
    8288static int b_commandtable_added = 0;
    8389
    8490struct compass {
    85         struct osd_item osd_item;
    8691        int width;
    8792        struct graphics_gc *green;
    8893};
     
    215220        return g_strdup_printf("%.0f", num);
    216221}
    217222
     223int set_std_osd_attr(struct osd_priv_common*opc, struct attr*the_attr)
     224{
     225        if(opc && the_attr && ATTR_IS_INT(the_attr->type)) {
     226                if(attr_w == the_attr->type) {
     227                        opc->osd_item.w = the_attr->u.num;
     228                        return 1;
     229                }
     230                else if(attr_h == the_attr->type) {
     231                        opc->osd_item.h = the_attr->u.num;
     232                        return 1;
     233                }
     234                else if(attr_x == the_attr->type) {
     235                        opc->osd_item.p.x = the_attr->u.num;
     236                        return 1;
     237                }
     238                else if(attr_y == the_attr->type) {
     239                        opc->osd_item.p.y = the_attr->u.num;
     240                        return 1;
     241                }
     242        }
     243        return 0;
     244}
     245
    218246/**
    219  * sets an attribute (name value pair) of a map item specified by map name and item id
     247 * sets an attribute (name value pair) of a named  osd (osd with name attribute set)
    220248 *
    221249 * @param navit The navit instance
    222250 * @param function unused (needed to match command function signiture)
     
    242270        ) {
    243271                struct attr attr_to_set;
    244272                struct osd* osd;
     273                struct osd_priv* osd_priv;
    245274               
    246275                if(ATTR_IS_STRING(attr_from_name(in[1]->u.str))) {
    247276                        attr_to_set.u.str = in[2]->u.str;
     
    258287                        attr_to_set.type = attr_from_name(in[1]->u.str);
    259288                }
    260289                osd = osd_get_osd_by_name(in[0]->u.str);
     290                osd_priv = osd_get_osd_priv_by_name(in[0]->u.str);
    261291                if(osd) {
    262                         osd_set_attr(osd, &attr_to_set);
    263                         val->u.num  = 1;
     292                        if(!set_std_osd_attr((struct osd_priv_common*)osd_priv, &attr_to_set)) {
     293                                osd_set_attr(osd, &attr_to_set);
     294                                val->u.num  = 1;
     295                        } else {
     296                                struct osd_priv_common* opc = (struct osd_priv_common*) osd_priv;
     297                                osd_std_resize(&opc->osd_item);
     298                        }
    264299                }
    265300        }
    266301        list[1] = NULL;
     
    278313};
    279314
    280315struct odometer {
    281         struct osd_item osd_item;
    282316        int width;
    283317        struct graphics_gc *orange;
    284318        struct graphics_gc *white;
     
    344378/*
    345379 * save current odometer state to string
    346380 */
    347 static char *osd_odometer_to_string(struct odometer* this_)
     381static char *osd_odometer_to_string(struct odometer *this_)
    348382{
    349383  return g_strdup_printf("odometer %s %lf %lf %d\n",this_->name,this_->sum_dist,this_->time_all,this_->bActive);
    350384}
     
    352386/*
    353387 * load current odometer state from string
    354388 */
    355 static void osd_odometer_from_string(struct odometer* this_, char*str)
     389static void osd_odometer_from_string(struct odometer *this_, char*str)
    356390{
    357391  char*  tok;
    358392  char*  name_str;
     
    395429  g_free(sum_time_str);
    396430}
    397431
    398 static void osd_odometer_draw(struct odometer *this, struct navit *nav, struct vehicle *v)
     432static void osd_odometer_draw(struct osd_priv_common *opc, struct navit *nav, struct vehicle *v)
    399433{
     434  struct odometer *this = (struct odometer *)opc->data;
     435
    400436  struct coord curr_coord;
    401437  struct graphics_gc *curr_color;
    402438
     
    433469  if(0==curr_vehicle)
    434470    return;
    435471
    436   osd_std_draw(&this->osd_item);
     472  osd_std_draw(&opc->osd_item);
    437473  if(this->bActive) {
    438474    if(!vehicle_get_attr(curr_vehicle, attr_position_coord_geo,&position_attr, NULL)) {
    439475      return;
     
    502538  }
    503539  g_free(time_buffer);
    504540
    505   graphics_get_text_bbox(this->osd_item.gr, this->osd_item.font, buffer, 0x10000, 0, bbox, 0);
    506   p.x=(this->osd_item.w-bbox[2].x)/2;
    507   p.y = this->osd_item.h-this->osd_item.h/10;
     541  graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, buffer, 0x10000, 0, bbox, 0);
     542  p.x=(opc->osd_item.w-bbox[2].x)/2;
     543  p.y = opc->osd_item.h-opc->osd_item.h/10;
    508544  curr_color = this->bActive?this->white:this->orange;
    509   graphics_draw_text(this->osd_item.gr, curr_color, NULL, this->osd_item.font, buffer, &p, 0x10000, 0);
     545  graphics_draw_text(opc->osd_item.gr, curr_color, NULL, opc->osd_item.font, buffer, &p, 0x10000, 0);
    510546  g_free(dist_buffer);
    511547  g_free(spd_buffer);
    512548  g_free(acc_buffer);
    513   graphics_draw_mode(this->osd_item.gr, draw_mode_end);
     549  graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    514550}
    515551
    516552
    517553static void
    518 osd_odometer_reset(struct odometer *this)
     554osd_odometer_reset(struct osd_priv_common *opc)
    519555{
     556  struct odometer *this = (struct odometer *)opc->data;
     557
    520558  if(!this->bDisableReset) {
    521559    this->bActive = 0;
    522560    this->sum_dist = 0;
     
    528566}
    529567
    530568static void
    531 osd_odometer_click(struct odometer *this, struct navit *nav, int pressed, int button, struct point *p)
     569osd_odometer_click(struct osd_priv_common *opc, struct navit *nav, int pressed, int button, struct point *p)
    532570{
    533   struct point bp = this->osd_item.p;
     571  struct odometer *this = (struct odometer *)opc->data;
     572
     573  struct point bp = opc->osd_item.p;
    534574  struct timeval tv;
    535575  double curr_time;
    536576  const double double_click_timewin = .5;
    537577  osd_wrap_point(&bp, nav);
    538   if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + this->osd_item.w || p->y > bp.y + this->osd_item.h || !this->osd_item.configured ) && !this->osd_item.pressed)
     578  if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + opc->osd_item.w || p->y > bp.y + opc->osd_item.h || !opc->osd_item.configured ) && !opc->osd_item.pressed)
    539579    return;
    540580  if (button != 1)
    541581    return;
    542582  if (navit_ignore_button(nav))
    543583    return;
    544   if (!!pressed == !!this->osd_item.pressed)
     584  if (!!pressed == !!opc->osd_item.pressed)
    545585    return;
    546586
    547587  gettimeofday(&tv,NULL);
     
    557597  this->bActive ^= 1;  //toggle active flag
    558598
    559599  if (curr_time-double_click_timewin <= this->last_click_time) { //double click handling
    560     osd_odometer_reset(this);
     600    osd_odometer_reset(opc);
    561601  }
    562602
    563603  this->last_click_time = curr_time;
    564604
    565   osd_odometer_draw(this, nav,NULL);
     605  osd_odometer_draw(opc, nav,NULL);
    566606  }
    567607}
    568608
     
    594634
    595635
    596636static void
    597 osd_odometer_init(struct odometer *this, struct navit *nav)
     637osd_odometer_init(struct osd_priv_common *opc, struct navit *nav)
    598638{
    599         osd_set_std_graphic(nav, &this->osd_item, (struct osd_priv *)this);
     639        struct odometer *this = (struct odometer *)opc->data;
    600640
    601         this->orange = graphics_gc_new(this->osd_item.gr);
     641        osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
     642
     643        this->orange = graphics_gc_new(opc->osd_item.gr);
    602644        graphics_gc_set_foreground(this->orange, &this->idle_color);
    603645        graphics_gc_set_linewidth(this->orange, this->width);
    604646
    605         this->white = graphics_gc_new(this->osd_item.gr);
    606         graphics_gc_set_foreground(this->white, &this->osd_item.text_color);
     647        this->white = graphics_gc_new(opc->osd_item.gr);
     648        graphics_gc_set_foreground(this->white, &opc->osd_item.text_color);
    607649        graphics_gc_set_linewidth(this->white, this->width);
    608650
    609         graphics_gc_set_linewidth(this->osd_item.graphic_fg_white, this->width);
     651        graphics_gc_set_linewidth(opc->osd_item.graphic_fg_white, this->width);
    610652
    611         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_odometer_draw), attr_position_coord_geo, this));
     653        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_odometer_draw), attr_position_coord_geo, opc));
    612654
    613         navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_odometer_click), attr_button, this));
     655        navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_odometer_click), attr_button, opc));
    614656       
    615657        if(this->autosave_period>0) {
    616658                event_add_timeout(this->autosave_period*1000, 1, callback_new_1(callback_cast(osd_odometer_save), NULL));
     
    619661        if(this->bAutoStart) {
    620662                this->bActive = 1;
    621663        }
    622         osd_odometer_draw(this, nav, NULL);
     664        osd_odometer_draw(opc, nav, NULL);
    623665}
    624666
    625667static void
     
    639681        char* fn;
    640682
    641683        struct odometer *this = g_new0(struct odometer, 1);
     684        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     685        opc->data = (void*)this;
     686
    642687        struct attr *attr;
    643688        struct color orange_color={0xffff,0xa5a5,0x0000,0xffff};
    644         this->osd_item.p.x = 120;
    645         this->osd_item.p.y = 20;
    646         this->osd_item.w = 60;
    647         this->osd_item.h = 80;
    648         this->osd_item.navit = nav;
    649         this->osd_item.font_size = 200;
    650         this->osd_item.meth.draw = osd_draw_cast(osd_odometer_draw);
     689        opc->osd_item.p.x = 120;
     690        opc->osd_item.p.y = 20;
     691        opc->osd_item.w = 60;
     692        opc->osd_item.h = 80;
     693        opc->osd_item.navit = nav;
     694        opc->osd_item.font_size = 200;
     695        opc->osd_item.meth.draw = osd_draw_cast(osd_odometer_draw);
    651696
    652697        this->bActive = 0; //do not count on init
    653698        this->sum_dist = 0;
     
    688733        else
    689734                this->autosave_period = -1;  //disabled by default
    690735
    691         osd_set_std_attr(attrs, &this->osd_item, 2);
     736        osd_set_std_attr(attrs, &opc->osd_item, 2);
    692737        attr = attr_search(attrs, NULL, attr_width);
    693738        this->width=attr ? attr->u.num : 2;
    694739        attr = attr_search(attrs, NULL, attr_idle_color);
     
    729774                navit_command_add_table(nav, commands, sizeof(commands)/sizeof(struct command_table));
    730775                b_commandtable_added = 1;
    731776        }
    732         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_odometer_init), attr_graphics_ready, this));
     777        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_odometer_init), attr_graphics_ready, opc));
    733778        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_odometer_destroy), attr_destroy, nav));
    734779        odometer_list = g_list_append(odometer_list, this);
    735780
    736         return (struct osd_priv *) this;
     781        return (struct osd_priv *) opc;
    737782}
    738783
    739784 
    740785struct cmd_interface {
    741         struct osd_item osd_item;
    742786        int width;
    743787        struct graphics_gc *orange,*white;
    744788        int update_period;   //in sec
     
    750794};
    751795 
    752796static void
    753 osd_cmd_interface_draw(struct cmd_interface *this, struct navit *nav,
     797osd_cmd_interface_draw(struct osd_priv_common *opc, struct navit *nav,
    754798                struct vehicle *v)
    755799{
     800        struct cmd_interface *this = (struct cmd_interface *)opc->data;
     801
    756802        struct point p;
    757803        struct point bbox[4];
    758804        struct graphics_gc *curr_color;
     
    760806        p.x = 0;
    761807        p.y = 0;
    762808        navit.type=attr_navit;
    763         navit.u.navit = this->osd_item.navit;
     809        navit.u.navit = opc->osd_item.navit;
    764810 
    765811        if(0==this->bReserved) {
    766812                this->bReserved = 1;
     
    768814                this->bReserved = 0;
    769815        }
    770816 
    771         osd_std_draw(&this->osd_item);
     817        osd_std_draw(&opc->osd_item);
    772818
    773819        //display image
    774820        if(this->img) {
    775                 graphics_draw_image(this->osd_item.gr, this->osd_item.graphic_bg, &p, this->img);
     821                graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, this->img);
    776822        }
    777823
    778824        //display text
    779         graphics_get_text_bbox(this->osd_item.gr, this->osd_item.font, this->text, 0x10000, 0, bbox, 0);
    780         p.x=(this->osd_item.w-bbox[2].x)/2;
    781         p.y = this->osd_item.h-this->osd_item.h/10;
     825        graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, this->text, 0x10000, 0, bbox, 0);
     826        p.x=(opc->osd_item.w-bbox[2].x)/2;
     827        p.y = opc->osd_item.h-opc->osd_item.h/10;
    782828        curr_color = this->white;
    783829if(this->text)
    784         graphics_draw_text(this->osd_item.gr, curr_color, NULL, this->osd_item.font, this->text, &p, 0x10000, 0);
    785         graphics_draw_mode(this->osd_item.gr, draw_mode_end);
     830        graphics_draw_text(opc->osd_item.gr, curr_color, NULL, opc->osd_item.font, this->text, &p, 0x10000, 0);
     831        graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    786832}
    787833
    788834
    789835
    790836static void
    791 osd_cmd_interface_init(struct cmd_interface *this, struct navit *nav)
     837osd_cmd_interface_init(struct osd_priv_common *opc, struct navit *nav)
    792838{
    793         osd_set_std_graphic(nav, &this->osd_item, (struct osd_priv *)this);
     839        struct cmd_interface *this = (struct cmd_interface *)opc->data;
    794840
    795         this->white = graphics_gc_new(this->osd_item.gr);
    796         graphics_gc_set_foreground(this->white, &this->osd_item.text_color);
     841        osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
     842
     843        this->white = graphics_gc_new(opc->osd_item.gr);
     844        graphics_gc_set_foreground(this->white, &opc->osd_item.text_color);
    797845        graphics_gc_set_linewidth(this->white, this->width);
    798846
    799847
    800         graphics_gc_set_linewidth(this->osd_item.graphic_fg_white, this->width);
     848        graphics_gc_set_linewidth(opc->osd_item.graphic_fg_white, this->width);
    801849
    802850        if(this->update_period>0) {
    803                 event_add_timeout(this->update_period*1000, 1, callback_new_1(callback_cast(osd_cmd_interface_draw), this));
     851                event_add_timeout(this->update_period*1000, 1, callback_new_1(callback_cast(osd_cmd_interface_draw), opc));
    804852        }
    805853
    806         navit_add_callback(nav, callback_new_attr_1(callback_cast (osd_std_click), attr_button, &this->osd_item));
     854        navit_add_callback(nav, callback_new_attr_1(callback_cast (osd_std_click), attr_button, &opc->osd_item));
    807855
    808856        this->text = g_strdup("");
    809857}
    810858
    811859static int
    812 osd_cmd_interface_set_attr(struct cmd_interface *this_, struct attr* attr)
     860osd_cmd_interface_set_attr(struct osd_priv_common *opc, struct attr* attr)
    813861{
    814         struct navit* nav = this_->osd_item.navit;
     862        struct cmd_interface *this_ = (struct cmd_interface *)opc->data;
     863
    815864        if(NULL==attr || NULL==this_) {
    816865                return 0;
    817866        }       
     
    827876        if(attr->type == attr_src) {
    828877                if(attr->u.str) {
    829878                        if((!this_->img_filename) || strcmp(this_->img_filename, graphics_icon_path(attr->u.str))) {
    830                                 struct graphics *gra = navit_get_graphics(nav);
    831879                                //destroy old img, create new  image
    832880                                if(this_->img) {
    833                                         graphics_image_free(this_->osd_item.gr, this_->img);
     881                                        graphics_image_free(opc->osd_item.gr, this_->img);
    834882                                }
    835883                                if(this_->img_filename) {
    836884                                        g_free(this_->img_filename);
    837885                                }
    838886                                this_->img_filename = graphics_icon_path(attr->u.str);
    839                                 this_->img = graphics_image_new(this_->osd_item.gr, this_->img_filename);       
     887                                this_->img = graphics_image_new(opc->osd_item.gr, this_->img_filename);
    840888                        }
    841889                }
    842890                return 1;
     
    850898                struct attr **attrs)
    851899{
    852900        struct cmd_interface *this = g_new0(struct cmd_interface, 1);
     901        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     902        opc->data = (void*)this;
     903
    853904        struct attr *attr;
    854905
    855         this->osd_item.p.x = 120;
    856         this->osd_item.p.y = 20;
    857         this->osd_item.w = 60;
    858         this->osd_item.h = 80;
    859         this->osd_item.navit = nav;
    860         this->osd_item.font_size = 200;
    861         this->osd_item.meth.draw = osd_draw_cast(osd_cmd_interface_draw);
     906        opc->osd_item.p.x = 120;
     907        opc->osd_item.p.y = 20;
     908        opc->osd_item.w = 60;
     909        opc->osd_item.h = 80;
     910        opc->osd_item.navit = nav;
     911        opc->osd_item.font_size = 200;
     912        opc->osd_item.meth.draw = osd_draw_cast(osd_cmd_interface_draw);
    862913
    863914        meth->set_attr = osd_cmd_interface_set_attr;
    864915
    865         osd_set_std_attr(attrs, &this->osd_item, 2);
     916        osd_set_std_attr(attrs, &opc->osd_item, 2);
    866917
    867918        attr = attr_search(attrs, NULL, attr_width);
    868919        this->width=attr ? attr->u.num : 2;
     
    877928                navit_command_add_table(nav, commands, sizeof(commands)/sizeof(struct command_table));
    878929                b_commandtable_added = 1;
    879930        }
    880         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_cmd_interface_init), attr_graphics_ready, this));
    881         return (struct osd_priv *) this;
     931        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_cmd_interface_init), attr_graphics_ready, opc));
     932        return (struct osd_priv *) opc;
    882933}
    883934
    884935
    885936
    886937
    887938struct stopwatch {
    888         struct osd_item osd_item;
    889939        int width;
    890940        struct graphics_gc *orange,*white;
    891941        struct callback *click_cb;
     
    899949};
    900950
    901951static void
    902 osd_stopwatch_draw(struct stopwatch *this, struct navit *nav,
     952osd_stopwatch_draw(struct osd_priv_common *opc, struct navit *nav,
    903953                struct vehicle *v)
    904954{
     955        struct stopwatch *this = (struct stopwatch *)opc->data;
    905956
    906957        struct graphics_gc *curr_color;
    907958        char buffer[32]="00:00:00";
     
    910961        time_t total_sec,total_min,total_hours,total_days;
    911962        total_sec = this->sum_time;
    912963
    913         osd_std_draw(&this->osd_item);
     964        osd_std_draw(&opc->osd_item);
    914965
    915966        if(this->bActive) {
    916967                total_sec += time(0)-this->current_base_time;
     
    927978                (int)total_days, (int)total_hours%24, (int)total_min%60, (int)total_sec%60);
    928979        }
    929980
    930         graphics_get_text_bbox(this->osd_item.gr, this->osd_item.font, buffer, 0x10000, 0, bbox, 0);
    931         p.x=(this->osd_item.w-bbox[2].x)/2;
    932         p.y = this->osd_item.h-this->osd_item.h/10;
     981        graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, buffer, 0x10000, 0, bbox, 0);
     982        p.x=(opc->osd_item.w-bbox[2].x)/2;
     983        p.y = opc->osd_item.h-opc->osd_item.h/10;
    933984
    934985        curr_color = this->bActive?this->white:this->orange;
    935         graphics_draw_text(this->osd_item.gr, curr_color, NULL, this->osd_item.font, buffer, &p, 0x10000, 0);
    936         graphics_draw_mode(this->osd_item.gr, draw_mode_end);
     986        graphics_draw_text(opc->osd_item.gr, curr_color, NULL, opc->osd_item.font, buffer, &p, 0x10000, 0);
     987        graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    937988}
    938989
    939990
    940991static void
    941 osd_stopwatch_click(struct stopwatch *this, struct navit *nav, int pressed, int button, struct point *p)
     992osd_stopwatch_click(struct osd_priv_common *opc, struct navit *nav, int pressed, int button, struct point *p)
    942993{
    943         struct point bp = this->osd_item.p;
     994        struct stopwatch *this = (struct stopwatch *)opc->data;
     995
     996        struct point bp = opc->osd_item.p;
    944997        osd_wrap_point(&bp, nav);
    945   if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + this->osd_item.w || p->y > bp.y + this->osd_item.h || !this->osd_item.configured ) && !this->osd_item.pressed)
     998  if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + opc->osd_item.w || p->y > bp.y + opc->osd_item.h || !opc->osd_item.configured ) && !opc->osd_item.pressed)
    946999        return;
    9471000  if (button != 1)
    9481001    return;
    9491002  if (navit_ignore_button(nav))
    9501003    return;
    951   if (!!pressed == !!this->osd_item.pressed)
     1004  if (!!pressed == !!opc->osd_item.pressed)
    9521005    return;
    9531006
    9541007        if (pressed) { //single click handling
     
    9711024        this->last_click_time = time(0);
    9721025        }
    9731026
    974         osd_stopwatch_draw(this, nav,NULL);
     1027        osd_stopwatch_draw(opc, nav,NULL);
    9751028}
    9761029
    9771030
    9781031static void
    979 osd_stopwatch_init(struct stopwatch *this, struct navit *nav)
     1032osd_stopwatch_init(struct osd_priv_common *opc, struct navit *nav)
    9801033{
    981         osd_set_std_graphic(nav, &this->osd_item, (struct osd_priv *)this);
     1034        struct stopwatch *this = (struct stopwatch *)opc->data;
    9821035
    983         this->orange = graphics_gc_new(this->osd_item.gr);
     1036        osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
     1037
     1038        this->orange = graphics_gc_new(opc->osd_item.gr);
    9841039        graphics_gc_set_foreground(this->orange, &this->idle_color);
    9851040        graphics_gc_set_linewidth(this->orange, this->width);
    9861041
    987         this->white = graphics_gc_new(this->osd_item.gr);
    988         graphics_gc_set_foreground(this->white, &this->osd_item.text_color);
     1042        this->white = graphics_gc_new(opc->osd_item.gr);
     1043        graphics_gc_set_foreground(this->white, &opc->osd_item.text_color);
    9891044        graphics_gc_set_linewidth(this->white, this->width);
    9901045
    9911046
    992         graphics_gc_set_linewidth(this->osd_item.graphic_fg_white, this->width);
     1047        graphics_gc_set_linewidth(opc->osd_item.graphic_fg_white, this->width);
    9931048
    994         event_add_timeout(500, 1, callback_new_1(callback_cast(osd_stopwatch_draw), this));
     1049        event_add_timeout(500, 1, callback_new_1(callback_cast(osd_stopwatch_draw), opc));
    9951050
    996         navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_stopwatch_click), attr_button, this));
     1051        navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_stopwatch_click), attr_button, opc));
    9971052
    998         osd_stopwatch_draw(this, nav, NULL);
     1053        osd_stopwatch_draw(opc, nav, NULL);
    9991054}
    10001055
    10011056static struct osd_priv *
     
    10031058                struct attr **attrs)
    10041059{
    10051060        struct stopwatch *this = g_new0(struct stopwatch, 1);
     1061        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     1062        opc->data = (void*)this;
     1063
    10061064        struct attr *attr;
    10071065        struct color orange_color={0xffff,0xa5a5,0x0000,0xffff};
    10081066
    1009         this->osd_item.p.x = 120;
    1010         this->osd_item.p.y = 20;
    1011         this->osd_item.w = 60;
    1012         this->osd_item.h = 80;
    1013         this->osd_item.navit = nav;
    1014         this->osd_item.font_size = 200;
    1015         this->osd_item.meth.draw = osd_draw_cast(osd_stopwatch_draw);
     1067        opc->osd_item.p.x = 120;
     1068        opc->osd_item.p.y = 20;
     1069        opc->osd_item.w = 60;
     1070        opc->osd_item.h = 80;
     1071        opc->osd_item.navit = nav;
     1072        opc->osd_item.font_size = 200;
     1073        opc->osd_item.meth.draw = osd_draw_cast(osd_stopwatch_draw);
    10161074
    10171075        this->bActive = 0; //do not count on init
    10181076        this->current_base_time = 0;
    10191077        this->sum_time = 0;
    10201078        this->last_click_time = 0;
    10211079
    1022         osd_set_std_attr(attrs, &this->osd_item, 2);
     1080        osd_set_std_attr(attrs, &opc->osd_item, 2);
    10231081        attr = attr_search(attrs, NULL, attr_width);
    10241082        this->width=attr ? attr->u.num : 2;
    10251083        attr = attr_search(attrs, NULL, attr_idle_color);
     
    10301088        else
    10311089                this->bDisableReset = 0;
    10321090
    1033         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_stopwatch_init), attr_graphics_ready, this));
    1034         return (struct osd_priv *) this;
     1091        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_stopwatch_init), attr_graphics_ready, opc));
     1092        return (struct osd_priv *) opc;
    10351093}
    10361094
    10371095
    10381096static void
    1039 osd_compass_draw(struct compass *this, struct navit *nav,
     1097osd_compass_draw(struct osd_priv_common *opc, struct navit *nav,
    10401098                 struct vehicle *v)
    10411099{
     1100        struct compass *this = (struct compass *)opc->data;
     1101
    10421102        struct point p,bbox[4];
    10431103        struct attr attr_dir, destination_attr, position_attr, imperial_attr;
    10441104        double dir, vdir = 0;
     
    10501110        if (navit_get_attr(nav, attr_imperial, &imperial_attr, NULL))
    10511111                imperial=imperial_attr.u.num;
    10521112
    1053         osd_std_draw(&this->osd_item);
    1054         p.x = this->osd_item.w/2;
    1055         p.y = this->osd_item.w/2;
    1056         graphics_draw_circle(this->osd_item.gr,
    1057                              this->osd_item.graphic_fg_white, &p, this->osd_item.w*5/6);
     1113        osd_std_draw(&opc->osd_item);
     1114        p.x = opc->osd_item.w/2;
     1115        p.y = opc->osd_item.w/2;
     1116        graphics_draw_circle(opc->osd_item.gr,
     1117                             opc->osd_item.graphic_fg_white, &p, opc->osd_item.w*5/6);
    10581118        if (v) {
    10591119                if (vehicle_get_attr(v, attr_position_direction, &attr_dir, NULL)) {
    10601120                        vdir = *attr_dir.u.numd;
    1061                         handle(this->osd_item.gr, this->osd_item.graphic_fg_white, &p, this->osd_item.w/3, -vdir);
     1121                        handle(opc->osd_item.gr, opc->osd_item.graphic_fg_white, &p, opc->osd_item.w/3, -vdir);
    10621122                }
    10631123
    10641124                if (navit_get_attr(nav, attr_destination, &destination_attr, NULL)
     
    10691129                        c2.y = destination_attr.u.pcoord->y;
    10701130                        dir = atan2(c2.x - c1.x, c2.y - c1.y) * 180.0 / M_PI;
    10711131                        dir -= vdir;
    1072                         handle(this->osd_item.gr, this->green, &p, this->osd_item.w/3, dir);
     1132                        handle(opc->osd_item.gr, this->green, &p, opc->osd_item.w/3, dir);
    10731133                        buffer=format_distance(transform_distance(pro, &c1, &c2),"",imperial);
    1074                         graphics_get_text_bbox(this->osd_item.gr, this->osd_item.font, buffer, 0x10000, 0, bbox, 0);
    1075                         p.x=(this->osd_item.w-bbox[2].x)/2;
    1076                         p.y = this->osd_item.h-this->osd_item.h/10;
    1077                         graphics_draw_text(this->osd_item.gr, this->green, NULL, this->osd_item.font, buffer, &p, 0x10000, 0);
     1134                        graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, buffer, 0x10000, 0, bbox, 0);
     1135                        p.x=(opc->osd_item.w-bbox[2].x)/2;
     1136                        p.y = opc->osd_item.h-opc->osd_item.h/10;
     1137                        graphics_draw_text(opc->osd_item.gr, this->green, NULL, opc->osd_item.font, buffer, &p, 0x10000, 0);
    10781138                        g_free(buffer);
    10791139                }
    10801140        }
    1081         graphics_draw_mode(this->osd_item.gr, draw_mode_end);
     1141        graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    10821142}
    10831143
    10841144
    10851145
    10861146static void
    1087 osd_compass_init(struct compass *this, struct navit *nav)
     1147osd_compass_init(struct osd_priv_common *opc, struct navit *nav)
    10881148{
    10891149        struct color c;
    10901150
    1091         osd_set_std_graphic(nav, &this->osd_item, (struct osd_priv *)this);
     1151        struct compass *this = (struct compass *)opc->data;
    10921152
    1093         this->green = graphics_gc_new(this->osd_item.gr);
     1153        osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
     1154
     1155        this->green = graphics_gc_new(opc->osd_item.gr);
    10941156        c.r = 0;
    10951157        c.g = 65535;
    10961158        c.b = 0;
    10971159        c.a = 65535;
    10981160        graphics_gc_set_foreground(this->green, &c);
    10991161        graphics_gc_set_linewidth(this->green, this->width);
    1100         graphics_gc_set_linewidth(this->osd_item.graphic_fg_white, this->width);
     1162        graphics_gc_set_linewidth(opc->osd_item.graphic_fg_white, this->width);
    11011163
    1102         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_compass_draw), attr_position_coord_geo, this));
     1164        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_compass_draw), attr_position_coord_geo, opc));
    11031165
    1104         osd_compass_draw(this, nav, NULL);
     1166        osd_compass_draw(opc, nav, NULL);
    11051167}
    11061168
    11071169static struct osd_priv *
     
    11091171                struct attr **attrs)
    11101172{
    11111173        struct compass *this = g_new0(struct compass, 1);
     1174        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     1175        opc->data = (void*)this;
     1176
    11121177        struct attr *attr;
    1113         this->osd_item.p.x = 20;
    1114         this->osd_item.p.y = 20;
    1115         this->osd_item.w = 60;
    1116         this->osd_item.h = 80;
    1117         this->osd_item.navit = nav;
    1118         this->osd_item.font_size = 200;
    1119         this->osd_item.meth.draw = osd_draw_cast(osd_compass_draw);
    1120         osd_set_std_attr(attrs, &this->osd_item, 2);
     1178        opc->osd_item.p.x = 20;
     1179        opc->osd_item.p.y = 20;
     1180        opc->osd_item.w = 60;
     1181        opc->osd_item.h = 80;
     1182        opc->osd_item.navit = nav;
     1183        opc->osd_item.font_size = 200;
     1184        opc->osd_item.meth.draw = osd_draw_cast(osd_compass_draw);
     1185        osd_set_std_attr(attrs, &opc->osd_item, 2);
    11211186        attr = attr_search(attrs, NULL, attr_width);
    11221187        this->width=attr ? attr->u.num : 2;
    1123         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_compass_init), attr_graphics_ready, this));
    1124         return (struct osd_priv *) this;
     1188        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_compass_init), attr_graphics_ready, opc));
     1189        return (struct osd_priv *) opc;
    11251190}
    11261191
    11271192struct osd_button {
    11281193        int use_overlay;
    1129         struct osd_item item;
    11301194        struct callback *draw_cb,*navit_init_cb;
    11311195        struct graphics_image *img;
    11321196        char *src;
    11331197};
    11341198
    11351199static void
    1136 osd_button_draw(struct osd_button *this, struct navit *nav)
     1200osd_button_draw(struct osd_priv_common *opc, struct navit *nav)
    11371201{
    1138         struct point bp = this->item.p;
    1139         if (!this->item.configured)
     1202        struct osd_button *this = (struct osd_button *)opc->data;
     1203
     1204        struct point bp = opc->osd_item.p;
     1205        if (!opc->osd_item.configured)
    11401206                return;
    11411207        osd_wrap_point(&bp, nav);
    1142         graphics_draw_image(this->item.gr, this->item.graphic_bg, &bp, this->img);
     1208        graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &bp, this->img);
    11431209}
    11441210
    11451211static void
    1146 osd_button_init(struct osd_button *this, struct navit *nav)
     1212osd_button_init(struct osd_priv_common *opc, struct navit *nav)
    11471213{
     1214        struct osd_button *this = (struct osd_button *)opc->data;
     1215
    11481216        struct graphics *gra = navit_get_graphics(nav);
    11491217        dbg(1, "enter\n");
    11501218        this->img = graphics_image_new(gra, this->src);
     
    11521220                dbg(1, "failed to load '%s'\n", this->src);
    11531221                return;
    11541222        }
    1155         if (!this->item.w)
    1156                 this->item.w=this->img->width;
    1157         if (!this->item.h)
    1158                 this->item.h=this->img->height;
     1223        if (!opc->osd_item.w)
     1224                opc->osd_item.w=this->img->width;
     1225        if (!opc->osd_item.h)
     1226                opc->osd_item.h=this->img->height;
    11591227        if (this->use_overlay) {
    11601228                struct graphics_image *img;
    11611229                struct point p;
    1162                 osd_set_std_graphic(nav, &this->item, (struct osd_priv *)this);
    1163                 img=graphics_image_new(this->item.gr, this->src);
    1164                 p.x=(this->item.w-this->img->width)/2;
    1165                 p.y=(this->item.h-this->img->height)/2;
    1166                 osd_std_draw(&this->item);
    1167                 graphics_draw_image(this->item.gr, this->item.graphic_bg, &p, img);
    1168                 graphics_draw_mode(this->item.gr, draw_mode_end);
    1169                 graphics_image_free(this->item.gr, img);
     1230                osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
     1231                img=graphics_image_new(opc->osd_item.gr, this->src);
     1232                p.x=(opc->osd_item.w-this->img->width)/2;
     1233                p.y=(opc->osd_item.h-this->img->height)/2;
     1234                osd_std_draw(&opc->osd_item);
     1235                graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
     1236                graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
     1237                graphics_image_free(opc->osd_item.gr, img);
    11701238        } else {
    1171                 osd_set_std_config(nav, &this->item);
    1172                 this->item.gr=gra;
    1173                 this->item.graphic_bg=graphics_gc_new(this->item.gr);
    1174                 graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_button_draw), attr_postdraw, this, nav));
     1239                osd_set_std_config(nav, &opc->osd_item);
     1240                opc->osd_item.gr=gra;
     1241                opc->osd_item.graphic_bg=graphics_gc_new(opc->osd_item.gr);
     1242                graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_button_draw), attr_postdraw, opc, nav));
    11751243        }
    1176         navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_std_click), attr_button, &this->item));
    1177         osd_button_draw(this,nav);
     1244        navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_std_click), attr_button, &opc->osd_item));
     1245        osd_button_draw(opc,nav);
    11781246}
    11791247 
    11801248int
    1181 osd_button_set_attr(struct osd_button *this_, struct attr* attr)
     1249osd_button_set_attr(struct osd_priv_common *opc, struct attr* attr)
    11821250{
     1251        struct osd_button *this_ = (struct osd_button *)opc->data;
     1252
    11831253        if(NULL==attr || NULL==this_) {
    11841254                return 0;
    11851255        }       
     
    11921262                if(attr->u.str) {
    11931263                        this_->src = graphics_icon_path(attr->u.str);
    11941264                }
    1195                 nav = this_->item.navit;
     1265                nav = opc->osd_item.navit;
    11961266                gra = navit_get_graphics(nav);
    11971267                this_->img = graphics_image_new(gra, this_->src);
    11981268                if (!this_->img) {
    11991269                        dbg(1, "failed to load '%s'\n", this_->src);
    12001270                        return 0;
    12011271                }
    1202                 if (!this_->item.w)
    1203                         this_->item.w=this_->img->width;
    1204                 if (!this_->item.h)
    1205                         this_->item.h=this_->img->height;
     1272                if (!opc->osd_item.w)
     1273                        opc->osd_item.w=this_->img->width;
     1274                if (!opc->osd_item.h)
     1275                        opc->osd_item.h=this_->img->height;
    12061276 
    12071277                if (this_->use_overlay) {
    12081278                        struct graphics_image *img;
    12091279                        struct point p;
    1210                         img=graphics_image_new(this_->item.gr, this_->src);
    1211                         p.x=(this_->item.w-this_->img->width)/2;
    1212                         p.y=(this_->item.h-this_->img->height)/2;
    1213                         osd_std_draw(&this_->item);
    1214                         graphics_draw_image(this_->item.gr, this_->item.graphic_bg, &p, img);
    1215                         graphics_image_free(this_->item.gr, img);
     1280                        img=graphics_image_new(opc->osd_item.gr, this_->src);
     1281                        p.x=(opc->osd_item.w-this_->img->width)/2;
     1282                        p.y=(opc->osd_item.h-this_->img->height)/2;
     1283                        osd_std_draw(&opc->osd_item);
     1284                        graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
     1285                        graphics_image_free(opc->osd_item.gr, img);
    12161286                }
    1217                 osd_button_draw(this_,nav);
    1218                 navit_draw(this_->item.navit);
     1287                osd_button_draw(opc,nav);
     1288                navit_draw(opc->osd_item.navit);
    12191289                return 1;
    12201290        }
    12211291        return 0;
     
    12281298               struct attr **attrs)
    12291299{
    12301300        struct osd_button *this = g_new0(struct osd_button, 1);
     1301        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     1302        opc->data = (void*)this;
     1303
    12311304        struct attr *attr;
    12321305
    1233         this->item.navit = nav;
    1234         this->item.meth.draw = osd_draw_cast(osd_button_draw);
     1306        opc->osd_item.navit = nav;
     1307        opc->osd_item.meth.draw = osd_draw_cast(osd_button_draw);
    12351308
    12361309        meth->set_attr = osd_button_set_attr;
    12371310
    1238         osd_set_std_attr(attrs, &this->item, 1|16);
     1311        osd_set_std_attr(attrs, &opc->osd_item, 1|16);
    12391312
    12401313        attr=attr_search(attrs, NULL, attr_use_overlay);
    12411314        if (attr)
    12421315                this->use_overlay=attr->u.num;
    1243         if (!this->item.command) {
     1316        if (!opc->osd_item.command) {
    12441317                dbg(0, "no command\n");
    12451318                goto error;
    12461319        }
     
    12521325
    12531326        this->src = graphics_icon_path(attr->u.str);
    12541327
    1255         navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_button_init), attr_graphics_ready, this));
     1328        navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_button_init), attr_graphics_ready, opc));
    12561329
    12571330        if(b_commandtable_added == 0) {
    12581331                navit_command_add_table(nav, commands, sizeof(commands)/sizeof(struct command_table));
    12591332                b_commandtable_added = 1;
    12601333        }
    12611334
    1262         return (struct osd_priv *) this;
     1335        return (struct osd_priv *) opc;
    12631336      error:
    12641337        g_free(this);
     1338        g_free(opc);
    12651339        return NULL;
    12661340}
    12671341
    12681342struct osd_image {
    12691343        int use_overlay;
    1270         struct osd_item item;
    12711344        struct callback *draw_cb,*navit_init_cb;
    12721345        struct graphics_image *img;
    12731346        char *src;
    12741347};
    12751348
    12761349static void
    1277 osd_image_draw(struct osd_image *this, struct navit *nav)
     1350osd_image_draw(struct osd_priv_common *opc, struct navit *nav)
    12781351{
    1279         struct point bp = this->item.p;
     1352        struct osd_button *this = (struct osd_button *)opc->data;
     1353
     1354        struct point bp = opc->osd_item.p;
    12801355        osd_wrap_point(&bp, nav);
    1281         graphics_draw_image(this->item.gr, this->item.graphic_bg, &bp, this->img);
     1356        graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &bp, this->img);
    12821357}
    12831358
    12841359static void
    1285 osd_image_init(struct osd_image *this, struct navit *nav)
     1360osd_image_init(struct osd_priv_common *opc, struct navit *nav)
    12861361{
     1362        struct osd_button *this = (struct osd_button *)opc->data;
     1363
    12871364        struct graphics *gra = navit_get_graphics(nav);
    12881365        dbg(1, "enter\n");
    12891366        this->img = graphics_image_new(gra, this->src);
     
    12911368                dbg(1, "failed to load '%s'\n", this->src);
    12921369                return;
    12931370        }
    1294         if (!this->item.w)
    1295                 this->item.w=this->img->width;
    1296         if (!this->item.h)
    1297                 this->item.h=this->img->height;
     1371        if (!opc->osd_item.w)
     1372                opc->osd_item.w=this->img->width;
     1373        if (!opc->osd_item.h)
     1374                opc->osd_item.h=this->img->height;
    12981375        if (this->use_overlay) {
    12991376                struct graphics_image *img;
    13001377                struct point p;
    1301                 osd_set_std_graphic(nav, &this->item, (struct osd_priv *)this);
    1302                 img=graphics_image_new(this->item.gr, this->src);
    1303                 p.x=(this->item.w-this->img->width)/2;
    1304                 p.y=(this->item.h-this->img->height)/2;
    1305                 osd_std_draw(&this->item);
    1306                 graphics_draw_image(this->item.gr, this->item.graphic_bg, &p, img);
    1307                 graphics_draw_mode(this->item.gr, draw_mode_end);
    1308                 graphics_image_free(this->item.gr, img);
     1378                osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
     1379                img=graphics_image_new(opc->osd_item.gr, this->src);
     1380                p.x=(opc->osd_item.w-this->img->width)/2;
     1381                p.y=(opc->osd_item.h-this->img->height)/2;
     1382                osd_std_draw(&opc->osd_item);
     1383                graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
     1384                graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
     1385                graphics_image_free(opc->osd_item.gr, img);
    13091386        } else {
    1310                 this->item.configured=1;
    1311                 this->item.gr=gra;
    1312                 this->item.graphic_bg=graphics_gc_new(this->item.gr);
    1313                 graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_button_draw), attr_postdraw, this, nav));
     1387                opc->osd_item.configured=1;
     1388                opc->osd_item.gr=gra;
     1389                opc->osd_item.graphic_bg=graphics_gc_new(opc->osd_item.gr);
     1390                graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_button_draw), attr_postdraw, opc, nav));
    13141391        }
    1315         osd_image_draw(this,nav);
     1392        osd_image_draw(opc,nav);
    13161393}
    13171394
    13181395static struct osd_priv *
     
    13201397               struct attr **attrs)
    13211398{
    13221399        struct osd_image *this = g_new0(struct osd_image, 1);
     1400        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     1401        opc->data = (void*)this;
     1402
    13231403        struct attr *attr;
    13241404
    1325         this->item.navit = nav;
    1326         this->item.meth.draw = osd_draw_cast(osd_image_draw);
     1405        opc->osd_item.navit = nav;
     1406        opc->osd_item.meth.draw = osd_draw_cast(osd_image_draw);
    13271407
    1328         osd_set_std_attr(attrs, &this->item, 1);
     1408        osd_set_std_attr(attrs, &opc->osd_item, 1);
    13291409
    13301410        attr=attr_search(attrs, NULL, attr_use_overlay);
    13311411        if (attr)
     
    13381418
    13391419        this->src = graphics_icon_path(attr->u.str);
    13401420
    1341         navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_image_init), attr_graphics_ready, this));
     1421        navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_image_init), attr_graphics_ready, opc));
    13421422
    13431423        return (struct osd_priv *) this;
    13441424      error:
     
    13471427}
    13481428
    13491429struct nav_next_turn {
    1350         struct osd_item osd_item;
    13511430        char *test_text;
    13521431        char *icon_src;
    13531432        int icon_h, icon_w, active;
     
    13561435};
    13571436
    13581437static void
    1359 osd_nav_next_turn_draw(struct nav_next_turn *this, struct navit *navit,
     1438osd_nav_next_turn_draw(struct osd_priv_common *opc, struct navit *navit,
    13601439                       struct vehicle *v)
    13611440{
     1441        struct nav_next_turn *this = (struct nav_next_turn *)opc->data;
     1442
    13621443        struct point p;
    13631444        int do_draw = 0;
    13641445        struct navigation *nav = NULL;
     
    13971478                map_rect_destroy(mr);
    13981479
    13991480        if (do_draw) {
    1400                 osd_std_draw(&this->osd_item);
     1481                osd_std_draw(&opc->osd_item);
    14011482                if (this->active) {
    14021483                        image = g_strdup_printf(this->icon_src, name);
    14031484                        dbg(1, "image=%s\n", image);
    14041485                        gr_image =
    1405                             graphics_image_new_scaled(this->osd_item.gr,
     1486                            graphics_image_new_scaled(opc->osd_item.gr,
    14061487                                                      image, this->icon_w,
    14071488                                                      this->icon_h);
    14081489                        if (!gr_image) {
     
    14101491                                g_free(image);
    14111492                                image = graphics_icon_path("unknown.xpm");
    14121493                                gr_image =
    1413                                     graphics_image_new_scaled(this->
     1494                                    graphics_image_new_scaled(opc->
    14141495                                                              osd_item.gr,
    14151496                                                              image,
    14161497                                                              this->icon_w,
     
    14201501                        dbg(1, "gr_image=%p\n", gr_image);
    14211502                        if (gr_image) {
    14221503                                p.x =
    1423                                     (this->osd_item.w -
     1504                                    (opc->osd_item.w -
    14241505                                     gr_image->width) / 2;
    14251506                                p.y =
    1426                                     (this->osd_item.h -
     1507                                    (opc->osd_item.h -
    14271508                                     gr_image->height) / 2;
    1428                                 graphics_draw_image(this->osd_item.gr,
    1429                                                     this->osd_item.
     1509                                graphics_draw_image(opc->osd_item.gr,
     1510                                                    opc->osd_item.
    14301511                                                    graphic_fg_white, &p,
    14311512                                                    gr_image);
    1432                                 graphics_image_free(this->osd_item.gr,
     1513                                graphics_image_free(opc->osd_item.gr,
    14331514                                                    gr_image);
    14341515                        }
    14351516                        g_free(image);
    14361517                }
    1437                 graphics_draw_mode(this->osd_item.gr, draw_mode_end);
     1518                graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    14381519        }
    14391520}
    14401521
    14411522static void
    1442 osd_nav_next_turn_init(struct nav_next_turn *this, struct navit *nav)
     1523osd_nav_next_turn_init(struct osd_priv_common *opc, struct navit *nav)
    14431524{
    1444         osd_set_std_graphic(nav, &this->osd_item, (struct osd_priv *)this);
    1445         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_next_turn_draw), attr_position_coord_geo, this));
    1446         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_std_click), attr_button, &this->osd_item));
    1447         osd_nav_next_turn_draw(this, nav, NULL);
     1525        osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
     1526        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_next_turn_draw), attr_position_coord_geo, opc));
     1527        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_std_click), attr_button, &opc->osd_item));
     1528        osd_nav_next_turn_draw(opc, nav, NULL);
    14481529}
    14491530
    14501531static struct osd_priv *
     
    14521533                      struct attr **attrs)
    14531534{
    14541535        struct nav_next_turn *this = g_new0(struct nav_next_turn, 1);
     1536        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     1537        opc->data = (void*)this;
     1538
    14551539        struct attr *attr;
    14561540
    1457         this->osd_item.p.x = 20;
    1458         this->osd_item.p.y = -80;
    1459         this->osd_item.w = 70;
    1460         this->osd_item.navit = nav;
    1461         this->osd_item.h = 70;
    1462         this->osd_item.font_size = 200;
    1463         this->osd_item.meth.draw = osd_draw_cast(osd_nav_next_turn_draw);
    1464         osd_set_std_attr(attrs, &this->osd_item, 0);
     1541        opc->osd_item.p.x = 20;
     1542        opc->osd_item.p.y = -80;
     1543        opc->osd_item.w = 70;
     1544        opc->osd_item.navit = nav;
     1545        opc->osd_item.h = 70;
     1546        opc->osd_item.font_size = 200;
     1547        opc->osd_item.meth.draw = osd_draw_cast(osd_nav_next_turn_draw);
     1548        osd_set_std_attr(attrs, &opc->osd_item, 0);
    14651549
    14661550        this->icon_w = -1;
    14671551        this->icon_h = -1;
     
    14921576        if (attr)
    14931577                this->level=attr->u.num;
    14941578
    1495         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_next_turn_init), attr_graphics_ready, this));
    1496         return (struct osd_priv *) this;
     1579        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_next_turn_init), attr_graphics_ready, opc));
     1580        return (struct osd_priv *) opc;
    14971581}
    14981582
    14991583struct nav_toggle_announcer
    15001584{
    15011585        int w,h;
    15021586        struct callback *navit_init_cb;
    1503         struct osd_item item;
    15041587        char *icon_src;
    15051588        int icon_h, icon_w, active, last_state;
    15061589};
    15071590
    15081591static void
    1509 osd_nav_toggle_announcer_draw(struct nav_toggle_announcer *this, struct navit *navit, struct vehicle *v)
     1592osd_nav_toggle_announcer_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle *v)
    15101593{
     1594        struct nav_toggle_announcer *this = (struct nav_toggle_announcer *)opc->data;
     1595
    15111596        struct point p;
    15121597        int do_draw = 0;
    15131598        struct graphics_image *gr_image;
     
    15331618
    15341619        if (do_draw)
    15351620    {
    1536                 graphics_draw_mode(this->item.gr, draw_mode_begin);
     1621                graphics_draw_mode(opc->osd_item.gr, draw_mode_begin);
    15371622                p.x = 0;
    15381623                p.y = 0;
    1539                 graphics_draw_rectangle(this->item.gr, this->item.graphic_bg, &p, this->item.w, this->item.h);
     1624                graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, opc->osd_item.w, opc->osd_item.h);
    15401625
    15411626                if (this->active)
    15421627            path = g_strdup_printf(this->icon_src, gui_sound_on);
    15431628        else
    15441629            path = g_strdup_printf(this->icon_src, gui_sound_off);
    15451630       
    1546         gr_image = graphics_image_new_scaled(this->item.gr, path, this->icon_w, this->icon_h);
     1631        gr_image = graphics_image_new_scaled(opc->osd_item.gr, path, this->icon_w, this->icon_h);
    15471632        if (!gr_image)
    15481633        {
    15491634            g_free(path);
    15501635            path = graphics_icon_path("unknown.xpm");
    1551             gr_image = graphics_image_new_scaled(this->item.gr, path, this->icon_w, this->icon_h);
     1636            gr_image = graphics_image_new_scaled(opc->osd_item.gr, path, this->icon_w, this->icon_h);
    15521637        }
    15531638       
    15541639        dbg(1, "gr_image=%p\n", gr_image);
    15551640       
    15561641        if (gr_image)
    15571642        {
    1558             p.x = (this->item.w - gr_image->width) / 2;
    1559             p.y = (this->item.h - gr_image->height) / 2;
    1560             graphics_draw_image(this->item.gr, this->item.graphic_fg_white, &p, gr_image);
    1561             graphics_image_free(this->item.gr, gr_image);
     1643            p.x = (opc->osd_item.w - gr_image->width) / 2;
     1644            p.y = (opc->osd_item.h - gr_image->height) / 2;
     1645            graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_fg_white, &p, gr_image);
     1646            graphics_image_free(opc->osd_item.gr, gr_image);
    15621647        }
    15631648       
    15641649        g_free(path);
    1565                 graphics_draw_mode(this->item.gr, draw_mode_end);
     1650                graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    15661651        }
    15671652}
    15681653
    15691654static void
    1570 osd_nav_toggle_announcer_init(struct nav_toggle_announcer *this, struct navit *nav)
     1655osd_nav_toggle_announcer_init(struct osd_priv_common *opc, struct navit *nav)
    15711656{
    1572         osd_set_std_graphic(nav, &this->item, (struct osd_priv *)this);
    1573         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_toggle_announcer_draw), attr_speech, this));
    1574     navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast(osd_std_click), attr_button, &this->item));
    1575         osd_nav_toggle_announcer_draw(this, nav, NULL);
     1657        struct nav_toggle_announcer *this = (struct nav_toggle_announcer *)opc->data;
     1658
     1659        osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
     1660        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_toggle_announcer_draw), attr_speech, opc));
     1661    navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast(osd_std_click), attr_button, &opc->osd_item));
     1662        osd_nav_toggle_announcer_draw(opc, nav, NULL);
    15761663}
    15771664
    15781665static struct osd_priv *
    15791666osd_nav_toggle_announcer_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs)
    15801667{
    15811668        struct nav_toggle_announcer *this = g_new0(struct nav_toggle_announcer, 1);
    1582     struct attr *attr;
    1583     char *command = "announcer_toggle()";
     1669        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     1670        opc->data = (void*)this;
     1671        struct attr *attr;
     1672        char *command = "announcer_toggle()";
    15841673
    1585         this->item.w = 48;
    1586         this->item.h = 48;
    1587         this->item.p.x = -64;
    1588         this->item.navit = nav;
    1589         this->item.p.y = 76;
    1590         this->item.meth.draw = osd_draw_cast(osd_nav_toggle_announcer_draw);
     1674        opc->osd_item.w = 48;
     1675        opc->osd_item.h = 48;
     1676        opc->osd_item.p.x = -64;
     1677        opc->osd_item.navit = nav;
     1678        opc->osd_item.p.y = 76;
     1679        opc->osd_item.meth.draw = osd_draw_cast(osd_nav_toggle_announcer_draw);
    15911680
    1592         osd_set_std_attr(attrs, &this->item, 0);
     1681        osd_set_std_attr(attrs, &opc->osd_item, 0);
    15931682
    15941683        this->icon_w = -1;
    15951684        this->icon_h = -1;
    1596     this->last_state = -1;
     1685        this->last_state = -1;
    15971686
    1598     attr = attr_search(attrs, NULL, attr_icon_src);
     1687        attr = attr_search(attrs, NULL, attr_icon_src);
    15991688        if (attr) {
    16001689                struct file_wordexp *we;
    16011690                char **array;
     
    16061695        } else
    16071696                this->icon_src = graphics_icon_path("%s_32.xpm");
    16081697
    1609     this->item.command = g_strdup(command);
     1698        opc->osd_item.command = g_strdup(command);
    16101699
    1611         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_toggle_announcer_init), attr_graphics_ready, this));
    1612         return (struct osd_priv *) this;
     1700        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_nav_toggle_announcer_init), attr_graphics_ready, opc));
     1701        return (struct osd_priv *) opc;
    16131702}
    16141703
    16151704enum osd_speed_warner_eAnnounceState {eNoWarn=0,eWarningTold=1};
     
    16281717};
    16291718
    16301719struct osd_speed_cam {
    1631   struct osd_item item;
    16321720  int width;
    16331721  struct graphics_gc *white,*orange;
    16341722  struct graphics_gc *red;
     
    16491737}
    16501738
    16511739static void
    1652 osd_speed_cam_draw(struct osd_speed_cam *this_, struct navit *navit, struct vehicle *v)
     1740osd_speed_cam_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle *v)
    16531741{
     1742  struct osd_speed_cam *this_ = (struct osd_speed_cam *)opc->data;
     1743
    16541744  struct attr position_attr,vehicle_attr,imperial_attr;
    16551745  struct point p, bbox[4];
    16561746  struct attr speed_attr;
     
    17681858    dCurrDist = transform_distance(projection_mg, &curr_coord, &cam_coord);
    17691859    ret_attr = vehicle_get_attr(curr_vehicle,attr_position_speed,&speed_attr, NULL);
    17701860    if(0==ret_attr) {
    1771       graphics_overlay_disable(this_->item.gr,1);
     1861      graphics_overlay_disable(opc->osd_item.gr,1);
    17721862      return;
    17731863    }
    1774     graphics_overlay_disable(this_->item.gr,0);
     1864    graphics_overlay_disable(opc->osd_item.gr,0);
    17751865    speed = *speed_attr.u.numd;
    17761866    if(dCurrDist <= speed*750.0/130.0) {  //at speed 130 distance limit is 750m
    17771867      if(this_->announce_state==eNoWarn && this_->announce_on) {
     
    17911881      buffer [0] = 0;
    17921882      buffer2[0] = 0;
    17931883 
    1794       osd_std_draw(&this_->item);
     1884      osd_std_draw(&opc->osd_item);
    17951885
    17961886      str_replace(buffer,this_->text,"${distance}",format_distance(dCurrDist,"",imperial));
    17971887      str_replace(buffer2,buffer,"${camera_type}",(0<=idx && idx<=CAM_TRAFFIPAX)?camera_t_strs[idx]:"");
     
    18011891      str_replace(buffer2,buffer,"${direction}",dir_str);
    18021892      str_replace(buffer,buffer2,"${speed_limit}",spd_str);
    18031893 
    1804       graphics_get_text_bbox(this_->item.gr, this_->item.font, buffer, 0x10000, 0, bbox, 0);
    1805       p.x=(this_->item.w-bbox[2].x)/2;
    1806       p.y = this_->item.h-this_->item.h/10;
     1894      graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, buffer, 0x10000, 0, bbox, 0);
     1895      p.x=(opc->osd_item.w-bbox[2].x)/2;
     1896      p.y = opc->osd_item.h-opc->osd_item.h/10;
    18071897      curr_color = this_->orange;
    18081898      //tolerance is +-20 degrees
    18091899      if(
     
    18241914      else if(dCurrDist <= speed*750.0/130.0) {
    18251915        curr_color = this_->red;
    18261916      }
    1827       graphics_draw_text(this_->item.gr, curr_color, NULL, this_->item.font, buffer, &p, 0x10000, 0);
    1828       graphics_draw_mode(this_->item.gr, draw_mode_end);
     1917      graphics_draw_text(opc->osd_item.gr, curr_color, NULL, opc->osd_item.font, buffer, &p, 0x10000, 0);
     1918      graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    18291919    }
    18301920  }
    18311921  else {
    1832     graphics_overlay_disable(this_->item.gr,1);
     1922    graphics_overlay_disable(opc->osd_item.gr,1);
    18331923  }
    18341924}
    18351925
    18361926static void
    1837 osd_speed_cam_init(struct osd_speed_cam *this, struct navit *nav)
     1927osd_speed_cam_init(struct osd_priv_common *opc, struct navit *nav)
    18381928{
     1929  struct osd_speed_cam *this = (struct osd_speed_cam *)opc->data;
     1930
    18391931  struct color red_color={0xffff,0x0000,0x0000,0xffff};
    1840   osd_set_std_graphic(nav, &this->item, (struct osd_priv *)this);
     1932  osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
    18411933
    1842   this->red = graphics_gc_new(this->item.gr);
     1934  this->red = graphics_gc_new(opc->osd_item.gr);
    18431935  graphics_gc_set_foreground(this->red, &red_color);
    18441936  graphics_gc_set_linewidth(this->red, this->width);
    18451937
    1846   this->orange = graphics_gc_new(this->item.gr);
     1938  this->orange = graphics_gc_new(opc->osd_item.gr);
    18471939  graphics_gc_set_foreground(this->orange, &this->idle_color);
    18481940  graphics_gc_set_linewidth(this->orange, this->width);
    18491941
    1850   this->white = graphics_gc_new(this->item.gr);
    1851   graphics_gc_set_foreground(this->white, &this->item.text_color);
     1942  this->white = graphics_gc_new(opc->osd_item.gr);
     1943  graphics_gc_set_foreground(this->white, &opc->osd_item.text_color);
    18521944  graphics_gc_set_linewidth(this->white, this->width);
    18531945
    18541946
    1855   graphics_gc_set_linewidth(this->item.graphic_fg_white, this->width);
     1947  graphics_gc_set_linewidth(opc->osd_item.graphic_fg_white, this->width);
    18561948
    1857   navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_cam_draw), attr_position_coord_geo, this));
     1949  navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_cam_draw), attr_position_coord_geo, opc));
    18581950
    18591951}
    18601952
     
    18651957  struct color default_color={0xffff,0xa5a5,0x0000,0xffff};
    18661958
    18671959  struct osd_speed_cam *this = g_new0(struct osd_speed_cam, 1);
     1960  struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     1961  opc->data = (void*)this;
     1962
    18681963  struct attr *attr;
    1869   this->item.p.x = 120;
    1870   this->item.p.y = 20;
    1871   this->item.w = 60;
    1872   this->item.h = 80;
    1873   this->item.navit = nav;
    1874   this->item.font_size = 200;
    1875   this->item.meth.draw = osd_draw_cast(osd_speed_cam_draw);
     1964  opc->osd_item.p.x = 120;
     1965  opc->osd_item.p.y = 20;
     1966  opc->osd_item.w = 60;
     1967  opc->osd_item.h = 80;
     1968  opc->osd_item.navit = nav;
     1969  opc->osd_item.font_size = 200;
     1970  opc->osd_item.meth.draw = osd_draw_cast(osd_speed_cam_draw);
    18761971
    1877   osd_set_std_attr(attrs, &this->item, 2);
     1972  osd_set_std_attr(attrs, &opc->osd_item, 2);
    18781973  attr = attr_search(attrs, NULL, attr_width);
    18791974  this->width=attr ? attr->u.num : 2;
    18801975  attr = attr_search(attrs, NULL, attr_idle_color);
     
    18951990    this->announce_on = 1;    //announce by default
    18961991  }
    18971992
    1898   navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_cam_init), attr_graphics_ready, this));
    1899   return (struct osd_priv *) this;
     1993  navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_cam_init), attr_graphics_ready, opc));
     1994  return (struct osd_priv *) opc;
    19001995}
    19011996
    19021997struct osd_speed_warner {
    1903         struct osd_item item;
    19041998        struct graphics_gc *red;
    19051999        struct graphics_gc *green;
    19062000        struct graphics_gc *grey;
     
    19192013};
    19202014
    19212015static void
    1922 osd_speed_warner_draw(struct osd_speed_warner *this, struct navit *navit, struct vehicle *v)
     2016osd_speed_warner_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle *v)
    19232017{
     2018    struct osd_speed_warner *this = (struct osd_speed_warner *)opc->data;
     2019
    19242020    struct point p,bbox[4];
    19252021    char text[16]="";
    19262022
     
    19292025    struct graphics_image *img = this->img_off;
    19302026
    19312027
    1932     osd_std_draw(&this->item);
    1933     p.x=this->item.w/2-this->d/4;
    1934     p.y=this->item.h/2-this->d/4;
    1935     p.x=this->item.w/2;
    1936     p.y=this->item.h/2;
     2028    osd_std_draw(&opc->osd_item);
     2029    p.x=opc->osd_item.w/2-this->d/4;
     2030    p.y=opc->osd_item.h/2-this->d/4;
     2031    p.x=opc->osd_item.w/2;
     2032    p.y=opc->osd_item.h/2;
    19372033
    19382034    if (navit) {
    19392035        tracking = navit_get_tracking(navit);
     
    20052101    }
    20062102    if(this->img_active && this->img_passive && this->img_off) {
    20072103      struct point p;
    2008       p.x=(this->item.w-img->width)/2;
    2009       p.y=(this->item.h-img->height)/2;
    2010       graphics_draw_image(this->item.gr, this->item.graphic_bg, &p, img);
     2104      p.x=(opc->osd_item.w-img->width)/2;
     2105      p.y=(opc->osd_item.h-img->height)/2;
     2106      graphics_draw_image(opc->osd_item.gr, opc->osd_item.graphic_bg, &p, img);
    20112107    }
    20122108    else if(0==this->bTextOnly) {
    2013       graphics_draw_circle(this->item.gr, osd_color, &p, this->d-this->width*2 );
     2109      graphics_draw_circle(opc->osd_item.gr, osd_color, &p, this->d-this->width*2 );
    20142110    }
    2015         graphics_get_text_bbox(this->item.gr, this->item.font, text, 0x10000, 0, bbox, 0);
    2016         p.x=(this->item.w-bbox[2].x)/2;
    2017         p.y=(this->item.h+bbox[2].y)/2-bbox[2].y;
    2018         graphics_draw_text(this->item.gr, osd_color, NULL, this->item.font, text, &p, 0x10000, 0);
    2019         graphics_draw_mode(this->item.gr, draw_mode_end);
     2111        graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, text, 0x10000, 0, bbox, 0);
     2112        p.x=(opc->osd_item.w-bbox[2].x)/2;
     2113        p.y=(opc->osd_item.h+bbox[2].y)/2-bbox[2].y;
     2114        graphics_draw_text(opc->osd_item.gr, osd_color, NULL, opc->osd_item.font, text, &p, 0x10000, 0);
     2115        graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    20202116}
    20212117
    20222118static void
    2023 osd_speed_warner_init(struct osd_speed_warner *this, struct navit *nav)
     2119osd_speed_warner_init(struct osd_priv_common *opc, struct navit *nav)
    20242120{
     2121        struct osd_speed_warner *this = (struct osd_speed_warner *)opc->data;
     2122
    20252123        struct color white_color={0xffff,0xffff,0xffff,0x0000};
    20262124        struct color red_color={0xffff,0,0,0xffff};
    20272125        struct color green_color={0,0xffff,0,0xffff};
    20282126        struct color grey_color={0x8888,0x8888,0x8888,0x8888};
    20292127        struct color black_color={0x1111,0x1111,0x1111,0x9999};
    20302128
    2031         osd_set_std_graphic(nav, &this->item, (struct osd_priv *)this);
    2032         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_warner_draw), attr_position_coord_geo, this));
     2129        osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
     2130        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_warner_draw), attr_position_coord_geo, opc));
    20332131
    20342132        if(this->label_str && !strncmp("images:",this->label_str,7)) {
    20352133          char *tok1=NULL, *tok2=NULL, *tok3=NULL;
     
    20452143            tok1 = graphics_icon_path(tok1);
    20462144            tok2 = graphics_icon_path(tok2);
    20472145            tok3 = graphics_icon_path(tok3);
    2048             this->img_active  = graphics_image_new(this->item.gr, tok1);
    2049             this->img_passive = graphics_image_new(this->item.gr, tok2);
    2050             this->img_off     = graphics_image_new(this->item.gr, tok3);
     2146            this->img_active  = graphics_image_new(opc->osd_item.gr, tok1);
     2147            this->img_passive = graphics_image_new(opc->osd_item.gr, tok2);
     2148            this->img_off     = graphics_image_new(opc->osd_item.gr, tok3);
    20512149            g_free(tok1);   
    20522150            g_free(tok2);   
    20532151            g_free(tok3);   
     
    20572155        g_free(this->label_str);
    20582156        this->label_str = NULL;
    20592157
    2060         this->white=graphics_gc_new(this->item.gr);
     2158        this->white=graphics_gc_new(opc->osd_item.gr);
    20612159        graphics_gc_set_foreground(this->white, &white_color);
    20622160
    20632161        graphics_gc_set_linewidth(this->white, this->d/2-2 /*-this->width*/ );
    20642162
    2065         this->red=graphics_gc_new(this->item.gr);
     2163        this->red=graphics_gc_new(opc->osd_item.gr);
    20662164        graphics_gc_set_foreground(this->red, &red_color);
    20672165        graphics_gc_set_linewidth(this->red, this->width);
    20682166
    2069         this->green=graphics_gc_new(this->item.gr);
     2167        this->green=graphics_gc_new(opc->osd_item.gr);
    20702168        graphics_gc_set_foreground(this->green, &green_color);
    20712169        graphics_gc_set_linewidth(this->green, this->width-2);
    20722170
    2073         this->grey=graphics_gc_new(this->item.gr);
     2171        this->grey=graphics_gc_new(opc->osd_item.gr);
    20742172        graphics_gc_set_foreground(this->grey, &grey_color);
    20752173        graphics_gc_set_linewidth(this->grey, this->width);
    20762174
    2077         this->black=graphics_gc_new(this->item.gr);
     2175        this->black=graphics_gc_new(opc->osd_item.gr);
    20782176        graphics_gc_set_foreground(this->black, &black_color);
    20792177        graphics_gc_set_linewidth(this->black, this->width);
    20802178
    2081         osd_speed_warner_draw(this, nav, NULL);
     2179        osd_speed_warner_draw(opc, nav, NULL);
    20822180}
    20832181
    20842182static struct osd_priv *
    20852183osd_speed_warner_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs)
    20862184{
    20872185        struct osd_speed_warner *this=g_new0(struct osd_speed_warner, 1);
     2186        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     2187        opc->data = (void*)this;
     2188
    20882189        struct attr *attr;
    2089         this->item.p.x=-80;
    2090         this->item.p.y=20;
    2091         this->item.w=60;
    2092         this->item.navit = nav;
    2093         this->item.h=60;
     2190        opc->osd_item.p.x=-80;
     2191        opc->osd_item.p.y=20;
     2192        opc->osd_item.w=60;
     2193        opc->osd_item.navit = nav;
     2194        opc->osd_item.h=60;
    20942195        this->active=-1;
    2095         this->item.meth.draw = osd_draw_cast(osd_speed_warner_draw);
     2196        opc->osd_item.meth.draw = osd_draw_cast(osd_speed_warner_draw);
    20962197
    20972198        attr = attr_search(attrs, NULL, attr_speed_exceed_limit_offset);
    20982199        if (attr) {
     
    21202221                this->announce_on = attr->u.num;
    21212222        else
    21222223                this->announce_on = 1;    //announce by default
    2123         osd_set_std_attr(attrs, &this->item, 2);
    2124         this->d=this->item.w;
    2125         if (this->item.h < this->d)
    2126                 this->d=this->item.h;
     2224        osd_set_std_attr(attrs, &opc->osd_item, 2);
     2225        this->d=opc->osd_item.w;
     2226        if (opc->osd_item.h < this->d)
     2227                this->d=opc->osd_item.h;
    21272228        this->width=this->d/10;
    2128         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_warner_init), attr_graphics_ready, this));
    2129         return (struct osd_priv *) this;
     2229        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_speed_warner_init), attr_graphics_ready, opc));
     2230        return (struct osd_priv *) opc;
    21302231}
    21312232
    21322233struct osd_text_item {
     
    21422243};
    21432244
    21442245struct osd_text {
    2145         struct osd_item osd_item;
    21462246        int active;
    21472247        char *text;
    21482248        int align;
     
    21752275        case attr_position_direction:
    21762276                return format_float_0(*attr->u.numd);
    21772277        case attr_position_magnetic_direction:
    2178                 return g_strdup_printf("%d",attr->u.num);
     2278                return g_strdup_printf("%ld",attr->u.num);
    21792279        case attr_position_coord_geo:
    21802280                if ((!format) || (!strcmp(format,"pos_degminsec")))
    21812281                {
     
    23512451}
    23522452
    23532453static void
    2354 osd_text_draw(struct osd_text *this, struct navit *navit, struct vehicle *v)
     2454osd_text_draw(struct osd_priv_common *opc, struct navit *navit, struct vehicle *v)
    23552455{
     2456        struct osd_text *this = (struct osd_text *)opc->data;
     2457
    23562458        struct point p, p2[4];
    23572459        char *str,*last,*next,*value,*absbegin;
    23582460        int do_draw = 0;
     
    23652467        struct item *item;
    23662468        struct osd_text_item *oti;
    23672469        int offset,lines;
    2368         int height=this->osd_item.font_size*13/256;
     2470        int height=opc->osd_item.font_size*13/256;
    23692471        int yspacing=height/2;
    23702472        int xspacing=height/4;
    23712473        int imperial=0;
     
    25032605
    25042606        absbegin=str;
    25052607        if (do_draw) {
    2506                 osd_std_draw(&this->osd_item);
     2608                osd_std_draw(&opc->osd_item);
    25072609        }
    25082610        if (do_draw && str) {
    25092611                lines=0;
     
    25292631                        p.y=0;
    25302632                        break;
    25312633                case 2:
    2532                         p.y=(this->osd_item.h-lines*(height+yspacing)-yspacing);
     2634                        p.y=(opc->osd_item.h-lines*(height+yspacing)-yspacing);
    25332635                        break;
    25342636                case 16: // Grow from top to bottom
    25352637                        p.y = 0;
    25362638                        if (lines != 0) {
    2537                                 this->osd_item.h = (lines-1) * (height+yspacing) + height;
     2639                                opc->osd_item.h = (lines-1) * (height+yspacing) + height;
    25382640                        } else {
    2539                                 this->osd_item.h = 0;
     2641                                opc->osd_item.h = 0;
    25402642                        }
    25412643
    25422644                        if (do_draw) {
    2543                                 osd_std_resize(&this->osd_item);
     2645                                osd_std_resize(&opc->osd_item);
    25442646                        }
    25452647                default:
    2546                         p.y=(this->osd_item.h-lines*(height+yspacing)-yspacing)/2;
     2648                        p.y=(opc->osd_item.h-lines*(height+yspacing)-yspacing)/2;
    25472649                }
    25482650
    25492651                while (str) {
     
    25522654                                *next='\0';
    25532655                                next+=2;
    25542656                        }
    2555                         graphics_get_text_bbox(this->osd_item.gr,
    2556                                                this->osd_item.font,
     2657                        graphics_get_text_bbox(opc->osd_item.gr,
     2658                                               opc->osd_item.font,
    25572659                                               str, 0x10000,
    25582660                                               0x0, p2, 0);
    25592661                        switch (this->align & 12) {
     
    25612663                                p.x=xspacing;
    25622664                                break;
    25632665                        case 8:
    2564                                 p.x=this->osd_item.w-(p2[2].x-p2[0].x)-xspacing;
     2666                                p.x=opc->osd_item.w-(p2[2].x-p2[0].x)-xspacing;
    25652667                                break;
    25662668                        default:
    2567                                 p.x = ((p2[0].x - p2[2].x) / 2) + (this->osd_item.w / 2);
     2669                                p.x = ((p2[0].x - p2[2].x) / 2) + (opc->osd_item.w / 2);
    25682670                        }
    25692671                        p.y += height+yspacing;
    2570                         graphics_draw_text(this->osd_item.gr,
    2571                                            this->osd_item.graphic_fg_text,
    2572                                            NULL, this->osd_item.font,
     2672                        graphics_draw_text(opc->osd_item.gr,
     2673                                           opc->osd_item.graphic_fg_text,
     2674                                           NULL, opc->osd_item.font,
    25732675                                           str, &p, 0x10000,
    25742676                                           0);
    25752677                        str=next;
    25762678                }
    25772679        }
    25782680        if(do_draw) {
    2579                 graphics_draw_mode(this->osd_item.gr, draw_mode_end);
     2681                graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    25802682        }
    25812683        g_free(absbegin);
    25822684
     
    26152717 * @returns nothing
    26162718 */
    26172719static void
    2618 osd_text_prepare(struct osd_text *this, struct navit *nav)
     2720osd_text_prepare(struct osd_priv_common *opc, struct navit *nav)
    26192721{
     2722        struct osd_text *this = (struct osd_text *)opc->data;
     2723
    26202724        char *absbegin,*str,*start,*end,*key,*subkey,*index;
    26212725        struct osd_text_item *oti;
    26222726
     
    27002804}
    27012805
    27022806static void
    2703 osd_text_init(struct osd_text *this, struct navit *nav)
     2807osd_text_init(struct osd_priv_common *opc, struct navit *nav)
    27042808{
     2809        osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
     2810        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_std_click), attr_button, &opc->osd_item));
     2811        osd_text_prepare(opc,nav);
     2812        osd_text_draw(opc, nav, NULL);
    27052813
    2706         osd_set_std_graphic(nav, &this->osd_item, (struct osd_priv *)this);
    2707         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_std_click), attr_button, &this->osd_item));
    2708         osd_text_prepare(this,nav);
    2709         osd_text_draw(this, nav, NULL);
    2710 
    27112814}
    27122815
    27132816static struct osd_priv *
     
    27152818            struct attr **attrs)
    27162819{
    27172820        struct osd_text *this = g_new0(struct osd_text, 1);
     2821        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     2822        opc->data = (void*)this;
     2823
    27182824        struct attr *attr;
    27192825
    2720         this->osd_item.p.x = -80;
    2721         this->osd_item.p.y = 20;
    2722         this->osd_item.w = 60;
    2723         this->osd_item.h = 20;
    2724         this->osd_item.navit = nav;
    2725         this->osd_item.font_size = 200;
    2726         this->osd_item.meth.draw = osd_draw_cast(osd_text_draw);
    2727         osd_set_std_attr(attrs, &this->osd_item, 2);
     2826        opc->osd_item.p.x = -80;
     2827        opc->osd_item.p.y = 20;
     2828        opc->osd_item.w = 60;
     2829        opc->osd_item.h = 20;
     2830        opc->osd_item.navit = nav;
     2831        opc->osd_item.font_size = 200;
     2832        opc->osd_item.meth.draw = osd_draw_cast(osd_text_draw);
     2833        osd_set_std_attr(attrs, &opc->osd_item, 2);
    27282834
    27292835        this->active = -1;
    27302836        this->last = NULL;
     
    27382844        if (attr)
    27392845                this->align=attr->u.num;
    27402846
    2741         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_text_init), attr_graphics_ready, this));
    2742         return (struct osd_priv *) this;
     2847        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_text_init), attr_graphics_ready, opc));
     2848        return (struct osd_priv *) opc;
    27432849}
    27442850
    27452851struct gps_status {
    2746         struct osd_item osd_item;
    27472852        char *icon_src;
    27482853        int icon_h, icon_w, active;
    27492854        int strength;
    27502855};
    27512856
    27522857static void
    2753 osd_gps_status_draw(struct gps_status *this, struct navit *navit,
     2858osd_gps_status_draw(struct osd_priv_common *opc, struct navit *navit,
    27542859                       struct vehicle *v)
    27552860{
     2861        struct gps_status *this = (struct gps_status *)opc->data;
     2862
    27562863        struct point p;
    27572864        int do_draw = 0;
    27582865        struct graphics_image *gr_image;
     
    27922899                do_draw=1;
    27932900        }
    27942901        if (do_draw) {
    2795                 osd_std_draw(&this->osd_item);
     2902                osd_std_draw(&opc->osd_item);
    27962903                if (this->active) {
    27972904                        image = g_strdup_printf(this->icon_src, strength);
    2798                         gr_image = graphics_image_new_scaled(this->osd_item.gr, image, this->icon_w, this->icon_h);
     2905                        gr_image = graphics_image_new_scaled(opc->osd_item.gr, image, this->icon_w, this->icon_h);
    27992906                        if (gr_image) {
    2800                                 p.x = (this->osd_item.w - gr_image->width) / 2;
    2801                                 p.y = (this->osd_item.h - gr_image->height) / 2;
    2802                                 graphics_draw_image(this->osd_item.gr, this->osd_item.  graphic_fg_white, &p, gr_image);
    2803                                 graphics_image_free(this->osd_item.gr, gr_image);
     2907                                p.x = (opc->osd_item.w - gr_image->width) / 2;
     2908                                p.y = (opc->osd_item.h - gr_image->height) / 2;
     2909                                graphics_draw_image(opc->osd_item.gr, opc->osd_item.  graphic_fg_white, &p, gr_image);
     2910                                graphics_image_free(opc->osd_item.gr, gr_image);
    28042911                        }
    28052912                        g_free(image);
    28062913                }
    2807                 graphics_draw_mode(this->osd_item.gr, draw_mode_end);
     2914                graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    28082915        }
    28092916}
    28102917
    28112918static void
    2812 osd_gps_status_init(struct gps_status *this, struct navit *nav)
     2919osd_gps_status_init(struct osd_priv_common *opc, struct navit *nav)
    28132920{
    2814         osd_set_std_graphic(nav, &this->osd_item, (struct osd_priv *)this);
    2815         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_draw), attr_position_coord_geo, this));
    2816         osd_gps_status_draw(this, nav, NULL);
     2921        osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
     2922        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_draw), attr_position_coord_geo, opc));
     2923        osd_gps_status_draw(opc, nav, NULL);
    28172924}
    28182925
    28192926static struct osd_priv *
     
    28212928                      struct attr **attrs)
    28222929{
    28232930        struct gps_status *this = g_new0(struct gps_status, 1);
     2931        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     2932        opc->data = (void*)this;
     2933
    28242934        struct attr *attr;
    28252935
    2826         this->osd_item.p.x = 20;
    2827         this->osd_item.p.y = -80;
    2828         this->osd_item.w = 60;
    2829         this->osd_item.navit = nav;
    2830         this->osd_item.h = 40;
    2831         this->osd_item.font_size = 200;
    2832         this->osd_item.meth.draw = osd_draw_cast(osd_gps_status_draw);
    2833         osd_set_std_attr(attrs, &this->osd_item, 0);
     2936        opc->osd_item.p.x = 20;
     2937        opc->osd_item.p.y = -80;
     2938        opc->osd_item.w = 60;
     2939        opc->osd_item.navit = nav;
     2940        opc->osd_item.h = 40;
     2941        opc->osd_item.font_size = 200;
     2942        opc->osd_item.meth.draw = osd_draw_cast(osd_gps_status_draw);
     2943        osd_set_std_attr(attrs, &opc->osd_item, 0);
    28342944
    28352945        this->icon_w = -1;
    28362946        this->icon_h = -1;
     
    28562966        } else
    28572967                this->icon_src = graphics_icon_path("gui_strength_%d_32_32.png");
    28582968
    2859         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_init), attr_graphics_ready, this));
    2860         return (struct osd_priv *) this;
     2969        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_gps_status_init), attr_graphics_ready, opc));
     2970        return (struct osd_priv *) opc;
    28612971}
    28622972
    28632973
    28642974struct volume {
    2865         struct osd_item osd_item;
    28662975        char *icon_src;
    28672976        int icon_h, icon_w, active;
    28682977        int strength;
     
    28702979};
    28712980
    28722981static void
    2873 osd_volume_draw(struct volume *this, struct navit *navit)
     2982osd_volume_draw(struct osd_priv_common *opc, struct navit *navit)
    28742983{
     2984        struct volume *this = (struct volume *)opc->data;
     2985
    28752986        struct point p;
    28762987        struct graphics_image *gr_image;
    28772988        char *image;
    28782989
    2879         osd_std_draw(&this->osd_item);
     2990        osd_std_draw(&opc->osd_item);
    28802991        if (this->active) {
    28812992                image = g_strdup_printf(this->icon_src, this->strength);
    2882                 gr_image = graphics_image_new_scaled(this->osd_item.gr, image, this->icon_w, this->icon_h);
     2993                gr_image = graphics_image_new_scaled(opc->osd_item.gr, image, this->icon_w, this->icon_h);
    28832994                if (gr_image) {
    2884                         p.x = (this->osd_item.w - gr_image->width) / 2;
    2885                         p.y = (this->osd_item.h - gr_image->height) / 2;
    2886                         graphics_draw_image(this->osd_item.gr, this->osd_item.  graphic_fg_white, &p, gr_image);
    2887                         graphics_image_free(this->osd_item.gr, gr_image);
     2995                        p.x = (opc->osd_item.w - gr_image->width) / 2;
     2996                        p.y = (opc->osd_item.h - gr_image->height) / 2;
     2997                        graphics_draw_image(opc->osd_item.gr, opc->osd_item.  graphic_fg_white, &p, gr_image);
     2998                        graphics_image_free(opc->osd_item.gr, gr_image);
    28882999                }
    28893000                g_free(image);
    28903001        }
    2891         graphics_draw_mode(this->osd_item.gr, draw_mode_end);
     3002        graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    28923003}
    28933004
    28943005static void
    2895 osd_volume_click(struct volume *this, struct navit *nav, int pressed, int button, struct point *p)
     3006osd_volume_click(struct osd_priv_common *opc, struct navit *nav, int pressed, int button, struct point *p)
    28963007{
    2897         struct point bp = this->osd_item.p;
     3008        struct volume *this = (struct volume *)opc->data;
     3009
     3010        struct point bp = opc->osd_item.p;
    28983011        osd_wrap_point(&bp, nav);
    2899         if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + this->osd_item.w || p->y > bp.y + this->osd_item.h) && !this->osd_item.pressed)
     3012        if ((p->x < bp.x || p->y < bp.y || p->x > bp.x + opc->osd_item.w || p->y > bp.y + opc->osd_item.h) && !opc->osd_item.pressed)
    29003013                return;
    29013014        navit_ignore_button(nav);
    29023015        if (pressed) {
    2903                 if (p->y - bp.y < this->osd_item.h/2)
     3016                if (p->y - bp.y < opc->osd_item.h/2)
    29043017                        this->strength++;
    29053018                else
    29063019                        this->strength--;
     
    29083021                        this->strength=0;
    29093022                if (this->strength > 5)
    29103023                        this->strength=5;
    2911                 osd_volume_draw(this, nav);
     3024                osd_volume_draw(opc, nav);
    29123025        }
    29133026}
    29143027static void
    2915 osd_volume_init(struct volume *this, struct navit *nav)
     3028osd_volume_init(struct osd_priv_common *opc, struct navit *nav)
    29163029{
    2917         osd_set_std_graphic(nav, &this->osd_item, (struct osd_priv *)this);
    2918         navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_volume_click), attr_button, this));
    2919         osd_volume_draw(this, nav);
     3030        struct volume *this = (struct volume *)opc->data;
     3031
     3032        osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
     3033        navit_add_callback(nav, this->click_cb = callback_new_attr_1(callback_cast (osd_volume_click), attr_button, opc));
     3034        osd_volume_draw(opc, nav);
    29203035}
    29213036
    29223037static struct osd_priv *
     
    29243039                      struct attr **attrs)
    29253040{
    29263041        struct volume *this = g_new0(struct volume, 1);
     3042        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     3043        opc->data = (void*)this;
     3044
    29273045        struct attr *attr;
    29283046
    2929         this->osd_item.p.x = 20;
    2930         this->osd_item.p.y = -80;
    2931         this->osd_item.w = 60;
    2932         this->osd_item.navit = nav;
    2933         this->osd_item.h = 40;
    2934         this->osd_item.font_size = 200;
    2935         this->osd_item.meth.draw = osd_draw_cast(osd_volume_draw);
    2936         osd_set_std_attr(attrs, &this->osd_item, 0);
     3047        opc->osd_item.p.x = 20;
     3048        opc->osd_item.p.y = -80;
     3049        opc->osd_item.w = 60;
     3050        opc->osd_item.navit = nav;
     3051        opc->osd_item.h = 40;
     3052        opc->osd_item.font_size = 200;
     3053        opc->osd_item.meth.draw = osd_draw_cast(osd_volume_draw);
     3054        osd_set_std_attr(attrs, &opc->osd_item, 0);
    29373055
    29383056        this->icon_w = -1;
    29393057        this->icon_h = -1;
     
    29593077        } else
    29603078                this->icon_src = graphics_icon_path("gui_strength_%d_32_32.png");
    29613079
    2962         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_volume_init), attr_graphics_ready, this));
    2963         return (struct osd_priv *) this;
     3080        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_volume_init), attr_graphics_ready, opc));
     3081        return (struct osd_priv *) opc;
    29643082}
    29653083
    29663084struct osd_scale {
    29673085        int use_overlay;
    2968         struct osd_item item;
    29693086        struct callback *draw_cb,*navit_init_cb;
    29703087        struct graphics_gc *black;
    29713088};
    29723089
    29733090static void
    2974 osd_scale_draw(struct osd_scale *this, struct navit *nav)
     3091osd_scale_draw(struct osd_priv_common *opc, struct navit *nav)
    29753092{
     3093        struct osd_scale *this = (struct osd_scale *)opc->data;
     3094
    29763095        struct point bp,bp1,bp2;
    29773096        struct point p[10],bbox[4];
    29783097        struct coord c[2];
     
    29803099        int len;
    29813100        double dist,exp,base,man;
    29823101        char *text;
    2983         int w=this->item.w*9/10;
    2984         int o=(this->item.w-w)/2;
     3102        int w=opc->osd_item.w*9/10;
     3103        int o=(opc->osd_item.w-w)/2;
    29853104        int imperial=0;
    29863105
    29873106        if (navit_get_attr(nav, attr_imperial, &imperial_attr, NULL))
     
    29903109        if (!navit_get_attr(nav, attr_transformation, &transformation, NULL))
    29913110                return;
    29923111        if (this->use_overlay) {
    2993                 graphics_draw_mode(this->item.gr, draw_mode_begin);
     3112                graphics_draw_mode(opc->osd_item.gr, draw_mode_begin);
    29943113                bp.x=0;
    29953114                bp.y=0;
    2996                 graphics_draw_rectangle(this->item.gr, this->item.graphic_bg, &bp, this->item.w, this->item.h);
     3115                graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_bg, &bp, opc->osd_item.w, opc->osd_item.h);
    29973116        } else {
    2998                 bp=this->item.p;
     3117                bp=opc->osd_item.p;
    29993118                osd_wrap_point(&bp, nav);
    30003119        }
    30013120        bp1=bp;
    3002         bp1.y+=this->item.h/2;
     3121        bp1.y+=opc->osd_item.h/2;
    30033122        bp1.x+=o;
    30043123        bp2=bp1;
    30053124        bp2.x+=w;
     
    30173136                man=2;
    30183137        else
    30193138                man=1;
    3020         len=this->item.w-man*base/dist*w;
     3139        len=opc->osd_item.w-man*base/dist*w;
    30213140        p[0].x+=len/2;
    30223141        p[1].x-=len/2;
    30233142        p[2]=p[0];
    30243143        p[3]=p[0];
    3025         p[2].y-=this->item.h/10;
    3026         p[3].y+=this->item.h/10;
     3144        p[2].y-=opc->osd_item.h/10;
     3145        p[3].y+=opc->osd_item.h/10;
    30273146        p[4]=p[1];
    30283147        p[5]=p[1];
    3029         p[4].y-=this->item.h/10;
    3030         p[5].y+=this->item.h/10;
     3148        p[4].y-=opc->osd_item.h/10;
     3149        p[5].y+=opc->osd_item.h/10;
    30313150        p[6]=p[2];
    30323151        p[6].x-=2;
    30333152        p[6].y-=2;
     
    30363155        p[8]=p[4];
    30373156        p[8].x-=2;
    30383157        p[8].y-=2;
    3039         graphics_draw_rectangle(this->item.gr, this->item.graphic_fg_white, p+6, 4,this->item.h/5+4);
    3040         graphics_draw_rectangle(this->item.gr, this->item.graphic_fg_white, p+7, p[1].x-p[0].x, 4);
    3041         graphics_draw_rectangle(this->item.gr, this->item.graphic_fg_white, p+8, 4,this->item.h/5+4);
    3042         graphics_draw_lines(this->item.gr, this->black, p, 2);
    3043         graphics_draw_lines(this->item.gr, this->black, p+2, 2);
    3044         graphics_draw_lines(this->item.gr, this->black, p+4, 2);
     3158        graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_fg_white, p+6, 4,opc->osd_item.h/5+4);
     3159        graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_fg_white, p+7, p[1].x-p[0].x, 4);
     3160        graphics_draw_rectangle(opc->osd_item.gr, opc->osd_item.graphic_fg_white, p+8, 4,opc->osd_item.h/5+4);
     3161        graphics_draw_lines(opc->osd_item.gr, this->black, p, 2);
     3162        graphics_draw_lines(opc->osd_item.gr, this->black, p+2, 2);
     3163        graphics_draw_lines(opc->osd_item.gr, this->black, p+4, 2);
    30453164        text=format_distance(man*base, "", imperial);
    3046         graphics_get_text_bbox(this->item.gr, this->item.font, text, 0x10000, 0, bbox, 0);
    3047         p[0].x=(this->item.w-bbox[2].x)/2+bp.x;
    3048         p[0].y=bp.y+this->item.h-this->item.h/10;
    3049         graphics_draw_text(this->item.gr, this->black, this->item.graphic_fg_white, this->item.font, text, &p[0], 0x10000, 0);
     3165        graphics_get_text_bbox(opc->osd_item.gr, opc->osd_item.font, text, 0x10000, 0, bbox, 0);
     3166        p[0].x=(opc->osd_item.w-bbox[2].x)/2+bp.x;
     3167        p[0].y=bp.y+opc->osd_item.h-opc->osd_item.h/10;
     3168        graphics_draw_text(opc->osd_item.gr, this->black, opc->osd_item.graphic_fg_white, opc->osd_item.font, text, &p[0], 0x10000, 0);
    30503169        g_free(text);
    30513170        if (this->use_overlay)
    3052                 graphics_draw_mode(this->item.gr, draw_mode_end);
     3171                graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    30533172}
    30543173
    30553174static void
    3056 osd_scale_init(struct osd_scale *this, struct navit *nav)
     3175osd_scale_init(struct osd_priv_common *opc, struct navit *nav)
    30573176{
     3177        struct osd_scale *this = (struct osd_scale *)opc->data;
     3178
    30583179        struct color color_white={0xffff,0xffff,0xffff,0x0000};
    30593180        struct color color_black={0x0000,0x0000,0x0000,0x0000};
    30603181        struct graphics *gra = navit_get_graphics(nav);
    30613182        dbg(1, "enter\n");
    30623183        if (this->use_overlay) {
    3063                 osd_set_std_graphic(nav, &this->item, (struct osd_priv *)this);
     3184                osd_set_std_graphic(nav, &opc->osd_item, (struct osd_priv *)opc);
    30643185        } else {
    3065                 this->item.configured=1;
    3066                 this->item.gr=gra;
    3067                 this->item.font = graphics_font_new(this->item.gr, this->item.font_size, 1);
    3068                 this->item.graphic_fg_white=graphics_gc_new(this->item.gr);
    3069                 this->item.color_white=color_white;
    3070                 graphics_gc_set_foreground(this->item.graphic_fg_white, &this->item.color_white);
     3186                opc->osd_item.configured=1;
     3187                opc->osd_item.gr=gra;
     3188                opc->osd_item.font = graphics_font_new(opc->osd_item.gr, opc->osd_item.font_size, 1);
     3189                opc->osd_item.graphic_fg_white=graphics_gc_new(opc->osd_item.gr);
     3190                opc->osd_item.color_white=color_white;
     3191                graphics_gc_set_foreground(opc->osd_item.graphic_fg_white, &opc->osd_item.color_white);
    30713192        }
    3072         this->black=graphics_gc_new(this->item.gr);
     3193        this->black=graphics_gc_new(opc->osd_item.gr);
    30733194        graphics_gc_set_foreground(this->black, &color_black);
    3074         graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_scale_draw), attr_postdraw, this, nav));
     3195        graphics_add_callback(gra, this->draw_cb=callback_new_attr_2(callback_cast(osd_scale_draw), attr_postdraw, opc, nav));
    30753196        if (navit_get_ready(nav) == 3)
    3076                 osd_scale_draw(this, nav);
     3197                osd_scale_draw(opc, nav);
    30773198}
    30783199
    30793200static struct osd_priv *
     
    30813202               struct attr **attrs)
    30823203{
    30833204        struct osd_scale *this = g_new0(struct osd_scale, 1);
     3205        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     3206        opc->data = (void*)this;
     3207
    30843208        struct attr *attr;
    30853209
    3086         this->item.navit = nav;
    3087         this->item.meth.draw = osd_draw_cast(osd_scale_draw);
     3210        opc->osd_item.navit = nav;
     3211        opc->osd_item.meth.draw = osd_draw_cast(osd_scale_draw);
    30883212
    3089         osd_set_std_attr(attrs, &this->item, 3);
     3213        osd_set_std_attr(attrs, &opc->osd_item, 3);
    30903214
    30913215        attr=attr_search(attrs, NULL, attr_use_overlay);
    30923216        if (attr)
    30933217                this->use_overlay=attr->u.num;
    30943218
    3095         navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_scale_init), attr_graphics_ready, this));
     3219        navit_add_callback(nav, this->navit_init_cb = callback_new_attr_1(callback_cast (osd_scale_init), attr_graphics_ready, opc));
    30963220
    3097         return (struct osd_priv *) this;
     3221        return (struct osd_priv *) opc;
    30983222}
    30993223
    31003224struct auxmap {
    3101         struct osd_item osd_item;
    31023225        struct displaylist *displaylist;
    31033226        struct transformation *ntrans;
    31043227        struct transformation *trans;
     
    31093232};
    31103233
    31113234static void
    3112 osd_auxmap_draw(struct auxmap *this)
     3235osd_auxmap_draw(struct osd_priv_common *opc)
    31133236{
     3237        struct auxmap *this = (struct auxmap *)opc->data;
     3238
    31143239        int d=10;
    31153240        struct point p;
    31163241        struct attr mapset;
    31173242
    3118         if (!this->osd_item.configured)
     3243        if (!opc->osd_item.configured)
    31193244                return;
    31203245        if (!navit_get_attr(this->nav, attr_mapset, &mapset, NULL) || !mapset.u.mapset)
    31213246                return;
    3122         p.x=this->osd_item.w/2;
    3123         p.y=this->osd_item.h/2;
     3247        p.x=opc->osd_item.w/2;
     3248        p.y=opc->osd_item.h/2;
    31243249        transform_set_center(this->trans, transform_get_center(this->ntrans));
    31253250        transform_set_scale(this->trans, 64);
    31263251        transform_set_yaw(this->trans, transform_get_yaw(this->ntrans));
    31273252        transform_setup_source_rect(this->trans);
    31283253        transform_set_projection(this->trans, transform_get_projection(this->ntrans));
    31293254#if 0
    3130         graphics_displaylist_draw(this->osd_item.gr, this->displaylist, this->trans, this->layout, 4);
     3255        graphics_displaylist_draw(opc->osd_item.gr, this->displaylist, this->trans, this->layout, 4);
    31313256#endif
    3132         graphics_draw(this->osd_item.gr, this->displaylist, mapset.u.mapset, this->trans, this->layout, 0, NULL, 1);
    3133         graphics_draw_circle(this->osd_item.gr, this->red, &p, d);
    3134         graphics_draw_mode(this->osd_item.gr, draw_mode_end);
     3257        graphics_draw(opc->osd_item.gr, this->displaylist, mapset.u.mapset, this->trans, this->layout, 0, NULL, 1);
     3258        graphics_draw_circle(opc->osd_item.gr, this->red, &p, d);
     3259        graphics_draw_mode(opc->osd_item.gr, draw_mode_end);
    31353260
    31363261}
    31373262
    31383263static void
    3139 osd_auxmap_init(struct auxmap *this, struct navit *nav)
     3264osd_auxmap_init(struct osd_priv_common *opc, struct navit *nav)
    31403265{
     3266        struct auxmap *this = (struct auxmap *)opc->data;
     3267
    31413268        struct graphics *gra;
    31423269        struct attr attr;
    31433270        struct map_selection sel;
     
    31573284        if (! navit_get_attr(nav, attr_layout, &attr, NULL))
    31583285                return;
    31593286        this->layout=attr.u.layout;
    3160         osd_set_std_graphic(nav, &this->osd_item, NULL);
    3161         graphics_init(this->osd_item.gr);
     3287        osd_set_std_graphic(nav, &opc->osd_item, NULL);
     3288        graphics_init(opc->osd_item.gr);
    31623289        this->red=graphics_gc_new(gra);
    31633290        graphics_gc_set_foreground(this->red,&red);
    31643291        graphics_gc_set_linewidth(this->red,3);
    31653292        this->trans=transform_new();
    31663293        memset(&sel, 0, sizeof(sel));
    3167         sel.u.p_rect.rl.x=this->osd_item.w;
    3168         sel.u.p_rect.rl.y=this->osd_item.h;
     3294        sel.u.p_rect.rl.x=opc->osd_item.w;
     3295        sel.u.p_rect.rl.y=opc->osd_item.h;
    31693296        transform_set_screen_selection(this->trans, &sel);
    3170         graphics_set_rect(this->osd_item.gr, &sel.u.p_rect);
     3297        graphics_set_rect(opc->osd_item.gr, &sel.u.p_rect);
    31713298#if 0
    3172         osd_auxmap_draw(this, nav);
     3299        osd_auxmap_draw(opc, nav);
    31733300#endif
    31743301}
    31753302
     
    31773304osd_auxmap_new(struct navit *nav, struct osd_methods *meth, struct attr **attrs)
    31783305{
    31793306        struct auxmap *this = g_new0(struct auxmap, 1);
     3307        struct osd_priv_common *opc = g_new0(struct osd_priv_common,1);
     3308        opc->data = (void*)this;
    31803309
    3181         this->osd_item.p.x = 20;
    3182         this->osd_item.p.y = -80;
    3183         this->osd_item.w = 60;
    3184         this->osd_item.h = 40;
    3185         this->osd_item.font_size = 200;
    3186         osd_set_std_attr(attrs, &this->osd_item, 0);
     3310        opc->osd_item.p.x = 20;
     3311        opc->osd_item.p.y = -80;
     3312        opc->osd_item.w = 60;
     3313        opc->osd_item.h = 40;
     3314        opc->osd_item.font_size = 200;
     3315        osd_set_std_attr(attrs, &opc->osd_item, 0);
    31873316
    3188         navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_auxmap_init), attr_navit, this));
    3189         return (struct osd_priv *) this;
     3317        navit_add_callback(nav, callback_new_attr_1(callback_cast(osd_auxmap_init), attr_navit, opc));
     3318        return (struct osd_priv *) opc;
    31903319}
    31913320
    31923321