From: Julian Smart Date: Sun, 12 Jul 1998 09:21:16 +0000 (+0000) Subject: Added wxTreeLayout for wxWindows 2.0 X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/4414cc1db82e420d6d0b0bd3a3cf23be9a205d87 Added wxTreeLayout for wxWindows 2.0 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@232 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/utils/wxtree/docs/back.gif b/utils/wxtree/docs/back.gif new file mode 100644 index 0000000000..8a61076d3b Binary files /dev/null and b/utils/wxtree/docs/back.gif differ diff --git a/utils/wxtree/docs/books.gif b/utils/wxtree/docs/books.gif new file mode 100644 index 0000000000..26ff394df6 Binary files /dev/null and b/utils/wxtree/docs/books.gif differ 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 0000000000..3dddfa3dd5 Binary files /dev/null and b/utils/wxtree/docs/contents.gif differ diff --git a/utils/wxtree/docs/forward.gif b/utils/wxtree/docs/forward.gif new file mode 100644 index 0000000000..9c81e8c92f Binary files /dev/null and b/utils/wxtree/docs/forward.gif differ 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 0000000000..fd6103035f Binary files /dev/null and b/utils/wxtree/docs/treetst.bmp differ diff --git a/utils/wxtree/docs/treetst.gif b/utils/wxtree/docs/treetst.gif new file mode 100644 index 0000000000..e9f7841957 Binary files /dev/null and b/utils/wxtree/docs/treetst.gif differ diff --git a/utils/wxtree/docs/up.gif b/utils/wxtree/docs/up.gif new file mode 100644 index 0000000000..316d0d2a14 Binary files /dev/null and b/utils/wxtree/docs/up.gif differ diff --git a/utils/wxtree/docs/wxtree.tex b/utils/wxtree/docs/wxtree.tex new file mode 100644 index 0000000000..bf14b0dc75 --- /dev/null +++ b/utils/wxtree/docs/wxtree.tex @@ -0,0 +1,73 @@ +\documentstyle[a4,makeidx,verbatim,texhelp,fancyhea,mysober,mytitle]{report}% +\newcommand{\indexit}[1]{#1\index{#1}}% +\newcommand{\pipe}[0]{$\|$\ }% +\definecolour{black}{0}{0}{0}% +\definecolour{cyan}{0}{255}{255}% +\definecolour{green}{0}{255}{0}% +\definecolour{magenta}{255}{0}{255}% +\definecolour{red}{255}{0}{0}% +\definecolour{blue}{0}{0}{200}% +\definecolour{yellow}{255}{255}{0}% +\definecolour{white}{255}{255}{255}% +\input psbox.tex +\parskip=10pt% +\title{Manual for wxTreeLayout 2.0: a tree layout library for wxWindows} +\author{Julian Smart\\Anthemion Software} +\date{July 1998}% +\makeindex% +\begin{document}% +\maketitle + +\pagestyle{fancyplain} +\bibliographystyle{plain} +\pagenumbering{roman} +\setheader{{\it CONTENTS}}{}{}{}{}{{\it CONTENTS}} +\setfooter{\thepage}{}{}{}{}{\thepage} +\tableofcontents% + +\chapter{Introduction} +\pagenumbering{arabic}% +\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}% +\setfooter{\thepage}{}{}{}{}{\thepage} + +This manual describes a tree-drawing class library for wxWindows. It +provides layout of simple trees with one root node, drawn left-to-right, +with user-defined spacing between nodes. + +wxTreeLayout is an abstract class that must be subclassed. The programmer +defines various member functions which will access whatever data structures +are appropriate for the application, and wxTreeLayout uses these when laying +out the tree. + +wxStoredTree is a class derived from wxTreeLayout that may be used directly to +draw trees on a canvas. It supplies storage for the nodes, and draws +to a device context. + +\helponly{Below is the example tree generated by the program test.cc. + +\begin{figure} +$$\image{11cm;0cm}{treetst.ps}$$ +\caption{Example tree}\label{exampletree} +\end{figure} +} + +\chapter{Implementation} +\setheader{{\it CHAPTER \thechapter}}{}{}{}{}{{\it CHAPTER \thechapter}}% +\setfooter{\thepage}{}{}{}{}{\thepage} + +The algorithm is due to Gabriel Robins \cite{robins87}, a linear-time +algorithm originally implemented in LISP for AI applications. + +The original algorithm has been modified so that both X and Y planes +are calculated simultaneously, increasing efficiency slightly. The basic +code is only a page or so long. + +\input classes.tex +% +\bibliography{tree} + +\addcontentsline{toc}{chapter}{Index} +\setheader{{\it INDEX}}{}{}{}{}{{\it INDEX}}% +\setfooter{\thepage}{}{}{}{}{\thepage} +\printindex +\end{document} diff --git a/utils/wxtree/lib/dummy b/utils/wxtree/lib/dummy new file mode 100644 index 0000000000..bfdf726d49 --- /dev/null +++ b/utils/wxtree/lib/dummy @@ -0,0 +1 @@ +I'm just here to force the creation of a LIB directory. diff --git a/utils/wxtree/src/makefile.b32 b/utils/wxtree/src/makefile.b32 new file mode 100644 index 0000000000..764b5fd123 --- /dev/null +++ b/utils/wxtree/src/makefile.b32 @@ -0,0 +1,71 @@ +# +# File: makefile.b32 +# Author: Patrick Halke +# Created: 1995 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds 32bit wxtree library for 32-bit BC++ + +WXDIR = $(WXWIN) +!include $(WXDIR)\src\makeb32.env + +WXINC = $(WXDIR)\include +TARGET=test +TESTOBJECTS=test.obj +LIBTARGET= $(WXLIBDIR)\wxprop.lib +LIBS=$(WXLIB)\wx32.lib $(LIBTARGET) cw32 import32 + +!ifndef DEBUG +DEBUG=0 +!endif + +!if "$(FINAL)" == "0" +LINKFLAGS=/v /Tpe /L$(WXLIBDIR);$(BCCDIR)\lib +OPT = -Od +DEBUG_FLAGS= -v -DDEBUG=$(DEBUG) +!else +LINKFLAGS=/Tpe /L$(WXLIBDIR);$(BCCDIR)\lib +OPT = -O2 +DEBUG_FLAGS = -DDEBUG=$(DEBUG) +!endif + +CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) + +.$(SRCSUFF).obj: + bcc32 $(CPPFLAGS) -c {$< } + +.c.obj: + bcc32 $(CPPFLAGS) -P- -c {$< } + +OBJECTS = wxtree.obj + +all: $(LIBTARGET) + +$(LIBTARGET): $(OBJECTS) + erase $(LIBTARGET) + tlib $(LIBTARGET) /P32 @&&! ++$(OBJECTS:.obj =.obj +) +! + +wxtree.obj: wxtree.$(SRCSUFF) wxtree.h + +$(TARGET).exe: $(TESTOBJECTS) $(LIBTARGET) $(TARGET).def $(TARGET).res + tlink32 $(LINKFLAGS) @&&! +c0w32.obj $(TESTOBJECTS) +$(TARGET) +nul +$(LIBS) $(LIBTARGET) +$(TARGET).def +! + brc32 -K $(TARGET).res + +test.obj: test.$(SRCSUFF) test.h + +$(TARGET).res : $(TARGET).rc $(WXDIR)\include\wx\msw\wx.rc + brc32 -r /i$(BCCDIR)\include /i$(WXDIR)\include $(TARGET) + +clean: + -erase *.obj $(LIBTARGET) *.exe *.res *.map *.rws diff --git a/utils/wxtree/src/makefile.bcc b/utils/wxtree/src/makefile.bcc new file mode 100644 index 0000000000..df91939532 --- /dev/null +++ b/utils/wxtree/src/makefile.bcc @@ -0,0 +1,96 @@ +# +# File: makefile.bcc +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds tree library and example (DOS). + +!if "$(BCCDIR)" == "" +!error You must define the BCCDIR variable in autoexec.bat, e.g. BCCDIR=d:\bc4 +!endif + +!if "$(WXWIN)" == "" +!error You must define the WXWIN variable in autoexec.bat, e.g. WXWIN=c:\wx +!endif + +# Change WXDIR to wherever wxWindows is found +WXDIR = $(WXWIN) +!include $(WXDIR)\src\makebcc.env + +WXLIB = $(WXDIR)\lib\wx.lib +WXINC = $(WXDIR)\include +CFG=$(WXWIN)\src\wxwin.cfg + +TREEDIR = $(WXDIR)\utils\wxtree +TREELIB = $(TREEDIR)\lib\wxtree.lib + +WXHELPDIR = $(WXDIR)\utils\wxhelp +TEX2RTFDIR = $(WXDIR)\utils\tex2rtf +DOCDIR = $(WXHELPDIR)\docs + +# Default is to output RTF for WinHelp +!ifndef WINHELP +WINHELP=-winhelp +!endif + +INC=/I$(WXDIR)\include\base /I$(WXDIR)\include\msw + +LIBS=$(WXLIB) $(TREELIB) mathwl cwl import mathwl + +!ifndef FINAL +FINAL=0 +!endif + +!if "$(FINAL)" == "0" +LINKFLAGS=/v/Vt /Twe /L$(WXDIR)\lib;$(BCCDIR)\lib +OPT = -Od +DEBUG_FLAGS= -v +!else +LINKFLAGS=/Twe /L$(WXDIR)\lib;$(BCCDIR)\lib +OPT = -O2 +DEBUG_FLAGS= +!endif +CPPFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) +CFLAGS=$(DEBUG_FLAGS) $(OPT) @$(CFG) + +HEADERS = wxtree.h +SOURCES = wxtree.$(SRCSUFF) +OBJECTS = wxtree.obj + +all: $(TREELIB) + +.$(SRCSUFF).obj: + bcc $(CPPFLAGS) $(INC) -c {$< } + +$(TREELIB): $(OBJECTS) + erase $(TREELIB) + tlib /P128 @&&! +$(TREELIB) & ++$(OBJECTS:.obj =.obj +) +! + +test.obj: test.$(SRCSUFF) + +test.res : test.rc $(WXDIR)\include\msw\wx.rc + rc /i$(BCCDIR)\include /i$(WXDIR)\include\msw /i$(WXDIR)\contrib\fafa -r test + +test.exe: test.obj test.def test.res $(TREELIB) + tlink $(LINKFLAGS) @&&! +c0wl.obj test.obj +test +nul +$(LIBS) +test.def +! + rc -K test.res + +clean: + -erase *.obj + -erase *.exe + -erase *.res + -erase ..\lib\*.lib + diff --git a/utils/wxtree/src/makefile.dos b/utils/wxtree/src/makefile.dos new file mode 100644 index 0000000000..c78d0a7cfb --- /dev/null +++ b/utils/wxtree/src/makefile.dos @@ -0,0 +1,118 @@ +# +# File: makefile.dos +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds tree library and example (DOS). +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +# Set WXDIR for your system +WXDIR = $(WXWIN) + +!include $(WXDIR)\src\makemsc.env + +TREEDIR = $(WXDIR)\utils\wxtree +TREELIB = $(TREEDIR)\lib\wxtree.lib +DOCDIR = $(TREEDIR)\docs +THISDIR = $(TREEDIR)\src +EXTRALIBS = $(TREELIB) +INC=-I$(WXDIR)\include\base -I$(WXDIR)\include\msw +DUMMY=$(WXDIR)\src\msw\dummy.obj + +# Default is to output RTF for WinHelp +!ifndef RTFSTYLE +RTFSTYLE=-winhelp +!endif + +HEADERS = wxtree.h +SOURCES = wxtree.$(SRCSUFF) +OBJECTS = wxtree.obj + +all: $(TREELIB) + +test: test.exe + +wx: + cd $(WXDIR)\src\msw + nmake -f makefile.dos FINAL=$(FINAL) + cd $(TREEDIR)\src + +wxclean: + cd $(WXDIR)\src\msw + nmake -f makefile.dos clean + cd $(TREEDIR)\src + +$(TREELIB): $(OBJECTS) + -erase $(TREELIB) + lib /PAGESIZE:128 @<< +$(TREELIB) +y +$(OBJECTS) +nul +; +<< + +test.exe: $(DUMMY) $(WXLIB) $(TREELIB) test.obj test.def test.res + link $(LINKFLAGS) @<< +$(DUMMY) test.obj, +test, +NUL, +$(LIBS), +test.def +; +<< + rc -31 -K test.res + +wxtree.obj: wxtree.h wxtree.$(SRCSUFF) $(DUMMY) + cl @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +test.obj: test.h wxtree.h test.$(SRCSUFF) $(DUMMY) + cl @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +test.res : test.rc $(WXDIR)\include\msw\wx.rc + rc -r /dFAFA_LIB /i$(WXDIR)\contrib\fafa /i$(WXDIR)\include\msw test + +# Making documents +docs: hlp xlp +hlp: $(DOCDIR)/wxtree.hlp +xlp: $(DOCDIR)/wxtree.xlp +rtf: $(DOCDIR)/wxtree.rtf + +$(DOCDIR)/wxtree.hlp: $(DOCDIR)/wxtree.rtf $(DOCDIR)/wxtree.hpj + cd $(DOCDIR) + -erase wxtree.ph + hc wxtree + cd $(THISDIR) + +$(DOCDIR)/wxtree.rtf: $(DOCDIR)/manual.tex $(DOCDIR)/classes.tex + cd $(DOCDIR) + -wx /W tex2rtf $(DOCDIR)\manual.tex $(DOCDIR)\wxtree.rtf -twice $(RTFSTYLE) + cd $(THISDIR) + +$(DOCDIR)/wxtree.xlp: $(DOCDIR)/manual.tex $(DOCDIR)/classes.tex + cd $(DOCDIR) + -wx /W tex2rtf $(DOCDIR)\manual.tex $(DOCDIR)\wxtree.xlp -twice -xlp + cd $(THISDIR) + +cleanrtf: + cd $(DOCDIR) + -erase *.rtf + cd $(THISDIR) + +clean: + -erase *.obj + -erase *.sbr + -erase *.exe + -erase *.res + -erase *.map + -erase *.pdb + -erase $(TREELIB) diff --git a/utils/wxtree/src/makefile.g95 b/utils/wxtree/src/makefile.g95 new file mode 100644 index 0000000000..a7b7f866c1 --- /dev/null +++ b/utils/wxtree/src/makefile.g95 @@ -0,0 +1,48 @@ +# +# File: makefile.g95 +# Author: Julian Smart +# Created: 1996 +# +# "%W% %G%" +# +# Makefile : Builds wxTree library and example under GNU-WIN32 +# +WXDIR = ../../.. +include $(WXDIR)/src/makeg95.env + +PROPDIR = $(WXDIR)/utils/wxtree +TREELIB = $(PROPDIR)/lib/$(LIBPREFIX)wxtree.$(LIBSUFF) +THISDIR = $(PROPDIR)/src + +OBJECTS = $(OBJDIR)/wxtree.$(OBJSUFF) +TESTOBJECTS = $(OBJDIR)/test.$(OBJSUFF) $(OBJDIR)/test_resources.$(OBJSUFF) + +LDFLAGS = -Wl,--subsystem,windows -mwindows -L$(WXDIR)/lib -L../lib +LDLIBS=-lwxtree $(LIBS) + +all: $(OBJDIR) $(TREELIB) + +test: $(OBJDIR) test.exe + +$(OBJDIR): + mkdir $(OBJDIR) + +$(TREELIB): $(OBJECTS) + rm -f $@ + ar $(AROPTIONS) $@ $(OBJECTS) + $(RANLIB) $@ + +$(OBJDIR)/test.$(OBJSUFF): test.h test.$(SRCSUFF) $(TREELIB) + $(CC) -c $(CPPFLAGS) -o $@ test.$(SRCSUFF) + +test.exe: $(TESTOBJECTS) + $(CC) $(LDFLAGS) -o test$(GUISUFFIX)$(EXESUFF) $(TESTOBJECTS) $(LDLIBS) + +$(OBJDIR)/wxtree.$(OBJSUFF): wxtree.h wxtree.$(SRCSUFF) + $(CC) -c $(CPPFLAGS) -o $@ wxtree.$(SRCSUFF) + +$(OBJDIR)/test_resources.o: test.rc + $(RESCOMP) -i test.rc -o $(OBJDIR)/test_resources.o $(RESFLAGS) + +clean: + rm -f *.$(OBJSUFF) $(TREELIB) objects/test.o *.exe *.res *.map *.rsc diff --git a/utils/wxtree/src/makefile.nt b/utils/wxtree/src/makefile.nt new file mode 100644 index 0000000000..5e815db012 --- /dev/null +++ b/utils/wxtree/src/makefile.nt @@ -0,0 +1,133 @@ +# +# File: makefile.nt +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile : Builds wxTree class library (MS VC++). +# Use FINAL=1 argument to nmake to build final version with no debugging +# info + +# Set WXDIR for your system +WXDIR = $(WXWIN) +TREEDIR = $(WXDIR)\utils\wxtree +THISDIR = $(WXDIR)\utils\wxtree\src +EXTRALIBS=$(TREEDIR)\lib\wxtree.lib +DOCDIR=$(WXDIR)\docs +LOCALDOCDIR=$(WXDIR)\utils\wxtree\docs + +!include $(WXDIR)\src\ntwxwin.mak + +PROGRAM=test + +OBJECTS = wxtree.obj +PROGOBJECTS = $(PROGRAM).obj +LIBTARGET=$(TREEDIR)\lib\wxtree.lib + +all: $(LIBTARGET) + +$(PROGRAM): $(PROGRAM).exe + +wx: + cd $(WXDIR)\src\msw + nmake -f makefile.nt FINAL=$(FINAL) + cd $(THISDIR) + +wxclean: + cd $(WXDIR)\src\msw + nmake -f makefile.nt clean + cd $(THISDIR) + +$(LIBTARGET): $(OBJECTS) + -erase $(LIBTARGET) + $(implib) @<< +-out:$(LIBTARGET) +-machine:$(CPU) +$(OBJECTS) +<< + +$(PROGRAM).exe: $(DUMMYOBJ) $(WXLIB) $(PROGOBJECTS) $(LIBTARGET) $(PROGRAM).res + $(link) @<< +-out:$(PROGRAM).exe +$(LINKFLAGS) +$(DUMMYOBJ) $(PROGOBJECTS) $(PROGRAM).res +$(LIBS) +<< + +wxtree.obj: wxtree.h wxtree.$(SRCSUFF) $(DUMMYOBJ) + $(cc) @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +$(PROGRAM).obj: $(PROGRAM).h $(PROGRAM).$(SRCSUFF) $(DUMMYOBJ) + $(cc) @<< +$(CPPFLAGS) /c /Tp $*.$(SRCSUFF) +<< + +$(PROGRAM).res : $(PROGRAM).rc $(WXDIR)\include\wx\msw\wx.rc + $(rc) -r /i$(WXDIR)\include -fo$@ $(PROGRAM).rc + + +clean: + -erase *.obj + -erase *.sbr + -erase *.exe + -erase *.res + -erase *.map + -erase *.pdb + -erase $(LIBTARGET) + +DOCSOURCES=$(LOCALDOCDIR)\wxtree.tex $(LOCALDOCDIR)\classes.tex + +html: $(DOCDIR)\html\wxtree\tree.htm +hlp: $(DOCDIR)\winhelp\wxtree.hlp +pdfrtf: $(DOCDIR)\pdf\wxtree.rtf +ps: $(WXDIR)\docs\ps\wxtree.ps + +$(DOCDIR)\winhelp\wxtree.hlp: $(LOCALDOCDIR)\wxtree.rtf $(LOCALDOCDIR)\wxtree.hpj + cd $(LOCALDOCDIR) + -erase wxtree.ph + hc wxtree + move wxtree.hlp $(DOCDIR)\winhelp\wxtree.hlp + move wxtree.cnt $(DOCDIR)\winhelp\wxtree.cnt + cd $(THISDIR) + +$(LOCALDOCDIR)\wxtree.rtf: $(DOCSOURCES) + cd $(LOCALDOCDIR) + -start /w tex2rtf $(LOCALDOCDIR)\wxtree.tex $(LOCALDOCDIR)\wxtree.rtf -twice -winhelp + cd $(THISDIR) + +$(DOCDIR)\pdf\wxtree.rtf: $(DOCSOURCES) + cd $(LOCALDOCDIR) + -copy *.bmp $(DOCDIR)\pdf + -start /w tex2rtf $(LOCALDOCDIR)\wxtree.tex $(DOCDIR)\pdf\wxtree.rtf -twice -rtf + cd $(THISDIR) + +$(DOCDIR)\html\wxtree\tree.htm: $(DOCSOURCES) + cd $(LOCALDOCDIR) + -mkdir $(DOCDIR)\html\wxtree + -start /w tex2rtf $(LOCALDOCDIR)\wxtree.tex $(DOCDIR)\html\wxtree\tree.htm -twice -html + -erase $(DOCDIR)\html\wxtree\*.con + -erase $(DOCDIR)\html\wxtree\*.ref + cd $(THISDIR) + +$(LOCALDOCDIR)\wxtree.dvi: $(DOCSOURCES) + cd $(LOCALDOCDIR) + -latex wxtree + -latex wxtree + -makeindx wxtree + -bibtex wxtree + -latex wxtree + -latex wxtree + cd $(THISDIR) + +$(WXDIR)\docs\ps\wxtree.ps: $(LOCALDOCDIR)\wxtree.dvi + cd $(LOCALDOCDIR) + -dvips32 -o wxtree.ps wxtree + move wxtree.ps $(WXDIR)\docs\ps\wxtree.ps + cd $(THISDIR) + + diff --git a/utils/wxtree/src/makefile.sc b/utils/wxtree/src/makefile.sc new file mode 100644 index 0000000000..a03ad23365 --- /dev/null +++ b/utils/wxtree/src/makefile.sc @@ -0,0 +1,73 @@ +# Symantec C++ makefile for the tree library +# NOTE that peripheral libraries are now dealt in main wxWindows makefile. + +WXDIR = $(WXWIN) + +WXLIB = $(WXDIR)\lib\wx.lib +INCDIR = $(WXDIR)\include +MSWINC = $(INCDIR)\msw +BASEINC = $(INCDIR)\base + +include $(WXDIR)\src\makesc.env + +TREEDIR = $(WXDIR)\utils\wxtree +TREEINC = $(TREEDIR)\src +TREELIB = $(TREEDIR)\lib\wxtree.lib + +DOCDIR = $(TREEDIR)\docs +SRCDIR = $(TREEDIR)\src + +# Default is to output RTF for WinHelp +WINHELP=-winhelp + +INCLUDE=$(BASEINC);$(MSWINC) + +LIBS=$(TREELIB) $(WXLIB) libw.lib commdlg.lib shell.lib + +.$(SRCSUFF).obj: + *$(CC) -c $(CFLAGS) -I$(INCLUDE) $< + +.rc.res: + *$(RC) -r -I$(INCLUDE) $< + +$(TREELIB): wxtree.obj + -del $(TREELIB) + *lib $(TREELIB) y wxtree.obj, nul; + +wxtree.obj: wxtree.h wxtree.$(SRCSUFF) + +test.exe: test.obj test.def test.res + *$(CC) $(LDFLAGS) -o$@ test.obj test.def $(LIBS) + *$(RC) -k test.res + +test.obj: test.h wxtree.h test.$(SRCSUFF) + +# Making documents +docs: hlp xlp +hlp: $(DOCDIR)/wxtree.hlp +xlp: $(DOCDIR)/wxtree.xlp +rtf: $(DOCDIR)/wxtree.rtf + +$(DOCDIR)/wxtree.hlp: $(DOCDIR)/wxtree.rtf $(DOCDIR)/wxtree.hpj + cd $(DOCDIR) + -erase wxtree.ph + hc wxtree + cd $(SRCDIR) + +$(DOCDIR)/wxtree.rtf: $(DOCDIR)/manual.tex $(DOCDIR)/classes.tex + cd $(DOCDIR) + -wx tex2rtf $(DOCDIR)\manual.tex $(DOCDIR)\wxtree.rtf -twice -winhelp + cd $(SRCDIR) + +$(DOCDIR)/wxtree.xlp: $(DOCDIR)/manual.tex $(DOCDIR)/classes.tex + cd $(DOCDIR) + -wx tex2rtf $(DOCDIR)\manual.tex $(DOCDIR)\wxtree.xlp -twice -xlp + cd $(SRCDIR) + +clean: + -del *.obj + -del *.exe + -del *.res + -del *.map + -del *.rws + -del $(TREELIB) diff --git a/utils/wxtree/src/makefile.unx b/utils/wxtree/src/makefile.unx new file mode 100644 index 0000000000..0d0d64162e --- /dev/null +++ b/utils/wxtree/src/makefile.unx @@ -0,0 +1,133 @@ +# +# File: makefile.unx +# Author: Julian Smart +# Created: 1993 +# Updated: +# Copyright: (c) 1993, AIAI, University of Edinburgh +# +# "%W% %G%" +# +# Makefile for tree library and example (UNIX). +# Change the WXDIR directory, and CPPFLAGS and LDFLAGS, for your system. + +WXDIR = ../../.. + +# All common UNIX compiler flags and options are now in +# this central makefile. +include $(WXDIR)/src/make.env + +TREEDIR = $(WXDIR)/utils/wxtree +TREEINC = $(TREEDIR)/src +TREELIB = $(TREEDIR)/lib/libwxtree$(GUISUFFIX).a + +SOURCES = tree.$(SRCSUFF) +HEADERS = tree.h +OBJECTS = $(OBJDIR)/wxtree.$(OBJSUFF) + +TESTOBJECTS = $(OBJDIR)/test.$(OBJSUFF) +TESTPROGRAM = $(TREEDIR)/src/test$(GUISUFFIX) + +DOCUTILSDIR = $(WXDIR)/utils/tex2rtf/src + +LDFLAGS = $(XLIB) -L$(WXDIR)/lib -L$(TREEDIR)/lib + +XVIEWLDLIBS = -lwxtree_ol -lwx_ol -lxview -lolgx -lX11 -lm $(COMPLIBS) +MOTIFLDLIBS = -lwxtree_motif -lwx_motif -lXm -lXmu -lXt -lX11 -lm $(COMPLIBS) +HPLDLIBS = -lwxtree_hp -lwx_hp -lXm -lXmu -lXt -lX11 -lm $(COMPLIBS) +# Default +LDLIBS=$(XVIEWLDLIBS) + +.SUFFIXES: + +all: $(OBJDIR) $(TREELIB) + +demo: $(TESTPROGRAM) + +$(TREELIB): $(OBJECTS) + rm -f $@ + ar $(AROPTIONS) $@ $(OBJECTS) + $(RANLIB) $@ + +wxmotif: + cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx motif DEBUG='$(DEBUG)' + +wxxview: + cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx xview DEBUG='$(DEBUG)' + +motif: + cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx motif OPT='$(OPT)' DEBUG='$(DEBUG)' + $(MAKE) -f makefile.unx GUISUFFIX=_motif GUI=-Dwx_motif GUISUFFIX=_motif DEBUG='$(DEBUG)' OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' XVIEW_LINK= + +xview: + cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx xview OPT='$(OPT)' DEBUG='$(DEBUG)' + $(MAKE) -f makefile.unx GUI=-Dwx_xview GUISUFFIX=_ol OPT='$(OPT)' DEBUG='$(DEBUG)' + +demo_motif: + $(MAKE) -f makefile.unx all test_motif GUI=-Dwx_motif GUISUFFIX=_motif DEBUG='$(DEBUG)' OPT='$(OPT)' LDLIBS='$(MOTIFLDLIBS)' XVIEW_LINK= + +demo_ol: + cd $(WXDIR)/src/x; $(MAKE) -f makefile.unx xview OPT='$(OPT)' DEBUG='$(DEBUG)' + $(MAKE) -f makefile.unx all test_ol GUI=-Dwx_xview OPT='$(OPT)' DEBUG='$(DEBUG)' + +hp: + $(MAKE) -f makefile.unx GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='$(DEBUG)' DEBUGFLAGS='-g' OPT='' WARN='-w' \ + XINCLUDE='$(HPXINCLUDE)' XLIB='$(HPXLIB)' XVIEW_LINK='' CCLEX='cc' \ + LDLIBS='$(HPLDLIBS)' + +demo_hp: + $(MAKE) -f makefile.unx all test_hp GUI=-Dwx_motif GUISUFFIX=_hp CC=CC DEBUG='$(DEBUG)' DEBUGFLAGS='-g' OPT='' WARN='-w' \ + XINCLUDE='$(HPXINCLUDE)' XLIB='$(HPXLIB)' XVIEW_LINK='' CCLEX='cc' \ + LDLIBS='$(HPLDLIBS)' + +$(OBJDIR): + mkdir $(OBJDIR) + +test$(GUISUFFIX): $(OBJDIR)/test.$(OBJSUFF) $(WXLIB) $(TREELIB) + $(CC) $(LDFLAGS) -o test$(GUISUFFIX) $(OBJDIR)/test.$(OBJSUFF) $(XVIEW_LINK) $(LDLIBS) + +$(OBJDIR)/wxtree.$(OBJSUFF): wxtree.$(SRCSUFF) wxtree.h + $(CC) -c $(CPPFLAGS) -o $@ wxtree.$(SRCSUFF) + +$(OBJDIR)/test.$(OBJSUFF): test.$(SRCSUFF) test.h wxtree.h + $(CC) -c $(CPPFLAGS) -o $@ test.$(SRCSUFF) + +HTMLDIR=/home/hardy/html/wx/manuals +docs: ps xlp +ps: $(TREEDIR)/docs/manual.ps +xlp: $(TREEDIR)/docs/wxtree.xlp +html: $(HTMLDIR)/wxtree/wxtree_contents.html + +$(TREEDIR)/docs/wxtree.xlp: $(TREEDIR)/docs/manual.tex $(TREEDIR)/docs/classes.tex + cd ../docs; tex2rtf manual.tex tmp.xlp -xlp -twice + sed -e "s/WXHELPCONTENTS/wxTree Manual/g" < $(TREEDIR)/docs/tmp.xlp > $(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 0000000000..2310c5d275 Binary files /dev/null and b/utils/wxtree/src/mondrian.ico differ diff --git a/utils/wxtree/src/test.cpp b/utils/wxtree/src/test.cpp new file mode 100644 index 0000000000..7fa625668f --- /dev/null +++ b/utils/wxtree/src/test.cpp @@ -0,0 +1,200 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: test.cpp +// Purpose: wxTreeLayout sample +// Author: Julian Smart +// Modified by: +// Created: 7/4/98 +// RCS-ID: $Id$ +// Copyright: (c) 1998 Julian Smart +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +// For compilers that support precompilation, includes "wx.h". +#include + +#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_ +