% content=tex
%
% copyright=pragma-ade readme=readme.pdf licence=cc-by-nc-sa

\startenvironment mcommon

% modules

\usemodule[abr-02]

% layout

\startmode[screen]
  \setuppapersize[S6][S6]
  \setupinteraction[state=start]
  \setupinteractionscreen[options=max]
\stopmode

\setuplayout
  [footer=0cm,
   width=middle,
   height=middle]

% fonts

\startmode[atpragma]

    \startMPenvironment[global]
      \usetypescriptfile[type-buy]
      \usetypescript[lucida][texnansi]
      \setupbodyfont[lucida,10pt]
    \stopMPenvironment

    \setupbodyfont[11pt]

\stopmode

\startnotmode[atpragma]

    \startMPenvironment[global]
      \usetypescript[palatino][ec]
      \setupbodyfont[palatino,10pt]
    \stopMPenvironment

    \setupbodyfont[11pt]

\stopnotmode

\definefont [BigFont] [SansBold at 60pt]
\definefont [MedFont] [SansBold at 30pt]

% colors

\setupcolors
  [state=start]

\definecolor [NopColor] [r=.6,g=.4,b=.5]
\definecolor [AltColor] [r=.4,g=.6,b=.5]
\definecolor [TheColor] [r=.4,g=.5,b=.6]
\definecolor [TmpColor] [r=.6,g=.5,b=.4]

\definecolor [red]   [NopColor]
\definecolor [green] [AltColor]
\definecolor [blue]  [TheColor]
\definecolor [yellow][TmpColor]

% spacing

\setupwhitespace
  [big]

\setuptolerance
  [verytolerant,stretch]

% verbatim

\setuptype
  [color=AltColor]

\setuptyping
  [color=AltColor]

% structure

\setupitemize
  [each]
  [color=TheColor]

\definedescription
  [switch]
  [headstyle=type,
   headcolor=TheColor,
   location=serried,
   width=broad]

\defineenumeration
  [topic]
  [location=serried,
   width=broad,
   headstyle=,
   headcolor=TheColor,
   text=,
   left={[},
   right={]}]

\setuphead
  [section]
  [style=\ss\bfb,
   color=TheColor]

\setuplist
  [section]
  [alternative=c,
   color=TheColor,
   textcolor=black,
   pagecolor=black]

% whatever

\setupsystem
  [random=medium]

\setupfloats
  [ntop=100]

\setupinteraction
  [style=,
   color=NopColor,
   contrastcolor=NopColor]

% tables and frames

\setuptabulate
  [rulethickness=.5pt,
   rulecolor=AltColor]

\setuptables
  [rulethickness=.5pt,
   rulecolor=AltColor]

\setupframedtexts
  [rulethickness=.5pt,
   framecolor=TheColor,
   width=\textwidth]

% quick reference things

\usemodule[set-11] \loadsetups

\setupframedtexts
  [setuptext]
  [rulethickness=.5pt,
   framecolor=AltColor]

% basic titlepage and colofon, a bit old fashioned approach, but let's not
% modernize everything now

\def\TitlePage#1#2#3#4#5% number/name angle title author screen
  {\doifnumberelse{#1}
     {\ifcase#1
        \defineoverlay
          [logo]
          [\useMPgraphic{titlepage}{width=\overlaywidth,height=\overlayheight}]
      \else
        \startMPrun
          logo_type := #1 ; mpgraph := #1 ; input mp-cont ;
        \stopMPrun
        \defineoverlay
          [logo]
          [{\externalfigure
              [\MPrunfile{#1}]
              [width=\overlaywidth,height=\overlayheight]}]
      \fi}
     {\defineoverlay
        [logo]
        [\useMPgraphic{#1}{width=\overlaywidth,height=\overlayheight}]}
   \setupbackgrounds
     [page]
     [background=logo]
   \definecolor[Gray][s=#5]
   \startstandardmakeup
     \dontcomplain
     \BigFont \setupinterlinespace \vfill \setupalign[left] \let\\=\par
     \ifcase#2\relax
       \noindent\color[Gray]{#3}\par
     \else
       \noindent\rotate[rotation=#2]{\color[Gray]{#3}}\par
     \fi
   \stopstandardmakeup
   \setupbackgrounds
     [page]
     [background=]}

\def\ColofonPage
  {\startstandardmakeup
     \vfill \setups [pragma-colofon]
   \stopstandardmakeup}

\stopenvironment
