Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / treemodelfilter.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_TREEMODELFILTER_H
4 #define _GTKMM_TREEMODELFILTER_H
5
6 #include <glibmm.h>
7
8 /* $Id$ */
9
10 /* Copyright(C) 1998-2002 The gtkmm Development Team
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Library General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or(at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public
23  * License along with this library; if not, write to the Free
24  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25  */
26
27 #include <gtkmm/treeiter.h>
28 #include <gtkmm/treemodel.h>
29 // We couldn't include it in treemodel.h, but doing it here makes it easier for people.
30 #include <gtkmm/treepath.h>
31
32
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 typedef struct _GtkTreeModelFilter GtkTreeModelFilter;
35 typedef struct _GtkTreeModelFilterClass GtkTreeModelFilterClass;
36 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
37
38
39 namespace Gtk
40 { class TreeModelFilter_Class; } // namespace Gtk
41 namespace Gtk
42 {
43
44 /** 
45  * @ingroup TreeView
46  * 
47  */
48
49 class TreeModelFilter :
50   public Glib::Object,
51   public TreeModel
52 {
53   
54 #ifndef DOXYGEN_SHOULD_SKIP_THIS
55
56 public:
57   typedef TreeModelFilter CppObjectType;
58   typedef TreeModelFilter_Class CppClassType;
59   typedef GtkTreeModelFilter BaseObjectType;
60   typedef GtkTreeModelFilterClass BaseClassType;
61
62 private:  friend class TreeModelFilter_Class;
63   static CppClassType treemodelfilter_class_;
64
65 private:
66   // noncopyable
67   TreeModelFilter(const TreeModelFilter&);
68   TreeModelFilter& operator=(const TreeModelFilter&);
69
70 protected:
71   explicit TreeModelFilter(const Glib::ConstructParams& construct_params);
72   explicit TreeModelFilter(GtkTreeModelFilter* castitem);
73
74 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
75
76 public:
77   virtual ~TreeModelFilter();
78
79 #ifndef DOXYGEN_SHOULD_SKIP_THIS
80   static GType get_type()      G_GNUC_CONST;
81   static GType get_base_type() G_GNUC_CONST;
82 #endif
83
84   ///Provides access to the underlying C GObject.
85   GtkTreeModelFilter*       gobj()       { return reinterpret_cast<GtkTreeModelFilter*>(gobject_); }
86
87   ///Provides access to the underlying C GObject.
88   const GtkTreeModelFilter* gobj() const { return reinterpret_cast<GtkTreeModelFilter*>(gobject_); }
89
90   ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
91   GtkTreeModelFilter* gobj_copy();
92
93 private:
94
95   
96 protected:
97
98   explicit TreeModelFilter(const Glib::RefPtr<TreeModel>& child_model);
99   explicit TreeModelFilter(const Glib::RefPtr<TreeModel>& child_model, const TreeModel::Path& virtual_root);
100   
101
102 public:
103
104   /** This creates a TreeModelFilter with @a child_model as the child model.
105    * You can use set_visible_func(), set_visible_column() and/or set_modify_func() to change the mapping of child
106    * model to parent model.
107    */
108   
109   static Glib::RefPtr<TreeModelFilter> create(const Glib::RefPtr<TreeModel>& child_model);
110
111
112   /** This creates a TreeModelFilter with @a child_model as the child model, and @a root as the virtual root.
113    * You can use set_visible_func(), set_visible_column() and/or set_modify_func() to change the mapping of child
114    * model to parent model.
115    */
116   
117   static Glib::RefPtr<TreeModelFilter> create(const Glib::RefPtr<TreeModel>& child_model, const TreeModel::Path& virtual_root);
118
119
120   /** For instance,
121    * bool on_visible(const TreeModel::const_iterator& iter);
122    * This should return true if the given row should be visible and false otherwise.
123    */                                     
124   typedef sigc::slot<bool, const TreeModel::const_iterator&> SlotVisible;
125
126   /** Sets the "visible" callback used when filtering the filter.
127    * The callback function should return true if the given row should be visible and false otherwise.
128    *
129    * @param slot A callback slot which determines whether the row should be visible.
130    */
131   void set_visible_func(const SlotVisible& slot);
132   
133
134   //TODO: It would be nicer to use "const TreeModelColumnBase& column" instead of "int column",
135   //but how can we get the TreeModelColumnBase from the int in the SignalProxy?
136   //Maybe we could pass the ColumnsRecord to set_modify_func() and store it in the proxy? murrayc.
137   /** For instance,
138    *   void on_modify(const Gtk::TreeModel::iterator& iter, Glib::ValueBase& value, int column);
139    *
140    * where iter is an iterator to a row in the child model,
141    * value is an output parameter in which you must store the value to be used in the parent model's row,
142    * column is the column in the parent row whose row value you must provide in the value output paramater.
143    */
144   typedef sigc::slot<void, const Gtk::TreeModel::iterator& /* iter */, Glib::ValueBase& /* value */, int /* column */> SlotModify;
145
146   /** Specify columns that will be provided by this model, and a callback that will provide data for these 
147    * columns based on data in the columns of the child model.
148    * The modify function will get called for each data access.
149    *
150    * @param columns Column types for this model (which will be exposed to the parent model/view).
151    * @param slot A callback which will be called for each data access.
152    */
153   void set_modify_func(const TreeModelColumnRecord& columns, const SlotModify& slot);
154   
155  
156   /** Sets @a column  of the child_model to be the column where @a filter  should
157    * look for visibility information. @a columns  should be a column of type
158    * G::TYPE_BOOLEAN, where <tt>true</tt> means that a row is visible, and <tt>false</tt>
159    * if not.
160    * 
161    * Since: 2.4
162    * @param column A <tt>int</tt> which is the column containing the visible information.
163    */
164   void set_visible_column(const TreeModelColumnBase& column);
165   
166   /** Sets @a column  of the child_model to be the column where @a filter  should
167    * look for visibility information. @a columns  should be a column of type
168    * G::TYPE_BOOLEAN, where <tt>true</tt> means that a row is visible, and <tt>false</tt>
169    * if not.
170    * 
171    * Since: 2.4
172    * @param column A <tt>int</tt> which is the column containing the visible information.
173    */
174   void set_visible_column(int column);
175
176   
177   /** Returns a pointer to the child model of @a filter .
178    * @return A pointer to a Gtk::TreeModel.
179    * 
180    * Since: 2.4.
181    */
182   Glib::RefPtr<TreeModel> get_model();
183   
184   /** Returns a pointer to the child model of @a filter .
185    * @return A pointer to a Gtk::TreeModel.
186    * 
187    * Since: 2.4.
188    */
189   Glib::RefPtr<const TreeModel> get_model() const;
190
191   /** Gets an iterator that points to the sorted row that corresponds to the child row pointed at by child_iter.
192    *
193    * @param child_iter A valid iterator pointing to a row on the child model.
194    * @result A valid iterator that points to the row in this sorted model.
195    */
196   iterator convert_child_iter_to_iter(const iterator& child_iter) const;
197
198   /** Gets an iterator that points to the child row that corresponds to the sorted row pointed at by sorted_iter.
199    *
200    * @param filter_iter A valid iterator pointing to a row on the sorted model.
201    * @result A valid iterator that points to the row in the child model.
202    */
203   iterator convert_iter_to_child_iter(const iterator& filter_iter) const;
204
205   //TODO: Remove these deprecated non-const versions when we can break ABI:
206   
207   /** Converts @a child_path  to a path relative to @a filter . That is, @a child_path 
208    * points to a path in the child model. The rerturned path will point to the
209    * same row in the filtered model. If @a child_path  isn't a valid path on the
210    * child model, then <tt>0</tt> is returned.
211    * @param child_path A Gtk::TreePath to convert.
212    * @return A newly allocated Gtk::TreePath, or <tt>0</tt>.
213    * 
214    * Since: 2.4.
215    */
216   Path convert_child_path_to_path(const Path& child_path);
217   
218   /** Converts @a filter_path  to a path on the child model of @a filter . That is,
219    *  @a filter_path  points to a location in @a filter . The returned path will
220    * point to the same location in the model not being filtered. If @a filter_path 
221    * does not point to a location in the child model, <tt>0</tt> is returned.
222    * @param filter_path A Gtk::TreePath to convert.
223    * @return A newly allocated Gtk::TreePath, or <tt>0</tt>.
224    * 
225    * Since: 2.4.
226    */
227   Path convert_path_to_child_path(const Path& filter_path);
228
229   
230   /** Converts @a child_path  to a path relative to @a filter . That is, @a child_path 
231    * points to a path in the child model. The rerturned path will point to the
232    * same row in the filtered model. If @a child_path  isn't a valid path on the
233    * child model, then <tt>0</tt> is returned.
234    * @param child_path A Gtk::TreePath to convert.
235    * @return A newly allocated Gtk::TreePath, or <tt>0</tt>.
236    * 
237    * Since: 2.4.
238    */
239   Path convert_child_path_to_path(const Path& child_path) const;
240   
241   /** Converts @a filter_path  to a path on the child model of @a filter . That is,
242    *  @a filter_path  points to a location in @a filter . The returned path will
243    * point to the same location in the model not being filtered. If @a filter_path 
244    * does not point to a location in the child model, <tt>0</tt> is returned.
245    * @param filter_path A Gtk::TreePath to convert.
246    * @return A newly allocated Gtk::TreePath, or <tt>0</tt>.
247    * 
248    * Since: 2.4.
249    */
250   Path convert_path_to_child_path(const Path& filter_path) const;
251
252   
253   /** Emits ::row_changed for each row in the child model, which causes
254    * the filter to re-evaluate whether a row is visible or not.
255    * 
256    * Since: 2.4
257    */
258   void refilter();
259   
260   /** This function should almost never be called. It clears the @a filter 
261    * of any cached iterators that haven't been reffed with
262    * ref_node(). This might be useful if the child model
263    * being filtered is static (and doesn't change often) and there has been
264    * a lot of unreffed access to nodes. As a side effect of this function,
265    * all unreffed itters will be invalid.
266    * 
267    * Since: 2.4
268    */
269   void clear_cache();
270
271 protected:
272   virtual void set_value_impl(const iterator& row, int column, const Glib::ValueBase& value);
273
274
275 public:
276
277 public:
278   //C++ methods used to invoke GTK+ virtual functions:
279
280 protected:
281   //GTK+ Virtual Functions (override these to change behaviour):
282
283   //Default Signal Handlers::
284
285
286 };
287
288 } // namespace Gtk
289
290
291 namespace Glib
292 {
293   /** @relates Gtk::TreeModelFilter
294    * @param object The C instance
295    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
296    * @result A C++ instance that wraps this C instance.
297    */
298   Glib::RefPtr<Gtk::TreeModelFilter> wrap(GtkTreeModelFilter* object, bool take_copy = false);
299 }
300
301
302 #endif /* _GTKMM_TREEMODELFILTER_H */
303