\chapter{wxGraphLayout 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{wxGraphLayout}: wxObject}

This abstract class is used for drawing a graph. You don't have to derive
a new class, but if you do provide \helpref{SetNodeX}{setnodex} and \helpref{SetNodeY}{setnodey} members, these
will automatically be called to position your nodes. If you do not derive
a new class and override these members, you need to call \helpref{GetNodeX}{getnodex}\rtfsp
and \helpref{GetNodeY}{getnodey} for each node after the call to \helpref{DoLayout}{dolayout}.

Nodes are identified by long integer identifiers. The application should
call \helpref{AddNode}{addnode} and \helpref{AddArc}{addarc} to register
the nodes and arcs with wxGraphLayout, before calling
\rtfsp\helprefn{DoLayout}{dolayout} to do the graph layout. Depending on how
the derived class has been defined, either
\rtfsp\helprefn{wxGraphLayout::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 wxGraphLayout to position existing node images in that system. So you
just need a way for wxGraphLayout to set the node image positions according to
the layout algorithm, and the rest will be done by your own image drawing
system.

\membersection{wxGraphLayout::wxGraphLayout}

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

Constructor. {\it dc} is an optional device context for the class
to draw the graph into.

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

\func{void}{ActivateNode}{\param{long}{ id}, \param{Bool }{active}}

Call this to turn off nodes in the graph (not implemented yet).
See also \helprefn{NodeActive}{nodeactive}.

\membersection{wxGraphLayout::AddArc}\label{addarc}

\func{void}{AddArc}{\param{long}{ id}, \param{long}{ fromId}, \param{long}{ toId},
\param{char *}{name = NULL}}

Call this to add an arc to the graph, with optional name to display.

\membersection{wxGraphLayout::AddNode}\label{addnode}

\func{void}{AddNode}{\param{long}{ id}, \param{char *}{name = NULL}}

Call this to add a node to the graph, with optional name to display.

\membersection{wxGraphLayout::Clear}

\func{void}{Clear}{\void}

Clears the graph so another graph may be defined and laid out.

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

\func{void}{DoLayout}{\void}

Calculates the layout for the graph.

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

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

Call this to let wxGraphLayout draw the graph 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{wxGraphLayout::DrawArc}

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

Defined by wxGraphLayout to draw an arc between two nodes.

\membersection{wxGraphLayout::DrawArcs}

\func{void}{DrawArcs}{\void}

Defined by wxGraphLayout to draw the arcs between nodes.

\membersection{wxGraphLayout::DrawNode}

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

Defined by wxGraphLayout to draw a node.

\membersection{wxGraphLayout::DrawNodes}

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

Defined by wxGraphLayout to draw the nodes.

\membersection{wxGraphLayout::GetDC}

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

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

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

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

Must be defined to return the next node after {\it id}, so that wxGraphLayout can
iterate through all relevant nodes. The ordering is not important.
The function should return -1 if there are no more nodes.

\begin{comment}
\membersection{wxGraphLayout::GetNodeName}

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

May optionally be defined to get a node's name (for example if leaving
the drawing to wxGraphLayout).
\end{comment}

\membersection{wxGraphLayout::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 wxGraphLayout to use the
name as an indication of size.

\membersection{wxGraphLayout::GetNodeX}\label{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{wxGraphLayout::GetNodeY}\label{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{wxGraphLayout::GetLeftMargin}

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

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

\membersection{wxGraphLayout::GetRotation}

\func{int}{GetRotation}{\void}

Get the rotation factor.

\membersection{wxGraphLayout::GetTopMargin}

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

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

\membersection{wxGraphLayout::GetXSpacing}

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

Gets the horizontal spacing between nodes.

\membersection{wxGraphLayout::GetYSpacing}

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

Gets the vertical spacing between nodes.

\membersection{wxGraphLayout::Initialize}

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

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

\membersection{wxGraphLayout::CalcLayout}

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

Private function for laying out a branch.

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

\func{Bool}{NodeActive}{\param{long}{ id}}

Define this so wxGraphLayout can know which nodes are to be drawn (not all
nodes may be connected in the graph). See also \helprefn{ActivateNode}{activatenode}.

\membersection{wxGraphLayout::SetBoundingBox}

\func{void}{SetBoundingBox}{\param{float}{ x1}, \param{float}{ y1}, \param{float}{ x2}, \param{float}{ y2}}

Sets the size of the bounding box to which the graph will be scaled. Pass the
top left corner and bottom right corner.

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

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

Use this to set the graph's device context, if leaving the drawing up
to wxGraphLayout.

\membersection{wxGraphLayout::SetNodeName}

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

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

\membersection{wxGraphLayout::SetNodeX}\label{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{wxGraphLayout::SetNodeY}\label{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{wxGraphLayout::SetRotation}

\func{void}{SetRotation}{\param{int}{ rot}}

Set the rotation factor (multipled by 90 degrees by wxGraphLayout).

\membersection{wxGraphLayout::SetSpacing}

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

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

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

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

Sets the left and top margins of the whole graph.

