Trait gtk::prelude::ContainerExt [−][src]
pub trait ContainerExt: 'static {}Show methods
fn add<P: IsA<Widget>>(&self, widget: &P); fn check_resize(&self); fn child_notify<P: IsA<Widget>>(&self, child: &P, child_property: &str); fn child_notify_by_pspec<P: IsA<Widget>>(
&self,
child: &P,
pspec: &ParamSpec
); fn child_type(&self) -> Type; fn forall<P: FnMut(&Widget)>(&self, callback: P); fn foreach<P: FnMut(&Widget)>(&self, callback: P); fn border_width(&self) -> u32; fn children(&self) -> Vec<Widget>; fn focus_child(&self) -> Option<Widget>; fn focus_hadjustment(&self) -> Option<Adjustment>; fn focus_vadjustment(&self) -> Option<Adjustment>; fn path_for_child<P: IsA<Widget>>(&self, child: &P) -> Option<WidgetPath>; fn propagate_draw<P: IsA<Widget>>(&self, child: &P, cr: &Context); fn remove<P: IsA<Widget>>(&self, widget: &P); fn set_border_width(&self, border_width: u32); fn set_focus_chain(&self, focusable_widgets: &[Widget]); fn set_focus_child<P: IsA<Widget>>(&self, child: Option<&P>); fn set_focus_hadjustment<P: IsA<Adjustment>>(&self, adjustment: &P); fn set_focus_vadjustment<P: IsA<Adjustment>>(&self, adjustment: &P); fn unset_focus_chain(&self); fn set_child<P: IsA<Widget>>(&self, child: Option<&P>); fn resize_mode(&self) -> ResizeMode; fn set_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; fn connect_set_focus_child<F: Fn(&Self, &Widget) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_border_width_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_child_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId; fn connect_resize_mode_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId;
Expand description
Required methods
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 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)
Emits a signal::Widget::child-notify
signal for the
[child property][child-properties]
child_property
on the child.
This is an analogue of [ObjectExtManual::notify()
][crate::glib::prelude::ObjectExtManual::notify()] for child properties.
Also see WidgetExt::child_notify()
.
child
the child widget
child_property
the name of a child property installed on
the class of self
Emits a signal::Widget::child-notify
signal for the
[child property][child-properties] specified by
pspec
on the child.
This is an analogue of [ObjectExtManual::notify_by_pspec()
][crate::glib::prelude::ObjectExtManual::notify_by_pspec()] for child properties.
child
the child widget
pspec
the glib::ParamSpec
of a child property instealled on
the class of self
fn child_type(&self) -> Type
fn child_type(&self) -> Type
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 foreach()
, rather
than forall()
.
callback
a callback
callback_data
callback user data
Invokes callback
on each non-internal child of self
.
See 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 foreach()
,
rather than forall()
.
callback
a callback
callback_data
callback user data
fn border_width(&self) -> u32
fn border_width(&self) -> u32
Retrieves the border width of the container. See
set_border_width()
.
Returns
the current border width
fn focus_child(&self) -> Option<Widget>
fn 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::focus()
.
Returns
The child widget which will receive the
focus inside self
when the self
is focused,
or None
if none is set.
fn focus_hadjustment(&self) -> Option<Adjustment>
fn focus_hadjustment(&self) -> Option<Adjustment>
fn focus_vadjustment(&self) -> Option<Adjustment>
fn focus_vadjustment(&self) -> Option<Adjustment>
Retrieves the vertical focus adjustment for the container. See
set_focus_vadjustment()
.
Returns
the vertical focus adjustment, or
None
if none has been set.
fn path_for_child<P: IsA<Widget>>(&self, child: &P) -> Option<WidgetPath>
fn 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
When a container receives a call to the draw function, it must send
synthetic signal::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 signal::Widget::draw
function,
calls propagate_draw()
once for each child, passing in
the cr
the container received.
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
signal::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.
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 g_object_ref()
. If you don’t want to use widget
again it’s usually more efficient to simply destroy it directly
using gtk_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)
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
property::Widget::margin
property on the child widget, for example
property::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])
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 GtkWidgetClass::focus signal.
focusable_widgets
the new focus chain
Sets, or unsets if child
is None
, the focused child of self
.
This function emits the GtkContainer::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
fn set_focus_hadjustment<P: IsA<Adjustment>>(&self, adjustment: &P)
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::hadjustment()
for a typical way of obtaining
the adjustment and 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)
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::vadjustment()
for a typical way of obtaining
the adjustment and 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)
fn unset_focus_chain(&self)
Removes a focus chain explicitly set with set_focus_chain()
.
Deprecated since 3.24
For overriding focus behavior, use the GtkWidgetClass::focus signal.
fn resize_mode(&self) -> ResizeMode
fn set_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
fn connect_set_focus_child<F: Fn(&Self, &Widget) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_border_width_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_child_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_resize_mode_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId