gtkmm: Gtk::ComboBoxText Class Reference

gtkmm 3.5.4

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Related Functions
Gtk::ComboBoxText Class Reference
Widgets

This is a simple variant of ComboBox that hides the model-view complexity for simple text-only use cases. More...

Inheritance diagram for Gtk::ComboBoxText:
[legend]

List of all members.

## Public Member Functions
virtual | ~ComboBoxText ()
GtkComboBoxText* | gobj ()
| Provides access to the underlying C GtkObject.
const GtkComboBoxText* | gobj () const
| Provides access to the underlying C GtkObject.
| ComboBoxText (bool has_entry=false)
| Creates a new empty ComboBoxText, optionally with an entry.
void | append (const Glib::ustring& text)
| Appends text to the list of strings stored in combo_box.
void | append (const Glib::ustring& id, const Glib::ustring& text)
| Appends text to the list of strings stored in combo_box.
void | insert (int position, const Glib::ustring& text)
| Inserts text at position in the list of strings stored in combo_box.
void | insert (int position, const Glib::ustring& id, const Glib::ustring& text)
| Inserts text at position in the list of strings stored in combo_box.
void | prepend (const Glib::ustring& text)
| Prepends text to the list of strings stored in combo_box.
void | prepend (const Glib::ustring& id, const Glib::ustring& text)
| Prepends text to the list of strings stored in combo_box.
void | remove_text (int position)
| Removes the string at position from combo_box.
Glib::ustring | get_active_text () const
| Returns the currently active string in combo_box, or `0` if none is selected.
void | remove_all ()
| Removes all the text entries from the combo box.
void | set_active_text (const Glib::ustring& text)
## Related Functions
(Note that these are not member functions.)
Gtk::ComboBoxText* | wrap (GtkComboBoxText* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

This is a simple variant of ComboBox that hides the model-view complexity for simple text-only use cases.

You can add items to a ComboBoxText with append(), insert() or prepend() and remove items with remove_text().

If the ComboBoxText contains an entry (via the 'has_entry' property), its contents can be retrieved using get_active_text(). The entry itself can be accessed by calling ComboBox::get_entry() or ComboBox::get_entry_text().

You should not call set_model() or attempt to pack more cells into this combo box via its CellLayout base class.

## Constructor & Destructor Documentation

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

Gtk::ComboBoxText::ComboBoxText | ( | bool | has_entry = `false` | ) | `[explicit]`

Creates a new empty ComboBoxText, optionally with an entry.

Parameters:

  has_entry | If this is true then this will have an Entry widget.

## Member Function Documentation

void Gtk::ComboBoxText::append | ( | const Glib::ustring & | text | ) |

Appends text to the list of strings stored in combo_box.

This is the same as calling insert_text() with a position of -1.

Since gtkmm 2.24:

Parameters:

  text | A string.

void Gtk::ComboBoxText::append | ( | const Glib::ustring & | id,
|  | const Glib::ustring & | text
| ) |  |

Appends text to the list of strings stored in combo_box.

If id is non-`0` then it is used as the ID of the row.

This is the same as calling insert() with a position of -1.

Since gtkmm 2.24:

Parameters:

  id | A string ID for this value, or `0`.
  text | A string.

Glib::ustring Gtk::ComboBoxText::get_active_text | ( |  | ) | const

Returns the currently active string in combo_box, or `0` if none is selected.

If combo_box contains an entry, this function will return its contents (which will not necessarily be an item from the list).

Since gtkmm 2.24:

Returns:
  A newly allocated string containing the currently active text. Must be freed with Glib::free().

GtkComboBoxText* Gtk::ComboBoxText::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::ComboBox.

const GtkComboBoxText* Gtk::ComboBoxText::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GtkObject.

Reimplemented from Gtk::ComboBox.

void Gtk::ComboBoxText::insert | ( | int | position,
|  | const Glib::ustring & | text
| ) |  |

Inserts text at position in the list of strings stored in combo_box.

If position is negative then text is appended.

This is the same as calling insert() with a `0` ID string.

Since gtkmm 2.24:

Parameters:

  position | An index to insert text.
  text | A string.

void Gtk::ComboBoxText::insert | ( | int | position,
|  | const Glib::ustring & | id,
|  | const Glib::ustring & | text
| ) |  |

Inserts text at position in the list of strings stored in combo_box.

If id is non-`0` then it is used as the ID of the row. See Gtk::ComboBox::property_id_column().

If position is negative then text is appended.

Since gtkmm 3.0:

Parameters:

  position | An index to insert text.
  id | A string ID for this value, or `0`.
  text | A string to display.

void Gtk::ComboBoxText::prepend | ( | const Glib::ustring & | text | ) |

Prepends text to the list of strings stored in combo_box.

This is the same as calling insert_text() with a position of 0.

Since gtkmm 2.24:

Parameters:

  text | A string.

void Gtk::ComboBoxText::prepend | ( | const Glib::ustring & | id,
|  | const Glib::ustring & | text
| ) |  |

Prepends text to the list of strings stored in combo_box.

If id is non-`0` then it is used as the ID of the row.

This is the same as calling insert() with a position of 0.

Since gtkmm 2.24:

Parameters:

  id | A string ID for this value, or `0`.
  text | A string.

void Gtk::ComboBoxText::remove_all | ( |  | ) |

Removes all the text entries from the combo box.

Since gtkmm 3.0:

void Gtk::ComboBoxText::remove_text | ( | int | position | ) |

Removes the string at position from combo_box.

Since gtkmm 2.24:

Parameters:

  position | Index of the item to remove.

void Gtk::ComboBoxText::set_active_text | ( | const Glib::ustring & | text | ) |

## Friends And Related Function Documentation

Gtk::ComboBoxText* wrap | ( | GtkComboBoxText * | 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/comboboxtext.h