Re: GdkPixmap and configure_event
- From: Olexiy Avramchenko <ath beast stu cn ua>
- To: Reham Younis <reham_younis yahoo com>
- Cc: gtk-list gnome org
- Subject: Re: GdkPixmap and configure_event
- Date: Thu, 12 Sep 2002 11:51:41 +0300
Reham Younis wrote:
Hi,
I am working on a project in which we are trying to
upgrade its old GUI based on x lib pure calls to GTK
(gtk-1.2).
The problem is that I am creating a gtk drawing area
which is used for drawing with x calls drawing
functions. Things are working fine,except for
GdkPixmap. It seems that for some reasons, using
configure event with gdkpixmap doesnt work! The expose
event works perfect,but when it tries to configure
only a black area appears after the configure event is
fired. Here is the code:
gint expose_event (GtkWidget *widget, GdkEventExpose
*event, gpointer data)
{
//HWindow is a struct that has a GdkPixmap as a
member.
HWindow *win = (HWindow*) data;
//widget is the drawing area
gdk_draw_pixmap (widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
win->pixmap,
event->area.x,event->area.y,
event->area.x,event->area.y,
event->area.width,event->area.height);
return FALSE;
}
gint config_event (GtkWidget *widget,GdkEventConfigure
*event, gpointer data)
{
HWindow *win= (Hwindow*)data;
if (win->pixmap)
gdk_pixmap_unref(win->pixmap);
win->pixmap = gdk_pixmap_new(widget->window,
widget->allocation.width,
widget->allocation.height,
-1);
gdk_draw_rectangle (win->pixmap,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
TRUE,
widget->allocation.x,widget->allocation.y,
*BUG* here: pass 0,0 as x,y
widget->allocation.width,widget->allocation.height);
}
1. Are you sure your gc *widget->style->fg_gc[GTK_WIDGET_STATE
(widget)]* contains the color
you need ? Create and use your own gc. This's not the problem, but...
2. This one looks like your problem.
You need to pass 0,0 as *x*, *y* coords to gdk_draw_rectangle, cause you
may got
allocation.x > allocation.width (the width of your pixmap), allocation.y
> allocation.height (the
height of your pixmap).
Olexiy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]