summaryrefslogtreecommitdiff
path: root/libs/gtkmm2/gtk/gtkmm/treestore.h
blob: e5d01a4443829d4f29b0fd21c50d5ba31a0ab200 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
// -*- c++ -*-
// Generated by gtkmmproc -- DO NOT MODIFY!
#ifndef _GTKMM_TREESTORE_H
#define _GTKMM_TREESTORE_H

#include <glibmm.h>

/* $Id$ */

/* Copyright(C) 1998-2002 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or(at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gtkmm/treeiter.h>
#include <gtkmm/treemodel.h>
#include <gtkmm/treesortable.h>
#include <gtkmm/treedragdest.h>
#include <gtkmm/treedragsource.h>
// We couldn't include it in treemodel.h, but doing it here makes it easier for people.
#include <gtkmm/treepath.h>


#ifndef DOXYGEN_SHOULD_SKIP_THIS
typedef struct _GtkTreeStore GtkTreeStore;
typedef struct _GtkTreeStoreClass GtkTreeStoreClass;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */


namespace Gtk
{ class TreeStore_Class; } // namespace Gtk
namespace Gtk
{

/**
 * @ingroup TreeView
 */

class TreeStore :
  public Glib::Object,
  public Gtk::TreeModel,
  public TreeSortable,
  public TreeDragSource,
  public TreeDragDest
{
  
#ifndef DOXYGEN_SHOULD_SKIP_THIS

public:
  typedef TreeStore CppObjectType;
  typedef TreeStore_Class CppClassType;
  typedef GtkTreeStore BaseObjectType;
  typedef GtkTreeStoreClass BaseClassType;

private:  friend class TreeStore_Class;
  static CppClassType treestore_class_;

private:
  // noncopyable
  TreeStore(const TreeStore&);
  TreeStore& operator=(const TreeStore&);

protected:
  explicit TreeStore(const Glib::ConstructParams& construct_params);
  explicit TreeStore(GtkTreeStore* castitem);

#endif /* DOXYGEN_SHOULD_SKIP_THIS */

public:
  virtual ~TreeStore();

#ifndef DOXYGEN_SHOULD_SKIP_THIS
  static GType get_type()      G_GNUC_CONST;
  static GType get_base_type() G_GNUC_CONST;
#endif

  ///Provides access to the underlying C GObject.
  GtkTreeStore*       gobj()       { return reinterpret_cast<GtkTreeStore*>(gobject_); }

  ///Provides access to the underlying C GObject.
  const GtkTreeStore* gobj() const { return reinterpret_cast<GtkTreeStore*>(gobject_); }

  ///Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
  GtkTreeStore* gobj_copy();

private:

  
protected:
  /** When using this constructor, you must use set_column_types() immediately afterwards.
   * This can be useful when deriving from this class, with a fixed TreeModelColumnRecord
   * that is a member of the class.
   * There is no create() method that corresponds to this constructor, because this
   * constructor should only be used by derived classes.
   */
  TreeStore();
  
  explicit TreeStore(const TreeModelColumnRecord& columns);

public:
  /** Instantiate a new TreeStore.
   * @param columns The column types for this tree model.
   * @result The new TreeStore.
   */
  
  static Glib::RefPtr<TreeStore> create(const TreeModelColumnRecord& columns);


  void set_column_types(const TreeModelColumnRecord& columns);
  

  /** Removes the given row from the list store.
   * @param iter The iterator to the row to be removed.
   * @result An iterator to the next row, or end() if there is none.
   */
  iterator erase(const iterator& iter);
  

  //TODO: Make this documentation similar to documentation for Standard C++ insert methods.
  /** Creates a new row before the position.
   * If iter is end() then a new row will be appended to the list.
   * The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value().
   * See also prepend() and append().
   *
   * @param iter An iterator to the row before which the new row will be inserted.
   * @result An iterator to the new row.
   */
  iterator insert(const iterator& iter);
  

  /** Creates a new row after the position.
   * If iter is end() then a new row will be prepended to the list.
   * The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value().
   * See also prepend() and append().
   *
   * @param iter An iterator to the row after which the new row will be inserted.
   * @result An iterator to the new row.
   */
  iterator insert_after(const iterator& iter);
  

  /** Creates a new row at the start of the top-level.
   * The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value().
   * See also insert() and append().
   *
   * @result An iterator to the new row.
   */
  iterator prepend();

  /** Creates a new row at the start of the row's children.
   * The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value().
   * See also insert() and append().
   *
   * @param node The list of the parent row's children, as returned by Gtk::TreeModel::iterator::children().
   * @result An iterator to the new row.
   */
  iterator prepend(const TreeNodeChildren& node);


  /** Creates a new row at the end of the top-level.
   * The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value().
   * See also insert() and prepend().
   *
   * @result An iterator to the new row.
   */
  iterator append();

  /** Creates a new row at the end of the row's children.
   * The row will be empty - to fill in values, you need to dereference the returned iterator and use Row::operator[] or Row::set_value().
   * See also insert() and prepend().
   *
   * @param node The list of the parent row's children, as returned by Gtk::TreeModel::iterator::children().
   * @result An iterator to the new row.
   */  
  iterator append(const TreeNodeChildren& node);

  
  /** Swaps @a a  and @a b  in the same level of @a tree_store . Note that this function
   * only works with unsorted stores.
   * 
   * Since: 2.2
   * @param a A Gtk::TreeIter.
   * @param b Another Gtk::TreeIter.
   */
  void iter_swap(const iterator& a, const iterator& b);

  /** Moves @a source to the position at @a destination.
   * @a source and @a destination should be at the same level.
   * Note that this function only works with unsorted stores.
   * @param source The row that should be moved.
   * @param destination The position to move to.
   */
  void move(const iterator& source, const iterator& destination);

  /** Reorders the children of @a node to follow the order indicated by @a new_order.
   * Note that this function only works with unsorted stores.
   */
  void reorder(const TreeNodeChildren& node, const Glib::ArrayHandle<int>& new_order);

  
  /** Removes all rows from @a tree_store 
   */
  void clear();
  
  /** Returns <tt>true</tt> if @a iter  is an ancestor of @a descendant .  That is, @a iter  is the
   * parent (or grandparent or great-grandparent) of @a descendant .
   * @param iter A valid Gtk::TreeIter.
   * @param descendant A valid Gtk::TreeIter.
   * @return <tt>true</tt>, if @a iter  is an ancestor of @a descendant .
   */
  bool is_ancestor(const iterator& iter, const iterator& descendant) const;
  
  /** Returns the depth of @a iter .  This will be 0 for anything on the root level, 1
   * for anything down a level, etc.
   * @param iter A valid Gtk::TreeIter.
   * @return The depth of @a iter .
   */
  int iter_depth(const iterator& iter) const;

  
  /** WARNING: This function is slow. Only use it for debugging and/or testing
   * purposes.
   * 
   * Checks if the given iter is a valid iter for this Gtk::TreeStore.
   * @param iter A Gtk::TreeIter.
   * @return <tt>true</tt> if the iter is valid, <tt>false</tt> if the iter is invalid.
   * 
   * Since: 2.2.
   */
  bool iter_is_valid(const iterator& iter) const;

protected:
  virtual void set_value_impl(const iterator& row, int column, const Glib::ValueBase& value);
  

public:

public:
  //C++ methods used to invoke GTK+ virtual functions:

protected:
  //GTK+ Virtual Functions (override these to change behaviour):

  //Default Signal Handlers::


};

} // namespace Gtk


namespace Glib
{
  /** @relates Gtk::TreeStore
   * @param object The C instance
   * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
   * @result A C++ instance that wraps this C instance.
   */
  Glib::RefPtr<Gtk::TreeStore> wrap(GtkTreeStore* object, bool take_copy = false);
}


#endif /* _GTKMM_TREESTORE_H */