[−][src]Trait gtk::ContainerExt
Trait containing all Container methods.
Implementors
Bin, Box, Container, Fixed, FlowBox, Grid, HeaderBar, IconView, Layout, ListBox, MenuShell, Notebook, Paned, Socket, Stack, TextView, ToolItemGroup, ToolPalette, Toolbar, TreeView
Required methods
fn add<P: IsA<Widget>>(&self, widget: &P)
Adds widget to self. 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 BoxExt::pack_start and
GridExt::attach as an alternative to ContainerExt::add 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.
widget
a widget to be placed inside self
fn check_resize(&self)
fn child_notify<P: IsA<Widget>>(&self, child: &P, child_property: &str)
Emits a Widget::child-notify signal for the
child property
child_property on widget.
This is an analogue of gobject::Object::notify for child properties.
Also see Widget::child_notify.
child
the child widget
child_property
the name of a child property installed on
the class of self
fn child_notify_by_pspec<P: IsA<Widget>>(&self, child: &P, pspec: &ParamSpec)
Emits a Widget::child-notify signal for the
[child property][child-properties] specified by
pspec on the child.
This is an analogue of gobject::ObjectExt::notify_by_pspec for child properties.
Feature: v3_18
child
the child widget
pspec
the gobject::ParamSpec of a child property instealled on
the class of self
fn child_type(&self) -> Type
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.
Returns
a glib::Type.
fn forall<P: FnMut(&Widget)>(&self, callback: P)
Invokes callback on each direct child of self, 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 ContainerExt::foreach, rather
than ContainerExt::forall.
callback
a callback
callback_data
callback user data
fn foreach<P: FnMut(&Widget)>(&self, callback: P)
Invokes callback on each non-internal child of self.
See ContainerExt::forall 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 ContainerExt::foreach,
rather than ContainerExt::forall.
callback
a callback
callback_data
callback user data
fn get_border_width(&self) -> u32
Retrieves the border width of the container. See
ContainerExt::set_border_width.
Returns
the current border width
fn get_children(&self) -> Vec<Widget>
Returns the container’s non-internal children. See
ContainerExt::forall for details on what constitutes an "internal" child.
Returns
a newly-allocated list of the container’s non-internal children.
fn get_focus_child(&self) -> Option<Widget>
Returns the current focus child widget inside self. This is not the
currently focused widget. That can be obtained by calling
GtkWindowExt::get_focus.
Returns
The child widget which will receive the
focus inside self when the self is focused,
or None if none is set.
fn get_focus_hadjustment(&self) -> Option<Adjustment>
Retrieves the horizontal focus adjustment for the container. See gtk_container_set_focus_hadjustment ().
Returns
the horizontal focus adjustment, or None if
none has been set.
fn get_focus_vadjustment(&self) -> Option<Adjustment>
Retrieves the vertical focus adjustment for the container. See
ContainerExt::set_focus_vadjustment.
Returns
the vertical focus adjustment, or
None if none has been set.
fn get_path_for_child<P: IsA<Widget>>(&self, child: &P) -> Option<WidgetPath>
Returns a newly created widget path representing all the widget hierarchy
from the toplevel down to and including child.
child
a child of self
Returns
A newly created WidgetPath
fn propagate_draw<P: IsA<Widget>>(&self, child: &P, cr: &Context)
When a container receives a call to the draw function, it must send
synthetic Widget::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 Widget::draw function,
calls ContainerExt::propagate_draw once for each child, passing in
the cr the container received.
ContainerExt::propagate_draw 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
WidgetExt::draw on the child directly.
In most cases, a container can simply either inherit the
Widget::draw implementation from Container, or do some drawing
and then chain to the ::draw implementation from Container.
child
a child of self
cr
Cairo context as passed to the container. If you want to use cr
in container’s draw function, consider using cairo_save and
cairo_restore before calling this function.
fn remove<P: IsA<Widget>>(&self, widget: &P)
Removes widget from self. widget must be inside self.
Note that self 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 gobject::ObjectExt::ref. If you don’t want to use widget
again it’s usually more efficient to simply destroy it directly
using Widget::destroy since this will remove it from the
container and help break any circular reference count cycles.
widget
a current child of self
fn set_border_width(&self, border_width: u32)
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.
border_width
amount of blank space to leave outside the container. Valid values are in the range 0-65535 pixels.
fn set_focus_chain(&self, focusable_widgets: &[Widget])
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.
Deprecated since 3.24
For overriding focus behavior, use the
WidgetClass::focus signal.
focusable_widgets
the new focus chain
fn set_focus_child<P: IsA<Widget>>(&self, child: Option<&P>)
Sets, or unsets if child is None, the focused child of self.
This function emits the Container::set_focus_child signal of
self. 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
WidgetExt::grab_focus to manually set the focus to a specific widget.
child
a Widget, or None
fn set_focus_hadjustment<P: IsA<Adjustment>>(&self, adjustment: &P)
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 ScrolledWindowExt::get_hadjustment for a typical way of obtaining
the adjustment and ContainerExt::set_focus_vadjustment 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.
adjustment
an adjustment which should be adjusted when the focus is
moved among the descendents of self
fn set_focus_vadjustment<P: IsA<Adjustment>>(&self, adjustment: &P)
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
ScrolledWindowExt::get_vadjustment for a typical way of obtaining
the adjustment and ContainerExt::set_focus_hadjustment 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.
adjustment
an adjustment which should be adjusted when the focus
is moved among the descendents of self
fn unset_focus_chain(&self)
Removes a focus chain explicitly set with ContainerExt::set_focus_chain.
Deprecated since 3.24
For overriding focus behavior, use the
WidgetClass::focus signal.
fn set_property_child<P: IsA<Widget> + SetValueOptional>(
&self,
child: Option<&P>
)
&self,
child: Option<&P>
)
fn get_property_resize_mode(&self) -> ResizeMode
fn set_property_resize_mode(&self, resize_mode: ResizeMode)
fn connect_add<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_check_resize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_remove<F: Fn(&Self, &Widget) + 'static>(
&self,
f: F
) -> SignalHandlerId
&self,
f: F
) -> SignalHandlerId
fn connect_set_focus_child<F: Fn(&Self, &Widget) + 'static>(
&self,
f: F
) -> SignalHandlerId
&self,
f: F
) -> SignalHandlerId
fn connect_property_border_width_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
&self,
f: F
) -> SignalHandlerId
fn connect_property_child_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
&self,
f: F
) -> SignalHandlerId
fn connect_property_resize_mode_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
&self,
f: F
) -> SignalHandlerId
Implementors
impl<O: IsA<Container>> ContainerExt for O[src]
fn add<P: IsA<Widget>>(&self, widget: &P)[src]
fn check_resize(&self)[src]
fn child_notify<P: IsA<Widget>>(&self, child: &P, child_property: &str)[src]
fn child_notify_by_pspec<P: IsA<Widget>>(&self, child: &P, pspec: &ParamSpec)[src]
fn child_type(&self) -> Type[src]
fn forall<P: FnMut(&Widget)>(&self, callback: P)[src]
fn foreach<P: FnMut(&Widget)>(&self, callback: P)[src]
fn get_border_width(&self) -> u32[src]
fn get_children(&self) -> Vec<Widget>[src]
fn get_focus_child(&self) -> Option<Widget>[src]
fn get_focus_hadjustment(&self) -> Option<Adjustment>[src]
fn get_focus_vadjustment(&self) -> Option<Adjustment>[src]
fn get_path_for_child<P: IsA<Widget>>(&self, child: &P) -> Option<WidgetPath>[src]
fn propagate_draw<P: IsA<Widget>>(&self, child: &P, cr: &Context)[src]
fn remove<P: IsA<Widget>>(&self, widget: &P)[src]
fn set_border_width(&self, border_width: u32)[src]
fn set_focus_chain(&self, focusable_widgets: &[Widget])[src]
fn set_focus_child<P: IsA<Widget>>(&self, child: Option<&P>)[src]
fn set_focus_hadjustment<P: IsA<Adjustment>>(&self, adjustment: &P)[src]
fn set_focus_vadjustment<P: IsA<Adjustment>>(&self, adjustment: &P)[src]
fn unset_focus_chain(&self)[src]
fn set_property_child<P: IsA<Widget> + SetValueOptional>(
&self,
child: Option<&P>
)[src]
&self,
child: Option<&P>
)
fn get_property_resize_mode(&self) -> ResizeMode[src]
fn set_property_resize_mode(&self, resize_mode: ResizeMode)[src]
fn connect_add<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> SignalHandlerId[src]
fn connect_check_resize<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId[src]
fn connect_remove<F: Fn(&Self, &Widget) + 'static>(
&self,
f: F
) -> SignalHandlerId[src]
&self,
f: F
) -> SignalHandlerId
fn connect_set_focus_child<F: Fn(&Self, &Widget) + 'static>(
&self,
f: F
) -> SignalHandlerId[src]
&self,
f: F
) -> SignalHandlerId
fn connect_property_border_width_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId[src]
&self,
f: F
) -> SignalHandlerId
fn connect_property_child_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId[src]
&self,
f: F
) -> SignalHandlerId
fn connect_property_resize_mode_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId[src]
&self,
f: F
) -> SignalHandlerId