%D \module
%D   [      file=t-graybeams,
%D        version=2007.07.17, 
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Module graybeams,
%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{graybeams} style for the presentation
%D module. It is loaded at runtime. The look of this style was inspired by the
%D \quotation{Copenhagen} theme of the \LaTeX\ {\tt beamer} package.

\writestatus{loading}{module graybeams}

\startmodule[graybeams]

\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{.97\textheight}
\define\NormalWidth{.476\textwidth}
\define\PictureFrameHeight{.97\textheight}
\define\PictureFrameWidth{.476\textwidth}

%D The page layout:

\setuplayout [width=fit,
              margin=0cm,
              height=14.7cm,
              header=1.75cm, 
              footer=1.5cm, 
              topspace=1cm, 
              backspace=1cm,
              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=10mm]

\define[1]\Slidetitle{\page\setlayer[slidetitle]%
     {\framed[frame=off,width=\textwidth,height=2.25cm,offset=0pt,top=\vss,bottom=\vss]{\switchtobodyfont[\Titlesize]\color[c]{#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
\framed[frame=off,width=\textwidth,height=.75\textheight,top=\vss,bottom=\vss,align=middle]{\switchtobodyfont[\Titlesize]\color[c]{\getvariable{taspresent}{title}}\switchtobodyfont[\Normalsize]\blank[line]\color[c]{\getvariable{taspresent}{author}\blank[2*line]\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 [a]                [s=.97]
\definecolor [b] 	        [s=.88]
\definecolor [c]                [r=.75]
\definecolor [Item]             [r=.75]

%D We let Metapost calculate the background:

\startuniqueMPgraphic{beams} 
StartPage ;
pair zd[] ;
path pb[] ;
numeric a; a=2.1cm ;
numeric b; b=1.5cm ;
fill Page withcolor \MPcolor{a} ;
z.d1 = llcorner Page shifted (0,2*a) ;
z.d2 = z.d1 shifted (0,2*a) ;
z.d3 = lrcorner Page shifted (0,b) ;
z.d4 = z.d3 shifted (0,b) ;
z.d5 = z.d2 shifted (0,b) ;
z.d6 = ulcorner Page  shifted (.1cm,0) ;
z.d7 = z.d4 shifted (0,b/2) ;
z.d8 = z.d7 shifted (0,b) ;
z.d9 = ulcorner Page shifted (.1cm+a,0) ;
z.d10 = z.d9 shifted (3*a,0) ;
z.d11 = z.d8 shifted (0,b/2) ;
z.d12 = z.d11 shifted (0,b) ;
z.d13 = z.d10 shifted (a,0) ;
z.d14 = z.d13 shifted (3*a,0) ;
z.d15 = z.d12 shifted (0,b/2) ;
z.d16 = z.d15 shifted (0,b) ;
z.d17 = llcorner Page shifted (0,b) ;
pb[1] = z.d1 -- z.d2 -- z.d4 -- z.d3 -- cycle ;
fill pb[1] withcolor \MPcolor{b} ;
pb[2] = z.d5 -- ulcorner Page -- z.d6 -- z.d8 -- z.d7 -- cycle ;
fill pb[2] withcolor \MPcolor{b} ;
pb[3] = z.d9 -- z.d10 -- z.d12 -- z.d11 -- cycle ;
fill pb[3] withcolor \MPcolor{b} ;
pb[4] = z.d13 -- z.d14 -- z.d16 -- z.d15 -- cycle ;
fill pb[4] withcolor \MPcolor{b} ;
pb[5] = llcorner Page -- z.d17 -- z.d3 -- lrcorner Page -- cycle ;
fill pb[5] withcolor \MPcolor{c} ;
StopPage ;
\stopuniqueMPgraphic 

\startuniqueMPgraphic{redstripes}
StartPage ;
path pb[] ;
numeric b; b=1.5cm ;
z.d18 = ulcorner Page shifted (0,-1.5*b) ;
z.d19 = z.d18 shifted (0,-1pt) ;
z.d20 = urcorner Page shifted (0,-1.5*b) ;
z.d21 = z.d20 shifted (0,-1pt) ;
pb[6] = z.d18 -- z.d19 -- z.d21 -- z.d20 -- cycle ;
linear_shade(pb[6],0,\MPcolor{c},\MPcolor{a}) ;
pb[7] = pb[6] shifted (0,-3pt) ;
linear_shade(pb[7],0,\MPcolor{c},\MPcolor{a}) ;
StopPage ;
\stopuniqueMPgraphic

%D We define these backgrounds as overlays:

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

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

%D We define the footer

\setupfooter[color=a,style={\switchtobodyfont[10pt]},strut=yes]
\setupfootertexts[{\framed[frame=off,height=1cm,width=\textwidth]{\getvariable{taspresent}{title}\hfill \pagenumber\ of \lastpage}}]

%D These are shortcuts to switch backgrounds:

\define\lecback{\setuplayout[header=1.75cm]\setupfooter[state=start]\setupbackgrounds[page][background={picbackground,lecbackground,slidetitle}]}
\define\titback{\setuplayout[header=1.75cm]\setupfooter[state=stop]\setupbackgrounds[page][background={picbackground,lecbackground}]}
\define\picback{\setuplayout[header=0cm]\setupfooter[state=start]\setupbackgrounds[page][background={picbackground}]}
\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][color=c]

\protect
\stopmodule

\endinput

