Re: [gtk-list] Exact specification of widget placement





On Sat, 19 Jul 1997, Yoav Cohen-Sivan wrote:

> I've just started studying GUI programming in my rare free time and I
> was given a pointer to gtk as a good beginning. I've glazed over the
> docs and I seem to be missing something; is there a way for me to
> specify the exact position of a child widget in a parent? Can I say:
> "put this child at coordinate 12,45 relative to it's parent"? If so,
> how; and if not, then how do I go about placing widgets inside their
> parents.
> 
> 	Apologies if this is a *really* stupid question, but, hey, I'm sure
> even Linus started from nothing sometime in the past ;-)

Not a stupid question at all. GTK widget packing is generally based on
relative boxes rather than absolute positioning. This makes the user
interface more resilient to changes in font and style, as well as making
it easier to rearrange the UI, but on the other hand offers a little less
precise control than coordinate-based placement. 

If your UI design fits into an hbox/vbox hierarchy, try building it that 
way first. If not, look into the table widget, which is surprisingly 
powerful - it's roughly equivalent to Java's GridBagConstraints tool.

Failing that, it's always possible to write your own absolute positioning 
container widget. It wouldn't even be that difficult. One thing to keep 
in mind, though, is that the GTK drawing model does not support 
overlapping draw rectangles.

Hope this helps.

Raph



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