Main Page Widgets Namespaces Book

# Gtk::Box Class Reference

Inheritance diagram for Gtk::Box:

[legend]
List of all members.

## 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.

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.

## 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)
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)
bool | get_homogeneous () const
| Returns whether the box is homogeneous (all children are the same size).
void | set_spacing (int spacing)
int | get_spacing () const
| Gets the value set by set_spacing().
void | reorder_child (Widget& child, int pos)
BoxList& | children ()
const BoxList& | children () const
Glib::PropertyProxy<int> | property_spacing ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly< int > | property_spacing () const
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy<bool> | property_homogeneous ()
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.
Glib::PropertyProxy_ReadOnly< bool > | property_homogeneous () const
| You rarely need to use properties because there are get_ and set_ methods for almost all of them.

## Protected Member Functions

| Box ()

## Related Functions

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

## 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::Combo, Gtk::GammaCurve, Gtk::FileChooserWidget, Gtk::FontSelection, and Gtk::Statusbar.

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::Combo, Gtk::GammaCurve, Gtk::FileChooserWidget, Gtk::FontSelection, and Gtk::Statusbar.

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`
| ) |

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.

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

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 | ( |  | ) |

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

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 | ( |  | ) |

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
| ) |

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

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

## Friends And Related Function Documentation

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

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:

- box.h