%D \module
%D   [      file=t-redframe,
%D        version=2007.07.17, 
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Module redframe,
%D         author=Thomas A. Schmitz,
%D           date=\currentdate,
%D      copyright={Thomas A. Schmitz}]
%C
%C Copyright 2007 Thomas A. Schmitz.
%C This file may be distributed under the GNU General Public License v. 2.0.

%D This file provides the \quotation{redframe} style for the presentation
%D module. It is loaded at runtime. The look of this style was inspired by the
%D screen version of the Metafun manual. 

\writestatus{loading}{module redframe}

\startmodule[redframe]

\unprotect

%D The taspresentation module provides a skeleton into which different styles
%D can be hooked. It uses a number of variables and macros which have to be set
%D beforehand. Some parts are optional. We begin with the necessary definitions:

%D We start colors:

\setupcolors[state=start]

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

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

%D The page layout:

\setuplayout [width=fit,
              margin=2cm,
              height=fit,
	      leftmargindistance=1cm,
	      rightmargindistance=0cm,
              header=2.8cm, 
              footer=1cm, 
              topspace=.7cm, 
              backspace=2cm,
              location=singlesided]

%D The macro for typesetting the Slidetitle; this is adapted from a sample
%D document that Brooks Moses published on the wiki:

\definelayer[slidetitle]
    [width=\paperwidth,
    height=\paperheight,
    x=20mm,
    y=16mm]

\define[1]\Slidetitle{\page\setlayer[slidetitle]%
     {\framed[frame=off,width=\textwidth,height=2.3cm,offset=0pt,top=\vss,bottom=\vss]{\switchtobodyfont[\Titlesize]\color[FrameColor]{#1}}}}

%D The macro \tex{Maketitle} produces a default title page with the author, the
%D title of the presentation, and the date. Using it is not mandatory.

\define\Maketitle{%
\titback
\null
\vfill
\midaligned{\switchtobodyfont[\Titlesize]\color[FrameColor]{\getvariable{taspresent}{title}}}
\blank[2*line]
\midaligned{\color[FrameColor]{\getvariable{taspresent}{author}}}
\blank[3*line]
\midaligned{\color[FrameColor]{\currentdate}}
\vfill
\null}

%D The following parts are optional; if you don't use backgrounds and are
%D content with CONTEXT's default itemization, you don't have to set these
%D macros. 

%D We define our colors:

\definecolor [lightb]           [s=.75]
\definecolor [darkb] 	        [s=.2]
\definecolor [BackgroundColor]  [s=.6]
\definecolor [FrameColor]       [r=.55, g=0, b=.04]
\definecolor [Item]             [r=.55, g=0, b=.04]
\definecolor [DarkYellow]       [s=.6]%[r=.73, g=.61, b=.25] % gray looks better?

%D We let Metapost calculate the background:

\startuniqueMPgraphic{slide} 
StartPage ;
path p[] ;
a=1.5cm ;
fill Page withcolor \MPcolor{lightb} ;
path Main ;
z1 = ulcorner Page shifted (a,0) ;
z2 = urcorner Page shifted (-a,0) ;
z3 = urcorner Page shifted (0,-a) ;
z4 = lrcorner Page shifted (0,a) ;
z5 = (x2,0) ;
z6 = (x1,0) ;
z7 = (0,y4) ;
z8 = (0,y3) ;
z9 = (x1,y3) ;
z10 = (x2,y3) ;
z11 = (x2,y4) ;
z12 = (x1,y4) ;
p[1] = z9 -- z12 -- z7 -- z8 -- cycle ;
p[2] = z10 -- z3 -- z4 -- z11 --cycle ;
p[3] = z12 -- z11 -- z5 -- z6 --cycle ;
p[4] = z9 -- z10 -- z2 -- z1 -- cycle ;
fill p[1] withcolor \MPcolor{darkb} ;
fill p[2] withcolor \MPcolor{darkb} ;
fill p[3] withcolor \MPcolor{darkb} ;
fill p[4] withcolor \MPcolor{darkb} ;
pickup pencircle scaled 8 pt ;
draw z1 -- z6 withcolor \MPcolor{FrameColor} ;
draw z2 -- z5 withcolor \MPcolor{FrameColor} ;
draw z7 -- z4 withcolor \MPcolor{FrameColor} ;
draw z8 -- z3 withcolor \MPcolor{FrameColor} ;
StopPage ;
\stopuniqueMPgraphic 

\startuseMPgraphic{Bottombg}
StartPage
path Q[] ;
path R[] ;
z4 = llcorner Page shifted (2cm,0.75cm) ;
z5 = lrcorner Page shifted (-2cm,0.75cm) ;
Q[1] = z4 -- z[5] ;
oa = NOfPages - 2 ;
ob = PageNumber - 2 ;
oc = arclength(Q[1]) ;
od = oc/oa ;
oe = oc/oa ;
Q[2] = fullcircle scaled .4 cm shifted (2cm,0.65cm) ;
fill Q[2] withcolor \MPcolor{DarkYellow} ;
for i = 1 upto NOfPages-2:
	R[i] = Q[2] shifted (i*od,0) ;
	fill R[i] withcolor \MPcolor{DarkYellow} ;
endfor ;
if PageNumber > 1 :
	Q[2] := Q[2] shifted (od*ob,0) ;
	fill Q[2] withcolor yellow ;
fi ;
StopPage
\stopuseMPgraphic

%D We define these backgrounds as overlays:

\defineoverlay 
[lecbackground] 
[\useMPgraphic{slide}] 

\defineoverlay 
[picbackground] 
[\useMPgraphic{slide}] 

\defineoverlay 
[bottom] 
[\useMPgraphic{Bottombg}] 

%D These are shortcuts to switch backgrounds:

\define\lecback{\setuplayout[header=2.8cm]\setupbackgrounds[page][background={lecbackground,bottom,slidetitle}]}
\define\titback{\setuplayout[header=1cm]\setupbackgrounds[page][background=lecbackground]}
\define\picback{\setuplayout[header=1cm]\setupbackgrounds[page][background={lecbackground,bottom}]}
\define\noback{\setupbackgrounds[page][background=nobackground]}

%D We use combinations for placing vertical pictures and text side by side, and
%D we want a distance of 1.1 cm between both.

\setupcombinations[distance=1.1cm]

%D The symbol for the first level of itemizations. 

\definesymbol[1][\useMPgraphic{ItSquare}]
\setupitemize[1][inmargin][color=FrameColor]

\protect
\stopmodule

\endinput

