rollback to 3428, before the mysterious removal of libs/* at 3431/3432
[ardour.git] / libs / gtkmm2 / gtk / src / liststore.hg
1 /* $Id: liststore.hg,v 1.4 2004/04/03 12:53:49 murrayc Exp $ */
2
3 /* Copyright(C) 1998-2002 The gtkmm Development Team
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or(at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 #include <gtkmm/treeiter.h>
21 #include <gtkmm/treemodel.h>
22 #include <gtkmm/treesortable.h>
23 #include <gtkmm/treedragdest.h>
24 #include <gtkmm/treedragsource.h>
25 // We couldn't include it in treemodel.h, but doing it here makes it easier for people.
26 #include <gtkmm/treepath.h>
27
28 _DEFS(gtkmm,gtk)
29 _PINCLUDE(glibmm/private/object_p.h)
30
31 namespace Gtk
32 {
33
34 /** Thist is a list model for use with a Gtk::TreeView widget.
35  * @ingroup TreeView
36  * It implements the Gtk::TreeModel interface, and also implements the
37  * Gtk::TreeSortable interface so you can sort the list using the view.
38  * Finally, it also implements the tree drag and drop interfaces.
39  */
40 class ListStore :
41   public Glib::Object,
42   public TreeModel,
43   public TreeSortable,
44   public TreeDragSource,
45   public TreeDragDest
46 {
47   _CLASS_GOBJECT(ListStore, GtkListStore, GTK_LIST_STORE, Glib::Object, GObject)
48   _IMPLEMENTS_INTERFACE(TreeModel)
49   _IMPLEMENTS_INTERFACE(TreeSortable)
50   _IMPLEMENTS_INTERFACE(TreeDragSource)
51   _IMPLEMENTS_INTERFACE(TreeDragDest)
52   _IGNORE(gtk_list_store_insert_after,
53           gtk_list_store_prepend, gtk_list_store_append, gtk_list_store_set_value,
54           gtk_list_store_insert,
55           gtk_list_store_set, gtk_list_store_set_valist,
56           gtk_list_store_reorder, gtk_list_store_move_after, gtk_list_store_move_before)
57
58 protected:
59   /** When using this constructor, you must use set_column_types() immediately afterwards.
60    * This can be useful when deriving from this class, with a fixed TreeModelColumnRecord
61    * that is a member of the class.
62    * There is no create() method that corresponds to this constructor, because this
63    * constructor should only be used by derived classes.
64    */
65   _CTOR_DEFAULT
66   
67   explicit ListStore(const TreeModelColumnRecord& columns);
68
69 public:
70
71   /** Instantiate a new ListStore.
72    * @param columns The column types for this tree model.
73    * @result The new ListStore.
74    */
75   _WRAP_CREATE(const TreeModelColumnRecord& columns)
76
77   void set_column_types(const TreeModelColumnRecord& columns);
78   _IGNORE(gtk_list_store_set_column_types)
79   
80   /** Removes the given row from the list store.
81    * @param iter The iterator to the row to be removed.
82    * @result An iterator to the next row, or end() if there is none.
83    */
84   iterator erase(const iterator& iter);
85   _IGNORE(gtk_list_store_remove)
86
87   //TODO: Make this documentation similar to documentation for Standard C++ insert methods.
88   /** Creates a new row before the position.
89    * If iter is end() then a new row will be appended to the list.
90    * The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value().
91    * See also prepend() and append().
92    *
93    * @param iter An iterator to the row before which the new row will be inserted.
94    * @result An iterator to the new row. 
95    */
96   iterator insert(const iterator& iter);
97   _IGNORE(gtk_list_store_insert_before)
98
99   //TODO: Docs. This one is apparently faster.
100   /** Creates a new row after the position.
101    * If iter is end() then a new row will be prepended to the list.
102    * The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value().
103    * See also insert(), prepend() and append().
104    *
105    * @param iter An iterator to the row after which the new row will be inserted.
106    * @result An iterator to the new row.
107    */
108   iterator insert_after(const iterator& iter);
109   _IGNORE(gtk_list_store_insert_after)
110   
111   /** Creates a new row at the start.
112    * The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value().
113    * See also insert() and append().
114    *
115    * @result An iterator to the new row.
116    */
117   iterator prepend();
118
119   /** Creates a new row at the end.
120    * The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value().
121    * See also insert() and prepend().
122    *
123    * @result An iterator to the new row.
124    */
125   iterator append();
126
127   _WRAP_METHOD(void iter_swap(const iterator& a, const iterator& b), gtk_list_store_swap)
128
129   /** Moves @a source to the position at @a destination.
130    * Note that this function only works with unsorted stores.
131    * @param source The row that should be moved.
132    * @param destination The position to move to.
133    */
134   void move(const iterator& source, const iterator& destination);
135
136   /** Reorders the list store to follow the order indicated by @a new_order.
137    * Note that this function only works with unsorted stores.
138    */
139   void reorder(const Glib::ArrayHandle<int>& new_order);
140
141   _WRAP_METHOD(void clear(), gtk_list_store_clear)
142
143   _WRAP_METHOD(bool iter_is_valid(const iterator& iter) const, gtk_list_store_iter_is_valid)
144
145 protected:
146   virtual void set_value_impl(const iterator& row, int column, const Glib::ValueBase& value);
147 };
148
149 } // namespace Gtk
150