From 4414cc1db82e420d6d0b0bd3a3cf23be9a205d87 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 12 Jul 1998 09:21:16 +0000 Subject: [PATCH] Added wxTreeLayout for wxWindows 2.0 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@232 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- utils/wxtree/docs/back.gif | Bin 0 -> 225 bytes utils/wxtree/docs/books.gif | Bin 0 -> 433 bytes utils/wxtree/docs/classes.tex | 304 +++++++++++++++++++++++ utils/wxtree/docs/contents.gif | Bin 0 -> 231 bytes utils/wxtree/docs/forward.gif | Bin 0 -> 164 bytes utils/wxtree/docs/tex2rtf.ini | 28 +++ utils/wxtree/docs/tree.bib | 8 + utils/wxtree/docs/treetst.bmp | Bin 0 -> 14982 bytes utils/wxtree/docs/treetst.gif | Bin 0 -> 2490 bytes utils/wxtree/docs/up.gif | Bin 0 -> 137 bytes utils/wxtree/docs/wxtree.tex | 73 ++++++ utils/wxtree/lib/dummy | 1 + utils/wxtree/src/makefile.b32 | 71 ++++++ utils/wxtree/src/makefile.bcc | 96 +++++++ utils/wxtree/src/makefile.dos | 118 +++++++++ utils/wxtree/src/makefile.g95 | 48 ++++ utils/wxtree/src/makefile.nt | 133 ++++++++++ utils/wxtree/src/makefile.sc | 73 ++++++ utils/wxtree/src/makefile.unx | 133 ++++++++++ utils/wxtree/src/makefile.wat | 49 ++++ utils/wxtree/src/mondrian.ico | Bin 0 -> 766 bytes utils/wxtree/src/test.cpp | 200 +++++++++++++++ utils/wxtree/src/test.def | 8 + utils/wxtree/src/test.h | 54 ++++ utils/wxtree/src/test.rc | 3 + utils/wxtree/src/wxtree.cpp | 440 +++++++++++++++++++++++++++++++++ utils/wxtree/src/wxtree.h | 135 ++++++++++ 27 files changed, 1975 insertions(+) create mode 100644 utils/wxtree/docs/back.gif create mode 100644 utils/wxtree/docs/books.gif create mode 100644 utils/wxtree/docs/classes.tex create mode 100644 utils/wxtree/docs/contents.gif create mode 100644 utils/wxtree/docs/forward.gif create mode 100644 utils/wxtree/docs/tex2rtf.ini create mode 100644 utils/wxtree/docs/tree.bib create mode 100644 utils/wxtree/docs/treetst.bmp create mode 100644 utils/wxtree/docs/treetst.gif create mode 100644 utils/wxtree/docs/up.gif create mode 100644 utils/wxtree/docs/wxtree.tex create mode 100644 utils/wxtree/lib/dummy create mode 100644 utils/wxtree/src/makefile.b32 create mode 100644 utils/wxtree/src/makefile.bcc create mode 100644 utils/wxtree/src/makefile.dos create mode 100644 utils/wxtree/src/makefile.g95 create mode 100644 utils/wxtree/src/makefile.nt create mode 100644 utils/wxtree/src/makefile.sc create mode 100644 utils/wxtree/src/makefile.unx create mode 100644 utils/wxtree/src/makefile.wat create mode 100644 utils/wxtree/src/mondrian.ico create mode 100644 utils/wxtree/src/test.cpp create mode 100644 utils/wxtree/src/test.def create mode 100644 utils/wxtree/src/test.h create mode 100644 utils/wxtree/src/test.rc create mode 100644 utils/wxtree/src/wxtree.cpp create mode 100644 utils/wxtree/src/wxtree.h diff --git a/utils/wxtree/docs/back.gif b/utils/wxtree/docs/back.gif new file mode 100644 index 0000000000000000000000000000000000000000..8a61076d3ba74bdedc1d24f60c3d1f5a361a6cee GIT binary patch literal 225 zcmV<703QEGNk%v~VLt#E0Pz3-zrVld=jU&4Z(9HWEC2ui06zd20008IjE||y?GK}z zNf>~$-n{z{YJwGn=81mem9{RpmcUHc_KoNIPRH~B4DyD9p%LJl6@Sa4^Epcbno6kk zD5XxT&EQg7>t<(Iwfoo literal 0 HcmV?d00001 diff --git a/utils/wxtree/docs/books.gif b/utils/wxtree/docs/books.gif new file mode 100644 index 0000000000000000000000000000000000000000..26ff394df62cbdb103908648614173654ec6d7eb GIT binary patch literal 433 zcmZ?wbhEHb)Mn6T*vtR|`@wiWnA#8I?caakz=4K_hW|kE{|x`Z6p#k8fI#sl3nK#q zJA)2LC&&y2mVX~kc&^@S@%pT_yTXfJi2|GDp6e!c+BKZ&%hNhxEdIWs;JKB{`SQ<< zPEHBjEDpTA+u5C@f_Kd_OY(VT@*wQ`^@ZOn?o==|n=f}d-eJDgYH!-kgw~pQIm^yJ zXXjvP=CI1BsxGLD%W7s3YHF40W?)U_XRRqLV(6RR*epGzV`f*;yy>Y6CaJQe#!Z{C zG>UD-^ymfsl8Zb1&6`&m_|BiWyJ*Ao%}m=4ZI5W$CBCQ1cE#btXOFO~5xrb_#{Jx* zoonY*JxIO&=++(K#Sd;geEISGLb2|JE2D3|`n+=W_r6@~gZ$Dxn*aVxe61F6#H#M4 z+#(G(M&FGcoR<~PT+2yhbBbrNeE0fzVUh`tc%sLY@Sv%-ybAJtM`mzESx;fke0N#G zhwFr(q4BvrDU)5js(vjKIV-p&b=Q1{zHc=TUM!ikY^BWIkV&5=g{jIH2eop2JLI}4 V)i6YMM%m#@+X@~Z>t$fD1^{??#6$o9 literal 0 HcmV?d00001 diff --git a/utils/wxtree/docs/classes.tex b/utils/wxtree/docs/classes.tex new file mode 100644 index 0000000000..98b9e89ee2 --- /dev/null +++ b/utils/wxtree/docs/classes.tex @@ -0,0 +1,304 @@ +\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. + + diff --git a/utils/wxtree/docs/contents.gif b/utils/wxtree/docs/contents.gif new file mode 100644 index 0000000000000000000000000000000000000000..3dddfa3dd5f0c652e8b27cd6c29e1fdd49ced5a8 GIT binary patch literal 231 zcmVG0Pz3-zrVld=jU&4Z(9HWEC2ui06_p40008OjE||y?GK}z zO&EZ)-n{z{a)K3v=81;mmA0S4Fj_r^UyThZDG{h6k9m zHI_(7spd!5_$SH6m{Q-cu3}3Ku`2^Nfa3dZ+VyHW%gtsZ`jV7k@%j8Ij}~W) zc{NUP6)X3OWa^|{8nl?rh|gZ1@{(qofnsWu+nmFHSnaq>lB41zSVC9`a)_v*xHx0L S5h*!IS!o$ynW>ps0028gDN7ju literal 0 HcmV?d00001 diff --git a/utils/wxtree/docs/tex2rtf.ini b/utils/wxtree/docs/tex2rtf.ini new file mode 100644 index 0000000000..8b55040f1f --- /dev/null +++ b/utils/wxtree/docs/tex2rtf.ini @@ -0,0 +1,28 @@ +;;; Tex2RTF initialisation file +runTwice = yes +titleFontSize = 12 +authorFontSize = 10 +authorFontSize = 10 +chapterFontSize = 12 +sectionFontSize = 12 +subsectionFontSize = 12 +contentsDepth = 2 +headerRule = yes +footerRule = yes +useHeadingStyles = yes +listItemIndent=40 +generateHPJ = no +htmlBrowseButtons = bitmap +winHelpContents = yes +winHelpVersion = 3 ; 3 for Windows 3.x, 4 for Windows 95 +winHelpTitle = "wxTreeLayout Manual" +truncateFilenames = yes +combineSubSections = yes +\overview [2] {\rtfonly{See also }\settransparency{on}\sethotspotcolour{off}\sethotspotunderline{on}\winhelponly{\image{}{books.bmp}\settransparency{off}} +\htmlonly{\image{}{books.gif}}\helpref{#1}{#2} +\sethotspotcolour{on}\sethotspotunderline{on}} +\docparam [2]{\parskip{0}{\it #1}\htmlignore{\par}\parskip{10}\indented{1cm}{#2}} +\wxheading [1]{{\bf \htmlignore{\fcol{blue}{#1}}\htmlonly{\fcol{red}{#1}}}} +\const [0] {{\bf const}} +\constfunc [3] {{\bf #1} {\bf #2}(#3) {\bf const}\index{#2}} +\windowstyle [1] {{\bf #1}\index{#1}} diff --git a/utils/wxtree/docs/tree.bib b/utils/wxtree/docs/tree.bib new file mode 100644 index 0000000000..9793c41c47 --- /dev/null +++ b/utils/wxtree/docs/tree.bib @@ -0,0 +1,8 @@ +@techreport{robins87, +author = {Robins, Gabriel}, +title = {The {ISI} grapher: a portable tool for displaying graphs pictorially (ISI/RS-87-196)}, +institution = {University of South California}, +year = {1987}, +month = {September} +} + diff --git a/utils/wxtree/docs/treetst.bmp b/utils/wxtree/docs/treetst.bmp new file mode 100644 index 0000000000000000000000000000000000000000..fd6103035f4403bedcad1c8a8a187e75f797b821 GIT binary patch literal 14982 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 rx}08pS4?)u<%PW $(TREEDIR)/docs/wxtree.xlp + /bin/rm -f $(TREEDIR)/docs/tmp.xlp + +$(HTMLDIR)/wxtree/wxtree_contents.html: $(TREEDIR)/docs/manual.tex $(TREEDIR)/docs/classes.tex + cd ../docs; tex2rtf manual.tex $(HTMLDIR)/wxtree/wxtree.html -html -twice + +$(TREEDIR)/docs/manual.dvi: $(TREEDIR)/docs/manual.tex $(TREEDIR)/docs/classes.tex + cd $(TREEDIR)/docs; latex manual; latex manual; makeindex manual; bibtex manual; latex manual; latex manual + +$(TREEDIR)/docs/manual.ps: $(TREEDIR)/docs/manual.dvi + cd $(TREEDIR)/docs; dvips -f -r < manual.dvi > manual.ps + +clean_motif: + $(MAKE) -f makefile.unx GUISUFFIX=_motif cleanany + +clean_ol: + $(MAKE) -f makefile.unx GUISUFFIX=_ol cleanany + +clean_hp: + $(MAKE) -f makefile.unx GUISUFFIX=_hp cleanany + +cleanany: + rm -f $(OBJECTS) $(OBJDIR)/*.$(OBJSUFF) test$(GUISUFFIX) $(TREELIB) core + +wxclean_ol: + cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx clean_ol + +wxclean_motif: + cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx clean_motif + +wxclean_hp: + cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx clean_hp diff --git a/utils/wxtree/src/makefile.wat b/utils/wxtree/src/makefile.wat new file mode 100644 index 0000000000..818e657eac --- /dev/null +++ b/utils/wxtree/src/makefile.wat @@ -0,0 +1,49 @@ +WXDIR = ..\..\.. + +NOPRECOMP=1 + +!include $(WXDIR)\src\makewat.env + +WXLIB=$(WXDIR)\lib +LIBTARGET = ..\lib\wxtree.lib +IFLAGS = -i=$(WXINC) -i=$(WXBASEINC) +EXTRACPPFLAGS = +NAME = wxtree +LNK = test.lnk +TESTOBJECTS=test.obj + +OBJECTS = $(name).obj + +all: $(OBJECTS) $(LIBTARGET) + +$(LIBTARGET): $(OBJECTS) + *wlib /b /c /n /P=256 $(LIBTARGET) $(OBJECTS) + +test: test.exe + +test.obj: test.$(SRCSUFF) test.h wxtree.h + +test.exe : $(TESTOBJECTS) test.res $(LNK) $(LIBTARGET) $(WXLIB)\wx$(LEVEL).lib + wlink @$(LNK) + $(BINDCOMMAND) test.res + +test.res : test.rc $(WXDIR)\include\msw\wx.rc + $(RC) $(RESFLAGS1) test.rc + +$(LNK) : makefile.wat + %create $(LNK) + @%append $(LNK) debug all + @%append $(LNK) system $(LINKOPTION) + @%append $(LNK) $(MINDATA) + @%append $(LNK) $(MAXDATA) + @%append $(LNK) $(STACK) + @%append $(LNK) name test + @%append $(LNK) file $(WXLIB)\wx$(LEVEL).lib + @%append $(LNK) file $(LIBTARGET) + @for %i in ($(EXTRALIBS)) do @%append $(LNK) file %i + @for %i in ($(TESTOBJECTS)) do @%append $(LNK) file %i + +clean: .SYMBOLIC + -erase $(LIBTARGET) *.obj *.bak *.err *.pch *.lib *.lbc *.res *.exe + + diff --git a/utils/wxtree/src/mondrian.ico b/utils/wxtree/src/mondrian.ico new file mode 100644 index 0000000000000000000000000000000000000000..2310c5d275a87af295d5ea8dc79ea417a5e74c53 GIT binary patch literal 766 zcmZQzU<5)11px*Sc)`TLAO@s0fLH;D9e|jTfdxnc0Z + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include +#endif + +#include "wxtree.h" +#include "test.h" + +wxStoredTree *myTree = NULL; + +// A macro needed for some compilers (AIX) that need 'main' to be defined +// in the application itself. +IMPLEMENT_APP(MyApp) + +// The `main program' equivalent, creating the windows and returning the +// main frame +bool MyApp::OnInit() +{ + // Create the main frame window + MyFrame* frame = new MyFrame(NULL, "Tree Test", wxPoint(-1, -1), wxSize(400, 550)); + + // Give it a status line + frame->CreateStatusBar(2); + + // Give it an icon +#ifdef __WINDOWS__ + wxIcon icon("tree_icn"); + frame->SetIcon(icon); +#endif + + // Make a menubar + wxMenu *file_menu = new wxMenu; + file_menu->Append(TEST_LEFT_RIGHT, "&Left to right", "Redraw left to right"); + file_menu->Append(TEST_TOP_BOTTOM, "&Top to bottom", "Redraw top to bottom"); + file_menu->AppendSeparator(); + file_menu->Append(TEST_QUIT, "E&xit", "Quit program"); + + wxMenu *help_menu = new wxMenu; + help_menu->Append(TEST_ABOUT, "&About", "About Tree Test"); + + wxMenuBar* menu_bar = new wxMenuBar; + + menu_bar->Append(file_menu, "&File"); + menu_bar->Append(help_menu, "&Help"); + + // Associate the menu bar with the frame + frame->SetMenuBar(menu_bar); + + MyCanvas *canvas = new MyCanvas(frame); + + // Give it scrollbars: the virtual canvas is 20 * 50 = 1000 pixels in each direction + canvas->SetScrollbars(20, 20, 50, 50); + frame->canvas = canvas; + + myTree = new wxStoredTree(); + + wxClientDC dc(canvas); + wxFont font(10, wxROMAN, wxNORMAL, wxBOLD); + dc.SetFont(font); + TreeTest(*myTree, dc); + + frame->Show(TRUE); + + frame->SetStatusText("Hello, tree!"); + + // Return the main frame window + return TRUE; +} + +void MyApp::TreeTest(wxStoredTree& tree, wxDC& dc) +{ + tree.Initialize(200); + + tree.AddChild("animal"); + tree.AddChild("mammal", "animal"); + tree.AddChild("insect", "animal"); + tree.AddChild("bird", "animal"); + + tree.AddChild("man", "mammal"); + tree.AddChild("cat", "mammal"); + tree.AddChild("dog", "mammal"); + tree.AddChild("giraffe", "mammal"); + tree.AddChild("elephant", "mammal"); + tree.AddChild("donkey", "mammal"); + tree.AddChild("horse", "mammal"); + + tree.AddChild("fido", "dog"); + tree.AddChild("domestic cat", "cat"); + tree.AddChild("lion", "cat"); + tree.AddChild("tiger", "cat"); + tree.AddChild("felix", "domestic cat"); + tree.AddChild("socks", "domestic cat"); + + tree.AddChild("beetle", "insect"); + tree.AddChild("earwig", "insect"); + tree.AddChild("eagle", "bird"); + tree.AddChild("bluetit", "bird"); + tree.AddChild("sparrow", "bird"); + tree.AddChild("blackbird", "bird"); + tree.AddChild("emu", "bird"); + tree.AddChild("crow", "bird"); + + tree.DoLayout(dc); +} + +BEGIN_EVENT_TABLE(MyFrame, wxFrame) + EVT_MENU(TEST_QUIT, MyFrame::OnQuit) + EVT_MENU(TEST_ABOUT, MyFrame::OnAbout) + EVT_MENU(TEST_LEFT_RIGHT, MyFrame::OnLeftRight) + EVT_MENU(TEST_TOP_BOTTOM, MyFrame::OnTopBottom) + EVT_CLOSE(MyFrame::OnCloseWindow) +END_EVENT_TABLE() + +// Define my frame constructor +MyFrame::MyFrame(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size): + wxFrame(parent, -1, title, pos, size) +{ +} + +void MyFrame::OnQuit(wxCommandEvent& event) +{ + Close(TRUE); +} + +void MyFrame::OnLeftRight(wxCommandEvent& event) +{ + if (myTree) + { + myTree->SetOrientation(FALSE); + wxClientDC dc(canvas); + wxFont font(10, wxROMAN, wxNORMAL, wxBOLD); + dc.SetFont(font); + wxGetApp().TreeTest(*myTree, dc); + canvas->Refresh(); + } +} + +void MyFrame::OnTopBottom(wxCommandEvent& event) +{ + if (myTree) + { + myTree->SetOrientation(TRUE); + wxClientDC dc(canvas); + wxFont font(10, wxROMAN, wxNORMAL, wxBOLD); + dc.SetFont(font); + wxGetApp().TreeTest(*myTree, dc); + canvas->Refresh(); + } +} + +void MyFrame::OnAbout(wxCommandEvent& event) +{ + (void)wxMessageBox("wxWindows tree library demo Vsn 2.0\nAuthor: Julian Smart (c) 1998", "About tree test"); +} + +void MyFrame::OnCloseWindow(wxCloseEvent& event) +{ + Destroy(); +} + +BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow) + EVT_PAINT(MyCanvas::OnPaint) +END_EVENT_TABLE() + +// Define a constructor for my canvas +MyCanvas::MyCanvas(wxWindow *parent): + wxScrolledWindow(parent, -1) +{ +} + +// Define the repainting behaviour +void MyCanvas::OnPaint(wxPaintEvent& event) +{ + wxPaintDC dc(this); + PrepareDC(dc); + if (myTree) + { + wxFont font(10, wxROMAN, wxNORMAL, wxBOLD); + dc.SetFont(font); + myTree->Draw(dc); + } +} + diff --git a/utils/wxtree/src/test.def b/utils/wxtree/src/test.def new file mode 100644 index 0000000000..558ccc1235 --- /dev/null +++ b/utils/wxtree/src/test.def @@ -0,0 +1,8 @@ +NAME Test +DESCRIPTION 'Tree Test' +EXETYPE WINDOWS +STUB 'WINSTUB.EXE' +CODE PRELOAD MOVEABLE DISCARDABLE +DATA PRELOAD MOVEABLE MULTIPLE +HEAPSIZE 1024 +STACKSIZE 16192 diff --git a/utils/wxtree/src/test.h b/utils/wxtree/src/test.h new file mode 100644 index 0000000000..b00660744e --- /dev/null +++ b/utils/wxtree/src/test.h @@ -0,0 +1,54 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: test.h +// Purpose: wxTreeLayout sample +// Author: Julian Smart +// Modified by: +// Created: 7/4/98 +// RCS-ID: $Id$ +// Copyright: (c) 1998 Julian Smart +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// Define a new application +class MyApp: public wxApp +{ + public: + bool OnInit(); + void TreeTest(wxStoredTree& tree, wxDC& dc); +}; + +DECLARE_APP(MyApp) + +class MyCanvas; + +class MyFrame: public wxFrame +{ + public: + MyCanvas *canvas; + MyFrame(wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size); + + void OnCloseWindow(wxCloseEvent& event); + void OnQuit(wxCommandEvent& event); + void OnAbout(wxCommandEvent& event); + void OnLeftRight(wxCommandEvent& event); + void OnTopBottom(wxCommandEvent& event); + +DECLARE_EVENT_TABLE() +}; + +// Define a new canvas which can receive some events +class MyCanvas: public wxScrolledWindow +{ + public: + MyCanvas(wxWindow *frame); + void OnPaint(wxPaintEvent& event); + void OnEvent(wxMouseEvent& event); + void OnChar(wxKeyEvent& event); +DECLARE_EVENT_TABLE() +}; + +#define TEST_QUIT 1 +#define TEST_ABOUT 2 +#define TEST_LEFT_RIGHT 3 +#define TEST_TOP_BOTTOM 4 + diff --git a/utils/wxtree/src/test.rc b/utils/wxtree/src/test.rc new file mode 100644 index 0000000000..41e6896e8e --- /dev/null +++ b/utils/wxtree/src/test.rc @@ -0,0 +1,3 @@ +tree_icn ICON "mondrian.ico" +#include "wx/msw/wx.rc" + diff --git a/utils/wxtree/src/wxtree.cpp b/utils/wxtree/src/wxtree.cpp new file mode 100644 index 0000000000..70d3be26c0 --- /dev/null +++ b/utils/wxtree/src/wxtree.cpp @@ -0,0 +1,440 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tree.h +// Purpose: wxTreeLayout class +// Author: Julian Smart +// Modified by: +// Created: 7/4/98 +// RCS-ID: $Id$ +// Copyright: (c) 1998 Julian Smart +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "wxtree.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#include +#endif + +#include "wxtree.h" + +/* + * Abstract tree + * + */ + +IMPLEMENT_ABSTRACT_CLASS(wxTreeLayout, wxObject) + +wxTreeLayout::wxTreeLayout() +{ + m_xSpacing = 16; + m_ySpacing = 20; + m_topMargin = 5; + m_leftMargin = 5; + m_orientation = FALSE; + m_parentNode = 0; +} + +void wxTreeLayout::DoLayout(wxDC& dc, long topId) +{ + if (topId != -1) + SetTopNode(topId); + + long actualTopId = GetTopNode(); + long id = actualTopId; + while (id != -1) + { + SetNodeX(id, 0); + SetNodeY(id, 0); + ActivateNode(id, FALSE); + id = GetNextNode(id); + } + m_lastY = m_topMargin; + m_lastX = m_leftMargin; + CalcLayout(actualTopId, 0, dc); +} + +void wxTreeLayout::Draw(wxDC& dc) +{ + dc.Clear(); + DrawBranches(dc); + DrawNodes(dc); +} + +void wxTreeLayout::DrawNodes(wxDC& dc) +{ + long id = GetTopNode(); + while (id != -1) + { + if (NodeActive(id)) + DrawNode(id, dc); + id = GetNextNode(id); + } +} + +void wxTreeLayout::DrawBranches(wxDC& dc) +{ + long id = GetTopNode(); + while (id != -1) + { + if (GetNodeParent(id) > -1) + { + long parent = GetNodeParent(id); + if (NodeActive(parent)) + DrawBranch(parent, id, dc); + } + id = GetNextNode(id); + } +} + +void wxTreeLayout::DrawNode(long id, wxDC& dc) +{ + char buf[80]; + wxString name(GetNodeName(id)); + if (name != "") + sprintf(buf, "%s", (const char*) name); + else + sprintf(buf, ""); + + long x = 80; + long y = 20; + dc.GetTextExtent(buf, &x, &y); + dc.DrawText(buf, GetNodeX(id), (long)(GetNodeY(id) - (y/2.0))); +} + +void wxTreeLayout::DrawBranch(long from, long to, wxDC& dc) +{ + long w, h; + GetNodeSize(from, &w, &h, dc); + dc.DrawLine(GetNodeX(from)+w, GetNodeY(from), + GetNodeX(to), GetNodeY(to)); +} + +void wxTreeLayout::Initialize(void) +{ +} + +void wxTreeLayout::GetNodeSize(long id, long *x, long *y, wxDC& dc) +{ + wxString name(GetNodeName(id)); + if (name != "") + dc.GetTextExtent(name, x, y); + else + { + *x = 70; *y = 20; + } +} + +void wxTreeLayout::CalcLayout(long nodeId, int level, wxDC& dc) +{ + wxList children; + GetChildren(nodeId, children); + int n = children.Number(); + + if (m_orientation == FALSE) + { + // Left to right + // X Calculations + if (level == 0) + SetNodeX(nodeId, m_leftMargin); + else + { + long x = 0; + long y = 0; + long parentId = GetNodeParent(nodeId); + if (parentId != -1) + GetNodeSize(parentId, &x, &y, dc); + SetNodeX(nodeId, (long)(GetNodeX(parentId) + m_xSpacing + x)); + } + + wxNode *node = children.First(); + while (node) + { + CalcLayout((long)node->Data(), level+1, dc); + node = node->Next(); + } + + // Y Calculations + long averageY; + ActivateNode(nodeId, TRUE); + + if (n > 0) + { + averageY = 0; + node = children.First(); + while (node) + { + averageY += GetNodeY((long)node->Data()); + node = node->Next(); + } + averageY = averageY / n; + SetNodeY(nodeId, averageY); + } + else + { + SetNodeY(nodeId, m_lastY); + long x, y; + GetNodeSize(nodeId, &x, &y, dc); + + m_lastY = m_lastY + y + m_ySpacing; + } + } + else + { + // Top to bottom + + // Y Calculations + if (level == 0) + SetNodeY(nodeId, m_topMargin); + else + { + long x = 0; + long y = 0; + long parentId = GetNodeParent(nodeId); + if (parentId != -1) + GetNodeSize(parentId, &x, &y, dc); + SetNodeY(nodeId, (long)(GetNodeY(parentId) + m_ySpacing + y)); + } + + wxNode *node = children.First(); + while (node) + { + CalcLayout((long)node->Data(), level+1, dc); + node = node->Next(); + } + + // X Calculations + long averageX; + ActivateNode(nodeId, TRUE); + + if (n > 0) + { + averageX = 0; + node = children.First(); + while (node) + { + averageX += GetNodeX((long)node->Data()); + node = node->Next(); + } + averageX = averageX / n; + SetNodeX(nodeId, averageX); + } + else + { + SetNodeX(nodeId, m_lastX); + long x, y; + GetNodeSize(nodeId, &x, &y, dc); + + m_lastX = m_lastX + x + m_xSpacing; + } + } +} + +/* + * Tree with storage + * + */ + +IMPLEMENT_DYNAMIC_CLASS(wxStoredTree, wxTreeLayout) + +wxStoredTree::wxStoredTree(int n):wxTreeLayout() +{ + m_nodes = NULL; + m_maxNodes = 0; + Initialize(n); +} + +wxStoredTree::~wxStoredTree(void) +{ + if (m_nodes) + delete[] m_nodes; +} + +void wxStoredTree::Initialize(int n) +{ + m_maxNodes = n; + wxTreeLayout::Initialize(); + if (m_nodes) delete[] m_nodes; + m_nodes = new wxStoredNode[m_maxNodes]; + int i; + for (i = 0; i < n; i++) + { + m_nodes[i].m_name = ""; + m_nodes[i].m_active = FALSE; + m_nodes[i].m_parentId = -1; + m_nodes[i].m_x = 0; + m_nodes[i].m_y = 0; + } + m_num = 0; +} + +long wxStoredTree::AddChild(const wxString& name, const wxString& parent) +{ + if (m_num < (m_maxNodes -1 )) + { + long i = -1; + if (parent != "") + i = NameToId(parent); + else m_parentNode = m_num; + + m_nodes[m_num].m_parentId = i; + m_nodes[m_num].m_name = name; + m_nodes[m_num].m_x = m_nodes[m_num].m_y = 0; + m_nodes[m_num].m_clientData = 0; + m_num ++; + + return (m_num - 1); + } + else + return -1; +} + +long wxStoredTree::NameToId(const wxString& name) +{ + long i; + for (i = 0; i < m_num; i++) + if (name == m_nodes[i].m_name) + return i; + return -1; +} + +void wxStoredTree::GetChildren(long id, wxList& list) +{ + long currentId = GetTopNode(); + while (currentId != -1) + { + if (id == GetNodeParent(currentId)) + list.Append((wxObject *)currentId); + currentId = GetNextNode(currentId); + } +} + +wxStoredNode* wxStoredTree::GetNode(long id) const +{ + wxASSERT(idx < m_num); + + return &m_nodes[idx]; +}; + +long wxStoredTree::GetNodeX(long id) +{ + wxASSERT(id < m_num); + + return (long)m_nodes[id].m_x; +} + +long wxStoredTree::GetNodeY(long id) +{ + wxASSERT(id < m_num); + + return (long)m_nodes[id].m_y; +} + +void wxStoredTree::SetNodeX(long id, long x) +{ + wxASSERT(id < m_num); + + m_nodes[id].m_x = (int)x; +} + +void wxStoredTree::SetNodeY(long id, long y) +{ + wxASSERT(id < m_num); + + m_nodes[id].m_y = (int)y; +} + +void wxStoredTree::SetNodeName(long id, const wxString& name) +{ + wxASSERT(id < m_num); + + m_nodes[id].m_name = name; +} + +wxString wxStoredTree::GetNodeName(long id) +{ + wxASSERT(id < m_num); + + return m_nodes[id].m_name; +} + +long wxStoredTree::GetNodeParent(long id) +{ + if (id != -1) + { + wxASSERT(id < m_num); + + return m_nodes[id].m_parentId; + } + else + return -1; +} + +long wxStoredTree::GetNextNode(long id) +{ + wxASSERT(id < m_num); + + if ((id != -1) && (id < (m_num - 1))) + return id + 1; + else + return -1; +} + +void wxStoredTree::SetClientData(long id, long clientData) +{ + wxASSERT(id < m_num); + + m_nodes[id].m_clientData = clientData; +} + +long wxStoredTree::GetClientData(long id) const +{ + wxASSERT(id < m_num); + + return m_nodes[id].m_clientData; +} + +void wxStoredTree::ActivateNode(long id, bool active) +{ + wxASSERT(id < m_num); + + m_nodes[id].m_active = active; +} + +bool wxStoredTree::NodeActive(long id) +{ + wxASSERT(id < m_num); + + return m_nodes[id].m_active; +} + +wxString wxStoredTree::HitTest(wxMouseEvent& event, wxDC& dc) +{ + long x, y; + event.Position(&x, &y); + + int i; + for (i = 0; i < m_maxNodes; i++) + { + wxStoredNode* item = &m_nodes[i]; + + long width, height; + dc.GetTextExtent(m_nodes[i].m_name, &width, &height); + + if ( (x >= (m_nodes[i].m_x-10)) && (x < (m_nodes[i].m_x + width+10)) && + (y >= m_nodes[i].m_y-10) && (y < (m_nodes[i].m_y + height+10)) ) + { + return m_nodes[i].m_name; + } + } + + return wxString(""); +} diff --git a/utils/wxtree/src/wxtree.h b/utils/wxtree/src/wxtree.h new file mode 100644 index 0000000000..538e9e0891 --- /dev/null +++ b/utils/wxtree/src/wxtree.h @@ -0,0 +1,135 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tree.h +// Purpose: wxTreeLayout class +// Author: Julian Smart +// Modified by: +// Created: 7/4/98 +// RCS-ID: $Id$ +// Copyright: (c) 1998 Julian Smart +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WXTREE_H_ +#define _WXTREE_H_ + +#ifdef __GNUG__ +#pragma interface "wxtree.h" +#endif + +#include + +class wxTreeLayout: public wxObject +{ + DECLARE_ABSTRACT_CLASS(wxTreeLayout) + + public: + wxTreeLayout(); + + // Redefine these + virtual void GetChildren(long id, wxList& list) = 0; + virtual long GetNextNode(long id) = 0; + virtual long GetNodeParent(long id) = 0; + virtual long GetNodeX(long id) = 0; + virtual long GetNodeY(long id) = 0; + virtual void SetNodeX(long id, long x) = 0; + virtual void SetNodeY(long id, long y) = 0; + virtual void ActivateNode(long id, bool active) = 0; + virtual bool NodeActive(long id) = 0; + + // Optional redefinition + void Initialize(void); + inline virtual void SetNodeName(long id, const wxString& name) {} + inline virtual wxString GetNodeName(long id) { return wxString(""); } + virtual void GetNodeSize(long id, long *x, long *y, wxDC& dc); + virtual void Draw(wxDC& dc); + virtual void DrawNodes(wxDC& dc); + virtual void DrawBranches(wxDC& dc); + virtual void DrawNode(long id, wxDC& dc); + virtual void DrawBranch(long from, long to, wxDC& dc); + + // Don't redefine + virtual void DoLayout(wxDC& dc, long topNode = -1); + + // Accessors -- don't redefine + inline void SetTopNode(long id) { m_parentNode = id; } + inline long GetTopNode(void) const { return m_parentNode; } + inline void SetSpacing(long x, long y) { m_xSpacing = x; m_ySpacing = y; } + inline long GetXSpacing(void) const { return m_xSpacing; } + inline long GetYSpacing(void) const { return m_ySpacing; } + inline void SetMargins(long x, long y) { m_leftMargin = x; m_topMargin = y; } + inline long GetTopMargin(void) const { return m_topMargin; } + inline long GetLeftMargin(void) const { return m_leftMargin; } + + inline bool GetOrientation(void) const { return m_orientation; } + inline void SetOrientation(bool or) { m_orientation = or; } + + private: + void CalcLayout(long node_id, int level, wxDC& dc); + +// Members + + protected: + long m_parentNode; + long m_lastY; + long m_lastX; + long m_xSpacing; + long m_ySpacing; + long m_topMargin; + long m_leftMargin; + bool m_orientation; // TRUE for top-to-bottom, FALSE for left-to-right +}; + +class wxStoredNode +{ + public: + wxString m_name; + long m_x, m_y; + long m_parentId; + bool m_active; + long m_clientData; +}; + +/* + * A version of wxTreeLayout with storage for nodes + */ + +class wxStoredTree: public wxTreeLayout +{ + DECLARE_DYNAMIC_CLASS(wxStoredTree) +public: + wxStoredTree(int noNodes = 200); + ~wxStoredTree(void); + void Initialize(int n); + + wxString HitTest(wxMouseEvent& event, wxDC& dc); + wxStoredNode* GetNode(long id) const; + inline int GetNumNodes() const { return m_maxNodes; }; + inline int GetNodeCount() const { return m_num; }; + + virtual void GetChildren(long id, wxList& list); + virtual long GetNextNode(long id); + virtual long GetNodeParent(long id); + virtual long GetNodeX(long id); + virtual long GetNodeY(long id); + virtual void SetNodeX(long id, long x); + virtual void SetNodeY(long id, long y); + virtual void SetNodeName(long id, const wxString& name); + virtual wxString GetNodeName(long id); + virtual void ActivateNode(long id, bool active); + virtual bool NodeActive(long id); + virtual void SetClientData(long id, long clientData); + virtual long GetClientData(long id) const; + + virtual long AddChild(const wxString& name, const wxString& parent = ""); + virtual long NameToId(const wxString& name); + +// Data members +private: + wxStoredNode* m_nodes; + int m_num; + int m_maxNodes; +}; + +#endif + // _WXTREE_H_ + -- 2.45.2