%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PiCTeX-Makros zum Satz von Verzeichnisb"aumen %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Syntax (EBNF-Derivat): %%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% <baum> :=               %
%%                        %
% \baum <name> structure  %
%  <struktur>             %
% / at x y                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% <struktur> :=  %
%%               %
% \ordner <name> %
%  <struktur>    %
% \endordner     %
%%               %
% |              %
%%               %
% \datei <name>  %
% <struktur>     %
%%               %
% | <empty>      %
%%%%%%%%%%%%%%%%%%
% <leer> :=      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% <name> := <alles was in einer \mbox stehen kann, %
%            also z.B. kein einfacher _ \ % etc. > %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newdimen\OAx \newdimen\OAy \newbox\Obox \newdimen\GY
\newdimen\Oleng \newdimen\GX \newdimen\Odown

\newif\ifvariing \variingfalse
\def\VariablerBaum{\variingtrue}
\def\FesterBaum{\variingfalse}

\def\Osep{0.5\unitlength}
\def\Oright{20\unitlength}
\def\Oinsert{15\unitlength}

\def\Ostrut{\vphantom{/}}
\def\Bfont{\footnotesize\bf\Ostrut}
\def\Ofont{\footnotesize\bf\Ostrut}
\def\Dfont{\footnotesize\fontseries{m}\fontshape{n}\selectfont\Ostrut}
\def\Drule{.4pt}
\def\Orule{1pt}
\def\Brule{1pt}

\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em}\kern.06em}

\def\baum #1 structure #2/ at #3 #4
 {\put {\beginpicture
 \fboxsep=1pt
 \fboxrule=\Orule
 \unitlength=1mm
 \OAx=0mm \OAy=0mm
 \setdimensionmode
 \setbox\Obox\hbox{\fboxrule=\Brule\fbox{\Bfont#1}}%
\ifvariing
 \Odown=0pt
\else
 \Odown=\ht\Obox \advance\Odown by \dp\Obox
\fi
 \advance\Odown by \Osep
 \Oleng=\Odown
 \put {\box\Obox} [b] at 0mm 0mm
 #2
 \endpicture} at #3 #4
}

\def\ordner #1
 {\GY=\OAy
  \begingroup
  \setbox\Obox\hbox{\fbox{\Ofont#1}}%
   \global\GX=-\dp\Obox \global\advance\GX by -\ht\Obox
\ifvariing
  \Odown=-.5\GX \advance\Odown by \Osep
   \advance\Oleng by -.5\GX
\fi
   \global\advance\OAy by -\Odown
   \put {\vrule height\Oleng width\linethickness depth0pt}
        [bl] at {\OAx} {\OAy}
  \put {\vrule height\linethickness width\Oinsert depth0pt}
        [lb] at {\OAx} {\OAy}
  \put {\box\Obox}
         <\Oinsert,0mm> [l] at {\OAx} {\OAy}
\ifvariing
  \global\advance\OAy by .5\GX
\fi
   \Oleng=\Odown
   \advance\OAx by \Oright
   \advance\Oleng by .5\GX
}

\catcode`\!=11
\def\endordner{%
  \global\!Xleft=\!xleft \global\!Xright=\!xright
  \global\!Ybot=\!ybot \global\!Ytop=\!ytop
  \endgroup
  \!xleft=\!Xleft \!xright=\!Xright
  \!ybot=\!Ybot \!ytop=\!Ytop
  \Oleng=-\OAy \advance\Oleng by \GY
\ifvariing
  \advance\Oleng by .5\GX
\fi
}

\catcode`\!=12

\def\datei #1
 {\fboxrule=\Drule
  \ordner{\Dfont#1} \endordner
   \fboxrule=\Orule}


