%D \module
%D   [      file=t-titleframe,
%D        version=2007.12.20, 
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Module blackblue,
%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{titleframe} style for the presentation
%D module. It is loaded at runtime. The most interesting part is the scratch
%D counter at the bottom of the page, which is explained in the metafun manual.

\writestatus{loading}{module titleframe}

\startmodule[titleframe]

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

%D The page layout:

\setuplayout [width=fit,
              margin=0cm,
              height=fit,
              header=2.2cm, 
              footer=1cm, 
              topspace=.6cm, 
              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,
    y=2mm]

\define[1]\Slidetitle{\page\setlayer[slidetitle]%
     {\framed[corner=round,background=color,backgroundcolor=myred,frame=off,width=\textwidth,height=2.1cm,offset=0pt,top=\vss,bottom=\vss]{\switchtobodyfont[\Titlesize]\color[background]{#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[corner=round,background=color,backgroundcolor=myred,frame=off,width=\textwidth,height=.75\textheight,top=\vss,bottom=\vss,align=middle]{\switchtobodyfont[\Titlesize]\color[background]{\getvariable{taspresent}{title}}\switchtobodyfont[\Normalsize]\blank[line]\color[background]{\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 [background]       [s=.9]
\definecolor [darkgray]	        [s=.3]
\definecolor [lightgray]        [s=.7]
\definecolor [myred]            [r=.5]
\definecolor [Item]             [r=.5]

%D We let Metapost calculate the background:

\startuniqueMPgraphic{slide} 
StartPage ;
fill Page withcolor \MPcolor{background} ;
StopPage ;
\stopuniqueMPgraphic 

\startuseMPgraphic{counter}
StartPage ;
numeric a ;
numeric b ;
b = PaperWidth/2 - NOfPages * 2.5pt ;
a = 7mm ;
% z1 = (0,0) ;
% z2 = (x1+2pt,y1+a) ;
% numeric a; a=.5cm ;
pickup pencircle scaled 3pt ;
for i := 1 upto NOfPages:
	path p ;
	path q ;
	p = (0,5mm) -- (1mm,11mm) ;
	p := p shifted (b,0) ;
	q = (-8mm,5mm) -- (0,11mm) ;
	q := q shifted (b,0) ;
	if (i mod 5<>0):
		draw p shifted (i*5pt,0pt) withcolor \MPcolor{lightgray} ;
		if (i <= PageNumber):
			draw p shifted (i*5pt,0pt) ;
		fi ;
	else:
		draw q shifted (i*5pt,0pt) withcolor \MPcolor{lightgray} ;
		if (i <= PageNumber):
			draw q shifted (i*5pt,0pt) ;
		fi ;
	fi ;
endfor ;
StopPage ;
\stopuseMPgraphic

%\setupfootertexts[{\framed[frame=on,framecolor=red,height=9mm,width=\textwidth]{\useMPgraphic{counter}}}]
%\setupfootertexts[some random text]

%D We define these backgrounds as overlays:

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

\defineoverlay
[scratchcounter]
[\useMPgraphic{counter}]

%D These are shortcuts to switch backgrounds:

\define\lecback{\setuplayout[header=2.2cm]\setupbackgrounds[page][background={lecbackground,scratchcounter,slidetitle}]}
\define\titback{\setuplayout[header=.5cm]\setupbackgrounds[page][background=lecbackground]}
\define\picback{\setuplayout[header=.5cm]\setupbackgrounds[page][background={lecbackground,scratchcounter}]}
\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=myred]

\protect
\stopmodule

\endinput

