add new sigc++2 directory
[ardour.git] / libs / gtkmm2 / gtk / src / combo.hg
1 /* $Id: combo.hg,v 1.7 2005/11/29 16:38:10 murrayc Exp $ */
2
3 /* combo.h
4  * 
5  * Copyright (C) 1998-2002 The gtkmm Development Team
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the Free
19  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21
22 // This is for including the config header before any code (such as
23 // the #ifndef GTKMM_DISABLE_DEPRECATED in deprecated classes) is generated:
24 _CONFIGINCLUDE(gtkmmconfig.h)
25
26 #include <glibmm/listhandle.h>
27 #include <glibmm/helperlist.h>
28 #include <gtkmm/box.h>
29 #include <gtkmm/button.h>
30 #include <gtkmm/entry.h>
31 #include <gtkmm/item.h>
32 _DEFS(gtkmm,gtk)
33 _PINCLUDE(gtkmm/private/box_p.h)
34 _PINCLUDE(gtkmm/private/item_p.h)
35
36 namespace Gtk
37 {
38
39
40 /** An item in a ComboDropDownList.
41  * 
42  * Items in a ComboDropDownList inherit Item. Two signals are added.
43  *
44  * @deprecated Use the ComboBox widget instead. 
45  */
46 class ComboDropDownItem : public Gtk::Item
47 {
48   _CLASS_GTKOBJECT(ComboDropDownItem,GtkListItem,GTK_LIST_ITEM,Gtk::Item,GtkItem)
49   _IS_DEPRECATED
50   _IGNORE(gtk_list_item_select,gtk_list_item_deselect)
51
52 public:
53   _CTOR_DEFAULT
54
55   _WRAP_SIGNAL(void scroll_horizontal(ScrollType scroll_type, float position), "scroll-horizontal")
56   _WRAP_SIGNAL(void scroll_vertical(ScrollType scroll_type, float position), "scroll-vertical")
57 };
58
59
60 namespace ComboDropDown_Helpers
61 {
62
63 typedef Gtk::ComboDropDownItem Element;
64
65 #m4 include(list.m4)
66   GP_LIST(ComboDropDownList,ComboDropDown,GtkList,ComboDropDownItem,children)
67   GP_LIST_ITER(Glib::List_Cpp_Iterator<GtkListItem, ComboDropDownItem>)
68   GP_LIST_FIND()
69   GP_LIST_END()
70
71 } /* namespace ComboDropDown_Helpers */
72
73
74 class Combo;
75
76 /** The dropdown list of a Combo.
77  * 
78  * A combo is a compound widget which crosses a text entry area and a pull
79  * down list. The dropdown list is implemented with the deprecated GtkList
80  * widget on the gtk+ side. ComboDropDown is a thin wrapper around GtkList
81  * containing just the functionality necessary for a Combo's list. To add
82  * and remove items use the STL-style interface that is accessible through
83  * ComboDropDown::children().
84  *
85  * @deprecated Use the ComboBox widget instead.
86  */
87 class ComboDropDown : public Gtk::Container
88 {
89   _CLASS_GTKOBJECT(ComboDropDown,GtkList,GTK_LIST,Gtk::Container,GtkContainer)
90   _IS_DEPRECATED
91   _IGNORE(gtk_list_remove_items_no_unref,gtk_list_select_item,gtk_list_unselect_item,gtk_list_set_selection_mode,gtk_list_extend_selection,gtk_list_start_selection,gtk_list_end_selection,gtk_list_select_all,gtk_list_unselect_all,gtk_list_toggle_add_mode,gtk_list_toggle_focus_row,gtk_list_toggle_row,gtk_list_undo_selection,gtk_list_end_drag_selection)
92 public:
93   typedef ComboDropDown_Helpers::ComboDropDownList ComboDropDownList;
94
95 protected:
96   _CTOR_DEFAULT
97   friend class Combo;
98 public:
99
100   _WRAP_METHOD(void scroll_horizontal(ScrollType scroll_type, float position), gtk_list_scroll_horizontal)
101   _WRAP_METHOD(void scroll_vertical(ScrollType scroll_type, float position), gtk_list_scroll_vertical)
102
103   ComboDropDownList& children();
104   const ComboDropDownList& children() const;
105
106   _IGNORE(gtk_list_insert_items)
107   _IGNORE(gtk_list_append_items,gtk_list_prepend_items)
108   _IGNORE(gtk_list_child_position)
109   _IGNORE(gtk_list_remove_items)
110
111   _WRAP_SIGNAL(void select_child(Widget& item), "select_child")
112   _WRAP_SIGNAL(void selection_changed(), "selection_changed")
113   _WRAP_SIGNAL(void unselect_child(Widget& item), "unselect_child")
114
115 protected:
116 #ifndef DOXYGEN_SHOULD_SKIP_THIS
117   mutable ComboDropDownList children_proxy_;
118 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
119 };
120
121
122 class ScrolledWindow;
123 class Window;
124
125 /** A text entry field with a dropdown list.
126  * 
127  * A combo is a compound widget which crosses a text entry area and a pull
128  * down list.  It may allow text entry or it may just allow list
129  * values depending on the settings.
130  *
131  * Access members allow altering of the widget components.
132  *
133  * @deprecated Use the ComboBox widget instead.
134  */
135 class Combo : public HBox
136 {
137   _CLASS_GTKOBJECT(Combo,GtkCombo,GTK_COMBO,Gtk::HBox,GtkHBox)
138   _IS_DEPRECATED
139 public:
140
141   _CTOR_DEFAULT
142   
143   /** Allow direct text entry
144    * Whether the text in the entry must be or not be in the list.
145    *
146    * @param value Set to true if the value must be in list.
147    * @param empty Set to true if the text area is allowed to be empty.
148    */
149   _WRAP_METHOD(void set_value_in_list(bool value = true, bool empty = false), gtk_combo_set_value_in_list)
150
151   /** Set arrows keys to change value
152    * Up and down will scroll through the list items.
153    * Useful when there is a small list of value that the
154    * list must have.
155    *
156    * @param arrows_on true indicates the arrow keys scroll.
157    */
158   _WRAP_METHOD(void set_use_arrows(bool arrows_on = true), gtk_combo_set_use_arrows)
159
160   /** Set arrows keys to change if value not in list
161    * Up and down will scroll through the list items but only
162    * change the current value if the text does not match a list item..
163    * Useful when there is a small list of value that the
164    * list must have.
165    *
166    * @param arrows_always true indicates the value will change.
167    */
168   _WRAP_METHOD(void set_use_arrows_always(bool arrows_always = true), gtk_combo_set_use_arrows_always)
169
170   /** Sets list case sensitive
171    * Determines if the list items and text comparisons for
172    * set_use_arrows_always() should be case sensitive.
173    */
174   _WRAP_METHOD(void set_case_sensitive(bool val = true), gtk_combo_set_case_sensitive)
175
176   /** Set the current entry Glib::ustring
177    * Call this function on an item if it isn't a label or you
178    * want it to have a different value to be displayed in the entry
179    */
180   _WRAP_METHOD(void set_item_string(Gtk::Item& item, const Glib::ustring& item_value), gtk_combo_set_item_string)
181    void remove_item_string(Gtk::Item& item);
182
183   /// Insert a list of items.
184   _WRAP_METHOD(void set_popdown_strings(const Glib::ListHandle<Glib::ustring>& strings), gtk_combo_set_popdown_strings)
185
186   Glib::ListHandle<Glib::ustring> get_popdown_strings() const;
187
188   _WRAP_METHOD(void disable_activate(), gtk_combo_disable_activate)
189
190   _MEMBER_GET_PTR(entry,entry,Entry*,GtkWidget*)
191   _MEMBER_GET_PTR(list,list,ComboDropDown*,GtkWidget*)
192
193   _WRAP_PROPERTY("enable-arrow-keys", bool)
194   _WRAP_PROPERTY("enable-arrows-always", bool)
195   _WRAP_PROPERTY("case-sensitive", bool)
196   _WRAP_PROPERTY("allow-empty", bool)
197   _WRAP_PROPERTY("value-in-list", bool)
198 };
199
200
201 } /* namespace Gtk */
202
203