# Gtk::Bin Class Reference
[Widgets]

A container with just one child. More...

Inherits Gtk::Container.

Inherited by Gtk::Alignment, Gtk::Button, Gtk::ComboBox, Gtk::EventBox, Gtk::Expander, Gtk::Frame, Gtk::HandleBox, Gtk::MenuItem, Gtk::ScrolledWindow, Gtk::ToolItem, Gtk::Viewport, and Gtk::Window.

Collaboration diagram for Gtk::Bin:
[legend]

List of all members.

## Public Member Functions

virtual | ~Bin ()
GtkBin* | gobj ()
| Provides access to the underlying C GtkObject.
const GtkBin* | gobj () const
| Provides access to the underlying C GtkObject.
Gtk::Widget* | get_child ()
| Gets the child of the Gtk::Bin, or `0` if the bin contains no child widget.
const Gtk::Widget* | get_child () const
| Gets the child of the Gtk::Bin, or `0` if the bin contains no child widget.
void | remove ()
| Remove the contained object Since this can only hold one object it is not necessary to specify which object to remove like other containers.
void | add_label (const Glib::ustring& label, bool mnemonic=false, double x_align=0.5, double y_align=0.5)
| Add a Label object.
void | add_label (const Glib::ustring& label, bool mnemonic, Align x_align, Align y_align=ALIGN_CENTER)
| Add a Label object.
void | add_pixlabel (const std::string& pixfile, const Glib::ustring& label, double x_align=0.5, double y_align=0.5)
| Add Image and Label objects.

## Protected Member Functions

| Bin ()
| This constructor is protected because only derived classes should be instantiated.

## Related Functions

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

## Detailed Description

A container with just one child.

This is an abstract base class from which all classes holding up to 1 widget inside of them derive. It provides access to methods relevent to a single object, such as add_label, etc.

## Constructor & Destructor Documentation

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

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

This constructor is protected because only derived classes should be instantiated.

## Member Function Documentation

void Gtk::Bin::add_label | ( | const Glib::ustring & | label,
|  | bool | mnemonic = `false`,
|  | double | x_align = `0.5`,
|  | double | y_align = `0.5` |
| ) |  |  |

Add a Label object.

This does not correspond to any GTK+ function and is provided purely for convenience.

Parameters:

  | label | The text for the label.
  | mnemonic | If `true`, characters preceded by an underscore (_) will be underlined and used as a keyboard accelerator (shortcut).
  | x_align | The horizontal alignment of the text. This ranges from 0.0 (left aligned) to 1.0 (right aligned).
  | y_align | The vertical alignment of the text. This ranges from 0.0 (top aligned) to 1.0 (bottom aligned).

void Gtk::Bin::add_label | ( | const Glib::ustring & | label,
|  | bool | mnemonic,
|  | Align | x_align,
|  | Align | y_align = `ALIGN_CENTER` |
| ) |  |  |

Add a Label object.

This does not correspond to any GTK+ function and is provided purely for convenience.

Parameters:

  | label | The label text.
  | mnemonic | If `true`, characters preceded by an underscore (_) will be underlined and used as a keyboard accelerator (shortcut).
  | x_align | The horizontal alignment of the text. For possible values, see Gtk::Align.
  | y_align | The vertical alignment of the text. For possible values, see Gtk::Align.

void Gtk::Bin::add_pixlabel | ( | const std::string & | pixfile,
|  | const Glib::ustring & | label,
|  | double | x_align = `0.5`,
|  | double | y_align = `0.5` |
| ) |  |  |

Add Image and Label objects.

This does not correspond to any GTK+ function and is provided purely for convenience. This will create, manage, add, and show a new Image and Label (within an HBox) to this Bin.

Parameters:

  | pixmap | A Glib::RefPtr to a Gdk::Pixmap.
  | mask | A Glib::RefPtr to a Gdk::Bitmap.
  | label | The text for the label.
  | x_align | The horizontal alignment of the text in the label.
  | y_align | The vertical alignment of the text in the label. Add Image and Label objects. This does not correspond to any GTK+ function and is provided purely for convenience. This will create, manage, add, and show a new Image and Label (within an HBox) to this Bin.
  | pixfile | The path to a file to be displayed.
  | label | The text for the label.
  | x_align | The horizontal alignment of the text in the label.
  | y_align | The vertical alignment of the text in the label.

const Gtk::Widget* Gtk::Bin::get_child | ( |  | ) | const

Gets the child of the Gtk::Bin, or `0` if the bin contains no child widget.

The returned widget does not have a reference added, so you do not need to unref it.

Returns:
  Pointer to child of the Gtk::Bin.

Gtk::Widget* Gtk::Bin::get_child | ( |  | ) |

Gets the child of the Gtk::Bin, or `0` if the bin contains no child widget.

The returned widget does not have a reference added, so you do not need to unref it.

Returns:
  Pointer to child of the Gtk::Bin.

const GtkBin* Gtk::Bin::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Container.

Reimplemented in Gtk::AboutDialog, Gtk::Alignment, Gtk::AspectFrame, Gtk::Assistant, Gtk::ColorSelectionDialog, Gtk::Dialog, Gtk::EventBox, Gtk::Expander, Gtk::FontSelectionDialog, Gtk::Frame, Gtk::HandleBox, Gtk::MessageDialog, Gtk::OffscreenWindow, Gtk::Plug, Gtk::ScrolledWindow, Gtk::Window, Gtk::PageSetupUnixDialog, and Gtk::PrintUnixDialog.

GtkBin* Gtk::Bin::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::Container.

Reimplemented in Gtk::AboutDialog, Gtk::Alignment, Gtk::AspectFrame, Gtk::Assistant, Gtk::ColorSelectionDialog, Gtk::Dialog, Gtk::EventBox, Gtk::Expander, Gtk::FontSelectionDialog, Gtk::Frame, Gtk::HandleBox, Gtk::MessageDialog, Gtk::OffscreenWindow, Gtk::Plug, Gtk::ScrolledWindow, Gtk::Window, Gtk::PageSetupUnixDialog, and Gtk::PrintUnixDialog.

void Gtk::Bin::remove | ( |  | ) |

Remove the contained object Since this can only hold one object it is not necessary to specify which object to remove like other containers.

When calling remove() on a Gtk::ScrolledWindow this might not remove the expected child directly, because Gtk::ScrolledWindow::add() sometimes creates a Gtk::ViewPort child and places the widget in that.

## Friends And Related Function Documentation

Gtk::Bin* wrap | ( | GtkBin * | 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/bin.h