Reference Manual

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

# liststore.h

Go to the documentation of this file.

    00001 /*  Inti: Integrated Foundation Classes
    00002  *  Copyright (C) 2002-2003 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_LIST_STORE_H
    00025 #define INTI_GTK_LIST_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_LIST_STORE_H__
    00044 #include <gtk/gtkliststore.h>
    00045 #endif
    00046
    00047 namespace Inti {
    00048
    00049 namespace Gtk {
    00050
    00051 class ListStoreClass;
    00052 class TreeIter;
    00053
    00148
    00149 class ListStore : public G::Object, public TreeModel, public TreeSortable
    00150 {
    00151         friend class G::Object;
    00152         friend class ListStoreClass;
    00153
    00154         ListStore(const ListStore&);
    00155         ListStore& operator=(const ListStore&);
    00156
    00157 protected:
    00160
    00161         explicit ListStore(GtkListStore *list_store, bool reference = true);
    00168
    00170
    00171 public:
    00174
    00175         ListStore(int n_columns, ...);
    00182
    00183         ListStore(const std::vector<GType>& types);
    00186
    00187         virtual ~ListStore();
    00189
    00193
    00194         GtkListStore* gtk_list_store() const { return (GtkListStore*)instance; }
    00196
    00197         GtkListStoreClass* gtk_list_store_class() const;
    00199
    00200         operator GtkListStore* () const;
    00202
    00203         bool iter_is_valid(const TreeIter& iter) const;
    00210
    00214
    00215         TreeIter prepend();
    00221
    00222         TreeIter append();
    00228
    00229         TreeIter insert(int position);
    00237
    00238         TreeIter insert_before(TreeIter& sibling);
    00245
    00246         TreeIter insert_after(TreeIter& sibling);
    00253
    00254         bool remove(TreeIter& iter);
    00261
    00262         void clear();
    00264
    00265         void reorder(int *new_order);
    00270
    00271         void swap(const TreeIter& a, const TreeIter& b);
    00277
    00278         void move_after(const TreeIter& iter, const TreeIter *position);
    00285
    00286         void move_before(const TreeIter& iter, const TreeIter *position);
    00293
    00294         void set_value(const TreeIter& iter, int column, const G::Value& value);
    00301
    00302         void set_value(const TreeIter& iter, int column, const char *str);
    00307
    00311
    00312         template<typename DataType>
    00313         void set_value(const TreeIter& iter, int column, const DataType& data)
    00314         {
    00315                 G::Value value(gtk_list_store()->column_headers[column]);
    00316                 value.set(data);
    00317                 gtk_list_store_set_value(gtk_list_store(), iter, column, value.g_value());
    00318         }
    00327
    00328         template<typename DataType>
    00329         void set_enum(const TreeIter& iter, int column, const DataType& data)
    00330         {
    00331                 G::Value value(gtk_list_store()->column_headers[column]);
    00332                 value.set((int)data);
    00333                 gtk_list_store_set_value(gtk_list_store(), iter, column, value.g_value());
    00334         }
    00343
    00344         template<typename DataType>
    00345         void set_object(const TreeIter& iter, int column, const DataType& data)
    00346         {
    00347                 G::Value value(gtk_list_store()->column_headers[column]);
    00348                 value.set((G::Object*)data);
    00349                 gtk_list_store_set_value(gtk_list_store(), iter, column, value.g_value());
    00350         }
    00358
    00359         template<typename DataType>
    00360         void set_pointer(const TreeIter& iter, int column, const DataType& data)
    00361         {
    00362                 G::Value value(gtk_list_store()->column_headers[column]);
    00363                 value.set((void*)data);
    00364                 gtk_list_store_set_value(gtk_list_store(), iter, column, value.g_value());
    00365         }
    00376
    00378 };
    00379
    00380 } // namespace Gtk
    00381
    00382 } // namespace Inti
    00383
    00384 #endif // INTI_GTK_LIST_STORE_H
    00385

Main Page - Footer