This abstract class is used for drawing a tree. You must derive a new class from this, and define member functions to access the data that wxTreeLayout needs.
Nodes are identified by long integer identifiers. The derived class communicates the actual tree structure to wxTreeLayout by defining wxTreeLayout::GetChildren and wxTreeLayout::GetNodeParent functions.
The application should call DoLayout to do the tree layout. Depending on how the derived class has been defined, either wxTreeLayout::Draw must be called (for example by the OnDraw member of a wxCanvas) or the application-defined drawing code should be called as normal.
For example, if you have an image drawing system already defined, you may want wxTreeLayout to position existing node images in that system. So you just need a way for wxTreeLayout to set the node image positions according to the layout algorithm, and the rest will be done by your own image drawing system.
wxTreeLayout::wxTreeLayout
wxTreeLayout::ActivateNode
wxTreeLayout::DoLayout
wxTreeLayout::Draw
wxTreeLayout::DrawBranch
wxTreeLayout::DrawBranches
wxTreeLayout::DrawNode
wxTreeLayout::DrawNodes
wxTreeLayout::GetChildren
wxTreeLayout::GetDC
wxTreeLayout::GetNextNode
wxTreeLayout::GetNodeName
wxTreeLayout::GetNodeSize
wxTreeLayout::GetNodeParent
wxTreeLayout::GetNodeX
wxTreeLayout::GetNodeY
wxTreeLayout::GetLeftMargin
wxTreeLayout::GetOrientation
wxTreeLayout::GetTopMargin
wxTreeLayout::GetTopNode
wxTreeLayout::GetXSpacing
wxTreeLayout::GetYSpacing
wxTreeLayout::Initialize
wxTreeLayout::CalcLayout
wxTreeLayout::NodeActive
wxTreeLayout::SetNodeName
wxTreeLayout::SetNodeX
wxTreeLayout::SetNodeY
wxTreeLayout::SetOrientation
wxTreeLayout::SetTopNode
wxTreeLayout::SetDC
wxTreeLayout::SetSpacing
wxTreeLayout::SetMargins
void wxTreeLayout(wxDC *dc = NULL)
Constructor.
void ActivateNode(long id, Bool active)
Define this so wxTreeLayout can turn nodes on and off for drawing purposes (not all nodes may be connected in the tree). See also NodeActive.
void DoLayout(long topNode = -1)
Calculates the layout for the tree, optionally specifying the top node.
void Draw(void)
Call this to let wxTreeLayout draw the tree itself, once the layout has been calculated with DoLayout. The device context must have been set in the constructor or using SetDC.
void DrawBranch(long from, long to)
Defined by wxTreeLayout to draw an arc between two nodes.
void DrawBranches(void)
Defined by wxTreeLayout to draw the arcs between nodes.
void DrawNode(long id)
Defined by wxTreeLayout to draw a node.
void DrawNodes(void)
Defined by wxTreeLayout to draw the nodes.
void GetChildren(long id, wxList &list)
Must be defined to return the children of node id in the given list of integers.
long GetDC(void)
Gets the (optional) device context associated with the tree.
long GetNextNode(long id)
Must be defined to return the next node after id, so that wxTreeLayout can iterate through all relevant nodes. The ordering is not important. The function should return -1 if there are no more nodes.
char * GetNodeName(long id)
May optionally be defined to get a node's name (for example if leaving the drawing to wxTreeLayout).
void GetNodeSize(long id, float *x, float *y)
Can be defined to indicate a node's size, or left to wxTreeLayout to use the name as an indication of size.
long GetNodeParent(long id)
Must be defined to return the parent node of id. The function should return -1 if there is no parent.
float GetNodeX(long id)
Must be defined to return the current X position of the node. Note that coordinates are assumed to be at the top-left of the node so some conversion may be necessary for your application.
float GetNodeY(long id)
Must be defined to return the current Y position of the node. Note that coordinates are assumed to be at the top-left of the node so some conversion may be necessary for your application.
float GetLeftMargin(void)
Gets the left margin set with SetMargins.
Bool GetOrientation(void)
Gets the orientation: TRUE means top-to-bottom, FALSE means left-to-right (the default).
float GetTopMargin(void)
Gets the top margin set with SetMargins.
long GetTopNode(void)
wxTreeLayout calls this to get the top of the tree. Don't redefine this; call SetTopNode instead before calling DoLayout.
float GetXSpacing(void)
Gets the horizontal spacing between nodes.
float GetYSpacing(void)
Gets the vertical spacing between nodes.
void Initialize(void)
Initializes wxTreeLayout. Call from application or overridden Initialize or constructor.
void CalcLayout(long node_id, int level)
Private function for laying out a branch.
Bool NodeActive(long id)
Define this so wxTreeLayout can know which nodes are to be drawn (not all nodes may be connected in the tree). See also ActivateNode.
void SetNodeName(long id, char * name)
May optionally be defined to set a node's name.
void SetNodeX(long id, float x)
Must be defined to set the current X position of the node. Note that coordinates are assumed to be at the top-left of the node so some conversion may be necessary for your application.
void SetNodeY(long id, float y)
Must be defined to set the current Y position of the node. Note that coordinates are assumed to be at the top-left of the node so some conversion may be necessary for your application.
void SetOrientation(Bool orientation)
Sets the tree orientation: TRUE means top-to-bottom, FALSE means left-to-right (the default).
void SetTopNode(long id)
Call this to identify the top of the tree to wxTreeLayout.
void SetDC(wxDC *dc)
Use this to set the tree's device context, if leaving the drawing up to wxTreeLayout.
void SetSpacing(float x, float y)
Sets the horizontal and vertical spacing between nodes in the tree.
void SetMargins(float x, float y)
Sets the left and top margins of the whole tree.