scrn-nav.mkii / last modification: 2020-01-30 14:15
%D \module
%D   [       file=scrn-nav,
%D        version=1998.01.15,
%D          title=\CONTEXT\ Core Macros,
%D       subtitle=Navigation,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Screen Macros / Navigation}


%D Support for interactive document is very present in
%D \CONTEXT\ and interwoven in many modules. This means that in
%D this module, where we deal with some common navigational
%D features, there will be quite some forward references.
%D When I started implementing hypertext support, the macros
%D were mostly dealing with things related to locations, that
%D is click in this location and goto that one. The
%D functionality of many macro depends on the output medium:
%D paper or screen. The next boolean holds the state:

\newif\iflocation  \def\ifinteractief{\iflocation} % upw comp

%D We also allocate a scratchbox:


%D There is no interaction at all unless enabled by saying:
%D \starttyping
%D \setupinteraction[state=start]
%D \stoptyping
%D The other settings are:
%D \showsetup{setupinteraction}
%D In the special driver modules we introduced a switch that
%D forces page destinations (instead of named ones). We set
%D this switch here.

\def\setinteractionparameter#1#2% use with case, no checking done
  {\setvalue{\??ia#1}{#2}}      % pass #2, can be \blabla

\def\resetinteractionparameter#1% use with case, no checking done

% \def\interactionparameter#1%
%   {\csname\??ia#1\endcsname}



\def\dodosetupinteraction[#1]% % \dosetupinteraction == special

% todo, move partial append to where the action happens

    \setsystemmode  \v!interaction
\to \everysetupinteraction

%D We have to make sure of some settings:

     \handlereferenceactions\@@iaopenaction \dosetupopenaction

\appendtoks \dolocationstartup \to \everyshipout

\def\dolocationpagecheck % brr pdf dependent
     \handlereferenceactions\@@iaopenpageaction \dosetupopenpageaction

\appendtoks \dolocationpagecheck \to \everyshipout

%D The next few macros are really horrible. For proper
%D navigation a in||line hypertext fragment must have
%D comfortable properties, so we must force some minimal
%D dimensions. On the other hand button, and here I mean those
%D pieces of text with fancy outlines and/or backgrounds, often
%D have fixed, preset dimensions.
%D To make things even worse, if we choose to let the optimal
%D dimensions depend on the height and depth of a strut, a not
%D too uncommon practice in \TEX, we have to deal with the fact
%D that such a strut, set inside a box, is unknown too the
%D outside world.
%D The solution lays in passing the strut characteristics in
%D a proper way, in our case by applying \type{\presetgoto}:
%D \starttyping
%D {some piece of text \presetgoto}
%D \stoptyping
%D This macro stores the current strut values.





%D In the macros that deal with making areas into hyperlinks,
%D we use:




          \dimen0=\@@ia@@diepte\relax % = !
        \advance\buttonheight \dimen0
              \dimen0=.5\wd0 % direct skipping is faster of course
              \advance\dimen0 -.5\buttonwidth % buts this is nicer
              \hskip\dimen0#2#3}}% when visualizing things
        \naturalhbox % needed for omega / moved from plus-omg

%D The secondary references are processed but not typeset. The
%D special driver must collect the data needed.

%D The width of the active area depends on the dimensions
%D preset, the actual dimens and/or the height and depth of the
%D strut.
%D Normally the hyper active area is laid on top of the text.
%D This enables stacking hyperlinks on top of each other. When,
%D for some reason the opposite is prefered, one can use the
%D next boolean to signal this wish.

\newif\ifreversegoto \reversegotofalse

%D As long as there a natural feeling of what can be considered
%D hyper active or not, we have to tell users where they can
%D possibly click. We've already seen a few macros that deal
%D with this visualization, something we definitely do not let
%D up to the viewer. One way of telling is using a distinctive
%D typeface, another way is using color.
%D There are two colors involved: one for normal hyperlinks,
%D and one for those that point to the currentpage, the
%D contrast color.

\definecolor [interactioncolor]         [r=0,  g=.6, b=0]
\definecolor [interactioncontrastcolor] [r=.8, g=0,  b=0]

\definecolor [interactiekleur]          [interactioncolor]
\definecolor [interactiecontrastkleur]  [interactioncontrastcolor]

%D The next few macros are responsible for highlighting hyper
%D links. The first one, \type{\showlocation}, is used in those
%D situations where the typeface is handled by the calling
%D macro.

\def\interactioncolor % todo \??ia as argument



%D When local color settings are to be used, we can use the
%D next macro, where \type{#1} is a tag like \type{\??tg} and
%D \type{#2} some text.


%D When we're dealing with pure page references, contrast
%D colors are used when we are already at the page mentioned.

\def\showcontrastlocation#1#2#3% the \@EA is needed

%D The next simple macro can be used in color specifications,
%D like \type{\color[\locationcolor{green}]}.


%D More tokens are spend when we want both typeface and color
%D highlighting.

   \@EA\doconvertfont\@EA{\fontattribute}{#4}% no \edef, but \@EA here


%D Although not decently supported in current viewers, a
%D provisory hiding mechanims is implemented. Areas marked as
%D such, are visible on screen, but invisible on paper. Don't
%D trust this mechanism yet!


\let\startinteraction = \relax
\let\stopinteraction  = \relax

% in the future:
% eerst boolean invoeren bij menu, achtergrond, balk, button
% enz; verder startinteractie een argument meegeven {#1} ->
% \getvalue{#1\c!print}=={\v!ja} enz. Consequent menubutton
% gebruiken!

   \ifnum\normalmonth<10 0\fi\the\normalmonth
   \ifnum\normalday  <10 0\fi\the\normalday}

% happens in core-fld
% \definereference [AtOpenInitializeForm] [\v!geen]

\setupinteraction % start fit page and reset form
  %\c!openaction=\v!ResetForm, % too buggy in reader 4.05
   \c!title=\jobname, % needed for fdf/x

\protect \endinput