\startenvironment correspondence-environment

%%%% Manual for the ConTeXt correspondence module

% To produce a pdf of this manual you have to run it with LuaTeX,
% to get the same layout as the version shipped with the module
% the lucida and delicious fonts are required.

%%%% Variables

\setvariables
  [correspondence]
  [title=Correspondence with \ConTeXt,
   version=\ctxlua{tex.sprint(tex.ctxcatcodes,thirddata.correspondence.files[1]["version"])}]


%%%% Colors

\definecolor[lettercolor]  [h=BBD0B4]
\definecolor[fakerulecolor][darkgray]

\definecolor[twhite][r=1,g=1,b=1,t=.75,a=1]


%%%% Images

\setupexternalfigures[directory=images]


%%%% Hyperlinks etc.

\setupinteraction
  [state=start,
   title={Correspondence with ConTeXt},
   author={Wolfgang Schuster},
   color=black,
   contrastcolor=black,
   style=]


%%%% Additional modules

\usemodule[visual]
\usemodule[abr-01]
\usemodule[letter]
\usemodule[resume]
\usemodule[set-11]\loadsetups[cont-en.xml]\loadsetups[t-letter.xml]\loadsetups[t-resume.xml]
\usemodule[examplecontent]

\setupframedtexts
  [setuptext]
  [frame=on,
   rulethickness=1pt,
   corner=round,
   framecolor=lettercolor]


%%%% Fonts

\startmode[wolf]

\setupbodyfont[lucida,10pt]

\definetypeface[examplefont][rm][specserif][Delicious][default]

\stopmode

\startnotmode[wolf]

\setupbodyfont[pagella,10pt]

\definetypeface[examplefont][rm][specserif][Latin Modern Sans][default]

\stopnotmode


%%%% Layout

%% Setup for the letter examples

\setupletterstyle
  [option]
  [bodyfont=examplefont,
   whitespace=line,
   marking=no,
   before={\page[left]},
   backgroundcolor=gray]

\setupletterstyle
  [content]
  [align=normal]

\setupletterstyle
  [enclosure,copy,postscript]
  [before={\blank[nowhite]},
   after={\blank[nowhite]}]

\setupletterstyle
  [closing]
  [after={\blank[2*line]}]

\setupresumestyle
  [option]
  [bodyfont=examplefont,
   whitespace=none,
   before={\page[left]},
   backgroundcolor=gray]

%% Whitespace

\setupwhitespace[line]

\setupalign[right,broad] % gives better results with \cs in the text

%% Headers

\definestructureresetset[default][0,0][1]

\setuphead
  [part]
  [placehead=yes,
   header=empty,
   sectionresetset=default,
   alternative=middle,
   style=\tfd]

\setuphead
  [chapter]
  [header=empty,
   style=\tfc,
   sectionsegments=2:100]

\setuphead
  [section,subject]
  [style=\tfb,
   sectionsegments=2:100]

\setuphead
  [subsection,subsubject]
  [style=\tfa]

%% Content

\setupcombinedlist
  [content]
  [interaction=all,
   color=black]

%% Pagenumbering

\definestructureconversionset [pagenumber] [] [numbers]

\setupuserpagenumber[numberconversionset=pagenumber]

\setuppagenumbering
  [alternative=doublesided,
   location=footer]

%% Head/Foot

\setupheadertexts[{\getmarking[chapter]}]

%% Verbatim

\setuptyping
  [before={\blank\testpage[2]}]

%% Misc

\setupmakeup
  [standard]
  [pagestate=start,
   doublesided=empty,
   page=no]

%% Cover

\defineoverlay[coverfigure][\overlayfigure{980559_60280625}]

\def\TitlePage
  {\bgroup
   \setupbackgrounds[page][background=color,backgroundcolor=lettercolor]
   \startstandardmakeup[align=middle]
   \vfill
   {\definedfont[SansBold sa 4]\setupinterlinespace\getvariable{correspondence}{title}\par}
   \blank[2*line]
   {\definedfont[Sans sa 2]\setupinterlinespace Version: \getvariable{correspondence}{version}\par}
   \vfill\vfill\vfill
   \stopstandardmakeup
   \egroup}

\def\LastPage
  {\page[yes,left]
   \bgroup
   \setupbackgrounds[page][background=color,backgroundcolor=lettercolor]
   \startstandardmakeup % why not
   \stopstandardmakeup  % \page[empty]?
   \egroup}

\def\CommandList
  {\chapter{Command definitions}
   \placesetup}

%% Examples for the letter elements

\defineframedtext
  [element]
  [width=\textwidth,
   rulethickness=1pt,
   corner=round,
   framecolor=lettercolor]

\defineframedtext
  [smallelement]
  [width=.35\textwidth,
   rulethickness=1pt,
   corner=round,
   framecolor=lettercolor]

%% Test mode

\startmode[test]

  \showframe
  \showgrid

\stopmode

%% The examplecontent module is not included in the manual sources
%% and will remain private therefore dummy defintions are necessary.

\ifx\startexamplecontent\undefined

  \def\startexamplecontent     {\gobbleuntil\stopexamplecontent}
  \def\examplecontent          {\dodoubleempty\doexamplecontent}
  \def\doexamplecontent[#1][#2]{\framed[width=6cm,height=8cm]{}}

\fi


\stopenvironment
