Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# treestore.h

Go to the documentation of this file.

    00001 /*  Inti: Integrated Foundation Classes
    00002  *  Copyright (C) 2002 The Inti 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
    00023
    00024 #ifndef INTI_GTK_TREE_STORE_H
    00025 #define INTI_GTK_TREE_STORE_H
    00026
    00027 #ifndef INTI_G_OBJECT_H
    00028 #include <inti/glib/object.h>
    00029 #endif
    00030
    00031 #ifndef INTI_G_VALUE_H
    00032 #include <inti/glib/value.h>
    00033 #endif
    00034
    00035 #ifndef INTI_GTK_TREE_MODEL_H
    00036 #include <inti/gtk/treemodel.h>
    00037 #endif
    00038
    00039 #ifndef INTI_GTK_TREE_SORTABLE_H
    00040 #include <inti/gtk/treesortable.h>
    00041 #endif
    00042
    00043 #ifndef __GTK_TREE_STORE_H__
    00044 #include <gtk/gtktreestore.h>
    00045 #endif
    00046
    00047 namespace Inti {
    00048
    00049 namespace Gtk {
    00050
    00051 class TreeIter;
    00052 class TreeStoreClass;
    00053
    00061
    00062 class TreeStore : public G::Object, public TreeModel, public TreeSortable
    00063 {
    00064         friend class G::Object;
    00065         friend class TreeStoreClass;
    00066
    00067         TreeStore(const TreeStore&);
    00068         TreeStore& operator=(const TreeStore&);
    00069
    00070 protected:
    00073
    00074         explicit TreeStore(GtkTreeStore *tree_store, bool reference = true);
    00081
    00083
    00084 public:
    00087
    00088         TreeStore(int n_columns, ...);
    00095
    00096         TreeStore(const std::vector<GType>& types);
    00099
    00100         virtual ~TreeStore();
    00102
    00106
    00107         GtkTreeStore* gtk_tree_store() const { return (GtkTreeStore*)instance; }
    00109
    00110         GtkTreeStoreClass* gtk_tree_store_class() const;
    00112
    00113         operator GtkTreeStore* () const;
    00115
    00116         bool is_ancestor(const TreeIter& iter, const TreeIter& descendant) const;
    00122
    00123         int iter_depth(const TreeIter& iter) const;
    00129
    00130         bool iter_is_valid(const TreeIter& iter) const;
    00136
    00140
    00141         TreeIter prepend(TreeIter *parent = 0);
    00150
    00151         TreeIter append(TreeIter *parent = 0);
    00160
    00161         TreeIter insert(int position, TreeIter *parent = 0);
    00172
    00173         TreeIter insert_before(TreeIter& sibling, TreeIter *parent = 0);
    00182
    00183         TreeIter insert_after(TreeIter& sibling, TreeIter *parent = 0);
    00192
    00193         bool remove(TreeIter& iter);
    00200
    00201         void clear();
    00203
    00204         void reorder(const TreeIter& parent, int *new_order);
    00211
    00212         void swap(const TreeIter& a, const TreeIter& b);
    00218
    00219         void move_after(const TreeIter& iter, const TreeIter *position);
    00227
    00228         void move_before(const TreeIter& iter, const TreeIter *position);
    00236
    00237         void set_value(const TreeIter& iter, int column, const G::Value& value);
    00244
    00245         void set_value(const TreeIter& iter, int column, const char *str);
    00250
    00254
    00255         template<typename DataType>
    00256         void set_value(const TreeIter& iter, int column, const DataType& data)
    00257         {
    00258                 G::Value value(gtk_tree_store()->column_headers[column]);
    00259                 value.set(data);
    00260                 gtk_tree_store_set_value(gtk_tree_store(), iter, column, value.g_value());
    00261         }
    00270
    00271         template<typename DataType>
    00272         void set_enum(const TreeIter& iter, int column, const DataType& data)
    00273         {
    00274                 G::Value value(gtk_tree_store()->column_headers[column]);
    00275                 value.set((int)data);
    00276                 gtk_tree_store_set_value(gtk_tree_store(), iter, column, value.g_value());
    00277         }
    00286
    00287         template<typename DataType>
    00288         void set_object(const TreeIter& iter, int column, const DataType& data)
    00289         {
    00290                 G::Value value(gtk_tree_store()->column_headers[column]);
    00291                 value.set((G::Object*)data);
    00292                 gtk_tree_store_set_value(gtk_tree_store(), iter, column, value.g_value());
    00293         }
    00301
    00302         template<typename DataType>
    00303         void set_pointer(const TreeIter& iter, int column, const DataType& data)
    00304         {
    00305                 G::Value value(gtk_tree_store()->column_headers[column]);
    00306                 value.set((void*)data);
    00307                 gtk_tree_store_set_value(gtk_tree_store(), iter, column, value.g_value());
    00308         }
    00319
    00321 };
    00322
    00323 } // namespace Gtk
    00324
    00325 } // namespace Inti
    00326
    00327 #endif // INTI_GTK_TREE_STORE_H
    00328

Main Page - Footer