TreeModel.h

Go to the documentation of this file.
00001 #ifndef TREEMODEL_H_
00002 #define TREEMODEL_H_
00003 
00004 #include <string>
00005 
00006 #include <gtk/gtktreemodel.h>
00007 #include <gtk/gtktreeselection.h>
00008 
00009 namespace gtkutil
00010 {
00011 
00017     class TreeModel
00018     {
00019         public:
00020 
00033             static std::string getString (GtkTreeModel* model, GtkTreeIter* iter, gint colNo);
00034 
00046             static bool getBoolean (GtkTreeModel* model, GtkTreeIter* iter, gint colNo);
00047 
00059             static int getInt (GtkTreeModel* model, GtkTreeIter* iter, gint colNo);
00060 
00072             static gpointer getPointer (GtkTreeModel* model, GtkTreeIter* iter, gint colNo);
00073 
00085             static std::string getSelectedString (GtkTreeSelection* selection, gint colNo);
00086 
00099             static std::string getSelectedParentString (GtkTreeSelection* sel, gint colNo);
00100 
00114             static bool getSelectedBoolean (GtkTreeSelection* selection, gint colNo);
00115 
00127             static gpointer getSelectedPointer (GtkTreeSelection* selection, gint colNo);
00128 
00138             static gboolean equalFuncStringContains (GtkTreeModel* model, gint column, const gchar* key,
00139                     GtkTreeIter* iter, gpointer search_data);
00140 
00141             /* Local object that walks the GtkTreeModel and obtains a GtkTreePath locating
00142              * the given name. The gtk_tree_model_foreach function requires a pointer to
00143              * a function, which in this case is a static member of the walker object that
00144              * accepts a void* pointer to the instance (like other GTK callbacks).
00145              */
00146             class SelectionFinder
00147             {
00148 
00149                     // String containing the name to highlight
00150                     std::string _selection;
00151 
00152                     // An integer to search for (alternative to the string above)
00153                     int _needle;
00154 
00155                     // The GtkTreePath* pointing to the required texture
00156                     GtkTreePath* _path;
00157 
00158                     // The GtkTreeModel that has been searched by forEach()
00159                     GtkTreeModel* _model;
00160 
00161                     // The column index to be searched
00162                     int _column;
00163 
00164                     // TRUE, if this should search for an integer instead of a string
00165                     bool _searchForInt;
00166 
00167                 public:
00168 
00169                     // Constructor to search for strings
00170                     SelectionFinder (const std::string& selection, int column);
00171 
00172                     // Constructor to search for integers
00173                     SelectionFinder (int needle, int column);
00174 
00175                     // Retrieve the found TreePath, which may be NULL if the texture was not
00176                     // found
00177                     GtkTreePath* getPath ();
00178 
00182                     GtkTreeIter getIter ();
00183 
00184                     // Static callback for GTK
00185                     static gboolean
00186                             forEach (GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer vpSelf);
00187 
00188             }; // class SelectionFinder
00189     };
00190 
00191 } // namespace gtkutil
00192 
00193 #endif /*TREEMODEL_H_*/

Generated by  doxygen 1.6.2