2 #ifndef _GTKMM_COMBOBOXTEXT_H
3 #define _GTKMM_COMBOBOXTEXT_H
7 * Copyright (C) 2003 The gtkmm Development Team
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include <gtkmm/combobox.h>
29 //This is a C++ convenience class that is equivalent to the gtk_combo_box_new_text() C convenience function.
31 /** This is a specialisation of the ComboBox which has one column of text (a simple list),
32 * and appropriate methods for setting and getting the text.
34 * Note that you can not use this class with Gnome::Glade::Xml::get_widget_derived() to wrap a GtkComboBox added
35 * in the Glade user interface designer, because Glade adds its own TreeModel instead of using the TreeModel from
36 * this class. You could use a normal Gtk::ComboBox instead, though you can not use Glade to add rows to a TreeModel
37 * that is defined in your C++ code.
45 #ifndef DOXYGEN_SHOULD_SKIP_THIS
48 ComboBoxText(const ComboBoxText&);
49 ComboBoxText& operator=(const ComboBoxText&);
52 explicit ComboBoxText(const Glib::ConstructParams& construct_params);
53 explicit ComboBoxText(GtkComboBox* castitem);
55 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
60 /** Add an item to the end of the drop-down list.
61 * @param text The text for the item.
63 void append_text(const Glib::ustring& text);
65 void insert_text(int position, const Glib::ustring& text);
67 /** Add an item to the beginning of the drop-down list.
68 * @param text The text for the item.
70 void prepend_text(const Glib::ustring& text);
72 /** Get the currently-chosen item.
73 * @result The text of the active item.
75 Glib::ustring get_active_text() const;
77 /** Set the currently-chosen item if it matches the specified text.
78 * @text The text of the item that should be selected.
80 void set_active_text(const Glib::ustring& text);
82 //There is a clear() method in the CellLayout base class, so this would cause confusion.
83 //TODO: Remove this when we can break API.
84 /// @deprecated See clear_items(). Since 2.8.
87 /** Remove all items from the drop-down menu.
91 /** Remove the specified item if it is in the drop-down menu.
92 * @text The text of the item that should be removed.
94 void remove_text(const Glib::ustring& text);
99 //These columns are used by the model that is created by the default constructor
100 class TextModelColumns : public Gtk::TreeModel::ColumnRecord
106 Gtk::TreeModelColumn<Glib::ustring> m_column;
109 TextModelColumns m_text_columns;
116 #endif /* _GTKMM_COMBOBOXTEXT_H */