1 /* $Id: liststore.hg,v 1.4 2004/04/03 12:53:49 murrayc Exp $ */
3 /* Copyright(C) 1998-2002 The gtkmm Development Team
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.
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.
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.
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>
29 _PINCLUDE(glibmm/private/object_p.h)
34 /** Thist is a list model for use with a Gtk::TreeView widget.
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.
44 public TreeDragSource,
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)
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.
67 explicit ListStore(const TreeModelColumnRecord& columns);
71 /** Instantiate a new ListStore.
72 * @param columns The column types for this tree model.
73 * @result The new ListStore.
75 _WRAP_CREATE(const TreeModelColumnRecord& columns)
77 void set_column_types(const TreeModelColumnRecord& columns);
78 _IGNORE(gtk_list_store_set_column_types)
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.
84 iterator erase(const iterator& iter);
85 _IGNORE(gtk_list_store_remove)
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().
93 * @param iter An iterator to the row before which the new row will be inserted.
94 * @result An iterator to the new row.
96 iterator insert(const iterator& iter);
97 _IGNORE(gtk_list_store_insert_before)
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().
105 * @param iter An iterator to the row after which the new row will be inserted.
106 * @result An iterator to the new row.
108 iterator insert_after(const iterator& iter);
109 _IGNORE(gtk_list_store_insert_after)
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().
115 * @result An iterator to the new row.
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().
123 * @result An iterator to the new row.
127 _WRAP_METHOD(void iter_swap(const iterator& a, const iterator& b), gtk_list_store_swap)
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.
134 void move(const iterator& source, const iterator& destination);
136 /** Reorders the list store to follow the order indicated by @a new_order.
137 * Note that this function only works with unsorted stores.
139 void reorder(const Glib::ArrayHandle<int>& new_order);
141 _WRAP_METHOD(void clear(), gtk_list_store_clear)
143 _WRAP_METHOD(bool iter_is_valid(const iterator& iter) const, gtk_list_store_iter_is_valid)
146 virtual void set_value_impl(const iterator& row, int column, const Glib::ValueBase& value);