How to customize children sizes in Gtk::[HV]Box



Hi all,

I want to arrange two or more widgets in a row or column so that each of them takes up a specified fraction of the available space. For example, say I'm putting two widgets in a row and I want the first to be twice as large as the second; in other words, the first should take two thirds of the available horizontal space and the other one the remaining third. Of course if I resize the window the proportion should be preserved.

I don't think this is possible with ordinary Gtk::HBox and Gtk::VBox. With homogeneous=true all children can be made of the same size, but I couldn't find a way to specify different sizes.

I've been able to do it with a Gtk::Table by setting homogeneous=true and spreading the first widget over two columns and the second over the third column; but this isn't flexible at all, for example if I want to change the proportion (say from 67%-33% to 60%-40%), I must detach the widgets and reattach them to different (sets of) columns. Furthermore with this method I can only specify a fixed fraction, while I'd like to also be able to specify only a minimum (maximum) fraction and let the window grow larger (shrink smaller) than that if appropriate.

I guess the most clean and flexible solution is to derive a custom version of Gtk::[HV]Box. But I have little to no idea of how to do that (which methods I should rewrite etc.). So I'd appreciate any guidance (a working example would be optimal ;-).

Thanks in advance
 Gerardo


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