Package: gtk

Function gtk-widget-allocation

Lambda List

gtk-widget-allocation (widget)

Syntax

(gtk-widget-allocation widget) => allocation
(setf (gtk-widget-allocation widget) allocation

Arguments

widget -- a gtk-widget object
allocation -- a gdk-rectangle instance

Details

Accessor of the allocation of the widget.

The gtk-widget-allocation function retrieves the allocation of the widget. The (setf gtk-widget-allocation) function sets the allocation. This should not be used directly, but from within a size_allocate method of the widget.

Note, when implementing a gtk-container widget an allocation of the widget will be its "adjusted" allocation, that is, the parent container of the widget typically calls the gtk-widget-size-allocate function with an allocation, and that allocation is then adjusted, to handle margin and alignment for example, before assignment to the widget. The gtk-widget-allocation function returns the adjusted allocation that was actually assigned to the widget. The adjusted allocation is guaranteed to be completely contained within the gtk-widget-size-allocate allocation, however. So a gtk-container widget is guaranteed that its children stay inside the assigned bounds, but not that they have exactly the bounds the container assigned. There is no way to get the original allocation assigned by the gtk-widget-size-allocate function, since it is not stored. If a container implementation needs that information it will have to track it itself.

The allocation set should be the "adjusted" or actual allocation. If you are implementing a gtk-container widget, you want to use the gtk-widget-size-allocate function instead of the gtk-widget-allocation function. The GtkWidgetClass::adjust_size_allocation virtual method adjusts the allocation inside the gtk-widget-size-allocate function to create an adjusted allocation.

Note

In the Lisp binding to GTK this function does not return an allocation of type GtkAllocation, but the type is gdk-rectangle. In the C implementation the type GtkAllocation is a synonym for the type gdk-rectangle.

In most cases, it is more convenient to use the gtk-widget-allocated-width and gtk-widget-allocated-height functions to retrieve the allocated width and height of the widget.
 

See also

*2021-12-7