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

\writestatus{loading}{module greenblue}

\startmodule[greenblue]

\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 define our colors:

\definecolor [Item]            [r=.09,g=.2,b=.41]
\definecolor [a]               [s=.95]
\definecolor [b]               [r=.58,g=.81,b=.58]
\definecolor [c]               [r=.09,g=.2,b=.41]
\definecolor [d]               [r=.04,g=.4,b=.4]

%D We start colors; textcolor is white:

\setupcolors[state=start,textcolor=c]

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

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

%D The page layout:

\setuplayout [width=fit,
              leftmargin=1.5cm,
	      rightmargin=0cm,
              leftmargindistance=1.2cm,
              rightmargindistance=0pt,
              height=fit, 
              header=5.3cm, 
              footer=0cm, 
              topspace=.4cm, 
              backspace=2.5cm,
	      cutspace=3.2cm,
              bottomspace=0cm,
              bottom=0pt,
              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=25mm,
    y=25mm]

\define[1]\Slidetitle{\page\setlayer[slidetitle]%
     {\framed[frame=off,width=\textwidth,height=2cm,offset=0pt,align=right,top=\vss,bottom=\vss]{\switchtobodyfont[\Titlesize]\color[d]{\bf #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.

\definelayer[prestitle]
    [width=\paperwidth,
    height=\paperheight,
    y=30mm]

\definelayer[presauthor]
    [width=.5\paperwidth,
    height=.5\paperheight,
    x=104mm,
    y=118mm]

\define\Maketitle{%
\titback\null
\setlayer[prestitle]%
{\framed[frame=off,width=\paperwidth,height=4cm,offset=0pt,align=middle,top=\vss,bottom=\vss]{\switchtobodyfont[\Titlesize]\color[c]{\bf \getvariable{taspresent}{title}}}}
\setlayer[presauthor]%
{\framed[frame=off,width=.5\paperwidth,height=4cm,offset=0pt,align=middle,top=\vss,bottom=\vss]{\switchtobodyfont[\Normalsize]\color[c]{\getvariable{taspresent}{author}}}}}

%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 let Metapost calculate the background:

\startuseMPgraphic{greenframe}
StartPage ;
fill Page withcolor \MPcolor{a} ;
numeric a ; a = 2cm ;
numeric b ; b = 0.7cm ;
numeric c ; c = 6cm ;
numeric d ; d = .7cm ;
pair zc[] ;
zc1 = llcorner Page shifted (a,0) ;
zc2 = ulcorner Page shifted (a,-a-b) ;
zc3 = ulcorner Page shifted (a+b/4,-a-b/4) ;
zc4 = ulcorner Page shifted (a+b,-a) ;
zc5 = urcorner Page shifted (0,-a) ;
zc6 = ulcorner Page shifted (c,0) ;
zc7 = ulcorner Page shifted (c,-a) ;
path pa[] ;
pa[1] = llcorner Page -- zc1 -- zc2 .. zc3 .. zc4 -- zc7 -- zc6 -- ulcorner Page -- cycle ;
fill pa[1] withcolor \MPcolor{b} ;
draw \sometxt{\framed[frame=off,width=2cm,height=2cm]{\color[a]{\pagenumber}}} ;
StopPage ;
\stopuseMPgraphic

\startuniqueMPgraphic{bluebeam}
StartPage ;
numeric a ; a = 2cm ;
numeric b ; b = 0.7cm ;
numeric c ; c = 6cm ;
numeric d ; d = .7cm ;
pair zc[] ;
zc8 = ulcorner Page shifted (a/2,-2.2*a) ;
zc9 = zc8 shifted (0,-d) ;
zc10 = urcorner Page shifted (-a,-2.2*a-d) ;
zc11 = zc10 shifted (0,d) ;
zc12 = zc8 shifted (-d/2,-d/2) ;
path pa[] ;
pa[3] = zc8 .. zc12 .. zc9 -- zc10 -- zc11 -- cycle ;
fill pa[3] withcolor \MPcolor{c} ;
StopPage ;
\stopuniqueMPgraphic

\startuniqueMPgraphic{Titlebg}
StartPage ;
numeric a ; a = 4cm ;
numeric b ; b = 3cm ;
numeric c ; c = 8cm ;
numeric d ; d = .7cm ;
path pa[] ;
pair zc [] ;
fill Page withcolor \MPcolor{a} ;
pa[1] = ulcorner Page -- ulcorner Page shifted (PaperWidth/2,0) -- llcorner Page shifted (PaperWidth/2,0) -- llcorner Page -- cycle ;
fill pa[1] withcolor \MPcolor{b} ;
zc1 = ulcorner Page shifted (PaperWidth/2,-b) ;
zc2 = zc1 shifted (-c,0) ;
zc3 = zc2 shifted (0,-a) ;
zc4 = zc3 shifted (c,0) ;
zc5 = zc2 shifted (-1.5cm,-a/2) ;
pa[2] = zc1 -- zc2 .. zc5 .. zc3 -- zc4 -- cycle ;
fill pa[2] withcolor \MPcolor{a} ;
zc6 = llcorner Page shifted (PaperWidth/2,0) ;
zc7 = 1/2[zc6,zc4] ;
zc8 = zc7 shifted (-.75*b,d/2) ;
zc9 = zc8 shifted (0,-d) ;
zc10 = zc9 shifted (1.3*c,0) ;
zc11 = zc10 shifted (0,d) ;
zc12 = zc10 shifted (d/2,d/2) ;
pa[3] = zc8 -- zc9 -- zc10 .. zc12 .. zc11 -- cycle ;
fill pa[3] withcolor \MPcolor{c} ;
StopPage ;
\stopuniqueMPgraphic

%D We define these backgrounds as overlays:

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

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

\defineoverlay
[titlebackground]
[\useMPgraphic{Titlebg}]

%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 These are shortcuts to switch backgrounds:

\define\lecback{\setuplayout[header=5.3cm]\setupbackgrounds[page][background={picbackground,lecbackground,slidetitle}]}
\define\titback{\setuplayout[header=2.3cm]\setupbackgrounds[page][background={titlebackground,prestitle,presauthor}]}
\define\picback{\setuplayout[header=2.3cm]\setupbackgrounds[page][background=picbackground]}
\define\noback{\setupbackgrounds[page][background=nobackground]}

\setupbackgrounds[page][background=lecbackground] 

%D The symbol for the first level of itemizations. 

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

\protect
\stopmodule

\endinput

