gtkmm: Gtk::Container Class Reference

gtkmm 3.5.4

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions | Related Functions
Gtk::Container Class Reference
Widgets

Abstract container class. More...

Inheritance diagram for Gtk::Container:
[legend]

List of all members.

## Public Types
typedef sigc::slot< void, Widget& > | ForeachSlot
| For instance, void on_foreach(Gtk::Widget* widget);.
## Public Member Functions
virtual | ~Container ()
GtkContainer* | gobj ()
| Provides access to the underlying C GtkObject.
const GtkContainer* | gobj () const
| Provides access to the underlying C GtkObject.
void | set_border_width (guint border_width)
| Sets the border width of the container.
guint | get_border_width () const
| Retrieves the border width of the container.
virtual void | add (Widget& widget)
void | remove (Widget& widget)
| Removes widget from container.
void | set_resize_mode (ResizeMode resize_mode)
| Sets the resize mode for the container.
ResizeMode | get_resize_mode () const
| Returns the resize mode for the container.
void | check_resize ()
| Request that contained widgets check their size.
void | foreach (const ForeachSlot& slot)
| Operate on contained items This is largely an internal used mainly for things like creating duplicates of internal lists and other such operations.
std::vector< Widget* > | get_children ()
| (internal) Operate on contained items (see foreach())
std::vector< const Widget* > | get_children () const
| Returns the container's non-internal children.
void | set_focus_chain (const std::vector< Widget* >& focusable_widgets)
| Sets a focus chain, overriding the one computed automatically by GTK+.
bool | has_focus_chain () const
std::vector< Widget* > | get_focus_chain ()
std::vector< const Widget* > | get_focus_chain () const
void | unset_focus_chain ()
| Removes a focus chain explicitly set with set_focus_chain().
void | set_reallocate_redraws (bool needs_redraws=true)
| Sets the reallocate_redraws flag of the container to the given value.
void | set_focus_child (Widget& widget)
| Sets the focus on a child.
void | set_focus_vadjustment (const Glib::RefPtr< Adjustment >& adjustment)
| 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.
Glib::RefPtr< Adjustment > | get_focus_vadjustment ()
| Retrieves the vertical focus adjustment for the container.
Glib::RefPtr< const Adjustment > | get_focus_vadjustment () const
| Retrieves the vertical focus adjustment for the container.
void | set_focus_hadjustment (const Glib::RefPtr< Adjustment >& adjustment)
| 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.
Glib::RefPtr< Adjustment > | get_focus_hadjustment ()
| Retrieves the horizontal focus adjustment for the container.
Glib::RefPtr< const Adjustment > | get_focus_hadjustment () const
| Retrieves the horizontal focus adjustment for the container.
void | resize_children ()
GType | child_type () const
| Returns the type of the children supported by the container.
Glib::SignalProxy1< void, Widget* > | signal_add ()
Glib::SignalProxy1< void, Widget* > | signal_remove ()
Glib::SignalProxy0< void > | signal_check_resize ()
Glib::SignalProxy1< void, Widget* > | signal_set_focus_child ()
void | show_all_children (bool recursive=true)
## Protected Member Functions
virtual void | on_add (Widget* widget)
| This is a default handler for the signal signal_add().
virtual void | on_remove (Widget* widget)
| This is a default handler for the signal signal_remove().
virtual void | on_check_resize ()
| This is a default handler for the signal signal_check_resize().
virtual void | on_set_focus_child (Widget* widget)
| This is a default handler for the signal signal_set_focus_child().
| Container ()
virtual GType | child_type_vfunc () const
| Implements child_type().
virtual void | forall_vfunc (gboolean include_internals, GtkCallback callback, gpointer callback_data)
| Invokes a callback on all children of the container.
virtual char* | composite_name_vfunc (GtkWidget* child)
| Returns the composite name of a child widget.
virtual void | set_child_property_vfunc (GtkWidget* child, guint property_id, const GValue*value, GParamSpec* pspec)
| Sets a child property for this container and its child.
virtual void | get_child_property_vfunc (GtkWidget* child, guint property_id, GValue*value, GParamSpec* pspec) const
| Returns a child property for this container and its child.
Glib::PropertyProxy< guint > | property_border_width ()
| The width of the empty border outside the containers children.
Glib::PropertyProxy_ReadOnly < guint > | property_border_width () const
| The width of the empty border outside the containers children.
Glib::PropertyProxy< ResizeMode > | property_resize_mode ()
| Specify how resize events are handled.
Glib::PropertyProxy_ReadOnly < ResizeMode > | property_resize_mode () const
| Specify how resize events are handled.
Glib::PropertyProxy_WriteOnly < Widget* > | property_child ()
| Can be used to add a new child to the container.
## Related Functions
(Note that these are not member functions.)
Gtk::Container* | wrap (GtkContainer* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

Abstract container class.

This is the abstract container from which all gtk+ widgets which hold other items derive from. It mainly houses virtual functions used for inserting and removing children. Containers in gtk+ may hold one item or many items depending on the implementation.

This interface is used for all single item holding containers. Multi-item containers provide their own unique interface as their items are generally more complex. The methods of the derived classes should be prefered over these.

## Member Typedef Documentation

typedef sigc::slot<void, Widget&> Gtk::Container::ForeachSlot

For instance, void on_foreach(Gtk::Widget* widget);.

## Constructor & Destructor Documentation

virtual Gtk::Container::~Container | ( |  | ) | `[virtual]`

Gtk::Container::Container | ( |  | ) | `[protected]`

## Member Function Documentation

virtual void Gtk::Container::add | ( | Widget& | widget | ) | `[virtual]`

Reimplemented in Gtk::ScrolledWindow.

void Gtk::Container::check_resize | ( |  | ) |

Request that contained widgets check their size.

GType Gtk::Container::child_type | ( |  | ) | const

Returns the type of the children supported by the container.

Note that this may return TYPE_NONE to indicate that no more children can be added, e.g. for a Gtk::Paned which already has two children.

Returns:
  A Type.

virtual GType Gtk::Container::child_type_vfunc | ( |  | ) | const`[protected, virtual]`

Implements child_type().

The default implementation returns G_TYPE_NONE

virtual char* Gtk::Container::composite_name_vfunc | ( | GtkWidget * | child | ) | `[protected, virtual]`

Returns the composite name of a child widget.

Composite widgets are children of the container 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.

The caller is responsible for freeing the returned string.

Parameters:

  child | The child widget.

Returns:
  The composite name of the child widget.

virtual void Gtk::Container::forall_vfunc | ( | gboolean | include_internals,
|  | GtkCallback | callback,
|  | gpointer | callback_data
| ) |  | `[protected, virtual]`

Invokes a callback on all children of the container.

The callback may optionally be invoked also on 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().

Parameters:

  include_internals |
  callback | A callback.
  callback_data | Callback user data

void Gtk::Container::foreach | ( | const ForeachSlot& | slot | ) |

Operate on contained items This is largely an internal used mainly for things like creating duplicates of internal lists and other such operations.

The result is lossy as it only gets the the main child and not its external pieces.

For example notebook pages contain a page, a label, and a menu item. But this only operates on the pages.

guint Gtk::Container::get_border_width | ( |  | ) | const

Retrieves the border width of the container.

See set_border_width().

Returns:
  The current border width.

virtual void Gtk::Container::get_child_property_vfunc | ( | GtkWidget * | child,
|  | guint | property_id,
|  | GValue * | value,
|  | GParamSpec * | pspec
| ) |  | const`[protected, virtual]`

Returns a child property for this container and its child.

Child properties 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 Gtk::Box.

Parameters:

  child | The child property.
  property_id | The ID of the child property to get.
  value | A GValue to fill with the child property's value.
  pspec |

std::vector<Widget*> Gtk::Container::get_children | ( |  | ) |

(internal) Operate on contained items (see foreach())

(internal) Operate on contained items (see foreach()) Returns the container's non-internal children. See forall() for details on what constitutes an "internal" child.

Returns:
  A newly-allocated list of the container's non-internal children.

std::vector<const Widget*> Gtk::Container::get_children | ( |  | ) | const

Returns the container's non-internal children.

See forall() for details on what constitutes an "internal" child.

Returns:
  A newly-allocated list of the container's non-internal children.

std::vector<Widget*> Gtk::Container::get_focus_chain | ( |  | ) |

std::vector<const Widget*> Gtk::Container::get_focus_chain | ( |  | ) | const

Glib::RefPtr<Adjustment> Gtk::Container::get_focus_hadjustment | ( |  | ) |

Retrieves the horizontal focus adjustment for the container.

See set_focus_hadjustment().

Returns:
  The horizontal focus adjustment, or `0` if none has been set.

Glib::RefPtr<const Adjustment> Gtk::Container::get_focus_hadjustment | ( |  | ) | const

Retrieves the horizontal focus adjustment for the container.

See set_focus_hadjustment().

Returns:
  The horizontal focus adjustment, or `0` if none has been set.

Glib::RefPtr<Adjustment> Gtk::Container::get_focus_vadjustment | ( |  | ) |

Retrieves the vertical focus adjustment for the container.

See set_focus_vadjustment().

Returns:
  The vertical focus adjustment, or `0` if none has been set.

Glib::RefPtr<const Adjustment> Gtk::Container::get_focus_vadjustment | ( |  | ) | const

Retrieves the vertical focus adjustment for the container.

See set_focus_vadjustment().

Returns:
  The vertical focus adjustment, or `0` if none has been set.

ResizeMode Gtk::Container::get_resize_mode | ( |  | ) | const

Returns the resize mode for the container.

See set_resize_mode().

Returns:
  The current resize mode.

GtkContainer* Gtk::Container::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Widget.

Reimplemented in Gtk::FontSelectionDialog, Gtk::ColorSelectionDialog, Gtk::TreeView, Gtk::Window, Gtk::HBox, Gtk::HButtonBox, Gtk::ToolPalette, Gtk::VPaned, Gtk::Dialog, Gtk::TextView, Gtk::IconView, Gtk::AboutDialog, Gtk::MessageDialog, Gtk::Box, Gtk::Socket, Gtk::Assistant, Gtk::MenuBar, Gtk::Notebook, Gtk::Table, Gtk::ComboBox, Gtk::Paned, Gtk::ButtonBox, Gtk::FontSelection, Gtk::Expander, Gtk::ColorSelection, Gtk::OffscreenWindow, Gtk::Grid, Gtk::InfoBar, Gtk::VButtonBox, Gtk::FileChooserButton, Gtk::ScrolledWindow, Gtk::LinkButton, Gtk::PrintUnixDialog, Gtk::AppChooserDialog, Gtk::HandleBox, Gtk::RecentChooserDialog, Gtk::VBox, Gtk::Button, Gtk::Layout, Gtk::ScaleButton, Gtk::HPaned, Gtk::Alignment, Gtk::ColorButton, Gtk::Toolbar, Gtk::AppChooserWidget, Gtk::Fixed, Gtk::FontButton, Gtk::Frame, Gtk::MenuItem, Gtk::RecentChooserMenu, Gtk::Statusbar, Gtk::MenuShell, Gtk::TearoffMenuItem, Gtk::AppChooserButton, Gtk::CheckButton, Gtk::EventBox, Gtk::FileChooserWidget, Gtk::FontChooserDialog, Gtk::FontChooserWidget, Gtk::Menu, Gtk::AspectFrame, Gtk::RadioButton, Gtk::RecentChooserWidget, Gtk::FileChooserDialog, Gtk::ImageMenuItem, Gtk::SeparatorToolItem, Gtk::ToolItem, Gtk::Bin, Gtk::ComboBoxText, Gtk::RadioToolButton, Gtk::ToggleToolButton, Gtk::ToolItemGroup, Gtk::VolumeButton, Gtk::RadioMenuItem, Gtk::PageSetupUnixDialog, Gtk::ColorChooserDialog, Gtk::Viewport, Gtk::CheckMenuItem, Gtk::MenuToolButton, Gtk::SeparatorMenuItem, Gtk::ToggleButton, Gtk::ApplicationWindow, Gtk::Plug, and Gtk::ToolButton.

const GtkContainer* Gtk::Container::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Widget.

Reimplemented in Gtk::FontSelectionDialog, Gtk::ColorSelectionDialog, Gtk::TreeView, Gtk::Window, Gtk::HBox, Gtk::HButtonBox, Gtk::ToolPalette, Gtk::VPaned, Gtk::Dialog, Gtk::TextView, Gtk::IconView, Gtk::AboutDialog, Gtk::MessageDialog, Gtk::Box, Gtk::Socket, Gtk::Assistant, Gtk::MenuBar, Gtk::Notebook, Gtk::Table, Gtk::ComboBox, Gtk::Paned, Gtk::ButtonBox, Gtk::FontSelection, Gtk::Expander, Gtk::ColorSelection, Gtk::OffscreenWindow, Gtk::Grid, Gtk::InfoBar, Gtk::VButtonBox, Gtk::FileChooserButton, Gtk::ScrolledWindow, Gtk::LinkButton, Gtk::PrintUnixDialog, Gtk::AppChooserDialog, Gtk::HandleBox, Gtk::RecentChooserDialog, Gtk::VBox, Gtk::Button, Gtk::Layout, Gtk::ScaleButton, Gtk::HPaned, Gtk::Alignment, Gtk::ColorButton, Gtk::Toolbar, Gtk::AppChooserWidget, Gtk::Fixed, Gtk::FontButton, Gtk::Frame, Gtk::MenuItem, Gtk::RecentChooserMenu, Gtk::Statusbar, Gtk::MenuShell, Gtk::TearoffMenuItem, Gtk::AppChooserButton, Gtk::CheckButton, Gtk::EventBox, Gtk::FileChooserWidget, Gtk::FontChooserDialog, Gtk::FontChooserWidget, Gtk::Menu, Gtk::AspectFrame, Gtk::RadioButton, Gtk::RecentChooserWidget, Gtk::FileChooserDialog, Gtk::ImageMenuItem, Gtk::SeparatorToolItem, Gtk::ToolItem, Gtk::Bin, Gtk::ComboBoxText, Gtk::RadioToolButton, Gtk::ToggleToolButton, Gtk::ToolItemGroup, Gtk::VolumeButton, Gtk::RadioMenuItem, Gtk::PageSetupUnixDialog, Gtk::ColorChooserDialog, Gtk::Viewport, Gtk::CheckMenuItem, Gtk::MenuToolButton, Gtk::SeparatorMenuItem, Gtk::ToggleButton, Gtk::ApplicationWindow, Gtk::Plug, and Gtk::ToolButton.

bool Gtk::Container::has_focus_chain | ( |  | ) | const

virtual void Gtk::Container::on_add | ( | Widget* | widget | ) | `[protected, virtual]`

This is a default handler for the signal signal_add().

virtual void Gtk::Container::on_check_resize | ( |  | ) | `[protected, virtual]`

This is a default handler for the signal signal_check_resize().

virtual void Gtk::Container::on_remove | ( | Widget* | widget | ) | `[protected, virtual]`

This is a default handler for the signal signal_remove().

virtual void Gtk::Container::on_set_focus_child | ( | Widget* | widget | ) | `[protected, virtual]`

This is a default handler for the signal signal_set_focus_child().

Glib::PropertyProxy< guint > Gtk::Container::property_border_width | ( |  | ) | `[protected]`

The width of the empty border outside the containers children.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< guint > Gtk::Container::property_border_width | ( |  | ) | const`[protected]`

The width of the empty border outside the containers children.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_WriteOnly< Widget* > Gtk::Container::property_child | ( |  | ) | `[protected]`

Can be used to add a new child to the container.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy< ResizeMode > Gtk::Container::property_resize_mode | ( |  | ) | `[protected]`

Specify how resize events are handled.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< ResizeMode > Gtk::Container::property_resize_mode | ( |  | ) | const`[protected]`

Specify how resize events are handled.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

void Gtk::Container::remove | ( | Widget& | widget | ) |

Removes widget from container.

widget must be inside container. If widget is managed with Gtk::manage(), and you don't want to use widget again then you should delete widget, because there will no longer be any parent container to delete it automatically.

Parameters:

  widget | A current child of container.

void Gtk::Container::resize_children | ( |  | ) |

void Gtk::Container::set_border_width | ( | guint | border_width | ) |

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 Gtk::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, one approach is to create a Gtk::Alignment widget, call Gtk::Widget::set_size_request() to give it a size, and place it on the side of the container as a spacer.

Parameters:

  border_width | Amount of blank space to leave outside the container. Valid values are in the range 0-65535 pixels.

virtual void Gtk::Container::set_child_property_vfunc | ( | GtkWidget * | child,
|  | guint | property_id,
|  | const GValue * | value,
|  | GParamSpec * | pspec
| ) |  | `[protected, virtual]`

Sets a child property for this container and its child.

Child properties 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 Gtk::Box.

Parameters:

  child | The child property.
  property_id | The ID of the child property to set.
  value | The new value for the child property.
  pspec |

void Gtk::Container::set_focus_chain | ( | const std::vector< Widget* >& | focusable_widgets | ) |

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.

Parameters:

  focusable_widgets | The new focus chain.

void Gtk::Container::set_focus_child | ( | Widget& | widget | ) |

Sets the focus on a child.

void Gtk::Container::set_focus_hadjustment | ( | const Glib::RefPtr< Adjustment >& | adjustment | ) |

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

Parameters:

  adjustment | An adjustment which should be adjusted when the focus is moved among the descendents of container.

void Gtk::Container::set_focus_vadjustment | ( | const Glib::RefPtr< Adjustment >& | adjustment | ) |

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

Parameters:

  adjustment | An adjustment which should be adjusted when the focus is moved among the descendents of container.

void Gtk::Container::set_reallocate_redraws | ( | bool | needs_redraws = `true` | ) |

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.

Parameters:

  needs_redraws | The new value for the container's reallocate_redraws flag.

void Gtk::Container::set_resize_mode | ( | ResizeMode | resize_mode | ) |

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.

Parameters:

  resize_mode | The new resize mode.

void Gtk::Container::show_all_children | ( | bool | recursive = `true` | ) |

Glib::SignalProxy1< void,Widget* > Gtk::Container::signal_add | ( |  | ) |

Slot Prototype:
  `void on_my_add(Widget* widget)`

Glib::SignalProxy0< void > Gtk::Container::signal_check_resize | ( |  | ) |

Slot Prototype:
  `void on_my_check_resize()`

Glib::SignalProxy1< void,Widget* > Gtk::Container::signal_remove | ( |  | ) |

Slot Prototype:
  `void on_my_remove(Widget* widget)`

Glib::SignalProxy1< void,Widget* > Gtk::Container::signal_set_focus_child | ( |  | ) |

Slot Prototype:
  `void on_my_set_focus_child(Widget* widget)`

void Gtk::Container::unset_focus_chain | ( |  | ) |

Removes a focus chain explicitly set with set_focus_chain().

## Friends And Related Function Documentation

Gtk::Container* wrap | ( | GtkContainer * | object,
|  | bool | take_copy = `false`
| ) |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- gtkmm/container.h