Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::Gtk::TreeStore Class Reference

A GtkTreeStore C++ wrapper class. More...

#include <xfc/gtk/treestore.hh>

Inheritance diagram for Xfc::Gtk::TreeStore:

Xfc::G::Object Xfc::Gtk::TreeModel Xfc::Gtk::TreeSortable Xfc::Gtk::TreeDragSource Xfc::Gtk::TreeDragDest Xfc::G::TypeInstance Xfc::G::TypeInterface Xfc::G::TypeInterface Xfc::G::TypeInterface Xfc::G::TypeInterface Xfc::Trackable Xfc::G::TypeInstance Xfc::G::TypeInstance Xfc::G::TypeInstance Xfc::G::TypeInstance Xfc::Trackable Xfc::Trackable Xfc::Trackable Xfc::Trackable List of all members.

Public Member Functions

Accessors
Methods
Templates

Protected Member Functions

Methods

Detailed Description

A GtkTreeStore C++ wrapper class.

The TreeStore object is a tree-like model for use with a TreeView widget. It implements the TreeModel interface, and consequentialy, can use all of the methods available there. It also implements the TreeSortable interface so it can be sorted by the view. Finally, it also implements the tree drag and drop interfaces (see Gtk::ListStore).

Note: dynamically allocated objects must either be unreferenced or assigned to a smart pointer. Stack objects are automatically unreferenced when they go out of scope.

See also: the TreeView Widget HOWTO and example.


Constructor & Destructor Documentation

Xfc::Gtk::TreeStore::TreeStore (  )  [protected]

Constructs a new tree store with a reference count of 1 that the caller owns.

After calling this constructor you must call set_column_types() to set column types for the tree store.

Xfc::Gtk::TreeStore::TreeStore ( GtkTreeStore *  tree_store,
bool  owns_reference = true 
) [explicit, protected]

Construct a new TreeStore from an existing GtkTreeStore.

Parameters:
tree_store A pointer to a GtkTreeStore.
owns_reference Set false if the initial reference count is floating, set true if it's not.
The tree_store can be a newly created GtkTreeStore or an existing GtkTreeStore (see G::Object::Object).

Xfc::Gtk::TreeStore::TreeStore ( int  n_columns,
  ... 
)

Construct a tree store of n_columns columns of each of the types passed in the variable argument list.

Parameters:
n_columns The number of columns in the tree store.
... All the GType types for the columns, from first to last.
As an example, TreeStore(3, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_PIXBUF) will create a new tree store with three columns, of type int, string and GdkPixbuf respectively. TreeStore is created with a reference count of 1 that the caller owns.

Xfc::Gtk::TreeStore::TreeStore ( int  n_columns,
const GType *  types 
)

Construct a tree store of n_columns columns of each of the types passed in the array of GType.

Parameters:
n_columns The number of columns in the tree store.
types An array of GType containing the column types, from first to last.
TreeStore is created with a reference count of 1 that the caller owns.

Xfc::Gtk::TreeStore::TreeStore (  )  [protected]

Constructs a new tree store with a reference count of 1 that the caller owns.

After calling this constructor you must call set_column_types() to set column types for the tree store.

Xfc::Gtk::TreeStore::TreeStore ( GtkTreeStore *  tree_store,
bool  owns_reference = true 
) [explicit, protected]

Construct a new TreeStore from an existing GtkTreeStore.

Parameters:
tree_store A pointer to a GtkTreeStore.
owns_reference Set false if the initial reference count is floating, set true if it's not.
The tree_store can be a newly created GtkTreeStore or an existing GtkTreeStore (see G::Object::Object).

Xfc::Gtk::TreeStore::TreeStore ( int  n_columns,
  ... 
)

Construct a tree store of n_columns columns of each of the types passed in the variable argument list.

Parameters:
n_columns The number of columns in the tree store.
... All the GType types for the columns, from first to last.
As an example, TreeStore(3, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_PIXBUF) will create a new tree store with three columns, of type int, string and GdkPixbuf respectively. TreeStore is created with a reference count of 1 that the caller owns.

Xfc::Gtk::TreeStore::TreeStore ( int  n_columns,
const GType *  types 
)

Construct a tree store of n_columns columns of each of the types passed in the array of GType.

Parameters:
n_columns The number of columns in the tree store.
types An array of GType containing the column types, from first to last.
TreeStore is created with a reference count of 1 that the caller owns.


Member Function Documentation

void Xfc::Gtk::TreeStore::set_column_types ( int  n_columns,
const GType *  types 
) [protected]

Sets the column types for the tree store.

Parameters:
n_columns The number of columns in the tree store.
types An array of GType containing the column types, from first to last.
This method is meant primarily for objects that derive from TreeStore, and and should only be used when constructing a new tree store. It will not function after a row has been added, or a method on the Gtk::TreeModel interface is called.

bool Xfc::Gtk::TreeStore::is_ancestor ( const TreeIter iter,
const TreeIter descendant 
) const

Returns true if iter is an ancestor of descendant, that is, iter is the parent (or grandparent or great-grandparent) of descendant.

Parameters:
iter A valid TreeIter.
descendant A valid TreeIter.
Returns:
true if iter is an ancestor of descendant.

int Xfc::Gtk::TreeStore::iter_depth ( const TreeIter iter  )  const

Returns the depth of iter.

Parameters:
iter A valid TreeIter.
Returns:
The depth of iter.
The depth will be 0 for anything on the root level, 1 for anything down a level, etc.

bool Xfc::Gtk::TreeStore::iter_is_valid ( const TreeIter iter  )  const

Checks if the given iter is a valid iter for the tree store.

Parameters:
iter A TreeIter.
Returns:
true if the iter is still valid, false if it's not.
WARNING: This function is slow. Only use it for debugging and/or testing purposes.

TreeIter Xfc::Gtk::TreeStore::prepend ( TreeIter parent = 0  ) 

Prepends a new row to the tree store.

Parameters:
parent A valid TreeIter, or null.
Returns:
An unset TreeIter to set to the prepended row.
If parent is non-null, then it will prepend the new row before the first child of parent, otherwise it will prepend a row to the top level. The returned TreeIter will point to this new row. The row will be empty after this function is called. To fill in values, you need to call set_value() or set_value_type().

TreeIter Xfc::Gtk::TreeStore::append ( TreeIter parent = 0  ) 

Appends a new row to the tree store.

Parameters:
parent A valid TreeIter, or null.
Returns:
An unset TreeIter to set to the appended row.
If parent is non-null, then it will append the new row after the last child of parent, otherwise it will append a row to the top level. The returned TreeIter will point to this new row. The row will be empty after this function is called. To fill in values, you need to call set_value() or set_value_type().

TreeIter Xfc::Gtk::TreeStore::insert ( int  position,
TreeIter parent = 0 
)

Creates a new row at position.

Parameters:
position The position to insert the new row.
parent A valid TreeIter, or null.
Returns:
An TreeIter set to the new row.
If parent is non-null, then the row will be made a child of parent. Otherwise, the row will be created at the toplevel. If position is larger than the number of rows at that level, then the new row will be inserted to the end of the list. An empty TreeIter pointing to the new row is returned. To fill in values, you need to call set_value() or set_value_type().

TreeIter Xfc::Gtk::TreeStore::insert_before ( TreeIter sibling,
TreeIter parent = 0 
)

Inserts a new row before sibling.

Parameters:
sibling A valid TreeIter.
parent A valid TreeIter, or null.
Returns:
An TreeIter set to the new row.
parent is optional but if set it must be the parent of sibling. An empty TreeIter pointing to the new row is returned. To fill in values, you need to call set_value() or set_value_type().

TreeIter Xfc::Gtk::TreeStore::insert_after ( TreeIter sibling,
TreeIter parent = 0 
)

Inserts a new row after sibling.

Parameters:
sibling A valid TreeIter.
parent A valid TreeIter, or null.
Returns:
An TreeIter set to the new row.
parent is optional but if set it must be the parent of sibling. An empty TreeIter pointing to the new row is returned. To fill in values, you need to call set_value() or set_value_type().

bool Xfc::Gtk::TreeStore::remove ( TreeIter iter  ) 

Removes iter from the tree store.

Parameters:
iter A valid TreeIter.
Returns:
true if iter is valid, false if it's not.
After being removed, iter is set to the next valid row at that level, or invalidated if it previously pointed to the last one.

void Xfc::Gtk::TreeStore::reorder ( const TreeIter parent,
int *  new_order 
)

Reorders the children of parent in the tree store to follow the order indicated by new_order.

Parameters:
parent A TreeIter.
new_order An integer array indicating the new order for the list.
Note: This method only works with unsorted stores.

void Xfc::Gtk::TreeStore::swap ( const TreeIter a,
const TreeIter b 
)

Swaps a and b in the same level of the tree store.

Parameters:
a A TreeIter.
b Another TreeIter.
Note: This method only works with unsorted stores.

void Xfc::Gtk::TreeStore::move_after ( const TreeIter iter,
const TreeIter position 
)

Moves iter in the tree store to the position after position (iter and position should be in the same level).

Parameters:
iter A TreeIter.
position A TreeIter, or null.
Note: This function only works with unsorted stores. If position is null, iter will be moved to the start of the level.

void Xfc::Gtk::TreeStore::move_before ( const TreeIter iter,
const TreeIter position 
)

Moves iter in the tree store to the position before position (iter and position should be in the same level).

Parameters:
iter A TreeIter.
position A TreeIter, or null.
Note: This function only works with unsorted stores. If position is null, iter will be moved to the end of the level.

void Xfc::Gtk::TreeStore::set_value ( const TreeIter iter,
int  column,
const G::Value value 
)

Sets the data in the cell specified by iter and column.

Parameters:
iter A valid TreeIter for the row being modified.
column The column number to modify.
value The new value for the cell.
The type of value must be convertible to the type of the column.

void Xfc::Gtk::TreeStore::set_value ( const TreeIter iter,
int  column,
const char *  str 
)

Sets a string value in the cell specified by iter and column.

Parameters:
iter A valid TreeIter for the row being modified.
column The column number to modify.
str The new string for the cell.

void Xfc::Gtk::TreeStore::set_value ( const TreeIter iter,
int  column,
const std::string &  str 
)

Sets a string value in the cell specified by iter and column.

Parameters:
iter A valid TreeIter for the row being modified.
column The column number to modify.
str The new string for the cell.

template<typename DataType>
void Xfc::Gtk::TreeStore::set_value ( const TreeIter iter,
int  column,
const DataType &  data 
)

Sets the data in the cell specified by iter and column.

Parameters:
iter A valid TreeIter for the row being modified.
column The column number to modify.
data The data to set for the cell.
This method is used to set values corresponding to the standard data types used by G::Value, such as bool, int, double, String and unsigned int. There is a good example of setting values in the gfc-demo program <demos/gfc-demo/liststore.cc>.

template<typename DataType>
void Xfc::Gtk::TreeStore::set_enum ( const TreeIter iter,
int  column,
const DataType &  data 
)

Sets the enum data in the cell specified by iter and column.

Parameters:
iter A valid TreeIter for the row being modified.
column The column number to modify.
data The enum value to set.
This method is used to set enumeration values. The DataType is the type of the enumeration being set. There is a good example of setting values in the gfc-demo program <demos/gfc-demo/liststore.cc>.

template<typename DataType>
void Xfc::Gtk::TreeStore::set_object ( const TreeIter iter,
int  column,
const DataType &  data 
)

Sets the object pointer data in the cell specified by iter and column.

Parameters:
iter A valid TreeIter for the row being modified.
column The column number to modify.
data A pointer to an object derived from G::Object, passed by reference.
There is a good example of setting values in the gfc-demo program <demos/gfc-demo/liststore.cc>.

template<typename DataType>
void Xfc::Gtk::TreeStore::set_pointer ( const TreeIter iter,
int  column,
const DataType &  data 
)

Sets the pointer data in the cell specified by iter and column.

Parameters:
iter A valid TreeIter for the row being modified.
column The column number to modify.
data The pointer to set in the cell.
The data argument can be a pointer to any object. The pointer is managed internally as a generic (void*) pointer. Unlike set_object() which passes the G::Object pointer internally as a GObject pointer, set_pointer() passes the pointer as is, without interpretation. There is a good example of setting values in the gfc-demo program <demos/gfc-demo/liststore.cc>.


The documentation for this class was generated from the following file: Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3