GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

treemodel.hh

Go to the documentation of this file.
00001 /* GFC-UI: GTK+ Foundation Classes (User Interface Library) 00002 * Copyright (C) 2002-2004 The GFC Development Team. 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Library General Public License for more details. 00013 * 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 00025 00026 #ifndef GFC_GTK_TREE_MODEL_HH 00027 #define GFC_GTK_TREE_MODEL_HH 00028 00029 #ifndef GFC_G_TYPE_HH 00030 #include <gfc/glib/type.hh> 00031 #endif 00032 00033 #ifndef GFC_G_VALUE_HH 00034 #include <gfc/glib/value.hh> 00035 #endif 00036 00037 #ifndef __GTK_TREE_MODEL_H__ 00038 #include <gtk/gtktreemodel.h> 00039 #endif 00040 00041 #ifndef _CPP_VECTOR 00042 #include <vector> 00043 #endif 00044 00045 namespace GFC { 00046 00047 namespace G { 00048 class Object; 00049 class Value; 00050 } 00051 00052 namespace Gtk { 00053 00054 class SelectionData; 00055 00061 00062 enum TreeModelFlags 00063 { 00064 TREE_MODEL_ITERS_PERSIST = GTK_TREE_MODEL_ITERS_PERSIST, 00066 00067 TREE_MODEL_LIST_ONLY = GTK_TREE_MODEL_LIST_ONLY 00069 }; 00070 00072 00073 typedef unsigned int TreeModelFlagsField; 00074 00084 00085 class TreePath : public G::Boxed 00086 { 00087 public: 00090 00091 TreePath(); 00093 00094 explicit TreePath(const char *path); 00095 explicit TreePath(const String& path); 00103 00104 explicit TreePath(int first_index, ...); 00108 00109 explicit TreePath(GtkTreePath *path); 00117 00118 TreePath(GtkTreePath *path, bool copy); 00128 00129 TreePath(const TreePath& src); 00132 00133 ~TreePath(); 00135 00136 TreePath& operator=(const TreePath& src); 00139 00143 00144 GtkTreePath* gtk_tree_path() const; 00146 00147 operator GtkTreePath* () const; 00149 00150 String to_string() const; 00154 00155 int get_depth() const; 00157 00158 std::vector<int> get_indices() const; 00161 00162 int compare(const TreePath& other) const; 00170 00171 bool is_ancestor(const TreePath& descendant) const; 00175 00176 bool is_descendant(const TreePath& ancestor) const; 00180 00181 bool operator==(const TreePath& other) const; 00183 00184 bool operator!=(const TreePath& other) const; 00186 00187 bool operator<(const TreePath& other) const; 00189 00190 bool operator>(const TreePath& other) const; 00192 00196 00197 void append_index(int index); 00200 00201 void prepend_index(int index); 00204 00205 void next(); 00207 00208 bool prev(); 00211 00212 bool up(); 00215 00216 void down(); 00218 00220 }; 00221 00232 00233 class TreeIter : public G::Boxed 00234 { 00235 public: 00238 00239 TreeIter(); 00241 00242 explicit TreeIter(GtkTreeIter *iter); 00250 00251 TreeIter(GtkTreeIter *iter, bool copy); 00261 00262 TreeIter(const TreeIter& src); 00265 00266 ~TreeIter(); 00268 00269 TreeIter& operator=(const TreeIter& src); 00272 00276 00277 GtkTreeIter* gtk_tree_iter() const; 00279 00280 operator GtkTreeIter* () const; 00282 00284 }; 00285 00393 00394 class TreeModel : public virtual G::TypeInterface 00395 { 00396 protected: 00399 00400 TreeModel(); 00402 00403 virtual ~TreeModel() = 0; 00405 00409 00410 typedef G::Signal<void, TreePath&, TreeIter&> RowChangedSignalType; 00411 typedef G::SignalProxy<TypeInstance, RowChangedSignalType> RowChangedSignalProxy; 00412 static const RowChangedSignalType row_changed_signal; 00419 00420 typedef G::Signal<void, TreePath&, TreeIter&> RowInsertedSignalType; 00421 typedef G::SignalProxy<TypeInstance, RowInsertedSignalType> RowInsertedSignalProxy; 00422 static const RowInsertedSignalType row_inserted_signal; 00429 00430 typedef G::Signal<void, TreePath&, TreeIter&> RowHasChildToggledSignalType; 00431 typedef G::SignalProxy<TypeInstance, RowHasChildToggledSignalType> RowHasChildToggledSignalProxy; 00432 static const RowHasChildToggledSignalType row_has_child_toggled_signal; 00439 00440 typedef G::Signal<void, TreePath&> RowDeletedSignalType; 00441 typedef G::SignalProxy<TypeInstance, RowDeletedSignalType> RowDeletedSignalProxy; 00442 static const RowDeletedSignalType row_deleted_signal; 00448 00449 typedef G::Signal<void, TreePath&, TreeIter&, int*> RowsReorderedSignalType; 00450 typedef G::SignalProxy<TypeInstance, RowsReorderedSignalType> RowsReorderedSignalProxy; 00451 static const RowsReorderedSignalType rows_reordered_signal; 00459 00461 00462 public: 00463 00464 typedef sigc::slot<bool, const TreePath&, const TreeIter&> ForeachSlot; 00476 00479 00480 GtkTreeModel* gtk_tree_model() const; 00482 00483 operator GtkTreeModel* () const; 00485 00486 TreeModelFlagsField get_flags() const; 00492 00493 int get_n_columns() const; 00495 00496 GType get_column_type(int index) const; 00500 00501 bool get_iter(TreeIter& iter, const TreePath& path) const; 00506 00507 bool get_iter(TreeIter& iter, const char *path) const; 00508 bool get_iter(TreeIter& iter, const String& path) const; 00514 00515 String get_string_from_iter(const TreeIter& iter) const; 00522 00523 bool get_iter_first(TreeIter& iter) const; 00527 00528 Pointer<TreePath> get_path(const TreeIter& iter) const; 00532 00533 void get_value(const TreeIter& iter, int column, G::Value& value) const; 00538 00539 String get_value(const TreeIter& iter, int column) const; 00544 00545 bool get_value(const TreeIter& iter, int column, String& str) const; 00551 00552 bool iter_has_child(const TreeIter& iter) const; 00554 00558 00559 template<typename DataType> 00560 void get_value(const TreeIter& iter, int column, DataType& data) const; 00569 00570 template<typename DataType> 00571 void get_enum(const TreeIter& iter, int column, DataType& data) const; 00581 00582 template<typename DataType> 00583 void get_object(const TreeIter& iter, int column, DataType& data) const; 00593 00594 template<typename DataType> 00595 void get_pointer(const TreeIter& iter, int column, DataType& data) const; 00606 00610 00611 bool iter_next(TreeIter& iter); 00617 00618 bool iter_children(TreeIter& iter, const TreeIter *parent = 0); 00628 00629 int iter_n_children(const TreeIter *iter); 00635 00636 bool iter_nth_child(TreeIter& iter, const TreeIter *parent, int n); 00647 00648 bool iter_parent(TreeIter& iter, const TreeIter& child); 00657 00658 void ref_node(TreeIter *iter); 00670 00671 void unref_node(TreeIter *iter); 00679 00680 void foreach(const ForeachSlot& each); 00686 00687 void row_changed(const TreePath& path, const TreeIter& iter); 00691 00692 void row_inserted(const TreePath& path, const TreeIter& iter); 00696 00697 void row_has_child_toggled(const TreePath& path, const TreeIter& iter); 00703 00704 void row_deleted(const TreePath& path); 00711 00712 void rows_reordered(const TreePath& path, const TreeIter& iter, int *new_order); 00720 00724 00725 const RowChangedSignalProxy sig_row_changed(); 00727 00728 const RowInsertedSignalProxy sig_row_inserted(); 00730 00731 const RowHasChildToggledSignalProxy sig_row_has_child_toggled(); 00733 00734 const RowDeletedSignalProxy sig_row_deleted(); 00736 00737 const RowsReorderedSignalProxy sig_rows_reordered(); 00739 00741 }; 00742 00749 00750 class TreeRowReference : public G::Boxed 00751 { 00752 public: 00755 00756 TreeRowReference(TreeModel& model, const TreePath& path); 00763 00764 TreeRowReference(G::Object& proxy, TreeModel& model, const TreePath& path); 00777 00778 explicit TreeRowReference(GtkTreeRowReference *reference); 00786 00787 TreeRowReference(GtkTreeRowReference *reference, bool copy); 00799 00800 TreeRowReference(const TreeRowReference& src); 00803 00804 ~TreeRowReference(); 00806 00807 TreeRowReference& operator=(const TreeRowReference& src); 00810 00814 00815 GtkTreeRowReference* gtk_tree_row_reference() const; 00817 00818 operator GtkTreeRowReference* () const; 00820 00821 Pointer<TreePath> get_path() const; 00825 00826 bool valid() const; 00829 00831 00832 static void inserted(const G::Object& proxy, const TreePath& path); 00837 00838 static void deleted(const G::Object& proxy, const TreePath& path); 00843 00844 static void reordered(const G::Object& proxy, const TreePath& path, const TreeIter& iter, int *new_order); 00851 }; 00852 00853 } // namespace Gtk 00854 00855 } // namespace GFC 00856 00857 #include <gfc/gtk/inline/treemodel.inl> 00858 00859 #endif // GFC_GTK_TREE_MODEL_HH 00860

Generated on Tue Aug 24 00:34:32 2004 for GFC-UI by doxygen 1.3.8