2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_TREEVIEW_H
4 #define _GTKMM_TREEVIEW_H
10 /* Copyright(C) 2002 The gtkmm Development Team
12 * This library is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU Library General Public
14 * License as published by the Free Software Foundation; either
15 * version 2 of the License, or(at your option) any later version.
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with this library; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <glibmm/listhandle.h>
28 #include <gtkmm/container.h>
29 #include <gtkmm/adjustment.h>
30 #include <gdkmm/pixmap.h>
31 #include <gtkmm/treeviewcolumn.h>
32 #include <gtkmm/treeselection.h>
33 #include <gtkmm/treemodelcolumn.h>
34 #include <gtkmm/cellrenderer.h>
35 #include <gtkmm/targetentry.h>
38 #ifndef DOXYGEN_SHOULD_SKIP_THIS
39 typedef struct _GtkTreeView GtkTreeView;
40 typedef struct _GtkTreeViewClass GtkTreeViewClass;
41 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
45 { class TreeView_Class; } // namespace Gtk
50 /** @addtogroup gtkmmEnums Enums and Flags */
55 enum TreeViewDropPosition
57 TREE_VIEW_DROP_BEFORE,
59 TREE_VIEW_DROP_INTO_OR_BEFORE,
60 TREE_VIEW_DROP_INTO_OR_AFTER
66 #ifndef DOXYGEN_SHOULD_SKIP_THIS
71 class Value<Gtk::TreeViewDropPosition> : public Glib::Value_Enum<Gtk::TreeViewDropPosition>
74 static GType value_type() G_GNUC_CONST;
78 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
85 #ifndef DOXYGEN_SHOULD_SKIP_THIS
89 namespace TreeView_Private
91 /* This helper function is not a member of TreeView just for the reason that
92 * there are compilers that have problems compiling it otherwise. E.g. in gcc
93 * 2.95.3 a compiler bug prevents member functions from refering to specialized
94 * member function templates and that's what we do here: In function
95 * _connect_auto_store_editable_signal_handler we build a slot from
96 * TreeView::_auto_store_on_cellrenderer_*_edited. (The latter must be member
97 * functions of TreeView since we connect them to signals and we want the
98 * connections to vanish when the TreeView dies, of course.)
100 template <class ColumnType> inline
101 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer, const Gtk::TreeModelColumn<ColumnType>& model_column);
103 template<class ColumnType> inline
104 void _auto_store_on_cellrenderer_text_edited_string(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, Gtk::TreeView*);
106 template <class ColumnType> inline
107 void _auto_store_on_cellrenderer_text_edited_numerical(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, Gtk::TreeView*);
109 template <class ColumnType> inline
110 void _auto_cell_data_func(Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter, int model_column, const Glib::ustring& format);
113 #endif //DOXYGEN_SHOULD_SKIP_THIS
116 //class TreeViewColumn;
119 /** @defgroup TreeView TreeView Classes
120 * These classes are used with the Gtk::TreeView widget.
123 /** The TreeView widget displays the model (Gtk::TreeModel) data and allows the user to interact with it.
124 * The View can show all of the model's columns, or just some, and it can show them in various ways.
125 * You must provide the TreeModel in the constructor, or with set_model().
127 * Add View columns with append_column(), append_column_editable(), insert_column(), or insert_column_editable().
129 * You can manipulate the selection by obtaining the @link Gtk::TreeSelection Gtk::TreeView::Selection@endlink from get_selection().
132 * @ingroup Containers
136 class TreeView : public Container
139 #ifndef DOXYGEN_SHOULD_SKIP_THIS
140 typedef TreeView CppObjectType;
141 typedef TreeView_Class CppClassType;
142 typedef GtkTreeView BaseObjectType;
143 typedef GtkTreeViewClass BaseClassType;
144 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
148 #ifndef DOXYGEN_SHOULD_SKIP_THIS
151 friend class TreeView_Class;
152 static CppClassType treeview_class_;
155 TreeView(const TreeView&);
156 TreeView& operator=(const TreeView&);
159 explicit TreeView(const Glib::ConstructParams& construct_params);
160 explicit TreeView(GtkTreeView* castitem);
162 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
165 #ifndef DOXYGEN_SHOULD_SKIP_THIS
166 static GType get_type() G_GNUC_CONST;
167 static GType get_base_type() G_GNUC_CONST;
170 ///Provides access to the underlying C GtkObject.
171 GtkTreeView* gobj() { return reinterpret_cast<GtkTreeView*>(gobject_); }
173 ///Provides access to the underlying C GtkObject.
174 const GtkTreeView* gobj() const { return reinterpret_cast<GtkTreeView*>(gobject_); }
178 //C++ methods used to invoke GTK+ virtual functions:
181 //GTK+ Virtual Functions (override these to change behaviour):
183 //Default Signal Handlers::
184 virtual void on_set_scroll_adjustments(Adjustment* hadjustment, Adjustment* vadjustment);
185 virtual void on_row_activated(const TreeModel::Path& path, TreeViewColumn* column);
186 virtual bool on_test_expand_row(const TreeModel::iterator& iter, const TreeModel::Path& path);
187 virtual bool on_test_collapse_row(const TreeModel::iterator& iter, const TreeModel::Path& path);
188 virtual void on_row_expanded(const TreeModel::iterator& iter, const TreeModel::Path& path);
189 virtual void on_row_collapsed(const TreeModel::iterator& iter, const TreeModel::Path& path);
190 virtual void on_cursor_changed();
191 virtual void on_columns_changed();
198 /** A visible column in a Gtk::TreeView widget.
200 typedef TreeViewColumn Column;
202 /** A selection object for Gtk::TreeView.
204 typedef TreeSelection Selection;
210 Constructor that binds to a TreeModel
212 explicit TreeView(const Glib::RefPtr<TreeModel>& model);
215 /** Returns the model the the Gtk::TreeView is based on. Returns <tt>0</tt> if the
217 * @return A Gtk::TreeModel, or <tt>0</tt> if none is currently being used.
219 Glib::RefPtr<TreeModel> get_model();
221 /** Returns the model the the Gtk::TreeView is based on. Returns <tt>0</tt> if the
223 * @return A Gtk::TreeModel, or <tt>0</tt> if none is currently being used.
225 Glib::RefPtr<const TreeModel> get_model() const;
227 /** Sets the model for a Gtk::TreeView. If the @a tree_view already has a model
228 * set, it will remove it before setting the new model. If @a model is <tt>0</tt>,
229 * then it will unset the old model.
230 * @param model The model.
232 void set_model(const Glib::RefPtr<TreeModel>& model);
234 /** Gets the Gtk::TreeSelection associated with @a tree_view .
235 * @return A Gtk::TreeSelection object.
237 Glib::RefPtr<TreeSelection> get_selection();
239 /** Gets the Gtk::TreeSelection associated with @a tree_view .
240 * @return A Gtk::TreeSelection object.
242 Glib::RefPtr<const TreeSelection> get_selection() const;
244 /** Gets the Gtk::Adjustment currently being used for the horizontal aspect.
245 * @return A Gtk::Adjustment object, or <tt>0</tt> if none is currently being
248 Adjustment* get_hadjustment();
250 /** Gets the Gtk::Adjustment currently being used for the horizontal aspect.
251 * @return A Gtk::Adjustment object, or <tt>0</tt> if none is currently being
254 const Adjustment* get_hadjustment() const;
256 /** Sets the Gtk::Adjustment for the current horizontal aspect. See also unset_hadjustment().
257 * @param adjustment The Gtk::Adjustment to set.
259 void set_hadjustment(Adjustment& adjustment);
261 /** This method removes the hadjustment.
262 * @see set_hadjustment().
264 void unset_hadjustment();
267 /** Gets the Gtk::Adjustment currently being used for the vertical aspect.
268 * @return A Gtk::Adjustment object, or <tt>0</tt> if none is currently being
271 Adjustment* get_vadjustment();
273 /** Gets the Gtk::Adjustment currently being used for the vertical aspect.
274 * @return A Gtk::Adjustment object, or <tt>0</tt> if none is currently being
277 const Adjustment* get_vadjustment() const;
279 /** Sets the Gtk::Adjustment for the current vertical aspect. See also unset_vadjustment().
280 * @param adjustment The Gtk::Adjustment to set.
282 void set_vadjustment(Adjustment& adjustment);
284 /** This method removes the vadjustment.
285 * @see set_vadjustment().
287 void unset_vadjustment();
290 /** Returns <tt>true</tt> if the headers on the @a tree_view are visible.
291 * @return Whether the headers are visible or not.
293 bool get_headers_visible() const;
295 /** Sets the the visibility state of the headers.
296 * @param headers_visible <tt>true</tt> if the headers are visible.
298 void set_headers_visible(bool headers_visible);
300 /** Resizes all columns to their optimal width. Only works after the
301 * treeview has been realized.
303 void columns_autosize();
305 /** Allow the column title buttons to be clicked.
306 * @param setting <tt>true</tt> if the columns are clickable.
308 void set_headers_clickable(bool setting = true);
310 /** This function tells GTK+ that the user interface for your
311 * application requires users to read across tree rows and associate
312 * cells with one another. By default, GTK+ will then render the tree
313 * with alternating row colors. Do <em>not</em> use it
314 * just because you prefer the appearance of the ruled tree; that's a
315 * question for the theme. Some themes will draw tree rows in
316 * alternating colors even when rules are turned off, and users who
317 * prefer that appearance all the time can choose those themes. You
318 * should call this function only as a <em>semantic</em>
319 * hint to the theme engine that your tree makes alternating colors
320 * useful from a functional standpoint (since it has lots of columns,
322 * @param setting <tt>true</tt> if the tree requires reading across rows.
324 void set_rules_hint(bool setting = true);
326 /** Gets the setting set by set_rules_hint().
327 * @return <tt>true</tt> if rules are useful for the user of this tree.
329 bool get_rules_hint() const;
332 /** Appends @a column to the list of columns. If @a tree_view has "fixed_height"
333 * mode enabled, then @a column must have its "sizing" property set to be
334 * GTK_TREE_VIEW_COLUMN_FIXED.
335 * @param column The Gtk::TreeViewColumn to add.
336 * @return The number of columns in @a tree_view after appending.
338 int append_column(TreeViewColumn& column);
340 /** Appends a View column with the appropriate CellRenderer for the Model column.
342 * The CellRenderer can only be created automatically for some basic
343 * column types, such as Glib::ustring, int, double, bool, and Gdk::Pixbuf.
344 * If the type is not supported then the following warning will be shown:
345 * GLib-GObject-WARNING **: unable to set property `text' of type
346 * `gchararray' from value of type `glibmm__CustomBoxed_t'.
348 * If the default formatting is not sufficient, or the numeric type is
349 * not supported, then you could use append_column_numeric(). Or you
350 * could create the TreeView::Column and/or CellRenderer
351 * manually and use TreeViewColumn::set_cell_data_func() to provide a callback
352 * that converts the model value into a string representation with .
354 * @param title The text to be used in the title header of this column.
355 * @param model_column The column in the TreeModel that will be rendered by this View column.
356 * @result The number of columns in the View after appending.
358 template <class ColumnType> inline
359 int append_column(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column);
361 /** Like append_column(), but only for numeric types, which will be displayed in the specified format.
362 * This convenience template uses TreeView::Column::set_cell_data_func(), so the numeric formatting will
363 * be deactivated if you specify your own cell_data callback by calling set_cell_data_func() again.
365 * @param title The text to be used in the title header of this column.
366 * @param model_column The column in the TreeModel that will be rendered by this View column.
367 * @param format A printf-style format, such as "%d", used to create a text representation of the number.
368 * @result The number of columns in the View after appending.
370 template <class ColumnType> inline
371 int append_column_numeric(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, const Glib::ustring& format);
373 //TODO: danielk suggested use of Glib::Value to simplify/improve this.
374 /** Appends a View column with the appropriate CellRenderer for the Model
375 * column. The compiler will attempt to instantiate appropriate template
376 * code to automatically store user changes in the model. To intercept the
377 * user's change and implement non-default logic, or if the compiler can't
378 * instantiate appropriate code for your model type, you could use
379 * append_column() and connect a signal handler to the CellRenderer.
381 * @see append_column_numeric_editable().
383 * @param title The text to be used in the title header of this column.
384 * @param model_column The column in the TreeModel that will be rendered by this View column.
385 * @result The number of columns in the View after appending.
387 template <class ColumnType> inline
388 int append_column_editable(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column);
390 /** Like append_column_editable(), but only for numeric types, which will be displayed in the specified format.
391 * This convenience template uses TreeView::Column::set_cell_data_func(), so the numeric formatting will
392 * be deactivated if you specify your own cell_data callback by calling set_cell_data_func() again.
394 * Note that the user's input will be interpreted as decimal (base 10), regardless of the @a format.
396 * @param title The text to be used in the title header of this column.
397 * @param model_column The column in the TreeModel that will be rendered by this View column.
398 * @param format A printf-style format, such as "%d", used to create a text representation of the number.
399 * @result The number of columns in the View after appending.
401 template <class ColumnType> inline
402 int append_column_numeric_editable(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, const Glib::ustring& format);
405 /// Creates a View column containing the CellRenderer, and appends it.
406 int append_column(const Glib::ustring& title, CellRenderer& cell);
409 /** Removes @a column from @a tree_view .
410 * @param column The Gtk::TreeViewColumn to remove.
411 * @return The number of columns in @a tree_view after removing.
413 int remove_column(TreeViewColumn& column);
415 /// Removes all View columns.
416 void remove_all_columns();
419 /** This inserts the @a column into the @a tree_view at @a position . If @a position is
420 * -1, then the column is inserted at the end. If @a tree_view has
421 * "fixed_height" mode enabled, then @a column must have its "sizing" property
422 * set to be GTK_TREE_VIEW_COLUMN_FIXED.
423 * @param column The Gtk::TreeViewColumn to be inserted.
424 * @param position The position to insert @a column in.
425 * @return The number of columns in @a tree_view after insertion.
427 int insert_column(TreeViewColumn& column, int position);
429 /** Creates a View column containing the CellRenderer, and inserts it.
431 * @param title The text to be used in the title header of this column.
432 * @param cell The CellRenderer.
433 * @param position The position at which the CellRenderer should be inserted.
434 * @result The number of columns in the View after inserting.
436 int insert_column(const Glib::ustring& title, CellRenderer& cell, int position);
439 /** Inserts a View column with the appropriate CellRenderer for the Model column.
441 * @param title The text to be used in the title header of this column.
442 * @param model_column The column in the TreeModel that will be rendered by this View column.
443 * @param position The position at which the CellRenderer should be inserted.
444 * @result The number of columns in the View after inserting.
446 template <class ColumnType> inline
447 int insert_column(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, int position);
449 /** Inserts a View column with the appropriate CellRenderer for the Model
450 * column. The compiler will attempt to instantiate appropriate template
451 * code to automatically store user changes in the model. To intercept the
452 * user's change and implement non-default logic, or if the compiler can't
453 * instantiate appropriate code for your model type, you should use
454 * append_column() and connect a signal handler to the CellRenderer.
456 * @param title The text to be used in the title header of this column.
457 * @param model_column The column in the TreeModel that will be rendered by this View column.
458 * @param position The position at which the CellRenderer should be inserted.
459 * @result The number of columns in the View after inserting.
461 template <class ColumnType> inline
462 int insert_column_editable(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, int position);
464 typedef TreeViewColumn::SlotCellData SlotCellData;
467 * Inserts a new column into the TreeView with the given cell
468 * renderer and a SlotCellData to set cell renderer attributes
469 * (normally using data from the model).
471 * @param position Position to insert, -1 for append
472 * @param title column title
473 * @param cell cell renderer for column
474 * @param slot function to set attributes of cell renderer
475 * @return number of columns in the TreeView after the insert
477 int insert_column_with_data_func(int position, const Glib::ustring& title, CellRenderer& cell, const SlotCellData& slot);
480 /** Gets the Gtk::TreeViewColumn at the given position in the #tree_view.
481 * @param n The position of the column, counting from 0.
482 * @return The Gtk::TreeViewColumn, or <tt>0</tt> if the position is outside the
485 TreeViewColumn* get_column(int n);
487 /** Gets the Gtk::TreeViewColumn at the given position in the #tree_view.
488 * @param n The position of the column, counting from 0.
489 * @return The Gtk::TreeViewColumn, or <tt>0</tt> if the position is outside the
492 const TreeViewColumn* get_column(int n) const;
494 //The column index is of the view, not the model, so we do not need TreeViewColumn* get_column(TreeViewColumn& base_column).
496 /** Gets the CellRenderer for that column.
497 * You should dynamic_cast<> to the expected derived CellRenderer type.
498 * This assumes that the TreeViewColumn contains only one CellRenderer.
500 * @param n The position of the view column.
501 * @result The CellRenderer.
503 CellRenderer* get_column_cell_renderer(int n);
505 //TODO: Add TreeViewColumn* get_column_cell_renderer(TreeViewColumn& base_column); and a const one.
508 /** Gets the CellRenderer for that column.
509 * You should dynamic_cast<> to the expected derived CellRenderer type.
510 * This assumes that the TreeViewColumn contains only one CellRenderer.
512 * @param n The position of the view column.
513 * @result The CellRenderer.
515 const CellRenderer* get_column_cell_renderer(int n) const;
518 /** Returns a list of all the Gtk::TreeViewColumn s currently in @a tree_view .
519 * @return A list of Gtk::TreeViewColumn s.
521 Glib::ListHandle<TreeViewColumn*> get_columns();
523 /** Returns a list of all the Gtk::TreeViewColumn s currently in @a tree_view .
524 * @return A list of Gtk::TreeViewColumn s.
526 Glib::ListHandle<const TreeViewColumn*> get_columns() const;
529 /** Moves @a column to be after to @a base_column . See also move_column_to_start().
530 * @param column The Gtk::TreeViewColumn to be moved.
531 * @param base_column The Gtk::TreeViewColumn to be moved relative to.
533 void move_column_after(TreeViewColumn& column, TreeViewColumn& base_column);
535 /** This method moves column to the first position in the view.
537 * @param column The view column that will be moved
539 void move_column_to_start(TreeViewColumn& column);
542 /** Sets the column to draw the expander arrow at. It must be in the TreeView. See also reset_expander_column().
543 * @param column The column to draw the expander arrow at.
545 void set_expander_column(TreeViewColumn& column);
547 /** This method resets the expander arrow to the default - the first visible column.
548 * @see set_expander_column().
550 void reset_expander_column();
553 /** Returns the column that is the current expander column. This
554 * column has the expander arrow drawn next to it.
555 * @return The expander column.
557 TreeViewColumn* get_expander_column();
559 /** Returns the column that is the current expander column. This
560 * column has the expander arrow drawn next to it.
561 * @return The expander column.
563 const TreeViewColumn* get_expander_column() const;
566 * bool on_column_drop(TreeView*, tree_view, TreeViewColumn* column, TreeViewColumn* prev_column, TreeViewColumn* next_column)
568 * This function is called on every column pair in turn at the beginning of a column drag to determine where a
569 * drop can take place. The arguments passed to the function are: the tree_view, the view Column being dragged,
570 * and the two view Columns determining the drop spot. If either of the view Column arguments for the drop spot
571 * are 0, then they indicate an edge.
573 typedef sigc::slot<bool, TreeView*, TreeViewColumn*, TreeViewColumn*, TreeViewColumn*> SlotColumnDrop;
575 /** Sets a callback slot for determining where a column may be dropped when dragged.
576 * This function is called on every column pair in turn at the beginning of a column drag to determine where a
577 * drop can take place. The arguments passed to the function are: the tree_view, the view Column being dragged,
578 * and the two view Columns determining the drop spot. If either of the view Column arguments for the drop spot
579 * are 0, then they indicate an edge.
581 * See unset_column_drag_function().
583 * @param slot A callback function to determine which columns are reorderable.
585 void set_column_drag_function(const SlotColumnDrop& slot);
588 /** See set_column_drag_function(). After this method has been called, the TreeView reverts to the default behavior of
589 * allowing all columns to be dropped everywhere.
591 void unset_column_drag_function();
594 /** Scrolls the tree view such that the top-left corner of the visible
595 * area is @a tree_x , @a tree_y , where @a tree_x and @a tree_y are specified
596 * in tree window coordinates. The @a tree_view must be realized before
597 * this function is called. If it isn't, you probably want to be
598 * using scroll_to_cell().
600 * If either @a tree_x or @a tree_y are -1, then that direction isn't scrolled.
601 * @param tree_x X coordinate of new top-left pixel of visible area, or -1.
602 * @param tree_y Y coordinate of new top-left pixel of visible area, or -1.
604 void scroll_to_point(int tree_x, int tree_y);
606 /** Moves the alignments of tree view to the position specified by @a column and @a path.
607 * @a row_align determines where the row is placed, and @a col_align determines where
608 * column is placed. Both are expected to be between 0.0 and 1.0. 0.0 means left/top
609 * alignment, 1.0 means right/bottom alignment, 0.5 means center.
611 * This function only works if the model is set, and @a path is a valid row on the model.
612 * If the model changes before the tree view is realized, the centered path will be
613 * modified to reflect this change.
615 * @param path The path of the row to move to.
616 * @param column The Gtk::TreeViewColumn to move horizontally to.
617 * @param row_align The vertical alignment of the row specified by @a path.
618 * @param col_align The horizontal alignment of the column specified by @a column.
620 void scroll_to_cell(const TreeModel::Path& path, TreeViewColumn& column, float row_align, float col_align);
623 /** Moves the alignments of tree view to the position specified by @a column and @a path.
624 * The tree does the minimum amount of work to scroll the cell onto the screen. This means
625 * that the cell will be scrolled to the edge closest to it's current position. If the cell
626 * is currently visible on the screen, nothing is done.
628 * This function only works if the model is set, and @a path is a valid row on the model.
629 * If the model changes before the tree_view is realized, the centered path will be modified
630 * to reflect this change.
632 * @param path The path of the row to move to.
633 * @param column The Gtk::TreeViewColumn to move horizontally to.
635 void scroll_to_cell(const TreeModel::Path& path, TreeViewColumn& column);
637 /** Moves the alignments of tree view to the position specified by @a path.
638 * @a row_align determines where the row is placed, and is expected to be between 0.0
639 * and 1.0. 0.0 means top alignment, 1.0 means bottom alignment, 0.5 means center.
641 * This function only works if the model is set, and @a path is a valid row on the model.
642 * If the model changes before the tree view is realized, the centered path will be
643 * modified to reflect this change.
645 * @param path The path of the row to move to.
646 * @param row_align The vertical alignment of the row specified by @a path.
648 void scroll_to_row(const TreeModel::Path& path, float row_align);
650 /** Moves the alignments of tree view to the position specified by @a path.
651 * The tree does the minimum amount of work to scroll the row onto the screen. This means
652 * that the row will be scrolled to the edge closest to it's current position. If the row
653 * is currently visible on the screen, nothing is done.
655 * This function only works if the model is set, and @a path is a valid row on the model.
656 * If the model changes before the tree view is realized, the centered path will be
657 * modified to reflect this change.
659 * @param path The path of the row to move to.
661 void scroll_to_row(const TreeModel::Path& path);
663 /** Moves the alignments of tree view to the position specified by @a column.
664 * @a col_align determines where the column is placed, and is expected to be between 0.0
665 * and 1.0. 0.0 means left alignment, 1.0 means right alignment, 0.5 means center.
667 * This function only works if the model is set. If the model changes before the tree
668 * view is realized, the centered path will be modified to reflect this change.
670 * @param column The Gtk::TreeViewColumn to move horizontally to.
671 * @param col_align The horizontal alignment of the column specified by @a column.
673 void scroll_to_column(TreeViewColumn& column, float col_align);
675 /** Moves the alignments of tree view to the position specified by @a column.
676 * The tree does the minimum amount of work to scroll the column onto the screen. This means
677 * that the column will be scrolled to the edge closest to it's current position. If the column
678 * is currently visible on the screen, nothing is done.
680 * This function only works if the model is set. If the model changes before the
681 * tree view is realized, the centered path will be modified to reflect this change.
683 * @param column The Gtk::TreeViewColumn to move horizontally to.
685 void scroll_to_column(TreeViewColumn& column);
688 /** Activates the cell determined by @a path and @a column .
689 * @param path The Gtk::TreePath to be activated.
690 * @param column The Gtk::TreeViewColumn to be activated.
692 void row_activated(const TreeModel::Path& path,TreeViewColumn& column);
694 /** Recursively expands all nodes in the @a tree_view .
698 /** Recursively collapses all visible, expanded nodes in @a tree_view .
702 /** Expands the row at @a path . This will also expand all parent rows of
703 * @a path as necessary.
706 * @param path Path to a row.
708 void expand_to_path(const TreeModel::Path& path);
710 /** Opens the row so its children are visible.
711 * @param path Path to a row.
712 * @param open_all Whether to recursively expand, or just expand immediate children.
713 * @return <tt>true</tt> if the row existed and had children.
715 bool expand_row(const TreeModel::Path& path, bool open_all);
717 /** Collapses a row (hides its child rows, if they exist).
718 * @param path Path to a row in the @a tree_view .
719 * @return <tt>true</tt> if the row was collapsed.
721 bool collapse_row(const TreeModel::Path& path);
724 * void on_map_expanded_rows(TreeView* tree_view, const TreeModel::Path& path);
726 typedef sigc::slot<void, TreeView*, const TreeModel::Path&> SlotMapping;
728 /** Calls the callback slot on all expanded rows.
729 * @param slot A callback function to be called.
731 void map_expanded_rows(const SlotMapping& slot);
734 /** Returns <tt>true</tt> if the node pointed to by @a path is expanded in @a tree_view .
735 * @param path A Gtk::TreePath to test expansion state.
736 * @return <tt>true</tt> if #path is expanded.
738 bool row_expanded(const TreeModel::Path& path);
740 /** This function is a convenience function to allow you to reorder models that
741 * support the Gtk::DragSourceIface and the Gtk::DragDestIface. Both
742 * Gtk::TreeStore and Gtk::ListStore support these. If @a reorderable is <tt>true</tt>, then
743 * the user can reorder the model by dragging and dropping rows. The
744 * developer can listen to these changes by connecting to the model's
745 * row_inserted and row_deleted signals.
747 * This function does not give you any degree of control over the order -- any
748 * reordering is allowed. If more control is needed, you should probably
749 * handle drag and drop manually.
750 * @param reorderable <tt>true</tt>, if the tree can be reordered.
752 void set_reorderable(bool reorderable = true);
754 /** Retrieves whether the user can reorder the tree via drag-and-drop. See
756 * @return <tt>true</tt> if the tree can be reordered.
758 bool get_reorderable() const;
760 //TODO: Add set_cursor(path, ModelColumnBase&, start_editing)?
762 /** Sets the current keyboard focus to be at @a path , and selects it. This is
763 * useful when you want to focus the user's attention on a particular row. Focus is given to the column specified.
764 * Additionally, if @a start_editing is
765 * <tt>true</tt>, then editing should be started in the specified cell.
766 * This function is often followed by Gtk::Widget::grab_focus( @a tree_view )
767 * in order to give keyboard focus to the widget. Please note that editing
768 * can only happen when the widget is realized.
769 * @param path A Gtk::TreePath.
770 * @param focus_column A Gtk::TreeViewColumn.
771 * @param start_editing <tt>true</tt> if the specified cell should start being edited.
773 void set_cursor(const TreeModel::Path& path, TreeViewColumn& focus_column, bool start_editing = false);
776 /** Sets the current keyboard focus to be at @a path , and selects it. This is
777 * useful when you want to focus the user's attention on a particular row. If
778 * @a focus_column is not <tt>0</tt>, then focus is given to the column specified by
779 * it. If @a focus_column and @a focus_cell are not <tt>0</tt>, and @a focus_column
780 * contains 2 or more editable or activatable cells, then focus is given to
781 * the cell specified by @a focus_cell . Additionally, if @a focus_column is
782 * specified, and @a start_editing is <tt>true</tt>, then editing should be started in
783 * the specified cell. This function is often followed by
784 * @a gtk_widget_grab_focus ( @a tree_view ) in order to give keyboard focus to the
785 * widget. Please note that editing can only happen when the widget is
789 * @param path A Gtk::TreePath.
790 * @param focus_column A Gtk::TreeViewColumn, or <tt>0</tt>.
791 * @param focus_cell A Gtk::CellRenderer, or <tt>0</tt>.
792 * @param start_editing <tt>true</tt> if the specified cell should start being edited.
794 void set_cursor(const TreeModel::Path& path, TreeViewColumn& focus_column, CellRenderer& focus_cell, bool start_editing = false);
797 /** Sets the current keyboard focus to be at path , and selects it.
798 * This is useful when you want to focus the user's attention on a particular row.
799 * This function is often followed by Gtk::widget::grab_focus(tree_view)
800 * in order to give keyboard focus to the widget.
802 * @param path A reference to cursor path.
804 void set_cursor(const TreeModel::Path& path);
806 /** Fills in path and focus_column with the current path and focus column.
808 * @param path A reference to be filled with the current cursor path
809 * @param focus_column A reference to be filled with the current focus column
811 void get_cursor(TreeModel::Path& path, TreeViewColumn*& focus_column);
813 /* Layout information */
815 /** Returns the window that @a tree_view renders to. This is used primarily to
816 * compare to <tt>event->window</tt> to confirm that the event on
817 * @a tree_view is on the right window.
818 * @return A Gdk::Window, or <tt>0</tt> when @a tree_view hasn't been realized yet.
820 Glib::RefPtr<Gdk::Window> get_bin_window();
822 /** Returns the window that @a tree_view renders to. This is used primarily to
823 * compare to <tt>event->window</tt> to confirm that the event on
824 * @a tree_view is on the right window.
825 * @return A Gdk::Window, or <tt>0</tt> when @a tree_view hasn't been realized yet.
827 Glib::RefPtr<const Gdk::Window> get_bin_window() const;
829 /** Finds the path at the point (x, y), relative to widget
830 * coordinates. It is primarily for things like popup menus.
832 * @param x The x position to be identified
833 * @param y The y position to be identified
834 * @param path A reference to a TreeModel::Path to be filled in
835 * @param column A reference to a TreeViewColumn pointer to be filled in
836 * @param cell_x A reference where the X coordinate relative to the cell
838 * @param cell_y A reference where the Y coordinate relative to the cell
840 * @return true if a row exists at that coordinate.
842 bool get_path_at_pos(int x, int y, TreeModel::Path& path, TreeViewColumn*& column, int& cell_x, int& cell_y);
844 /** Fills the bounding rectangle in tree window coordinates for the cell at the
845 * row specified by @a path and the column specified by @a column . If @a path points to a path not currently displayed, the @a y and @a height fields
846 * of the rectangle will be filled with 0. The sum of all cell rects does not cover the
847 * entire tree; there are extra pixels in between rows, for example. The
848 * returned rectangle is equivalent to the @a cell_area passed to
849 * Gtk::CellRenderer::render(). This function is only valid if #tree_view is
851 * @param path A Gtk::TreePath for the row.
852 * @param column A Gtk::TreeViewColumn for the column.
853 * @param rect Rectangle to fill with cell rect.
855 void get_cell_area(const TreeModel::Path& path, TreeViewColumn& column, Gdk::Rectangle& rect);
856 //We ignore the fact that one of the arguments can be 0 - it does not seem useful.
859 /** Fills the bounding rectangle in tree window coordinates for the cell at the
860 * row specified by @a path and the column specified by @a column . The returned rectangle is equivalent to the
861 * @a background_area passed to Gtk::CellRenderer::render(). These background
862 * areas tile to cover the entire tree window (except for the area used for
863 * header buttons). Contrast with the @a cell_area , returned by
864 * get_cell_area(), which returns only the cell itself, excluding
865 * surrounding borders and the tree expander area.
866 * @param path A Gtk::TreePath for the row.
867 * @param column A Gtk::TreeViewColumn for the column.
868 * @param rect Rectangle to fill with cell background rect.
870 void get_background_area(const TreeModel::Path& path, TreeViewColumn& column, Gdk::Rectangle& rect);
871 //We ignore the fact that one of the arguments can be 0 - it does not seem useful.
874 /** Fills @a visible_rect with the currently-visible region of the
875 * buffer, in tree coordinates. Convert to widget coordinates with
876 * tree_to_widget_coords(). Tree coordinates start at
877 * 0,0 for row 0 of the tree, and cover the entire scrollable area of
879 * @param visible_rect Rectangle to fill.
881 void get_visible_rect(Gdk::Rectangle& visible_rect);
883 /** Converts widget coordinates to coordinates for the
884 * tree window (the full scrollable area of the tree).
885 * @param wx Widget X coordinate.
886 * @param wy Widget Y coordinate.
887 * @param tx Return location for tree X coordinate.
888 * @param ty Return location for tree Y coordinate.
890 void widget_to_tree_coords(int wx, int wy, int& tx, int& ty);
892 /** Converts tree coordinates (coordinates in full scrollable area of the tree)
893 * to widget coordinates.
894 * @param tx Tree X coordinate.
895 * @param ty Tree Y coordinate.
896 * @param wx Return location for widget X coordinate.
897 * @param wy Return location for widget Y coordinate.
899 void tree_to_widget_coords(int tx, int ty, int& wx, int& wy);
901 /* Drag-and-Drop support */
905 * Turns the TreeView into a drag source for automatic DND.
907 * @param targets Standard container of targets that the drag will support.
908 * @param start_button_mask Mask of allowed buttons to start drag.
909 * @param actions The bitmask of possible actions for a drag from this widget.
911 void enable_model_drag_source(const ArrayHandle_TargetEntry& targets,
912 Gdk::ModifierType start_button_mask = Gdk::MODIFIER_MASK,
913 Gdk::DragAction actions = Gdk::ACTION_COPY | Gdk::ACTION_MOVE);
915 // Uses the default "GTK_TREE_MODEL_ROW" target, which the TreeView can handle automatically.
917 /** Turns the TreeView into a drag source for automatic DND.
919 * @param start_button_mask Mask of allowed buttons to start drag.
920 * @param actions The bitmask of possible actions for a drag from this widget.
922 void enable_model_drag_source(Gdk::ModifierType start_button_mask = Gdk::MODIFIER_MASK,
923 Gdk::DragAction actions = Gdk::ACTION_COPY | Gdk::ACTION_MOVE);
926 /** Turns the TreeViewinto a drop destination for automatic DND.
928 * @param targets The table of targets that the drag will support.
929 * @param actions The bitmask of possible actions for a drag from this widget.
931 void enable_model_drag_dest(const ArrayHandle_TargetEntry& targets, Gdk::DragAction actions = Gdk::ACTION_COPY | Gdk::ACTION_MOVE);
933 /** Turns the TreeView into a drop destination for automatic DND. This uses the default
934 * "GTK_TREE_MODEL_ROW" target, which the TreeView can handle automatically.
936 * @param actions The bitmask of possible actions for a drag from this widget.
938 void enable_model_drag_dest(Gdk::DragAction actions = Gdk::ACTION_COPY | Gdk::ACTION_MOVE);
940 /** Undoes the effect of enable_model_drag_source()
943 /** Undoes the effect of enable_model_drag_source().
945 void unset_rows_drag_source();
947 /** Undoes the effect of enable_model_drag_source()
950 /** Undoes the effect of enable_model_drag_dest().
952 void unset_rows_drag_dest();
955 /* These are useful to implement your own custom stuff. */
957 /** Sets the row that is highlighted for feedback.
959 * @param path The path of the row to highlight
960 * @param pos Specifies whether to drop before, after or into the row
963 /** Sets the row that is highlighted for feedback.
964 * @param path The path of the row to highlight, or <tt>0</tt>.
965 * @param pos Specifies whether to drop before, after or into the row.
967 void set_drag_dest_row(const TreeModel::Path& path, TreeViewDropPosition pos);
969 /** Gets information about the row that is highlighted for feedback.
971 * @param path Return location for the path of the highlighted row
972 * @param pos Return location for the drop position
974 void get_drag_dest_row(TreeModel::Path& path, TreeViewDropPosition& pos) const;
976 /** Determines the destination row for a given position.
978 * @param drag_x The x position to determine the destination row for
979 * @param drag_y The y position to determine the destination row for
980 * @param path Return location for the path of the highlighted row
981 * @param pos Return location for the drop position
983 bool get_dest_row_at_pos(int drag_x, int drag_y, TreeModel::Path& path, TreeViewDropPosition& pos) const;
986 /** Creates a Gdk::Pixmap representation of the row at @a path . This image is used
988 * @param path A Gtk::TreePath in @a tree_view .
989 * @return A newly-allocated pixmap of the drag icon.
991 Glib::RefPtr<Gdk::Pixmap> create_row_drag_icon(const TreeModel::Path& path);
993 /* Interactive search */
995 /** If @a enable_search is set, then the user can type in text to search through
996 * the tree interactively.
997 * @param enable_search <tt>true</tt>, if the user can search interactively.
999 void set_enable_search(bool enable_search = true);
1001 /** Returns whether or not the tree allows interactive searching.
1002 * @return Whether or not to let the user search interactively.
1004 bool get_enable_search() const;
1006 /** Gets the column searched on by the interactive search code.
1007 * @return The column the interactive search code searches in.
1009 int get_search_column() const;
1011 /** Sets @a column as the column where the interactive search code should
1012 * search in. Additionally, turns on interactive searching. Note that
1013 * @a column refers to a column of the model.
1014 * @param column The column of the model to search in.
1016 void set_search_column(const TreeModelColumnBase& column);
1018 /** Sets @a column as the column where the interactive search code should
1019 * search in. Additionally, turns on interactive searching. Note that
1020 * @a column refers to a column of the model.
1021 * @param column The column of the model to search in.
1023 void set_search_column(int column);
1025 ///void on_search_equal(const Glib::RefPtr<TreeModel>& model, int column, const Glib::ustring& key, const TreeModel::iterator& iter)
1026 typedef sigc::slot<bool, const Glib::RefPtr<TreeModel>&, int, const Glib::ustring&, const TreeModel::iterator&> SlotSearchEqual;
1027 //SlotSearchEqual get_search_equal_func();
1030 /** Sets the compare function for the interactive search capabilities.
1032 * @param slot The compare function to use during the search
1034 void set_search_equal_func(const SlotSearchEqual& slot);
1037 /** Enables or disables the fixed height mode of @a tree_view .
1038 * Fixed height mode speeds up Gtk::TreeView by assuming that all
1039 * rows have the same height.
1040 * Only enable this option if all rows are the same height and all
1041 * columns are of type Gtk::TREE_VIEW_COLUMN_FIXED.
1044 * @param enable <tt>true</tt> to enable fixed height mode.
1046 void set_fixed_height_mode(bool enable = true);
1048 /** Returns whether fixed height mode is turned on for @a tree_view .
1049 * @return <tt>true</tt> if @a tree_view is in fixed height mode
1053 bool get_fixed_height_mode() const;
1055 /** Enables of disables the hover selection mode of @a tree_view .
1056 * Hover selection makes the selected row follow the pointer.
1057 * Currently, this works only for the selection modes
1058 * Gtk::SELECTION_SINGLE and Gtk::SELECTION_BROWSE.
1061 * @param hover <tt>true</tt> to enable hover selection mode.
1063 void set_hover_selection(bool hover = true);
1065 /** Returns whether hover selection mode is turned on for @a tree_view .
1066 * @return <tt>true</tt> if @a tree_view is in hover selection mode
1070 bool get_hover_selection() const;
1072 /** Enables of disables the hover expansion mode of @a tree_view .
1073 * Hover expansion makes rows expand or collaps if the pointer
1077 * @param expand <tt>true</tt> to enable hover selection mode.
1079 void set_hover_expand(bool expand = true);
1081 /** Returns whether hover expansion mode is turned on for @a tree_view .
1082 * @return <tt>true</tt> if @a tree_view is in hover expansion mode
1086 bool get_hover_expand() const;
1089 * void on_row_separator(const Gtk::TreeModel& model, const Gtk::TreeModel::iterator& iter);
1091 typedef sigc::slot<bool, const Glib::RefPtr<TreeModel>&, const TreeModel::iterator&> SlotRowSeparator;
1093 void set_row_separator_func(const SlotRowSeparator& slot);
1096 Glib::SignalProxy2< void,Adjustment*,Adjustment* > signal_set_scroll_adjustments();
1099 Glib::SignalProxy2< void,const TreeModel::Path&,TreeViewColumn* > signal_row_activated();
1102 Glib::SignalProxy2< bool,const TreeModel::iterator&,const TreeModel::Path& > signal_test_expand_row();
1105 Glib::SignalProxy2< bool,const TreeModel::iterator&,const TreeModel::Path& > signal_test_collapse_row();
1108 Glib::SignalProxy2< void,const TreeModel::iterator&,const TreeModel::Path& > signal_row_expanded();
1111 Glib::SignalProxy2< void,const TreeModel::iterator&,const TreeModel::Path& > signal_row_collapsed();
1114 Glib::SignalProxy0< void > signal_cursor_changed();
1117 Glib::SignalProxy0< void > signal_columns_changed();
1120 //Don't wrap these. They are keybinding signals, and their API broke for GTK+ 2.2.
1123 /** The model for the tree view.
1125 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1126 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1127 * the value of the property changes.
1129 Glib::PropertyProxy< Glib::RefPtr<TreeModel> > property_model() ;
1131 /** The model for the tree view.
1133 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1134 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1135 * the value of the property changes.
1137 Glib::PropertyProxy_ReadOnly< Glib::RefPtr<TreeModel> > property_model() const;
1139 /** Horizontal Adjustment for the widget.
1141 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1142 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1143 * the value of the property changes.
1145 Glib::PropertyProxy<Adjustment*> property_hadjustment() ;
1147 /** Horizontal Adjustment for the widget.
1149 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1150 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1151 * the value of the property changes.
1153 Glib::PropertyProxy_ReadOnly<Adjustment*> property_hadjustment() const;
1155 /** Vertical Adjustment for the widget.
1157 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1158 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1159 * the value of the property changes.
1161 Glib::PropertyProxy<Adjustment*> property_vadjustment() ;
1163 /** Vertical Adjustment for the widget.
1165 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1166 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1167 * the value of the property changes.
1169 Glib::PropertyProxy_ReadOnly<Adjustment*> property_vadjustment() const;
1171 /** Show the column header buttons.
1173 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1174 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1175 * the value of the property changes.
1177 Glib::PropertyProxy<bool> property_headers_visible() ;
1179 /** Show the column header buttons.
1181 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1182 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1183 * the value of the property changes.
1185 Glib::PropertyProxy_ReadOnly<bool> property_headers_visible() const;
1187 /** Column headers respond to click events.
1189 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1190 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1191 * the value of the property changes.
1193 Glib::PropertyProxy<bool> property_headers_clickable() ;
1195 /** Column headers respond to click events.
1197 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1198 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1199 * the value of the property changes.
1201 Glib::PropertyProxy_ReadOnly<bool> property_headers_clickable() const;
1203 /** Set the column for the expander column.
1205 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1206 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1207 * the value of the property changes.
1209 Glib::PropertyProxy<TreeViewColumn*> property_expander_column() ;
1211 /** Set the column for the expander column.
1213 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1214 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1215 * the value of the property changes.
1217 Glib::PropertyProxy_ReadOnly<TreeViewColumn*> property_expander_column() const;
1219 /** View is reorderable.
1221 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1222 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1223 * the value of the property changes.
1225 Glib::PropertyProxy<bool> property_reorderable() ;
1227 /** View is reorderable.
1229 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1230 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1231 * the value of the property changes.
1233 Glib::PropertyProxy_ReadOnly<bool> property_reorderable() const;
1235 /** Set a hint to the theme engine to draw rows in alternating colors.
1237 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1238 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1239 * the value of the property changes.
1241 Glib::PropertyProxy<bool> property_rules_hint() ;
1243 /** Set a hint to the theme engine to draw rows in alternating colors.
1245 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1246 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1247 * the value of the property changes.
1249 Glib::PropertyProxy_ReadOnly<bool> property_rules_hint() const;
1251 /** View allows user to search through columns interactively.
1253 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1254 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1255 * the value of the property changes.
1257 Glib::PropertyProxy<bool> property_enable_search() ;
1259 /** View allows user to search through columns interactively.
1261 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1262 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1263 * the value of the property changes.
1265 Glib::PropertyProxy_ReadOnly<bool> property_enable_search() const;
1267 /** Model column to search through when searching through code.
1269 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1270 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1271 * the value of the property changes.
1273 Glib::PropertyProxy<int> property_search_column() ;
1275 /** Model column to search through when searching through code.
1277 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1278 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1279 * the value of the property changes.
1281 Glib::PropertyProxy_ReadOnly<int> property_search_column() const;
1283 /** Speeds up GtkTreeView by assuming that all rows have the same height.
1285 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1286 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1287 * the value of the property changes.
1289 Glib::PropertyProxy<bool> property_fixed_height_mode() ;
1291 /** Speeds up GtkTreeView by assuming that all rows have the same height.
1293 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1294 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1295 * the value of the property changes.
1297 Glib::PropertyProxy_ReadOnly<bool> property_fixed_height_mode() const;
1299 /** Whether the selection should follow the pointer.
1301 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1302 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1303 * the value of the property changes.
1305 Glib::PropertyProxy<bool> property_hover_selection() ;
1307 /** Whether the selection should follow the pointer.
1309 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1310 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1311 * the value of the property changes.
1313 Glib::PropertyProxy_ReadOnly<bool> property_hover_selection() const;
1315 /** Whether rows should be expanded/collapsed when the pointer moves over them.
1317 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1318 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1319 * the value of the property changes.
1321 Glib::PropertyProxy<bool> property_hover_expand() ;
1323 /** Whether rows should be expanded/collapsed when the pointer moves over them.
1325 * You rarely need to use properties because there are get_ and set_ methods for almost all of them.
1326 * @return A PropertyProxy that allows you to get or set the property of the value, or receive notification when
1327 * the value of the property changes.
1329 Glib::PropertyProxy_ReadOnly<bool> property_hover_expand() const;
1332 /// Get the treeview's model, but actually get the child model if it's a TreeModelFilter.
1333 Glib::RefPtr<Gtk::TreeModel> _get_base_model();
1337 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1338 template<class ColumnType> friend
1339 void _auto_store_on_cellrenderer_text_edited_string(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, Gtk::TreeView*);
1341 template <class ColumnType> friend
1342 void _auto_store_on_cellrenderer_text_edited_numerical(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, Gtk::TreeView*);
1344 void _auto_store_on_cellrenderer_toggle_edited(const Glib::ustring& path_string, int model_column);
1346 template<class ColumnType> friend
1347 void TreeView_Private::_connect_auto_store_editable_signal_handler(TreeView*, CellRenderer*, const TreeModelColumn<ColumnType>&);
1349 #endif //DOXYGEN_SHOULD_SKIP_THIS
1355 template <class ColumnType> inline
1356 int TreeView::append_column(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column)
1358 // compilation will fail if there is no appropriate TreeViewColumn
1359 // constructor for this model column type.
1360 TreeViewColumn *const pViewColumn = Gtk::manage( new TreeViewColumn(title, model_column) );
1362 return append_column(*pViewColumn);
1365 //This is here because sigc::bind once did not work on all platforms, but now it does..
1366 #define GTKMM_HAVE_SIGC_BIND 1
1368 #ifdef GTKMM_HAVE_SIGC_BIND
1370 template <class ColumnType> inline
1371 int TreeView::append_column_numeric(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, const Glib::ustring& format)
1373 TreeViewColumn* const pViewColumn = Gtk::manage( new TreeViewColumn(title) );
1375 //Use a CellRendererText:
1376 //We don't use TreeView::Column::append_column(model_column) to generate an appropriate CellRenderer,
1377 //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.
1378 CellRenderer* pCellRenderer = manage( new CellRendererText() );
1379 pViewColumn->pack_start(*pCellRenderer);
1382 //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1383 typedef void (*type_fptr)(Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter, int model_column, const Glib::ustring& format);
1384 type_fptr fptr = TreeView_Private::_auto_cell_data_func<ColumnType>;
1386 //Connect a cell_data callback, to show the number's text representation in the specified format:
1387 //We use sigc::bind<-1> twice here, instead of sigc::bind() once, because some compilers need the extra hint.
1388 Gtk::TreeViewColumn::SlotCellData slot = sigc::bind<-1>(
1389 sigc::bind<-1>( sigc::ptr_fun(fptr), format),
1390 model_column.index()
1393 pViewColumn->set_cell_data_func(*pCellRenderer, slot);
1395 return append_column(*pViewColumn);
1398 #endif //GTKMM_HAVE_SIGC_BIND
1400 template <class ColumnType> inline
1401 int TreeView::append_column_numeric_editable(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, const Glib::ustring& format)
1403 int cols_count = append_column_numeric(title, model_column, format);
1405 //connect signal handlers for auto-storing of edited cell data
1406 //Note: This will only work for base-10 (decimal) formatted numbers:
1407 CellRenderer *const cell = get_column_cell_renderer(cols_count - 1);
1410 TreeView_Private::_connect_auto_store_editable_signal_handler<ColumnType>(this, cell, model_column);
1416 template <class ColumnType> inline
1417 int TreeView::append_column_editable(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column)
1419 g_assert(model_column.type() != 0);
1421 // compilation will fail if there is no appropriate TreeViewColumn
1422 // constructor for this model column type.
1423 TreeViewColumn *const pViewColumn = Gtk::manage( new TreeViewColumn(title, model_column) );
1425 //connect signal handlers for auto-storing of edited cell data
1426 CellRenderer* pCellRender = pViewColumn->get_first_cell_renderer();
1427 TreeView_Private::_connect_auto_store_editable_signal_handler<ColumnType>(this, pCellRender, model_column);
1429 return append_column(*pViewColumn);
1432 template <class ColumnType> inline
1433 int TreeView::insert_column(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, int position)
1435 // compilation will fail if there is no appropriate TreeViewColumn
1436 // constructor for this model column type.
1437 TreeViewColumn *const pViewColumn = Gtk::manage( new TreeViewColumn(title, model_column) );
1439 return insert_column(*pViewColumn, position);
1442 template <class ColumnType> inline
1443 int TreeView::insert_column_editable(const Glib::ustring& title, const TreeModelColumn<ColumnType>& model_column, int position)
1445 // compilation will fail if there is no appropriate TreeViewColumn
1446 // constructor for this model column type.
1447 TreeViewColumn *const pViewColumn = Gtk::manage( new TreeViewColumn(title, model_column) );
1449 //connect signal handlers for auto-storing of edited cell data
1450 CellRenderer* pCellRender = pViewColumn->get_first_cell_renderer();
1451 TreeView_Private::_connect_auto_store_editable_signal_handler(this, pCellRender, model_column);
1453 return insert_column(*pViewColumn, position);
1457 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1458 namespace TreeView_Private
1461 //Template specializations, for different model column types:
1462 //TODO: Move these specializations into the .ccg file - I tried, but the int specialization was not used by the compiler. murrayc.
1464 #ifdef GTKMM_HAVE_SIGC_BIND
1466 //bool specialization:
1468 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer, const Gtk::TreeModelColumn<bool>& model_column)
1470 Gtk::CellRendererToggle* pCellToggle = dynamic_cast<Gtk::CellRendererToggle*>(pCellRenderer);
1473 //Set the appropriate property,
1474 pCellToggle->property_activatable() = true;
1476 //Connect to the appropriate signal, sending the model_column too,
1477 pCellToggle->signal_toggled().connect(
1478 sigc::bind<-1>( sigc::mem_fun(*this_p, &Gtk::TreeView::_auto_store_on_cellrenderer_toggle_edited), model_column.index()) );
1479 //We use bind<1> instead of bind because some compilers need the extra hint.
1483 //int specialization:
1485 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer, const Gtk::TreeModelColumn<int>& model_column)
1487 Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
1490 //Set the appropriate property,
1491 pCellText->property_editable() = true;
1493 //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1494 typedef void (*type_fptr)(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, Gtk::TreeView* this_p);
1495 type_fptr fptr = _auto_store_on_cellrenderer_text_edited_numerical<int>;
1497 //Connect to the appropriate signal, sending the model_column too,
1498 //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1499 pCellText->signal_edited().connect(
1501 sigc::bind<-1>( sigc::ptr_fun(fptr), this_p),
1502 model_column.index()
1509 //unsigned int specialization:
1511 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer, const Gtk::TreeModelColumn<unsigned int>& model_column)
1513 Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
1516 //Set the appropriate property,
1517 pCellText->property_editable() = true;
1519 //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1520 typedef void (*type_fptr)(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, Gtk::TreeView* this_p);
1521 type_fptr fptr = _auto_store_on_cellrenderer_text_edited_numerical<unsigned int>;
1523 //Connect to the appropriate signal, sending the model_column too,
1524 //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1525 pCellText->signal_edited().connect(
1527 sigc::bind<-1>( sigc::ptr_fun(fptr), this_p),
1528 model_column.index()
1535 //long specialization:
1537 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer, const Gtk::TreeModelColumn<long>& model_column)
1539 Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
1542 //Set the appropriate property,
1543 pCellText->property_editable() = true;
1545 //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1546 typedef void (*type_fptr)(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, Gtk::TreeView* this_p);
1547 type_fptr fptr = _auto_store_on_cellrenderer_text_edited_numerical<long>;
1549 //Connect to the appropriate signal, sending the model_column too,
1550 //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1551 pCellText->signal_edited().connect(
1553 sigc::bind<-1>( sigc::ptr_fun(fptr), this_p),
1554 model_column.index()
1561 //unsigned long specialization:
1563 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer, const Gtk::TreeModelColumn<unsigned long>& model_column)
1565 Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
1568 //Set the appropriate property,
1569 pCellText->property_editable() = true;
1571 //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1572 typedef void (*type_fptr)(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, Gtk::TreeView* this_p);
1573 type_fptr fptr = _auto_store_on_cellrenderer_text_edited_numerical<unsigned long>;
1575 //Connect to the appropriate signal, sending the model_column too,
1576 //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1577 pCellText->signal_edited().connect(
1579 sigc::bind<-1>( sigc::ptr_fun(fptr), this_p),
1580 model_column.index()
1587 //float specialization:
1589 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer, const Gtk::TreeModelColumn<float>& model_column)
1591 Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
1594 //Set the appropriate property,
1595 pCellText->property_editable() = true;
1597 //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1598 typedef void (*type_fptr)(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, Gtk::TreeView* this_p);
1599 type_fptr fptr = _auto_store_on_cellrenderer_text_edited_numerical<float>;
1601 //Connect to the appropriate signal, sending the model_column too,
1602 //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1603 pCellText->signal_edited().connect(
1605 sigc::bind<-1>( sigc::ptr_fun(fptr), this_p),
1606 model_column.index()
1612 //double specialization:
1614 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer, const Gtk::TreeModelColumn<double>& model_column)
1616 Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
1619 //Set the appropriate property,
1620 pCellText->property_editable() = true;
1622 //Some compilers don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1623 typedef void (*type_fptr)(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, Gtk::TreeView* this_p);
1624 type_fptr fptr = _auto_store_on_cellrenderer_text_edited_numerical<double>;
1626 //Connect to the appropriate signal, sending the model_column too,
1627 //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1628 pCellText->signal_edited().connect(
1630 sigc::bind<-1>( sigc::ptr_fun(fptr), this_p),
1631 model_column.index()
1637 #endif //GTKMM_HAVE_SIGC_BIND
1639 } // namespace TreeView_Private
1640 #endif //DOXYGEN_SHOULD_SKIP_THIS
1643 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1644 namespace TreeView_Private
1647 #ifdef GTKMM_HAVE_SIGC_BIND
1649 template <class ColumnType> inline
1650 void _connect_auto_store_editable_signal_handler(Gtk::TreeView* this_p, Gtk::CellRenderer* pCellRenderer, const Gtk::TreeModelColumn<ColumnType>& model_column)
1652 g_assert(model_column.type() != 0);
1654 //The different CellRenderers have different "edited" signals,
1655 //and numerical values need to convert the text value to a number,
1656 //so there are specializations for this tempate.
1658 Gtk::CellRendererText* pCellText = dynamic_cast<Gtk::CellRendererText*>(pCellRenderer);
1660 //Set the appropriate property,
1661 //and connect to the appropriate signal, sending the model_column too,
1664 pCellText->property_editable() = true;
1666 //Some compilers (IRIX MipsPro) don't like us to give the pointer to a template function directly to sigc::ptr_fun():
1667 typedef void (*type_func)(const Glib::ustring&, const Glib::ustring&, int, Gtk::TreeView*);
1668 type_func func = &(_auto_store_on_cellrenderer_text_edited_string<ColumnType>);
1669 sigc::slot<void, const Glib::ustring&, const Glib::ustring&, int, Gtk::TreeView*> theslot =
1670 sigc::ptr_fun(func);
1672 //We use bind<-1> twice here, instead of using bind() once, because some compilers need the extra hint.
1673 pCellText->signal_edited().connect(
1675 sigc::bind<-1>( theslot, this_p),
1676 model_column.index()
1684 #endif //GTKMM_HAVE_SIGC_BIND
1686 template <class ColumnType> inline
1687 void _auto_store_on_cellrenderer_text_edited_string(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, Gtk::TreeView* this_p)
1689 Gtk::TreePath path(path_string);
1691 //Get the row from the path:
1692 Glib::RefPtr<TreeModel> refModel = this_p->_get_base_model();
1693 Gtk::TreeModel::iterator iter = refModel->get_iter(path);
1696 //Store the user's new text in the model:
1697 Gtk::TreeRow row = *iter;
1698 row.set_value(model_column, (ColumnType)new_text);
1702 template <class ColumnType> inline
1703 void _auto_store_on_cellrenderer_text_edited_numerical(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column, Gtk::TreeView* this_p)
1705 //This is used on numerical model columns:
1707 Gtk::TreePath path(path_string);
1709 //Get the row from the path:
1710 Glib::RefPtr<TreeModel> refModel = this_p->_get_base_model();
1711 Gtk::TreeModel::iterator iter = refModel->get_iter(path);
1714 //std::istringstream astream(new_text); //Put it in a stream.
1715 //ColumnType new_value = ColumnType();
1716 //new_value << astream; //Get it out of the stream as the numerical type.
1718 //Convert the text to a number, using the same logic used by GtkCellRendererText when it stores numbers.
1720 ColumnType new_value = static_cast<ColumnType>( strtod(new_text.c_str(), &pchEnd) );
1722 //Store the user's new text in the model:
1723 Gtk::TreeRow row = *iter;
1724 row.set_value(model_column, (ColumnType)new_value);
1728 template <class ColumnType> inline
1729 void _auto_cell_data_func(Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter, int model_column, const Glib::ustring& format)
1731 Gtk::CellRendererText* pTextRenderer = dynamic_cast<Gtk::CellRendererText*>(cell);
1734 g_warning("gtkmm: TextView: append_column_numeric() was used with a non-numeric type.");
1740 //Get the value from the model.
1741 Gtk::TreeModel::Row row = *iter;
1742 ColumnType value = ColumnType();
1743 row.get_value(model_column, value);
1745 //Convert it to a string representation:
1747 int used = g_snprintf(buff, sizeof(buff), format.c_str(), value); //value must be a numeric type.
1750 //Show the text representation in the view:
1751 pTextRenderer->property_text() = buff;
1757 } // namespace TreeView_Private
1758 #endif //DOXYGEN_SHOULD_SKIP_THIS
1766 /** @relates Gtk::TreeView
1767 * @param object The C instance
1768 * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
1769 * @result A C++ instance that wraps this C instance.
1771 Gtk::TreeView* wrap(GtkTreeView* object, bool take_copy = false);
1773 #endif /* _GTKMM_TREEVIEW_H */