Reference Manual
Inti Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

treeview.h

Go to the documentation of this file.
00001 /*  Inti: Integrated Foundation Classes
00002  *  Copyright (C) 2002-2003 The Inti Development Team.
00003  *  Copyright (C) 2000 Red Hat, Inc.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU Library General Public License for more details.
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018  
00023 
00024 #ifndef INTI_GTK_TREE_VIEW_H
00025 #define INTI_GTK_TREE_VIEW_H
00026 
00027 #ifndef INTI_GTK_CONTAINER_H
00028 #include <inti/gtk/container.h>
00029 #endif
00030 
00031 #ifndef INTI_GTK_CELL_RENDERER_H
00032 #include <inti/gtk/cellrenderer.h>
00033 #endif
00034 
00035 #ifndef INTI_GTK_TREE_SELECTION_H
00036 #include <inti/gtk/treeselection.h>
00037 #endif
00038 
00039 #ifndef INTI_GTK_TREE_VIEW_COLUMN_H
00040 #include <inti/gtk/treeviewcolumn.h>
00041 #endif
00042 
00043 #ifndef __GTK_TREE_VIEW_H__
00044 #include <gtk/gtktreeview.h>
00045 #endif
00046 
00047 namespace Inti {
00048 
00049 namespace Gtk {
00050 
00051 class CellRenderer;
00052 class DragContext;
00053 class TreeIter;
00054 class TreeModel;
00055 class TreePath;
00056 class TreeViewClass;
00057 
00060 
00061 enum TreeViewDropPosition
00062 {
00063         TREE_VIEW_DROP_BEFORE = GTK_TREE_VIEW_DROP_BEFORE, 
00065         
00066         TREE_VIEW_DROP_AFTER = GTK_TREE_VIEW_DROP_AFTER, 
00068         
00069         TREE_VIEW_DROP_INTO_OR_BEFORE = GTK_TREE_VIEW_DROP_INTO_OR_BEFORE,
00071         
00072         TREE_VIEW_DROP_INTO_OR_AFTER = GTK_TREE_VIEW_DROP_INTO_OR_AFTER
00074 };
00075 
00084 
00085 class TreeView : public Container
00086 {
00087         friend class G::Object;
00088         friend class TreeViewClass;
00089 
00090         TreeView(const TreeView&);
00091         TreeView& operator=(const TreeView&);
00092 
00093 protected:
00096 
00097         explicit TreeView(GtkTreeView *tree_view, bool reference = false);
00104         
00108 
00109         virtual void on_set_scroll_adjustments(Adjustment *hadjustment, Adjustment *vadjustment);
00113 
00114         virtual void on_row_activated(const TreePath& path, TreeViewColumn& column);
00118         
00119         virtual bool on_test_expand_row(const TreeIter& iter, const TreePath& path);
00125 
00126         virtual bool on_test_collapse_row(const TreeIter& iter, const TreePath& path);
00132 
00133         virtual void on_row_expanded(const TreeIter& iter, const TreePath& path);
00137                 
00138         virtual void on_row_collapsed(const TreeIter& iter, const TreePath& path);
00142         
00143         virtual void on_columns_changed();
00145 
00146         virtual void on_cursor_changed();
00148 
00150 //  Properties
00151 
00152         typedef G::Property<TreeModel*, G::Object*> ModelPropertyType;
00153         typedef G::PropertyProxy<G::Object, ModelPropertyType> ModelPropertyProxy;
00154         static const ModelPropertyType model_property;
00155 
00156         typedef G::Property<Adjustment*, G::Object*> HAdjustmentPropertyType;
00157         typedef G::PropertyProxy<G::Object, HAdjustmentPropertyType> HAdjustmentPropertyProxy;
00158         static const HAdjustmentPropertyType hadjustment_property;
00159 
00160         typedef G::Property<Adjustment*, G::Object*> VAdjustmentPropertyType;
00161         typedef G::PropertyProxy<G::Object, VAdjustmentPropertyType> VAdjustmentPropertyProxy;
00162         static const VAdjustmentPropertyType vadjustment_property;
00163 
00164         typedef G::Property<bool> HeadersVisiblePropertyType;
00165         typedef G::PropertyProxy<G::Object, HeadersVisiblePropertyType> HeadersVisiblePropertyProxy;
00166         static const HeadersVisiblePropertyType headers_visible_property;
00167 
00168         typedef G::WritableProperty<bool> HeadersClickablePropertyType;
00169         typedef G::PropertyProxy<G::Object, HeadersClickablePropertyType> HeadersClickablePropertyProxy;
00170         static const HeadersClickablePropertyType headers_clickable_property;
00171 
00172         typedef G::Property<TreeViewColumn*, G::Object*> ExpanderColumnPropertyType;
00173         typedef G::PropertyProxy<G::Object, ExpanderColumnPropertyType> ExpanderColumnPropertyProxy;
00174         static const ExpanderColumnPropertyType expander_column_property;
00175 
00176         typedef G::Property<bool> ReorderablePropertyType;
00177         typedef G::PropertyProxy<G::Object, ReorderablePropertyType> ReorderablePropertyProxy;
00178         static const ReorderablePropertyType reorderable_property;
00179 
00180         typedef G::Property<bool> RulesHintPropertyType;
00181         typedef G::PropertyProxy<G::Object, RulesHintPropertyType> RulesHintPropertyProxy;
00182         static const RulesHintPropertyType rules_hint_property;
00183 
00184         typedef G::Property<bool> EnableSearchPropertyType;
00185         typedef G::PropertyProxy<G::Object, EnableSearchPropertyType> EnableSearchPropertyProxy;
00186         static const EnableSearchPropertyType enable_search_property;
00187 
00188         typedef G::Property<int> SearchColumnPropertyType;
00189         typedef G::PropertyProxy<G::Object, SearchColumnPropertyType> SearchColumnPropertyProxy;
00190         static const SearchColumnPropertyType search_column_property;
00191 
00192 //  Signals
00193 
00194         typedef G::Signal2<void, GtkAdjustment*, GtkAdjustment*> SetScrollAdjustmentsSignalType;
00195         typedef G::SignalProxy<TypeInstance, SetScrollAdjustmentsSignalType> SetScrollAdjustmentsSignalProxy;
00196         static const SetScrollAdjustmentsSignalType set_scroll_adjustments_signal;
00197 
00198         typedef G::Signal2<void, GtkTreePath*, GtkTreeViewColumn*> RowActivatedSignalType;
00199         typedef G::SignalProxy<TypeInstance, RowActivatedSignalType> RowActivatedSignalProxy;
00200         static const RowActivatedSignalType row_activated_signal;
00201 
00202         typedef G::Signal2<bool, GtkTreeIter*, GtkTreePath*> TestExpandRowSignalType;
00203         typedef G::SignalProxy<TypeInstance, TestExpandRowSignalType> TestExpandRowSignalProxy;
00204         static const TestExpandRowSignalType test_expand_row_signal;
00205 
00206         typedef G::Signal2<bool, GtkTreeIter*, GtkTreePath*> TestCollapseRowSignalType;
00207         typedef G::SignalProxy<TypeInstance, TestCollapseRowSignalType> TestCollapseRowSignalProxy;
00208         static const TestCollapseRowSignalType test_collapse_row_signal;
00209 
00210         typedef G::Signal2<void, GtkTreeIter*, GtkTreePath*> RowExpandSignalType;
00211         typedef G::SignalProxy<TypeInstance, RowExpandSignalType> RowExpandSignalProxy;
00212         static const RowExpandSignalType row_expanded_signal;
00213 
00214         typedef G::Signal2<void, GtkTreeIter*, GtkTreePath*> RowCollapsedSignalType;
00215         typedef G::SignalProxy<TypeInstance, RowCollapsedSignalType> RowCollapsedSignalProxy;
00216         static const RowCollapsedSignalType row_collapsed_signal;
00217 
00218         typedef G::Signal0<void> ColumnsChangedSignalType;
00219         typedef G::SignalProxy<TypeInstance, ColumnsChangedSignalType> ColumnsChangedSignalProxy;
00220         static const ColumnsChangedSignalType columns_changed_signal;
00221 
00222         typedef G::Signal0<void> CursorChangedSignalType;
00223         typedef G::SignalProxy<TypeInstance, CursorChangedSignalType> CursorChangedSignalProxy;
00224         static const CursorChangedSignalType cursor_changed_signal;
00225 
00226 public:
00227         typedef Slot4<bool, TreeView&, TreeViewColumn&, TreeViewColumn*, TreeViewColumn*> ColumnDropSlot;
00248 
00249         typedef Slot2<void, TreeView&, const TreePath&> MappingSlot;
00258         
00259         typedef Slot4<bool, TreeModel*, int, const String&, const TreeIter&> SearchEqualSlot;
00271 
00274 
00275         TreeView();
00277 
00278         explicit TreeView(TreeModel& model);
00281 
00282         virtual ~TreeView();
00284         
00288 
00289         GtkTreeView* gtk_tree_view() const { return (GtkTreeView*)instance; }
00291         
00292         GtkTreeViewClass* gtk_tree_view_class() const;
00294 
00295         operator GtkTreeView* () const;
00297         
00298         TreeModel* get_model() const;
00301 
00302         TreeSelection* get_selection() const;
00304  
00305         Adjustment* get_hadjustment() const;
00308          
00309         Adjustment* get_vadjustment() const;
00312 
00313         bool get_headers_visible() const;
00316          
00317         TreeViewColumn* get_column(int position) const;
00321         
00322         bool get_columns(std::vector<TreeViewColumn*>& columns) const;
00326         
00327         TreeViewColumn* get_expander_column() const;
00331          
00332         bool row_expanded(const TreePath& path) const;
00336          
00337         bool get_reorderable() const;
00340                 
00341         void get_cursor(Pointer<TreePath> *path, TreeViewColumn **focus_column) const;
00348          
00349         Gdk::Window* get_bin_window() const;
00355                 
00356         bool get_path_at_pos(int x, int y, Pointer<TreePath> *path, TreeViewColumn **column, int *cell_x, int *cell_y) const;
00373 
00374         void get_cell_area(const TreePath *path, const TreeViewColumn *column, Gdk::Rectangle& rectangle) const;
00387 
00388         Gdk::Rectangle get_cell_area(const TreePath *path, const TreeViewColumn *column) const;
00401 
00402         void get_background_area(const TreePath *path, const TreeViewColumn *column, Gdk::Rectangle& rectangle) const;
00416          
00417         Gdk::Rectangle get_background_area(const TreePath *path, const TreeViewColumn *column) const;
00431 
00432         void get_visible_rect(Gdk::Rectangle& visible_rect) const;
00439          
00440         Gdk::Rectangle get_visible_rect() const;
00446 
00447         bool get_rules_hint() const;
00450         
00451         void get_drag_dest_row(Pointer<TreePath> *path, TreeViewDropPosition *pos) const;
00455         
00456         bool get_dest_row_at_pos(int drag_x, int drag_y, Pointer<TreePath> *path, TreeViewDropPosition *pos) const;
00466         
00467         bool get_enable_search() const;
00470          
00471         int get_search_column() const;
00474          
00478         
00479         void set_model(TreeModel *model);
00485          
00486         void set_hadjustment(Adjustment *adjustment);
00489          
00490         void set_vadjustment(Adjustment *adjustment);
00493 
00494         void set_headers_visible(bool headers_visible);
00497         
00498         void columns_autosize();
00500         
00501         void set_headers_clickable(bool setting);
00504         
00505         int append_column(TreeViewColumn& column);
00509         
00510         int append_column(const String& title, CellRenderer *cell, ...); 
00518 
00519         int append_column(const String& title, CellRenderer& cell, const TreeViewColumn::CellDataSlot *data);
00528 
00529         int insert_column(TreeViewColumn& column, int position);
00536          
00537         int insert_column(int position, const String& title, CellRenderer *cell, ...); 
00547 
00548         int insert_column(int position, const String& title, CellRenderer& cell, const TreeViewColumn::CellDataSlot *data);
00558          
00559         int remove_column(TreeViewColumn& column);
00563          
00564         void move_column_after(TreeViewColumn& column, TreeViewColumn *base_column);
00570         
00571         void set_expander_column(TreeViewColumn *column);
00577         
00578         void set_column_drag_function(const ColumnDropSlot *drop);
00588 
00589         void scroll_to_point(int tree_x, int tree_y);
00598          
00599         void scroll_to_cell(const TreePath *path, const TreeViewColumn *column);
00613         
00614         void scroll_to_cell(const TreePath *path, const TreeViewColumn *column, float row_align, float col_align);
00631          
00632         void row_activated(TreePath& path, TreeViewColumn& column);
00636         
00637         void expand_all();
00639         
00640         void collapse_all();
00642 
00643         void expand_to_path(const TreePath& path);
00648 
00649         bool expand_row(const TreePath& path, bool open_all);
00654          
00655         bool collapse_row(const TreePath& path);
00659          
00660         void map_expanded_rows(const MappingSlot *map);
00663         
00664         void set_reorderable(bool reorderable);
00674 
00675         void set_cursor(const TreePath& path, TreeViewColumn *focus_column, bool start_editing = false);
00687 
00688         void set_cursor_on_cell(const TreePath& path, TreeViewColumn *focus_column, CellRenderer *focus_cell, bool start_editing = false);
00704 
00705         void widget_to_tree_coords(int wx, int wy, int *tx, int *ty) const;
00712          
00713         void tree_to_widget_coords(int tx, int ty, int *wx, int *wy) const;
00720          
00721         void set_rules_hint(bool setting);
00733 
00734         void enable_model_drag_source(Gdk::ModifierTypeField start_button_mask, 
00735                                       const std::vector<TargetEntry>& targets, 
00736                                       Gdk::DragActionField actions);
00745         
00746         void enable_model_drag_dest(const std::vector<TargetEntry>& targets, Gdk::DragActionField actions);
00753          
00754         void unset_rows_drag_source();
00756          
00757         void unset_rows_drag_dest();
00760         
00761         void set_drag_dest_row(const TreePath& path, TreeViewDropPosition pos);
00765         
00766         Pointer<Gdk::Pixmap> create_row_drag_icon(const TreePath& path);
00770         
00771         void set_enable_search(bool enable_search);
00774         
00775         void set_search_column(int column);
00781 
00782         void set_search_equal_func(const SearchEqualSlot *search_equal);
00785 
00789         
00790         const ModelPropertyProxy prop_model()
00791         {
00792                 return ModelPropertyProxy(this, &model_property);
00793         }
00795 
00796         const HAdjustmentPropertyProxy prop_hadjustment()
00797         {
00798                 return HAdjustmentPropertyProxy(this, &hadjustment_property);
00799         }
00801 
00802         const VAdjustmentPropertyProxy prop_vadjustment()
00803         {
00804                 return VAdjustmentPropertyProxy(this, &vadjustment_property);
00805         }
00807 
00808         const HeadersVisiblePropertyProxy prop_headers_visible()
00809         {
00810                 return HeadersVisiblePropertyProxy(this, &headers_visible_property);
00811         }
00813 
00814         const HeadersClickablePropertyProxy prop_headers_clickable()
00815         {
00816                 return HeadersClickablePropertyProxy(this, &headers_clickable_property);
00817         }
00819 
00820         const ExpanderColumnPropertyProxy prop_expander_column()
00821         {
00822                 return ExpanderColumnPropertyProxy(this, &expander_column_property);
00823         }
00825 
00826         const ReorderablePropertyProxy prop_reorderable()
00827         {
00828                 return ReorderablePropertyProxy(this, &reorderable_property);
00829         }
00831 
00832         const RulesHintPropertyProxy prop_rules_hint()
00833         {
00834                 return RulesHintPropertyProxy(this, &rules_hint_property);
00835         }
00837 
00838         const EnableSearchPropertyProxy prop_enable_search()
00839         {
00840                 return EnableSearchPropertyProxy(this, &enable_search_property);
00841         }
00843 
00844         const SearchColumnPropertyProxy prop_search_column()
00845         {
00846                 return SearchColumnPropertyProxy(this, &search_column_property);
00847         }
00849 
00853         
00854         const SetScrollAdjustmentsSignalProxy sig_set_scroll_adjustments()
00855         {
00856                 return SetScrollAdjustmentsSignalProxy(this, &set_scroll_adjustments_signal);
00857         }
00860 
00861         const RowActivatedSignalProxy sig_row_activated()
00862         {
00863                 return RowActivatedSignalProxy(this, &row_activated_signal);
00864         }
00866 
00867         const TestExpandRowSignalProxy sig_test_expand_row()
00868         {
00869                 return TestExpandRowSignalProxy(this, &test_expand_row_signal);
00870         }
00873 
00874         const TestCollapseRowSignalProxy sig_test_collapse_row()
00875         {
00876                 return TestCollapseRowSignalProxy(this, &test_collapse_row_signal);
00877         }
00880 
00881         const RowExpandSignalProxy sig_row_expanded()
00882         {
00883                 return RowExpandSignalProxy(this, &row_expanded_signal);
00884         }
00886 
00887         const RowCollapsedSignalProxy sig_row_collapsed()
00888         {
00889                 return RowCollapsedSignalProxy(this, &row_collapsed_signal);
00890         }
00892 
00893         const ColumnsChangedSignalProxy sig_columns_changed()
00894         {
00895                 return ColumnsChangedSignalProxy(this, &columns_changed_signal);
00896         }
00899 
00900         const CursorChangedSignalProxy sig_cursor_changed()
00901         {
00902                 return CursorChangedSignalProxy(this, &cursor_changed_signal);
00903         }
00905 
00907 };
00908 
00909 } // namespace Gtk
00910 
00911 } // namespace Inti
00912 
00913 #endif // INTI_GTK_TREE_VIEW_H
00914 
Main Page - Footer


Generated on Sun Sep 14 20:08:04 2003 for Inti by doxygen 1.3.2 written by Dimitri van Heesch, © 1997-2002