Upgrade gtkmm to 2.10.8, glibmm to 2.13.3 and add cairomm 1.2.4
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / comboboxtext.h
1 // -*- c++ -*-
2 #ifndef _GTKMM_COMBOBOXTEXT_H
3 #define _GTKMM_COMBOBOXTEXT_H
4
5 /* comboboxtext.h
6  * 
7  * Copyright (C) 2003 The gtkmm Development Team
8  *
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.
13  *
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.
18  *
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.
22  */
23
24 #include <gtkmm/combobox.h>
25
26 namespace Gtk
27 {
28
29 //This is a C++ convenience class that is equivalent to the gtk_combo_box_new_text() C convenience function.
30
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.
33  *
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.
38  *
39  * @ingroup Widgets
40  */
41
42 class ComboBoxText
43 : public ComboBox
44 {
45 #ifndef DOXYGEN_SHOULD_SKIP_THIS
46 private:
47   // noncopyable
48   ComboBoxText(const ComboBoxText&);
49   ComboBoxText& operator=(const ComboBoxText&);
50
51 protected:
52   explicit ComboBoxText(const Glib::ConstructParams& construct_params);
53   explicit ComboBoxText(GtkComboBox* castitem);
54
55 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
56
57 public:
58   ComboBoxText();
59
60   /** Add an item to the end of the drop-down list.
61    * @param text The text for the item.
62    */
63   void append_text(const Glib::ustring& text);
64
65   void insert_text(int position, const Glib::ustring& text);
66
67   /** Add an item to the beginning of the drop-down list.
68    * @param text The text for the item.
69    */
70   void prepend_text(const Glib::ustring& text);
71
72   /** Get the currently-chosen item.
73    * @result The text of the active item.
74    */
75   Glib::ustring get_active_text() const;
76
77   /** Set the currently-chosen item if it matches the specified text.
78    * @text The text of the item that should be selected.
79    */
80   void set_active_text(const Glib::ustring& text);
81
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.
85   void clear();
86
87   /** Remove all items from the drop-down menu.
88    */
89   void clear_items();
90
91   /** Remove the specified item if it is in the drop-down menu.
92    * @text The text of the item that should be removed.
93    */
94   void remove_text(const Glib::ustring& text);
95
96 protected:
97
98   //Tree model columns:
99   //These columns are used by the model that is created by the default constructor
100   class TextModelColumns : public Gtk::TreeModel::ColumnRecord
101   {
102   public:
103     TextModelColumns()
104     { add(m_column); }
105
106     Gtk::TreeModelColumn<Glib::ustring> m_column;
107   };
108
109   TextModelColumns m_text_columns;
110 };
111
112
113 } // namespace Gtk
114
115
116 #endif /* _GTKMM_COMBOBOXTEXT_H */
117