Expose events and drawing areas



'evening all

I've been fiddeling around with pixmaps and drawing areas in gtk a bit and
I've come across a problem. It seems to me that expose events aren't
propagated to my drawing area. I have a main (toplevel) window containing
a drawing area and the expose events get delivered to the main window, but
not to the drawing area. The strange thing is that configuration events
get propagated alright. 

Anyhow, I've included a small program at the end of this mail and I would
very much appreciate it if someone would have a look at it. 


Also, what does the return value of signal functions mean? I fail to
notice any difference if I set them to either TRUE or FALSE.


#include <gtk/gtk.h>

GdkPixmap *_bg_pixmap;

static gint
expose_handler(GtkWidget *widget, GdkEventExpose *event)
{
  fprintf(stderr, "Expose_handler\n");

  gdk_draw_pixmap((GdkDrawable *)widget->window, 
		  widget->style->fg_gc[GTK_WIDGET_STATE(widget)], 
		  _bg_pixmap, 0, 0, 0, 0, 400, 300);  

  return TRUE;
}

static gint
configure_handler(GtkWidget *widget, GdkEventConfigure *event)
{ 
  fprintf(stderr, "Configure_handler\n");

  gdk_draw_pixmap((GdkDrawable *)widget->window, 
		  widget->style->fg_gc[GTK_WIDGET_STATE(widget)], 
		  _bg_pixmap, 0, 0, 0, 0, 400, 300);  
  
  return FALSE;
}

int
main(int argc, char *argv[])
{
  
  GtkWidget *main_window;
  GtkWidget *drawing_area;
  GtkWidget *bg_pixmap;

  GdkBitmap *_bg_pixmap_mask; 
  GdkColor _bg_colour;

  gint w,h,i;
  
  gtk_init(&argc, &argv);

  main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  
  drawing_area = gtk_drawing_area_new();
  gtk_drawing_area_size(GTK_DRAWING_AREA(drawing_area), 400, 300);

  gtk_signal_connect(GTK_OBJECT(drawing_area), "expose_event", 
		     GTK_SIGNAL_FUNC(expose_handler), NULL);
  gtk_signal_connect(GTK_OBJECT(drawing_area), "configure_event", 
		     GTK_SIGNAL_FUNC(configure_handler), NULL);

  gtk_container_add(GTK_CONTAINER(main_window), drawing_area);

  _bg_pixmap = gdk_pixmap_create_from_xpm(drawing_area->window,
					  &_bg_pixmap_mask,
					  &_bg_colour,
					  "bg.xpm");

  gtk_widget_show(drawing_area); 
  gtk_widget_show(main_window);
  
  gtk_main();


  return 0;
}


-----------------------------------------------------------------------
Per Lewau (perle@lysator.liu.se)	Student of Computer Science at 
					Linköping University, Sweden. 
"Don't quote me; that's what you heard, not what I said."
						- Lawrence K. Frank



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]