Xfce Foundation Classes
Main Page | Index | Namespace List | Alphabetical List | Class List | File List

# Xfc::Gtk::Box Class Reference

A GtkBox C++ wrapper class. More...

`#include <xfc/gtk/box.hh>`

Inheritance diagram for Xfc::Gtk::Box:

List of all members.

## Public Member Functions

Accessors

- GtkBox * gtk_box () const
    Get a pointer to the GtkBox structure.
- operator GtkBox * () const
    Conversion operator; safely converts a Box to a GtkBox pointer.
- bool children (std::vector< BoxChild * > &child_list) const
    Get a list of children belonging to the Box.
- bool get_homogeneous () const
    Returns whether the box is homogeneous (all children are the same size); see set_homogeneous().
- int get_spacing () const
    Gets the value set by set_spacing().

Methods

- void pack_start (Widget &child, bool expand=true, bool fill=true, unsigned int padding=0)
    Adds child to the box, packed with reference to the start of box.
- void pack_end (Widget &child, bool expand=true, bool fill=true, unsigned int padding=0)
    Adds child to the box, packed with reference to the end of box.
- void insert_start (Widget &child, int position, bool expand=true, bool fill=true, unsigned int padding=0)
    Inserts child into the box at position, with reference to the start of box.
- void insert_end (Widget &child, int position, bool expand=true, bool fill=true, unsigned int padding=0)
    Inserts child into the box at position, packed with reference to the end of box.
- void set_homogeneous (bool homogeneous)
    Sets the homogeneous field of the Box, controlling whether or not all children of box are given equal space in the box.
- void set_spacing (int spacing)
    Sets the spacing field of the Box, which is the number of pixels to place between children of box.
- void reorder_child (Widget &child, int position)
    Moves child to a new position in the list of box children.
- void query_child_packing (Widget &child, bool *expand, bool *fill, unsigned int *padding, PackType *pack_type) const
    Returns information about how child is packed into the box.
- void set_child_packing (Widget &child, bool expand, bool fill, unsigned int padding, PackType pack_type)
    Sets the way child is packed into the box.

## Protected Member Functions

Constructors

- Box (GtkBox *box, bool owns_reference=false)
    Construct a new Box from an existing GtkBox.
- virtual ~Box ()=0
    Destructor.

## Detailed Description

A GtkBox C++ wrapper class.

Box is an abstract widget which encapsulates functionallity for a particular kind of container, one that organizes a variable number of widgets into a rectangular area. Box currently has two derived classes, HBox and VBox. The rectangular area of a Box is organized into either a single row or a single column of child widgets depending upon whether the box is of type HBox or VBox, respectively. Thus, all children of a Box are allocated one dimension in common, which is the height of a row, or the width of a column.

Box uses a notion of packing. Packing refers to adding widgets with reference to a particular position in a Container. For a Box, 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 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 Box.

Because Box is a Container, you may also use Gtk::Container::add() to insert widgets into the box, and they will be packed as if with pack_start() using the default values: expand true, fill true and padding zero. Use Gtk::Container::remove() to remove widgets from the Box.

Use set_homogeneous() to specify whether or not all children of the Box are forced to get the same amount of space. Use set_spacing() to determine how much space will be minimally placed between all children in the Box. Use reorder_child() to move a Box child to a different place in the box. Use set_child_packing() to reset the expand, fill, and padding attributes of any Box child. Use query_child_packing() to query these fields.

See also: the Packing Boxes HOWTO and example.

## Constructor & Destructor Documentation

Xfc::Gtk::Box::Box | ( | GtkBox * | box,
|  | bool | owns_reference = `false`
| ) | `[explicit, protected]`

Construct a new Box from an existing GtkBox.

Parameters:

  | box | A pointer to a GtkBox.
  | owns_reference | Set false if the initial reference count is floating, set true if it's not.

The box can be a newly created GtkBox or an existing GtkBox. (see G::Object::Object).

## Member Function Documentation

bool Xfc::Gtk::Box::children | ( | std::vector< BoxChild * > & | child_list | ) | const

Get a list of children belonging to the Box.

Parameters:

  | child_list | A reference to an empty vector of BoxChild* to hold the children.

Returns:
  true if successful, false otherwise.

The data is a vector of BoxChild pointers. The returned children do not have a reference added, so you do not need to unref them.

bool Xfc::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 Xfc::Gtk::Box::get_spacing | ( |  | ) | const

Gets the value set by set_spacing().

Returns:
  The spacing between children.

void Xfc::Gtk::Box::insert_end | ( | Widget & | child,
|  | int | position,
|  | bool | expand = `true`,
|  | bool | fill = `true`,
|  | unsigned int | padding = `0`
| ) |

Inserts child into the box at position, packed with reference to the end of box.

Parameters:

  | child | The Widget to be added to the box.
  | position | The new position for child at the end, starting from 0.
  | expand | Set true if the new child is to be given extra space allocated to the box. The extra space is divided evenly between all children of box using this option.
  | fill | Set true if space given to child by the expand option is actually allocated to the 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 HBox and the full width of a VBox. This option affects the other dimension.
  | padding | The extra space in pixels to put between this child and its neighbors, over and above the global amount specified by spacing in Box. If child is a widget at one of the reference ends of the box, then padding pixels are also put between child and the reference edge of box.

This method is equivalent to calling pack_end() followed by reorder_child(). The default arguments specified are those most frequently used. Setting position to -1 is the same as calling pack_end(); the position argument is ignored.

void Xfc::Gtk::Box::insert_start | ( | Widget & | child,
|  | int | position,
|  | bool | expand = `true`,
|  | bool | fill = `true`,
|  | unsigned int | padding = `0`
| ) |

Inserts child into the box at position, with reference to the start of box.

Parameters:

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

This method is equivalent to calling pack_start() followed by reorder_child(). The default arguments specified are those most frequently used. Setting position to -1 is the same as calling pack_start(); the position argument is ignored.

void Xfc::Gtk::Box::pack_end | ( | Widget & | child,
|  | bool | expand = `true`,
|  | bool | fill = `true`,
|  | unsigned int | padding = `0`
| ) |

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

Parameters:

  | child | The Widget to be added to the box.
  | expand | Set true if the new child is to be given extra space allocated to the box. The extra space is divided evenly between all children of box using this option.
  | fill | Set true if space given to child by the expand option is actually allocated to the 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 HBox and the full width of a VBox. This option affects the other dimension.
  | padding | The extra space in pixels to put between this child and its neighbors, over and above the global amount specified by spacing in Box. If child is a widget at one of the reference ends of the box, then padding pixels are also put between child and the reference edge of box.

The child is packed after (away from end of) any other child packed with reference to the end of box. The default arguments specified are those most frequently used.

void Xfc::Gtk::Box::pack_start | ( | Widget & | child,
|  | bool | expand = `true`,
|  | bool | fill = `true`,
|  | unsigned int | padding = `0`
| ) |

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

Parameters:

  | child | The Widget to be added to the box.
  | expand | Set true if the new child is to be given extra space allocated to the box. The extra space is divided evenly between all children of box using this option.
  | fill | Set true if space given to child by the expand option is actually allocated to the 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 HBox and the full width of a VBox. This option affects the other dimension.
  | padding | The extra space in pixels to put between this child and its neighbors, over and above the global amount specified by spacing in Box. If child is a widget at one of the reference ends of the box, then padding pixels are also put between child and the reference edge of box.

The child is packed after any other child packed with reference to the start of box. The default arguments specified are those most frequently used.

void Xfc::Gtk::Box::query_child_packing | ( | Widget & | child,
|  | bool * | expand,
|  | bool * | fill,
|  | unsigned int * | padding,
|  | PackType * | pack_type
| ) | const

Returns information about how child is packed into the box.

Parameters:

  | child | The Widget of the child to query.
  | expand | The returned value of the expand field in BoxChild.
  | fill | The returned value of the fill field in BoxChild.
  | padding | The returned value of the padding field in BoxChild.
  | pack_type | The returned value of the pack field in BoxChild.

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

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

Parameters:

  | child | The Widget to move.
  | position | The new position for child in the children list, starting from 0.

The list is the children field of GtkBox, 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 negative value indicates the end of the list.

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.

void Xfc::Gtk::Box::set_child_packing | ( | Widget & | child,
|  | bool | expand,
|  | bool | fill,
|  | unsigned int | padding,
|  | PackType | pack_type
| ) |

Sets the way child is packed into the box.

Parameters:

  | child | The Widget of the child to set.
  | expand | The new value of the expand field in BoxChild.
  | fill | The new value of the fill field in BoxChild.
  | padding | The new value of the padding field in BoxChild.
  | pack_type | The new value of the pack field in BoxChild.

void Xfc::Gtk::Box::set_homogeneous | ( | bool | homogeneous | ) |

Sets the homogeneous field of the 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 Xfc::Gtk::Box::set_spacing | ( | int | spacing | ) |

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

Parameters:

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

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

- box.hh

Xfce Foundation Classes

Copyright © 2004-2005 The XFC Development Team | XFC 4.3