can't get height during expose-event



Hello,

trying out example 1 of section GtkDrawinArea of GTK2.0.0 Reference
Manual (sample code at the end of the mail) I got some trouble.
I'm using GTK2.0.0

The sample draws a filled circle in a window.
Changing the width of the window changes the circle's diameter to.
Changing the height of the window works but the circle doesn't
change his diameter.

widget->allocation.height remains at predefined value.

Any idea how to get the correct height ?

thanks

Joachim Klaehn




gboolean
expose_event_callback (GtkWidget *widget, 
		       GdkEventExpose *event, gpointer data)
{
  gdk_draw_arc (widget->window,
                widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                TRUE,
                0, 0, 
		widget->allocation.width, widget->allocation.height,
                0, 64 * 360);
  printf("expose event w: %d h: %d\n",
	 widget->allocation.width, widget->allocation.height);
  return TRUE;
}

int main (int argc, char *argv[])  
{
  GtkWidget *Vbox,*Win;

  gtk_init(&argc, &argv);

  Win = gtk_window_new(GTK_WINDOW_TOPLEVEL);

  Vbox = gtk_vbox_new(FALSE,0);
  gtk_container_set_border_width (GTK_CONTAINER (Win), 0);
  gtk_container_add(GTK_CONTAINER(Win),Vbox);
  gtk_widget_show(Vbox);

  GtkWidget *drawing_area = gtk_drawing_area_new ();
  gtk_widget_set_size_request (drawing_area, 100, 100);
  g_signal_connect (G_OBJECT (drawing_area), "expose_event",  
                    G_CALLBACK (expose_event_callback), NULL);

  gtk_box_pack_start (GTK_BOX (Vbox),drawing_area, FALSE, FALSE, 0);

  gtk_widget_show_all(Win);

  gtk_main();

  exit (0);
}



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