2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_TREEMODELFILTER_H
4 #define _GTKMM_TREEMODELFILTER_H
10 /* Copyright(C) 1998-2002 The gtkmm Development Team
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.
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.
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.
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>
33 #ifndef DOXYGEN_SHOULD_SKIP_THIS
34 typedef struct _GtkTreeModelFilter GtkTreeModelFilter;
35 typedef struct _GtkTreeModelFilterClass GtkTreeModelFilterClass;
36 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
40 { class TreeModelFilter_Class; } // namespace Gtk
49 class TreeModelFilter :
54 #ifndef DOXYGEN_SHOULD_SKIP_THIS
57 typedef TreeModelFilter CppObjectType;
58 typedef TreeModelFilter_Class CppClassType;
59 typedef GtkTreeModelFilter BaseObjectType;
60 typedef GtkTreeModelFilterClass BaseClassType;
62 private: friend class TreeModelFilter_Class;
63 static CppClassType treemodelfilter_class_;
67 TreeModelFilter(const TreeModelFilter&);
68 TreeModelFilter& operator=(const TreeModelFilter&);
71 explicit TreeModelFilter(const Glib::ConstructParams& construct_params);
72 explicit TreeModelFilter(GtkTreeModelFilter* castitem);
74 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
77 virtual ~TreeModelFilter();
79 #ifndef DOXYGEN_SHOULD_SKIP_THIS
80 static GType get_type() G_GNUC_CONST;
81 static GType get_base_type() G_GNUC_CONST;
84 ///Provides access to the underlying C GObject.
85 GtkTreeModelFilter* gobj() { return reinterpret_cast<GtkTreeModelFilter*>(gobject_); }
87 ///Provides access to the underlying C GObject.
88 const GtkTreeModelFilter* gobj() const { return reinterpret_cast<GtkTreeModelFilter*>(gobject_); }
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();
98 explicit TreeModelFilter(const Glib::RefPtr<TreeModel>& child_model);
99 explicit TreeModelFilter(const Glib::RefPtr<TreeModel>& child_model, const TreeModel::Path& virtual_root);
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.
109 static Glib::RefPtr<TreeModelFilter> create(const Glib::RefPtr<TreeModel>& child_model);
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.
117 static Glib::RefPtr<TreeModelFilter> create(const Glib::RefPtr<TreeModel>& child_model, const TreeModel::Path& virtual_root);
121 * bool on_visible(const TreeModel::const_iterator& iter);
122 * This should return true if the given row should be visible and false otherwise.
124 typedef sigc::slot<bool, const TreeModel::const_iterator&> SlotVisible;
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.
129 * @param slot A callback slot which determines whether the row should be visible.
131 void set_visible_func(const SlotVisible& slot);
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.
138 * void on_modify(const Gtk::TreeModel::iterator& iter, Glib::ValueBase& value, int column);
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.
144 typedef sigc::slot<void, const Gtk::TreeModel::iterator& /* iter */, Glib::ValueBase& /* value */, int /* column */> SlotModify;
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.
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.
153 void set_modify_func(const TreeModelColumnRecord& columns, const SlotModify& slot);
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>
162 * @param column A <tt>int</tt> which is the column containing the visible information.
164 void set_visible_column(const TreeModelColumnBase& column);
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>
172 * @param column A <tt>int</tt> which is the column containing the visible information.
174 void set_visible_column(int column);
177 /** Returns a pointer to the child model of @a filter .
178 * @return A pointer to a Gtk::TreeModel.
182 Glib::RefPtr<TreeModel> get_model();
184 /** Returns a pointer to the child model of @a filter .
185 * @return A pointer to a Gtk::TreeModel.
189 Glib::RefPtr<const TreeModel> get_model() const;
191 /** Gets an iterator that points to the sorted row that corresponds to the child row pointed at by child_iter.
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.
196 iterator convert_child_iter_to_iter(const iterator& child_iter) const;
198 /** Gets an iterator that points to the child row that corresponds to the sorted row pointed at by sorted_iter.
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.
203 iterator convert_iter_to_child_iter(const iterator& filter_iter) const;
205 //TODO: Remove these deprecated non-const versions when we can break ABI:
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>.
216 Path convert_child_path_to_path(const Path& child_path);
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>.
227 Path convert_path_to_child_path(const Path& filter_path);
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>.
239 Path convert_child_path_to_path(const Path& child_path) const;
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>.
250 Path convert_path_to_child_path(const Path& filter_path) const;
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.
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.
272 virtual void set_value_impl(const iterator& row, int column, const Glib::ValueBase& value);
278 //C++ methods used to invoke GTK+ virtual functions:
281 //GTK+ Virtual Functions (override these to change behaviour):
283 //Default Signal Handlers::
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.
298 Glib::RefPtr<Gtk::TreeModelFilter> wrap(GtkTreeModelFilter* object, bool take_copy = false);
302 #endif /* _GTKMM_TREEMODELFILTER_H */