%D \module
%D   [      file=s-pre-01,
%D        version=1997.07.22,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Environment 1,
%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 environment can be used to typeset interactive
%D presentations. This module was first used at the 1997 \TUG\
%D meeting.

\usemodule[pre-general] 

%D \macros
%D   {language}
%D
%D Because this module is defined in english, we default to the
%D english hyphenation patterns and labels too.

\language
  [en]

%D \macros
%D   {setupbodyfont,setuplayout}
%D
%D For screen reading, a Lucida Bright font looks nice. We use
%D a 14.4 point bodyfont for the main text, but switch back to 
%D 12 points for ornaments.

\startmode[asintended] \setupbodyfont[lbr] \stopmode

\setupbodyfont[14.4pt]

\setuplayout
  [style=smallbodyfont]

%D \macros
%D   {setupcolors,definecolor}
%D
%D Screen presentations without color just look dull, so we
%D enable color support. We define ourselves a yellowish
%D backgroundcolor and a not too dark blue interactioncolor.

\setupcolors
  [state=start]

\definecolor [BackgroundColor]  [r=1,  g=1,  b=.7]
\definecolor [InteractionColor] [r=.1, g=.5, b=.8]
\definecolor [ContrastColor]    [r=.9, g=.5, b=.2]

%D \macros
%D   {setuppapersize,setuplayout,setupinteractionscreen}
%D
%D
%D We use a nice large screen, and dedicate the right edge and
%D bottom part to navigational tools. We automatically set
%D the width and height of the page and start up full screen.

\setuppapersize
  [S6][S6]

\setuplayout
  [topspace=12pt,
   header=0pt,
   footer=0pt,
   height=402pt, % 450 - 12 - 15 - 12 - 12 + 3 
   bottomdistance=15pt,
   bottom=12pt,
   backspace=12pt,
   margin=0pt,
   width=fit,
   edgedistance=12pt,
   rightedge=96pt]

\setupinteractionscreen
  [option=max]

%D \macros
%D   {setupbackgrounds}
%D
%D We set the pagecolor to yellow except the part of the screen
%D that is used to display the running text. By seting the
%D offset to 3pt the text will not touch the yellow parts. We
%D do not set the depth.

\setupbackgrounds
  [page]
  [background=color,
   backgroundcolor=BackgroundColor,
   offset=3pt]

\setupbackgrounds
  [text][text]
  [background=color,
   backgroundcolor=white]

%D I considered the next setup too, but finaly decided to
%D comment it out.
%D
%D \starttyping
%D \setupbackgrounds
%D   [bottom][text]
%D   [frame=on,
%D    framecolor=white]
%D \stoptyping

%D \macros
%D   {setupinteraction}
%D
%D We did not enable interactive text support yet, so let's do
%D that now. We force page reference to circumvent problems
%D with named destinations in buggy viewers. 

\setupinteraction
  [page=yes,
   color=InteractionColor,
   contrastcolor=ContrastColor,
   menu=on,
   state=start]

%D \macros
%D   {setupinteractionmenu,startinteractionmenu}
%D
%D At the bottom of the screen we show two navigational bars.
%D At the left we show the subpage bar, at the right we use a
%D non default backward|/|forward bar.

\setupinteractionmenu
  [bottom]
  [leftoffset=-3pt,
   rightoffset=-3pt]

\startinteractionmenu[bottom]
  \txt \InteractionBar \\ 
  \txt \InteractionButtons \\ 
\stopinteractionmenu

%D \macros
%D   {interactionbar}
%D
%D The left bar gets a white border (on the yellow background).
%D Because we don't want to typeset an empty frame when no
%D subpage bar is shown, we check for the number of subpages.

\def\InteractionBar%
  {\ifnum\nofsubpages>1
     \framed
       [framecolor=white,rulethickness=1pt,
        height=\bottomheight,strut=no]
       {\interactionbar[alternative=f,width=.5\makeupwidth,height=1ex]}
   \fi}

%D \macros
%D   {setupinteractionbar, interactionbuttons}
%D
%D The right hand buttons enable us to jump backward and forward,
%D as well as to the previous and next jump. We also enable to
%D close the presentation.

\setupinteractionbar
  [framecolor=white,rulethickness=1pt,
   height=\bottomheight,strut=no]
   
\def\InteractionButtons%
  {\interactionbuttons
     [width=15em]
     [PreviousJump,NextJump,
      firstpage,
      firstsubpage,previouspage,nextpage,lastsubpage,
      lastpage,
      CloseDocument]}

%D \macros
%D  {StartTitlePage, TitlePage}
%D
%D The titlepage is rather simple and can be typeset in two 
%D ways: 
%D
%D \starttyping
%D \StartTitlePage
%D text \\ text \\ text 
%D \StopTitlepage
%D \stoptyping
%D
%D or more straightforward:
%D
%D \starttyping
%D \TitlePage{text\\text\\text} 
%D \stoptyping
%D 
%D The first alternative can be used for more complicated 
%D title pages.  

\def\StartTitlePage%
  {\startstandardmakeup
   \bfd\setupinterlinespace
   \setupalign[middle]
   \vfil
   \let\\=\vfil}

\def\StopTitlePage%
  {\vfil\vfil\vfil
   \stopstandardmakeup}

\def\TitlePage#1%
  {\StartTitlePage#1\StopTitlePage}

%D \macros
%D   {TitlePage, Topics, Topic, Subject}
%D
%D A presentation after loading this module looks like:
%D
%D \starttyping
%D \TitlePage {About Whatever\\Topics}
%D
%D \Topics {Todays Talk}
%D
%D \Topic {Some topic}
%D
%D \Subject {Alfa}
%D
%D .....
%D
%D \Subject {Beta}
%D
%D .....
%D \stoptyping

%D \macros
%D   {definehead}
%D
%D The commands \type{\Topic} and \type{\Subject} are defined
%D as copies of head. We use \type{\Nopic} for internal 
%D purposes. 

\definehead [Topic]   [chapter]
\definehead [Subject] [section]

\definehead [Nopic]   [title]

%D \macros
%D   {setuphead}
%D
%D Because chapters and sections do not make sense in 
%D presentations, we use our own command for typesetting the 
%D titles. Sectionnumbers are of course hidden from viewing. 
%D Each topic is followed by a list of subjects that belong 
%D to the topic.

\setuphead
  [Topic, Nopic, Subject]
  [command=\HeadLine,
   page=yes,
   style=\tfb,
   after=\blank,
   sectionnumber=no]

\setuphead
  [Topic]
  [after=\PlaceSubjectList]

\setuphead
  [Subject]
  [continue=no]

%D \macros
%D   {framed, midalined}
%D
%D The command used to typeset the head lines is rather simple.
%D We just center the framed title. The frame macro optimizes
%D the alignment and at the same time enables us to typeset a
%D nice colored rule.

\def\HeadLine#1#2%
  {\midaligned
     {\framed
        [framecolor=BackgroundColor,rulethickness=1pt,
         width=.8\hsize,align=middle,strut=no]
        {#2}}}

%D \macros
%D   {setuplist}
%D
%D The subject list is automatically placed. We center each
%D subject line by using one of the default alternatives (g). We
%D could have said:
%D
%D \starttyping
%D \setuplist
%D   [Subject]
%D   [alternative=none,
%D    command=\SubjectListLine,
%D    interaction=all]
%D
%D \def\SubjectListLine#1#2#3%
%D   {\midaligned{#2}}
%D \stoptyping
%D
%D But why should we complicate things when we can use 
%D alternative~\type{g}. The test is only needed if one 
%D does not automatically goes a new page with each subject. 

\def\PlaceSubjectList%
  {\blank
   \determinelistcharacteristics[Subject] 
 % \ifnum\utilitylistlength>0 \placelist[Subject] \fi}
   \doifmode{*list}{\placelist[Subject]}} 

\setuplist
  [Subject, Topic]
  [alternative=g,
   interaction=all,
   before=,
   after=]

% %D \macros
% %D   {setuptexttexts}
% %D
% %D The topics will be listed in the right edge, using:
% 
% \setuptexttexts
%   [edge]
%   [][\TopicList]

%D \macros
%D   {setuplist, placelist,startinteractionmenu}
%D
%D The actual topic list is typeset using a \type{\vbox}. We
%D have to specify \type{criteriumcriterium=all} because otherwise no 
%D list will be typeset. (By default lists are typeset 
%D locally.)

\startinteractionmenu[right]
  \placelist
    [Topic]
    [alternative=f, % command, % none,
     maxwidth=\hsize,
     width=\hsize,
     offset=0pt,
     criterium=all,
     align=left,
     style=\setsmallbodyfont\bfx]
\stopinteractionmenu

\def\Topics#1% temporary hack 
  {\Nopic{#1}
   \placelist[Topic][criterium=all]}

\def\Subjects%
  {}

%D \macros
%D   {setuptexttexts, button}
%D 
%D During a presentation, we want to use the cursor to point to
%D parts of the text. Furthermore we want to be able to jump to
%D the next page, without the need to move the cursor on buttons.
%D Therefore we make the text part of the screen into an
%D invisible button. 

\setuptexttexts
  [\GotoNextPage][]

\def\GotoNextPage
  {\button[width=\hsize,height=\vsize,frame=off]{}[nextpage]}

%D \macros
%D   {setupsubpagenumber}
%D
%D The left bottom navigation bar shows the subpages, which will
%D be counted by text. One can change this in the preentation 
%D itself by saying \type {[way=byTopic]}. 

\setupsubpagenumber
  [way=bytext, % Topic,
   state=start]

\endinput
