add new sigc++2 directory
[ardour.git] / libs / gtkmm2 / gtk / src / treeview.hg
1 /* $Id: treeview.hg,v 1.45 2006/06/20 18:46:59 murrayc Exp $ */
2
3 /* Copyright(C) 2002 The gtkmm Development Team
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or(at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 // This is for including the config header before any code (such as
21 // the #ifndef GTKMM_DISABLE_DEPRECATED in deprecated classes) is generated:
22 _CONFIGINCLUDE(gtkmmconfig.h)
23
24 #include <glibmm/listhandle.h>
25 #include <gtkmm/container.h>
26 #include <gtkmm/adjustment.h>
27 #include <gdkmm/pixmap.h>
28 #include <gtkmm/treeviewcolumn.h>
29 #include <gtkmm/treeselection.h>
30 #include <gtkmm/treemodelcolumn.h>
31 #include <gtkmm/cellrenderer.h>
32 #include <gtkmm/targetentry.h>
33 #include <gtkmm/entry.h>
34 #include <gtkmm/tooltip.h>
35
36 _DEFS(gtkmm,gtk)
37 _PINCLUDE(gtkmm/private/container_p.h)
38
39
40 namespace Gtk
41 {
42
43 _CC_INCLUDE(gtk/gtktypebuiltins.h)
44 _WRAP_ENUM(TreeViewDropPosition, GtkTreeViewDropPosition)
45 _WRAP_ENUM(TreeViewGridLines, GtkTreeViewGridLines)
46
47
48 #ifndef DOXYGEN_SHOULD_SKIP_THIS
49
50 class TreeView;
51
52 namespace TreeView_Private
53 {
54 /* This helper function is not a member of TreeView just for the reason that
55  * there are compilers that have problems compiling it otherwise. E.g. in gcc
56  * 2.95.3 a compiler bug prevents member functions from refering to specialized
57  * member function templates and that's what we do here: In function
58  * _connect_auto_store_editable_signal_handler we build a slot from
59  * TreeView::_auto_store_on_cellrenderer_*_edited. (The latter must be member
60  * functions of TreeView since we connect them to signals and we want the
61  * connections to vanish when the TreeView dies, of course.)
62  */
63   template <class ColumnType> inline
64   void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer, const Gtk::TreeModelColumn<ColumnType>& model_column);
65
66   template<class ColumnType> inline
67   void _auto_store_on_cellrenderer_text_edited_string(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model);
68
69   template <class ColumnType> inline
70   void _auto_store_on_cellrenderer_text_edited_numerical(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model); 
71
72   template <class ColumnType> inline
73   void _auto_cell_data_func(Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter, int model_column, const Glib::ustring& format);
74 }
75
76 #endif //DOXYGEN_SHOULD_SKIP_THIS
77
78
79 //class TreeViewColumn;
80 class TreeModel;
81
82 /** @defgroup TreeView TreeView Classes
83  * These classes are used with the Gtk::TreeView widget.
84  */
85
86 /** The TreeView widget displays the model (Gtk::TreeModel) data and allows the user to interact with it.
87  * The View can show all of the model's columns, or just some, and it can show them in various ways.
88  * You must provide the TreeModel in the constructor, or with set_model().
89  *
90  * Add View columns with append_column(), append_column_editable(), insert_column(), or insert_column_editable().
91  *
92  * You can manipulate the selection by obtaining the @link Gtk::TreeSelection Gtk::TreeView::Selection@endlink from get_selection().
93  *
94  * @ingroup Widgets
95  * @ingroup Containers
96  * @ingroup TreeView
97  */
98 class TreeView : public Container
99 {
100   _CLASS_GTKOBJECT(TreeView, GtkTreeView, GTK_TREE_VIEW, Gtk::Container, GtkContainer)
101   _IGNORE(gtk_tree_view_get_path_at_pos, gtk_tree_view_set_destroy_count_func, gtk_tree_view_get_cursor
102           gtk_tree_view_insert_column_with_data_func, gtk_tree_view_get_drag_dest_row, gtk_tree_view_get_dest_row_at_pos)
103 public:
104   /**  A visible column in a Gtk::TreeView widget.
105    */
106   typedef TreeViewColumn Column;
107   
108   /** A selection object for Gtk::TreeView.
109    */
110   typedef TreeSelection Selection;
111   /**
112      Default constructor
113    */
114   _CTOR_DEFAULT()
115   /**
116      Constructor that binds to a TreeModel
117    */
118   _WRAP_CTOR(TreeView(const Glib::RefPtr<TreeModel>& model), gtk_tree_view_new_with_model)
119
120   _WRAP_METHOD(Glib::RefPtr<TreeModel> get_model(), gtk_tree_view_get_model, refreturn)
121   _WRAP_METHOD(Glib::RefPtr<const TreeModel> get_model() const, gtk_tree_view_get_model, refreturn)
122   _WRAP_METHOD(void set_model(const Glib::RefPtr<TreeModel>& model), gtk_tree_view_set_model)
123   
124   /** Remove the model from the TreeView.
125    */
126   void unset_model();
127   
128   _WRAP_METHOD(Glib::RefPtr<TreeSelection> get_selection(), gtk_tree_view_get_selection, refreturn)
129   _WRAP_METHOD(Glib::RefPtr<const TreeSelection> get_selection() const, gtk_tree_view_get_selection, refreturn, constversion)
130   _WRAP_METHOD(Adjustment* get_hadjustment(), gtk_tree_view_get_hadjustment)
131   _WRAP_METHOD(const Adjustment* get_hadjustment() const, gtk_tree_view_get_hadjustment, constversion)
132   _WRAP_METHOD(void set_hadjustment(Adjustment& adjustment), gtk_tree_view_set_hadjustment)
133   
134   /** This method removes the hadjustment.
135    * @see set_hadjustment().
136    */
137   void unset_hadjustment();
138   
139   _WRAP_METHOD(Adjustment* get_vadjustment(), gtk_tree_view_get_vadjustment)
140   _WRAP_METHOD(const Adjustment* get_vadjustment() const, gtk_tree_view_get_vadjustment, constversion)
141   _WRAP_METHOD(void set_vadjustment(Adjustment& adjustment), gtk_tree_view_set_vadjustment)
142   
143   /** This method removes the vadjustment.
144    * @see set_vadjustment().
145    */
146   void unset_vadjustment();
147   
148   _WRAP_METHOD(bool get_headers_visible() const, gtk_tree_view_get_headers_visible)
149   _WRAP_METHOD(void set_headers_visible(bool headers_visible), gtk_tree_view_set_headers_visible)
150   _WRAP_METHOD(void columns_autosize(), gtk_tree_view_columns_autosize)
151   _WRAP_METHOD(bool get_headers_clickable() const, gtk_tree_view_get_headers_clickable)
152   _WRAP_METHOD(void set_headers_clickable(bool setting = true), gtk_tree_view_set_headers_clickable)
153   _WRAP_METHOD(void set_rules_hint(bool setting = true), gtk_tree_view_set_rules_hint)
154   _WRAP_METHOD(bool get_rules_hint() const, gtk_tree_view_get_rules_hint)
155
156   _WRAP_METHOD(int append_column(TreeViewColumn& column), gtk_tree_view_append_column)
157
158   /** Appends a View column with the appropriate CellRenderer for the Model column.
159    *
160    * The CellRenderer can only be created automatically for some basic
161    * column types, such as Glib::ustring, int, double, bool, and Gdk::Pixbuf. 
162    * If the type is not supported then the following warning will be shown:
163    * GLib-GObject-WARNING **: unable to set property `text' of type
164    * `gchararray' from value of type `glibmm__CustomBoxed_t'.
165    *
166    * If the default formatting is not sufficient, or the numeric type is 
167    * not supported, then you could use append_column_numeric(). Or you 
168    * could create the TreeView::Column and/or CellRenderer
169    * manually and use TreeViewColumn::set_cell_data_func() to provide a callback 
170    * that converts the model value into a string representation with .
171    *
172    * @param title The text to be used in the title header of this column.
173    * @param model_column The column in the TreeModel that will be rendered by this View column.
174    * @result The number of columns in the View after appending.
175    */
176   template <class ColumnType> inline
177   int append_column(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column);
178
179   /** Like append_column(), but only for numeric types, which will be displayed in the specified format.
180    * This convenience template uses TreeView::Column::set_cell_data_func(), so the numeric formatting will 
181    * be deactivated if you specify your own cell_data callback by calling set_cell_data_func() again.
182    *
183    * @param title The text to be used in the title header of this column.
184    * @param model_column The column in the TreeModel that will be rendered by this View column.
185    * @param format A printf-style format, such as "%d", used to create a text representation of the number.
186    * @result The number of columns in the View after appending.
187    */
188   template <class ColumnType> inline
189   int append_column_numeric(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, const Glib::ustring& format);
190   
191   //TODO: danielk suggested use of Glib::Value to simplify/improve this.
192   /** Appends a View column with the appropriate CellRenderer for the Model
193    * column.  The compiler will attempt to instantiate appropriate template
194    * code to automatically store user changes in the model.  To intercept the
195    * user's change and implement non-default logic, or if the compiler can't
196    * instantiate appropriate code for your model type, you could use
197    * append_column() and connect a signal handler to the CellRenderer.
198    *
199    * @see append_column_numeric_editable().
200    *
201    * @param title The text to be used in the title header of this column.
202    * @param model_column The column in the TreeModel that will be rendered by this View column.
203    * @result The number of columns in the View after appending.
204    */
205   template <class ColumnType> inline
206   int append_column_editable(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column);
207
208   /** Like append_column_editable(), but only for numeric types, which will be displayed in the specified format.
209    * This convenience template uses TreeView::Column::set_cell_data_func(), so the numeric formatting will 
210    * be deactivated if you specify your own cell_data callback by calling set_cell_data_func() again.
211    *
212    * Note that the user's input will be interpreted as decimal (base 10), regardless of the @a format.
213    *
214    * @param title The text to be used in the title header of this column.
215    * @param model_column The column in the TreeModel that will be rendered by this View column.
216    * @param format A printf-style format, such as "%d", used to create a text representation of the number.
217    * @result The number of columns in the View after appending.
218    */
219   template <class ColumnType> inline
220   int append_column_numeric_editable(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, const Glib::ustring& format);
221
222   
223   /// Creates a View column containing the CellRenderer, and appends it.
224   int append_column(const Glib::ustring& title, CellRenderer& cell);
225
226   _WRAP_METHOD(int remove_column(TreeViewColumn& column), gtk_tree_view_remove_column)
227
228   /// Removes all View columns.
229   void remove_all_columns();
230
231   _WRAP_METHOD(int insert_column(TreeViewColumn& column, int position), gtk_tree_view_insert_column)
232
233   /** Creates a View column containing the CellRenderer, and inserts it.
234    *
235    * @param title The text to be used in the title header of this column.
236    * @param cell The CellRenderer.
237    * @param position The position at which the CellRenderer should be inserted.
238    * @result The number of columns in the View after inserting.
239    */
240   int insert_column(const Glib::ustring& title, CellRenderer& cell, int position);
241
242   _IGNORE(gtk_tree_view_insert_column_with_attributes)
243
244   /** Inserts a View column with the appropriate CellRenderer for the Model column.
245    *
246    * @param title The text to be used in the title header of this column.
247    * @param model_column The column in the TreeModel that will be rendered by this View column.
248    * @param position The position at which the CellRenderer should be inserted.
249    * @result The number of columns in the View after inserting.
250    */
251   template <class ColumnType> inline
252   int insert_column(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, int position);
253
254   /** Inserts a View column with the appropriate CellRenderer for the Model
255    * column.  The compiler will attempt to instantiate appropriate template
256    * code to automatically store user changes in the model.  To intercept the
257    * user's change and implement non-default logic, or if the compiler can't
258    * instantiate appropriate code for your model type, you should use
259    * append_column() and connect a signal handler to the CellRenderer.
260    *
261    * @param title The text to be used in the title header of this column.
262    * @param model_column The column in the TreeModel that will be rendered by this View column.
263    * @param position The position at which the CellRenderer should be inserted.
264    * @result The number of columns in the View after inserting.
265    */
266   template <class ColumnType> inline
267   int insert_column_editable(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, int position);
268
269   typedef TreeViewColumn::SlotCellData SlotCellData;
270   
271   /**
272    * Inserts a new column into the TreeView with the given cell
273    * renderer and a SlotCellData to set cell renderer attributes
274    * (normally using data from the model). 
275    *
276    * @param position Position to insert, -1 for append
277    * @param title column title
278    * @param cell cell renderer for column
279    * @param slot function to set attributes of cell renderer
280    * @return number of columns in the TreeView after the insert
281    */
282   int insert_column_with_data_func(int position, const Glib::ustring& title, CellRenderer& cell, const SlotCellData& slot);
283
284   _WRAP_METHOD(TreeViewColumn* get_column(int n), gtk_tree_view_get_column)
285   _WRAP_METHOD(const TreeViewColumn* get_column(int n) const, gtk_tree_view_get_column, constversion)
286
287   //The column index is of the view, not the model, so we do not need TreeViewColumn* get_column(TreeViewColumn& base_column).
288
289   /** Gets the CellRenderer for that column.
290     * You should dynamic_cast<> to the expected derived CellRenderer type.
291     * This assumes that the TreeViewColumn contains only one CellRenderer.
292     *
293     * @param n The position of the view column.
294     * @result The CellRenderer.
295     */
296   CellRenderer* get_column_cell_renderer(int n);
297
298  //TODO: Add TreeViewColumn* get_column_cell_renderer(TreeViewColumn& base_column); and a const one.
299
300
301   /** Gets the CellRenderer for that column.
302     * You should dynamic_cast<> to the expected derived CellRenderer type.
303     * This assumes that the TreeViewColumn contains only one CellRenderer.
304     *
305     * @param n The position of the view column.
306     * @result The CellRenderer.
307     */
308   const CellRenderer* get_column_cell_renderer(int n) const;
309
310   _WRAP_METHOD(Glib::ListHandle<TreeViewColumn*> get_columns(), gtk_tree_view_get_columns)
311   _WRAP_METHOD(Glib::ListHandle<const TreeViewColumn*> get_columns() const, gtk_tree_view_get_columns)
312   
313   _WRAP_METHOD(void move_column_after(TreeViewColumn& column, TreeViewColumn& base_column), gtk_tree_view_move_column_after)
314
315   /** This method moves column to the first position in the view.
316    *
317    * @param column The view column that will be moved
318    */
319   void move_column_to_start(TreeViewColumn& column);
320   
321   _WRAP_METHOD(void set_expander_column(TreeViewColumn& column), gtk_tree_view_set_expander_column)
322   
323   /** This method resets the expander arrow to the default - the first visible column.
324    * @see set_expander_column().  
325    */
326   void reset_expander_column();
327   
328   _WRAP_METHOD(TreeViewColumn* get_expander_column(), gtk_tree_view_get_expander_column)
329   _WRAP_METHOD(const TreeViewColumn* get_expander_column() const, gtk_tree_view_get_expander_column, constversion)
330
331   /** For instance,
332    * bool on_column_drop(TreeView*, tree_view, TreeViewColumn* column, TreeViewColumn* prev_column, TreeViewColumn* next_column)
333    *
334    * This function is called on every column pair in turn at the beginning of a column drag to determine where a
335    * drop can take place. The arguments passed to the function are: the tree_view, the view Column being dragged,
336    * and the two view Columns determining the drop spot. If either of the view Column arguments for the drop spot
337    * are 0, then they indicate an edge.
338    */
339   typedef sigc::slot<bool, TreeView*, TreeViewColumn*,  TreeViewColumn*, TreeViewColumn*> SlotColumnDrop;
340
341   /** Sets a callback slot for determining where a column may be dropped when dragged.
342    * This function is called on every column pair in turn at the beginning of a column drag to determine where a
343    * drop can take place. The arguments passed to the function are: the tree_view, the view Column being dragged,
344    * and the two view Columns determining the drop spot. If either of the view Column arguments for the drop spot
345    * are 0, then they indicate an edge.
346    *
347    * See unset_column_drag_function().
348    *
349    * @param slot A callback function to determine which columns are reorderable.
350    */
351   void set_column_drag_function(const SlotColumnDrop& slot);
352   _IGNORE(gtk_tree_view_set_column_drag_function)
353
354   /** See set_column_drag_function(). After this method has been called, the TreeView reverts to the default behavior of
355   * allowing all columns to be dropped everywhere.
356   */
357   void unset_column_drag_function();
358    
359   _WRAP_METHOD(void scroll_to_point(int tree_x, int tree_y), gtk_tree_view_scroll_to_point)
360
361   /** Moves the alignments of tree view to the position specified by @a column and @a path.
362    * @a row_align determines where the row is placed, and @a col_align determines where
363    * column is placed. Both are expected to be between 0.0 and 1.0. 0.0 means left/top
364    * alignment, 1.0 means right/bottom alignment, 0.5 means center.
365    *
366    * This function only works if the model is set, and @a path is a valid row on the model.
367    * If the model changes before the tree view is realized, the centered path will be
368    * modified to reflect this change.
369    *
370    * @param path The path of the row to move to.
371    * @param column The Gtk::TreeViewColumn to move horizontally to.
372    * @param row_align The vertical alignment of the row specified by @a path.
373    * @param col_align The horizontal alignment of the column specified by @a column.
374    */
375   void scroll_to_cell(const TreeModel::Path& path, TreeViewColumn& column, float row_align, float col_align);
376   _IGNORE(gtk_tree_view_scroll_to_cell)
377
378   /** Moves the alignments of tree view to the position specified by @a column and @a path.
379    * The tree does the minimum amount of work to scroll the cell onto the screen. This means
380    * that the cell will be scrolled to the edge closest to it's current position. If the cell
381    * is currently visible on the screen, nothing is done.
382    *
383    * This function only works if the model is set, and @a path is a valid row on the model.
384    * If the model changes before the tree_view is realized, the centered path will be modified
385    * to reflect this change.
386    *
387    * @param path The path of the row to move to.
388    * @param column The Gtk::TreeViewColumn to move horizontally to.
389    */
390   void scroll_to_cell(const TreeModel::Path& path, TreeViewColumn& column);
391
392   /** Moves the alignments of tree view to the position specified by @a path.
393    * @a row_align determines where the row is placed, and is expected to be between 0.0
394    * and 1.0.  0.0 means top alignment, 1.0 means bottom alignment, 0.5 means center.
395    *
396    * This function only works if the model is set, and @a path is a valid row on the model.
397    * If the model changes before the tree view is realized, the centered path will be
398    * modified to reflect this change.
399    *
400    * @param path The path of the row to move to.
401    * @param row_align The vertical alignment of the row specified by @a path.
402    */
403   void scroll_to_row(const TreeModel::Path& path, float row_align);
404
405   /** Moves the alignments of tree view to the position specified by @a path.
406    * The tree does the minimum amount of work to scroll the row onto the screen. This means
407    * that the row will be scrolled to the edge closest to it's current position. If the row
408    * is currently visible on the screen, nothing is done.
409    *
410    * This function only works if the model is set, and @a path is a valid row on the model.
411    * If the model changes before the tree view is realized, the centered path will be
412    * modified to reflect this change.
413    *
414    * @param path The path of the row to move to.
415    */
416   void scroll_to_row(const TreeModel::Path& path);
417
418   /** Moves the alignments of tree view to the position specified by @a column.
419    * @a col_align determines where the column is placed, and is expected to be between 0.0
420    * and 1.0.  0.0 means left alignment, 1.0 means right alignment, 0.5 means center.
421    *
422    * This function only works if the model is set.  If the model changes before the tree
423    * view is realized, the centered path will be modified to reflect this change.
424    *
425    * @param column The Gtk::TreeViewColumn to move horizontally to.
426    * @param col_align The horizontal alignment of the column specified by @a column.
427    */
428   void scroll_to_column(TreeViewColumn& column, float col_align);
429
430   /** Moves the alignments of tree view to the position specified by @a column.
431    * The tree does the minimum amount of work to scroll the column onto the screen. This means
432    * that the column will be scrolled to the edge closest to it's current position. If the column
433    * is currently visible on the screen, nothing is done.
434    *
435    * This function only works if the model is set.  If the model changes before the
436    * tree view is realized, the centered path will be modified to reflect this change.
437    *
438    * @param column The Gtk::TreeViewColumn to move horizontally to.
439    */
440   void scroll_to_column(TreeViewColumn& column);
441
442   _WRAP_METHOD(void row_activated(const TreeModel::Path& path,TreeViewColumn& column), gtk_tree_view_row_activated)
443   _WRAP_METHOD(void expand_all(), gtk_tree_view_expand_all)
444   _WRAP_METHOD(void collapse_all(), gtk_tree_view_collapse_all)
445   _WRAP_METHOD(void expand_to_path(const TreeModel::Path& path), gtk_tree_view_expand_to_path)
446   _WRAP_METHOD(bool expand_row(const TreeModel::Path& path, bool open_all), gtk_tree_view_expand_row)
447   _WRAP_METHOD(bool collapse_row(const TreeModel::Path& path), gtk_tree_view_collapse_row)
448
449   /** For example,
450    * void on_map_expanded_rows(TreeView* tree_view, const TreeModel::Path& path);
451    */
452   typedef sigc::slot<void, TreeView*, const TreeModel::Path&> SlotMapping;
453
454   /** Calls the callback slot on all expanded rows.
455    * @param slot A callback function to be called.
456    */  
457   void map_expanded_rows(const SlotMapping& slot);
458   _IGNORE(gtk_tree_view_map_expanded_rows)
459
460   _WRAP_METHOD(bool row_expanded(const TreeModel::Path& path), gtk_tree_view_row_expanded)
461   _WRAP_METHOD(void set_reorderable(bool reorderable = true), gtk_tree_view_set_reorderable)
462   _WRAP_METHOD(bool get_reorderable() const, gtk_tree_view_get_reorderable)
463
464   //TODO: Add set_cursor(path, ModelColumnBase&, start_editing)?
465   _WRAP_METHOD(void set_cursor(const TreeModel::Path& path, TreeViewColumn& focus_column, bool start_editing = false), gtk_tree_view_set_cursor)
466     
467   _WRAP_METHOD(void set_cursor(const TreeModel::Path& path, TreeViewColumn& focus_column, CellRenderer& focus_cell, bool start_editing = false), gtk_tree_view_set_cursor_on_cell)
468
469  
470   /** Sets the current keyboard focus to be at path , and selects it.
471    * This is useful when you want to focus the user's attention on a particular row.
472    * This function is often followed by Gtk::widget::grab_focus(tree_view)
473    * in order to give keyboard focus to the widget.
474    *
475    *  @param path A reference to cursor path.
476    */
477   void set_cursor(const TreeModel::Path& path);
478
479   /**  Fills in path and focus_column with the current path and focus column.
480    *
481    *  @param path A reference to be filled with the current cursor path
482    *  @param focus_column A reference to be filled with the current focus column
483    */
484   void get_cursor(TreeModel::Path& path, TreeViewColumn*& focus_column);
485
486 /* Layout information */
487   _WRAP_METHOD(Glib::RefPtr<Gdk::Window> get_bin_window(), gtk_tree_view_get_bin_window, refreturn)
488   _WRAP_METHOD(Glib::RefPtr<const Gdk::Window> get_bin_window() const, gtk_tree_view_get_bin_window, refreturn, constversion)
489
490   _DEPRECATE_IFDEF_START
491   /** @deprecated Use the const version.
492    */
493   bool get_path_at_pos(int x, int y, TreeModel::Path& path, TreeViewColumn*& column, int& cell_x, int& cell_y);
494   _DEPRECATE_IFDEF_END
495
496   /** Finds the path at the point (x, y), relative to widget
497    * coordinates. It is primarily for things like popup menus.
498    *
499    * @param x The x position to be identified
500    * @param y The y position to be identified
501    * @param path A reference to a TreeModel::Path to be filled in
502    * @param column A reference to a TreeViewColumn pointer to be filled in
503    * @param cell_x A reference where the X coordinate relative to the cell
504    *   can be placed
505    * @param cell_y A reference where the Y coordinate relative to the cell
506    *   can be placed
507    * @return true if a row exists at that coordinate.
508    */
509   bool get_path_at_pos(int x, int y, TreeModel::Path& path, TreeViewColumn*& column, int& cell_x, int& cell_y) const;
510
511   _WRAP_METHOD(void get_cell_area(const TreeModel::Path& path, TreeViewColumn& column, Gdk::Rectangle& rect), gtk_tree_view_get_cell_area, deprecated "Use the const version")
512 //We ignore the fact that one of the arguments can be 0 - it does not seem useful.
513
514   _WRAP_METHOD(void get_cell_area(const TreeModel::Path& path, TreeViewColumn& column, Gdk::Rectangle& rect) const, gtk_tree_view_get_cell_area)
515
516    _WRAP_METHOD(void get_background_area(const TreeModel::Path& path, TreeViewColumn& column, Gdk::Rectangle& rect), gtk_tree_view_get_background_area, deprecated "Use the const version.")
517   _WRAP_METHOD(void get_background_area(const TreeModel::Path& path, TreeViewColumn& column, Gdk::Rectangle& rect) const, gtk_tree_view_get_background_area)
518   //We ignore the fact that one of the arguments can be 0 - it does not seem useful.
519
520   _WRAP_METHOD(void get_visible_rect(Gdk::Rectangle&  visible_rect), gtk_tree_view_get_visible_rect, deprecated "Use the const version.")
521   _WRAP_METHOD(void get_visible_rect(Gdk::Rectangle&  visible_rect) const, gtk_tree_view_get_visible_rect)
522
523   _WRAP_METHOD(void widget_to_tree_coords(int wx, int wy, int& tx, int& ty), gtk_tree_view_widget_to_tree_coords, deprecated "Use the const version")
524   _WRAP_METHOD(void widget_to_tree_coords(int wx, int wy, int& tx, int& ty) const, gtk_tree_view_widget_to_tree_coords)
525
526   _WRAP_METHOD(void tree_to_widget_coords(int tx, int ty, int& wx, int& wy), gtk_tree_view_tree_to_widget_coords, deprecated "Use the const version.")
527   _WRAP_METHOD(void tree_to_widget_coords(int tx, int ty, int& wx, int& wy) const, gtk_tree_view_tree_to_widget_coords)
528
529    bool get_visible_range(TreeModel::Path& start_path, TreeModel::Path& end_path) const;
530   _IGNORE(gtk_tree_view_get_visible_range)
531
532 /* Drag-and-Drop support */
533   _IGNORE(gtk_tree_view_enable_model_drag_source)
534
535   /**
536    * Turns the TreeView into a drag source for automatic DND.
537    *
538    * @param targets Standard container of targets that the drag will support.
539    * @param start_button_mask Mask of allowed buttons to start drag.
540    * @param actions The bitmask of possible actions for a drag from this widget.
541    */
542   void enable_model_drag_source(const ArrayHandle_TargetEntry& targets,
543                                 Gdk::ModifierType start_button_mask = Gdk::MODIFIER_MASK,
544                                 Gdk::DragAction actions = Gdk::ACTION_COPY | Gdk::ACTION_MOVE);
545
546   // Uses the default "GTK_TREE_MODEL_ROW" target, which the TreeView can handle automatically.
547
548   /** Turns the TreeView into a drag source for automatic DND.
549    *
550    * @param start_button_mask Mask of allowed buttons to start drag.
551    * @param actions The bitmask of possible actions for a drag from this widget.
552    */
553   void enable_model_drag_source(Gdk::ModifierType start_button_mask = Gdk::MODIFIER_MASK,
554                                 Gdk::DragAction actions = Gdk::ACTION_COPY | Gdk::ACTION_MOVE);                                                                                              
555
556   _IGNORE(gtk_tree_view_enable_model_drag_dest)
557     
558   /** Turns the TreeView into a drop destination for automatic DND.
559    *
560    * @param targets The table of targets that the drag will support.
561    * @param actions The bitmask of possible actions for a drag from this widget.
562    */ 
563   void enable_model_drag_dest(const ArrayHandle_TargetEntry& targets, Gdk::DragAction actions = Gdk::ACTION_COPY | Gdk::ACTION_MOVE);
564
565   /** Turns the TreeView into a drop destination for automatic DND.  This uses the default
566     *  "GTK_TREE_MODEL_ROW" target, which the TreeView can handle automatically.
567     *
568     * @param actions The bitmask of possible actions for a drag from this widget.
569    */ 
570   void enable_model_drag_dest(Gdk::DragAction actions = Gdk::ACTION_COPY | Gdk::ACTION_MOVE);
571
572   /** Undoes the effect of enable_model_drag_source()
573    */
574   _WRAP_METHOD(void unset_rows_drag_source(), gtk_tree_view_unset_rows_drag_source)
575
576   /** Undoes the effect of enable_model_drag_source()
577    */
578   _WRAP_METHOD(void unset_rows_drag_dest(), gtk_tree_view_unset_rows_drag_dest)
579
580
581   /* These are useful to implement your own custom stuff. */
582
583   /** Sets the row that is highlighted for feedback.
584    *
585    * @param path The path of the row to highlight
586    * @param pos Specifies whether to drop before, after or into the row
587    */
588   _WRAP_METHOD(void set_drag_dest_row(const TreeModel::Path& path, TreeViewDropPosition pos), gtk_tree_view_set_drag_dest_row)
589     
590   /** Gets information about the row that is highlighted for feedback.
591    *
592    * @param path Return location for the path of the highlighted row
593    * @param pos Return location for the drop position
594    */
595   void get_drag_dest_row(TreeModel::Path& path, TreeViewDropPosition& pos) const;
596
597   /** Determines the destination row for a given position.
598    *
599    * @param drag_x The x position to determine the destination row for
600    * @param drag_y The y position to determine the destination row for
601    * @param path Return location for the path of the highlighted row
602    * @param pos Return location for the drop position
603    */
604   bool get_dest_row_at_pos(int drag_x, int drag_y, TreeModel::Path& path, TreeViewDropPosition& pos) const;
605
606   _WRAP_METHOD(Glib::RefPtr<Gdk::Pixmap> create_row_drag_icon(const TreeModel::Path& path), gtk_tree_view_create_row_drag_icon)
607
608 /* Interactive search */
609   _WRAP_METHOD(void set_enable_search(bool enable_search = true), gtk_tree_view_set_enable_search)
610   _WRAP_METHOD(bool get_enable_search() const, gtk_tree_view_get_enable_search)
611   _WRAP_METHOD(int get_search_column() const, gtk_tree_view_get_search_column)
612   _WRAP_METHOD(void set_search_column(const TreeModelColumnBase& column), gtk_tree_view_set_search_column)
613   _WRAP_METHOD(void set_search_column(int column), gtk_tree_view_set_search_column)
614
615   ///void on_search_equal(const Glib::RefPtr<TreeModel>& model, int column, const Glib::ustring& key, const TreeModel::iterator& iter)
616   typedef sigc::slot<bool, const Glib::RefPtr<TreeModel>&, int, const Glib::ustring&, const TreeModel::iterator&> SlotSearchEqual;
617   //SlotSearchEqual get_search_equal_func();
618   _IGNORE(gtk_tree_view_get_search_equal_func)
619   
620   /** Sets the compare function for the interactive search capabilities.
621    *
622    * @param slot The compare function to use during the search
623    */
624   void set_search_equal_func(const SlotSearchEqual& slot);
625   _IGNORE(gtk_tree_view_set_search_equal_func)
626
627   _WRAP_METHOD(Entry* get_search_entry(), gtk_tree_view_get_search_entry)
628   _WRAP_METHOD(const Entry* get_search_entry() const, gtk_tree_view_get_search_entry, constversion)
629   _WRAP_METHOD(void set_search_entry(Entry& entry), gtk_tree_view_set_search_entry)
630
631   ///void on_search_position(Gtk::Widget* search_dialog)
632   typedef sigc::slot<void, Gtk::Widget* /* search_dialog */> SlotSearchPosition;
633   void set_search_position_func(const SlotSearchPosition& slot);
634   _IGNORE(gtk_tree_view_get_search_position_func, gtk_tree_view_set_search_position_func)
635
636   _WRAP_METHOD(void convert_widget_to_tree_coords(int wx, int wy, int& tx, int& ty) const, gtk_tree_view_convert_widget_to_tree_coords)
637   _WRAP_METHOD(void convert_tree_to_widget_coords(int tx, int ty, int& wx, int& wy) const, gtk_tree_view_convert_tree_to_widget_coords)
638   _WRAP_METHOD(void convert_widget_to_bin_window_coords(int wx, int wy, int& bx, int& by) const, gtk_tree_view_convert_widget_to_bin_window_coords)
639   _WRAP_METHOD(void convert_bin_window_to_widget_coords(int bx, int by, int& wx, int& wy) const, gtk_tree_view_convert_bin_window_to_widget_coords)
640   _WRAP_METHOD(void convert_tree_to_bin_window_coords(int tx, int ty, int& bx, int& by) const, gtk_tree_view_convert_tree_to_bin_window_coords)
641   _WRAP_METHOD(void convert_bin_window_to_tree_coords(int bx, int by, int& tx, int& ty) const, gtk_tree_view_convert_bin_window_to_tree_coords)
642
643
644   _WRAP_METHOD(void set_fixed_height_mode(bool enable = true), gtk_tree_view_set_fixed_height_mode)
645   _WRAP_METHOD(bool get_fixed_height_mode() const, gtk_tree_view_get_fixed_height_mode)
646   _WRAP_METHOD(void set_hover_selection(bool hover = true), gtk_tree_view_set_hover_selection)
647   _WRAP_METHOD(bool get_hover_selection() const, gtk_tree_view_get_hover_selection)
648   _WRAP_METHOD(void set_hover_expand(bool expand = true), gtk_tree_view_set_hover_expand)
649   _WRAP_METHOD(bool get_hover_expand() const, gtk_tree_view_get_hover_expand)
650   _WRAP_METHOD(void set_rubber_banding(bool enable = true), gtk_tree_view_set_rubber_banding)
651   _WRAP_METHOD(bool get_rubber_banding() const, gtk_tree_view_get_rubber_banding)
652
653   //TODO: Rename to get_is?
654   _WRAP_METHOD(bool is_rubber_banding_active() const, gtk_tree_view_is_rubber_banding_active)
655
656   /** For instance,
657    * void on_row_separator(const Gtk::TreeModel& model, const Gtk::TreeModel::iterator& iter);
658    */
659   typedef sigc::slot<bool, const Glib::RefPtr<TreeModel>&, const TreeModel::iterator&> SlotRowSeparator;
660   
661   void set_row_separator_func(const SlotRowSeparator& slot);
662   _IGNORE(gtk_tree_view_set_row_separator_func, gtk_tree_view_get_row_separator_func)
663
664   _WRAP_METHOD(void set_grid_lines(TreeViewGridLines grid_lines), gtk_tree_view_set_grid_lines)
665   _WRAP_METHOD(TreeViewGridLines get_grid_lines() const, gtk_tree_view_get_grid_lines)
666
667   _WRAP_METHOD(void set_enable_tree_lines(bool enable = true), gtk_tree_view_set_enable_tree_lines)
668   _WRAP_METHOD(bool get_enable_tree_lines() const, gtk_tree_view_get_enable_tree_lines)
669
670   _WRAP_METHOD(void set_show_expanders(bool enabled = true), gtk_tree_view_set_show_expanders)
671   _WRAP_METHOD(bool get_show_expanders() const, gtk_tree_view_get_show_expanders)
672   _WRAP_METHOD(void set_level_indentation(int indentation), gtk_tree_view_set_level_indentation)
673   _WRAP_METHOD(int get_level_indentation() const, gtk_tree_view_get_level_indentation)
674
675   _WRAP_METHOD(void set_tooltip_row(const Glib::RefPtr<Tooltip>& tooltip, const TreePath& path), gtk_tree_view_set_tooltip_row)
676
677   //Note that we use pointers instead of references because any one of the 3 arguments may be NULL, and we don't want that many method overloads:
678 #m4 _CONVERSION(`const TreeModel::Path*',`GtkTreePath*',`(($3) ? const_cast<GtkTreePath*>(($3)->gobj()) : 0)')
679   _WRAP_METHOD(void set_tooltip_cell(const Glib::RefPtr<Tooltip>& tooltip, const TreeModel::Path* path, TreeViewColumn* column, CellRenderer* cell), gtk_tree_view_set_tooltip_cell)
680
681   _IGNORE(gtk_tree_view_get_tooltip_context)
682
683   /**
684    * @param x: the x coordinate (relative to widget coordinates)
685    * @param y: the y coordinate (relative to widget coordinates)
686    * @param keyboard_tip: whether this is a keyboard tooltip or not
687    * @param path: a reference to receive a Gtk::TreePath
688    *
689    * This function is supposed to be used in a Gtk::Widget::query-tooltip
690    * signal handler for Gtk::TreeView. The x, y and keyboard_tip values
691    * which are received in the signal handler, should be passed to this
692    * function without modification.
693    *
694    * The return value indicates whether there is an tree view row at the given
695    * coordinates (true) or not (false) for mouse tooltips. For keyboard
696    * tooltips the row returned will be the cursor item. When true, then the
697    * path which has been provided will be set to point to
698    * that row and the corresponding model. x and y will always be converted
699    * to be relative to Gtk::TreeView's bin_window if keyboard_tooltip is false.
700    *
701    * Return value: whether or not the given tooltip context points to a row.
702    *
703    * @newin2p12
704    */
705   bool get_tooltip_context_path(int& x, int& y,
706                                 bool keyboard_tip,
707                                 TreeModel::Path& path);
708
709   /**
710    * @param x: the x coordinate (relative to widget coordinates)
711    * @param y: the y coordinate (relative to widget coordinates)
712    * @param keyboard_tip: whether this is a keyboard tooltip or not
713    * @param iter: a pointer to receive a Gtk::TreeIter
714    *
715    * This function is supposed to be used in a Gtk::Widget::query-tooltip
716    * signal handler for Gtk::TreeView. The x, y and keyboard_tip values
717    * which are received in the signal handler, should be passed to this
718    * function without modification.
719    *
720    * The return value indicates whether there is an tree view row at the given
721    * coordinates (true) or not (false) for mouse tooltips. For keyboard
722    * tooltips the row returned will be the cursor item. When true, then the
723    * iter which has been provided will be set to point to
724    * that row and the corresponding model. x and y will always be converted
725    * to be relative to Gtk::TreeView's bin_window if keyboard_tooltip is false.
726    *
727    * Return value: whether or not the given tooltip context points to a row.
728    *
729    * @newin2p12
730    */
731   bool get_tooltip_context_iter(int& x, int& y,
732                                 bool keyboard_tip,
733                                 Gtk::TreeModel::iterator& iter);
734
735   _WRAP_METHOD(void set_tooltip_column(int column), gtk_tree_view_set_tooltip_column)
736   _WRAP_METHOD(int get_tooltip_column() const, gtk_tree_view_get_tooltip_column)
737
738
739 #m4begin
740 dnl // We need this special conversion here since the C++ Gtk::TreeIter carries
741 dnl // a pointer to the Gtk::TreeModel, whereas the plain GtkTreeIter struct does
742 dnl // not.  Fortunately we can use the `self' parameter to get our hands on the
743 dnl // GtkTreeModel*.
744 _CONVERSION(`GtkTreeIter*',`const TreeModel::iterator&',`TreeModel::iterator(gtk_tree_view_get_model(self), $3)')
745 #m4end
746
747   _WRAP_SIGNAL(void set_scroll_adjustments(Adjustment* hadjustment, Adjustment* vadjustment), "set-scroll-adjustments")
748   _WRAP_SIGNAL(void row_activated(const TreeModel::Path& path, TreeViewColumn* column) , "row-activated")
749   _WRAP_SIGNAL(bool test_expand_row(const TreeModel::iterator& iter, const TreeModel::Path& path), "test-expand-row")
750   _WRAP_SIGNAL(bool test_collapse_row(const TreeModel::iterator& iter, const TreeModel::Path& path), "test-collapse-row")
751   _WRAP_SIGNAL(void row_expanded(const TreeModel::iterator& iter, const TreeModel::Path& path), "row-expanded")
752   _WRAP_SIGNAL(void row_collapsed(const TreeModel::iterator& iter, const TreeModel::Path& path), "row-collapsed")
753   _WRAP_SIGNAL(void cursor_changed(), "cursor-changed")
754   _WRAP_SIGNAL(void columns_changed(), "columns-changed")
755
756   //Don't wrap these. They are keybinding signals, and their API broke for GTK+ 2.2.
757   _IGNORE_SIGNAL("move-cursor")
758   _IGNORE_SIGNAL("select-all")
759   _IGNORE_SIGNAL("unselect-all")
760   _IGNORE_SIGNAL("select-cursor-row")
761   _IGNORE_SIGNAL("toggle-cursor-row")
762   _IGNORE_SIGNAL("expand-collapse-cursor-row")
763   _IGNORE_SIGNAL("select-cursor-parent")
764   _IGNORE_SIGNAL("start-interactive-search")
765
766
767   _WRAP_PROPERTY("model", Glib::RefPtr<TreeModel>)
768   _WRAP_PROPERTY("hadjustment", Adjustment*)
769   _WRAP_PROPERTY("vadjustment", Adjustment*)
770   _WRAP_PROPERTY("headers-visible", bool)
771   _WRAP_PROPERTY("headers-clickable", bool)
772   _WRAP_PROPERTY("expander-column", TreeViewColumn*)
773   _WRAP_PROPERTY("reorderable", bool)
774   _WRAP_PROPERTY("rules-hint", bool)
775   _WRAP_PROPERTY("enable-search", bool)
776   _WRAP_PROPERTY("search-column", int)
777   _WRAP_PROPERTY("fixed-height-mode", bool)
778   _WRAP_PROPERTY("hover-selection", bool)
779   _WRAP_PROPERTY("hover-expand", bool)
780   _WRAP_PROPERTY("show-expanders", bool)
781   _WRAP_PROPERTY("level-indentation", bool)
782   _WRAP_PROPERTY("rubber-banding", bool)
783   _WRAP_PROPERTY("enable-grid-lines", bool)
784   _WRAP_PROPERTY("enable-tree-lines", bool)
785
786   /// Get the treeview's model, but actually get the child model if it's a TreeModelFilter.
787   Glib::RefPtr<Gtk::TreeModel> _get_base_model();
788  
789 protected:
790
791 #ifndef DOXYGEN_SHOULD_SKIP_THIS
792   template<class ColumnType> friend
793   void _auto_store_on_cellrenderer_text_edited_string(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model);
794
795   template <class ColumnType> friend
796   void _auto_store_on_cellrenderer_text_edited_numerical(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model);
797
798   void _auto_store_on_cellrenderer_toggle_edited_with_model(const Glib::ustring& path_string, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model);
799
800   // This is no longer used, but we must keep it to prevent linker errors with already-compiled applications,
801   // For instance, applications that were compiled with the older versions of the templates that did use this method.
802   // TODO: Remove this when we can break API.
803   void _auto_store_on_cellrenderer_toggle_edited(const Glib::ustring& path_string, int model_column);
804
805   template<class ColumnType> friend
806   void TreeView_Private::_connect_auto_store_editable_signal_handler(TreeView*, CellRenderer*, const TreeModelColumn<ColumnType>&);
807
808 #endif //DOXYGEN_SHOULD_SKIP_THIS
809 };
810
811
812
813 template <class ColumnType> inline
814 int TreeView::append_column(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column)
815 {
816   // compilation will fail if there is no appropriate TreeViewColumn
817   // constructor for this model column type.
818   TreeViewColumn *const pViewColumn = Gtk::manage( new TreeViewColumn(title, model_column) );
819
820   return append_column(*pViewColumn);
821 }
822
823 //This is here because sigc::bind once did not work on all platforms, but now it does..
824 #define GTKMM_HAVE_SIGC_BIND 1
825
826 #ifdef GTKMM_HAVE_SIGC_BIND
827
828 template <class ColumnType> inline
829 int TreeView::append_column_numeric(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, const Glib::ustring& format)
830 {
831   TreeViewColumn* const pViewColumn = Gtk::manage( new TreeViewColumn(title) );
832     
833   //Use a CellRendererText:
834   //We don't use TreeView::Column::append_column(model_column) to generate an appropriate CellRenderer, 
835   //because that uses set_renderer(), which renders the model value using the automatic glib "transformations" (number-string conversions). As well as being unnecessary here, those automatic conversions can't handle all numeric types.
836   CellRenderer* pCellRenderer = manage( new CellRendererText() );
837   pViewColumn->pack_start(*pCellRenderer);
838   
839
840   //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
841   typedef void (*type_fptr)(Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter, int model_column, const Glib::ustring& format);
842   type_fptr fptr = TreeView_Private::_auto_cell_data_func<ColumnType>;
843
844   //Connect a cell_data callback, to show the number's text representation in the specified format:
845   //We use sigc::bind<-1> twice here, instead of sigc::bind() once, because some compilers need the extra hint.
846   Gtk::TreeViewColumn::SlotCellData slot = sigc::bind<-1>(
847     sigc::bind<-1>( sigc::ptr_fun(fptr), format),
848     model_column.index()
849   );
850     
851   pViewColumn->set_cell_data_func(*pCellRenderer, slot);
852
853   return append_column(*pViewColumn);
854 }
855
856 #endif //GTKMM_HAVE_SIGC_BIND
857
858 template <class ColumnType> inline
859 int TreeView::append_column_numeric_editable(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, const Glib::ustring& format)
860 {
861   int cols_count = append_column_numeric(title, model_column, format);
862   
863   //connect signal handlers for auto-storing of edited cell data
864   //Note: This will only work for base-10 (decimal) formatted numbers:
865   CellRenderer *const cell = get_column_cell_renderer(cols_count - 1);
866   if(cell)
867   {
868     TreeView_Private::_connect_auto_store_editable_signal_handler<ColumnType>(this, cell, model_column);
869   }
870    
871   return cols_count;
872 }
873
874 template <class ColumnType> inline
875 int TreeView::append_column_editable(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column)
876 {
877   //Don't use this in a header, because it gives warnings when disabled: g_assert(model_column.type() != 0);
878
879   // compilation will fail if there is no appropriate TreeViewColumn
880   // constructor for this model column type.
881   TreeViewColumn *const pViewColumn = Gtk::manage( new TreeViewColumn(title, model_column) );
882
883   //connect signal handlers for auto-storing of edited cell data
884   CellRenderer* pCellRender = pViewColumn->get_first_cell_renderer();
885   TreeView_Private::_connect_auto_store_editable_signal_handler<ColumnType>(this, pCellRender, model_column);
886
887   return append_column(*pViewColumn);
888 }
889
890 template <class ColumnType> inline
891 int TreeView::insert_column(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, int position)
892 {
893   // compilation will fail if there is no appropriate TreeViewColumn
894   // constructor for this model column type.
895   TreeViewColumn *const pViewColumn = Gtk::manage( new TreeViewColumn(title, model_column) );
896
897   return insert_column(*pViewColumn, position);
898 }
899
900 template <class ColumnType> inline
901 int TreeView::insert_column_editable(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, int position)
902 {
903   // compilation will fail if there is no appropriate TreeViewColumn
904   // constructor for this model column type.
905   TreeViewColumn *const pViewColumn = Gtk::manage( new TreeViewColumn(title, model_column) );
906
907    //connect signal handlers for auto-storing of edited cell data
908   CellRenderer* pCellRender = pViewColumn->get_first_cell_renderer();
909   TreeView_Private::_connect_auto_store_editable_signal_handler(this, pCellRender, model_column);
910
911   return insert_column(*pViewColumn, position);
912 }
913
914
915 #ifndef DOXYGEN_SHOULD_SKIP_THIS
916 namespace TreeView_Private
917 {
918
919 //Template specializations, for different model column types:
920 //TODO: Move these specializations into the .ccg file - I tried, but the int specialization was not used by the compiler. murrayc.
921
922 #ifdef GTKMM_HAVE_SIGC_BIND
923
924 //bool specialization:
925 template<> inline
926 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer, const Gtk::TreeModelColumn<bool>& model_column)
927 {
928   Gtk::CellRendererToggle* pCellToggle = dynamic_cast<Gtk::CellRendererToggle*>(pCellRenderer);
929   if(pCellToggle)
930   {
931     //Set the appropriate property,
932     #ifdef GLIBMM_PROPERTIES_ENABLED
933     pCellToggle->property_activatable() = true;
934     #else
935     pCellToggle->set_property("activatable", true);
936     #endif
937
938     //Connect to the appropriate signal, sending the model_column too
939
940     sigc::slot<void, const Glib::ustring&, int> slot_temp = 
941       sigc::bind<-1>(
942         sigc::mem_fun(*this_p, &Gtk::TreeView::_auto_store_on_cellrenderer_toggle_edited_with_model), 
943         this_p->_get_base_model()
944       );
945
946     pCellToggle->signal_toggled().connect(
947       sigc::bind<-1>( 
948         slot_temp,
949         model_column.index()
950       )
951     );
952
953     //We use bind<1> instead of bind because some compilers need the extra hint.
954   }
955 }
956
957 //int specialization:
958 template<> inline
959 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer,  const Gtk::TreeModelColumn<int>& model_column)
960 {
961   Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
962   if(pCellText)
963   {
964     //Set the appropriate property,
965     #ifdef GLIBMM_PROPERTIES_ENABLED
966     pCellText->property_editable() = true;
967     #else
968     pCellText->set_property("editable", true);
969     #endif
970
971     //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
972     typedef void (*type_fptr)(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model);
973     type_fptr fptr = _auto_store_on_cellrenderer_text_edited_numerical<int>;
974
975     //Connect to the appropriate signal, sending the model_column too,
976     //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
977     pCellText->signal_edited().connect(
978       sigc::bind<-1>(
979         sigc::bind<-1>( 
980           sigc::ptr_fun(fptr),
981           this_p->_get_base_model() ),
982         model_column.index()
983       )
984     );
985
986   }
987 }
988
989 //unsigned int specialization:
990 template<> inline
991 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer,  const Gtk::TreeModelColumn<unsigned int>& model_column)
992 {
993   Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
994   if(pCellText)
995   {
996     //Set the appropriate property,
997     #ifdef GLIBMM_PROPERTIES_ENABLED
998     pCellText->property_editable() = true;
999     #else
1000     pCellText->set_property("editable", true);
1001     #endif
1002
1003     //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1004     typedef void (*type_fptr)(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model);
1005     type_fptr fptr = _auto_store_on_cellrenderer_text_edited_numerical<unsigned int>;
1006
1007     //Connect to the appropriate signal, sending the model_column too,
1008     //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1009     pCellText->signal_edited().connect(
1010       sigc::bind<-1>(
1011         sigc::bind<-1>( 
1012           sigc::ptr_fun(fptr),
1013           this_p->_get_base_model() ),
1014         model_column.index()
1015       )
1016     );
1017     
1018   }
1019 }
1020
1021 //long specialization:
1022 template<> inline
1023 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer,  const Gtk::TreeModelColumn<long>& model_column)
1024 {
1025   Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
1026   if(pCellText)
1027   {
1028     //Set the appropriate property,
1029     #ifdef GLIBMM_PROPERTIES_ENABLED
1030     pCellText->property_editable() = true;
1031     #else
1032     pCellText->set_property("editable", true);
1033     #endif
1034
1035     //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1036     typedef void (*type_fptr)(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model);
1037     type_fptr fptr = _auto_store_on_cellrenderer_text_edited_numerical<long>;
1038
1039     //Connect to the appropriate signal, sending the model_column too,
1040     //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1041     pCellText->signal_edited().connect(
1042       sigc::bind<-1>(
1043         sigc::bind<-1>( 
1044           sigc::ptr_fun(fptr),
1045           this_p->_get_base_model() ),
1046         model_column.index()
1047       )
1048     );
1049     
1050   }
1051 }
1052
1053 //unsigned long specialization:
1054 template<> inline
1055 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer,  const Gtk::TreeModelColumn<unsigned long>& model_column)
1056 {
1057   Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
1058   if(pCellText)
1059   {
1060     //Set the appropriate property,
1061     #ifdef GLIBMM_PROPERTIES_ENABLED
1062     pCellText->property_editable() = true;
1063     #else
1064     pCellText->set_property("editable", true);
1065     #endif
1066
1067     //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1068     typedef void (*type_fptr)(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model);
1069     type_fptr fptr = _auto_store_on_cellrenderer_text_edited_numerical<unsigned long>;
1070
1071     //Connect to the appropriate signal, sending the model_column too,
1072     //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1073     pCellText->signal_edited().connect(
1074       sigc::bind<-1>(
1075         sigc::bind<-1>( 
1076           sigc::ptr_fun(fptr),
1077           this_p->_get_base_model() ),
1078         model_column.index()
1079       )
1080     );
1081  
1082   }
1083 }
1084
1085 //float specialization:
1086 template<> inline
1087 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer,  const Gtk::TreeModelColumn<float>& model_column)
1088 {
1089   Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
1090   if(pCellText)
1091   {
1092     //Set the appropriate property,
1093     #ifdef GLIBMM_PROPERTIES_ENABLED
1094     pCellText->property_editable() = true;
1095     #else
1096     pCellText->set_property("editable", true);
1097     #endif
1098
1099     //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1100     typedef void (*type_fptr)(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model);
1101     type_fptr fptr = _auto_store_on_cellrenderer_text_edited_numerical<float>;
1102
1103     //Connect to the appropriate signal, sending the model_column too,
1104     //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1105     pCellText->signal_edited().connect(
1106       sigc::bind<-1>(
1107         sigc::bind<-1>( 
1108           sigc::ptr_fun(fptr),
1109           this_p->_get_base_model() ),
1110         model_column.index()
1111       )
1112     );
1113   }
1114 }
1115
1116 //double specialization:
1117 template<> inline
1118 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer,  const Gtk::TreeModelColumn<double>& model_column)
1119 {
1120   Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
1121   if(pCellText)
1122   {
1123     //Set the appropriate property,
1124     #ifdef GLIBMM_PROPERTIES_ENABLED
1125     pCellText->property_editable() = true;
1126     #else
1127     pCellText->set_property("editable", true);
1128     #endif
1129
1130     //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1131     typedef void (*type_fptr)(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model);
1132     type_fptr fptr = _auto_store_on_cellrenderer_text_edited_numerical<double>;
1133
1134     //Connect to the appropriate signal, sending the model_column too,
1135     //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1136     pCellText->signal_edited().connect(
1137       sigc::bind<-1>(
1138         sigc::bind<-1>( 
1139           sigc::ptr_fun(fptr),
1140           this_p->_get_base_model() ),
1141         model_column.index()
1142       )
1143     );
1144   }
1145 }
1146
1147 #endif //GTKMM_HAVE_SIGC_BIND
1148
1149 } // namespace TreeView_Private
1150 #endif //DOXYGEN_SHOULD_SKIP_THIS
1151
1152
1153 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1154 namespace TreeView_Private
1155 {
1156
1157 #ifdef GTKMM_HAVE_SIGC_BIND
1158
1159 template <class ColumnType> inline
1160 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer, const Gtk::TreeModelColumn<ColumnType>& model_column)
1161 {
1162   //Don't use this in a header, because it gives warnings when disabled: g_assert(model_column.type() != 0);
1163
1164   //The different CellRenderers have different "edited" signals,
1165   //and numerical values need to convert the text value to a number,
1166   //so there are specializations for this tempate.
1167
1168   Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
1169
1170   //Set the appropriate property,
1171   //and connect to the appropriate signal, sending the model_column too,
1172   if(pCellText)
1173   {
1174     #ifdef GLIBMM_PROPERTIES_ENABLED
1175     pCellText->property_editable() = true;
1176     #else
1177     pCellText->set_property("editable", true);
1178     #endif
1179
1180     //Some compilers (IRIX MipsPro) don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1181     typedef void (*type_func)(const Glib::ustring&, const Glib::ustring&, int, const Glib::RefPtr<Gtk::TreeModel>&);
1182     type_func func = &(_auto_store_on_cellrenderer_text_edited_string<ColumnType>);
1183     sigc::slot<void, const Glib::ustring&, const Glib::ustring&, int, const Glib::RefPtr<Gtk::TreeModel>&> theslot  =
1184       sigc::ptr_fun(func);
1185
1186     //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1187     pCellText->signal_edited().connect(
1188       sigc::bind<-1>(
1189         sigc::bind<-1>( theslot, this_p->_get_base_model()),
1190         model_column.index()
1191       )
1192     );
1193
1194     
1195   }
1196 }
1197
1198 #endif //GTKMM_HAVE_SIGC_BIND
1199
1200 template <class ColumnType> inline
1201 void _auto_store_on_cellrenderer_text_edited_string(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model)
1202 {
1203   Gtk::TreePath path(path_string);
1204
1205   //Get the row from the path:
1206   if(model)
1207   {
1208     Gtk::TreeModel::iterator iter = model->get_iter(path);
1209     if(iter)
1210     {
1211         //Store the user's new text in the model:
1212         Gtk::TreeRow row = *iter;
1213         row.set_value(model_column, (ColumnType)new_text);
1214     }
1215   }
1216 }
1217
1218 template <class ColumnType> inline
1219 void _auto_store_on_cellrenderer_text_edited_numerical(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, const Glib::RefPtr<Gtk::TreeModel>& model)
1220 {
1221   //This is used on numerical model columns:
1222
1223   Gtk::TreePath path(path_string);
1224
1225   //Get the row from the path:
1226   if(model)
1227   {
1228     Gtk::TreeModel::iterator iter = model->get_iter(path);
1229     if(iter)
1230     {
1231       //std::istringstream astream(new_text); //Put it in a stream.
1232       //ColumnType new_value = ColumnType();
1233       //new_value << astream; //Get it out of the stream as the numerical type.
1234
1235       //Convert the text to a number, using the same logic used by GtkCellRendererText when it stores numbers.
1236       char* pchEnd = 0;
1237       ColumnType new_value = static_cast<ColumnType>( strtod(new_text.c_str(), &pchEnd) );
1238
1239       //Store the user's new text in the model:
1240       Gtk::TreeRow row = *iter;
1241       row.set_value(model_column, (ColumnType)new_value);
1242     }
1243   }
1244 }
1245
1246 template <class ColumnType> inline
1247 void _auto_cell_data_func(Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter, int model_column, const Glib::ustring& format)
1248 {
1249   Gtk::CellRendererText* pTextRenderer = dynamic_cast<Gtk::CellRendererText*>(cell);
1250   if(!pTextRenderer)
1251   {
1252     g_warning("gtkmm: TextView: append_column_numeric() was used with a non-numeric type.");
1253   }
1254   else
1255   {
1256     if(iter)
1257     {
1258       //Get the value from the model.
1259       Gtk::TreeModel::Row row = *iter;
1260       ColumnType value = ColumnType();
1261       row.get_value(model_column, value);
1262
1263       //Convert it to a string representation:
1264       char buff[20];
1265       int used = g_snprintf(buff, sizeof(buff), format.c_str(), value); //value must be a numeric type.
1266       if(used > 0)
1267       {
1268         //Show the text representation in the view:
1269         #ifdef GLIBMM_PROPERTIES_ENABLED
1270         pTextRenderer->property_text() = buff;
1271         #else
1272         pTextRenderer->set_property("text", (void*)buff);
1273         #endif
1274       }
1275     }
1276   }
1277 }
1278
1279 } // namespace TreeView_Private
1280 #endif //DOXYGEN_SHOULD_SKIP_THIS
1281
1282
1283 } // namespace Gtk
1284