%D \module
%D   [      file=s-pre-13,
%D        version=1999.08.20,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Environment 13,
%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 is again one of the \EUROTEX\ 99 styles. It's one of
%D the quick and dirty styles supporting basic structuring. 

\setuppapersize
  [S6][S6]

\setuplayout
  [width=middle,
   height=middle,
   header=0pt,
   footer=0pt,
   bottomdistance=.5cm,
   bottom=1cm,
   topspace=2cm,
   backspace=2cm]

%D This style is meant to be used with lucida handwriting 
%D fonts. If you don't have that font, you may reconsider 
%D using this style. 

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

%D These colors will mostly be used in the graphics drawn by
%D \METAPOST. 

\setupcolors
  [state=start]

\definecolor[PageColor]  [s=.6]
\definecolor[TextColor]  [s=.8]
\definecolor[LineColor]  [g=.4]
\definecolor[SymbolColor][r=.4]

%D When interacting, we will use button shaped that are 
%D quite random and thereby regenerated for each instance. 

\setupinteractionscreen
  [option=max]

\setupinteractionmenu
  [bottom]
  [state=start,
   height=1cm,
   middle=\hskip1cm]

\setupinteraction
  [state=start,
   menu=on,
   display=new,
   click=no,
   color=SymbolColor,
   contrastcolor=SymbolColor]

\startinteractionmenu[bottom]
  \hfill
  \got [previouspage]  \symbol[prevmark] \\ 
  \got [nextpage]      \symbol[nextmark] \\ 
  \got [CloseDocument] \symbol[stopmark] \\ 
  \txt \tfd \SymbolColor \pagenumber     \\ 
\stopinteractionmenu

%D When not processed at runtime, the itemmark graphics can
%D result in processing loops due to funny dimensions.
%D Therefore, from now on, the itemize macros limit the height
%D and depth. 

\definesymbol[itemmark][\useMPgraphic{itemmark}]
\definesymbol[stopmark][\useMPgraphic{stopmark}]
\definesymbol[nextmark][\useMPgraphic{nextmark}]
\definesymbol[prevmark][\useMPgraphic{prevmark}]

%D Of course we have some backgrounds. 

\defineoverlay [page] [\useMPgraphic{page}]
\defineoverlay [next] [\overlaybutton{forward}]
\defineoverlay [prev] [\overlaybutton{PreviousJump}]

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

\setupbackgrounds
  [text]
  [background=next] 

\setuphead
  [chapter]
  [alternative=middle,
   number=no,
   color=SymbolColor,
   style=\tfc]

%D A little bit of tweaking.

\setupwhitespace
  [big]

\setupitemize
  [1]
  [symbol=itemmark,
   width=3\bodyfontsize]

\def\StartTitlePage%
  {\setupinteractionmenu[bottom][state=stop] % will be named page block 
   \startstandardmakeup
     \setupalign[middle]
     \def\\%
       {\stopcolor
        \vfil
        \bfb\setupinterlinespace
        \startcolor[black]}
     \bfd\setupinterlinespace
     \vfil
     \startcolor[SymbolColor]}

\def\StopTitlePage
  {\stopcolor
   \vfil\vfil
   \stopstandardmakeup
   \setupinteractionmenu[bottom][state=start]}


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

\definehead[Topic][chapter]
\definehead[Nopic][title]

\setuplist
  [Topic]
  [criterium=all,
   alternative=g,
   interaction=all,
   after=\blank]

\def\Topics#1%
 {\Nopic{#1}
  \bgroup
  \setupinteraction  
    [color=,
     contrastcolor=]
   \determinelistcharacteristics[Topic]
   \ifnum\utilitylistlength>12  
     \startcolumns[n=2]
       \placelist[Topic]
     \stopcolumns
   \else
     \placelist[Topic]
   \fi
  \egroup}

%D We don't support another level of structuring. 

\let\Subject \Topic
\let\Subjects\relax

%D Most of this style is \METAPOST\ definitions. We could 
%D have shared some code, but it would not on forehand make 
%D things more readable, so we stick to the following 
%D definitions. 

\startuseMPgraphic{page}

 width  := \overlaywidth ; 
 height := \overlayheight ; 

 d := 15 ; dd := d ;          dd := 10 ; 

 def fuzzy (expr p,dx,dy) = 
   (xpart p +dx-uniformdeviate dx,ypart p+dy-uniformdeviate dy)
 enddef ; 

 pair ll, lr, ur, ul ; 

 ll := (d,d) ;
 lr := (width-d,d) ;
 ur := (width-d,height-d) ;
 ul := (d,height-d) ;

 path p, q, r, s ; 

 p := ll.. for i=.1 step .1 until .9 : fuzzy (i[ll,lr],0,+dd).. endfor lr ;
 q := lr.. for i=.1 step .1 until .9 : fuzzy (i[lr,ur],-dd,0).. endfor ur ;
 r := ur.. for i=.1 step .1 until .9 : fuzzy (i[ur,ul],0,-dd).. endfor ul ;
 s := ul.. for i=.1 step .1 until .9 : fuzzy (i[ul,ll],+dd,0).. endfor ll ;

 fill unitsquare xscaled width yscaled height withcolor \MPcolor{PageColor} ;

 fill p & q & r & s -- cycle withcolor \MPcolor{TextColor} ;

 color c ; c := \MPcolor{LineColor} ; 

 draw p withpen pencircle xscaled 20 yscaled  5 rotated 30 withcolor c ;   
 draw q withpen pencircle xscaled  5 yscaled 20 rotated 30 withcolor c ;   
 draw r withpen pencircle xscaled 20 yscaled  5 rotated 30 withcolor c ;   
 draw s withpen pencircle xscaled  5 yscaled 20 rotated 30 withcolor c ;   

\stopuseMPgraphic

\startuseMPgraphic{itemmark}
  width     := BodyFontSize ; height := width/4 ; 
  maxheight := StrutHeight  ; line   := 3width/2 ;

  def fuzzy = -(height/4)+uniformdeviate (height/2) enddef ; 

  draw 
    ((0,0+fuzzy)--(width,height+fuzzy/2)) 
      shifted (line/2,0) 
    withpen pencircle 
      xscaled line yscaled (line/4) 
      rotated (25+uniformdeviate 10) withcolor \MPcolor{SymbolColor} ;   

  setbounds currentpicture to unitsquare xyscaled(width,maxheight) ;
\stopuseMPgraphic

\startuseMPgraphic{nextmark}
  LoadPageState ; width := BottomHeight ; height := line := width/2 ;

  def fuzzy = -(height/8)+uniformdeviate (height/4) enddef ; 

  z1 = (0,0+fuzzy) ; z2 = (width,height/2+fuzzy/2) ; z3 = (0,height+fuzzy) ;

  draw 
    (z1..{right}z2 & z2{left}..z3)
    withpen pencircle 
      xscaled line yscaled (line/4) 
      rotated 30 withcolor \MPcolor{SymbolColor} ;    

  setbounds currentpicture to unitsquare xyscaled(width,height) ;
\stopuseMPgraphic

\startuseMPgraphic{prevmark}
  LoadPageState ; width := BottomHeight ; height := line := width/2 ;

  def fuzzy = -(height/8)+uniformdeviate (height/4) enddef ; 

  z1 = (width,0+fuzzy) ; z2 = (0,height/2+fuzzy/2) ; z3 = (width,height+fuzzy) ;

  draw 
    (z1..{left}z2 & z2{right}..z3)
    withpen pencircle 
      xscaled line yscaled (line/4) 
      rotated 30 withcolor \MPcolor{SymbolColor} ;    

  setbounds currentpicture to unitsquare xyscaled(width,height) ;
\stopuseMPgraphic

\startuseMPgraphic{stopmark}
  LoadPageState ; width := BottomHeight ; height := line := width/2 ;

  def fuzzy = -(height/8)+uniformdeviate (height/4) enddef ; 

  z1 = (0,0+fuzzy) ;
  z2 = (width,height+fuzzy) ;
  z3 = (width,0+fuzzy) ;
  z4 = (0,height+fuzzy) ;
  z5 = (width/2,height/2) ;

  drawoptions 
   (withpen pencircle 
      xscaled line yscaled (line/4) 
      rotated 30 withcolor \MPcolor{SymbolColor}) ;   

  draw z1..{right}z5..z2 ; draw z3..{left}z5..z4 ;

  setbounds currentpicture to unitsquare xyscaled(width,height) ;
\stopuseMPgraphic

\endinput 
