gtk_window_set_policy & gtk_widget_set_usize




I have a drawing_area, with size set at runtime. This is inside a scrolled
window, which is inside a top level window:

  mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_policy( GTK_WINDOW( mainwin ), TRUE, FALSE, FALSE );

  dscroll = gtk_scrolled_window_new( NULL, NULL );
  gtk_widget_set_usize( GTK_WIDGET (dscroll), xsize, ysize);
  gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW (dscroll),
    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );

  darea = gtk_drawing_area_new();
  gtk_drawing_area_size(GTK_DRAWING_AREA (darea), xsize, ysize);

  gtk_container_add (GTK_CONTAINER (dscroll), darea);
  gtk_container_add (GTK_CONTAINER (mainwin), dscroll);


where xsize and ysize are the size of darea (Irrelevant lines cut).

As you may be able to see, I'm trying to stop the user enlarging the top
level window larger than the drawing area - ie. So there's no blank
screen.  However, I do want them to be able to reduce the size of the
window, and use the scroll bars to move around. 

This has the problem that the maximum size of the window does not take
account of the scroll bar widths.

I COULD increase the usize of dscroll, but:

1. Can scroll bars have different widths?

2. When the window is full size, and no scroll bars are to be shown, there
will be blank space. I'd rather not use GTK_POLICY_ALWAYS, as this is a
bit ugly.

Any ideas, anyone, on how to fix this?


Alistair Cunningham.

--------------------------------------------------------------------------
 Alistair Cunningham   Selwyn College, Cambridge   Email: ac212@cam.ac.uk



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