%D \module
%D   [      file=simpleslides-s-FramedTitle,
%D        version=2009.03.30
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Module --- FramedTitle style,
%D         author=Aditya Mahajan and Thomas A. Schmitz,
%D           date=\currentdate,
%D      copyright={Aditya Mahajan and Thomas A. Schmitz}]
%C
%C Copyright 2007 Aditya Mahajan and Thomas A. Schmitz
%C This file may be distributed under the GNU General Public License v. 2.0.

%D This file provides the \quotation{FramedTitle} style for the presentation
%D module. It is loaded at runtime. The most interesting part is the scratch
%D counter at the bottom of the page, which is explained in the metafun manual.

\writestatus{simpleslides}{loading style FramedTitle}

\startmodule[simpleslides-s-FramedTitle]

\unprotect

%D The page layout:

\setuplayout [width=fit,
              margin=0cm,
              height=fit,
              header=2.2cm, 
              footer=.8cm, 
              topspace=.6cm, 
              backspace=1cm,
              location=singlesided]

\setuplayout [simpleslides:layout:horizontal][header=2.2cm]
\setuplayout [simpleslides:layout:vertical]  [header=0.5cm]
\setuplayout [simpleslides:layout:title]     [header=0.5cm]

%D We also specify the position of the slidetitle.

\setuplayer[simpleslides:layer:slidetitle]
    [x=10mm,y=2mm]


%D These macros are used for placing figures/pictures:

\define\NormalHeight        {\textheight}
\define\NormalWidth         {.476\textwidth}
\define\PictureFrameHeight  {\textheight}
\define\PictureFrameWidth   {.476\textwidth}

\setupframed[simpleslides:framed]
             [corner=round,
              background=color,backgroundcolor={simpleslides:contrastcolor}]

%D We define our color scheme:

\definecolor [simpleslides:backgroundcolor]       [s=.9]
\definecolor [simpleslides:variantcolor]        [s=.7]
\definecolor [simpleslides:contrastcolor]         [r=.5]
\definecolor [simpleslides:itemize:color]         [simpleslides:contrastcolor]

%D We let Metapost calculate the background:

\startuniqueMPgraphic{simpleslides:MP:horizontal} 
StartPage ;
fill Page withcolor \MPcolor{simpleslides:backgroundcolor} ;
StopPage ;
\stopuniqueMPgraphic 

\startuseMPgraphic{simpleslides:MP:ornament}
StartPage ;

save a,b ;
numeric a,b ;
a = 7mm ;
b = PaperWidth/2 - NOfPages * 2.5pt ;

save p,q; path p,q ;
p =((0,5mm)    -- (1mm,11mm)) shifted (b,0) ;
q =((-8mm,5mm) -- (0,11mm)  ) shifted (b,0) ;

pickup pencircle scaled 3pt ;
for i := NOfPages-1 downto 1:
  draw (if i mod 5 = 0 : q else : p fi)
       shifted (i*5pt, 0pt)
       withcolor if i < PageNumber : \MPcolor{simpleslides:contrastcolor} 
                 else :              \MPcolor{simpleslides:variantcolor}
                 fi ;
endfor ;
StopPage ;
\stopuseMPgraphic

%D We define these backgrounds as overlays:

\defineoverlay 
  [simpleslides:background:horizontal] 
  [\useMPgraphic{simpleslides:MP:horizontal}] 

\defineoverlay 
  [simpleslides:background:vertical] 
  [\useMPgraphic{simpleslides:MP:horizontal}] 

\defineoverlay 
  [simpleslides:background:title] 
  [\useMPgraphic{simpleslides:MP:horizontal}] 

\defineoverlay 
  [simpleslides:background:ornament] 
  [\useMPgraphic{simpleslides:MP:ornament}] 

%D We want the title to placed in a framed box. We redefine all the keys of
%D \type{\setupTitle}, so that the module is easier to maintain.

\setupTitle
  [\c!title=,
   \c!author=,
   \c!date=\currentdate,
   \c!headstyle=,
   \c!headcolor={simpleslides:backgroundcolor},
   \c!align=\v!middle,
   \c!before={\vfill\getvalue{simpleslides:framed}
              [\c!width=\textwidth,\c!height=.75\textheight,
               \c!align=\v!middle, \c!strut=\v!no]
              \bgroup},
   \c!after={\egroup\vfill},
   \c!title\c!style={\switchtobodyfont[\TitleSize]},
   \c!title\c!color=,
   \c!title\c!align=,%\v!middle,
   \c!author\c!style=,
   \c!author\c!color=,
   \c!author\c!align=,%\v!middle, 
   \c!date\c!style=,
   \c!date\c!color=,
   \c!date\c!align=,%\v!middle,
   \c!before\c!title=,
   \c!before\c!author=,
   \c!before\c!date=,
   \c!after\c!title={\blank[1*line]},
   \c!after\c!author={\blank[2*line]},
   \c!after\c!date=]

%D We also want the slide title in a framed box.

\setupSlideTitle
  [\c!after=,
   \c!alternative=layer,
   \c!height=2.1cm,
   \c!width=\textwidth,
   \c!color=simpleslides:backgroundcolor]


%D The symbol for the first level of itemizations. 

\definesymbol[1][\useMPgraphic{simpleslides:itemize:square}]
\setupitemize[1][color=simpleslides:contrastcolor]

\protect
\stopmodule

\endinput

