%D \module
%D   [       file=core-int,
%D        version=1995.1.1,
%D          title=\CONTEXT\ Core Macros,
%D       subtitle=Interaction,
%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 Still to be done properly.

\writestatus{loading}{Context Core Macros / Interaction}

\startmessages  dutch  library: interactions
  title: interactie
      1: aspect ratio -- x -- (b x h)
      2: actief
      3: niet actief
      4: geen paginasynchronisatie (--) in hmode
\stopmessages

\startmessages  english  library: interactions
  title: interaction
      1: aspect ratio -- x -- (b x h)
      2: active
      3: inactive
      4: no pagesynchronisation (--) in hmode
\stopmessages

\startmessages  german  library: interactions
  title: Interaktion
      1: Aspekt des Verhaeltnis -- x -- (B x H)
      2: aktiv
      3: inaktiv
      4: keine Seitensynchronisation (--) im hmode
\stopmessages

\startmessages  czech  library: interactions
  title: interakce
      1: pomer -- x -- (s x v)
      2: aktivni
      3: neaktivni
      4: zadna strankova synchronizace (--) v hmode
\stopmessages

\startmessages  dutch  library: versions
  title: versie
      1: er mankeert een @+
      2: markeren pagina's
      3: geselecteerde pagina's: --
\stopmessages

\startmessages  english  library: versions
  title: version
      1: missing @+
      2: marking pages
      3: selected pages: --
\stopmessages

\startmessages  german  library: versions
  title: Version
      1: fehlendes @+
      2: Erstelle Seiten
      3: Ausgewaehlte Seiten: --
\stopmessages

\startmessages  czech  library: versions
  title: verze
      1: postradam @+
      2: oznacuji se strany
      3: oznacene strany: --
\stopmessages

\unprotect

\definesystemconstant {link}

\definesystemvariable {lk}

% \expand vs \expanded

% linked registers implementeren als een koppeling == mooier

\presetlocalframed[\??lk]

\newcounter\numberoflinks

\def\stelkoppelingenin%
  {\dodoubleargument\getparameters[\??lk]}

\def\definieerkoppeling[#1]%  % local loading ! 
  {\doifundefined{\s!link:#1:\s!list}
     {\expanded{\definetwopasslist{\s!link:#1}}%
      \expanded{\doloadtwopassdata{\s!link:#1}}%
      \getfirsttwopassdata{\s!link:#1}%
      \setxvalue{\s!link:#1:f}{\twopassdata}%  
      \getlasttwopassdata{\s!link:#1}%
      \setxvalue{\s!link:#1:l}{\twopassdata}%
      \setxvalue{\s!link:#1:s}{\noftwopassitems}%
      \gettwopassdata{\s!link:#1}%
      \setxvalue{\s!link:#1:c}{\twopassdata}%
      \setxvalue{\s!link:#1:n}{\twopassdata}}}

\def\koppeling[#1]#2%
  {\bgroup
   \definieerkoppeling[#1]%
   \doglobal\increment\numberoflinks
   \gettwopassdata{\s!link:#1}%
   \edef\numberoflinks{0\getvalue{\s!link:#1:s}}%
   \edef\firstlink{0\getvalue{\s!link:#1:f}}%
   \edef\lastlink{0\getvalue{\s!link:#1:l}}%
   \edef\currentlink{0\getvalue{\s!link:#1:n}}%
   \edef\prevlink{0\getvalue{\s!link:#1:c}}% 
   \iftwopassdatafound
     \edef\nextlink{0\twopassdata}%
     \setxvalue{\s!link:#1:n}{\nextlink}%
     \setxvalue{\s!link:#1:c}{\currentlink}%
   \else
     \edef\nextlink  {0\getvalue{\s!link:#1:l}}%
   \fi
   \edef\writelink%
     {\writeutilitycommand%
        {\twopassentry%
           {\s!link:#1}%
           {\numberoflinks}%
           {\noexpand\realfolio}}}%
   \writelink
   \ifnum\noflinks<2
     \locationfalse
   \fi
   \iflocation
     \hbox
       {\setupinteraction[\c!breedte=\!!zeropoint]%
        \doganaareenpagina\??lk\gotobegincharacter\firstlink\hss
        \ifnum\noflinks>2
          \hskip\@@lkafstand
          \doganaareenpagina\??lk\gobackwardcharacter\prevlink\hss
        \fi
        \hskip\@@lkafstand
        #2\relax
        \hskip\@@lkafstand
        \ifnum\noflinks>2
          \doganaareenpagina\??lk\goforwardcharacter\nextlink\hss
          \hskip\@@lkafstand
        \fi
        \doganaareenpagina\??lk\gotoendcharacter\lastlink}%
   \else
     \hbox{#2}%
   \fi
   \egroup}

\def\definieerkoppeling[#1]%  % local loading ! 
  {\doifundefined{\s!link:#1:\s!list}
     {\expanded{\definetwopasslist{\s!link:#1}}%      \expanded{\doloadtwopassdata{\s!link:#1}}%
      \getfirsttwopassdata{\s!link:#1}%
      \let\firstlink=\twopassdata  
      \getlasttwopassdata{\s!link:#1}%
      \let\lastlink=\twopassdata
      \let\noflinks=\noftwopassitems
      \gettwopassdata{\s!link:#1}%
      \let\currentlink=\twopassdata
      \let\nextlink=\twopassdata
      \setxvalue{\s!link:#1:}%
        {\firstlink:\lastlink:\noflinks:\currentlink:\nextlink}}}

\def\koppeling[#1]#2%
  {\bgroup
   \definieerkoppeling[#1]%
   \doglobal\increment\numberoflinks
   \gettwopassdata{\s!link:#1}%
   \def\next[##1:##2:##3:##4:##5]%
     {\edef\firstlink  {0##1}%
      \edef\lastlink   {0##2}%
      \edef\noflinks   {0##3}%
      \edef\prevlink   {0##4}%
      \edef\currentlink{0##5}}%
   \expanded{\next[\getvalue{\s!link:#1:}]}%
   \edef\nextlink%
     {0\iftwopassdatafound\twopassdata\else\lastlink\fi}%
   \setxvalue{\s!link:#1:}%
     {\firstlink:\lastlink:\noflinks:\currentlink:\nextlink}%
   \edef\writelink%
     {\writeutilitycommand%
        {\twopassentry%
           {\s!link:#1}%
           {\numberoflinks}%
           {\noexpand\realfolio}}}%
   \writelink
   \ifnum\noflinks<2
     \locationfalse
   \fi
   \iflocation
     \hbox
       {\setupinteraction[\c!breedte=\!!zeropoint]%
%
%        \doganaareenpagina\??lk\gotobegincharacter\firstlink\hss
%        \ifnum\noflinks>2
%          \hskip\@@lkafstand
%          \doganaareenpagina\??lk\gobackwardcharacter\prevlink\hss
%        \fi
%        \hskip\@@lkafstand
%        #2\relax
%        \hskip\@@lkafstand
%        \ifnum\noflinks>2
%          \doganaareenpagina\??lk\goforwardcharacter\nextlink\hss
%          \hskip\@@lkafstand
%        \fi
%        \doganaareenpagina\??lk\gotoendcharacter\lastlink}%
%
        #2\relax
        \hskip\@@lkafstand
        \doganaareenpagina\??lk\gotobegincharacter\firstlink\hss
        \ifnum\noflinks>2
          \doganaareenpagina\??lk\gobackwardcharacter\prevlink\hss
        \fi
        \ifnum\noflinks>2
          \doganaareenpagina\??lk\goforwardcharacter\nextlink\hss
          \hskip\@@lkafstand
        \fi
        \doganaareenpagina\??lk\gotoendcharacter\lastlink}%
%
   \else
     \hbox{#2}%
   \fi
   \egroup}

\let\setupinteractionscreens\empty

\def\berekeninteractiescherm%
  {\doifelse{\@@scbreedte}{\v!passend}
     {\!!widtha=\linkerrandbreedte
      \advance\!!widtha by \linkerrandafstand
      \advance\!!widtha by \paginascheiding
      \advance\!!widtha by \linkermargebreedte
      \advance\!!widtha by \linkermargeafstand
      \ifdim\rugwit>\!!widtha\ifdim\rugwit>\!!zeropoint\relax
        \advance\rugwit by -\!!widtha
      \fi\fi
      \advance\!!widtha by \zetbreedte
      \advance\!!widtha by \rechtermargeafstand
      \advance\!!widtha by \rechtermargebreedte
      \advance\!!widtha by \paginascheiding
      \advance\!!widtha by \rechterrandafstand
      \advance\!!widtha by \rechterrandbreedte
      \scratchdimen=\@@scrugwit
      \advance\scratchdimen by \@@scrugoffset
      \advance\!!widtha by 2\scratchdimen}
     {\doifelse{\@@scbreedte}{\v!max}
        {\!!widtha=\printpapierbreedte}
        {\!!widtha=\@@scbreedte}}%
   \doifelse{\@@schoogte}{\v!passend}
     {\!!heighta=\bovenhoogte
      \advance\!!heighta by \bovenafstand
      \ifdim\kopwit>\!!heighta\ifdim\kopwit>\!!zeropoint\relax
        \advance\kopwit by -\!!heighta
      \fi\fi
      \advance\!!heighta by \zethoogte
      \advance\!!heighta by \onderafstand
      \advance\!!heighta by \onderhoogte
      \scratchdimen=\@@sckopwit
      \advance\scratchdimen by \@@sckopoffset
      \advance\!!heighta by 2\scratchdimen}
     {\doifelse{\@@schoogte}{\v!max}
        {\!!heighta=\printpapierhoogte}
        {\!!heighta=\@@schoogte}}%
   \doif{\@@scwachttijd}{\v!geen}{\def\@@scwachttijd{0}}}

\def\initializeidentity% The macro is not to be changed;
  {\iflocation         % only the ia-variables may be set! 
     \dosetupidentity    
       {\@@iatitel}
       {\@@iasubtitel}
       {\@@iaauteur} 
       {CONTEXT / www.pragma-ade.nl / \jobname.tex}
       {\@@iadatum}%
     \global\let\initializeidentity\relax
   \fi}

\appendtoks \initializeidentity \to \everyshipout 

\def\initializepaper%
  {\iflocation % without screen settings
     \dosetuppaper
       {\papierformaat}
       {\the\papierbreedte}
       {\the\papierhoogte}%
   \else
     \dosetuppaper
       {\printpapierformaat}
       {\the\printpapierbreedte}
       {\the\printpapierhoogte}%
   \fi}

\def\doinitializepaper%
  {\bgroup
   \berekeninteractiescherm
   \ifdim\!!widtha>\papierbreedte\ifdim\!!widtha>\!!zeropoint 
     \papierbreedte=\!!widtha  
   \fi\fi
   \ifdim\!!heighta>\papierhoogte\ifdim\!!heighta>\!!zeropoint 
     \papierhoogte=\!!heighta 
   \fi\fi
   \dosetuppaper
     {\printpapierformaat}
     {\the\papierbreedte}
     {\the\papierhoogte}%
   \egroup}

\def\dosetupinteractionscreens% met a, b en \number
  {\bgroup
   \berekeninteractiescherm
   \processaction
     [\@@scoptie]
     [     \v!max=>\!!counte=1,
      \v!bookmark=>\!!counte=2,
       \s!unknown=>\!!counte=0,
       \s!default=>\!!counte=0]%
   \showmessage{\m!interactions}{1} % niet waterdicht
     {\@EA\withoutpt\the\!!widtha,\@EA\withoutpt\the\!!heighta}%
   \dosetupscreen
     {\number\rugoffset}{\number\kopoffset}
     {\number\!!widtha}{\number\!!heighta}
     {\the\!!counte}%
   \egroup}

\def\dostelinteractieschermin[#1]%
  {\getparameters[\??sc][#1]%
   \ifproductionrun
     \let\initializepaper\doinitializepaper
     \let\setupinteractionscreens\dosetupinteractionscreens
   \fi}

\def\stelinteractieschermin%
  {\dosingleempty\dostelinteractieschermin}

%D Due to requests I finally decided to support bookmarks, a
%D driver dependant way of showing tables of content. The most
%D simple way of support is hooking bookmark generation into
%D the existing list mechanisms. That way users can generate
%D bookmarks automatically, although its entirely valid to add
%D bookmarks by defining alternative ones. These will be added
%D at the appropriate place in the list.

% \hoofdstuk{het eerste hoofdstuk}
%
% \bookmark {de eerste bookmark} % optional overuled hoofdstuk
%
% .... text ....
%
% \placebookmarks [hoofdstuk,paragraaf,subparagraaf,subsubparagraaf,mylist]
%                 [open list]
%
% \bookmark[mylist]{whatever}

\def\@@bookmark {bm::}
\def\@@booklevel{bl::}
\def\@@bookcount{bc::}

\definieerlijst[\@@bookmark]

\appendtoks\flushpostponedbookmark\to\everypar
\appendtoks\flushpostponedbookmark\to\neverypar

\let\flushpostponedbookmark\relax

\def\simplebookmark#1%
  {\ifx\flushpostponedbookmark\relax \else
     \bgroup
     \convertargument#1\to\ascii
     \writestatus{system}{clashing bookmarks: \ascii}% ECHTE MESSAGE MAKEN
     \egroup
   \fi
   \gdef\flushpostponedbookmark%
     {\global\let\flushpostponedbookmark\relax
      \schrijfnaarlijst[\@@bookmark]{}{#1}}}

\def\complexbookmark[#1]#2%
  {\schrijfnaarlijst[#1]{}{#2}}

\definecomplexorsimple\bookmark

%\def\insertbookmark[#1]#2%
%  {\bgroup
%   \doifreferencefoundelse{#1}
%     {\doinsertbookmark{0}{0}{#2}{\currentrealreference}}{1}
%     {\unknownreference{#1}}%
%   \egroup}

\newif\iftracebookmarks \tracebookmarksfalse

\let\tracebookmarks\tracebookmarkstrue

\def\placebookmarks%
  {\dodoubleempty\doplacebookmarks}

\def\doplacebookmarks[#1][#2]%
  {\iflocation
     \iffirstargument
       \bgroup
       \ifsecondargument
         \edef\openbookmarklist{#2}%
       \else
         \let\openbookmarklist=\empty
       \fi
       \global\let\bookmarklevellist=\empty
       \def\bookmarklevelcount{0}%
       \doprocessbookmarks[#1]\dogetbookmarkelement
       \dolijstelement{}{}{}{}{}{}% needed to finish the first pass
       \doprocessbookmarks[#1]\doputbookmarkelement
       \flushbookmark
       \egroup
     \else
       \expanded{\placebookmarks\@EA[\getvalue{\??ih\v!inhoud\c!lijst}]}%
     \fi
   \fi}

\def\doprocessbookmarks[#1]#2%
  {\let\dolijstelement=#2\relax
   \scratchcounter=0
   \def\docommando##1%
     {\advance\scratchcounter by 1
      \getlistlevel[##1]\listlevel{\the\scratchcounter}%
      \setxvalue{\@@bookcount\the\scratchcounter}{1}%
      \setxvalue{\@@booklevel##1}{\listlevel}}%
   \processcommalist[#1]\docommando
   \setxvalue{\@@bookcount0}{1}%
   \global\chardef\currentbookmarklevel=0
   \global\chardef\previousbookmarklevel=0
   \doutilities{#1,\@@bookmark}{\jobname}{#1}{}{}}

\def\dodogetbookmarkelement#1#2#3#4#5#6%
  {%\doifsomething{#1}
   %  {\global\chardef\currentbookmarklevel=\getvalue{\@@booklevel#1}}%
   \doifelsenothing{#1}
     {\global\chardef\currentbookmarklevel=0\relax}
     {\global\chardef\currentbookmarklevel=\getvalue{\@@booklevel#1}\relax}%
   \ifnum\currentbookmarklevel>\previousbookmarklevel
     \setxvalue{\@@bookcount\the\currentbookmarklevel}{1}%
   \else\ifnum\currentbookmarklevel<\previousbookmarklevel
     \bgroup
     \!!counta=\previousbookmarklevel
     \doloop
       {\let\bookmarktag=\empty
        \!!countb=\!!counta
        \advance\!!countb by -1
        \dorecurse{\!!countb}
          {\edef\bookmarktag%
             {\bookmarktag\getvalue{\@@bookcount\recurselevel}:}}%
        \edef\bookmarklevelcount%
          {\getvalue{\@@bookcount\the\!!counta}}%
        \xdef\bookmarklevellist%
          {\bookmarklevellist/\bookmarktag:\bookmarklevelcount/}%
        \advance\!!counta by -1
        \ifnum\!!counta=\currentbookmarklevel
          \exitloop
        \fi}%
     \egroup
     \@EA\doglobal\@EA\increment\csname \@@bookcount\the\currentbookmarklevel\endcsname\relax
   \else
     \@EA\doglobal\@EA\increment\csname \@@bookcount\the\previousbookmarklevel\endcsname\relax
   \fi\fi
   \global\utilitydonetrue
   \global\chardef\previousbookmarklevel=\currentbookmarklevel}

\def\getbookmarklevelcount%
  {\@EA\def\@EA\docommando\@EA[\@EA##\@EA1\@EA/\bookmarktag:##2/##3]%
     {\def\bookmarklevelcount{##2}}%
   \@EA\@EA\@EA\docommando\@EA\@EA\@EA[\@EA\bookmarklevellist\@EA/\bookmarktag:0/]}

\def\dodoputbookmarkelement#1#2#3#4#5#6%
  {%\doifsomething{#1}
   %  {\global\chardef\currentbookmarklevel=\getvalue{\@@booklevel#1}}%
   \doifelsenothing{#1}
     {\global\chardef\currentbookmarklevel=0\relax}
     {\global\chardef\currentbookmarklevel=\getvalue{\@@booklevel#1}\relax}%
   \ifnum\currentbookmarklevel>\previousbookmarklevel
     \setxvalue{\@@bookcount\the\currentbookmarklevel}{1}%
   \else\ifnum\currentbookmarklevel<\previousbookmarklevel
     \@EA\doglobal\@EA\increment\csname \@@bookcount\the\currentbookmarklevel\endcsname\relax
   \else
     \@EA\doglobal\@EA\increment\csname \@@bookcount\the\previousbookmarklevel\endcsname\relax
   \fi\fi
   \let\bookmarktag=\empty
   \!!countb\currentbookmarklevel
   \dorecurse{\!!countb}
     {\edef\bookmarktag%
        {\bookmarktag\getvalue{\@@bookcount\recurselevel}:}}%
   \getbookmarklevelcount
   \iftracebookmarks
     \bgroup
     \par
     \bookmarktag\quad
     \dorecurse{\currentbookmarklevel}{\quad}\unskip#1\quad
     (\bookmarklevelcount)\quad
     \egroup
   \fi
   \global\chardef\previousbookmarklevel=\currentbookmarklevel
   \global\utilitydonetrue
   \insertsomebookmark
     {#1}
     {\the\currentbookmarklevel}
     {\bookmarklevelcount}
     {#4}
     {#6}}

\def\dogetbookmarkelement#1#2#3#4#5#6%
  {\doifnot{#1}{\@@bookmark}
     {\dodogetbookmarkelement{#1}{#2}{#3}{#4}{#5}{#6}}}

\def\doputbookmarkelement#1#2#3#4#5#6%
  {\doifelse{#1}{\@@bookmark}
     {\localbookmark{#4}}
     {\flushbookmark
      \dodoputbookmarkelement{#1}{#2}{#3}{#4}{#5}{#6}}}

\let\flushbookmark=\relax
\let\localbookmark=\gobbleoneargument

\def\insertsomebookmark#1#2#3#4#5%
  {\gdef\flushbookmark%
     {\doinsertsomebookmark{#1}{#2}{#3}{#4}{#5}{g}}%
   \gdef\localbookmark##1%
     {\doinsertsomebookmark{#1}{#2}{#3}{##1}{#5}{l}}}

\def\doinsertsomebookmark#1#2#3#4#5#6%
  {\global\utilitydonetrue
   \global\let\localbookmark=\gobbleoneargument
   \global\let\flushbookmark=\relax
   \doifinstringelse{#1}{\openbookmarklist}
     {\chardef\openbookmark=1}
     {\chardef\openbookmark=0}%
   \iftracebookmarks(#6: #4)\quad(\the\openbookmark)\par\fi
   \doinsertbookmark{#2}{#3}{#4}{#5}{\openbookmark}}

% \startinteractiemenu[rechts]
%   \but [eerste]  eerste  \\
%   \txt hello world       \\
%   \but [tweede]  tweede  \\
%   \nop                   \\
%   \but [tweede]  tweede  \\
%   \rul whow              \\
%   \but [tweede]  tweede  \\
%   \raw hello world       \\
%   \but [tweede]  tweede  \\
%   \com \vfill            \\
%   \but [derde]   derde   \\
% \stopinteractiemenu

\newif\iflocationmenupermitted

\def\testinteractiemenu#1%
   {\iflocation
      \doifelse{\@@iamenu}{\v!aan}
        {\doifelsevalue{\??am#1\c!status}{\v!start}
           {\global\locationmenupermittedtrue}
           {\global\locationmenupermittedfalse}}
        {\global\locationmenupermittedfalse}%
    \else
      \global\locationmenupermittedfalse
    \fi}

\def\doblokkeerinteractiemenu[#1][#2][#3]%
  {\def\dodoblokkeerinteractiemenu##1%
     {\doifelse{#3}{}
        {\setevalue{\??am##1\c!blokkade}{}}
        {\edef\interactieblokkade{\getvalue{\??am##1\c!blokkade}}
         \def\docommando####1%
           {#1{####1}{\interactieblokkade}}% #1 = \remove or \add
         \processcommalist[#3]\docommando
         \setevalue{\??am##1\c!blokkade}{\interactieblokkade}}}%
   \processcommalist[#2]\dodoblokkeerinteractiemenu}

\def\blokkeerinteractiemenu%
  {\dotripleempty\doblokkeerinteractiemenu[\addtocommalist]}

\def\geefinteractiemenuvrij%
  {\dotripleempty\doblokkeerinteractiemenu[\removefromcommalist]}

% ja   : kader/achtergrond met tekst
% leeg : kader/achtergrond maar geen tekst
% nee  : alleen ruimte reserveren
% geen : helemaal weglaten

\newif\iflocationdummy
\newif\ifskippedmenuitem

\def\dosetlocationbox#1[#2]#3#4%
  {\global\skippedmenuitemfalse
   \setbox\locationbox=\hbox
     {% anders cyclische aanroep !
      \resetgoto
      \iflocationdummy
        \edef\locationboxborder{\getvalue{#1\c!kader}}%
        \edef\locationboxbackground{\getvalue{#1\c!achtergrond}}%
      \else
        \edef\locationboxborder{\v!uit}%
        \edef\locationboxbackground{}%
      \fi
      \localframed[#1]
        [\c!kader=\locationboxborder,
         \c!achtergrond=\locationboxbackground,
         #2]
        {\dolocationattributes{#1}\c!letter\c!kleur{#3}}}%
   \hbox{#4{\box\locationbox}}}%{\copy\locationbox}}}

\def\setlocationboxyes#1[#2]#3[#4]%
  {\ifx\currentouterreference\empty
     \ifrealreferencepage\!!doneatrue\else\!!doneafalse\fi
     %\doifelse{\currentrealreference}{\realfolio}
     %  {\!!doneatrue}{\!!doneafalse}%
   \else
     \!!doneafalse
   \fi
   \if!!donea
     \ifcase0\getvalue{#1\c!zelfdepagina}\relax
       \bgroup
       \locationdummytrue
       \setevalue{#1\c!kleur}{\getvalue{#1\c!contrastkleur}}%
       \dosetlocationbox{#1}[#2,\c!leeg=\v!nee]{#3}{\gotolocation{#4}}%
       \egroup
     \or
       \locationdummytrue
       \dosetlocationbox{#1}[#2,\c!leeg=\v!ja]{#3}{\gotolocation{#4}}%
     \or
       \locationdummyfalse
       \dosetlocationbox{#1}[#2,\c!leeg=\v!ja]{#3}{\gotolocation{#4}}%
     \or
       \locationdummyfalse
       \global\skippedmenuitemtrue
     \fi
   \else
     \locationdummytrue
     \dosetlocationbox{#1}[#2,\c!leeg=\v!nee]{#3}{\gotolocation{#4}}%
   \fi}

\def\setlocationboxnop#1[#2]#3[#4]%
  {\ifcase\getvalue{#1\c!onbekendeverwijzing}\relax
     \locationdummytrue
     \dosetlocationbox{#1}[#2,\c!leeg=\v!nee]{#3}{}%
   \or
     \locationdummytrue
     \dosetlocationbox{#1}[#2,\c!leeg=\v!ja]{#3}{}%
   \or
     \locationdummyfalse
     \dosetlocationbox{#1}[#2,\c!leeg=\v!ja]{#3}{}%
   \or
     \locationdummyfalse
     \global\skippedmenuitemtrue
   \fi}

%\def\setlocationbox#1[#2]#3[#4]%
%  {\doifinstringelse{#4}{\getvalue{#1\c!blokkade}}
%     {\setlocationboxnop{#1}[#2]{#3}[#4]}
%     {\doifreferencefoundelse{#4}
%        {\setlocationboxyes{#1}[#2]{#3}[#4]}
%        {\setlocationboxnop{#1}[#2]{#3}[#4]%
%         \unknownreference{#4}}}}

\def\setlocationbox#1[#2]#3[#4]%
  {\doifreferencepermittedelse{#4}{\getvalue{#1\c!blokkade}}
     {\setlocationboxyes{#1}[#2]{#3}[#4]}
     {\setlocationboxnop{#1}[#2]{#3}[#4]}}

%\dolocationattributes{#1}\c!letter\c!kleur{#3}}}%

\def\dodosetlocationcommanditem#1#2#3[#4]#5\\%
  {\bgroup
   \leavevmode
   \doifelse{#5}{[]}
     {\doifinstringelse{=}{#4}
        {#3}
        {\setlocationbox{\??am#1}[]{#3}[#4]}}
     {#3}%
   \ifskippedmenuitem \else
     \getvalue{\??am#1#2}%
   \fi
   \egroup}

\def\dosetlocationcommanditem#1#2#3%
  {\dodosetlocationcommanditem{#1}{#2}#3[]\\}

\def\setlocationnop#1[#2]#3%
  {\localframed[#1][#2]{#3}}

\def\executeamboxcommands#1#2#3#4#5%
  {\processaction
     [\getvalue{\??am#1\c!dummy}]
     [  \v!ja=>\chardef\handleunknownmenuitem=0\relax,
      \v!leeg=>\chardef\handleunknownmenuitem=1\relax,
       \v!nee=>\chardef\handleunknownmenuitem=2\relax]%
   \getvalue{\??am#1#3}\relax
   \ifextendedmenu
     \setamboxcommands{#1}{#4}%
     \def\next%
       {\ignorespaces#2}%
   \else
     \def\dolocationcommand##1%
       {\dosetlocationcommanditem{#1}{#4}{##1}}%
     \def\next%
       {\processcommalist[#2]\dolocationcommand}%
   \fi
   \next
   \unskip
   \getvalue{\??am#1#5}}

\def\setamboxcommands#1#2%
  {\def\@@amboxcommand##1\\%
     {\bgroup
      \leavevmode\ignorespaces##1\unskip\relax
      \ifskippedmenuitem \else
        \getvalue{\??am#1#2}%
      \fi
      \egroup
      \ignorespaces}%
   \def\raw[##1]##2\\%
     {\@@amboxcommand\naarbox{\ignorespaces##2\unskip}[##1]\\}%
   \def\but[##1]##2\\%
     {\@@amboxcommand\setlocationbox{\??am#1}[]{\ignorespaces##2\unskip}[##1]\\}%
   \def\got[##1]##2\\%
     {\@@amboxcommand\setlocationbox{\??am#1}[\c!kader=\v!uit,\c!achtergrond=]{\ignorespaces##2\unskip}[##1]\\}%
   \def\nop##1\\%
     {\@@amboxcommand\phantom{\localframed[\??am#1][]{}}\\}%
   \def\txt##1\\%
     {\@@amboxcommand\localframed[\??am#1][\c!kader=\v!uit,\c!achtergrond=]{\ignorespaces##1\unskip}\\}%
   \def\rul##1\\%
     {\@@amboxcommand\localframed[\??am#1][]{\ignorespaces##1\unskip}\\}%
   \def\com##1\\%
     {\ignorespaces##1\unskip}}

\def\@@amhbox#1#2#3#4%
  {\testinteractiemenu{#3}%
   \iflocationmenupermitted
     \bgroup
\showcomposition
     \def\dolocationcommand##1%
       {\dosetlocationcommanditem{#3}{##1}}%
     \dimen0=\zetbreedte
     \advance\dimen0 by \pagebackgroundhoffset
     \advance\dimen0 by \pagebackgroundhoffset
     \advance\dimen0 by -\getvalue{\??am#3\c!linkeroffset}%
     \advance\dimen0 by -\getvalue{\??am#3\c!rechteroffset}%
     \setbox0=\hbox to \dimen0
       {\forgetall
        \executeamboxcommands{#3}{#4}\c!links\c!midden\c!rechts}%
     \wd0=\zetbreedte
     % geen \ht=#2 setting (yet)
     \hskip-\pagebackgroundhoffset
     \hskip \getvalue{\??am#3\c!linkeroffset}%
     \box0\relax
     \egroup
   \else
     #1\relax
   \fi}

\def\@@amvbox#1#2#3#4% don't change skipping, this one works!
  {\testinteractiemenu{#3}%
   \iflocationmenupermitted
     \bgroup
\showcomposition
     \dimen0=\teksthoogte
     \advance\dimen0 by \pagebackgroundvoffset
     \advance\dimen0 by \pagebackgroundvoffset
     \advance\dimen0 by \pagebackgrounddepth
     \advance\dimen0 by -\getvalue{\??am#3\c!bovenoffset}%
     \advance\dimen0 by -\getvalue{\??am#3\c!onderoffset}%
     \setbox0=\vbox to \dimen0
       {\forgetall                     % Voor't geval de afstand
        \stelblankoin[\v!standaard]%   % (tijdelijk) is aangepast.
        \hsize#2\relax
        \executeamboxcommands{#3}{#4}\c!voor\c!tussen\c!na}%
     \setbox0=\vbox
       {\vskip-\pagebackgroundvoffset
        \vskip\getvalue{\??am#3\c!bovenoffset}%
        \ht0=\!!zeropoint
        \box0
        \vskip\pagebackgroundvoffset}% overbodig
     \ht0=\teksthoogte
     \wd0=#2\relax
     \box0
     \egroup
   \else
     #1\relax
   \fi}

\setvalue{\??am\s!do\v!rechts}%
  {\@@amvbox{\dodummypageskip\v!rechts}\rechterrandbreedte}

\setvalue{\??am\s!do\v!links}%
  {\@@amvbox{\dodummypageskip\v!links}\linkerrandbreedte}

\setvalue{\??am\s!do\v!boven}%
  {\@@amhbox{\dodummypageskip\v!boven}\bovenhoogte}

\setvalue{\??am\s!do\v!onder}%
  {\@@amhbox{\dodummypageskip\v!onder}\onderhoogte}

\def\dointeractiemenu#1#2%
  {\getvalue{\??am\s!do\getvalue{\??am#1\c!plaats}}{#1}{#2}}

\unexpanded\def\interactiemenu[#1]%
  {\getvalue{\??am\c!menu#1}}

\def\horizontaalinteractiemenu#1#2#3#4%
  {\ifdim#2>\!!zeropoint % new 
     \dimen2=\!!zeropoint
     \setbox0=\hbox
       {\def\docommando##1%
          {\doifnotvalue{\??am##1\c!status}{\v!geen}
             {\hskip\dimen2
              \setbox2=\hbox to #2
                {\getvalue{\??am##1#3}\interactiemenu[##1]\getvalue{\??am##1#4}}%
              \doifelsevalue{\??am##1\c!afstand}{\v!overlay}
                {\dimen2=\!!zeropoint
                 \wd2=\!!zeropoint}%
                {\dimen2=\getvalue{\??am##1\c!afstand}}%
              \box2}}%
       \startinteractie
       \processcommacommand[\getvalue{\??am#1}]\docommando
       \stopinteractie}%  
     \wd0=#2\relax
     \box0\relax
   \fi}

\def\vertikaalinteractiemenu#1#2#3#4%
  {\ifdim#2>\!!zeropoint % new 
     \dimen2=\!!zeropoint
     \setbox0=\vbox
       {\def\docommando##1%
          {\doifnotvalue{\??am##1\c!status}{\v!geen}
             {\vskip\dimen2
              \setbox2=\vbox to #2
                {\getvalue{\??am##1#3}\interactiemenu[##1]\getvalue{\??am##1#4}}%
              \doifelsevalue{\??am##1\c!afstand}{\v!overlay}
                {\dimen2=\!!zeropoint
                 \offinterlineskip
                 \dp2=\!!zeropoint
                 \ht2=\!!zeropoint}%
                {\dimen2=\getvalue{\??am##1\c!afstand}}%
              \box2}}%
        \startinteractie
        \processcommacommand[\getvalue{\??am#1}]\docommando
        \stopinteractie}%  
     \ht0=#2\relax
     \dp0=\!!zeropoint
     \box0\relax
   \fi}

\def\interactiemenus[#1]%
  {\iflocation
     \processaction
       [#1]
       [  \v!links=>\horizontaalinteractiemenu\v!links\linkerrandbreedte\c!links\c!rechts,
         \v!rechts=>\horizontaalinteractiemenu\v!rechts\rechterrandbreedte\c!links\c!rechts,
          \v!boven=>\vertikaalinteractiemenu\v!boven\bovenhoogte\c!voor\c!na,
          \v!onder=>\vertikaalinteractiemenu\v!onder\onderhoogte\c!voor\c!na]%
   \else
     \dodummypageskip{#1}%
   \fi}

\setvalue{\??am\v!links }{}
\setvalue{\??am\v!rechts}{}
\setvalue{\??am\v!boven }{}
\setvalue{\??am\v!onder }{}

\newif\ifextendedmenu

\def\dodefinieerinteractiemenu[#1][#2][#3]%
  {\ConvertToConstant\doifelse{#3}{}
     {\setvalue{\??am\c!menu#1}%
        {\extendedmenufalse\dointeractiemenu{#1}{#2}}}
     {\setvalue{\??am\c!menu#1}%
        {\extendedmenufalse\dointeractiemenu{#1}{}}%
      \presetlocalframed[\??am#1]%
      \letvalue{\??am#1\c!blokkade}\empty
      \edef\!!stringe{\getvalue{\??am#2}}%
      \addtocommalist{#1}\!!stringe
      \letvalue{\??am#2}=\!!stringe
      \doifnot{#1}{#2}
        {\copyparameters[\??am#1][\??am#2]
           [\c!links,\c!midden,\c!rechts,\c!voor,\c!na,\c!tussen,
            \c!breedte,\c!hoogte,\c!afstand,\c!offset,\c!kader,
            \c!achtergrond,\c!achtergrondkleur,\c!achtergrondraster,
            \c!letter,\c!kleur,\c!contrastkleur,\c!zelfdepagina,\c!onbekendeverwijzing,
            \c!linkeroffset,\c!rechteroffset,\c!bovenoffset,\c!onderoffset]}%
      \ConvertToConstant\doifinstringelse{=}{#3}
        {\getparameters[\??am#1][\c!plaats=#2,#3]}%
        {\doifnot{#2}{#3}
           {\copyparameters[\??am#1][\??am#3]
              [\c!links,\c!midden,\c!rechts,\c!voor,\c!na,\c!tussen,
               \c!breedte,\c!hoogte,\c!afstand,\c!offset,\c!kader,
               \c!achtergrond,\c!achtergrondkleur,\c!achtergrondraster,
               \c!letter,\c!kleur,\c!zelfdepagina,\c!onbekendeverwijzing,
               \c!linkeroffset,\c!rechteroffset,\c!bovenoffset,\c!onderoffset]}%
         \getparameters[\??am#1][\c!plaats=#2]}}}

\def\definieerinteractiemenu%
  {\dotripleempty\dodefinieerinteractiemenu}

\processbetween{\e!interactiemenu}\dostartinteractiemenu

\def\dostartinteractiemenu#1%
  {\dodostartinteractiemenu#1\dodostopinteractiemenu}

\def\dodostartinteractiemenu[#1]#2\dodostopinteractiemenu%
  {\setvalue{\??am\c!menu#1}{\extendedmenutrue\dointeractiemenu{#1}{#2}}}

\def\dododostelinteractiemenuin#1%
  {\processaction
     [\getvalue{#1}]
     [     \v!ja=>\setvalue{#1}{0},
         \v!leeg=>\setvalue{#1}{1},
          \v!nee=>\setvalue{#1}{2},
         \v!geen=>\setvalue{#1}{3},
      \s!default=>\setvalue{#1}{1}]}

\def\dodostelinteractiemenuin[#1][#2]%
  {\def\docommando##1%
     {\getparameters[\??am##1][#2]%
      \dododostelinteractiemenuin{\??am##1\c!onbekendeverwijzing}%
      \dododostelinteractiemenuin{\??am##1\c!zelfdepagina}}%
   \processcommalist[#1]\docommando}

\def\dostelinteractiemenuin[#1][#2]%
  {\ConvertToConstant\doifinstringelse{=}{#2}
     {\dodostelinteractiemenuin[#1][#2]}
     {\dodefinieerinteractiemenu[#1][#2][]}}

\def\stelinteractiemenuin%
  {\dodoubleargument\dostelinteractiemenuin}

% \scherm moet worden als \pagina

\def\simplescherm%  zou niet nodig moeten zijn
  {\iflocation
     \pagina[\v!ja]%
   \fi}

\def\complexscherm[#1]%
  {\iflocation
     \pagina[#1]%
   \fi}

\definecomplexorsimple\scherm

\def\domenubutton[#1][#2]#3[#4]%
  {\bgroup
   \locationdummytrue
   \iffirstargument
     \ifsecondargument
       \setlocationbox{\??am#1}[#2]{#3}[#4]%
     \else
       \ConvertToConstant\doifinstringelse{=}{#1}
         {\setlocationbox{\??bt}[#1]{#3}[#4]}
         {\setlocationbox{\??am#1}[]{#3}[#4]}%
     \fi
   \else
     \setlocationbox{\??bt}[]{#3}[#4]%
   \fi
   \egroup}

\unexpanded\def\menubutton%
  {\dodoubleempty\domenubutton}

\def\domenubox[#1][#2]#3%
  {\bgroup
   \def\setlocationbox##1[##2]##3[##4]%
     {\localframed[##1][##2]%
        {\dolocationattributes{##1}\c!letter\c!kleur{##3}}}%
   \domenubutton[#1][#2]#3[]%
   \egroup}

\def\menubox%
  {\dodoubleempty\domenubox}

% Hier volgen de synchronisatiemacro's:

\def\syncprefix{sync}
\def\syncmarker{syncmark}

%\definieermarkering[\syncmarker]
%\stelmarkeringin[\syncmarker][\c!expansie=\v!ja]

\newmark\syncmarker

\newcounter\synccounter

\newif\ifsynchronisation

\def\startsynchronisatie%
  {\iflocation\ifsynchronisation
     \doglobal\increment\synccounter
   \fi\fi}

\def\stopsynchronisatie%
  {\iflocation\ifsynchronisation
     %\thisisdestination{\syncprefix:\synccounter}%
     \paginareferentie[\syncprefix:\synccounter]%
     \ifvmode
       \@EA\setmark\@EA\syncmarker\@EA{\synccounter} % \marking[\syncmarker]{\synccounter}%
     \else
       \showmessage{\m!interactions}{4}{\synccounter}%
     \fi
   \fi\fi}

\def\synchroniseer%
  {\startsynchronisatie
   \stopsynchronisatie}

\def\dostelsynchronisatiein[#1]%
  {\getparameters[\??sy][#1]%
   \doifelse{\@@systatus}{\v!start}
     {\synchronisationtrue}
     {\synchronisationfalse}}

\def\stelsynchronisatiein%
  {\dosingleargument\dostelsynchronisatiein}

\def\definieersynchronisatie%
  {\dosingleargument\dodefinieersynchronisatie}

\def\stelsynchronisatiebalkin%
  {\dodoubleargument\getparameters[\??ba]}

\presetlocalframed[\??ba]

\setvalue{synchronisatie\v!pagina}[#1]%
  {\bgroup
   \setupinteraction[\c!breedte=\!!zeropoint]%
   \setbox0=\hbox
     {\localframed[\??ba][]%
        {\dolocationattributes\??ba\c!letter\c!kleur{\strut\@@batekst}}}%
   \mindermeldingen
   \def\onder%
     {\leaders\hrule\!!depth1ex\!!height-.5ex\hfil}%
   \def\boven##1##2##3%
     {\dimen0=\wd0
      \divide\dimen0 by 3
      \multiply\dimen0 by ##2\relax
      \dimen2=.25em
      \advance\dimen0 by -##3\dimen2
      %\gotodestination
      %  {}{#1}{\syncprefix:##1}{}
      %  {\hbox to \dimen0{\color[\locationcolor\@@bakleur]{\onder}}}}%
      \naarbox
        {\hbox to \dimen0{\color[\locationcolor\@@bakleur]{\onder}}}%
        [#1::\syncprefix:##1]}%
   \hbox
     {\def\check##1##2%
        {\edef##2{0##1\syncmarker}%
         \ifnum0##2=0 \def##2{1}\fi}%
      \check\gettopmark\top
      \check\getfirstmark\first
      \check\getbotmark\bot
      \setbox2=\hbox to \wd0
        {\ifnum\top=\first\relax
           \ifnum\first=\bot\relax
             \boven\first30\relax
           \else
             \boven\first21\hss\boven\bot11\relax
           \fi
         \else
           \ifnum\first=\bot\relax
             \boven\top11\hss\boven\first21\relax
           \else
             \boven\top11\hss\boven\first11\hss\boven\bot11\relax
           \fi
         \fi}%
      \wd2=\!!zeropoint\box2
      \box0\relax}%
   \egroup}

\setvalue{synchronisatie\v!lokaal}[#1]%
  {\bgroup
   \setupinteraction[\c!breedte=\!!zeropoint]%
   \def\blackrule{\hbox{\vrule\!!height.5em\!!width.5em}}%
   %\gotodestination
   %   {}{##1}{\syncprefix:#1}{0}
   %   {\color[\locationcolor\@@bakleur]{\blackrule}}%
   \naarbox %
     {\color[\locationcolor\@@bakleur]{\blackrule}}%
     [#1::\syncprefix:\synccounter]%
   \egroup}

\def\synchronisatiebalk[#1][#2]%
  {\iflocation\ifsynchronisation
     \bgroup
     \stelsynchronisatiebalkin
       [\c!tekst=\getvalue{doc:des:#1},#2]%
     \getvalue{synchronisatie\@@bavariant}[#1]%
     \egroup
   \fi\fi}

% Dit is leuke toepassing van glue!

\newbox\meterbox

\newif\ifbalksymbool

\def\doganaareenpagina#1#2#3% nog checken !
  {\checkreferences  % nodig ??
   \iflocation
     \ifnum#3=\realpageno
       {#2}%
     \else
       \doifelsenothing{#1}
         {\hbox{\gotorealpage{}{}{#3}
            {#2}}}
         {\hbox{\gotorealpage{}{}{#3}
            {\dolocationattributes{#1}\c!letter\c!kleur{#2}}}}%
     \fi
   \else
     {#2}%
   \fi}

\def\interactiebalka%
  {\iflocation
     \bgroup
     \setupinteraction[\c!breedte=\!!zeropoint]%
     \setupblackrules[\c!hoogte=\v!max,\c!diepte=\v!max]% maten ??
     \!!widthb=\@@ibbreedte\relax
     \advance\!!widthb by -2.75em\relax
     \!!widtha=\!!widthb\relax
     \divide\!!widtha by \lastpage\relax
     \bgroup
       \advance\realpageno by -1\relax
       \ifvoid\meterbox
         \bgroup
         \processaction
           [\@@ibstap]
           [   \v!klein=>\dimen0=.25em\relax,
              \v!middel=>\dimen0=.5em\relax,
               \v!groot=>\dimen0=1em\relax,
             \s!unknown=>\dimen0=\!!widtha]%
         \ifdim\!!widtha<\dimen0\relax
           \!!counta=\dimen0\relax
           \!!countb=\!!widtha
           \divide\!!counta by \!!countb
         \else
           \!!counta=\@@ibstap\relax
         \fi
         \!!widtha=\!!counta\!!widtha
         \setbox0=\hbox{\blackrule[\c!breedte=\!!widtha]}%
         \global\setbox\meterbox=\hbox to \!!widthb
           {\hss
            \for \teller=1 \to \lastpage \step \!!counta \do
              {\gotorealpage{}{}{\teller}{\copy0}}%
            \hss}%
         \global\wd\meterbox=\!!zeropoint\relax
         \egroup
       \fi
     \egroup
     \noindent
     \strut
     \hbox to \@@ibbreedte
       {\mindermeldingen
        \setupblackrules[\c!breedte=1em]%
        \doganaareenpagina\??ib\blackrule\firstpage
        \hss
        \color[middlegray]{\copy\meterbox}%
        \hbox to \!!widthb
          {\ifdim\!!widtha<1em\relax
             \!!widtha=1em\relax
           \fi
           \setupblackrules[\c!breedte=\!!widtha]%
           \ifnum\realpageno>1\relax
             \!!counta=\realpageno
             \advance\!!counta by -2\relax
             \hskip\!!zeropoint\!!plus\!!counta sp\relax % cm gives overflow
             \doganaareenpagina\??ib\blackrule\prevpage
           \fi
           \color[\@@ibcontrastkleur]{\blackrule[\c!breedte=.5em]}%
           \ifnum\realpageno<\lastpage\relax
             \doganaareenpagina\??ib\blackrule\nextpage
             \!!counta=\lastpage\relax
             \advance\!!counta by -\realpageno
             \advance\!!counta by -1\relax
             \hskip\!!zeropoint\!!plus\!!counta sp\relax % cm gives overflow
           \fi}%
        \hss
        \doganaareenpagina\??ib\blackrule\lastpage}%
     \egroup
   \fi}

\presetlocalframed[\??ib]

\def\interactiebalkc%
  {\iflocation
     \ifnum\lastpage>1
       \hbox to \@@ibbreedte
         {\setupblackrules[\c!hoogte=\@@ibhoogte,\c!diepte=\@@ibdiepte]%
          \def\gotox##1%
            {\doganaareenpagina{}{\blackrule[\c!breedte=##1]}}%
          \dimen0=\@@ibbreedte\relax
          \advance\dimen0 by -4em
          \!!counta=\lastpage
          \advance\!!counta by -1
          \divide\dimen0 by \!!counta
          \!!counta=\realpageno
          \advance\!!counta by -1
          \!!widtha=\!!counta\dimen0\relax
          \!!countb=\lastpage
          \advance\!!countb by -\realpageno
          \!!widthb=\!!countb\dimen0
          \startcolor[\locationcolor\@@ibkleur]%
          \gotox{1em}\firstpage
          \hss
          \gotox{\!!widtha}\prevpage
          \color[\@@ibcontrastkleur]{\blackrule[\c!breedte=1em]}%
          \gotox{\!!widthb}\nextpage
          \hss
          \gotox{1em}\lastpage
          \stopcolor}%
     \fi
   \fi}

\def\interactiebalkd%
  {\iflocation\ifshowingsubpage
     \ifnum\nofsubpages>1
       \hbox
       \bgroup
       \setupinteraction[\c!breedte=\!!zeropoint]%
       \ifbalksymbool % beter: 3 chars assign en 3*box
         \setupsymbolset[\@@iasymboolset]%
         \setbox0=\hbox{\symbol[\v!vorige]}%
         \setbox2=\hbox{\symbol[\v!ergens]}%
         \setbox4=\hbox{\symbol[\v!volgende]}%
       \else
         \setbox0=\hbox
           {\vrule
              \!!height\@@ibhoogte
              \!!depth\@@ibdiepte
              \!!width\@@ibbreedte}%
         \setbox2=\copy0
         \setbox4=\copy0
       \fi
       \startcolor[\locationcolor\@@ibkleur]%
       \for\teller=1\to\nofsubpages\step1\do
         {\bgroup
          \increment(\teller,\firstsubpage)\relax
          \decrement\teller\relax
          \ifnum\teller<\realpageno\relax
            \gotorealpage{}{}{\teller}{\copy0}\relax
          \else\ifnum\teller=\realpageno\relax
            \color
              [\@@ibcontrastkleur]
              {\gotorealpage{}{}{\teller}{\copy2}}%
          \else
            \gotorealpage{}{}{\teller}{\copy4}\relax
          \fi\fi
          \egroup
          \hskip\@@ibafstand}%
       \unskip
       \stopcolor
       \egroup
     \fi
   \fi\fi}

\def\interactiebalke%  KAN WORDEN GECOMBINEERD MET D
  {\iflocation\ifshowingsubpage
     \ifnum\nofsubpages>1
       \bgroup
       \!!widthb=\@@ibafstand
       \multiply\!!widthb by \nofsubpages
       \advance\!!widthb by -\@@ibafstand % (n-1)
       \!!widtha=\@@ibbreedte
       \advance\!!widtha by -\!!widthb
       \divide\!!widtha by \nofsubpages\relax
       \ifdim\!!widtha<\@@ibafstand\relax
         \interactiebalkf
       \else
         \setupinteraction[\c!breedte=\!!zeropoint]%
         \noindent
         \hbox to \@@ibbreedte
           \bgroup
             \ifbalksymbool
               \setupsymbolset[\@@iasymboolset]%
               \setbox0=\hbox{\symbol[\v!vorige]}%
               \setbox2=\hbox{\symbol[\v!ergens]}%
               \setbox4=\hbox{\symbol[\v!volgende]}%
             \else
               \setbox0=\hbox
                  {\vrule
                     \!!height\@@ibhoogte
                     \!!depth\@@ibdiepte
                     \!!width\!!widtha}%
               \setbox2=\copy0
               \setbox4=\copy0
             \fi
             \startcolor[\locationcolor\@@ibkleur]%
             \for\teller=1\to\nofsubpages\step1\do
               {\bgroup
                \increment(\teller,\firstsubpage)\relax
                \decrement\teller\relax
                \ifnum\teller<\realpageno\relax
                  \gotorealpage{}{}{\teller}{\copy0}\relax
                \else\ifnum\teller=\realpageno\relax
                  \color
                    [\@@ibcontrastkleur]
                    {\gotorealpage{}{}{\teller}{\copy2}}%
                \else
                  \gotorealpage{}{}{\teller}{\copy4}\relax
                \fi\fi
                \egroup
                \hss}%
             \unskip
             \stopcolor
           \egroup
       \fi
       \egroup
     \fi
   \fi\fi}

\def\interactiebalkf%  !! KAN WORDEN GECOMBINEERD MET D !!
  {\iflocation\ifshowingsubpage
     \ifnum\nofsubpages>1
       \setupinteraction[\c!breedte=\!!zeropoint]%
       \noindent
       \hbox to \@@ibbreedte
       \bgroup
       \!!countb=0
       \loop
         \advance\!!countb by 1
         \!!countc=\nofsubpages
         \divide\!!countc by \!!countb
         \advance\!!countc by 1
         \!!widthb=\@@ibafstand
         \multiply\!!widthb by \!!countc
         \advance\!!widthb by -\@@ibafstand
         \!!widtha=\@@ibbreedte
         \advance\!!widtha by -\!!widthb
         \divide\!!widtha by \!!countc
         \ifdim\!!widtha<\@@ibafstand\relax
       \repeat
\advance\!!countc by -2
\!!widtha=-\@@ibafstand
\!!widtha=\!!countc\!!widtha
\advance\!!widtha by \@@ibbreedte
\advance\!!countc by 1
\divide\!!widtha by \!!countc
       \ifbalksymbool
         \setupsymbolset[\@@iasymboolset]%
         \setbox0=\hbox{\symbol[\v!vorige]}%
         \setbox4=\hbox{\symbol[\v!ergens]}%
         \setbox8=\hbox{\symbol[\v!volgende]}%
         \setbox2=\copy4
         \setbox6=\copy4
       \else
         \setbox0=\hbox
           {\vrule
              \!!height\@@ibhoogte
              \!!depth\@@ibdiepte
              \!!width\!!widtha}%
         \setbox4=\copy0
         \setbox8=\copy0
         \setbox2=\hbox
           {\vrule
              \!!height.5\ht0
              \!!depth.5\dp0
              \!!width\!!widtha}%
         \ht2=\ht0
         \dp2=\dp0
         \setbox6=\copy2
       \fi
       \def\gotox##1%
         {\ifnum\teller=\realpageno
            \color
              [\@@ibcontrastkleur]
              {\gotorealpage{}{}{\teller}{\copy##1}}%
          \else
            \gotorealpage{}{}{\teller}{\copy##1}%
          \fi
          \!!countf=0
          \hss}%
       \startcolor[\locationcolor\@@ibkleur]%
       \!!countc=\realpageno \advance\!!countc by -2
       \!!countd=\realpageno \advance\!!countd by 2
       \!!countf=0
       \for\teller=\firstsubpage\to\lastsubpage\step1\do
         {\!!doneafalse
          \advance\!!countf by 1
          \ifnum\teller=\firstsubpage\relax \!!doneatrue \fi
          \ifnum\teller=\lastsubpage\relax  \!!doneatrue \fi
          \ifnum\teller>\!!countc \ifnum\teller<\!!countd \!!doneatrue \fi\fi
          \if!!donea
            \ifnum\teller<\realpageno
              \gotox0%
            \else\ifnum\teller>\realpageno
              \gotox4%
            \else
              \gotox8%
            \fi\fi
          \else\ifnum\!!countf=\!!countb
            \ifnum\teller<\realpageno
              \gotox2%
            \else\ifnum\teller>\realpageno
              \gotox6%
            \else
              \gotox4%
            \fi\fi
          \fi\fi}%
       \unskip
       \stopcolor
       \egroup
     \fi
   \fi\fi}

\def\interactiebalkb%
  {\ifnum\lastpage>\firstpage\relax
     \interactiebuttons
       [\v!eerstepagina,
        \v!vorigepagina,
        \v!volgendepagina,
        \v!laatstepagina]%
   \fi}

\def\interactiebalkg%
  {\ifnum\lastsubpage>\firstsubpage\relax
     \interactiebuttons
       [\v!eerstesubpagina,
        \v!vorigesubpagina,
        \v!volgendesubpagina,
        \v!laatstesubpagina]%
   \fi}

\def\checkinteractiebalk#1#2%
  {\doifnothing{\@@ibhoogte}{\def\@@ibhoogte{#1}}%
   \doifnothing{\@@ibdiepte}{\def\@@ibdiepte{#2}}}

\def\complexinteractiebalk[#1]%
  {\doifelse{#1}{\v!reset}
    {\global\setbox\meterbox=\box\voidb@x}%
    {\bgroup
       \iflocation
         \checksubpages % goes wrong / loads \numberofpages too
         \getparameters[\??ib][#1]%
         \doif{\@@ibstatus}{\v!start}
           {\startinteractie
            \processaction
              [\@@ibvariant]
              [         c=>\checkinteractiebalk\v!max\v!max,
                        d=>\checkinteractiebalk{.5em}\!!zeropoint,
                        e=>\checkinteractiebalk{.5em}\!!zeropoint,
                        f=>\checkinteractiebalk{.5em}\!!zeropoint,
               \s!default=>\checkinteractiebalk\v!ruim\!!zeropoint,
               \s!unknown=>\checkinteractiebalk\v!ruim\!!zeropoint]%
            \doifelse{\@@ibsymbool}{\v!ja}
              {\balksymbooltrue}{\balksymboolfalse}%
            \getvalue{interactiebalk\@@ibvariant}%
            \stopinteractie}%
       \fi
     \egroup}}

\definecomplexorsimpleempty\interactiebalk

\def\stelinteractiebalkin%
  {\dodoubleargument\getparameters[\??ib]}

% Er wordt vooralsnog uitgegaan van een symmetrische
% start-stop situatie.

\def\c!profiel!! {profiel:}  % brrr
\def\c!versie!!  {versie:}

\def\dodefinieerprofiel[#1][#2]%
  {\iflocation
     \def\dododefinieerprofiel##1%
       {\def\dodododefinieerprofiel####1%
          {\doifdefinedelse{\c!profiel!!####1}%
             {\edef\!!stringa{\getvalue{\c!profiel!!####1}}%
              \setevalue{\c!profiel!!####1}{\!!stringa,##1}}%
             {\setevalue{\c!profiel!!####1}{##1}}}%
        \processcommalist[#2]\dodododefinieerprofiel}%
     \processcommalist[#1]\dododefinieerprofiel
   \fi}

\def\definieerprofiel%
  {\dodoubleargument\dodefinieerprofiel}

% Als met \getpar wordt gewerkt, dan moet \next worden toegepast.

% TZT initialisatie!

\def\profilepage{}

\let\dosetprofilepage=\relax
\let\dogetprofilepage=\relax

\def\processprofile#1[#2]%
  {\iflocation
     \par % needed for pdftex
     \bgroup
     \dosetprofilepage
     \dogetprofilepage
     \def\processoneprofile##1##2%
       {\ExpandBothAfter\doifinsetelse{##2}{\processedprofiles}%
          {\doifsomething{##1}{(##1)}}%
          {\addtocommalist{##2}\processedprofiles
            ##1\relax
            \ifcase#1\relax
              \dobeginofprofile
                {##2}
                {\number\papierbreedte}{\number\papierhoogte}
                {\profilepage}%
            \else
              \doendofprofile
            \fi}}%
     \def\processedprofiles{}%
     \def\doprocessprofile##1%
       {\doifelse{\@@pfoptie}{\v!test}%
          {\goodbreak\blanko\nobreak\tt[\spatie
           \ifcase#1\v!start\else\v!stop\fi profiel\spatie ##1:\spatie
           \doifdefinedelse{\c!profiel!!##1}%
             {\def\dodoprocessprofile####1%
                {\processoneprofile
                   {\naar{####1}[\c!profiel!!####1]}%
                   {####1}%
                 \spatie}%
              \processcommacommand
                [\getvalue{\c!profiel!!##1}]\dodoprocessprofile}%
             {- }%
           ]\nobreak\blanko}%
          {\doifdefined{\c!profiel!!##1}%
             {\def\dodoprocessprofile####1%
                {\processoneprofile{}{####1}}%
              \processcommacommand
                 [\getvalue{\c!profiel!!##1}]\dodoprocessprofile}}}%
     \processcommalist[#2]\doprocessprofile
     \egroup
     \par % needed for pdftex
   \fi}

\def\startprofiel[#1]%
  {\iflocation
     \bgroup
     \addtocommalist{#1}\actualprofile
     \def\stopprofiel%
       {\processprofile1[#1]%
        \egroup}%
     \DoAfterFi\processprofile0[#1]%
   \fi}

\let\stopprofiel=\relax

\def\dovolgprofiel#1[#2]%
  {\iflocation
     \hbox
       {\dostartgoto
          \data
            {\dolocationattributes\??ia\c!letter\c!kleur{#1\presetgoto}}%
          \start
            \dostartgotoprofile
              {\number\buttonwidth}{\number\buttonheight}
              {#2}%
          \stop
            \dostopgotoprofile
        \dostopgoto}%
   \else
     {#1}%
   \fi}

\def\volgprofiel#1[#2]%
  {\iflocation
     \doif{\@@pfoptie}{\v!test}{\pagereference[\c!profiel!!#2]}%
     \dovolgprofiel{#1}[#2]%
   \fi}

\def\stelprofielenin%
  {\dodoubleargument\getparameters[\??pf]}

% Als er nog geen tekst op de pagina staat, dan heeft het
% profiel betrekking op het bovenstaande, dus soms een vorige
% pagina! Vreemd, omdat PDF paginagewijs werkt. Gelukkig
% biedt /page een oplossing. Echter: expansie van een
% \special kan niet worden uitgesteld, zodat alleen een
% two-pass een oplossing vormt. Het onderstaande kan komen
% te vervallen als Acrobat dit ondervangt. Het scheelt een
% pass en een lijst.
%
% Er kunnen eventueel twee lijsten worden gebruikt. Een voor
% het begin (start) en een voor het eind (stop). Nu staat
% alles in een lijst.

\definetwopasslist{\s!profile}

\newcounter\currentprofile

\def\dosetprofilepage%
  {\doglobal\increment\currentprofile
   \edef\docommando%
     {\writeutilitycommand%
        {\twopassentry%
           {\s!profile}%
           {\currentprofile}%
           {\noexpand\realfolio}}}%
   \docommando}

\def\dogetprofilepage%
  {\gettwopassdata{\s!profile}%
   \let\profilepage=\twopassdata}

\newcounter\versionlevel
\newcounter\versionorder

\newif\ifrecentversion

\let\oldatcharacter=@

\def\minimumversion{0}
\def\actualversion{0}

\def\dostelversiesin[#1]%
  {\getparameters[\??ve][#1]
   \stripcharacter.\from\@@venummer\to\minimumversion
   \setversion}

\def\stelversiesin%
  {\dosingleargument\dostelversiesin}

\definetwopasslist{\s!versionbegin}
\definetwopasslist{\s!versionend}

\def\actualprofile{}

\def\doresetpageversion%
  {\edef\docommando%
     {\writeutilitycommand%
        {\twopassentry%
           {\s!versionend}%
           {\versionorder}%
           {\noexpand\realfolio}}}%
   \docommando}

\def\dosetpageversion#1%
  {\recentversiontrue
   \doglobal\increment\versionorder\relax
   \edef\docommando%
     {\writeutilitycommand%
        {\twopassentry%
           {\s!versionbegin}%
           {\versionorder}%
           {\noexpand\realfolio}}}%
   \docommando
   \let\resetpageversion=\doresetpageversion}

\def\recentcontributions{}

\def\checkrecentcontributions%
  {\gettwopassdata{\s!versionbegin}%
   \iftwopassdatafound
     \!!counta=\twopassdata\relax
     \gettwopassdata{\s!versionend}%
     \iftwopassdatafound
       \!!countb=\twopassdata\relax
       \doglobal\increment\versionorder\relax
       \writeutilitycommand%
         {\twopassentry%
            {\s!versionbegin}%
            {\versionorder}%
            {\the\!!counta}}%
       \writeutilitycommand%
         {\twopassentry%
            {\s!versionend}%
            {\versionorder}%
            {\the\!!countb}}%
       \for\teller=\!!counta\to\!!countb\step1\do%
         {\@EA\doglobal\@EA\addtocommalist\@EA{\teller}{\recentcontributions}}%
       \let\next=\checkrecentcontributions
     \else
       \let\next=\relax
     \fi
   \else
     \let\next=\relax
   \fi
   \next}

\def\docheckpageversion%
  {\ExpandBothAfter\doifinsetelse{\realfolio}{\recentcontributions}
     {\geselecteerdtrue}%
     {\geselecteerdfalse}}

\let\setpageversion   = \gobbleoneargument
\let\resetpageversion = \relax
\let\checkpageversion = \relax

\def\complexstartversie[#1]%
  {\bgroup
   \doifelse{\actualprofile}{}%
     {\startprofiel[#1]}%
     {\startprofiel[#1,\actualprofile]}%
   \def\docomplexstartversie##1%
     {\stripcharacter.\from##1\to\actualversion
      \ifnum\versionlevel>0\relax
        \ifnum\actualversion=0\relax
          \setpageversion\actualversion   % unknown version
        \else
          \ifnum\actualversion<\minimumversion\relax
            \relax                        % old version
          \else
            \setpageversion\actualversion % new version
          \fi
        \fi
      \fi}%
   \doglobal\increment\versionlevel\relax
   \doifelsenothing{#1}
     {\docomplexstartversie{0}}%
     {\processcommalist[#1]\docomplexstartversie}}

\definecomplexorsimpleempty\startversie

\def\stopversie%
  {\stopprofiel
   \doglobal\decrement\versionlevel
   \ifnum\versionlevel<0\relax
     \showmessage{\m!versions}{1}{}%
   \else
     \resetpageversion
     \egroup
   \fi}

\bgroup
\catcode`@=\active
\gdef\setversion%
  {\catcode`@=\active        % we can't use \@@active here
   \long\def@##1##2 %
     {\ifx##1+%
        \startversie[##2]%
      \else\ifx##1-%
        \stopversie
      \else
        \oldatcharacter##1##2 %
      \fi\fi}}
\egroup

\def\markeerversie%
  {\showmessage{\m!versions}{2}{}%
   \let\setpageversion=\dosetpageversion
   \let\resetpageversion=\relax
   \let\checkpageversion=\relax}

\def\selecteerversie%
  {\checkrecentcontributions
   \showmessage{\m!versions}{3}{\recentcontributions}%
   \let\setpageversion=\gobbleoneargument
   \let\resetpageversion=\relax
   \let\checkpageversion=\docheckpageversion
   \setversion}

\def\dodefinieerversie[#1][#2]%
  {\setvalue{\c!versie!!#1}{#2}%
   \definieerprofiel[#1][#2]}

\def\definieerversie%
  {\dodoubleargument\dodefinieerversie}

\def\volgversie%
  {\volgprofiel}

\def\volgprofielversie#1[#2][#3]%
  {\def\docommando##1%
     {\definieerprofiel[#2#3][##1]}%
   \processcommacommand[\getvalue{\c!versie!!#3}]\docommando
   \volgprofiel#1[#2#3]}

\newcounter\currentpagetransition

\newif\ifrandomtransitions

\def\stelpaginaovergangenin%
  {\dosingleempty\dostelpaginaovergangenin}

\def\dostelpaginaovergangenin[#1]%
  {\doifelsenothing{#1}
     {\doifnot{\@@scwachttijd}{\v!geen}
        {\let\setpagetransition\setsomepagedelay}}
     {\doifelse{#1}{\v!start}
        {\doifnot{\@@scwachttijd}{\v!geen}
           {\let\setpagetransition\setsomepagedelay}}
        {\doglobal\newcounter\currentpagetransition
         \doifinsetelse{#1}{\v!reset,\v!stop}
           {\let\setpagetransition\relax}
           {\let\setpagetransition\setsomepagetransition
            \doifinsetelse{\v!willekeurig}{#1}
              {\randomtransitionstrue}{\randomtransitionsfalse}%
            \edef\userpagetransitions{#1}%
            \@EA\removefromcommalist\@EA{\v!willekeurig}\userpagetransitions
            \ifx\userpagetransitions\empty
              \let\userpagetransitions\pagetransitions
            \fi}}}}

\def\setsomepagedelay%
  {\expanded{\dosetpagetransition{0}{\@@scwachttijd}}}

\def\setsomepagetransition%
  {\iflocation
     \ifrandomtransitions
       \expanded{\getcommalistsize[\userpagetransitions]}%
       \getrandomnumber{\currentpagetransition}{1}{\commalistsize}%
     \else
       \doglobal\increment\currentpagetransition
     \fi
     \expanded{\getfromcommalist[\userpagetransitions][\currentpagetransition]}%
     \doifnumberelse{\commalistelement}
       {\expanded{\getfromcommalist[\pagetransitions][\commalistelement]}}
       {}%
     \ifx\commalistelement\empty
       \doglobal\newcounter\currentpagetransition
       \setsomepagetransition
     \else
       \doifelse{\@@scwachttijd}{\v!geen}
         {\expanded{\dosetpagetransition{\commalistelement}{0}}}
         {\expanded{\dosetpagetransition{\commalistelement}{\@@scwachttijd}}}%
     \fi
   \fi}

\prependtoks \setpagetransition \to \everyshipout

% temporary here

%D \startbuffer
%D \dorecurse{10}
%D   {\horizontalpositionbar
%D      \pos\recurselevel \min1 \max10
%D      \token\framed{\recurselevel}%
%D    \\}
%D
%D \hbox to 15em
%D   {\hss
%D    \dorecurse{10}
%D      {\verticalpositionbar\pos\recurselevel\min1\max10\token\blokje\\
%D       \hss}}
%D \stopbuffer

\def\horizontalpositionbar\pos#1\min#2\max#3\token#4\\%
  {\hbox to \hsize
     {\hskip\!!zeropoint\!!plus #1\!!fill
      \hskip\!!zeropoint\!!plus-#2\!!fill
      #4\relax
      \hskip\!!zeropoint\!!plus #3\!!fill
      \hskip\!!zeropoint\!!plus-#1\!!fill}}

\def\verticalpositionbar\pos#1\min#2\max#3\token#4\\%
  {\vbox to \vsize
     {\vskip\!!zeropoint\!!plus #1\!!fill
      \vskip\!!zeropoint\!!plus-#2\!!fill
      \hbox{#4}\relax
      \vskip\!!zeropoint\!!plus #3\!!fill
      \vskip\!!zeropoint\!!plus-#1\!!fill}}

\def\horizontalgrowingbar\pos#1\min#2\max#3\height#4\depth#5\\%
  {\hbox to \hsize
     {\scratchcounter=#1\relax
      \advance\scratchcounter by -#2\relax
      \advance\scratchcounter by 1\relax
      \leaders\vrule\hskip\!!zeropoint\!!plus \scratchcounter\!!fill
      \vrule\!!width\!!zeropoint\!!height#4\!!depth#5\relax
      \hskip\!!zeropoint\!!plus #3\!!fill
      \hskip\!!zeropoint\!!plus-#1\!!fill}}

\def\verticalgrowingbar\pos#1\min#2\max#3\width#4\\%
  {\vbox to \vsize
     {\scratchcounter=#1\relax
      \advance\scratchcounter by -#2\relax
      \advance\scratchcounter by 1\relax
      \leaders\hrule\vskip\!!zeropoint\!!plus\scratchcounter\!!fill
      \hrule\!!width#4\!!height\!!zeropoint\!!depth\!!zeropoint
      \vskip\!!zeropoint\!!plus #3\!!fill
      \vskip\!!zeropoint\!!plus-#1\!!fill}}

\newbox\commentbox

\def\flushcomments%
  {\ifvoid\commentbox\else
     \inmarge{\hbox{\raise\ht\strutbox\box\commentbox}}%
   \fi}

\def\stelcommentaarin%
  {\dodoubleargument\getparameters[\??cc]}

\setvalue{\e!start\e!commentaar}% the dummy triple gobbles trailing spaces
  {\dotripleempty\dostartcommentaar}

\def\dostartcommentaar[#1][#2][#3]%
  {\bgroup
   \doifassignmentelse{#1}
     {\getparameters[\??cc][#1]}
     {\getparameters[\??cc][\c!titel=#1,#2]}%
   \bgroup
   \obeylines
   \doif{\@@ccspatie}{\v!ja}{\obeyspaces}%
   \long\def\docommando##1%
     {\egroup
      \global\setbox\commentbox=\hbox
        {\!!widtha=\@@ccbreedte
         \!!heighta=\@@cchoogte
         \doinsertcomment
           {\@@cctitel}{\number\!!widtha}{\number\!!heighta}
           {\@@cckleur}{0}{\@@ccsymbool}{##1}%
        \hskip\ifvoid\commentbox\@@ccmarge\else\@@ccafstand\fi
        \box\commentbox
        \egroup}}%
   \grabuntil{\e!stop\e!commentaar}\docommando}

\def\commentaar%
  {\dodoubleempty\docommentaar}

\def\docommentaar[#1][#2]#3%
  {\bgroup
   \doifassignmentelse{#1}
     {\getparameters[\??cc][#1]}
     {\getparameters[\??cc][\c!titel=#1,#2]}%
   \!!widtha=\@@ccbreedte
   \!!heighta=\@@cchoogte
   \hbox to \!!zeropoint
     {\hskip-\@@ccmarge
      \raise\ht\strutbox\hbox
        {\doPDFinsertcomment
           {\@@cctitel}{\number\!!widtha}{\number\!!heighta}
           {\@@cckleur}{0}{\@@ccsymbool}{#3}}}%
   \egroup
   \ignorespaces}

% \startcommentaar
%   hello beautiful\\world
% \stopcommentaar
%
% \startcommentaar[hallo]
%   hello \<< \'e\'erste \>>
%   beautiful
%   world
% \stopcommentaar
%
% \startcommentaar[hallo][kleur=groen,breedte=4cm,hoogte=3cm]
%   hello \<< \'e\'erste \>>
%   beautiful
%   world
% \stopcommentaar
%
% \startcommentaar[hallo][kleur=groen,breedte=4cm,hoogte=3cm]
%   hello \<< \'e\'erste \>>
%
%   beautiful
%
%   world
% \stopcommentaar
%
% \startcommentaar[symbool=Balloon]
%   Do we want this kind of rubish? And, why isn't this and
%   some more features related to text annotations so poorly
%   (actually not) documented? Anyhow, by providing this
%   functionality we demonstrate that \pdfTeX\ can do it. By
%   the way, it's funny that when in Acrobat we scale up the
%   text, the symbols scale down. 
% \stopcommentaar

\def\doregistermenubuttons[#1][#2]% [menu id] [register]
  {\bgroup
   \ifsecondargument
     \stelinteractiemenuin
       [#1][\c!onbekendeverwijzing=\v!ja,\c!zelfdepagina=\v!ja]%
     \def\docommando##1%
       {\noindent
        \menubutton[#1]{##1}[#2:##1]%
        \space}%
   \else
     \def\docommando##1%
       {\noindent
        \button[\c!onbekendeverwijzing=\v!ja,\c!zelfdepagina=\v!ja]{##1}[#1:##1]%
        \space}%
   \fi
   \handletokens abcdefghijklmnopqrstuvwxyz\with\docommando
   \egroup}

\def\registermenubuttons%
  {\dodoubleempty\doregistermenubuttons}

\stelkoppelingenin
  [\c!afstand=.25em,
   \c!breedte=\v!passend,
   \c!plaats=\v!laag,
   \c!kleur=\@@iakleur,
   \c!kader=\v!uit,
   \c!achtergrond=,
   \c!achtergrondraster=\@@rsraster,
   \c!achtergrondkleur=]

\definieerinteractiemenu
  [\v!rechts]
  [\v!rechts]
  [\c!voor=,
   \c!na=\vfil,
   \c!tussen=\blanko,
   \c!afstand=\bodyfontsize, % 12pt
   \c!links=\hss,
   \c!rechts=\hss,
   \c!breedte=\rechterrandbreedte,
   \c!hoogte=\v!ruim]

\definieerinteractiemenu
  [\v!links]
  [\v!links]
  [\c!voor=,
   \c!na=\vfil,
   \c!tussen=\blanko,
   \c!afstand=\bodyfontsize, % 12pt
   \c!links=\hss,
   \c!rechts=\hss,
   \c!breedte=\linkerrandbreedte,
   \c!hoogte=\v!ruim]

\definieerinteractiemenu
  [\v!onder]
  [\v!onder]
  [\c!voor=\vss,
   \c!na=\vss,
   \c!midden=\hfil,
   \c!afstand=\bodyfontsize, % 12pt
   \c!breedte=\v!passend,
   \c!hoogte=\v!ruim]

\definieerinteractiemenu
  [\v!boven]
  [\v!boven]
  [\c!voor=\vss,
   \c!na=\vss,
   \c!midden=\hfil,
   \c!afstand=\bodyfontsize, % 12pt
   \c!breedte=\v!passend,
   \c!hoogte=\v!ruim]

\stelinteractiemenuin
  [\v!links,\v!rechts,\v!boven,\v!onder]
  [\c!offset=.25em,
   \c!kader=\v!aan,
   \c!achtergrond=,
   \c!achtergrondkleur=,
   \c!achtergrondraster=\@@rsraster,
   \c!letter=\@@ialetter,
   \c!kleur=\@@iakleur,
   \c!contrastkleur=\@@iacontrastkleur,
   \c!status=\v!start,
   \c!zelfdepagina=\v!ja,
   \c!onbekendeverwijzing=\v!leeg,
   \c!bovenoffset=\!!zeropoint,
   \c!onderoffset=\!!zeropoint,
   \c!linkeroffset=\!!zeropoint,
   \c!rechteroffset=\!!zeropoint]

%\stelbovenin [\v!tekst] [\c!middentekst={\interactiemenus[\v!boven]}]
%\stelonderin [\v!tekst] [\c!middentekst={\interactiemenus[\v!onder]}]

\def\plaatsrechterrandblok {\interactiemenus[\v!rechts]}
\def\plaatslinkerrandblok  {\interactiemenus[\v!links]}
\def\plaatsboventekstblok  {\interactiemenus[\v!boven]}
\def\plaatsondertekstblok  {\interactiemenus[\v!onder]}

\def\plaatsboventekstblok%
  {\vbox to \bovenhoogte
     {\getvalue{\??tk\v!boven\v!tekst\c!voor}
      \interactiemenus[\v!boven]
      \getvalue{\??tk\v!boven\v!tekst\c!na}
      \kern\!!zeropoint}}

\def\plaatsondertekstblok%
  {\vbox to \onderhoogte
     {\getvalue{\??tk\v!onder\v!tekst\c!voor}
      \interactiemenus[\v!onder]
      \getvalue{\??tk\v!onder\v!tekst\c!na}
      \kern\!!zeropoint}}

\stelinteractieschermin
  [\c!breedte=\printpapierbreedte,
   \c!hoogte=\printpapierhoogte,
   \c!rugoffset=\!!zeropoint,
   \c!kopoffset=\!!zeropoint,
   \c!rugwit=\rugwit,
   \c!kopwit=\kopwit,
   \c!optie=\c!min,
   \c!wachttijd=\v!geen]

\stelbuttonsin
  [\c!status=\v!start,
   \c!breedte=\v!passend,
   \c!hoogte=\v!ruim,
   \c!offset=0.25em,
   \c!kader=\v!aan,
   \c!achtergrond=,
   \c!achtergrondraster=\@@rsraster,
   \c!achtergrondkleur=,
   \c!letter=\@@ialetter,
   \c!kleur=\@@iakleur,
   \c!contrastkleur=\@@iacontrastkleur,
   \c!zelfdepagina=\v!ja,
   \c!onbekendeverwijzing=\v!ja]

\stelinteractiebalkin
  [\c!status=\v!start,
   \c!variant=a,
   \c!symbool=\v!nee,
   \c!breedte=\rechterrandbreedte,
   \c!hoogte=, % these are taken care
   \c!diepte=, % of at calling time
   \c!afstand=.5em, % beter relateren aan breedte
   \c!stap=1,
   \c!kleur=\@@iakleur,
   \c!contrastkleur=\@@iacontrastkleur,
   \c!kader=\v!aan,
   \c!achtergrond=,
   \c!achtergrondraster=\@@rsraster,
   \c!achtergrondkleur=]

\stelsynchronisatiebalkin
  [\c!variant=\v!pagina,
   \c!breedte=\rechterrandbreedte,
   \c!letter=\@@ialetter,
   \c!kleur=\@@iakleur,
   \c!achtergrond=,
   \c!achtergrondraster=\@@rsraster,
   \c!achtergrondkleur=]

\stelsynchronisatiein
  [\c!status=\v!stop]

\stelprofielenin
  [\c!optie=]

\stelprogrammasin
  [\c!gebied=]

\stelpaginaovergangenin
  [\v!reset]

\stelcommentaarin
  [\c!marge=2.5em,
   \c!afstand=1em,
   \c!breedte=.3\tekstbreedte,
   \c!hoogte=.2\teksthoogte,
   \c!kleur=\@@iakleur,
   \c!titel=,
   \c!spatie=\v!nee,
   \c!symbool=\v!normaal]

\stelversiesin    % beware, @ is made active here,
  [\c!nummer=1,   % therefore we set this one at the end
   \c!letter=\ss,
   \c!kleur=]

\protect \endinput
