public final class Requisition extends Boxed
getRequisition()
method.
As a general principle across GTK programming, we encourage people to leave Widgets alone to work out their own needs. You will not be able to forecast the impact of a user's fonts, accessibility settings, and theme engine, not to mention the actual implementation of the Containers you are packing your Widget into. The great part is that you don't need to; the GNOME libraries are really good at Doing The Right Thing (tm) and you will do well by them.
When an occasion does arise where you need to force one or both dimensions, you can either:
setSizeRequest()
;
SizeGroup
to influence a set of related Widgets to have a
dimension in common; or
setBorderWidth()
.
GTK's box packing model works on a size-request/size-allocation process.
Each Widget is asked by it's parent Container how much space it wants on
the screen, in pixels. These requests are aggregated and in turn
represented up the tree until the top-level Window is reached. The Window
then negotiates with the window manager and with the X server, with the
result being that the Window is allocated. The Containers start
divvying up the allocation they were given amongst their children according
to whatever algorithms and settings are in place. Eventually your Widget
will be told how much space it has been given in it's Allocation
object, and it will have to then carry on accordingly. The important point
to note here is that requests are just that; a Widget must be able to cope
with any size down to 1x1
. Ideally it will degrade gracefully,
although that's not always easy.