%D \module
%D   [      file=t-narrowstripe,
%D        version=2007.07.25, 
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Module narrowstripe,
%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{narrowstripe} 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 narrowstripe}

\startmodule[narrowstripe]

\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 The narrowframe module has parameters of its own; we set them up and use
%D them:

\setupmodule[color=blue]

\processaction[\currentmoduleparameter{color}]
	[         red=>\def\colormode{redmode},
                 blue=>\def\colormode{bluemode},
                green=>\def\colormode{greenmode},
           \v!unknown=>\def\colormode{bluemode},
           \v!default=>\def\colormode{bluemode}]

\enablemode[\colormode]

%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.8cm,
              rightmargindistance=0pt,
              height=fit, 
              header=2.5cm, 
              footer=0cm, 
              topspace=.4cm, 
              backspace=3.2cm,
	      cutspace=3.7cm,
              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=32mm]

\define[1]\Slidetitle{\page\setlayer[slidetitle]%
     {\framed[framecolor=red,frame=off,width=\textwidth,height=2.25cm,offset=0pt,align=middle,top=\vss,bottom=\vss]{\switchtobodyfont[\Titlesize]\color[d]{#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[d]{\getvariable{taspresent}{title}}}
\blank[2*line]
\midaligned{\color[d]{\getvariable{taspresent}{author}}}
\blank[3*line]
\midaligned{\color[d]{\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, depending on the mode:

\startmode[bluemode]
\definecolor [Item]            [b=.8]
\definecolor [a]               [s=.95]
\definecolor [b]               [r=0,g=0,b=1]
\definecolor [c]               [r=.69,g=.69,b=.97]
\definecolor [d]               [b=.8]
\stopmode

\startmode[redmode]
\definecolor [Item]            [r=.8]
\definecolor [a]               [s=.95]
\definecolor [b]               [r=1]
\definecolor [c]               [b=.69,g=.69,r=.97]
\definecolor [d]               [r=.8]
\stopmode

\startmode[greenmode]
\definecolor [Item]            [g=.4]
\definecolor [a]               [s=.95]
\definecolor [b]               [g=.4]
\definecolor [c]               [b=.68,r=.68,g=.79]
\definecolor [d]               [g=.4]
\stopmode

%D We let Metapost calculate the background:

\startuseMPgraphic{narrow}
StartPage ;
numeric a ;
numeric b ;
numeric c ;
c = PaperHeight - a/2 ;
pair za[] ;
path p[] ;
a = 2.25cm ;
b = 0.4 cm ;
za1 = ulcorner Page shifted (0,-a) ;
za2 = ulcorner Page shifted (0,-a-b) ;
za3 = urcorner Page shifted (0,-a-b) ;
za4 = urcorner Page shifted (0,-a) ;
za5 = ulcorner Page shifted (a,0) ;
za6 = ulcorner Page shifted (a+b,0) ;
za7 = llcorner Page shifted (a+b,0) ;
za8 = llcorner Page shifted (a,0) ;
za9 = ulcorner Page shifted (a,-a) ;
za10 = ulcorner Page shifted (a+b,-a) ;
za11 = ulcorner Page shifted (a+b,-a-b) ;
za12 = ulcorner Page shifted (a,-a-b) ;
p[1] = za1 -- za2 -- za3 -- za4 -- cycle ;
p[2] = za5 -- za6 -- za7 -- za8 -- cycle ;
p[3] = za9 -- za10 --za11 -- za12 -- cycle ;
linear_shade(p[1],1,\MPcolor{a},\MPcolor{b}) ;
linear_shade(p[2],2,\MPcolor{b},\MPcolor{a}) ;
fill p[3] withcolor \MPcolor{c} ;
draw \sometxt{\framed[frame=off,width=2.25cm,height=2.25cm]{\color[d]{\tfx \folio}}} shifted (0,PaperHeight-a) ;
StopPage ;
\stopuseMPgraphic

%D We define these backgrounds as overlays:

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

%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{\setupbackgrounds[page][background={lecbackground,slidetitle}]}
\define\titback{\setupbackgrounds[page][background=lecbackground]}
\define\picback{\setupbackgrounds[page][background={lecbackground,slidetitle}]}
\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=d]

\protect
\stopmodule

\endinput

