%D \module
%D   [      file=s-mod-02,
%D        version=very-old,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Documentation Screen Environment,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D This module looks like crap, is not documented, will
%D change, and used to be called modu-*.tex.

% Macro's

\usemodule[mod-00]

% todo: internationalize + setups

\setuphead[paragraaf][expansie=commando]

\def\complexmodule[#1]% redefined
  {\startglobal % i.v.m. \bgroup in \startdocumentation
   \getparameters[Module][#1]
   \stopglobal  % i.v.m. \bgroup in \startdocumentation
   \paragraaf{\Modulesubtitle}
   \SchrijfLijstenWeg}

\def\stopmodule% redefined
  {\page
   \determineregistercharacteristics
     [index]
     [criterium=paragraaf]
   \ifutilitydone
     \pagereference
       [index]
     \placeregister
       [index]
       [balanceren=ja,
        aanduiding=nee,
        criterium=paragraaf]
   \fi}

\let\StelLijstenSamen=\relax

\newcounter\ModuleNumber

\newwrite\BatchFile \openout\BatchFile=\jobname.bat

\def\WriteBatchFile
  {\doglobal\increment\ModuleNumber
   \immediate\write\BatchFile{call modu-run \FileName\space \ModuleNumber}}

\newif\ifProcessingPublic

\def\SchrijfLijstenWeg
  {\writetolist[FileNames] {}{\FileName}
   \writetolist[GroupItems]{}{\GroupItem}}

\def\moduletitel{}

\def\TypeZeroModule#1%
  {\paragraaf{[to be extracted: #1]}
   {\em This module is not yet split off.}
   \SchrijfLijstenWeg}

\def\TypeOneModule#1%
  {\paragraaf{[to be documented: #1]}
   {\em This module is not yet fully documented.}
   \SchrijfLijstenWeg}

\def\TypeTwoModule#1%
  {\ifProcessingPublic
     \readfile{#1.ted}{}{}%
     \WriteBatchFile
   \else
     \paragraaf{[not yet public: #1]}
     {\em This module is documented but not yet public.}
     \SchrijfLijstenWeg
   \fi}

\def\TypeThreeModule#1%
  {\readfile{#1.ted}{}{}%
   \WriteBatchFile}

\def\verwerkmodule#1#2%
  {\page
   \bgroup
   \def\FileName{#1}
   \setupreferencing[prefix=#1]
   \useexternaldocument[PaperVersion][#1][]
   \aftersplitstring#1\at-\to\GroupItem
   \StelLijstenSamen
   \ifcase#2
     \TypeZeroModule{#1}
   \or
     \TypeOneModule{#1}
   \or
     \TypeTwoModule{#1}  % \TypeThreeModule{#1}
   \or
     \TypeThreeModule{#1}
   \fi
   \page
   \setupreferencing[prefix=]
   \egroup}

\def\ModuleGroep#1#2%
  {\page
   \let\Modulefile=\empty
   \setupreferencing[prefix=#1]
   \def\FileGroup{#1}
   \writetolist[FileGroups]{}{\FileGroup}
   \hoofdstuk[inhoud]{#2}
   \MaakLijstMetItems
   \MaakLijstMetNames
   \MaakLijstMetGroups
   \plaatsinhoud[criterium=hoofdstuk,niveau=paragraaf]}

% Layout

\setupbodyfont
  [9pt,ams]

\mainlanguage
  [en]

\setuppapersize
  [S6][S6]

\setuplayout
  [rugwit=72.5pt,
   linkermarge=50pt,
   linkermargeafstand=12.5pt,
   rechtermarge=0pt,
   rechterrand=80pt,
   rechterrandafstand=10pt,
   linkerrand=0pt,
   breedte=430pt,
   kopwit=10pt,
   hoofd=0pt,
   voet=30pt,
   onderafstand=10pt,
   onder=15pt,
   hoogte=410pt,
   letter=\ss]

\setuptyping
  [palet=colorpretty]

\setupsetup
  [verwijzing=3]

\definecolor [AchtergrondKleur] [s=.6]
\definecolor [ButtonKleur]      [r=.2,g=.2,b=.6]
\definecolor [TekstKleur]       [r=.6,g=.2,b=.2]

\definecolor [colorprettyone]   [r=.6,g=.0,b=.0]  % red
\definecolor [colorprettytwo]   [r=.0,g=.6,b=.0]  % green
\definecolor [colorprettythree] [r=.0,g=.0,b=.6]  % blue
\definecolor [colorprettyfour]  [r=.6,g=.6,b=.0]  % yellow

\setupinteraction
  [status=start,
   pagina=ja,
   contrastkleur=,
   menu=aan,
   kleur=]

\setupbackgrounds
  [pagina]
  [achtergrond=kleur,
   achtergrondkleur=AchtergrondKleur,
   offset=2.5pt]  % this offset influences the menus!

\setupbackgrounds
  [tekst,voet]
  [tekst,linkermarge]
  [achtergrond=kleur,
   achtergrondkleur=wit]

\setupsubpagenumber
  [wijze=perparagraaf,
   status=start]

\setupinteractionbar
  [kader=uit,
   offset=0pt,
   hoogte=passend]

\setupwhitespace
  [groot]

\setuptyping
  [typen]
  [optie=kleur]

\setuptyping
  [definition]
  [optie=kleur]

\setuptyping
  [file]
  [optie=kleur]

\setuppagenumbering
  [variant=enkelzijdig,
   wijze=perparagraaf,
   status=geen]

\setupinmargin
  [plaats=links]

\setupheads
  [variant=inmarge]

\setuphead
  [hoofdstuk]
  [letter=\ssc,
   pagina=rechts]

\setuphead
  [paragraaf]
  [letter=\ssb,
   pagina=rechts]

\setuplist
  [hoofdstuk]
  [letter=vet,
   na=\blank]

\setupcontent
  [breedte=2em]

\setupindex
  [balanceren=ja,
   aanduiding=nee]

\setupcolors
  [status=start]

\def\TitelBlad#1%
  {\startstandardmakeup
     \definefont[GrootFont] [SansBold at 72pt]
     \definefont[MiddelFont][Sans at 32pt]
     \definefont[KleinFont] [Sans at 24pt]
     \startcolor[AchtergrondKleur]
     \vskip12pt
     \midaligned{\GrootFont\setstrut\strut    Con\TeX t}
     \vskip24pt
     \midaligned{\MiddelFont\setstrut\strut   #1}
     \vskip24pt
     \midaligned{\KleinFont\setstrut\strut    Hans Hagen}
     \vfilll
     \midaligned{\KleinFont\setstrut\strut    PRAGMA ADE}
     \vskip24pt
     \midaligned{\KleinFont\setstrut\strut    www.pragma-ade.nl --- \currentdate}
     \vskip12pt
     \stopcolor
   \stopstandardmakeup}

\def\ColofonBlad%
  {\startmode[atpragma]
   \page
   \bgroup
     \def\PragmaHoogte {\makeupheight}
     \def\PragmaBreedte{\textwidth}
     \def\PragmaKopwit {\topspace}
     \def\PragmaRugwit {\rugwit}
     \def\PragmaMarge  {0pt}
     \PragmaLijnentrue
     \PlaatsPragmaLogo[ADE]
     \vfill
     \startnarrower[3*midden]
     This is the official documentation of \CONTEXT\ version
     \referraldate, a \TEX\ macropackage developed by J.~Hagen
     \& A.F.~Otten, who both hold the copyrights.
     \stopnarrower
     \vfill
     \page
   \egroup
   \stopmode}

\newbox\LijstMetItems
\newbox\LijstMetGroups
\newbox\LijstMetNames

\definelist[FileNames]   \def\FileName  {}
\definelist[FileGroups]  \def\FileGroup {}
\definelist[GroupItems]  \def\GroupItem {}

\setuplist
  [FileNames,FileGroups,FileGroups]
  [expansie=ja,
   paginanummer=nee,
   letter=\ss\bf]

\setuplist
  [FileNames]
  [commando=\FileNameEntry,
   na=\endgraf,
   variant=geen]

\setuplist
  [FileGroups]
  [commando=\FileGroupEntry,
   na=\hss,
   variant=geen]

\def\FileNameEntry#1#2#3%
  {\strut\hbox{#2}\endgraf}

\def\FileGroupEntry#1#2#3%
  {\strut#2\endgraf}

\def\MaakLijstMetItems
  {\setbox\LijstMetItems=\vbox
     {\ss\bf
      \placelist[GroupItems][kleur=ButtonKleur,contrastkleur=wit,criterium=hoofdstuk]}}

\def\MaakLijstMetNames
  {\setbox\LijstMetNames=\vbox
     {\hsize\rightedgewidth
      \ss\bf\stelinterliniein
      \startsimplecolumns[afstand=10pt]
        \placelist[FileNames][kleur=ButtonKleur,contrastkleur=wit,criterium=hoofdstuk]
      \stopsimplecolumns}}

\def\MaakLijstMetGroups
  {\setbox\LijstMetGroups=\hbox to \textwidth
     {\ss\bf
      \setupinteraction[kleur=ButtonKleur]%
      \placelist[FileGroups][kleur=ButtonKleur,contrastkleur=wit,criterium=alles]\unskip\unskip}}

\setbox\LijstMetGroups=\hbox{}

%\setupfootertexts
%  [rand]
%  []
%  [{\interactiebalk[variant=g]}]

\setupinteractionmenu
  [rechts,onder]
  [status=start,
   kader=uit,
   kleur=AchtergrondKleur,
   contrastkleur=wit,
   letter=\ss\bf,
   hoogte=15pt,
   offset=0pt,
   tussen=\vskip5pt,
   achtergrond=kleur,
   achtergrondkleur=ButtonKleur]

\startinteractionmenu[rechts]
  \boxofsize \vbox \textheight \voetafstand \voethoogte 5pt
    \bgroup
      \copy\LijstMetNames
      \vfill
      \but [\FileGroup:inhoud]   local contents \\
      \but [\FileName:index]     local register \\
      \but [PaperVersion::begin] paper version  \\
      \but [inhoud]              main contents  \\
      \but [index]               main register  \\
      \but [VorigeSprong]        previous jump  \\
      \but [VerlaatViewer]       close document \\
      \unskip
    \egroup
\stopinteractionmenu

\startinteractionmenu[onder]
  \unhcopy\LijstMetGroups
\stopinteractionmenu

\def\plaatsmoduleregister
  {\startbackmatter
   \setupsubpagenumber[reset]
   \title[-:index]{Register}
   \placeregister[index]
   \stopbackmatter}

\def\plaatsmoduleinhoud
  {\startfrontmatter
   \title[-:inhoud]{Contents}
   \setupinteractionbar[status=stop]
   \placecontent[criterium=tekst,niveau=hoofdstuk]
   \stopfrontmatter}

\setupcontent
  [paginanummer=nee,
   niveau=hoofdstuk,
   interactie=alles,
   letter=,
   voor=,
   na=]

\setupfootertexts
  [marge]
  [\tt\Modulefile]
  []

\setupfootertexts
  [tekst]
  [hoofdstuk][paragraaf]

\setupindex
  [symbool=1]

\setuptolerance
  [zeersoepel]

\endinput
