Class: Gtk::Container
- Inherits:
-
Object
- Object
- Gtk::Container
- Defined in:
- (unknown)
Overview
Base class for containers.
Instance Method Summary collapse
-
#add(widget) ⇒ nil
Adds widget to container.
-
#add_with_properties(widget, first_prop_name, array) ⇒ nil
Adds widget to container, setting child properties at the same time.
-
#border_width ⇒ Integer
Border-width.
- #border_width=(border_width) ⇒ Integer
- #check_resize ⇒ nil
-
#child=(child) ⇒ Gtk::Widget
Child.
-
#child_get(child, first_prop_name, array) ⇒ nil
Gets the values of one or more child properties for child and container.
-
#child_get_property(child, property_name, value) ⇒ nil
Gets the value of a child property for child and container.
-
#child_get_valist(child, first_property_name, var_args) ⇒ nil
Gets the values of one or more child properties for child and container.
-
#child_notify(child, child_property) ⇒ nil
Emits a Gtk::Widget::child-notify signal for the [child property] child_property on the child.
-
#child_notify_by_pspec(child, pspec) ⇒ nil
Emits a Gtk::Widget::child-notify signal for the [child property] specified by pspec on the child.
-
#child_set(child, first_prop_name, array) ⇒ nil
Sets one or more child properties for child and container.
-
#child_set_property(child, property_name, value) ⇒ nil
Sets a child property for child and container.
-
#child_set_valist(child, first_property_name, var_args) ⇒ nil
Sets one or more child properties for child and container.
-
#child_type ⇒ GLib::Type
Returns the type of the children supported by the container.
-
#children ⇒ GLib::List
Returns the container’s non-internal children.
-
#find_child_property(property_name) ⇒ GObject::ParamSpec
Finds a child property of a container class by name.
-
#focus_chain=(focusable_widgets) ⇒ nil
Sets a focus chain, overriding the one computed automatically by GTK+.
-
#focus_child ⇒ Gtk::Widget
Returns the current focus child widget inside container.
-
#focus_child=(child) ⇒ nil
Sets, or unsets if child is nil, the focused child of container.
-
#focus_hadjustment ⇒ Gtk::Adjustment
Retrieves the horizontal focus adjustment for the container.
-
#focus_hadjustment=(adjustment) ⇒ nil
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.
-
#focus_vadjustment ⇒ Gtk::Adjustment
Retrieves the vertical focus adjustment for the container.
-
#focus_vadjustment=(adjustment) ⇒ nil
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.
-
#forall(callback, callback_data) ⇒ nil
Invokes callback on each direct child of container, including children that are considered “internal” (implementation details of the container).
-
#foreach(callback, callback_data) ⇒ nil
Invokes callback on each non-internal child of container.
-
#get_focus_chain(focusable_widgets) ⇒ TrueClass
Retrieves the focus chain of the container, if one has been set explicitly.
-
#get_path_for_child(child) ⇒ Gtk::WidgetPath
Returns a newly created widget path representing all the widget hierarchy from the toplevel down to and including child.
-
#handle_border_width ⇒ nil
Modifies a subclass of Gtk::ContainerClass to automatically add and remove the border-width setting on GtkContainer.
-
#install_child_properties(n_pspecs, pspecs) ⇒ nil
Installs child properties on a container class.
-
#install_child_property(property_id, pspec) ⇒ nil
Installs a child property on a container class.
-
#list_child_properties(n_properties) ⇒ Array<GObject::ParamSpec>
Returns all child properties of a container class.
-
#propagate_draw(child, cr) ⇒ nil
When a container receives a call to the draw function, it must send synthetic Gtk::Widget::draw calls to all children that don’t have their own Gdk::Windows.
-
#reallocate_redraws=(needs_redraws) ⇒ nil
Sets the reallocate_redraws flag of the container to the given value.
-
#remove(widget) ⇒ nil
Removes widget from container.
- #resize_children ⇒ nil
-
#resize_mode ⇒ Gtk::ResizeMode
Resize-mode.
- #resize_mode=(resize_mode) ⇒ Gtk::ResizeMode
-
#unset_focus_chain ⇒ nil
Removes a focus chain explicitly set with gtk_container_set_focus_chain().
Instance Method Details
#add(widget) ⇒ nil
Adds widget to container. Typically used for simple containers such as Gtk::Window, #GtkFrame, or #GtkButton; for more complicated layout containers such as Gtk::Box or #GtkGrid, this function will pick default packing parameters that may not be correct. So consider functions such as gtk_box_pack_start() and gtk_grid_attach() as an alternative to gtk_container_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 Gtk::ScrolledWindow or #GtkListBox, may add intermediate children between the added widget and the container.
#add_with_properties(widget, first_prop_name, array) ⇒ nil
Adds widget to container, setting child properties at the same time. See gtk_container_add() and gtk_container_child_set() for more details.
#border_width ⇒ Integer
Returns border-width.
#border_width=(border_width) ⇒ Integer
#check_resize ⇒ nil
#child=(child) ⇒ Gtk::Widget
Returns child.
#child_get(child, first_prop_name, array) ⇒ nil
Gets the values of one or more child properties for child and container.
#child_get_property(child, property_name, value) ⇒ nil
Gets the value of a child property for child and container.
#child_get_valist(child, first_property_name, var_args) ⇒ nil
Gets the values of one or more child properties for child and container.
#child_notify(child, child_property) ⇒ nil
Emits a Gtk::Widget::child-notify signal for the
- child property][child-properties
-
child_property on the child.
This is an analogue of g_object_notify() for child properties.
Also see gtk_widget_child_notify().
#child_notify_by_pspec(child, pspec) ⇒ nil
Emits a Gtk::Widget::child-notify signal for the
- child property][child-properties
-
specified by
pspec on the child.
This is an analogue of g_object_notify_by_pspec() for child properties.
#child_set(child, first_prop_name, array) ⇒ nil
Sets one or more child properties for child and container.
#child_set_property(child, property_name, value) ⇒ nil
Sets a child property for child and container.
#child_set_valist(child, first_property_name, var_args) ⇒ nil
Sets one or more child properties for child and container.
#child_type ⇒ GLib::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 Gtk::Paned which already has two children.
#children ⇒ GLib::List
Returns the container’s non-internal children. See gtk_container_forall() for details on what constitutes an “internal” child.
#find_child_property(property_name) ⇒ GObject::ParamSpec
Finds a child property of a container class by name.
#focus_chain=(focusable_widgets) ⇒ nil
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.
#focus_child ⇒ Gtk::Widget
Returns the current focus child widget inside container. This is not the currently focused widget. That can be obtained by calling gtk_window_get_focus().
#focus_child=(child) ⇒ nil
Sets, or unsets if child is nil, the focused child of container.
This function emits the GtkContainer::set_focus_child signal of container. Implementations of Gtk::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 gtk_widget_grab_focus() to manually set the focus to a specific widget.
#focus_hadjustment ⇒ Gtk::Adjustment
Retrieves the horizontal focus adjustment for the container. See gtk_container_set_focus_hadjustment ().
#focus_hadjustment=(adjustment) ⇒ nil
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 gtk_scrolled_window_get_hadjustment() for a typical way of obtaining the adjustment and gtk_container_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.
#focus_vadjustment ⇒ Gtk::Adjustment
Retrieves the vertical focus adjustment for the container. See gtk_container_set_focus_vadjustment().
#focus_vadjustment=(adjustment) ⇒ nil
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 gtk_scrolled_window_get_vadjustment() for a typical way of obtaining the adjustment and gtk_container_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.
#forall(callback, callback_data) ⇒ nil
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 gtk_container_foreach(), rather than gtk_container_forall().
#foreach(callback, callback_data) ⇒ nil
Invokes callback on each non-internal child of container. See gtk_container_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 gtk_container_foreach(), rather than gtk_container_forall().
#get_focus_chain(focusable_widgets) ⇒ TrueClass
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 nil in focusable_widgets and returns false. has been set explicitly.
#get_path_for_child(child) ⇒ Gtk::WidgetPath
Returns a newly created widget path representing all the widget hierarchy from the toplevel down to and including child.
#handle_border_width ⇒ nil
Modifies a subclass of Gtk::ContainerClass to automatically add and remove the border-width setting on GtkContainer. This allows the subclass to ignore the border width in its size request and allocate methods. The intent is for a subclass to invoke this in its class_init function.
gtk_container_class_handle_border_width() is necessary because it would break API too badly to make this behavior the default. So subclasses must “opt in” to the parent class handling border_width for them.
#install_child_properties(n_pspecs, pspecs) ⇒ nil
Installs child properties on a container class.
#install_child_property(property_id, pspec) ⇒ nil
Installs a child property on a container class.
#list_child_properties(n_properties) ⇒ Array<GObject::ParamSpec>
Returns all child properties of a container class.
#propagate_draw(child, cr) ⇒ nil
When a container receives a call to the draw function, it must send synthetic Gtk::Widget::draw calls to all children that don’t have their own Gdk::Windows. This function provides a convenient way of doing this. A container, when it receives a call to its Gtk::Widget::draw function, calls gtk_container_propagate_draw() once for each child, passing in the cr the container received.
gtk_container_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 gtk_widget_draw() on the child directly.
In most cases, a container can simply either inherit the Gtk::Widget::draw implementation from #GtkContainer, or do some drawing and then chain to the ::draw implementation from Gtk::Container.
#reallocate_redraws=(needs_redraws) ⇒ nil
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.
#remove(widget) ⇒ nil
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 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.
#resize_children ⇒ nil
#resize_mode ⇒ Gtk::ResizeMode
Returns resize-mode.
#resize_mode=(resize_mode) ⇒ Gtk::ResizeMode
#unset_focus_chain ⇒ nil
Removes a focus chain explicitly set with gtk_container_set_focus_chain().