%D \module
%D   [       file=m-layout,
%D        version=2004.01.16,
%D          title=\CONTEXT\ Modules,
%D       subtitle=Additional Layouts,
%D         author={Hans Hagen \& Ton Otten},
%D           date=\currentdate,
%D      copyright={PRAGMA ADE/ Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

% layout-preset - thf th tf

%D This is a preliminary module, don't depend on these dimensions yet.

\readsysfile{lang-frq}\donothing\donothing
\readsysfile{lang-frd}\donothing\donothing

\unprotect

% \def\layouthwratio{\withoutpt\the\dimexpr(8\paperheight/\dimexpr(\paperwidth/ 8192))}
% \def\layouthwratio{\withoutpt\the\dimexpr(4\paperheight/\dimexpr(\paperwidth/16384))}
% \def\layouthwratio{\withoutpt\the\dimexpr(2\paperheight/\dimexpr(\paperwidth/32768))}

\def\layouthwratio
  {\withoutpt\the\dimexpr(2\paperheight/(\paperwidth/32768))}

\def\layouthfheight
  {\dimexpr(\layoutparameter\c!header+\layoutparameter\c!headerdistance+
            \layoutparameter\c!footer +\layoutparameter\c!footerdistance )}

\startsetups[preset-1]

  \xdef\layoutwidth {\dimexpr(\layoutparameter\c!width)}
  \gdef\layoutheight{\dimexpr(\layouthwratio\dimexpr(\layoutwidth)+\layouthfheight)}

\stopsetups

\definelayout
  [preset-1-1]
  [\c!preset=preset-1,
   \c!backspace=\dimexpr((\paperwidth-\layoutwidth)/2),
   \c!width=\dimexpr(2\paperwidth/3),
   \c!cutspace=\dimexpr((\paperwidth-\layoutwidth)/2),
   \c!margin=\dimexpr((\paperwidth-\layoutwidth)/3),
   \c!header=2\lineheight,
   \c!headerdistance=\lineheight,
   \c!height=\v!middle, % \layoutheight
   \c!footerdistance=\layoutparameter\c!headerdistance, % \lineheight,
   \c!footer=\layoutparameter\c!header, % 2\lineheight,
   \c!topspace=\dimexpr(1\dimexpr(\paperheight-(\layoutheight+\layouthfheight))/3),
   \c!bottomspace=\dimexpr(2\dimexpr(\paperheight-(\layoutheight+\layouthfheight))/3)]

\startsetups[preset-2]

  \gdef\layouthstep{\dimexpr(\paperwidth /\layoutparameter\c!columns)}
  \gdef\layoutvstep{\dimexpr(\paperheight/\layoutparameter\c!columns)}

\stopsetups

\definelayout
  [preset-2-1]
  [\c!preset=preset-2,
   \c!columns=12,
   \c!backspace=\layouthstep,
   \c!width=\v!middle,
   \c!cutspace=2\layouthstep,
   \c!margin=\layouthstep,
   \c!header=2\lineheight,
   \c!headerdistance=\lineheight,
   \c!height=\v!middle, % \layoutheight
   \c!footerdistance=\layoutparameter\c!headerdistance,
   \c!footer=\layoutparameter\c!header,
   \c!topspace=\dimexpr(\layoutvstep-\layoutparameter\c!header-\layoutparameter\c!headerdistance),
   \c!bottomspace=\dimexpr(2\layoutvstep-\layoutparameter\c!header-\layoutparameter\c!headerdistance)]

\definelayout
  [preset-2-2]
  [\c!preset=preset-2,
   \c!columns=12,
   \c!backspace=\layouthstep,
   \c!width=\v!middle,
   \c!cutspace=2\layouthstep,
   \c!margin=\layouthstep,
   \c!header=2\lineheight,
   \c!headerdistance=\lineheight,
   \c!height=\v!middle, % \layoutheight
   \c!footerdistance=\layoutparameter\c!headerdistance,
   \c!footer=\layoutparameter\c!header,
   \c!topspace=\layoutvstep,
   \c!bottomspace=\layoutvstep] % maybe 1.5

%                                                     \setuplayout[preset-1-1] test \showframe \page
% \setuplayout[preset-1-1][width=65\averagecharwidth] \setuplayout[preset-1-1] test \showframe \page
%                                                     \setuplayout[preset-2-1] test \showframe \page
% \setuplayout[preset-2-1][columns=10]                \setuplayout[preset-2-1] test \showframe \page
%                                                     \setuplayout[preset-2-2] test \showframe \page
% \setuplayout[preset-2-2][columns=10]                \setuplayout[preset-2-2] test \showframe \page

\protect \endinput
