Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
- Exported types
- Methods
- add
- checkResize
- childGetProperty
- childNotify
- childNotifyByPspec
- childSetProperty
- childType
- forall
- foreach
- getBorderWidth
- getChildren
- getFocusChain
- getFocusChild
- getFocusHadjustment
- getFocusVadjustment
- getPathForChild
- getResizeMode
- propagateDraw
- remove
- resizeChildren
- setBorderWidth
- setFocusChain
- setFocusChild
- setFocusHadjustment
- setFocusVadjustment
- setReallocateRedraws
- setResizeMode
- unsetFocusChain
- Properties
- Signals
A GTK+ user interface is constructed by nesting widgets inside widgets.
Container widgets are the inner nodes in the resulting tree of widgets:
they contain other widgets. So, for example, you might have a Window
containing a Frame
containing a Label
. If you wanted an image instead
of a textual label inside the frame, you might replace the Label
widget
with a Image
widget.
There are two major kinds of container widgets in GTK+. Both are subclasses of the abstract GtkContainer base class.
The first type of container widget has a single child widget and derives
from Bin
. These containers are decorators, which
add some kind of functionality to the child. For example, a Button
makes
its child into a clickable button; a Frame
draws a frame around its child
and a Window
places its child widget inside a top-level window.
The second type of container can have more than one child; its purpose is to
manage layout. This means that these containers assign
sizes and positions to their children. For example, a HBox
arranges its
children in a horizontal row, and a Grid
arranges the widgets it contains
in a two-dimensional grid.
For implementations of Container
the virtual method ContainerClass
.forall
()
is always required, since it's used for drawing and other internal operations
on the children.
If the Container
implementation expect to have non internal children
it's needed to implement both ContainerClass
.add
() and ContainerClass
.remove
().
If the GtkContainer implementation has internal children, they should be added
with widgetSetParent
on init()
and removed with widgetUnparent
in the WidgetClass
.destroy
() implementation.
See more about implementing custom widgets at https://wiki.gnome.org/HowDoI/CustomWidgets
Height for width geometry management
GTK+ uses a height-for-width (and width-for-height) geometry management system. Height-for-width means that a widget can change how much vertical space it needs, depending on the amount of horizontal space that it is given (and similar for width-for-height).
There are some things to keep in mind when implementing container widgets
that make use of GTK+’s height for width geometry management system. First,
it’s important to note that a container must prioritize one of its
dimensions, that is to say that a widget or container can only have a
SizeRequestMode
that is SizeRequestModeHeightForWidth
or
SizeRequestModeWidthForHeight
. However, every widget and container
must be able to respond to the APIs for both dimensions, i.e. even if a
widget has a request mode that is height-for-width, it is possible that
its parent will request its sizes using the width-for-height APIs.
To ensure that everything works properly, here are some guidelines to follow when implementing height-for-width (or width-for-height) containers.
Each request mode involves 2 virtual methods. Height-for-width apis run
through widgetGetPreferredWidth
and then through widgetGetPreferredHeightForWidth
.
When handling requests in the opposite SizeRequestMode
it is important that
every widget request at least enough space to display all of its content at all times.
When widgetGetPreferredHeight
is called on a container that is height-for-width,
the container must return the height for its minimum width. This is easily achieved by
simply calling the reverse apis implemented for itself as follows:
C code
static void foo_container_get_preferred_height (GtkWidget *widget, gint *min_height, gint *nat_height) { if (i_am_in_height_for_width_mode) { gint min_width; GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, NULL); GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width (widget, min_width, min_height, nat_height); } else { ... many containers support both request modes, execute the real width-for-height request here by returning the collective heights of all widgets that are stacked vertically (or whatever is appropriate for this container) ... } }
Similarly, when widgetGetPreferredWidthForHeight
is called for a container or widget
that is height-for-width, it then only needs to return the base minimum width like so:
C code
static void foo_container_get_preferred_width_for_height (GtkWidget *widget, gint for_height, gint *min_width, gint *nat_width) { if (i_am_in_height_for_width_mode) { GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, min_width, nat_width); } else { ... execute the real width-for-height request here based on the required width of the children collectively if the container were to be allocated the said height ... } }
Height for width requests are generally implemented in terms of a virtual allocation
of widgets in the input orientation. Assuming an height-for-width request mode, a container
would implement the get_preferred_height_for_width()
virtual function by first calling
widgetGetPreferredWidth
for each of its children.
For each potential group of children that are lined up horizontally, the values returned by
widgetGetPreferredWidth
should be collected in an array of RequestedSize
structures.
Any child spacing should be removed from the input forWidth
and then the collective size should be
allocated using the distributeNaturalAllocation
convenience function.
The container will then move on to request the preferred height for each child by using
widgetGetPreferredHeightForWidth
and using the sizes stored in the RequestedSize
array.
To allocate a height-for-width container, it’s again important
to consider that a container must prioritize one dimension over the other. So if
a container is a height-for-width container it must first allocate all widgets horizontally
using a RequestedSize
array and distributeNaturalAllocation
and then add any
extra space (if and where appropriate) for the widget to expand.
After adding all the expand space, the container assumes it was allocated sufficient
height to fit all of its content. At this time, the container must use the total horizontal sizes
of each widget to request the height-for-width of each of its children and store the requests in a
RequestedSize
array for any widgets that stack vertically (for tabular containers this can
be generalized into the heights and widths of rows and columns).
The vertical space must then again be distributed using distributeNaturalAllocation
while this time considering the allocated height of the widget minus any vertical spacing
that the container adds. Then vertical expand space should be added where appropriate and available
and the container should go on to actually allocating the child widgets.
See [GtkWidget’s geometry management section][geometry-management] to learn more about implementing height-for-width geometry management for widgets.
Child properties
GtkContainer introduces child properties.
These are object properties that are not specific
to either the container or the contained widget, but rather to their relation.
Typical examples of child properties are the position or pack-type of a widget
which is contained in a Box
.
Use containerClassInstallChildProperty
to install child properties
for a container class and containerClassFindChildProperty
or
containerClassListChildProperties
to get information about existing
child properties.
To set the value of a child property, use containerChildSetProperty
,
gtk_container_child_set()
or gtk_container_child_set_valist()
.
To obtain the value of a child property, use
containerChildGetProperty
, gtk_container_child_get()
or
gtk_container_child_get_valist()
. To emit notification about child property
changes, use widgetChildNotify
.
GtkContainer as GtkBuildable
The GtkContainer implementation of the GtkBuildable interface supports a <packing> element for children, which can contain multiple <property> elements that specify child properties for the child.
Since 2.16, child properties can also be marked as translatable using the same “translatable”, “comments” and “context” attributes that are used for regular properties.
Since 3.16, containers can have a <focus-chain> element containing multiple <widget> elements, one for each child that should be added to the focus chain. The ”name” attribute gives the id of the widget.
An example of these properties in UI definitions: > >class="GtkBox" > child > class="GtkEntry" id="entry1"/ > packing > name="pack-type"start/property > /packing > /child > child > class="GtkEntry" id="entry2"/ > /child > focus-chain > name="entry1"/ > name="entry2"/ > /focus-chain >/object
Synopsis
- newtype Container = Container (ManagedPtr Container)
- class (GObject o, IsDescendantOf Container o) => IsContainer o
- toContainer :: (MonadIO m, IsContainer o) => o -> m Container
- containerAdd :: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) => a -> b -> m ()
- containerCheckResize :: (HasCallStack, MonadIO m, IsContainer a) => a -> m ()
- containerChildGetProperty :: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) => a -> b -> Text -> GValue -> m ()
- containerChildNotify :: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) => a -> b -> Text -> m ()
- containerChildNotifyByPspec :: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) => a -> b -> GParamSpec -> m ()
- containerChildSetProperty :: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) => a -> b -> Text -> GValue -> m ()
- containerChildType :: (HasCallStack, MonadIO m, IsContainer a) => a -> m GType
- containerForall :: (HasCallStack, MonadIO m, IsContainer a) => a -> Callback -> m ()
- containerForeach :: (HasCallStack, MonadIO m, IsContainer a) => a -> Callback -> m ()
- containerGetBorderWidth :: (HasCallStack, MonadIO m, IsContainer a) => a -> m Word32
- containerGetChildren :: (HasCallStack, MonadIO m, IsContainer a) => a -> m [Widget]
- containerGetFocusChain :: (HasCallStack, MonadIO m, IsContainer a) => a -> m (Bool, [Widget])
- containerGetFocusChild :: (HasCallStack, MonadIO m, IsContainer a) => a -> m (Maybe Widget)
- containerGetFocusHadjustment :: (HasCallStack, MonadIO m, IsContainer a) => a -> m (Maybe Adjustment)
- containerGetFocusVadjustment :: (HasCallStack, MonadIO m, IsContainer a) => a -> m (Maybe Adjustment)
- containerGetPathForChild :: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) => a -> b -> m WidgetPath
- containerGetResizeMode :: (HasCallStack, MonadIO m, IsContainer a) => a -> m ResizeMode
- containerPropagateDraw :: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) => a -> b -> Context -> m ()
- containerRemove :: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) => a -> b -> m ()
- containerResizeChildren :: (HasCallStack, MonadIO m, IsContainer a) => a -> m ()
- containerSetBorderWidth :: (HasCallStack, MonadIO m, IsContainer a) => a -> Word32 -> m ()
- containerSetFocusChain :: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) => a -> [b] -> m ()
- containerSetFocusChild :: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) => a -> Maybe b -> m ()
- containerSetFocusHadjustment :: (HasCallStack, MonadIO m, IsContainer a, IsAdjustment b) => a -> b -> m ()
- containerSetFocusVadjustment :: (HasCallStack, MonadIO m, IsContainer a, IsAdjustment b) => a -> b -> m ()
- containerSetReallocateRedraws :: (HasCallStack, MonadIO m, IsContainer a) => a -> Bool -> m ()
- containerSetResizeMode :: (HasCallStack, MonadIO m, IsContainer a) => a -> ResizeMode -> m ()
- containerUnsetFocusChain :: (HasCallStack, MonadIO m, IsContainer a) => a -> m ()
- constructContainerBorderWidth :: (IsContainer o, MonadIO m) => Word32 -> m (GValueConstruct o)
- getContainerBorderWidth :: (MonadIO m, IsContainer o) => o -> m Word32
- setContainerBorderWidth :: (MonadIO m, IsContainer o) => o -> Word32 -> m ()
- clearContainerChild :: (MonadIO m, IsContainer o) => o -> m ()
- constructContainerChild :: (IsContainer o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o)
- setContainerChild :: (MonadIO m, IsContainer o, IsWidget a) => o -> a -> m ()
- constructContainerResizeMode :: (IsContainer o, MonadIO m) => ResizeMode -> m (GValueConstruct o)
- getContainerResizeMode :: (MonadIO m, IsContainer o) => o -> m ResizeMode
- setContainerResizeMode :: (MonadIO m, IsContainer o) => o -> ResizeMode -> m ()
- type C_ContainerAddCallback = Ptr () -> Ptr Widget -> Ptr () -> IO ()
- type ContainerAddCallback = Widget -> IO ()
- afterContainerAdd :: (IsContainer a, MonadIO m) => a -> ContainerAddCallback -> m SignalHandlerId
- genClosure_ContainerAdd :: MonadIO m => ContainerAddCallback -> m (GClosure C_ContainerAddCallback)
- mk_ContainerAddCallback :: C_ContainerAddCallback -> IO (FunPtr C_ContainerAddCallback)
- noContainerAddCallback :: Maybe ContainerAddCallback
- onContainerAdd :: (IsContainer a, MonadIO m) => a -> ContainerAddCallback -> m SignalHandlerId
- wrap_ContainerAddCallback :: ContainerAddCallback -> C_ContainerAddCallback
- type C_ContainerCheckResizeCallback = Ptr () -> Ptr () -> IO ()
- type ContainerCheckResizeCallback = IO ()
- afterContainerCheckResize :: (IsContainer a, MonadIO m) => a -> ContainerCheckResizeCallback -> m SignalHandlerId
- genClosure_ContainerCheckResize :: MonadIO m => ContainerCheckResizeCallback -> m (GClosure C_ContainerCheckResizeCallback)
- mk_ContainerCheckResizeCallback :: C_ContainerCheckResizeCallback -> IO (FunPtr C_ContainerCheckResizeCallback)
- noContainerCheckResizeCallback :: Maybe ContainerCheckResizeCallback
- onContainerCheckResize :: (IsContainer a, MonadIO m) => a -> ContainerCheckResizeCallback -> m SignalHandlerId
- wrap_ContainerCheckResizeCallback :: ContainerCheckResizeCallback -> C_ContainerCheckResizeCallback
- type C_ContainerRemoveCallback = Ptr () -> Ptr Widget -> Ptr () -> IO ()
- type ContainerRemoveCallback = Widget -> IO ()
- afterContainerRemove :: (IsContainer a, MonadIO m) => a -> ContainerRemoveCallback -> m SignalHandlerId
- genClosure_ContainerRemove :: MonadIO m => ContainerRemoveCallback -> m (GClosure C_ContainerRemoveCallback)
- mk_ContainerRemoveCallback :: C_ContainerRemoveCallback -> IO (FunPtr C_ContainerRemoveCallback)
- noContainerRemoveCallback :: Maybe ContainerRemoveCallback
- onContainerRemove :: (IsContainer a, MonadIO m) => a -> ContainerRemoveCallback -> m SignalHandlerId
- wrap_ContainerRemoveCallback :: ContainerRemoveCallback -> C_ContainerRemoveCallback
- type C_ContainerSetFocusChildCallback = Ptr () -> Ptr Widget -> Ptr () -> IO ()
- type ContainerSetFocusChildCallback = Widget -> IO ()
- afterContainerSetFocusChild :: (IsContainer a, MonadIO m) => a -> ContainerSetFocusChildCallback -> m SignalHandlerId
- genClosure_ContainerSetFocusChild :: MonadIO m => ContainerSetFocusChildCallback -> m (GClosure C_ContainerSetFocusChildCallback)
- mk_ContainerSetFocusChildCallback :: C_ContainerSetFocusChildCallback -> IO (FunPtr C_ContainerSetFocusChildCallback)
- noContainerSetFocusChildCallback :: Maybe ContainerSetFocusChildCallback
- onContainerSetFocusChild :: (IsContainer a, MonadIO m) => a -> ContainerSetFocusChildCallback -> m SignalHandlerId
- wrap_ContainerSetFocusChildCallback :: ContainerSetFocusChildCallback -> C_ContainerSetFocusChildCallback
Exported types
Memory-managed wrapper type.
Instances
Eq Container Source # | |
GObject Container Source # | |
Defined in GI.Gtk.Objects.Container | |
ManagedPtrNewtype Container Source # | |
Defined in GI.Gtk.Objects.Container toManagedPtr :: Container -> ManagedPtr Container | |
TypedObject Container Source # | |
Defined in GI.Gtk.Objects.Container | |
HasParentTypes Container Source # | |
Defined in GI.Gtk.Objects.Container | |
IsGValue (Maybe Container) Source # | Convert |
Defined in GI.Gtk.Objects.Container gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Container -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Container) | |
type ParentTypes Container Source # | |
Defined in GI.Gtk.Objects.Container |
class (GObject o, IsDescendantOf Container o) => IsContainer o Source #
Type class for types which can be safely cast to Container
, for instance with toContainer
.
Instances
(GObject o, IsDescendantOf Container o) => IsContainer o Source # | |
Defined in GI.Gtk.Objects.Container |
toContainer :: (MonadIO m, IsContainer o) => o -> m Container Source #
Methods
Click to display all available methods, including inherited ones
Methods
activate, add, addAccelerator, addChild, addDeviceEvents, addEvents, addMnemonicLabel, addTickCallback, bindProperty, bindPropertyFull, canActivateAccel, checkResize, childFocus, childGetProperty, childNotify, childNotifyByPspec, childSetProperty, childType, classPath, computeExpand, constructChild, createPangoContext, createPangoLayout, customFinished, customTagEnd, customTagStart, destroy, destroyed, deviceIsShadowed, dragBegin, dragBeginWithCoordinates, dragCheckThreshold, dragDestAddImageTargets, dragDestAddTextTargets, dragDestAddUriTargets, dragDestFindTarget, dragDestGetTargetList, dragDestGetTrackMotion, dragDestSet, dragDestSetProxy, dragDestSetTargetList, dragDestSetTrackMotion, dragDestUnset, dragGetData, dragHighlight, dragSourceAddImageTargets, dragSourceAddTextTargets, dragSourceAddUriTargets, dragSourceGetTargetList, dragSourceSet, dragSourceSetIconGicon, dragSourceSetIconName, dragSourceSetIconPixbuf, dragSourceSetIconStock, dragSourceSetTargetList, dragSourceUnset, dragUnhighlight, draw, ensureStyle, errorBell, event, forall, forceFloating, foreach, freezeChildNotify, freezeNotify, getv, grabAdd, grabDefault, grabFocus, grabRemove, hasDefault, hasFocus, hasGrab, hasRcStyle, hasScreen, hasVisibleFocus, hide, hideOnDelete, inDestruction, initTemplate, inputShapeCombineRegion, insertActionGroup, intersect, isAncestor, isComposited, isDrawable, isFloating, isFocus, isSensitive, isToplevel, isVisible, keynavFailed, listAccelClosures, listActionPrefixes, listMnemonicLabels, map, mnemonicActivate, modifyBase, modifyBg, modifyCursor, modifyFg, modifyFont, modifyStyle, modifyText, notify, notifyByPspec, overrideBackgroundColor, overrideColor, overrideCursor, overrideFont, overrideSymbolicColor, parserFinished, path, propagateDraw, queueAllocate, queueComputeExpand, queueDraw, queueDrawArea, queueDrawRegion, queueResize, queueResizeNoRedraw, realize, ref, refSink, regionIntersect, registerWindow, remove, removeAccelerator, removeMnemonicLabel, removeTickCallback, renderIcon, renderIconPixbuf, reparent, resetRcStyles, resetStyle, resizeChildren, runDispose, sendExpose, sendFocusChange, shapeCombineRegion, show, showAll, showNow, sizeAllocate, sizeAllocateWithBaseline, sizeRequest, stealData, stealQdata, styleAttach, styleGetProperty, thawChildNotify, thawNotify, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unref, unregisterWindow, unsetFocusChain, unsetStateFlags, watchClosure.
Getters
getAccessible, getActionGroup, getAllocatedBaseline, getAllocatedHeight, getAllocatedSize, getAllocatedWidth, getAllocation, getAncestor, getAppPaintable, getBorderWidth, getCanDefault, getCanFocus, getChildRequisition, getChildVisible, getChildren, getClip, getClipboard, getCompositeName, getData, getDeviceEnabled, getDeviceEvents, getDirection, getDisplay, getDoubleBuffered, getEvents, getFocusChain, getFocusChild, getFocusHadjustment, getFocusOnClick, getFocusVadjustment, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHasWindow, getHexpand, getHexpandSet, getInternalChild, getMapped, getMarginBottom, getMarginEnd, getMarginLeft, getMarginRight, getMarginStart, getMarginTop, getModifierMask, getModifierStyle, getName, getNoShowAll, getOpacity, getPangoContext, getParent, getParentWindow, getPath, getPathForChild, getPointer, getPreferredHeight, getPreferredHeightAndBaselineForWidth, getPreferredHeightForWidth, getPreferredSize, getPreferredWidth, getPreferredWidthForHeight, getProperty, getQdata, getRealized, getReceivesDefault, getRequestMode, getRequisition, getResizeMode, getRootWindow, getScaleFactor, getScreen, getSensitive, getSettings, getSizeRequest, getState, getStateFlags, getStyle, getStyleContext, getSupportMultidevice, getTemplateChild, getTooltipMarkup, getTooltipText, getTooltipWindow, getToplevel, getValign, getValignWithBaseline, getVexpand, getVexpandSet, getVisible, getVisual, getWindow.
Setters
setAccelPath, setAllocation, setAppPaintable, setBorderWidth, setBuildableProperty, setCanDefault, setCanFocus, setChildVisible, setClip, setCompositeName, setData, setDataFull, setDeviceEnabled, setDeviceEvents, setDirection, setDoubleBuffered, setEvents, setFocusChain, setFocusChild, setFocusHadjustment, setFocusOnClick, setFocusVadjustment, setFontMap, setFontOptions, setHalign, setHasTooltip, setHasWindow, setHexpand, setHexpandSet, setMapped, setMarginBottom, setMarginEnd, setMarginLeft, setMarginRight, setMarginStart, setMarginTop, setName, setNoShowAll, setOpacity, setParent, setParentWindow, setProperty, setRealized, setReallocateRedraws, setReceivesDefault, setRedrawOnAllocate, setResizeMode, setSensitive, setSizeRequest, setState, setStateFlags, setStyle, setSupportMultidevice, setTooltipMarkup, setTooltipText, setTooltipWindow, setValign, setVexpand, setVexpandSet, setVisible, setVisual, setWindow.
add
:: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) | |
=> a |
|
-> b |
|
-> m () |
Adds widget
to container
. Typically used for simple containers
such as Window
, Frame
, or Button
; for more complicated
layout containers such as Box
or Grid
, this function will
pick default packing parameters that may not be correct. So
consider functions such as boxPackStart
and
gridAttach
as an alternative to containerAdd
in
those cases. A widget may be added to only one container at a time;
you can’t place the same widget inside two different containers.
Note that some containers, such as ScrolledWindow
or ListBox
,
may add intermediate children between the added widget and the
container.
checkResize
containerCheckResize :: (HasCallStack, MonadIO m, IsContainer a) => a -> m () Source #
No description available in the introspection data.
childGetProperty
containerChildGetProperty Source #
:: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) | |
=> a |
|
-> b |
|
-> Text |
|
-> GValue |
|
-> m () |
Gets the value of a child property for child
and container
.
childNotify
:: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) | |
=> a |
|
-> b |
|
-> Text |
|
-> m () |
Emits a childNotify signal for the
[child property][child-properties]
childProperty
on the child.
This is an analogue of objectNotify
for child properties.
Also see widgetChildNotify
.
Since: 3.2
childNotifyByPspec
containerChildNotifyByPspec Source #
:: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) | |
=> a |
|
-> b |
|
-> GParamSpec |
|
-> m () |
Emits a childNotify signal for the
[child property][child-properties] specified by
pspec
on the child.
This is an analogue of objectNotifyByPspec
for child properties.
Since: 3.18
childSetProperty
containerChildSetProperty Source #
:: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) | |
=> a |
|
-> b |
|
-> Text |
|
-> GValue |
|
-> m () |
Sets a child property for child
and container
.
childType
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> m GType | Returns: a |
Returns the type of the children supported by the container.
Note that this may return G_TYPE_NONE
to indicate that no more
children can be added, e.g. for a Paned
which already has two
children.
forall
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> Callback |
|
-> m () |
Invokes callback
on each direct child of container
, including
children that are considered “internal” (implementation details
of the container). “Internal” children generally weren’t added
by the user of the container, but were added by the container
implementation itself.
Most applications should use containerForeach
, rather
than containerForall
.
foreach
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> Callback |
|
-> m () |
Invokes callback
on each non-internal child of container
.
See containerForall
for details on what constitutes
an “internal” child. For all practical purposes, this function
should iterate over precisely those child widgets that were
added to the container by the application with explicit add()
calls.
It is permissible to remove the child from the callback
handler.
Most applications should use containerForeach
,
rather than containerForall
.
getBorderWidth
containerGetBorderWidth Source #
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> m Word32 | Returns: the current border width |
Retrieves the border width of the container. See
containerSetBorderWidth
.
getChildren
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> m [Widget] | Returns: a newly-allocated list of the container’s non-internal children. |
Returns the container’s non-internal children. See
containerForall
for details on what constitutes an "internal" child.
getFocusChain
containerGetFocusChain Source #
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> m (Bool, [Widget]) | Returns: |
Deprecated: (Since version 3.24)For overriding focus behavior, use the GtkWidgetClass[focus](#g:signal:focus) signal.
Retrieves the focus chain of the container, if one has been
set explicitly. If no focus chain has been explicitly
set, GTK+ computes the focus chain based on the positions
of the children. In that case, GTK+ stores Nothing
in
focusableWidgets
and returns False
.
getFocusChild
containerGetFocusChild Source #
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> m (Maybe Widget) | Returns: The child widget which will receive the
focus inside |
Returns the current focus child widget inside container
. This is not the
currently focused widget. That can be obtained by calling
windowGetFocus
.
Since: 2.14
getFocusHadjustment
containerGetFocusHadjustment Source #
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> m (Maybe Adjustment) | Returns: the horizontal focus adjustment, or |
Retrieves the horizontal focus adjustment for the container. See gtk_container_set_focus_hadjustment ().
getFocusVadjustment
containerGetFocusVadjustment Source #
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> m (Maybe Adjustment) | Returns: the vertical focus adjustment, or
|
Retrieves the vertical focus adjustment for the container. See
containerSetFocusVadjustment
.
getPathForChild
containerGetPathForChild Source #
:: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) | |
=> a |
|
-> b |
|
-> m WidgetPath | Returns: A newly created |
Returns a newly created widget path representing all the widget hierarchy
from the toplevel down to and including child
.
getResizeMode
containerGetResizeMode Source #
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> m ResizeMode | Returns: the current resize mode |
Deprecated: (Since version 3.12)Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.
Returns the resize mode for the container. See gtk_container_set_resize_mode ().
propagateDraw
containerPropagateDraw Source #
:: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) | |
=> a |
|
-> b |
|
-> Context |
|
-> m () |
When a container receives a call to the draw function, it must send
synthetic draw calls to all children that don’t have their
own GdkWindows
. This function provides a convenient way of doing this.
A container, when it receives a call to its draw function,
calls containerPropagateDraw
once for each child, passing in
the cr
the container received.
containerPropagateDraw
takes care of translating the origin of cr
,
and deciding whether the draw needs to be sent to the child. It is a
convenient and optimized way of getting the same effect as calling
widgetDraw
on the child directly.
In most cases, a container can simply either inherit the
draw implementation from Container
, or do some drawing
and then chain to the draw implementation from Container
.
remove
:: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) | |
=> a |
|
-> b |
|
-> m () |
Removes widget
from container
. widget
must be inside container
.
Note that container
will own a reference to widget
, and that this
may be the last reference held; so removing a widget from its
container can destroy that widget. If you want to use widget
again, you need to add a reference to it before removing it from
a container, using objectRef
. If you don’t want to use widget
again it’s usually more efficient to simply destroy it directly
using widgetDestroy
since this will remove it from the
container and help break any circular reference count cycles.
resizeChildren
containerResizeChildren Source #
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> m () |
Deprecated: (Since version 3.10)
No description available in the introspection data.
setBorderWidth
containerSetBorderWidth Source #
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> Word32 |
|
-> m () |
Sets the border width of the container.
The border width of a container is the amount of space to leave
around the outside of the container. The only exception to this is
Window
; because toplevel windows can’t leave space outside,
they leave the space inside. The border is added on all sides of
the container. To add space to only one side, use a specific
Widget
:margin
property on the child widget, for example
Widget
:margin-top
.
setFocusChain
containerSetFocusChain Source #
:: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) | |
=> a |
|
-> [b] |
|
-> m () |
Deprecated: (Since version 3.24)For overriding focus behavior, use the GtkWidgetClass[focus](#g:signal:focus) signal.
Sets a focus chain, overriding the one computed automatically by GTK+.
In principle each widget in the chain should be a descendant of the container, but this is not enforced by this method, since it’s allowed to set the focus chain before you pack the widgets, or have a widget in the chain that isn’t always packed. The necessary checks are done when the focus chain is actually traversed.
setFocusChild
containerSetFocusChild Source #
:: (HasCallStack, MonadIO m, IsContainer a, IsWidget b) | |
=> a |
|
-> Maybe b | |
-> m () |
Sets, or unsets if child
is Nothing
, the focused child of container
.
This function emits the GtkContainer[set_focus_child](#g:signal:set_focus_child) signal of
container
. Implementations of Container
can override the
default behaviour by overriding the class closure of this signal.
This is function is mostly meant to be used by widgets. Applications can use
widgetGrabFocus
to manually set the focus to a specific widget.
setFocusHadjustment
containerSetFocusHadjustment Source #
:: (HasCallStack, MonadIO m, IsContainer a, IsAdjustment b) | |
=> a |
|
-> b |
|
-> m () |
Hooks up an adjustment to focus handling in a container, so when a child
of the container is focused, the adjustment is scrolled to show that
widget. This function sets the horizontal alignment.
See scrolledWindowGetHadjustment
for a typical way of obtaining
the adjustment and containerSetFocusVadjustment
for setting
the vertical adjustment.
The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the container.
setFocusVadjustment
containerSetFocusVadjustment Source #
:: (HasCallStack, MonadIO m, IsContainer a, IsAdjustment b) | |
=> a |
|
-> b |
|
-> m () |
Hooks up an adjustment to focus handling in a container, so when a
child of the container is focused, the adjustment is scrolled to
show that widget. This function sets the vertical alignment. See
scrolledWindowGetVadjustment
for a typical way of obtaining
the adjustment and containerSetFocusHadjustment
for setting
the horizontal adjustment.
The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the container.
setReallocateRedraws
containerSetReallocateRedraws Source #
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> Bool |
|
-> m () |
Deprecated: (Since version 3.14)Call widgetQueueDraw
in your size_allocate handler.
Sets the reallocateRedraws
flag of the container to the given value.
Containers requesting reallocation redraws get automatically redrawn if any of their children changed allocation.
setResizeMode
containerSetResizeMode Source #
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> ResizeMode |
|
-> m () |
Deprecated: (Since version 3.12)Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.
Sets the resize mode for the container.
The resize mode of a container determines whether a resize request will be passed to the container’s parent, queued for later execution or executed immediately.
unsetFocusChain
containerUnsetFocusChain Source #
:: (HasCallStack, MonadIO m, IsContainer a) | |
=> a |
|
-> m () |
Deprecated: (Since version 3.24)For overriding focus behavior, use the GtkWidgetClass[focus](#g:signal:focus) signal.
Removes a focus chain explicitly set with containerSetFocusChain
.
Properties
borderWidth
No description available in the introspection data.
constructContainerBorderWidth :: (IsContainer o, MonadIO m) => Word32 -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “border-width
” property. This is rarely needed directly, but it is used by new
.
getContainerBorderWidth :: (MonadIO m, IsContainer o) => o -> m Word32 Source #
Get the value of the “border-width
” property.
When overloading is enabled, this is equivalent to
get
container #borderWidth
setContainerBorderWidth :: (MonadIO m, IsContainer o) => o -> Word32 -> m () Source #
Set the value of the “border-width
” property.
When overloading is enabled, this is equivalent to
set
container [ #borderWidth:=
value ]
child
No description available in the introspection data.
clearContainerChild :: (MonadIO m, IsContainer o) => o -> m () Source #
Set the value of the “child
” property to Nothing
.
When overloading is enabled, this is equivalent to
clear
#child
constructContainerChild :: (IsContainer o, MonadIO m, IsWidget a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “child
” property. This is rarely needed directly, but it is used by new
.
setContainerChild :: (MonadIO m, IsContainer o, IsWidget a) => o -> a -> m () Source #
Set the value of the “child
” property.
When overloading is enabled, this is equivalent to
set
container [ #child:=
value ]
resizeMode
No description available in the introspection data.
constructContainerResizeMode :: (IsContainer o, MonadIO m) => ResizeMode -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “resize-mode
” property. This is rarely needed directly, but it is used by new
.
getContainerResizeMode :: (MonadIO m, IsContainer o) => o -> m ResizeMode Source #
Get the value of the “resize-mode
” property.
When overloading is enabled, this is equivalent to
get
container #resizeMode
setContainerResizeMode :: (MonadIO m, IsContainer o) => o -> ResizeMode -> m () Source #
Set the value of the “resize-mode
” property.
When overloading is enabled, this is equivalent to
set
container [ #resizeMode:=
value ]
Signals
add
type C_ContainerAddCallback = Ptr () -> Ptr Widget -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type ContainerAddCallback = Widget -> IO () Source #
No description available in the introspection data.
afterContainerAdd :: (IsContainer a, MonadIO m) => a -> ContainerAddCallback -> m SignalHandlerId Source #
Connect a signal handler for the add signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
container #add callback
genClosure_ContainerAdd :: MonadIO m => ContainerAddCallback -> m (GClosure C_ContainerAddCallback) Source #
Wrap the callback into a GClosure
.
mk_ContainerAddCallback :: C_ContainerAddCallback -> IO (FunPtr C_ContainerAddCallback) Source #
Generate a function pointer callable from C code, from a C_ContainerAddCallback
.
noContainerAddCallback :: Maybe ContainerAddCallback Source #
A convenience synonym for
.Nothing
:: Maybe
ContainerAddCallback
onContainerAdd :: (IsContainer a, MonadIO m) => a -> ContainerAddCallback -> m SignalHandlerId Source #
Connect a signal handler for the add signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
container #add callback
wrap_ContainerAddCallback :: ContainerAddCallback -> C_ContainerAddCallback Source #
Wrap a ContainerAddCallback
into a C_ContainerAddCallback
.
checkResize
type C_ContainerCheckResizeCallback = Ptr () -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type ContainerCheckResizeCallback = IO () Source #
No description available in the introspection data.
afterContainerCheckResize :: (IsContainer a, MonadIO m) => a -> ContainerCheckResizeCallback -> m SignalHandlerId Source #
Connect a signal handler for the checkResize signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
container #checkResize callback
genClosure_ContainerCheckResize :: MonadIO m => ContainerCheckResizeCallback -> m (GClosure C_ContainerCheckResizeCallback) Source #
Wrap the callback into a GClosure
.
mk_ContainerCheckResizeCallback :: C_ContainerCheckResizeCallback -> IO (FunPtr C_ContainerCheckResizeCallback) Source #
Generate a function pointer callable from C code, from a C_ContainerCheckResizeCallback
.
noContainerCheckResizeCallback :: Maybe ContainerCheckResizeCallback Source #
A convenience synonym for
.Nothing
:: Maybe
ContainerCheckResizeCallback
onContainerCheckResize :: (IsContainer a, MonadIO m) => a -> ContainerCheckResizeCallback -> m SignalHandlerId Source #
Connect a signal handler for the checkResize signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
container #checkResize callback
wrap_ContainerCheckResizeCallback :: ContainerCheckResizeCallback -> C_ContainerCheckResizeCallback Source #
Wrap a ContainerCheckResizeCallback
into a C_ContainerCheckResizeCallback
.
remove
type C_ContainerRemoveCallback = Ptr () -> Ptr Widget -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type ContainerRemoveCallback = Widget -> IO () Source #
No description available in the introspection data.
afterContainerRemove :: (IsContainer a, MonadIO m) => a -> ContainerRemoveCallback -> m SignalHandlerId Source #
Connect a signal handler for the remove signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
container #remove callback
genClosure_ContainerRemove :: MonadIO m => ContainerRemoveCallback -> m (GClosure C_ContainerRemoveCallback) Source #
Wrap the callback into a GClosure
.
mk_ContainerRemoveCallback :: C_ContainerRemoveCallback -> IO (FunPtr C_ContainerRemoveCallback) Source #
Generate a function pointer callable from C code, from a C_ContainerRemoveCallback
.
noContainerRemoveCallback :: Maybe ContainerRemoveCallback Source #
A convenience synonym for
.Nothing
:: Maybe
ContainerRemoveCallback
onContainerRemove :: (IsContainer a, MonadIO m) => a -> ContainerRemoveCallback -> m SignalHandlerId Source #
Connect a signal handler for the remove signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
container #remove callback
wrap_ContainerRemoveCallback :: ContainerRemoveCallback -> C_ContainerRemoveCallback Source #
Wrap a ContainerRemoveCallback
into a C_ContainerRemoveCallback
.
setFocusChild
type C_ContainerSetFocusChildCallback = Ptr () -> Ptr Widget -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type ContainerSetFocusChildCallback = Widget -> IO () Source #
No description available in the introspection data.
afterContainerSetFocusChild :: (IsContainer a, MonadIO m) => a -> ContainerSetFocusChildCallback -> m SignalHandlerId Source #
Connect a signal handler for the setFocusChild signal, to be run after the default handler. When overloading is enabled, this is equivalent to
after
container #setFocusChild callback
genClosure_ContainerSetFocusChild :: MonadIO m => ContainerSetFocusChildCallback -> m (GClosure C_ContainerSetFocusChildCallback) Source #
Wrap the callback into a GClosure
.
mk_ContainerSetFocusChildCallback :: C_ContainerSetFocusChildCallback -> IO (FunPtr C_ContainerSetFocusChildCallback) Source #
Generate a function pointer callable from C code, from a C_ContainerSetFocusChildCallback
.
noContainerSetFocusChildCallback :: Maybe ContainerSetFocusChildCallback Source #
A convenience synonym for
.Nothing
:: Maybe
ContainerSetFocusChildCallback
onContainerSetFocusChild :: (IsContainer a, MonadIO m) => a -> ContainerSetFocusChildCallback -> m SignalHandlerId Source #
Connect a signal handler for the setFocusChild signal, to be run before the default handler. When overloading is enabled, this is equivalent to
on
container #setFocusChild callback