4414cc1db8
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@232 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
305 lines
9.4 KiB
TeX
305 lines
9.4 KiB
TeX
\chapter{wxTreeLayout Class Reference}
|
|
\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}%
|
|
\setfooter{\thepage}{}{}{}{}{\thepage}
|
|
|
|
\section{\class{wxTreeLayout}}\label{wxtreelayout}
|
|
|
|
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 OnPaint member
|
|
of a wxScrolledWindow) 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.
|
|
|
|
\wxheading{Derived from}
|
|
|
|
wxObject
|
|
|
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
|
|
|
\membersection{wxTreeLayout::wxTreeLayout}
|
|
|
|
\func{}{wxTreeLayout}{\void}
|
|
|
|
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::CalcLayout}
|
|
|
|
\func{void}{CalcLayout}{\param{long}{ id}, \param{int}{ level}}
|
|
|
|
Private function for laying out a branch.
|
|
|
|
\membersection{wxTreeLayout::DoLayout}\label{dolayout}
|
|
|
|
\func{void}{DoLayout}{\param{wxDC\&}{ dc}, \param{long}{ topNode = -1}}
|
|
|
|
Calculates the layout for the tree, optionally specifying the top node.
|
|
|
|
\membersection{wxTreeLayout::Draw}\label{draw}
|
|
|
|
\func{void}{Draw}{\param{wxDC\&}{ dc}}
|
|
|
|
Call this to let wxTreeLayout draw the tree itself, once the layout has been
|
|
calculated with \helprefn{DoLayout}{dolayout}.
|
|
|
|
\membersection{wxTreeLayout::DrawBranch}
|
|
|
|
\func{void}{DrawBranch}{\param{long}{ from}, \param{long}{ to}, \param{wxDC\&}{ dc}}
|
|
|
|
Defined by wxTreeLayout to draw an arc between two nodes.
|
|
|
|
\membersection{wxTreeLayout::DrawBranches}
|
|
|
|
\func{void}{DrawBranches}{\param{wxDC\&}{ dc}}
|
|
|
|
Defined by wxTreeLayout to draw the arcs between nodes.
|
|
|
|
\membersection{wxTreeLayout::DrawNode}
|
|
|
|
\func{void}{DrawNode}{\param{long}{ id}, \param{wxDC\&}{ dc}}
|
|
|
|
Defined by wxTreeLayout to draw a node.
|
|
|
|
\membersection{wxTreeLayout::DrawNodes}
|
|
|
|
\func{void}{DrawNodes}{\param{wxDC\&}{ dc}}
|
|
|
|
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::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}
|
|
|
|
\constfunc{wxString}{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}
|
|
|
|
\constfunc{void}{GetNodeSize}{\param{long}{ id}, \param{long*}{ x}, \param{long*}{ 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}
|
|
|
|
\constfunc{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}
|
|
|
|
\constfunc{long}{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}
|
|
|
|
\constfunc{long}{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}
|
|
|
|
\constfunc{long}{GetLeftMargin}{\void}
|
|
|
|
Gets the left margin set with \helprefn{SetMargins}{setmargins}.
|
|
|
|
\membersection{wxTreeLayout::GetOrientation}
|
|
|
|
\constfunc{bool}{GetOrientation}{\void}
|
|
|
|
Gets the orientation: TRUE means top-to-bottom, FALSE means left-to-right (the default).
|
|
|
|
\membersection{wxTreeLayout::GetTopMargin}
|
|
|
|
\constfunc{long}{GetTopMargin}{\void}
|
|
|
|
Gets the top margin set with \helprefn{SetMargins}{setmargins}.
|
|
|
|
\membersection{wxTreeLayout::GetTopNode}
|
|
|
|
\constfunc{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}
|
|
|
|
\constfunc{long}{GetXSpacing}{\void}
|
|
|
|
Gets the horizontal spacing between nodes.
|
|
|
|
\membersection{wxTreeLayout::GetYSpacing}
|
|
|
|
\constfunc{long}{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::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{const wxString\& }{ name}}
|
|
|
|
May optionally be defined to set a node's name.
|
|
|
|
\membersection{wxTreeLayout::SetNodeX}
|
|
|
|
\func{void}{SetNodeX}{\param{long}{ id}, \param{long}{ 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{long}{ 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::SetOrientation}
|
|
|
|
\func{void}{SetOrientation}{\param{bool}{ orientation}}
|
|
|
|
Sets the tree orientation: TRUE means top-to-bottom, FALSE means left-to-right (the default).
|
|
|
|
\membersection{wxTreeLayout::SetTopNode}\label{settopnode}
|
|
|
|
\func{void}{SetTopNode}{\param{long}{ id}}
|
|
|
|
Call this to identify the top of the tree to wxTreeLayout.
|
|
|
|
\membersection{wxTreeLayout::SetSpacing}
|
|
|
|
\func{void}{SetSpacing}{\param{long}{ x}, \param{long}{ y}}
|
|
|
|
Sets the horizontal and vertical spacing between nodes in the tree.
|
|
|
|
\membersection{wxTreeLayout::SetMargins}\label{setmargins}
|
|
|
|
\func{void}{SetMargins}{\param{long}{ x}, \param{long}{ y}}
|
|
|
|
Sets the left and top margins of the whole tree.
|
|
|
|
\section{\class{wxStoredTree}}\label{wxstoredtree}
|
|
|
|
wxStoredTree provides storage for node labels, position and client data. It also provides hit-testing
|
|
(which node a mouse event occurred on). It is usually a more convenient class to use than wxTreeLayout.
|
|
|
|
\wxheading{Derived from}
|
|
|
|
\helpref{wxTreeLayout}{wxtreelayout}
|
|
|
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
|
|
|
\membersection{wxStoredTree::wxStoredTree}
|
|
|
|
\func{}{wxStoredTree}{\param{int }{noNodes = 200}}
|
|
|
|
Constructor. Specify the maximum number of nodes to be allocated.
|
|
|
|
\membersection{wxStoredTree::AddChild}\label{wxstoredtreeaddchild}
|
|
|
|
\func{long}{AddChild}{\param{const wxString\&}{ name}, \param{const wxString\&}{ parent = ""}}
|
|
|
|
Adds a child with a given parent, returning the node id.
|
|
|
|
\membersection{wxStoredTree::GetClientData}\label{wxstoredtreegetclientdata}
|
|
|
|
\constfunc{long}{GetClientData}{\param{long}{ id}}
|
|
|
|
Gets the client data for the given node.
|
|
|
|
\membersection{wxStoredTree::GetNode}\label{wxstoredtreegetnode}
|
|
|
|
\constfunc{wxStoredNode*}{GetNode}{\param{long}{ id}}
|
|
|
|
Returns the wxStoredNode object for the given node id.
|
|
|
|
\membersection{wxStoredTree::GetNodeCount}\label{wxstoredtreegetnodecount}
|
|
|
|
\constfunc{int}{GetNodeCount}{\void}
|
|
|
|
Returns the current number of nodes.
|
|
|
|
\membersection{wxStoredTree::GetNumNodes}\label{wxstoredtreegetnumnodes}
|
|
|
|
\constfunc{int}{GetNumNodes}{\void}
|
|
|
|
Returns the maximum number of nodes.
|
|
|
|
\membersection{wxStoredTree::HitTest}\label{wxstoredtreehittest}
|
|
|
|
\func{wxString}{HitTest}{\param{wxMouseEvent\&}{ event}, \param{wxDC\& }{dc}}
|
|
|
|
Returns a string with the node name corresponding to the position of the mouse event, or the empty string if no node
|
|
was detected.
|
|
|
|
\membersection{wxStoredTree::NameToId}\label{wxstoredtreenametoid}
|
|
|
|
\func{long}{NameToId}{\param{const wxString\&}{ name}}
|
|
|
|
Returns the id for the given node name, or -1 if there was no such node.
|
|
|
|
\membersection{wxStoredTree::SetClientData}\label{wxstoredtreesetclientdata}
|
|
|
|
\func{void}{SetClientData}{\param{long}{ id}, \param{long}{ clientData}}
|
|
|
|
Sets client data for the given node.
|
|
|
|
|