Reference Manual

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

# Inti::Gtk::TreePath Class Reference

A GtkTreePath C++ wrapper class. More...

`#include <inti/gtk/treemodel.h>`

Inheritance diagram for Inti::Gtk::TreePath:

List of all members.

## Public Member Functions

Constructors

- TreePath ()
    Construct a new tree path.
- TreePath (const char *path)
    Constructs a new tree path initialized to path, or the root if path is null.
- TreePath (int first_index,...)
    Construct a new path with first_index and varargs as the indices.
- TreePath (GtkTreePath *path)
    Construct a new tree path from an existing GtkTreePath.
- TreePath (GtkTreePath *path, bool copy)
    Construct a new text iterator from an existing GtkTreePath.
- TreePath (const TreePath &src)
    Copy constructor.
- ~TreePath ()
    Destructor.
- TreePath & operator= (const TreePath &src)
    Assignment operator.

Accessors

- GtkTreePath * gtk_tree_path () const
    Get a pointer to the GtkTreePath structure.
- operator GtkTreePath * () const
    Conversion operator; safely converts a TreePath to a GtkTreePath pointer.
- String to_string () const
    Generates a string representation of the path.
- int get_depth () const
    Returns the current depth of the path.
- std::vector< int > get_indices () const
    Returns the current indices of the path as a vector of integers, each integer representing a node in a tree.
- int compare (const TreePath &other) const
    Compares two paths.
- bool is_ancestor (const TreePath &descendant) const
    Returns true if descendant is a descendant of this path.
- bool is_descendant (const TreePath &ancestor) const
    Returns true if path is a descendant of ancestor.
- bool operator== (const TreePath &other) const
    Returns true if this path is equal to other.
- bool operator!= (const TreePath &other) const
    Returns true if this path is not equal to other.
- bool operator< (const TreePath &other) const
    Returns true if this path appears before other in a tree.
- bool operator> (const TreePath &other) const
    Returns true if this path appears after other in a tree.

Methods

- void append_index (int index)
    Appends a new index to the path; as a result, the depth of the path is increased.
- void prepend_index (int index)
    Prepends a new index to the path; as a result, the depth of the path is increased.
- void next ()
    Moves the path to point to the next node at the current depth.
- bool prev ()
    Moves the path to point to the previous node at the current depth, if it exists.
- bool up ()
    Moves the path to point to it's parent node, if it has a parent.
- void down ()
    Moves the path to point to the first child of the current path.

## Detailed Description

A GtkTreePath C++ wrapper class.

A tree path is essentially a potential node. It is a location on a tree model that may or may not actually correspond to a node on a specific model. The TreePath can be converted into either a vector of integers or a string. The string form is a list of numbers separated by a colon. Each number refers to the offset at that level. Thus, the path "0" refers to the root node and the path "2:4" refers to the fifth child of the third node.

## Constructor & Destructor Documentation

Inti::Gtk::TreePath::TreePath | ( | const char * | path | ) | `[explicit]`

  | Constructs a new tree path initialized to path, or the root if path is null. Parameters:
  path | The string representation of a path.
The path is expected to be a colon separated list of numbers. For example, the string "10:4:0" would create a path of depth 3 pointing to the 11th child of the root node, the 5th child of that 11th child, and the 1st child of that 5th child.

Inti::Gtk::TreePath::TreePath | ( | int | first_index,
|  | ... |
| ) | `[explicit]`

  | Construct a new path with first_index and varargs as the indices. Parameters:
  first_index | The first integer.
  ... | A list of integers terminated by -1.

Inti::Gtk::TreePath::TreePath | ( | GtkTreePath * | path | ) | `[explicit]`

  | Construct a new tree path from an existing GtkTreePath. Parameters:
  path | A pointer to a GtkTreePath.
The path can be a newly created GtkTreePath or an existing GtkTreePath. The TreePath object created is a temporary object. It doesn't take over the ownership of GtkTreePath and GtkTreePath is not freed by the destructor.

Inti::Gtk::TreePath::TreePath | ( | GtkTreePath * | path,
|  | bool | copy
| ) |

  | Construct a new text iterator from an existing GtkTreePath. Parameters:
  path | A pointer to a GtkTreePath.
  copy | Whether the TreePath object should make a copy of GtkTreePath or not.
The path can be a newly created GtkTreePath or an existing GtkTreePath. If copy is true TreePath will make a copy of GtkTreePath. If copy is false TreePath wont make a copy but instead takes over the ownership of GtkTreePath. Either way, the destructor will free GtkTreePath when the TreePath object is destroyed. This constructor is used by G::Boxed::wrap() to wrap GtkTreePath objects in a C++ wrapper.

Inti::Gtk::TreePath::TreePath | ( | const TreePath & | src | ) |

  | Copy constructor. Parameters:
  src | The source tree path.

## Member Function Documentation

void Inti::Gtk::TreePath::append_index | ( | int | index | ) |

  | Appends a new index to the path; as a result, the depth of the path is increased. Parameters:
  index | The index.

int Inti::Gtk::TreePath::compare | ( | const TreePath & | other | ) | const

  | Compares two paths. Parameters:
  other | A TreePath to compare with.
Returns: The relative positions of two paths. If this path appears before other in a tree, then -1 is returned. If other appears before this path, then 1 is returned. If the two nodes are equal, then 0 is returned.

bool Inti::Gtk::TreePath::is_ancestor | ( | const TreePath & | descendant | ) | const

  | Returns true if descendant is a descendant of this path. Parameters:
  descendant | Another TreePath.
Returns: true if descendant is contained inside this path.

bool Inti::Gtk::TreePath::is_descendant | ( | const TreePath & | ancestor | ) | const

  | Returns true if path is a descendant of ancestor. Parameters:
  ancestor | Another TreePath.
Returns: true if ancestor contains path somewhere below it.

TreePath& Inti::Gtk::TreePath::operator= | ( | const TreePath & | src | ) |

  | Assignment operator. Parameters:
  src | The source tree path.

void Inti::Gtk::TreePath::prepend_index | ( | int | index | ) |

  | Prepends a new index to the path; as a result, the depth of the path is increased. Parameters:
  index | The index.

bool Inti::Gtk::TreePath::prev | ( |  | ) |

| Moves the path to point to the previous node at the current depth, if it exists. Returns: true if the path has a previous node, and the move was made.

String Inti::Gtk::TreePath::to_string | ( |  | ) | const

| Generates a string representation of the path. This string is a ':' separated list of numbers. For example, "4:10:0:3" would be an acceptable return value for this string.

bool Inti::Gtk::TreePath::up | ( |  | ) |

| Moves the path to point to it's parent node, if it has a parent. Returns: true if the path has a parent, and the move was made.

The documentation for this class was generated from the following file:

- treemodel.h

Main Page - Footer