Class Index Cross Index Namespace Index

Class Gtk::Box

Abstract base class for horizontal and vertical boxes
Contained in: Gtk
Derived from: Gtk::Container
Derived by: Gtk::ButtonBox Gtk::HBox Gtk::VBox

#include <gtk--/box.h>


public function member index:

BoxList& children();
const BoxList& children() const;
GtkBox* gtkobj();
const GtkBox* gtkobj() const;
static bool isA(Object* object);
void pack_end(Widget& child, bool expand=true, bool fill=true, guint padding=0);
void pack_start(Widget& child, bool expand=true, bool fill=true, guint padding=0);
void reorder_child(Widget& child, gint pos);
void set_homogeneous(bool homogeneous);
void set_spacing(gint spacing);
virtual ~Box();
 

protected function member index:

Box();
 

Description:

Gtk::Box is an abstract class and it defers choice of which way the widgets are packed to the screen to the derived classes. Gtk::Box provides common interface for inserting widgets to a box indepenently of how it is shown in the screen.

The most common use of Gtk::Box is like this:

  class mywindow : public Gtk_Window {
     Gtk_Label label1,label2;
     Gtk_VBox vbox;
  public:
     mywindow();
  };
  mywindow::mywindow()
  {
     add(vbox);
     vbox.pack_end(label1, true, true, 0);
     vbox.pack_end(label2, true, true, 0);
  }



Function Member Descriptions:

Gtk::Box::gtkobj - Returns the underlaying gtk+ object.

GtkBox* gtkobj();

Gtk::Box::isA - Returns true if object is this type.

static bool isA(Object* object);

Gtk::Box::pack_end - right side insert a widget to a box.

void pack_end(Widget& child, bool expand=true, bool fill=true, guint padding=0);

Gtk::Box::pack_start - left side insert a widget to a box.

void pack_start(Widget& child, bool expand=true, bool fill=true, guint padding=0);
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 alloted 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), spacing is added between objects, and padding is added on either side of an object.



Gtk::Box::reorder_child - Reorder children by integer index.

void reorder_child(Widget& child, gint pos);

Gtk::Box::set_homogeneous - Change box child sizing policy.

void set_homogeneous(bool homogeneous);
allows setting homongeneous afterwards. This is usually given on VBox or HBox


Gtk::Box::set_spacing - Change spacing between children.

void set_spacing(gint spacing);