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

\setuppapersize
  [S6][S6]

\setuplayout
  [topspace=0cm,
   backspace=0cm,
   header=0pt,
   footer=0pt,
   width=middle,
   height=middle]

\setupbodyfont
  [14.4pt,lbr]

\setupcolors
  [state=start]

\setupinteraction
  [click=no,
   display=new,
   state=start]

\setupinteractionscreen
  [option=max]

\def\SomeShape%
  {\resetMPdrawing
   \startMPdrawing
     path p ; pair a, b ;
     ahlength := .375cm ;
     StartPage ;
     draw Page %unitsquare
       %xscaled PaperWidth yscaled PaperHeight
       withpen pencircle scaled .5cm
       withcolor \MPcolor{EdgeColor} ;
   \stopMPdrawing
   \dorecurse{\CurrentTopic}
     {\startMPdrawing
        initialize_box(\MPpos{topic-\realfolio-\recurselevel}) ;
        p := tensecircle (wxy,hxy,.25cm) shifted cxy ;
        fill p withcolor .9white  ;
        pickup pencircle scaled .25cm ;
        \ifnum\recurselevel=\CurrentTopic
          draw p withcolor \MPcolor{ShowColor} ;
          a := bot point 7 of p ;
        \else
          draw p withcolor \MPcolor{DoneColor} ;
        \fi
      \stopMPdrawing}
   \dorecurse{\CurrentMaxItem}
     {\startMPdrawing
        initialize_box(\MPpos{item-\realfolio-\recurselevel}) ;
        linewidth := .25cm ; 
        p := tensecircle (wxy,hxy,linewidth) shifted cxy ;
        fill p withcolor .9white  ;
        pickup pencircle scaled linewidth ;
        b := rt point 3 of p ;
        \ifnum\recurselevel=\CurrentMaxItem
          draw p withcolor \MPcolor{ShowColor} ;
        \else
          draw p withcolor \MPcolor{DoneColor} ;
        \fi
        dxab := xpart a-xpart b ; 
        dyab := ypart a-ypart b ; 
        sign := if dyab>0 : - fi 1 ;
        drawarrow
          a --
          a shifted (+2linewidth-dxab/2,0) {left} ..
          if abs(dyab)>4linewidth :
            a shifted (-dxab/2,+sign*2linewidth) --
            b shifted (+dxab/2,-sign*2linewidth) ..
          fi 
          {left} b shifted (-2linewidth+dxab/2,0) --
          b
          withcolor \MPcolor{ArrowColor} ;
      \stopMPdrawing}%
   \startMPdrawing
     StopPage ;
   \stopMPdrawing
   \MPdrawingdonetrue
   \getMPdrawing}

\definecolor[PageColor][r=.5,g=.4,b=.3]
\definecolor[LineColor][r=.7,g=.6,b=.5]

\definecolor[PageColor]  [s=.60]
\definecolor[ShowColor]  [r=.40]
\definecolor[EdgeColor]  [g=.40]
\definecolor[DoneColor]  [r=.40,g=.40]
\definecolor[ArrowColor] [b=.40]
\definecolor[LineColor]  [r=.60,g=.60]
\definecolor[GotoColor]  [ArrowColor]

\setupinteraction[color=GotoColor,contrastcolor=GotoColor]

\defineoverlay [shape] [\SomeShape]
\defineoverlay [next]  [\overlaybutton{forward}] 

\setupbackgrounds
  [page]
  [background={color,next,shape},
   backgroundcolor=PageColor]

\doglobal\newcounter\CurrentItem
\doglobal\newcounter\CurrentTopic
\doglobal\newcounter\CurrentMaxItem

\def\StartIdea%
  {\doglobal\newcounter\CurrentItem}

\def\StartTopic%
  {\doglobal\increment\CurrentTopic
   \dostartbuffer[topic-\CurrentTopic][StartTopic][StopTopic]}

\def\StopIdea%
  {\dorecurse{\CurrentItem}
     {\let\CurrentMaxItem\recurselevel
      \doStopIdea}}

\def\IdeaWidth {.6\makeupwidth} % .5
\def\TopicWidth{.2\makeupwidth} % .3

\def\doStopIdea%
  {\startstandardmakeup
   \dontcomplain
   \vbox to \makeupheight
     {\vskip.75cm \relax % \vfill
      \dorecurse{\CurrentMaxItem}
        {\edef\Item{item-\realfolio-\recurselevel}
         \hbox to \makeupwidth
           {\hskip.75cm
            \hpos
              {\Item}
              {\framed
                 [width=\IdeaWidth,frame=off,
                  align=middle,offset=.125cm]
                 {\getbuffer[item-\recurselevel]}}}
         \vskip.875cm}
      \vfill}
   \vskip-\makeupheight
   \vbox to \makeupheight
     {\vskip.75cm \relax
      \dorecurse{\CurrentTopic}
        {\edef\Topic{topic-\realfolio-\recurselevel}
         \hbox to \makeupwidth
           {\hfill
            \hpos
              {\Topic}
              {\framed
                 [width=\TopicWidth,frame=off,
                  align=middle,offset=.25cm]
                 {\getbuffer[topic-\recurselevel]}}%
            \hskip.75cm}
         \vskip.875cm}
      \vfill}
   \stopstandardmakeup}

\def\StartItem%
  {\doglobal\increment\CurrentItem
   \dostartbuffer[item-\CurrentItem][StartItem][StopItem]}

\lefthyphenmin =\maxdimen
\righthyphenmin=\maxdimen

\def\TitlePage#1%
  {\startstandardmakeup
     \setupalign[middle]
     \def\\{\vfil\bfb\setupinterlinespace}
     \bfd\setupinterlinespace
     \vfil#1\vfil\vfil
   \stopstandardmakeup}

\endinput 

% \starttext
% 
% \StartIdea
%   \StartTopic
%      What a topic
%   \StopTopic
%   \StartItem
%     \input reich \relax
%   \StopItem
%   \StartItem
%     \input reich \relax
%   \StopItem
%   \StartItem
%     \input reich \relax
%   \StopItem
% \StopIdea
% 
% \StartIdea
%   \StartTopic
%      One More Nice Idea
%   \StopTopic
%   \StartItem
%     \input reich \relax
%  \StopItem
%   \StartItem
%     \input reich \relax
%   \StopItem
% \StopIdea
% 
% \StartIdea
%   \StartTopic
%      The Last Idea
%   \StopTopic
%   \StartItem
%     \input tufte \relax
%   \StopItem
% \StopIdea
% 
% \stoptext
