Install ardour as a binary, a script and a set of shared
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / treesortable.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_TREESORTABLE_H
4 #define _GTKMM_TREESORTABLE_H
5
6 #include <glibmm.h>
7
8 /* $Id$ */
9
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 Library General Public
15  * License as published by the Free Software Foundation; either
16  * version 2 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  * Library General Public License for more details.
22  *
23  * You should have received a copy of the GNU Library 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/enums.h>
30 #include <gtkmm/treemodelcolumn.h>
31 #include <gtkmm/treemodel.h>
32 #include <gtkmm/treeiter.h>
33 #include <gtk/gtktreesortable.h>
34
35
36 #ifndef DOXYGEN_SHOULD_SKIP_THIS
37 typedef struct _GtkTreeSortable GtkTreeSortable;
38 typedef struct _GtkTreeSortableClass GtkTreeSortableClass;
39 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
40
41
42 namespace Gtk
43 { class TreeSortable_Class; } // namespace Gtk
44 namespace Gtk
45 {
46
47 /**
48  * @ingroup TreeView
49 */
50
51 class TreeSortable : public Glib::Interface
52 {
53   
54 #ifndef DOXYGEN_SHOULD_SKIP_THIS
55
56 public:
57   typedef TreeSortable CppObjectType;
58   typedef TreeSortable_Class CppClassType;
59   typedef GtkTreeSortable BaseObjectType;
60   typedef GtkTreeSortableIface BaseClassType;
61
62 private:
63   friend class TreeSortable_Class;
64   static CppClassType treesortable_class_;
65
66   // noncopyable
67   TreeSortable(const TreeSortable&);
68   TreeSortable& operator=(const TreeSortable&);
69
70 protected:
71   TreeSortable(); // you must derive from this class
72   explicit TreeSortable(GtkTreeSortable* castitem);
73
74 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
75
76 public:
77   virtual ~TreeSortable();
78
79   static void add_interface(GType gtype_implementer);
80
81 #ifndef DOXYGEN_SHOULD_SKIP_THIS
82   static GType get_type()      G_GNUC_CONST;
83   static GType get_base_type() G_GNUC_CONST;
84 #endif
85
86   ///Provides access to the underlying C GObject.
87   GtkTreeSortable*       gobj()       { return reinterpret_cast<GtkTreeSortable*>(gobject_); }
88
89   ///Provides access to the underlying C GObject.  
90   const GtkTreeSortable* gobj() const { return reinterpret_cast<GtkTreeSortable*>(gobject_); }
91
92 private:
93
94
95 public:
96
97   enum
98   {
99     /// See set_default_sort_func() and set_sort_column().
100     DEFAULT_SORT_COLUMN_ID = -1,
101     DEFAULT_UNSORTED_COLUMN_ID = -2
102   }; //See GTK+ implementation.
103
104   
105   /** Fills in @a sort_column_id  and @a order  with the current sort column and the
106    * order.  It returns <tt>true</tt> unless the @a sort_column_id  is 
107    * Gtk::TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID or 
108    * Gtk::TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID.
109    * @param sort_column_id The sort column id to be filled in.
110    * @param order The Gtk::SortType to be filled in.
111    * @return <tt>true</tt> if the sort column is not one of the special sort
112    * column ids.
113    */
114   bool get_sort_column_id(int& sort_column_id, SortType& order) const;
115
116   
117   /** Sets the current sort column to be @a sort_column_id .  The @a sortable  will
118    * resort itself to reflect this change, after emitting a
119    * GtkTreeSortable::sort_column_changed signal.  If @a sort_column_id  is
120    * Gtk::TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the default sort function
121    * will be used, if it is set.
122    * @param sort_column_id The sort column id to set.
123    * @param order The sort order of the column.
124    */
125   void set_sort_column(const TreeModelColumnBase& sort_column_id, SortType order);
126   
127   /** Sets the current sort column to be @a sort_column_id .  The @a sortable  will
128    * resort itself to reflect this change, after emitting a
129    * GtkTreeSortable::sort_column_changed signal.  If @a sort_column_id  is
130    * Gtk::TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, then the default sort function
131    * will be used, if it is set.
132    * @param sort_column_id The sort column id to set.
133    * @param order The sort order of the column.
134    */
135   void set_sort_column(int sort_column_id, SortType order);
136
137   #ifndef GTKMM_DISABLE_DEPRECATED
138   /** @deprecated Use set_sort_column() instead.
139    */
140   void set_sort_column_id(const TreeModelColumnBase& sort_column_id, SortType order);
141
142   /** @deprecated Use set_sort_column() instead.
143    */
144   void set_sort_column_id(int sort_column_id, SortType order);
145   #endif //GTKMM_DISABLE_DEPRECATED
146
147   /** This callback should return -1 if b compares before a, 0 if they compare equal, 1 if a compares after b. 
148    * For instance, int on_sort_compare(const Gtk::TreeModel::iterator& a, const Gtk::TreeModel::iterator& b);
149    */
150   typedef sigc::slot<int, const Gtk::TreeModel::iterator&, const Gtk::TreeModel::iterator&> SlotCompare;
151
152   
153   /** Sets the comparison function used when sorting a certain column.
154    * If the current sort column is the same as @a sort_column, then the model will sort using this function.
155    * @param sort_column the sort column to set the function for
156    * @param slot The sorting slot callback.
157    */
158   void set_sort_func(const TreeModelColumnBase& sort_column, const SlotCompare& slot);
159
160   /** Sets the comparison function used when sorting a certain column.
161    * If the current sort column id is the same as @a sort_column_id, then the model will sort using this function.
162    * @param sort_column_id the sort column id to set the function for
163    * @param slot The sorting slot callback.
164    */
165   void set_sort_func(int sort_column_id, const SlotCompare& slot);
166
167   /** Sets the default comparison function used when sorting.
168    * If the current sort column id of sortable is DEFAULT_SORT_COLUMN_ID, then the model will
169    * sort using this function.  See also unset_default_sort_func().
170    *
171    * @param slot The sorting function
172    */
173   void set_default_sort_func(const SlotCompare& slot);
174
175   /** Sets the default comparison function used when sorting. See set_default_sort_func().
176    *
177    * After calling this method there will be no default comparison function. This means that once the model has been sorted,
178    * it can't go back to the default state. In this case, when the current sort column id of sortable is
179    * DEFAULT_SORT_COLUMN_ID, the model will be unsorted.
180    */
181   void unset_default_sort_func();
182
183   
184   /** Returns <tt>true</tt> if the model has a default sort function.  This is used
185    * primarily by GtkTreeViewColumns in order to determine if a model can go back
186    * to the default state, or not.
187    * @return <tt>true</tt>, if the model has a default sort function.
188    */
189   bool has_default_sort_func() const;
190
191   
192   /** Emits a GtkTreeSortable::sort_column_changed signal on
193    */
194   void sort_column_changed();
195   
196
197   Glib::SignalProxy0< void > signal_sort_column_changed();
198
199
200 protected:
201     virtual bool get_sort_column_id_vfunc(int* sort_column_id, SortType* order) const;
202     virtual void set_sort_column_id_vfunc(int sort_column_id, SortType order);
203     virtual void set_sort_func_vfunc(int sort_column_id, GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy);
204     virtual void set_default_sort_func_vfunc(GtkTreeIterCompareFunc func, void* data, GtkDestroyNotify destroy);
205     virtual bool has_default_sort_func_vfunc() const;
206     virtual void sort_column_changed_vfunc() const;
207
208
209 public:
210
211 public:
212   //C++ methods used to invoke GTK+ virtual functions:
213
214 protected:
215   //GTK+ Virtual Functions (override these to change behaviour):
216
217   //Default Signal Handlers::
218   virtual void on_sort_column_changed();
219
220
221 };
222
223 } // namespace Gtk
224
225
226 namespace Glib
227 {
228   /** @relates Gtk::TreeSortable
229    * @param object The C instance
230    * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
231    * @result A C++ instance that wraps this C instance.
232    */
233   Glib::RefPtr<Gtk::TreeSortable> wrap(GtkTreeSortable* object, bool take_copy = false);
234
235 } // namespace Glib
236
237 #endif /* _GTKMM_TREESORTABLE_H */
238