~inkscape.dev/inkscape-devlibs/devlibs-gtk3

« back to all changes in this revision

Viewing changes to include/gtkmm-2.4/gtkmm/treemodel.h

  • Committer: JazzyNico
  • Date: 2013-01-21 10:11:05 UTC
  • Revision ID: nicoduf@yahoo.fr-20130121101105-i8d8slkq9ng4olx8
Adding gtk2 libraries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- c++ -*-
 
2
// Generated by gtkmmproc -- DO NOT MODIFY!
 
3
#ifndef _GTKMM_TREEMODEL_H
 
4
#define _GTKMM_TREEMODEL_H
 
5
 
 
6
 
 
7
#include <glibmm.h>
 
8
 
 
9
/* $Id: treemodel.hg,v 1.25 2006/05/10 20:59:28 murrayc Exp $ */
 
10
 
 
11
/* Copyright (C) 1998-2002 The gtkmm Development Team
 
12
 *
 
13
 * This library is free software; you can redistribute it and/or
 
14
 * modify it under the terms of the GNU Lesser General Public
 
15
 * License as published by the Free Software Foundation; either
 
16
 * version 2.1 of the License, or (at your option) any later version.
 
17
 *
 
18
 * This library is distributed in the hope that it will be useful,
 
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
21
 * Lesser General Public License for more details.
 
22
 *
 
23
 * You should have received a copy of the GNU Lesser General Public
 
24
 * License along with this library; if not, write to the Free
 
25
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
26
 */
 
27
 
 
28
#include <glibmm/interface.h>
 
29
#include <gtkmm/treeiter.h>
 
30
 
 
31
 
 
32
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
33
typedef struct _GtkTreeModel GtkTreeModel;
 
34
typedef struct _GtkTreeModelClass GtkTreeModelClass;
 
35
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
36
 
 
37
 
 
38
namespace Gtk
 
39
{ class TreeModel_Class; } // namespace Gtk
 
40
namespace Gtk
 
41
{
 
42
 
 
43
class TreeModelSort;
 
44
class TreePath;
 
45
class TreeRowReference;
 
46
 
 
47
 
 
48
/** @addtogroup gtkmmEnums gtkmm Enums and Flags */
 
49
 
 
50
/**
 
51
 * @ingroup gtkmmEnums
 
52
 * @par Bitwise operators:
 
53
 * <tt>%TreeModelFlags operator|(TreeModelFlags, TreeModelFlags)</tt><br>
 
54
 * <tt>%TreeModelFlags operator&(TreeModelFlags, TreeModelFlags)</tt><br>
 
55
 * <tt>%TreeModelFlags operator^(TreeModelFlags, TreeModelFlags)</tt><br>
 
56
 * <tt>%TreeModelFlags operator~(TreeModelFlags)</tt><br>
 
57
 * <tt>%TreeModelFlags& operator|=(TreeModelFlags&, TreeModelFlags)</tt><br>
 
58
 * <tt>%TreeModelFlags& operator&=(TreeModelFlags&, TreeModelFlags)</tt><br>
 
59
 * <tt>%TreeModelFlags& operator^=(TreeModelFlags&, TreeModelFlags)</tt><br>
 
60
 */
 
61
enum TreeModelFlags
 
62
{
 
63
  TREE_MODEL_ITERS_PERSIST = 1 << 0,
 
64
  TREE_MODEL_LIST_ONLY = 1 << 1
 
65
};
 
66
 
 
67
/** @ingroup gtkmmEnums */
 
68
inline TreeModelFlags operator|(TreeModelFlags lhs, TreeModelFlags rhs)
 
69
  { return static_cast<TreeModelFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); }
 
70
 
 
71
/** @ingroup gtkmmEnums */
 
72
inline TreeModelFlags operator&(TreeModelFlags lhs, TreeModelFlags rhs)
 
73
  { return static_cast<TreeModelFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); }
 
74
 
 
75
/** @ingroup gtkmmEnums */
 
76
inline TreeModelFlags operator^(TreeModelFlags lhs, TreeModelFlags rhs)
 
77
  { return static_cast<TreeModelFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); }
 
78
 
 
79
/** @ingroup gtkmmEnums */
 
80
inline TreeModelFlags operator~(TreeModelFlags flags)
 
81
  { return static_cast<TreeModelFlags>(~static_cast<unsigned>(flags)); }
 
82
 
 
83
/** @ingroup gtkmmEnums */
 
84
inline TreeModelFlags& operator|=(TreeModelFlags& lhs, TreeModelFlags rhs)
 
85
  { return (lhs = static_cast<TreeModelFlags>(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs))); }
 
86
 
 
87
/** @ingroup gtkmmEnums */
 
88
inline TreeModelFlags& operator&=(TreeModelFlags& lhs, TreeModelFlags rhs)
 
89
  { return (lhs = static_cast<TreeModelFlags>(static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs))); }
 
90
 
 
91
/** @ingroup gtkmmEnums */
 
92
inline TreeModelFlags& operator^=(TreeModelFlags& lhs, TreeModelFlags rhs)
 
93
  { return (lhs = static_cast<TreeModelFlags>(static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs))); }
 
94
 
 
95
} // namespace Gtk
 
96
 
 
97
 
 
98
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
99
namespace Glib
 
100
{
 
101
 
 
102
template <>
 
103
class Value<Gtk::TreeModelFlags> : public Glib::Value_Flags<Gtk::TreeModelFlags>
 
104
{
 
105
public:
 
106
  static GType value_type() G_GNUC_CONST;
 
107
};
 
108
 
 
109
} // namespace Glib
 
110
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
111
 
 
112
 
 
113
namespace Gtk
 
114
{
 
115
 
 
116
 
 
117
//TODO: Remove any mention of null arguments from the method documentation, by adding overrides in gtk_docs_override.xml.
 
118
/** This class defines a generic tree interface for use by the Gtk::TreeView widget.
 
119
 * @ingroup TreeView
 
120
 *
 
121
 * It is is designed to be usable with any appropriate data structure. The
 
122
 * programmer just has to implement this interface on their own data type for
 
123
 * it to be viewable by a Gtk::TreeView widget.
 
124
 *
 
125
 * The model is represented as a hierarchical tree of strongly-typed, columned
 
126
 * data. In other words, the model can be seen as a tree where every node has
 
127
 * different values depending on which column is being queried.  The type of
 
128
 * data found in a column is determined by TreeModel::Column<> templates.
 
129
 * The types are homogeneous per column across all nodes. It is important to note that this
 
130
 * interface only provides a way of examining a model and observing changes.
 
131
 * The implementation of each individual model decides how and if changes are
 
132
 * made.
 
133
 *
 
134
 * In order to make life simpler for programmers who do not need to write their
 
135
 * own specialized model, two generic models are provided - the Gtk::TreeStore
 
136
 * and the Gtk::ListStore. To use these, the developer simply pushes data into
 
137
 * these models as necessary. These models provide the data structure as well
 
138
 * as all appropriate tree interfaces. As a result, implementing drag and drop,
 
139
 * sorting, and storing data is trivial. For the vast majority of trees and
 
140
 * lists, these two models are sufficient.
 
141
 *
 
142
 * Models are accessed on a node/column level of granularity. One can query for
 
143
 * the value of a model at a certain node and a certain column on that node.
 
144
 * There are two structures used to reference a particular node in a model.
 
145
 * They are the @link Gtk::TreePath Path@endlink and the iterator. Most of the interface consists of
 
146
 * operations on an @link Gtk::TreeIter iterator@endlink.
 
147
 *
 
148
 * A @link Gtk::TreePath Gtk::TreeModel::Path@endlink is essentially a potential node. It is a location on a model that may
 
149
 * or may not actually correspond to a node on a specific model.
 
150
 *
 
151
 * By contrast, an @link Gtk::TreeIter Gtk::TreeModel::iterator@endlink  is a reference to a specific node on a specific
 
152
 * model. One can convert a path to an @link Gtk::TreeIter iterator@endlink by calling Gtk::TreeModel::get_iter().
 
153
 * These iterators are the primary way of accessing a model and are similar to the iterators
 
154
 * used by Gtk::TextBuffer. The model interface defines a set of operations
 
155
 * using them for navigating the model.
 
156
 *
 
157
 * The @link Gtk::TreeRowReference RowReference@endlink is also useful, because it remains
 
158
 * valid as long as there is an existing row pointed to by it's path. You can convert between RowReferences and iterators and @link Gtk::TreePath Path@endlink s.
 
159
 */
 
160
 
 
161
class TreeModel : public Glib::Interface
 
162
{
 
163
  
 
164
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
165
 
 
166
public:
 
167
  typedef TreeModel CppObjectType;
 
168
  typedef TreeModel_Class CppClassType;
 
169
  typedef GtkTreeModel BaseObjectType;
 
170
  typedef GtkTreeModelIface BaseClassType;
 
171
 
 
172
private:
 
173
  friend class TreeModel_Class;
 
174
  static CppClassType treemodel_class_;
 
175
 
 
176
  // noncopyable
 
177
  TreeModel(const TreeModel&);
 
178
  TreeModel& operator=(const TreeModel&);
 
179
 
 
180
protected:
 
181
  TreeModel(); // you must derive from this class
 
182
 
 
183
  /** Called by constructors of derived classes. Provide the result of 
 
184
   * the Class init() function to ensure that it is properly 
 
185
   * initialized.
 
186
   * 
 
187
   * @param interface_class The Class object for the derived type.
 
188
   */
 
189
  explicit TreeModel(const Glib::Interface_Class& interface_class);
 
190
 
 
191
public:
 
192
  // This is public so that C++ wrapper instances can be
 
193
  // created for C instances of unwrapped types.
 
194
  // For instance, if an unexpected C type implements the C interface. 
 
195
  explicit TreeModel(GtkTreeModel* castitem);
 
196
 
 
197
protected:
 
198
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
 
199
 
 
200
public:
 
201
  virtual ~TreeModel();
 
202
 
 
203
  static void add_interface(GType gtype_implementer);
 
204
 
 
205
#ifndef DOXYGEN_SHOULD_SKIP_THIS
 
206
  static GType get_type()      G_GNUC_CONST;
 
207
  static GType get_base_type() G_GNUC_CONST;
 
208
#endif
 
209
 
 
210
  ///Provides access to the underlying C GObject.
 
211
  GtkTreeModel*       gobj()       { return reinterpret_cast<GtkTreeModel*>(gobject_); }
 
212
 
 
213
  ///Provides access to the underlying C GObject.
 
214
  const GtkTreeModel* gobj() const { return reinterpret_cast<GtkTreeModel*>(gobject_); }
 
215
 
 
216
private:
 
217
 
 
218
  
 
219
public:
 
220
  typedef TreeModelColumnRecord ColumnRecord;
 
221
 
 
222
  typedef TreeNodeChildren Children;
 
223
  typedef Children::iterator iterator;
 
224
  typedef Children::reverse_iterator reverse_iterator;
 
225
  typedef Children::const_iterator const_iterator;
 
226
  typedef Children::const_reverse_iterator const_reverse_iterator;
 
227
 
 
228
  typedef TreeRow Row;
 
229
  typedef TreePath Path;
 
230
  typedef TreeRowReference RowReference;
 
231
 
 
232
 
 
233
  //These are part of GtkTreeModelFilter or GtkTreeModelSort, not GtkTreeModel:
 
234
  
 
235
 
 
236
  /** Returns a valid iterator pointing to @a path.
 
237
   *
 
238
   * @param path The @link Gtk::TreePath Gtk::TreeModel::Path@endlink.
 
239
   * @result A valid iterator pointing to the path, or an invalid iterator if that is not possible.
 
240
   */
 
241
  iterator get_iter(const Path& path);
 
242
  //TODO: Add const_iterator get_iter(const Path& path) const;
 
243
  //Implement a const_iterator?
 
244
 
 
245
  /** Returns a valid iterator pointing to @a path_string.
 
246
   *
 
247
   * @param path_string The path, as a string representation.
 
248
   * @result A valid iterator pointing to the path, or an invalid iterator if that is not possible.
 
249
   */
 
250
  iterator get_iter(const Glib::ustring& path_string);
 
251
  //TODO: Implement a const_iterator? const_iterator get_iter(const Glib::ustring& path_string) const;
 
252
 
 
253
  ///This returns an STL-like container API, for iterating over the rows.
 
254
  Children children();
 
255
 
 
256
  //TODO: Return a real TreeNodeChildren (a container of const_iterators), when we have a real const_iterator.
 
257
  ///This returns an STL-like container API, for iterating over the rows.
 
258
  Children children() const;
 
259
 
 
260
  
 
261
  /** For example,
 
262
   * void on_foreach(const Gtk::TreeModel::iterator& iter);
 
263
   *
 
264
   * If the callback function returns true, then the tree ceases to be walked, and foreach() returns.
 
265
   */
 
266
  typedef sigc::slot<bool, const TreeModel::iterator&> SlotForeachIter;
 
267
 
 
268
  /** Calls a callback slot on each node in the model in a depth-first fashion.
 
269
   * If the callback function returns true, then the tree ceases to be walked, and foreach() returns.
 
270
   *
 
271
   * @param slot The function to call for each selected node.
 
272
   */
 
273
  void foreach_iter(const SlotForeachIter& slot);
 
274
 
 
275
  /** For example,
 
276
   * void on_foreach(const Gtk::TreeModel::Path& path);
 
277
   *
 
278
   * If the callback function returns true, then the tree ceases to be walked, and foreach() returns.
 
279
   */
 
280
  typedef sigc::slot<bool, const TreeModel::Path&> SlotForeachPath;
 
281
 
 
282
  /** Calls a callback slot on each node in the model in a depth-first fashion.
 
283
   * If the callback function returns true, then the tree ceases to be walked, and foreach() returns.
 
284
   *
 
285
   * @param slot The function to call for each selected node.
 
286
   */
 
287
  void foreach_path(const SlotForeachPath& slot);
 
288
 
 
289
  /** For example,
 
290
   * void on_foreach(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter);
 
291
   *
 
292
   * If the callback function returns true, then the tree ceases to be walked, and foreach() returns.
 
293
   */
 
294
  typedef sigc::slot<bool, const TreeModel::Path&, const TreeModel::iterator&> SlotForeachPathAndIter;
 
295
 
 
296
  /** Calls a callback slot on each node in the model in a depth-first fashion.
 
297
   * If the callback function returns true, then the tree ceases to be walked, and foreach() returns.
 
298
   *
 
299
   * @param slot The function to call for each selected node.
 
300
   */
 
301
  void foreach(const SlotForeachPathAndIter& slot);
 
302
 
 
303
  
 
304
  /** Returns a set of flags supported by this interface.  The flags are a bitwise
 
305
   * combination of Gtk::TreeModelFlags.  The flags supported should not change
 
306
   * during the lifecycle of the @a tree_model.
 
307
   * @return The flags supported by this interface.
 
308
   */
 
309
  TreeModelFlags get_flags() const;
 
310
  
 
311
  /** Returns the number of columns supported by @a tree_model.
 
312
   * @return The number of columns.
 
313
   */
 
314
  int get_n_columns() const;
 
315
  
 
316
  /** Returns the type of the column.
 
317
   * @param index The column index.
 
318
   * @return The type of the column.
 
319
   */
 
320
  GType get_column_type(int index) const;
 
321
  //TODO: A C++-type version of get_column_type()?
 
322
 
 
323
  
 
324
  /** Returns a Gtk::TreePath referenced by @a iter.
 
325
   * @param iter The Gtk::TreeIter.
 
326
   * @return A Gtk::TreePath.
 
327
   */
 
328
  TreeModel::Path get_path(const iterator& iter) const;
 
329
 
 
330
  
 
331
  /** Emits the "row-changed" signal on @a tree_model.
 
332
   * @param path A Gtk::TreePath pointing to the changed row.
 
333
   * @param iter A valid Gtk::TreeIter pointing to the changed row.
 
334
   */
 
335
  void row_changed(const Path& path, const iterator& iter);
 
336
  
 
337
  /** Emits the "row-inserted" signal on @a tree_model
 
338
   * @param path A Gtk::TreePath pointing to the inserted row.
 
339
   * @param iter A valid Gtk::TreeIter pointing to the inserted row.
 
340
   */
 
341
  void row_inserted(const Path& path, const iterator& iter);
 
342
  
 
343
  /** Emits the "row-has-child-toggled" signal on @a tree_model.  This should be
 
344
   * called by models after the child state of a node changes.
 
345
   * @param path A Gtk::TreePath pointing to the changed row.
 
346
   * @param iter A valid Gtk::TreeIter pointing to the changed row.
 
347
   */
 
348
  void row_has_child_toggled(const Path& path, const iterator& iter);
 
349
  
 
350
  /** Emits the "row-deleted" signal on @a tree_model.  This should be called by
 
351
   * models after a row has been removed.  The location pointed to by @a path 
 
352
   * should be the location that the row previously was at.  It may not be a 
 
353
   * valid location anymore.
 
354
   * @param path A Gtk::TreePath pointing to the previous location of the deleted row.
 
355
   */
 
356
  void row_deleted(const Path& path);
 
357
 
 
358
 /** Emits the "rows_reordered" signal on the tree model.  This should be called by
 
359
  * custom models when their rows have been reordered.
 
360
  *
 
361
  * @param path A tree path pointing to the tree node whose children have been reordered.
 
362
  * @param iter A valid iterator pointing to the node whose children have been reordered. See also, rows_reordered(const Path& path, const Glib::ArrayHandle<int>& new_order), if the path has a depth of 0.
 
363
  * @param new_order An array of integers mapping the current position of each child
 
364
  * to its old position before the re-ordering, i.e. @a new_order<literal>[newpos] = oldpos.
 
365
  */
 
366
  void rows_reordered(const Path& path, const iterator& iter, const Glib::ArrayHandle<int>& new_order);
 
367
 
 
368
 /** Emits the "rows_reordered" signal on the tree model.  This should be called by
 
369
  * custom models when their rows have been reordered. This method overload is for nodes whose
 
370
  * path has a depth of 0.
 
371
  * @newin{2,10}
 
372
  *
 
373
  * @param path A tree path pointing to the tree node whose children have been reordered.
 
374
  * @param new_order An array of integers mapping the current position of each child
 
375
  * to its old position before the re-ordering, i.e. @a new_order<literal>[newpos] = oldpos.
 
376
  */
 
377
  void rows_reordered(const Path& path, const Glib::ArrayHandle<int>& new_order);
 
378
 
 
379
  
 
380
  /** Emits the "rows-reordered" signal on @a tree_model.  This should be called by
 
381
   * models when their rows have been reordered.
 
382
   * @param path A Gtk::TreePath pointing to the tree node whose children have been 
 
383
   * reordered.
 
384
   * @param iter A valid Gtk::TreeIter pointing to the node whose children have been 
 
385
   * reordered, or <tt>0</tt> if the depth of @a path is 0.
 
386
   * @param new_order An array of integers mapping the current position of each child
 
387
   * to its old position before the re-ordering,
 
388
   * i.e. @a new_order<tt>[newpos] = oldpos</tt>.
 
389
   */
 
390
  void rows_reordered(const Path& path, const iterator& iter, int* new_order);
 
391
 
 
392
  
 
393
  /** Generates a string representation of the iter. This string is a ':'
 
394
   * separated list of numbers. For example, "4:10:0:3" would be an
 
395
   * acceptable return value for this string.
 
396
   * 
 
397
   * @newin{2,2}
 
398
   * @param iter An Gtk::TreeIter.
 
399
   * @return The string.
 
400
   */
 
401
  Glib::ustring get_string(const iterator& iter) const;
 
402
 
 
403
 
 
404
  /**
 
405
   * @par Prototype:
 
406
   * <tt>void on_my_%row_changed(const TreeModel::Path& path, const TreeModel::iterator& iter)</tt>
 
407
   */
 
408
 
 
409
  Glib::SignalProxy2< void,const TreeModel::Path&,const TreeModel::iterator& > signal_row_changed();
 
410
 
 
411
  
 
412
  /**
 
413
   * @par Prototype:
 
414
   * <tt>void on_my_%row_inserted(const TreeModel::Path& path, const TreeModel::iterator& iter)</tt>
 
415
   */
 
416
 
 
417
  Glib::SignalProxy2< void,const TreeModel::Path&,const TreeModel::iterator& > signal_row_inserted();
 
418
 
 
419
  
 
420
  /**
 
421
   * @par Prototype:
 
422
   * <tt>void on_my_%row_has_child_toggled(const TreeModel::Path& path, const TreeModel::iterator& iter)</tt>
 
423
   */
 
424
 
 
425
  Glib::SignalProxy2< void,const TreeModel::Path&,const TreeModel::iterator& > signal_row_has_child_toggled();
 
426
 
 
427
  
 
428
  /**
 
429
   * @par Prototype:
 
430
   * <tt>void on_my_%row_deleted(const TreeModel::Path& path)</tt>
 
431
   */
 
432
 
 
433
  Glib::SignalProxy1< void,const TreeModel::Path& > signal_row_deleted();
 
434
 
 
435
  
 
436
  /**
 
437
   * @par Prototype:
 
438
   * <tt>void on_my_%rows_reordered(const TreeModel::Path& path, const TreeModel::iterator& iter, int* new_order)</tt>
 
439
   */
 
440
 
 
441
  Glib::SignalProxy3< void,const TreeModel::Path&,const TreeModel::iterator&,int* > signal_rows_reordered();
 
442
 
 
443
 
 
444
protected:
 
445
    virtual TreeModelFlags get_flags_vfunc() const;
 
446
 
 
447
    virtual int get_n_columns_vfunc() const;
 
448
 
 
449
    virtual GType get_column_type_vfunc(int index) const;
 
450
 
 
451
 
 
452
  //These are only for deriving new TreeModels, which isn't very common or easy:
 
453
 
 
454
  /** Override and implement this in a derived TreeModel class.
 
455
   * Sets @a iter_next to refer to the node following @a iter it at the current level.
 
456
   * If there is no next iter, false is returned and iter_next is set to be invalid.
 
457
   *
 
458
   * @param iter An iterator.
 
459
   * @param iter_next An iterator that will be set to refer to the next node, or will be set as invalid.
 
460
   * @result true if the operation was possible.
 
461
   */
 
462
  virtual bool iter_next_vfunc(const iterator& iter, iterator& iter_next) const;
 
463
 
 
464
  /** Override and implement this in a derived TreeModel class.
 
465
   * Sets @a iter to a valid iterator pointing to @a path
 
466
   *
 
467
   * @param path An path to a node.
 
468
   * @param iter An iterator that will be set to refer to a node to the path, or will be set as invalid.
 
469
   * @result true if the operation was possible.
 
470
   */
 
471
  virtual bool get_iter_vfunc(const Path& path, iterator& iter) const;
 
472
 
 
473
  /** Override and implement this in a derived TreeModel class.
 
474
   * Sets @a iter to refer to the first child of @a parent. If @a parent has no children,
 
475
   * false is returned and @a iter is set to be invalid.
 
476
   *
 
477
   * @param parent An iterator.
 
478
   * @param iter An iterator that will be set to refer to the firt child node, or will be set as invalid.
 
479
   * @result true if the operation was possible.
 
480
   */
 
481
  virtual bool iter_children_vfunc(const iterator& parent, iterator& iter) const;
 
482
 
 
483
  /** Override and implement this in a derived TreeModel class.
 
484
   * Sets @a iter to be the parent of @a child. If @a child is at the toplevel, and
 
485
   * doesn't have a parent, then @a iter is set to an invalid iterator and false
 
486
   * is returned.
 
487
   *
 
488
   * @param child An iterator.
 
489
   * @param iter An iterator that will be set to refer to the parent node, or will be set as invalid.
 
490
   * @result true if the operation was possible.
 
491
   */
 
492
  virtual bool iter_parent_vfunc(const iterator& child, iterator& iter) const;
 
493
 
 
494
  /** Override and implement this in a derived TreeModel class.
 
495
   * Sets @a iter to be the child of @a parent using the given index.  The first
 
496
   * index is 0.  If @a n is too big, or @a parent has no children, @a iter is set
 
497
   * to an invalid iterator and false is returned.
 
498
   * See also iter_nth_root_child_vfunc()
 
499
   *
 
500
   * @param parent An iterator.
 
501
   * @param n The index of the child node to which @a iter should be set.
 
502
   * @param iter An iterator that will be set to refer to the nth node, or will be set as invalid.
 
503
   * @result true if the operation was possible.
 
504
   */
 
505
  virtual bool iter_nth_child_vfunc(const iterator& parent, int n, iterator& iter) const;
 
506
 
 
507
   /** Override and implement this in a derived TreeModel class.
 
508
   * Sets @a iter to be the child of at the root level using the given index.  The first
 
509
   * index is 0.  If @a n is too big, or if there are no children, @a iter is set
 
510
   * to an invalid iterator and false is returned.
 
511
   * See also iter_nth_child_vfunc().
 
512
   *
 
513
   * @param n The index of the child node to which @a iter should be set.
 
514
   * @param iter An iterator that will be set to refer to the nth node, or will be set as invalid.
 
515
   * @result true if the operation was possible.
 
516
   */
 
517
  virtual bool iter_nth_root_child_vfunc(int n, iterator& iter) const;
 
518
 
 
519
 
 
520
  /** Override and implement this in a derived TreeModel class.
 
521
   * Returns true if @a iter has children, false otherwise.
 
522
   *
 
523
   * @param iter The iterator to test for children.
 
524
   * @result true if @a iter has children.
 
525
   */
 
526
    virtual bool iter_has_child_vfunc(const iterator& iter) const;
 
527
 
 
528
 
 
529
  /** Override and implement this in a derived TreeModel class.
 
530
   * Returns the number of children that @a iter has.
 
531
   * See also iter_n_root_children_vfunc().
 
532
   *
 
533
   * @param iter The iterator to test for children.
 
534
   * @result The number of children of @a iter.
 
535
   */
 
536
  virtual int iter_n_children_vfunc(const iterator& iter) const;
 
537
 
 
538
  /** Override and implement this in a derived TreeModel class.
 
539
   * Returns the number of toplevel nodes.
 
540
   * See also iter_n_children().
 
541
   *
 
542
   * @result The number of children at the root level.
 
543
   */
 
544
  virtual int iter_n_root_children_vfunc() const;
 
545
 
 
546
  /** Override and implement this in a derived TreeModel class.
 
547
   * Lets the tree ref the node.  This is an optional method for models to
 
548
   * implement.  To be more specific, models may ignore this call as it exists
 
549
   * primarily for performance reasons.
 
550
   *
 
551
   * This function is primarily meant as a way for views to let caching model know
 
552
   * when nodes are being displayed (and hence, whether or not to cache that
 
553
   * node.)  For example, a file-system based model would not want to keep the
 
554
   * entire file-hierarchy in memory, just the sections that are currently being
 
555
   * displayed by every current view.
 
556
   *
 
557
   * A model should be expected to be able to get an iter independent of its
 
558
   * reffed state.
 
559
   *
 
560
   * @param iter the iterator.
 
561
   */
 
562
    virtual void ref_node_vfunc(const iterator& iter) const;
 
563
 
 
564
 
 
565
  /** Override and implement this in a derived TreeModel class.
 
566
   * Lets the tree unref the node.  This is an optional method for models to
 
567
   * implement.  To be more specific, models may ignore this call as it exists
 
568
   * primarily for performance reasons.
 
569
   *
 
570
   * For more information on what this means, see unref_node_vfunc().
 
571
   * Please note that nodes that are deleted are not unreffed.
 
572
   *
 
573
   * @param iter the iterator.
 
574
   */
 
575
    virtual void unref_node_vfunc(const iterator& iter) const;
 
576
 
 
577
 
 
578
  /** Override and implement this in a derived TreeModel class.
 
579
   * Returns a Path referenced by @a iter.
 
580
   *
 
581
   * @param iter The iterator.
 
582
   * @result The path.
 
583
   */
 
584
 
 
585
 
 
586
    virtual TreeModel::Path get_path_vfunc(const iterator& iter) const;
 
587
 
 
588
 
 
589
  /** Override and implement this in a derived TreeModel class.
 
590
   * Initializes and sets @a value to that at @a column.
 
591
   *
 
592
   * @param iter The iterator.
 
593
   * @param column The column to lookup the value at.
 
594
   * @param value An empty Glib:Value to set.
 
595
   */
 
596
    virtual void get_value_vfunc(const iterator& iter, int column, Glib::ValueBase& value) const;
 
597
 
 
598
 
 
599
  //We don't put an deprecation ifdef around this because it would break ABI.
 
600
  /** Override and implement this in a derived TreeModel class.
 
601
   * @note This virtual method is not recommended.  To check
 
602
   * whether an iterator is valid, call TreeStore::iter_is_valid(),
 
603
   * ListStore::iter_is_valid() or TreeModelSort::iter_is_valid() directly
 
604
   * instead.  Because these methods are intended to be used only for debugging
 
605
   * and/or testing purposes, it doesn't make sense to provide an abstract
 
606
   * interface to them.
 
607
   *
 
608
   * @result true if the iterator is valid.
 
609
   *
 
610
   * @deprecated Use iter_is_valid() in the derived class.
 
611
   */
 
612
  virtual bool iter_is_valid(const iterator& iter) const;
 
613
 
 
614
  //Called by TreeRow, which is a friend class:
 
615
  //The comment about set_row_changed() in the documentation is based on my reading of the source of
 
616
  //gtk_list_store_set_value() and gtk_tree_store_set_value().
 
617
  /** Override and implement this in a derived TreeModel class, so that Row::operator() and
 
618
   * Row::set_value() work.
 
619
   * You can probably just implement this by calling set_value_vfunc().
 
620
   * Your implementation of set_value_impl() should also call row_changed() after changing the value.
 
621
   */
 
622
  virtual void set_value_impl(const iterator& row, int column, const Glib::ValueBase& value);
 
623
 
 
624
  //This might not need to be virtual, but it's not a big deal. murrayc.
 
625
  virtual void get_value_impl(const iterator& row, int column, Glib::ValueBase& value) const;
 
626
 
 
627
  friend class Gtk::TreeModelSort;
 
628
  friend class Gtk::TreeRow;
 
629
  friend class Gtk::TreeIter;
 
630
 
 
631
 
 
632
public:
 
633
 
 
634
public:
 
635
  //C++ methods used to invoke GTK+ virtual functions:
 
636
 
 
637
protected:
 
638
  //GTK+ Virtual Functions (override these to change behaviour):
 
639
 
 
640
  //Default Signal Handlers::
 
641
  virtual void on_row_changed(const TreeModel::Path& path, const TreeModel::iterator& iter);
 
642
  virtual void on_row_inserted(const TreeModel::Path& path, const TreeModel::iterator& iter);
 
643
  virtual void on_row_has_child_toggled(const TreeModel::Path& path, const TreeModel::iterator& iter);
 
644
  virtual void on_row_deleted(const TreeModel::Path& path);
 
645
  virtual void on_rows_reordered(const TreeModel::Path& path, const TreeModel::iterator& iter, int* new_order);
 
646
 
 
647
 
 
648
};
 
649
 
 
650
} // namespace Gtk
 
651
 
 
652
 
 
653
namespace Glib
 
654
{
 
655
  /** A Glib::wrap() method for this object.
 
656
   * 
 
657
   * @param object The C instance.
 
658
   * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
 
659
   * @result A C++ instance that wraps this C instance.
 
660
   *
 
661
   * @relates Gtk::TreeModel
 
662
   */
 
663
  Glib::RefPtr<Gtk::TreeModel> wrap(GtkTreeModel* object, bool take_copy = false);
 
664
 
 
665
} // namespace Glib
 
666
 
 
667
 
 
668
#endif /* _GTKMM_TREEMODEL_H */
 
669