org.gnu.gtk
Class TreeStore

java.lang.Object
  |
  +--org.gnu.glib.GObject
        |
        +--org.gnu.gtk.TreeModel
              |
              +--org.gnu.gtk.TreeStore

public class TreeStore
extends TreeModel

The TreeStore is a Model used for storing data which will be displayed in any number of TreeView widgets. For an overview of how the tree and list objects fit together, see the TreeView description.

Data is stored within this object in DataBlocks. This data is displayed in the widgets via CellRenderer's; the mapping between this data and the cell renderers of each treeview column is done in the TreeViewColumn class.

Author:
Mark Howard <mh@debian.org>

Constructor Summary
TreeStore(DataBlock[] dataBlocks)
          Constructs a new TreeStore, defining the types for each datablock.
 
Method Summary
 TreeIter appendRow(TreeIter parent)
          Appends a new row to tree_store.
 void clear()
          Removes all items from the treestore.
 int getIteratorDepth(TreeIter iter)
          Returns the depth of the iterator.
static Type getType()
          Retrieve the runtime type used by the GLib library.
 TreeIter insertRow(TreeIter parent, int position)
          Creates a new row at position.
 TreeIter insertRowAfter(TreeIter sibling, TreeIter parent)
          Inserts a new row after sibling.
 TreeIter insertRowBefore(TreeIter sibling, TreeIter parent)
          Inserts a new row before sibling.
 boolean isAncestor(TreeIter iter, TreeIter descendant)
          Returns TRUE if iter is an ancestor of descendant.
 TreeIter prependRow(TreeIter parent)
          Prepends a new row to the store.
 void removeRow(TreeIter iter)
          Removes a row from the tree store.
 void setValue(TreeIter iter, DataBlockBoolean dataBlock, boolean value)
          Sets a value in the dataStore.
 void setValue(TreeIter iter, DataBlockDouble dataBlock, double value)
          Sets a value in the dataStore.
 void setValue(TreeIter iter, DataBlockInt dataBlock, int value)
          Sets a value in the dataStore.
 void setValue(TreeIter iter, DataBlockObject dataBlock, java.lang.Object value)
          Sets a value in the dataStore.
 void setValue(TreeIter iter, DataBlockPixbuf dataBlock, Pixbuf value)
          Sets a value in the dataStore.
 void setValue(TreeIter iter, DataBlockString dataBlock, java.lang.String value)
          Sets a value in the dataStore.
 
Methods inherited from class org.gnu.gtk.TreeModel
getDataBlockCount, getFirstChild, getFirstIter, getIter, getIter, getIterChildCount, getNextIter, getPath, getType, getValue, getValue, getValue, getValue, getValue, iterHasChild
 
Methods inherited from class org.gnu.glib.GObject
addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, equals, getData, getHandle, removeEventHandler, setData
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeStore

public TreeStore(DataBlock[] dataBlocks)
Constructs a new TreeStore, defining the types for each datablock. Subsequent setting of data to any of the datablocks must follow the types you set out here.

Method Detail

setValue

public void setValue(TreeIter iter,
                     DataBlockString dataBlock,
                     java.lang.String value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn#addAttributeMapping(CellRenderer, CellRendererAttribute, int) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set.

setValue

public void setValue(TreeIter iter,
                     DataBlockInt dataBlock,
                     int value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn#addAttributeMapping(CellRenderer, CellRendererAttribute, int) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set.

setValue

public void setValue(TreeIter iter,
                     DataBlockBoolean dataBlock,
                     boolean value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn#addAttributeMapping(CellRenderer, CellRendererAttribute, int) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set.

setValue

public void setValue(TreeIter iter,
                     DataBlockDouble dataBlock,
                     double value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn#addAttributeMapping(CellRenderer, CellRendererAttribute, int) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set.

setValue

public void setValue(TreeIter iter,
                     DataBlockObject dataBlock,
                     java.lang.Object value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn#addAttributeMapping(CellRenderer, CellRendererAttribute, int) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data, starting at 0.
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set. This must match the type for that dataBlock, as set in the constructor.

setValue

public void setValue(TreeIter iter,
                     DataBlockPixbuf dataBlock,
                     Pixbuf value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn#addAttributeMapping(CellRenderer, CellRendererAttribute, int) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data, starting at 0.
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set.

removeRow

public void removeRow(TreeIter iter)
Removes a row from the tree store. After being removed, iter is set to the next valid row at that level, or invalidated if it previously pointed to the last one.

Parameters:
iter - Iterator representing the row.

insertRow

public TreeIter insertRow(TreeIter parent,
                          int position)
Creates a new row at position. 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.

Parameters:
parent - A valid TreeIter, or NULL
position - Position to insert the new row
Returns:
Iterator for the new row

insertRowBefore

public TreeIter insertRowBefore(TreeIter sibling,
                                TreeIter parent)
Inserts a new row before sibling. If sibling is NULL, then the row will be appended to parent 's children. If parent and sibling are NULL, then the row will be appended to the toplevel. If both sibling and parent are set, then parent must be the parent of sibling. When sibling is set, parent is optional

Parameters:
parent - A valid TreeIter, or NULL
sibling - A valid TreeIter, or NULL
Returns:
Iterator for the new row.

insertRowAfter

public TreeIter insertRowAfter(TreeIter sibling,
                               TreeIter parent)
Inserts a new row after sibling. If sibling is NULL, then the row will be prepended to the beginning of the parent 's children. If parent and sibling are NULL, then the row will be prepended to the toplevel. If both sibling and parent are set, then parent must be the parent of sibling. When sibling is set, parent is optional.

Parameters:
parent - A valid TreeIter, or NULL
sibling - A valid GtkTreeIter, or NULL
Returns:
Iterator for the new row.

prependRow

public TreeIter prependRow(TreeIter parent)
Prepends a new row to the store. 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.

Parameters:
parent - A valid TreeIter, or NULL
Returns:
Iterator for the new row.

appendRow

public TreeIter appendRow(TreeIter parent)
Appends a new row to tree_store. 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.

Parameters:
parent - A valid TreeIter, or NULL
Returns:
Iterator for the new row.

isAncestor

public boolean isAncestor(TreeIter iter,
                          TreeIter descendant)
Returns TRUE if iter is an ancestor of descendant. That is, iter is the parent (or grandparent or great-grandparent) of descendant.

Parameters:
iter - Row to be tested.
descendant - Descendant row for testing
Returns:
True of iter is an ancestor of descendant

getIteratorDepth

public int getIteratorDepth(TreeIter iter)
Returns the depth of the iterator. This will be 0 for anything on the root level, 1 for anything down a level, etc.

Parameters:
iter - The iterator to test the depth of
Returns:
Depth of the iterator.

clear

public void clear()
Removes all items from the treestore.


getType

public static Type getType()
Retrieve the runtime type used by the GLib library.


Please send any bug reports, comments, or suggestions for the API or documentation to java-gnome-developer@lists.sf.net