%D \module
%D   [      file=t-graysquare,
%D        version=2007.07.17, 
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Module graysquare,
%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{graysquare} style for the presentation
%D module. It is loaded at runtime. This minimalistic design is inspired by a
%D presentation Taco gave at EuroTeX 2006. 

\writestatus{loading}{module graysquare}

\startmodule[graysquare]

\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 [a]         [r=.95,g=.95,b=.95]
\definecolor [b]         [r=.7,g=.1,b=.3]
\definecolor [c]         [s=.3]
\definecolor [Item]      [r=.7,g=.1,b=.3]

%D We start colors:

\setupcolors[state=start]

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

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

%D The page layout:

\setuplayout [width=fit,
	      height=middle,
              margin=0cm,
              height=fit,
	      margindistance=0cm,
              header=0cm, 
              footer=0cm, 
              topspace=2cm, 
              backspace=1.5cm,
              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=15mm]

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

\startuseMPgraphic{bottom} 
StartPage ;
fill Page withcolor \MPcolor{a} ;
z.b1 = llcorner Field[Text][Text] ;
z.b2 = lrcorner Field[Text][Text] ;
path wdt ;
wdt = z.b1 -- z.b2 ;
numeric diff; diff = .3cm ;
numeric arc; arc = arclength (wdt) - diff ;
numeric pages; pages = NOfPages - 1 ;
numeric factor; factor = arc/pages ;
path m[] ;
m[0] = unitsquare xyscaled (diff,diff) shifted (x.b1,0.85cm) ;
fill m[0] withcolor \MPcolor{c} ;
if PageNumber = 1:
	fill m[0] xyscaled (0,2) shifted (0,-diff-.85cm) withcolor \MPcolor{b} ;
fi ;
for i = 1 upto pages:
	m[i] = m[0] shifted (i*factor,0) ;
	fill m[i] withcolor \MPcolor{c} ;
	if i+1 = PageNumber:
%		fill m[i] withcolor \MPcolor{b} ;
		fill m[i] xyscaled (0,2) shifted (0,-diff-.85cm) withcolor \MPcolor{b} ;
	fi ;
endfor ;
StopPage ;
\stopuseMPgraphic 

%D We define these backgrounds as overlays:

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

%D These are shortcuts to switch backgrounds:

\define\lecback{\setuplayout[header=1cm]\setupbackgrounds[page][background={lecbackground,slidetitle}]}
\define\titback{\setuplayout[header=0cm]\setupbackgrounds[page][background=lecbackground]}
\define\picback{\setuplayout[header=0cm]\setupbackgrounds[page][background={lecbackground,slidetitle}]}
\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=0cm]

%D The symbol for the first level of itemizations. 

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

\protect
\stopmodule

\endinput

