ATTR(lag)
ATTR(bpp)
ATTR(fullscreen)
+ATTR(windowid)
ATTR2(0x00027500,type_rel_abs_begin)
/* These attributes are int that can either hold relative *
* or absolute values. A relative value is indicated by *
static void draw_circle(struct point *pnt, int diameter, int scale, int start, int len, struct point *res, int *pos, int dir);
static void graphics_process_selection(struct graphics *gra, struct displaylist *dl);
+int
+graphics_set_attr(struct graphics *gra, struct attr *attr)
+{
+ int ret=1;
+ dbg(0,"enter\n");
+ if (gra->meth.set_attr)
+ ret=gra->meth.set_attr(gra->priv, attr);
+ return ret != 0;
+}
+
void
graphics_set_rect(struct graphics *gra, struct point_rect *pr)
{
*/
void graphics_init(struct graphics *this_)
{
+ if (this_->gc[0])
+ return;
this_->gc[0]=graphics_gc_new(this_);
graphics_gc_set_background(this_->gc[0], &(struct color) { 0xffff, 0xefef, 0xb7b7, 0xffff});
graphics_gc_set_foreground(this_->gc[0], &(struct color) { 0xffff, 0xefef, 0xb7b7, 0xffff });
void (*get_text_bbox)(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate);
void (*overlay_disable)(struct graphics_priv *gr, int disable);
void (*overlay_resize)(struct graphics_priv *gr, struct point *p, int w, int h, int alpha, int wraparound);
+ int (*set_attr)(struct graphics_priv *gr, struct attr *attr);
};
struct point;
struct point_rect;
struct transformation;
+int graphics_set_attr(struct graphics *gra, struct attr *attr);
void graphics_set_rect(struct graphics *gra, struct point_rect *pr);
struct graphics *graphics_new(struct attr *parent, struct attr **attrs);
int graphics_get_attr(struct graphics *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
struct timeval button_press[8];
struct timeval button_release[8];
int timeout;
+ int delay;
};
* * Exit navit (X pressed)
* * @param widget active widget
* * @param event the event (delete_event)
- * * @param nav our Navit context
+ * * @param user_data Pointer to private data structure
* * @returns TRUE
* */
static gint
-delete(GtkWidget *widget, GdkEventKey *event, struct navit *nav)
+delete(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
{
- navit_destroy(nav);
+ struct graphics_priv *this=user_data;
+ dbg(0,"enter this->win=%p\n",this->win);
+ if (this->delay & 2) {
+ if (this->win)
+ this->win=NULL;
+ } else {
+ navit_destroy(this->nav);
+ }
return TRUE;
}
}
}
+static void
+get_data_window(struct graphics_priv *this, unsigned int xid)
+{
+ if (!xid)
+ this->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ else
+ this->win = gtk_plug_new(xid);
+ if (!gtk_widget_get_parent(this->widget))
+ gtk_widget_ref(this->widget);
+ gtk_window_set_default_size(GTK_WINDOW(this->win), this->win_w, this->win_h);
+ dbg(1,"h= %i, w= %i\n",this->win_h, this->win_w);
+ gtk_window_set_title(GTK_WINDOW(this->win), "Navit");
+ gtk_window_set_wmclass (GTK_WINDOW (this->win), "navit", "Navit");
+ gtk_widget_realize(this->win);
+ if (gtk_widget_get_parent(this->widget))
+ gtk_widget_reparent(this->widget, this->win);
+ else
+ gtk_container_add(GTK_CONTAINER(this->win), this->widget);
+ gtk_widget_show_all(this->win);
+ GTK_WIDGET_SET_FLAGS (this->widget, GTK_CAN_FOCUS);
+ gtk_widget_set_sensitive(this->widget, TRUE);
+ gtk_widget_grab_focus(this->widget);
+ g_signal_connect(G_OBJECT(this->widget), "key-press-event", G_CALLBACK(keypress), this);
+ g_signal_connect(G_OBJECT(this->win), "delete_event", G_CALLBACK(delete), this);
+}
+
+static int
+set_attr(struct graphics_priv *gr, struct attr *attr)
+{
+ dbg(0,"enter\n");
+ switch (attr->type) {
+ case attr_windowid:
+ get_data_window(gr, attr->u.num);
+ return 1;
+ default:
+ return 0;
+ }
+}
+
static struct graphics_priv *
overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int alpha, int wraparound)
{
#else
dbg(1, "failed to kill() under Windows\n");
#endif
-}
+}
+
static void *
get_data(struct graphics_priv *this, char *type)
unsigned xid = 0;
if (cp)
xid = strtol(cp, NULL, 0);
- if (!xid)
- this->win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- else
- this->win = gtk_plug_new(xid);
- gtk_window_set_default_size(GTK_WINDOW(this->win), this->win_w, this->win_h);
- dbg(1,"h= %i, w= %i\n",this->win_h, this->win_w);
- gtk_window_set_title(GTK_WINDOW(this->win), "Navit");
- gtk_window_set_wmclass (GTK_WINDOW (this->win), "navit", "Navit");
- gtk_widget_realize(this->win);
- gtk_container_add(GTK_CONTAINER(this->win), this->widget);
- gtk_widget_show_all(this->win);
- GTK_WIDGET_SET_FLAGS (this->widget, GTK_CAN_FOCUS);
- gtk_widget_set_sensitive(this->widget, TRUE);
- gtk_widget_grab_focus(this->widget);
- g_signal_connect(G_OBJECT(this->widget), "key-press-event", G_CALLBACK(keypress), this);
- g_signal_connect(G_OBJECT(this->win), "delete_event", G_CALLBACK(delete), this->nav);
+ if (!(this->delay & 1))
+ get_data_window(this, xid);
this->window.fullscreen=graphics_gtk_drawing_area_fullscreen;
this->window.disable_suspend=graphics_gtk_drawing_area_disable_suspend;
this->window.priv=this;
NULL,
overlay_disable,
overlay_resize,
+ set_attr,
};
static struct graphics_priv *
this->timeout=100;
if ((attr=attr_search(attrs, NULL, attr_timeout)))
this->timeout=attr->u.num;
+ this->delay=0;
+ if ((attr=attr_search(attrs, NULL, attr_delay)))
+ this->delay=attr->u.num;
this->cbl=cbl;
this->colormap=gdk_colormap_new(gdk_visual_get_system(),FALSE);
gtk_widget_set_events(draw, GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK|GDK_POINTER_MOTION_MASK|GDK_KEY_PRESS_MASK);
}
}
+static void
+gui_internal_setup_gc(struct gui_priv *this)
+{
+ struct color cbh={0x9fff,0x9fff,0x9fff,0xffff};
+ struct color cf={0xbfff,0xbfff,0xbfff,0xffff};
+ struct graphics *gra=this->gra;
+
+ if (this->background)
+ return;
+ this->background=graphics_gc_new(gra);
+ this->background2=graphics_gc_new(gra);
+ this->highlight_background=graphics_gc_new(gra);
+ graphics_gc_set_foreground(this->highlight_background, &cbh);
+ this->foreground=graphics_gc_new(gra);
+ graphics_gc_set_foreground(this->foreground, &cf);
+ this->text_background=graphics_gc_new(gra);
+ this->text_foreground=graphics_gc_new(gra);
+ graphics_gc_set_foreground(this->background, &this->background_color);
+ graphics_gc_set_foreground(this->background2, &this->background2_color);
+ graphics_gc_set_foreground(this->text_background, &this->text_background_color);
+ graphics_gc_set_foreground(this->text_foreground, &this->text_foreground_color);
+}
+
//##############################################################################################################
//# Description:
//# Comment:
{
struct gui_priv *this=data;
+ gui_internal_setup_gc(this);
if( this->root.w==w && this->root.h==h)
return;
static int gui_internal_set_graphics(struct gui_priv *this, struct graphics *gra)
{
struct window *win;
- struct color cbh={0x9fff,0x9fff,0x9fff,0xffff};
- struct color cf={0xbfff,0xbfff,0xbfff,0xffff};
struct transformation *trans=navit_get_trans(this->nav);
win=graphics_get_data(gra, "window");
graphics_add_callback(gra, this->motion_cb);
this->keypress_cb=callback_new_attr_1(callback_cast(gui_internal_keypress), attr_keypress, this);
graphics_add_callback(gra, this->keypress_cb);
- this->background=graphics_gc_new(gra);
- this->background2=graphics_gc_new(gra);
- this->highlight_background=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->highlight_background, &cbh);
- this->foreground=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->foreground, &cf);
- this->text_background=graphics_gc_new(gra);
- this->text_foreground=graphics_gc_new(gra);
- graphics_gc_set_foreground(this->background, &this->background_color);
- graphics_gc_set_foreground(this->background2, &this->background2_color);
- graphics_gc_set_foreground(this->text_background, &this->text_background_color);
- graphics_gc_set_foreground(this->text_foreground, &this->text_foreground_color);
// set fullscreen if needed
if (this->fullscreen)
sel.u.p_rect.rl.x=w;
sel.u.p_rect.rl.y=h;
transform_set_screen_selection(this_->trans, &sel);
+ graphics_init(this_->gra);
this_->ready |= 2;
graphics_set_rect(this_->gra, &sel.u.p_rect);
if (this_->ready == 3)
return;
}
dbg(2,"Initializing graphics\n");
- graphics_init(this_->gra);
dbg(2,"Setting Vehicle\n");
navit_set_vehicle(this_, this_->vehicle);
dbg(2,"Adding dynamic maps to mapset %p\n",this_->mapsets);