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

%D This module provides some non core functionality that can 
%D be used in the presentations styles. This module contains 
%D experimental macros. 
%D 
%D The presentation environments are independent of each other.
%D Although they have much in common, and in many cases can be
%D exchanged, the common components are not collected in this
%D file. That way they can serve as examples of style
%D definitions. 

\unprotect

\newbox     \presentationstack
\newcounter \presentationcounter
\newdimen   \presentationheight

\appendtoks\doglobal\newcounter\presentationcounter\to\everyshipout

\defineframedtext
  [presentationshield]

\setupframedtexts  
  [presentationshield]
  [\c!achtergrond=\v!kleur,
   \c!achtergrondkleur=StepColor,
   \c!offset=\v!overlay,
   \c!kader=\v!uit]

\definecolor[StepColor][white]

\def\enablepresentationstep%
  {\let\enablepresentationstep\relax
   \useJSpreamblenow{presentation}%
   \stelteksttekstenin
     [\vbox to \teksthoogte
        {\dopresentationstep1\box\presentationstack\vfill}]}

\def\presentationstep%
  {\dopresentationstep0}

\def\dopresentationstep#1%
  {\global\setbox\presentationstack=\vbox
     {\ifnum\presentationcounter=0 
        \global\presentationheight=\!!zeropoint
      \fi
      \ifcase#1\relax
        \scratchdimen=\pagetotal 
      \else
        \scratchdimen=\textheight
      \fi
      \advance\scratchdimen by -\presentationheight
      \global\presentationheight=\pagetotal
      \forgetall
      \offinterlineskip
      \mindermeldingen
      \box\presentationstack
      \doglobal\increment\presentationcounter
      \scratchcounter=\realpageno \multiply\scratchcounter by 100
      \advance\scratchcounter by \presentationcounter
      \edef\presentationtag{presentation:\the\scratchcounter}
      \setupfield
        [presentation]
        [\c!breedte=\v!passend,\c!hoogte=\v!passend,\c!offset=\v!overlay,
         \c!strut=\v!nee,\c!kader=\v!uit,\c!optie={\v!alleenleesbaar}]
      \definesymbol    
        [\presentationtag]
        [\presentationshade]
      \def\presentationshade%
        {\presentationshield
           [\c!breedte=\tekstbreedte,\c!hoogte=\scratchdimen]{}}
      \definefield[\presentationtag][check][presentation][\presentationtag][\presentationtag]
      \fitfield[\presentationtag]}}

\startJSpreamble {presentation} used later 
  var presentation = new Array() ; 
  for (i=1;i<=\lastpage;i++)
    { presentation[i] = 0 } 
  this.dirty = false ; 
  function NextPresentation (pagenumber) 
    { % ++presentation[pagenumber] ; 
      presentation[pagenumber] = presentation[pagenumber] + 1 ; 
      var dummy = 100*pagenumber + presentation[pagenumber] ;
      var v = this.getField("presentation:"+dummy) ;   
      if (v) 
        { v.hidden = true } 
      else
        { ++pagenumber ;
          if (pagenumber<=\lastpage) 
            { presentation[pagenumber] = presentation[pagenumber] + 1 ; 
              dummy = 100*(pagenumber) + presentation[pagenumber] ;
              v = this.getField("presentation:"+dummy) ;   
              if (v) { v.hidden = true } 
              ++this.pageNum } }
      this.dirty = false } 
\stopJSpreamble

\definereference[NextStep][JS(NextPresentation{\realfolio})]

%D \macros 
%D   {presentationstep}
%D
%D The macro \type {\presentationstep} provides a basic slide
%D show functionality. It sort of records pieces of the page 
%D that will show up stepwise. It can be used like: 
%D
%D \starttypen
%D \startitemize
%D \item eerste 
%D \item tweede
%D \stopitemize
%D 
%D \presentationstep 
%D 
%D \startformula
%D   ax^2+bx+c
%D \stopformula
%D 
%D \presentationstep
%D \stoptypen 
%D 
%D When the document is opened, the two text fragments are
%D covered by a shield. Each page has its own shield stack. The
%D logical reference \type {NextStep} can be used to hide the
%D shield. 
%D
%D \starttypen 
%D \setupfootertexts[{\button{Show Up}[NextStep]}]
%D \stoptypen 
%D
%D Special effects can be reached with: 
%D
%D \starttypen 
%D \setupframedtexts  
%D   [presentationshield]
%D   [background=color,backgroundcolor=red]
%D \stoptypen 
%D
%D There is also: 
%D
%D \autopresentationsteptrue
%D
%D One can enable this feature as \type {step} mode. 

\newif\ifautopresentationstep 

\appendtoks \ifautopresentationstep\presentationstep\fi \to \everypar

\doifmode{step}{\enablepresentationstep}

%D When in \type {comment} mode, embedded page comments are 
%D processed and put below the page. The default space of 
%D 5cm should be adequate but can of course be changed. 

\doifmode{comment}{\setuppagecomment[state=start,location=bottom]}

\protect \endinput 
