tree (lx_tree.hpp)

From The Foundry MODO SDK wiki
Jump to: navigation, search
There are security restrictions on this page


Tree

This module defines a generic TreeObj that represents a hierarchial arrangement of data items. These structures for the basis of several higher-level tree-like structures in the user interface. Such structures include tree panes, popups and system menus, the latter of which are defined in this module.

TreeObj objects attemt to factor out common attributes of the various tree like UI elements in order to form a basis for all of the various implementatiuons.

Tree Object

The tree interface represents a single tier of a tree, which is a list of siblings, and a currently selected member of that list.

Spawn() creates a new tree object referencing either the same part or another part of the tree. Clients can copy this tier, or they can get the tier containing the parent, or the sub-items of the current child.

(1) SDK: ILxTree interface
         LXxMETHOD(  LxResult,
 Spawn) (
         LXtObjectID               self,
         unsigned                  mode,
         void                    **ppvObj);

(2) SDK: Declarations
 #define LXiTREE_CLONE    0
 #define LXiTREE_PARENT   1
 #define LXiTREE_CHILD    2
 #define LXiTREE_ROOT     3

(3) User Class: Tree method
         bool
 Clone (
         unsigned                 mode,
         CLxUser_Tree            &tree)
 {
         LXtObjectID             obj;
 
         return (LXx_OK (Spawn (mode, &obj)) && tree.take (obj));
 }

The tree object itself can be walked around the tree.

(4) SDK: ILxTree interface
         LXxMETHOD(  LxResult,
 ToParent) (
         LXtObjectID      self);
 
         LXxMETHOD(  LxResult,
 ToChild) (
         LXtObjectID      self);
 
         LXxMETHOD(  LxResult,
 ToRoot) (
         LXtObjectID      self);

This returns LXe_TRUE if this tree has no parent. If so, calling ToParent() will fail.

(5) SDK: ILxTree interface
         LXxMETHOD(  LxResult,
 IsRoot) (
         LXtObjectID              self);

This returns LXe_TRUE if the current element has no children. It's equivalent to calling ToChild() and testing the count for zero.

(6) SDK: ILxTree interface
         LXxMETHOD(  LxResult,
 ChildIsLeaf) (
         LXtObjectID              self);

This returns the number of elements in this tier. This can be zero for elements with no children.

(7) SDK: ILxTree interface
         LXxMETHOD(  LxResult,
 Count) (
         LXtObjectID              self,
         unsigned                *count);

The tree object maintains a current element, whose properties can be accessed through an ILxAttributes interface on the tree.

(8) SDK: ILxTree interface
         LXxMETHOD(  LxResult,
 Current) (
         LXtObjectID              self,
         unsigned                *index);
 
         LXxMETHOD(  LxResult,
 SetCurrent) (
         LXtObjectID              self,
         unsigned                 index);

(9) SDK: ILxTree interface
         LXxMETHOD( LxResult,
 ItemState) (
         LXtObjectID              self,
         const char              *guid,
         int                     *state);
 
         LXxMETHOD( LxResult,
 SetItemState) (
         LXtObjectID              self,
         const char              *guid,
         int                      state);

(10) SDK: Declarations
 #define LXu_TREE                "E61F3BA6-B9E8-41B8-8A61-3F78CBC79E98"
 #define LXa_TREE                "tree"

Empty Tree Python user class.

(11) PY: Tree method
 pass

ILxTreeListener

Tree clients can attach a listener interface (using the tree's ListenerPort) which can be informed of changes to the tree, either just attribute values or the structure of the tree.

(12) SDK: ILxTreeListener interface
         LXxMETHOD(  LxResult,
 NewAttributes) (
         LXtObjectID              self);
 
         LXxMETHOD(  LxResult,
 NewShape) (
         LXtObjectID              self);

(13) SDK: Declarations
 #define LXu_TREELISTENER        "EB38EE07-0E35-455F-A570-F4AF313494FD"

Empty TreeListener user classed.

(14) User Class: TreeListener method

(15) PY: TreeListener method
 pass