Remove ancient/unused flowcanvas and libglademm from repository.
[ardour.git] / libs / gtkmm2 / gtk / src / treemodelfilter.hg
1 /* $Id: treemodelfilter.hg,v 1.16 2006/04/12 11:11:25 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 // We couldn't include it in treemodel.h, but doing it here makes it easier for people.
23 #include <gtkmm/treepath.h>
24
25 _DEFS(gtkmm,gtk)
26 _PINCLUDE(glibmm/private/object_p.h)
27
28 namespace Gtk
29 {
30
31 /** 
32  * @ingroup TreeView
33  * 
34  */
35 class TreeModelFilter :
36   public Glib::Object,
37   public TreeModel
38 {
39   _CLASS_GOBJECT(TreeModelFilter, GtkTreeModelFilter, GTK_TREE_MODEL_FILTER, Glib::Object, GObject)
40   _IMPLEMENTS_INTERFACE(TreeModel)
41
42 protected:
43
44   explicit TreeModelFilter(const Glib::RefPtr<TreeModel>& child_model);
45   explicit TreeModelFilter(const Glib::RefPtr<TreeModel>& child_model, const TreeModel::Path& virtual_root);
46   _IGNORE(gtk_tree_model_filter_new)
47
48 public:
49
50   /** This creates a TreeModelFilter with @a child_model as the child model.
51    * You can use set_visible_func(), set_visible_column() and/or set_modify_func() to change the mapping of child
52    * model to parent model.
53    */
54   _WRAP_CREATE(const Glib::RefPtr<TreeModel>& child_model)
55
56   /** This creates a TreeModelFilter with @a child_model as the child model, and @a root as the virtual root.
57    * You can use set_visible_func(), set_visible_column() and/or set_modify_func() to change the mapping of child
58    * model to parent model.
59    */
60   _WRAP_CREATE(const Glib::RefPtr<TreeModel>& child_model, const TreeModel::Path& virtual_root)
61
62
63   /** For instance,
64    * bool on_visible(const TreeModel::const_iterator& iter);
65    * This should return true if the given row should be visible and false otherwise.
66    */                                     
67   typedef sigc::slot<bool, const TreeModel::const_iterator&> SlotVisible;
68
69   /** Sets the "visible" callback used when filtering the filter.
70    * The callback function should return true if the given row should be visible and false otherwise.
71    *
72    * @param slot A callback slot which determines whether the row should be visible.
73    */
74   void set_visible_func(const SlotVisible& slot);
75   _IGNORE(gtk_tree_model_filter_set_visible_func)
76
77   //TODO: It would be nicer to use "const TreeModelColumnBase& column" instead of "int column",
78   //but how can we get the TreeModelColumnBase from the int in the SignalProxy?
79   //Maybe we could pass the ColumnsRecord to set_modify_func() and store it in the proxy? murrayc.
80   /** For instance,
81    *   void on_modify(const Gtk::TreeModel::iterator& iter, Glib::ValueBase& value, int column);
82    *
83    * where iter is an iterator to a row in the child model,
84    * value is an output parameter in which you must store the value to be used in the parent model's row,
85    * column is the column in the parent row whose row value you must provide in the value output paramater.
86    */
87   typedef sigc::slot<void, const Gtk::TreeModel::iterator& /* iter */, Glib::ValueBase& /* value */, int /* column */> SlotModify;
88
89   /** Specify columns that will be provided by this model, and a callback that will provide data for these 
90    * columns based on data in the columns of the child model.
91    * The modify function will get called for each data access.
92    *
93    * @param columns Column types for this model (which will be exposed to the parent model/view).
94    * @param slot A callback which will be called for each data access.
95    */
96   void set_modify_func(const TreeModelColumnRecord& columns, const SlotModify& slot);
97   _IGNORE(gtk_tree_model_filter_set_modify_func)
98  
99   _WRAP_METHOD(void set_visible_column(const TreeModelColumnBase& column), gtk_tree_model_filter_set_visible_column)
100   _WRAP_METHOD(void set_visible_column(int column), gtk_tree_model_filter_set_visible_column)
101
102   _WRAP_METHOD(Glib::RefPtr<TreeModel> get_model(), gtk_tree_model_filter_get_model, refreturn)
103   _WRAP_METHOD(Glib::RefPtr<const TreeModel> get_model() const, gtk_tree_model_filter_get_model, refreturn, constversion)
104
105   /** Gets an iterator that points to the sorted row that corresponds to the child row pointed at by child_iter.
106    *
107    * @param child_iter A valid iterator pointing to a row on the child model.
108    * @result A valid iterator that points to the row in this sorted model.
109    */
110   iterator convert_child_iter_to_iter(const iterator& child_iter) const;
111
112   /** Gets an iterator that points to the child row that corresponds to the sorted row pointed at by sorted_iter.
113    *
114    * @param filter_iter A valid iterator pointing to a row on the sorted model.
115    * @result A valid iterator that points to the row in the child model.
116    */
117   iterator convert_iter_to_child_iter(const iterator& filter_iter) const;
118
119   //TODO: Remove these deprecated non-const versions when we can break ABI:
120   _WRAP_METHOD(Path convert_child_path_to_path(const Path& child_path), gtk_tree_model_filter_convert_child_path_to_path, deprecated "Use convert_child_path_to_path(const Path& child_path) const")
121
122   _WRAP_METHOD(Path convert_path_to_child_path(const Path& filter_path), gtk_tree_model_filter_convert_path_to_child_path, deprecated "convert_path_to_child_path(const Path& filter_path) const")
123
124   _WRAP_METHOD(Path convert_child_path_to_path(const Path& child_path) const, gtk_tree_model_filter_convert_child_path_to_path)
125   _WRAP_METHOD(Path convert_path_to_child_path(const Path& filter_path) const, gtk_tree_model_filter_convert_path_to_child_path)
126
127   _WRAP_METHOD(void refilter(), gtk_tree_model_filter_refilter)
128   _WRAP_METHOD(void clear_cache(), gtk_tree_model_filter_clear_cache)
129
130 protected:
131   virtual void set_value_impl(const iterator& row, int column, const Glib::ValueBase& value);
132 };
133
134 } // namespace Gtk
135