\chapter{wxTreeLayout Class Reference}
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
\setfooter{\thepage}{}{}{}{}{\thepage}

The member functions are given in alphabetical order except for the
constructors and destructors which appear first.

\section{\class{wxTreeLayout}: wxObject}

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 \helprefn{wxTreeLayout::GetChildren}{getchildren}\rtfsp
and \helprefn{wxTreeLayout::GetNodeParent}{getnodeparent} functions.

The application should call \helprefn{DoLayout}{dolayout} to do the tree
layout. Depending on how the derived class has been defined, either
\rtfsp\helprefn{wxTreeLayout::Draw}{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.

\membersection{wxTreeLayout::wxTreeLayout}

\func{void}{wxTreeLayout}{\param{wxDC *}{dc = NULL}}

Constructor.

\membersection{wxTreeLayout::ActivateNode}\label{activatenode}

\func{void}{ActivateNode}{\param{long}{ id}, \param{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 \helprefn{NodeActive}{nodeactive}.

\membersection{wxTreeLayout::DoLayout}\label{dolayout}

\func{void}{DoLayout}{\param{long}{ topNode = -1}}

Calculates the layout for the tree, optionally specifying the top node.

\membersection{wxTreeLayout::Draw}\label{draw}

\func{void}{Draw}{\void}

Call this to let wxTreeLayout draw the tree itself, once the layout has been
calculated with \helprefn{DoLayout}{dolayout}. The device context must
have been set in the constructor or using \helprefn{SetDC}{setdc}.

\membersection{wxTreeLayout::DrawBranch}

\func{void}{DrawBranch}{\param{long}{ from}, \param{long}{ to}}

Defined by wxTreeLayout to draw an arc between two nodes.

\membersection{wxTreeLayout::DrawBranches}

\func{void}{DrawBranches}{\void}

Defined by wxTreeLayout to draw the arcs between nodes.

\membersection{wxTreeLayout::DrawNode}

\func{void}{DrawNode}{\param{long}{ id}}

Defined by wxTreeLayout to draw a node.

\membersection{wxTreeLayout::DrawNodes}

\func{void}{DrawNodes}{\void}

Defined by wxTreeLayout to draw the nodes.

\membersection{wxTreeLayout::GetChildren}\label{getchildren}

\func{void}{GetChildren}{\param{long}{ id}, \param{wxList \&}{list}}

Must be defined to return the children of node {\it id} in the given list
of integers.

\membersection{wxTreeLayout::GetDC}

\func{long}{GetDC}{\void}

Gets the (optional) device context associated with the tree.

\membersection{wxTreeLayout::GetNextNode}\label{getnextnode}

\func{long}{GetNextNode}{\param{long}{ id}}

Must be defined to return the next node after {\it 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.

\membersection{wxTreeLayout::GetNodeName}

\func{char *}{GetNodeName}{\param{long}{ id}}

May optionally be defined to get a node's name (for example if leaving
the drawing to wxTreeLayout).

\membersection{wxTreeLayout::GetNodeSize}

\func{void}{GetNodeSize}{\param{long}{ id}, \param{float}{ *x}, \param{float}{ *y}}

Can be defined to indicate a node's size, or left to wxTreeLayout to use the
name as an indication of size.

\membersection{wxTreeLayout::GetNodeParent}\label{getnodeparent}

\func{long}{GetNodeParent}{\param{long}{ id}}

Must be defined to return the parent node of {\it id}.
The function should return -1 if there is no parent.

\membersection{wxTreeLayout::GetNodeX}

\func{float}{GetNodeX}{\param{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.

\membersection{wxTreeLayout::GetNodeY}

\func{float}{GetNodeY}{\param{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.

\membersection{wxTreeLayout::GetLeftMargin}

\func{float}{GetLeftMargin}{\void}

Gets the left margin set with \helprefn{SetMargins}{setmargins}.

\membersection{wxTreeLayout::GetTopMargin}

\func{float}{GetTopMargin}{\void}

Gets the top margin set with \helprefn{SetMargins}{setmargins}.

\membersection{wxTreeLayout::GetTopNode}

\func{long}{GetTopNode}{\void}

wxTreeLayout calls this to get the top of the tree. Don't redefine this; call
\rtfsp\helprefn{SetTopNode}{settopnode} instead before calling \helprefn{DoLayout}{dolayout}.

\membersection{wxTreeLayout::GetXSpacing}

\func{float}{GetXSpacing}{\void}

Gets the horizontal spacing between nodes.

\membersection{wxTreeLayout::GetYSpacing}

\func{float}{GetYSpacing}{\void}

Gets the vertical spacing between nodes.

\membersection{wxTreeLayout::Initialize}

\func{void}{Initialize}{\void}

Initializes wxTreeLayout. Call from application or overridden {\bf Initialize}
or constructor.

\membersection{wxTreeLayout::CalcLayout}

\func{void}{CalcLayout}{\param{long}{ node\_id}, \param{int}{ level}}

Private function for laying out a branch.

\membersection{wxTreeLayout::NodeActive}\label{nodeactive}

\func{Bool}{NodeActive}{\param{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 \helprefn{ActivateNode}{activatenode}.

\membersection{wxTreeLayout::SetNodeName}

\func{void}{SetNodeName}{\param{long}{ id}, \param{char *}{ name}}

May optionally be defined to set a node's name.

\membersection{wxTreeLayout::SetNodeX}

\func{void}{SetNodeX}{\param{long}{ id}, \param{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.

\membersection{wxTreeLayout::SetNodeY}

\func{void}{SetNodeY}{\param{long}{ id}, \param{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.

\membersection{wxTreeLayout::SetTopNode}\label{settopnode}

\func{void}{SetTopNode}{\param{long}{ id}}

Call this to identify the top of the tree to wxTreeLayout.

\membersection{wxTreeLayout::SetDC}\label{setdc}

\func{void}{SetDC}{\param{wxDC *}{dc}}

Use this to set the tree's device context, if leaving the drawing up
to wxTreeLayout.

\membersection{wxTreeLayout::SetSpacing}

\func{void}{SetSpacing}{\param{float}{ x}, \param{float}{ y}}

Sets the horizontal and vertical spacing between nodes in the tree.

\membersection{wxTreeLayout::SetMargins}\label{setmargins}

\func{void}{SetMargins}{\param{float}{ x}, \param{float}{ y}}

Sets the left and top margins of the whole tree.

