gtkmm: Gtk::Box Class Reference

# Gtk::Box Class Reference

A base class for box containers. More...

Inherits Gtk::Container.

Inherited by Gtk::ButtonBox, Gtk::HBox, and Gtk::VBox.

Collaboration diagram for Gtk::Box:
[legend]

List of all members.

## Public Types

typedef Box_Helpers::BoxList | BoxList

## Public Member Functions

virtual | ~Box ()
GtkBox* | gobj ()
| Provides access to the underlying C GtkObject.
const GtkBox* | gobj () const
| Provides access to the underlying C GtkObject.
void | pack_start (Widget& child, bool expand, bool fill, guint padding=0)
| Left side insert a widget to a box.
void | pack_start (Widget& child, PackOptions options=PACK_EXPAND_WIDGET, guint padding=0)
| Left side insert a widget to a box.
void | pack_end (Widget& child, bool expand, bool fill, guint padding=0)
| Adds child to box, packed with reference to the end of box.
void | pack_end (Widget& child, PackOptions options=PACK_EXPAND_WIDGET, guint padding=0)
| Right side insert a widget to a box.
void | set_homogeneous (bool homogeneous=true)
| Sets the Gtk::Box:homogeneous property of box, controlling whether or not all children of box are given equal space in the box.
bool | get_homogeneous () const
| Returns whether the box is homogeneous (all children are the same size).
void | set_spacing (int spacing)
| Sets the Gtk::Box:spacing property of box, which is the number of pixels to place between children of box.
int | get_spacing () const
| Gets the value set by set_spacing().
void | reorder_child (Widget& child, int pos)
| Moves child to a new position in the list of box children.
BoxList& | children ()
const BoxList& | children () const
Glib::PropertyProxy< int > | property_spacing ()
| The amount of space between children.
Glib::PropertyProxy_ReadOnly< int > | property_spacing () const
| The amount of space between children.
Glib::PropertyProxy< bool > | property_homogeneous ()
| Whether the children should all be the same size.
Glib::PropertyProxy_ReadOnly < bool > | property_homogeneous () const
| Whether the children should all be the same size.

## Protected Member Functions

| Box ()

## Related Functions

(Note that these are not member functions.)
Gtk::Box* | wrap (GtkBox* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

A base class for box containers.

Abstract base class for horizontal and vertical boxes, which organize a variable number of widgets into a rectangular area. This is an abstract class and it defers choice of which way the widgets are packed to the screen to the derived classes. It provides a common interface for inserting widgets to a box indepenently of how it is shown in the screen.

Gtk::Box uses a notion of packing. Packing refers to adding widgets with reference to a particular position in a Gtk::Container. There are two reference positions: the start and the end of the box. For a VBox, the start is defined as the top of the box and the end is defined as the bottom. For a HBox the start is defined as the left side and the end is defined as the right side. Use repeated calls to pack_start() to pack widgets into a Gtk::Box from start to end. Use pack_end() to add widgets from end to start. You may intersperse these calls and add widgets from both ends of the same Gtk::Box. The last widget added with pack_start() will be placed just before the last widget added with pack_end()

Because Gtk::Box is a Gtk::Container, you may also use Gtk::Container::add() to insert widgets, and they will be packed as if with pack_start(). Use Gtk::Container::remove() to remove widgets.

Use set_homogeneous() to specify whether or not all children of the Gtk::Box occupy the same amount of space. Use set_spacing() to determine the minimum space placed between all children in the Gtk::Box. Use reorder_child() to move a child widget to a different place in the box. Use set_child_packing() to reset the pack options and padding attributes of any Gtk::Box child. Use query_child_packing() to query these fields.

## Member Typedef Documentation

typedef Box_Helpers::BoxList Gtk::Box::BoxList

## Constructor & Destructor Documentation

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

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

## Member Function Documentation

const BoxList& Gtk::Box::children | ( |  | ) | const

BoxList& Gtk::Box::children | ( |  | ) |

bool Gtk::Box::get_homogeneous | ( |  | ) | const

Returns whether the box is homogeneous (all children are the same size).

See set_homogeneous().

Returns:
  `true` if the box is homogeneous.

int Gtk::Box::get_spacing | ( |  | ) | const

Gets the value set by set_spacing().

Returns:
  Spacing between children.

const GtkBox* Gtk::Box::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Container.

Reimplemented in Gtk::VBox, Gtk::HBox, Gtk::ButtonBox, Gtk::VButtonBox, Gtk::HButtonBox, Gtk::ColorSelection, Gtk::FileChooserButton, Gtk::FileChooserWidget, Gtk::FontSelection, Gtk::InfoBar, Gtk::RecentChooserWidget, Gtk::Statusbar, Gtk::Combo, and Gtk::GammaCurve.

GtkBox* Gtk::Box::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Container.

Reimplemented in Gtk::VBox, Gtk::HBox, Gtk::ButtonBox, Gtk::VButtonBox, Gtk::HButtonBox, Gtk::ColorSelection, Gtk::FileChooserButton, Gtk::FileChooserWidget, Gtk::FontSelection, Gtk::InfoBar, Gtk::RecentChooserWidget, Gtk::Statusbar, Gtk::Combo, and Gtk::GammaCurve.

void Gtk::Box::pack_end | ( | Widget& | child,
|  | PackOptions | options = `PACK_EXPAND_WIDGET`,
|  | guint | padding = `0` |
| ) |  |  |

Right side insert a widget to a box.

Parameters:

  | child | A Widget to be added to box.
  | options | Controls how the widget expands to fill space, and how the space around them is used.
  | padding | Padding that is added on either side of the widget. This is different to spacing set when the box is created (or with set_spacing()) - spacing is added between objects, and padding is added on either side of an object.

void Gtk::Box::pack_end | ( | Widget& | child,
|  | bool | expand,
|  | bool | fill,
|  | guint | padding = `0` |
| ) |  |  |

Adds child to box, packed with reference to the end of box.

The child is packed after (away from end of) any other child packed with reference to the end of box.

Parameters:

  | child | The Gtk::Widget to be added to box.
  | expand | `true` if the new child is to be given extra space allocated to box. The extra space will be divided evenly between all children of box that use this option.
  | fill | `true` if space given to child by the expand option is actually allocated to child, rather than just padding it. This parameter has no effect if expand is set to `false`. A child is always allocated the full height of a Gtk::HBox and the full width of a Gtk::VBox. This option affects the other dimension.
  | padding | Extra space in pixels to put between this child and its neighbors, over and above the global amount specified by Gtk::Box:spacing property. If child is a widget at one of the reference ends of box, then padding pixels are also put between child and the reference edge of box.

void Gtk::Box::pack_start | ( | Widget& | child,
|  | PackOptions | options = `PACK_EXPAND_WIDGET`,
|  | guint | padding = `0` |
| ) |  |  |

Left side insert a widget to a box.

Parameters:

  | child | A Widget to be added to box.
  | options | Controls how the widget expands to fill space, and how the space around them is used.
  | padding | Padding that is added on either side of the widget. This is different to spacing set when the box is created (or with set_spacing()) - spacing is added between objects, and padding is added on either side of an object.

void Gtk::Box::pack_start | ( | Widget& | child,
|  | bool | expand,
|  | bool | fill,
|  | guint | padding = `0` |
| ) |  |  |

Left side insert a widget to a box.

The expand argument to pack_start() or pack_end() controls whether the widgets are laid out in the box to fill in all the extra space in the box so the box is expanded to fill the area allocated to it (`true`). Or the box is shrunk to just fit the widgets (`false`). Setting expand to `false` will allow you to do right and left justifying of your widgets. Otherwise, they will all expand to fit in the box, and the same effect could be achieved by using only one of pack_start() or pack_end() functions.

The fill argument to the pack_start()/pack_end() functions control whether the extra space is allocated to the objects themselves (`true`), or as extra padding in the box around these objects (`false`). It only has an effect if the expand argument is also `true`.

The difference between spacing (set when the box is created) and padding (set when elements are packed) is, that spacing is added between objects, and padding is added on either side of an object.

Parameters:

  | child | The Gtk::Widget to be added to box.
  | expand | `true` if the new child is to be given extra space allocated to box. The extra space will be divided evenly between all children of box that use this option.
  | fill | `true` if space given to child by the expand option is actually allocated to child, rather than just padding it. This parameter has no effect if expand is set to `false`. A child is always allocated the full height of a Gtk::HBox and the full width of a Gtk::VBox. This option affects the other dimension.
  | padding | Extra space in pixels to put between this child and its neighbors, over and above the global amount specified by Gtk::Box:spacing property. If child is a widget at one of the reference ends of box, then padding pixels are also put between child and the reference edge of box.

Glib::PropertyProxy_ReadOnly<bool> Gtk::Box::property_homogeneous | ( |  | ) | const

Whether the children should all be the same size.

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<bool> Gtk::Box::property_homogeneous | ( |  | ) |

Whether the children should all be the same size.

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<int> Gtk::Box::property_spacing | ( |  | ) | const

The amount of space between 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<int> Gtk::Box::property_spacing | ( |  | ) |

The amount of space between 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.

void Gtk::Box::reorder_child | ( | Widget& | child,
|  | int | pos |
| ) |  |  |

Moves child to a new position in the list of box children.

The list is the <structfield>children</structfield> field of Gtk::Box-struct, and contains both widgets packed Gtk::PACK_START as well as widgets packed Gtk::PACK_END, in the order that these widgets were added to box.

A widget's position in the box children list determines where the widget is packed into box. A child widget at some position in the list will be packed just after all other widgets of the same packing type that appear earlier in the list.

Parameters:

  | child | The Gtk::Widget to move.
  | position | The new position for child in the list of children of box, starting from 0. If negative, indicates the end of the list.

void Gtk::Box::set_homogeneous | ( | bool | homogeneous = `true` | ) |

Sets the Gtk::Box:homogeneous property of box, controlling whether or not all children of box are given equal space in the box.

Parameters:

  | homogeneous | A boolean value, `true` to create equal allotments, `false` for variable allotments.

void Gtk::Box::set_spacing | ( | int | spacing | ) |

Sets the Gtk::Box:spacing property of box, which is the number of pixels to place between children of box.

Parameters:

  | spacing | The number of pixels to put between children.

## Friends And Related Function Documentation

Gtk::Box* wrap | ( | GtkBox * | 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/box.h