Re: A question about box packing and widget/window sizing..




"Daniel J. Kressin" <kressd11@sol.acs.uwosh.edu> writes:

> I've got the following layout:
> 
> +-toplevel window----------------------+
> | +-vbox-----------------------------+ |
> | | +------------------------------+ | |
> | | | menu                         | | |
> | | +------------------------------+ | |
> | | +-hbox-------------------------+ | |
> | | | +---------+ +--------------+ | | |
> | | | | packing | | drawing area | | | |
> | | | |  table  | |              | | | |
> | | | |         | |              | | | |
> | | | +---------+ |              | | | |
> | | |             |              | | | |
> | | |             |              | | | |
> | | |             +--------------+ | | |
> | | +------------------------------+ | |
> | +----------------------------------+ |
> +--------------------------------------+
> (isn't ascii art fun??)
> 
> I need all of the following to occur when the toplevel window gets resized
> by the user:
> 1) The packing table should always remain at its smallest possible size
>    given its contents (several fixed-sized pixmaps).
> 2) The drawing area should take up any/all remaining space while keeping
>    a square aspect ratio.
> 3) The toplevel window should automatically shrink itself to tightly
>    enclose the table and newly sized (square) drawing area.

Note that your constraints actually constrain the possible sizes
of the toplevel window - so if you don't want to play some
game with the user of "no, you can't have that size", you
need to tell the window manager about the constraints.

GTK+-1.2 adds a new call to make this (fairly) easy:

void       
gtk_window_set_geometry_hints       (GtkWindow           *window,
			             GtkWidget           *geometry_widget,
				     GdkGeometry         *geometry,
				     GdkWindowHints       geom_mask);

I think the following should achive exactly the effect you
want:

 GdkGeometry geometry;
  
 geometry min_aspect = 1.0;
 geometry max_aspect = 1.0;

 gtk_window_set_geometry_hint (toplevel, drawing_area,
                               &geometry, GDK_HINT_ASPECT);

The key here is the geometry_widget argument; if this
is non-null then the constraints refer not to the toplevel
as a whole, but to subwidget of the toplevel.

Regards,
                                        Owen



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