%D \module
%D   [      file=s-pre-27,
%D        version=1999.08.20,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Environment 27,
%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]

% \setupbodyfont[ppl]

\definetypeface[main][rm][casual][informal][default]
\loadmapfile[original-micropress-informal.map]

\setupbodyfont[main,10pt]

\setuplayout
  [footerdistance=20pt,
   footer=40pt,
  %footer=24pt,
  %bottomdistance=10pt,
  %bottom=12pt,
   header=0pt,
   backspace=20pt,
   topspace=20pt,
   width=middle,
   height=fit]

% \def\MainTitle#1{\setupfootertexts[\hfill#1]}
% \def\SubTitle #1{\setupbottomtexts[\hfill#1]}
%
% \MainTitle{a dull talk held at \currentdate}
% \SubTitle {welcome to whatever}
%
% \setupbottom
%   [style=\ssbf,
%    color=white]
%
% \setupfooter
%   [style=\ssbfb,
%    color=white]

\setupfooter
  [strut=no,
   style=\bfb,
   color=white]

\setupinteraction
  [state=start]

\setupinteractionscreen
  [option=max]

\definecolor[white] [s=.8]
\definecolor[red]   [r=.7]
\definecolor[green] [g=.7]
\definecolor[blue]  [b=.7]
\definecolor[yellow][r=.7,g=.7]

\setupcolors
  [state=start]

\defineoverlay [page]     [\reuseMPgraphic{page}]
\defineoverlay [text]     [\useMPgraphic  {text}]
\defineoverlay [continue] [\overlaybutton {forward}]

\setupbackgrounds
  [page]
  [background={page,continue}]

\definecolor [PageColor] [red]
\definecolor [TextColor] [yellow]

\defineframedtext
  [TopicPage]

\defineframedtext
  [TopicText]

\setupframedtexts
  [TopicPage]
  [width=\textwidth,
   height=\textheight,
   offset=overlay]

\setupframedtexts
  [TopicText]
  [offset=10pt,
   style=bold, % hm
   width=\TopicWidth,
   background=text,
   align=normal]

\setupframedtexts
  [TopicPage,TopicText]
  [frame=off,
   depthcorrection=off,
   before=,
   after=]

\newbox     \TopicBox
\newcounter \KindOfTopic
\newdimen   \TopicWidth

\def\KindOfTopic{1}

\def\StartTopic
  {\getrandomdimen\TopicWidth{.5\textwidth}{.7\textwidth}
   \ifcase\KindOfTopic\or
     \setupframedtexts [TopicPage] [align={right,high}] \or
     \setupframedtexts [TopicPage] [align={left,high}]  \or
     \setupframedtexts [TopicPage] [align={left,low}]   \or
     \setupframedtexts [TopicPage] [align={right,low}]  \fi
   \setbox\scratchbox=\vbox \bgroup \dontcomplain
     \noindent \startTopicPage [none]
       \noindent \startTopicText [none]
         \setuptolerance [verytolerant,stretch]}

\def\StopTopic%
  {\stopTopicText
   \stopTopicPage
   \egroup
   \global\setbox\TopicBox=\vbox
     {\startoverlay
        {\box\TopicBox} {\box\scratchbox}
      \stopoverlay}
   \copy\TopicBox
   \ifnum\KindOfTopic=4
     \def\KindOfTopic{1}
   \else
     \increment\KindOfTopic
   \fi
   \page}

\startuseMPgraphic{text}
  path p ; p := unitsquare xyscaled (OverlayWidth,OverlayHeight) ;
  color c ; c := (.7+uniformdeviate.3)*\MPcolor{TextColor} ;
  p := p enlarged -1.25pt ;
  fill p withcolor c ;
  draw p withpen pencircle scaled 2.5pt withcolor .75c ;
\stopuseMPgraphic

\startreusableMPgraphic{page}
  path p ; p := unitsquare xyscaled (OverlayWidth,OverlayHeight) ;
  color c ; c := \MPcolor{PageColor} ;
  fill p withcolor c ;
  draw p withpen pencircle scaled 2.5pt withcolor c ;
\stopreusableMPgraphic

\def\StartNopic#1\StopNopic
  {\setupfootertexts
     [\vbox to \footerheight
        {\vfill
         \raggedleft
         \def\\{\endgraf\tx\setstrut\strut}
         \setstrut\strut\ignorespaces#1\unskip\endgraf\removedepth}]
   \null \page}

\def\TitlePage#1%
  {\StartNopic#1\StopNopic}

\setuphead[title]  [style=\bfc,after=\blank]
\setuphead[subject][style=\bfa,before=\blank]

\doifnotmode{demo}{\endinput}

\starttext

\TitlePage
  {a dull talk held at \currentdate\\welcome to whatever}

\dorecurse{10}{\StartTopic \input tufte \StopTopic}

\stoptext
