core-int.tex / last modification: 2008-06-28 22:44
%D \module
%D   [       file=core-int,
%D        version=1995.01.01,
%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.

% evt interactionbaren runtime laden (scheelt 8K)

%D Still to be done properly.

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

% interactions 5 and 6 to be translated

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

\startmessages  english  library: interactions
  title: interaction
      1: aspect ratio -- x -- (b x h)
      2: active
      3: inactive
      4: no pagesynchronisation (--) in hmode
      5: unknown attachment --
      6: attachment file -- does not exist
\stopmessages

\startmessages  german  library: interactions
  title: Interaktion
      1: Seitenverhaeltnis -- x -- (B x H)
      2: aktiv
      3: inaktiv
      4: keine Seitensynchronisation (--) im hmode
      5: unknown attachment --
      6: attachment file -- does not exist
\stopmessages

\startmessages  czech  library: interactions
  title: interakce
      1: pomer -- x -- (s x v)
      2: aktivni
      3: neaktivni
      4: zadna strankova synchronizace (--) v hmode
      5: unknown attachment --
      6: attachment file -- does not exist
\stopmessages

\startmessages  italian  library: interactions
  title: interazione
      1: rapporto -- x -- (b x a)
      2: attiva
      3: inattiva
      4: sincronizzazione di pagina (--) non disponibile in hmode
      5: unknown attachment --
      6: attachment file -- does not exist
\stopmessages

\startmessages  norwegian  library: interactions
  title: interaksjon
      1: forholdstall -- x -- (b x h)
      2: aktiv
      3: inaktiv
      4: ingen sidesynkronisering (--) i hmode
      5: unknown attachment --
      6: attachment file -- does not exist
\stopmessages

\startmessages  romanian  library: interactions
  title: interactiuni
      1: aspectul -- x -- (b x h)
      2: activ
      3: inactiv
      4: nu exista sincronizare pt. pagini (--) in hmode
      5: unknown attachment --
      6: attachment file -- does not exist
\stopmessages

\startmessages  french  library: interactions
  title: interaction
      1: ratio d'aspect -- x -- (b x h)
      2: actif
      3: inactif
      4: pas de synchronisation de page (--) dans le hmode
      5: le fichier joint -- est inconnu
      6: le fichier joint -- n'existe pas
\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

\startmessages  italian  library: versions
  title: version
      1: @+ mancante
      2: marcatura pagine
      3: pagine selezionate: --
\stopmessages

\startmessages  norwegian  library: versions
  title: versjon
      1: manglende @+
      2: markerer sider
      3: valgte sider: --
\stopmessages

\startmessages  romanian  library: versions
  title: versiuni
      1: lipseste @+
      2: pagini marcate
      3: pagini selectate: --
\stopmessages

\startmessages  french  library: versions
  title: version
      1: @+ manquant
      2: marquage des pages
      3: pages sélectionnées : --
\stopmessages

\unprotect

% \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}%
      \letgvalue{\s!link:#1:f}\twopassdata
      \getlasttwopassdata{\s!link:#1}%
      \letgvalue{\s!link:#1:l}\twopassdata
      \letgvalue{\s!link:#1:s}\noftwopassitems
      \gettwopassdata{\s!link:#1}%
      \letgvalue{\s!link:#1:c}\twopassdata
      \letgvalue{\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}%
     \letgvalue{\s!link:#1:n}\nextlink
     \letgvalue{\s!link:#1:c}\currentlink
   \else
     \edef\nextlink{0\getvalue{\s!link:#1:l}}%
   \fi
   \lazysavetwopassdata{\s!link:#1}{\numberoflinks}{\noexpand\realfolio}%
   \ifnum\noflinks<\plustwo
     \locationfalse
   \fi
   \iflocation
     \hbox
       {\setinteractionparameter\c!width\!!zeropoint
        \dogotosomepage\??lk\gotobegincharacter\firstlink\hss
        \ifnum\noflinks>\plustwo
          \hskip\@@lkdistance
          \dogotosomepage\??lk\gobackwardcharacter\prevlink\hss
        \fi
        \hskip\@@lkdistance
        #2\relax
        \hskip\@@lkdistance
        \ifnum\noflinks>\plustwo
          \dogotosomepage\??lk\goforwardcharacter\nextlink\hss
          \hskip\@@lkdistance
        \fi
        \dogotosomepage\??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}%
   \lazysavetwopassdata{\s!link:#1}{\numberoflinks}{\noexpand\realfolio}%
   \ifnum\noflinks<\plustwo
     \locationfalse
   \fi
   \iflocation
     \hbox
       {\setinteractionparameter\c!width\!!zeropoint
        #2\relax
        \hskip\@@lkdistance
        \dogotosomepage\??lk\gotobegincharacter\firstlink\hss
        \ifnum\noflinks>\plustwo
          \dogotosomepage\??lk\gobackwardcharacter\prevlink\hss
        \fi
        \ifnum\noflinks>\plustwo
          \dogotosomepage\??lk\goforwardcharacter\nextlink\hss
          \hskip\@@lkdistance
        \fi
        \dogotosomepage\??lk\gotoendcharacter\lastlink}%
   \else
     \hbox{#2}%
   \fi
   \egroup}

\let\setupinteractionscreens\empty

\def\docalculateinteractionscreen
  {\doifelse\@@scwidth\v!fit
     {\!!widtha\leftcombitotal
      \ifdim\backspace>\!!widtha\ifdim\backspace>\zeropoint\relax
        \advance\backspace -\!!widtha
      \fi\fi
      \advance\!!widtha\rightcombitotal
      \advance\!!widtha 2\dimexpr\@@scbackspace+\@@schoroffset\relax}
     {\doifelse\@@scwidth\v!max
        {\!!widtha\printpaperwidth}
        {\!!widtha\@@scwidth}}%
   \doifelse\@@scheight\v!fit
     {\!!heighta\dimexpr\topheight+\topdistance\relax
      \ifdim\topspace>\!!heighta\ifdim\topspace>\zeropoint\relax
        \advance\topspace -\!!heighta
      \fi\fi
      \advance\!!heighta  \dimexpr\makeupheight+\bottomdistance+\bottomheight\relax
      \advance\!!heighta 2\dimexpr\@@sctopspace+\@@scveroffset\relax}
     {\doifelse\@@scheight\v!max
        {\!!heighta\printpaperheight}
        {\!!heighta\@@scheight}}%
   \doif\@@scdelay\v!none{\let\@@scdelay\zerocountervalue}}

% The macro is not to be changed; only the \@@ia-variables
% may be set! ConTeXt is the producer but we no longer
% mention the pragma site, since we don't want to be bothered
% with remarks about third party documents and/or associated
% with documents produced outside our control.

\def\doprepareidentity        % beware, we need to construct
  {\let\!!stringa\@@iakeyword % an unexpanded space separated
   \let\@@iakeyword\empty     % list of keywords from a comma
   \def\doprepareidentity##1% % separated one
     {\ifx\@@iakeyword\empty
        \appended\def\@@iakeyword{##1}%
      \else
        \appended\def\@@iakeyword{ ##1}%
      \fi}%
   \@EA\processcommalist\@EA[\!!stringa]\doprepareidentity
   \global\let\doprepareidentity\relax}

%D The Creator field is changed per 12/04/2006 due to user presure. This
%D means that I need to put my own status info someplace else.

\def\initializeidentity
  {\doprepareidentity
   \dosetupidentity % no \expanded{..} will be done in special (else no pdfdoc)
     {\@@iatitle}{\@@iasubtitle}{\@@iaauthor}%
     {ConTeXt - \contextversion}%
     {\@@iadate}{\@@iakeyword}%
   \global\let\initializeidentity\relax}

\appendtoks \initializeidentity \to \everyshipout

\def\initializepaper
  {\bgroup
   \ifx\@@ppleft \empty
   \ifx\@@ppright\empty
   \ifx\@@pptop \empty
   \ifx\@@ppbottom \empty
   \ifx\@@pcstate\v!start
     \locationfalse\fi\else
     \locationfalse\fi\else
     \locationfalse\fi\else
     \locationfalse\fi\else
     \locationfalse\fi
   \iflocation % without screen settings
     \egroup
     \dosetuppaper\papersize\paperwidth\paperheight
   \else
     \egroup
     \dosetuppaper\printpapersize\printpaperwidth\printpaperheight
   \fi}

\appendtoks \initializepaper \to \everyshipout

\def\doinitializepaper
  {\bgroup
   \docalculateinteractionscreen
   \ifdim\!!widtha>\paperwidth\ifdim\!!widtha>\zeropoint
     \paperwidth\!!widtha
   \fi\fi
   \ifdim\!!heighta>\paperheight\ifdim\!!heighta>\zeropoint
     \paperheight\!!heighta
   \fi\fi
   \dosetuppaper
     {\printpapersize}
     {\the\paperwidth}
     {\the\paperheight}%
   \egroup}

\let\@@pcscreendata\empty

\def\dosetupinteractionscreens % met a, b en \number
  {\doifnot\@@pcstate\v!start\dodosetupinteractionscreens}

\setvalue{\??sc\c!option\v!max        }{1} % tzt share with driver
\setvalue{\??sc\c!option\v!bookmark   }{2} % tzt share with driver
\setvalue{\??sc\c!option\v!fit        }{3} % tzt share with driver
\setvalue{\??sc\c!option\v!doublesided}{4} % tzt share with driver

\def\dodosetupinteractionscreens % met a, b en \number
  {\bgroup
   \docalculateinteractionscreen
   \!!counte=0\getvalue{\??sc\c!option\@@scoption}\relax
   % niet waterdicht
   \doifnot{\the\!!widtha\the\!!heighta}\@@pcscreendata
     {\xdef\@@pcscreendata{\the\!!widtha\the\!!heighta}%
      \showmessage\m!interactions1{\withoutpt\the\!!widtha,\withoutpt\the\!!heighta}}%
   % needs to be split: dimensions for each page
   % and mode per document and only once !
   \dosetupscreen \backoffset\topoffset\!!widtha\!!heighta{\the\!!counte}%
   \dosetupcropbox\backoffset\topoffset\!!widtha\!!heighta
   \egroup}

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

\appendtoks \setupinteractionscreens \to \everyfirstshipout % needed to get option=max etc working
\appendtoks \setupinteractionscreens \to \everyshipout      % needed for page/screen dimensions

\def\setupinteractionscreen
  {\dosingleempty\dosetupinteractionscreen}

%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 overruled hoofdstuk
%
% .... text ....
%
% \placebookmarks [hoofdstuk,paragraaf,subparagraaf,subsubparagraaf,mylist]
%                 [open list]
%
% \bookmark[mylist]{whatever}

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

\definelist[\@@bookmark]

\newtoks\postponedbookmarks

\def\flushpostponedbookmark
  {\the\postponedbookmarks
   \global\postponedbookmarks\emptytoks}

\def\simplebookmark#1%
  {\doglobal\prependtoks
     \writetolist[\@@bookmark]{}{#1}%
   \to\postponedbookmarks}

\def\complexbookmark[#1]#2%
  {\doglobal\appendtoks\writetolist[#1]{}{#2}\to\postponedbookmarks}

\definecomplexorsimple\bookmark

\newif\iftracebookmarks \tracebookmarksfalse

\let\tracebookmarks\tracebookmarkstrue

\def\placebookmarks
  {\dodoubleempty\doplacebookmarks}

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

\def\doprocessbookmarks[#1]#2%
  {\let\dolistelement#2\relax
   \scratchcounter\zerocount
   \def\docommand##1%
     {\advance\scratchcounter \plusone
      \getlistlevel[##1]\listlevel{\the\scratchcounter}%
      \setxvalue{\@@bookcount\the\scratchcounter}{1}%
      \setxvalue{\@@booklevel##1}{\listlevel}}%
   \processcommalist[#1]\docommand
   \setxvalue{\@@bookcount0}{1}%
   \global\chardef\currentbookmarklevel\zerocount
   \global\chardef\previousbookmarklevel\zerocount
   \doutilities{listentries,#1,\@@bookmark}\jobname{#1}\relax\relax}

\def\dodogetbookmarkelement#1#2#3#4#5#6%
  {\doifelsenothing{#1}
     {\global\chardef\currentbookmarklevel\zerocount}
     {\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 \minusone
        \dorecurse\!!countb
          {\edef\bookmarktag
             {\bookmarktag\getvalue{\@@bookcount\recurselevel}:}}%
        \edef\bookmarklevelcount
          {\getvalue{\@@bookcount\the\!!counta}}%
        \xdef\bookmarklevellist
          {\bookmarklevellist/\bookmarktag:\bookmarklevelcount/}%
        \advance\!!counta \minusone
        \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\docommand\@EA[\@EA##\@EA1\@EA/\bookmarktag:##2/##3]%
     {\def\bookmarklevelcount{##2}}%
   \@EA\@EA\@EA\docommand\@EA\@EA\@EA[\@EA\bookmarklevellist\@EA/\bookmarktag:0/]}

\def\dodoputbookmarkelement#1#2#3#4#5#6%
  {\doifelsenothing{#1}
     {\global\chardef\currentbookmarklevel\zerocount}
     {\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\plusone}
     {\chardef\openbookmark\zerocount}%
   \iftracebookmarks(#6: #4)\quad(\the\openbookmark)\par\fi
   \doinsertbookmark{#2}{#3}{#4}{#5}{\openbookmark}}

% \startinteractionmenu[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   \\
% \stopinteractionmenu

\newif\iflocationmenupermitted

\def\testinteractionmenu#1%
   {\iflocation
      \doifelse\@@iamenu\v!on
        {\doifelsevalue{\??am#1\c!state}\v!start
           {\global\locationmenupermittedtrue}
           {\global\locationmenupermittedfalse}}
        {\global\locationmenupermittedfalse}%
    \else
      \global\locationmenupermittedfalse
    \fi}

\def\dodisableinteractionmenu[#1][#2][#3]%
  {\def\dododisableinteractionmenu##1%
     {\doifelse{#3}{}
        {\letvalue{\??am##1\c!obstruction}\empty}
        {\edef\interactieblokkade{\getvalue{\??am##1\c!obstruction}}
         \def\docommand####1{#1{####1}{\interactieblokkade}}% #1 = \remove or \add
         \processcommalist[#3]\docommand
         \setevalue{\??am##1\c!obstruction}{\interactieblokkade}}}%
   \processcommalist[#2]\dododisableinteractionmenu}

\def\disableinteractionmenu
  {\dotripleempty\dodisableinteractionmenu[\addtocommalist]}

\def\enableinteractionmenu
  {\dotripleempty\dodisableinteractionmenu[\removefromcommalist]}

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

\newif\iflocationdummy
\newif\ifskippedmenuitem

\newif\iflocationempty
\newif\iflocationclick

% ja   : kader/achtergrond met tekst
% leeg : kader/achtergrond maar geen tekst
% nee  : alleen ruimte reserveren
% geen : helemaal weglaten
%
% \setupinteractionmenu[right][samepage=yes,  unknownreference=yes]
% \setupinteractionmenu[right][samepage=empty,unknownreference=empty]
% \setupinteractionmenu[right][samepage=no,   unknownreference=no]
% \setupinteractionmenu[right][samepage=none, unknownreference=none]
%
% \startinteractionmenu[right]
% \but [firstpage] first \\
% \but [lastpage] last \\
% \but [somepage] crap \\
% \stopinteractionmenu

\def\dosetlocationboxcontent#1[#2]#3[#4]%
  {\global\skippedmenuitemfalse
   \setbox\locationbox\hbox
     {\resetgoto % anders cyclische aanroep !
      \localframed[#1][#2]{\dolocationattributes{#1}\c!style\c!color{#3}}}%
   \iflocationclick
     \hbox{\gotolocation{#4}{\box\locationbox}}%
   \else
     \hbox{\box\locationbox}%
   \fi}

\let\dosetlocationboxyes\dosetlocationboxcontent

\def\dosetlocationboxempty#1[%
  {\dosetlocationboxcontent{#1}[\c!empty=\v!yes,}

\def\dosetlocationboxno#1[%
  {\dosetlocationboxcontent{#1}[\c!empty=\v!yes,\c!frame=,\c!background=,}

\def\dosetlocationboxnone#1[#2]#3[#4]%
  {\global\skippedmenuitemtrue}

\def\setlocationboxyes#1[#2]#3[#4]%
  {\locationclicktrue
   \setbox\locationbox\hbox
     {\resetgoto % anders cyclische aanroep !
      \global\skippedmenuitemfalse
      \gotolocation
        {#4}% % needed
        {\ifrealreferencepage
           \ifcase\csname\??am\??am\csname#1\c!samepage\endcsname\endcsname\relax
             \copycsname#1\c!color\endcsname\csname#1\c!contrastcolor\endcsname
             \localframed[#1][#2]{\dolocationattributes{#1}\c!style\c!color{#3}}%
           \or
             \localframed[#1][\c!empty=\v!yes,#2]{\dolocationattributes{#1}\c!style\c!color{#3}}%
           \or
             \localframed[#1][\c!empty=\v!yes,\c!frame=,\c!background=,#2]{\dolocationattributes{#1}\c!style\c!color{#3}}%
           \or
             \global\skippedmenuitemtrue
           \fi
         \else
           \localframed[#1][#2]{\dolocationattributes{#1}\c!style\c!color{#3}}%
         \fi}}%
   \ifskippedmenuitem\else\box\locationbox\fi}

\def\setlocationboxnop#1[#2]#3[#4]%
  {\locationclickfalse
   \setbox\locationbox\hbox
     {\resetgoto % anders cyclische aanroep !
      \global\skipp