Trait gtk::ContainerExt [] [src]

pub trait ContainerExt {
    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_type(&self) -> Type;
    fn get_border_width(&self) -> u32;
    fn get_children(&self) -> Vec<Widget>;
    fn get_focus_child(&self) -> Option<Widget>;
    fn get_focus_hadjustment(&self) -> Option<Adjustment>;
    fn get_focus_vadjustment(&self) -> Option<Adjustment>;
    fn get_resize_mode(&self) -> ResizeMode;
    fn propagate_draw<P: IsA<Widget>>(&self, child: &P, cr: &Context);
    fn remove<P: IsA<Widget>>(&self, widget: &P);
    fn resize_children(&self);
    fn set_border_width(&self, border_width: u32);
    fn set_focus_chain(&self, focusable_widgets: &[Widget]);
    fn set_focus_child<'a, P: IsA<Widget> + 'a, Q: Into<Option<&'a P>>>(&self,
                                                                        child: Q); fn set_focus_hadjustment(&self, adjustment: &Adjustment); fn set_focus_vadjustment(&self, adjustment: &Adjustment); fn set_reallocate_redraws(&self, needs_redraws: bool); fn set_resize_mode(&self, resize_mode: ResizeMode); fn unset_focus_chain(&self); fn set_property_child(&self, child: Option<&Widget>); fn connect_add<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> u64; fn connect_check_resize<F: Fn(&Self) + 'static>(&self, f: F) -> u64; fn connect_remove<F: Fn(&Self, &Widget) + 'static>(&self, f: F) -> u64; fn connect_set_focus_child<F: Fn(&Self, &Widget) + 'static>(&self,
                                                                f: F)
                                                                -> u64; }

Trait containing all Container methods.

Implementors

Bin, Box, Container, Fixed, FlowBox, Grid, HeaderBar, IconView, Layout, ListBox, MenuShell, Notebook, Paned, Stack, TextView, ToolItemGroup, ToolPalette, Toolbar, TreeView

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 Grid::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

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

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.

Retrieves the border width of the container. See ContainerExt::set_border_width.

Returns

the current border width

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.

Returns the current focus child widget inside self. This is not the currently focused widget. That can be obtained by calling Window::get_focus.

Returns

The child widget which will receive the focus inside self when the conatiner is focussed, or None if none is set.

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.

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.

Returns the resize mode for the container. See gtk_container_set_resize_mode ().

Deprecated since 3.12

Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.

Returns

the current resize mode

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 Widget::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.

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 while it’s not inside a container, using gobject::Object::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

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.

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.

focusable_widgets

the new focus chain

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 Widget::grab_focus to manually set the focus to a specific widget.

child

a Widget, or None

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 ScrolledWindow::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

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 ScrolledWindow::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

Sets the reallocate_redraws flag of the container to the given value.

Containers requesting reallocation redraws get automatically redrawn if any of their children changed allocation.

Deprecated since 3.14

Call Widget::queue_draw in your size_allocate handler.

needs_redraws

the new value for the container’s reallocate_redraws flag

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.

Deprecated since 3.12

Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.

resize_mode

the new resize mode

Removes a focus chain explicitly set with ContainerExt::set_focus_chain.

Implementors