diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
commit | d7ccb42582f85acf30568913610ccf4d602023fb (patch) | |
tree | 7292e3545a420676878e7451b68892d360c62cb6 /Master/texmf-dist/tex/context/base/page-lay.mkiv | |
parent | 2d62a6fe9b80def59c392268022f1f9a2d6e358f (diff) |
commit context 2011.05.18
git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/page-lay.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/page-lay.mkiv | 371 |
1 files changed, 234 insertions, 137 deletions
diff --git a/Master/texmf-dist/tex/context/base/page-lay.mkiv b/Master/texmf-dist/tex/context/base/page-lay.mkiv index 28f9be594dc..812f3a3aca8 100644 --- a/Master/texmf-dist/tex/context/base/page-lay.mkiv +++ b/Master/texmf-dist/tex/context/base/page-lay.mkiv @@ -13,13 +13,6 @@ \writestatus{loading}{ConTeXt Page Macros / Layout Specification} -%D This module is now etex dependent. - -% to be translated into english - -% hoofdhoogte wordt bij status=hoog niet aangepast op outer -% level, wel binnen bepaalde berekeningen - %D Before you start wondering why some of the page related %D modules skip upward or left in order to place elements, you %D must realize that the reference point is the top left @@ -42,6 +35,7 @@ \newdimen\paperheight \paperheight = 297mm \newdimen\paperwidth \paperwidth = 210mm +\newdimen\paperoffset \paperoffset = 0mm \newdimen\printpaperheight \printpaperheight = \paperheight \newdimen\printpaperwidth \printpaperwidth = \paperwidth @@ -114,9 +108,6 @@ %D is no area, we use a zero distance in case there is no %D area. -\def\layoutdistance#1#2% - {\ifdim\zeropoint<#1\layoutparameter#2\else\zeropoint\fi} - %D The horizontal distances are: \newdimen \leftedgedistance @@ -133,23 +124,53 @@ %D We need to calculate the extra distances: +\newdimen\naturalmarginwidth +\newdimen\naturaledgewidth +\newdimen\naturalmargindistance +\newdimen\naturaledgedistance +\newdimen\naturalleftedgedistance +\newdimen\naturalrightedgedistance +\newdimen\naturalleftmargindistance +\newdimen\naturalrightmargindistance +\newdimen\naturaltopdistance +\newdimen\naturalheaderdistance +\newdimen\naturalfooterdistance +\newdimen\naturalbottomdistance + +\def\layoutdistance#1#2{\ifdim\zeropoint<#1#2\else\zeropoint\fi} + \def\setlayoutdimensions - {\global\marginwidth \layoutparameter\c!margin - \global\edgewidth \layoutparameter\c!edge - \global\margindistance \layoutparameter\c!margindistance - \global\edgedistance \layoutparameter\c!edgedistance - \global\leftedgedistance \layoutdistance \leftedgewidth \c!leftedgedistance - \global\rightedgedistance \layoutdistance \rightedgewidth \c!rightedgedistance - \global\leftmargindistance \layoutdistance \leftmarginwidth \c!leftmargindistance - \global\rightmargindistance\layoutdistance \rightmarginwidth \c!rightmargindistance - \global\topdistance \layoutdistance \topheight \c!topdistance - \global\headerdistance \layoutdistance \headerheight \c!headerdistance - \global\footerdistance \layoutdistance \footerheight \c!footerdistance - \global\bottomdistance \layoutdistance \bottomheight \c!bottomdistance} + {\global\naturalmarginwidth \layoutparameter\c!margin + \global\naturaledgewidth \layoutparameter\c!edge + \global\naturalmargindistance \layoutparameter\c!margindistance + \global\naturaledgedistance \layoutparameter\c!edgedistance + \global\naturalleftedgedistance \layoutparameter\c!leftedgedistance + \global\naturalrightedgedistance \layoutparameter\c!rightedgedistance + \global\naturalleftmargindistance \layoutparameter\c!leftmargindistance + \global\naturalrightmargindistance\layoutparameter\c!rightmargindistance + \global\naturaltopdistance \layoutparameter\c!topdistance + \global\naturalheaderdistance \layoutparameter\c!headerdistance + \global\naturalfooterdistance \layoutparameter\c!footerdistance + \global\naturalbottomdistance \layoutparameter\c!bottomdistance + % + \global\marginwidth \naturalmarginwidth + \global\edgewidth \naturaledgewidth + \global\margindistance \naturalmargindistance + \global\edgedistance \naturaledgedistance + % + \global\leftedgedistance \layoutdistance\leftedgewidth \naturalleftedgedistance + \global\rightedgedistance \layoutdistance\rightedgewidth \naturalrightedgedistance + \global\leftmargindistance \layoutdistance\leftmarginwidth \naturalleftmargindistance + \global\rightmargindistance \layoutdistance\rightmarginwidth\naturalrightmargindistance + \global\topdistance \layoutdistance\topheight \naturaltopdistance + \global\headerdistance \layoutdistance\headerheight \naturalheaderdistance + \global\footerdistance \layoutdistance\footerheight \naturalfooterdistance + \global\bottomdistance \layoutdistance\bottomheight \naturalbottomdistance + } \def\setlayoutdistances % local in \setreducedvsize - {\headerdistance\layoutdistance\headerheight\c!headerdistance - \footerdistance\layoutdistance\footerheight\c!footerdistance} + {\headerdistance\layoutdistance\headerheight\naturalheaderdistance + \footerdistance\layoutdistance\footerheight\naturalfooterdistance} % these are wrong in the running text, assumes some swapping, needs a cleanup @@ -266,10 +287,10 @@ %D We keep track of these features with the following %D variables. -\chardef\papermirror =0 \chardef\printmirror =0 -\chardef\paperorientation=0 \chardef\printorientation=0 % beware: later no chardef -\chardef\paperreverse =0 \chardef\printreverse =0 -\chardef\paperlandscape =0 \chardef\printlandscape =0 +\newconditional\papermirror \newconditional\printmirror +\newconstant \paperorientation \newconstant \printorientation +\newconstant \paperreverse \newconstant \printreverse +\newconditional\paperlandscape \newconditional\printlandscape \let\papersize\empty \let\printpapersize\empty @@ -295,7 +316,8 @@ {\doifelsenothing{#2} {\expanded{\dodosetuppapersize [\executeifdefined{\??pp:1:#1}{#1}]% - [\executeifdefined{\??pp:2:#1}{}]}} +% [\executeifdefined{\??pp:2:#1}{\v!default}]}} + [\executeifdefined{\??pp:2:#1}{#1}]}} {\doifassignmentelse{#2} {\getparameters[\??pp\executeifdefined{\??pp:1:#1}{#1}][#2]} {\expanded{\dodosetuppapersize @@ -361,10 +383,10 @@ \global\setdimentoatleast\paperheight \onepoint \global\setdimentoatleast\printpaperwidth \onepoint \global\setdimentoatleast\printpaperheight\onepoint - \ifcase\paperlandscape\else + \ifconditional\paperlandscape \doglobal\swapdimens\paperwidth\paperheight \fi - \ifcase\printlandscape\else + \ifconditional\printlandscape \doglobal\swapdimens\printpaperwidth\printpaperheight \fi % this check can be confusing, so we've added the possibility @@ -372,37 +394,45 @@ \doif\@@ppoption\v!max % \v!fit is {\bgroup % we need to pre-swap else we get the wrong paper size - \ifcase\paperorientation\else - \doifinset\paperorientation{90,270}{\swapdimens\paperwidth\paperheight}% - \fi - \ifcase\printorientation\else - \doifinset\printorientation{90,270}{\swapdimens\printpaperwidth\printpaperheight}% - \fi + \ifnum\paperorientation=\rightrotatioangle + \swapdimens\paperwidth\paperheight + \else\ifnum\paperorientation=\leftrotatioangle + \swapdimens\paperwidth\paperheight + \fi\fi + \ifnum\printorientation=\rightrotatioangle + \swapdimens\printpaperwidth\printpaperheight + \else\ifnum\printorientation=\leftrotatioangle + \swapdimens\printpaperwidth\printpaperheight + \fi\fi \ifdim\paperheight>\printpaperheight \global\printpaperheight\paperheight - \writestatus\m!systems{print height forced to paper height}% + \writestatus\m!system{print height forced to paper height}% \fi \ifdim\paperwidth>\printpaperwidth \global\printpaperwidth\paperwidth - \writestatus\m!systems{print width forced to paper width}% + \writestatus\m!system{print width forced to paper width}% \fi \egroup}} \def\dosetuppaperorientation#1#2#3#4#5% - {\global\chardef#2\zerocount - \global\chardef#5\zerocount - \globallet#3\!!zerocount - \globallet#4\!!zerocount + {\global\setfalse#2% + \global\setfalse#5% + \global#3\uprotationangle + \global#4\uprotationangle \global\negateprintboxfalse \processallactionsinset [#1] - [ \v!landscape=>\global\chardef#2\plusone, - \v!mirrored=>\global\chardef#5\plusone, - \v!rotated=>\gdef#3{90}\gdef#4{270}, + [ \v!landscape=>\global\settrue#2, + \v!mirrored=>\global\settrue#5, + \v!rotated=>\global#3\rightrotatioangle + \global#4\leftrotatioangle, \v!negative=>\global\negateprintboxtrue, - 90=>\gdef#3{90}\gdef#4{270}, - 180=>\gdef#3{180}\gdef#4{0}, - 270=>\gdef#3{270}\gdef#4{90}]} + 90=>\global#3\rightrotatioangle + \global#4\leftrotatioangle, + 180=>\global#3\downrotatioangle + \global#4\zerocount, + 270=>\global#3\leftrotatioangle + \global#4\rightrotatioangle]} \ifx\calculatepaperoffsets\undefined @@ -419,7 +449,7 @@ % {\beforesplitstring#1\at em\to\asciia % \doifnot\asciia{#1} % {\aftersplitstring\asciia\at=\to\asciia -% \doifsomething\asciia{\showmessage\m!systems{10}{#1}}}} +% \doifsomething\asciia{\showmessage\m!system{10}{#1}}}} % % \def\checkforems[#1]% % {\processcommalist[#1]\docheckforems} @@ -642,16 +672,43 @@ \newif\ifdoublesidedprint -\def\presetcenterpagebox % in \setuplayout !!!!!!!!!!!!!!!! +\newconditional\page_location_is_set + +\def\page_location_reset + {\setfalse\page_location_is_set + \let\page_location_left_fill \relax + \let\page_location_right_fill \relax + \let\page_location_top_fill \relax + \let\page_location_bottom_fill\relax} + +\page_location_reset + +\setvalue{\??ly:\c!location:\v!right }{\settrue\page_location_is_set + \let\page_location_left_fill \hss} +\setvalue{\??ly:\c!location:\v!left }{\settrue\page_location_is_set + \let\page_location_right_fill \hss} +\setvalue{\??ly:\c!location:\v!bottom }{\settrue\page_location_is_set + \let\page_location_top_fill \vss} +\setvalue{\??ly:\c!location:\v!top }{\settrue\page_location_is_set + \let\page_location_bottom_fill\vss} +\setvalue{\??ly:\c!location:\v!middle }{\settrue\page_location_is_set + \let\page_location_left_fill \hss + \let\page_location_right_fill \hss + \let\page_location_top_fill \vss + \let\page_location_bottom_fill\vss} +\setvalue{\??ly:\c!location:\empty }{\setfalse\page_location_is_set % default also signal to scrn_ + \let\page_location_right_fill \hss + \let\page_location_bottom_fill\hss} +\setvalue{\??ly:\c!location:\v!doublesided}{\doublesidedprinttrue} +\setvalue{\??ly:\c!location:\v!singlesided}{\doublesidedprintfalse} + +\def\dopresetcenterpagebox#1% + {\ifcsname\??ly:\c!location:#1\endcsname\csname\??ly:\c!location:#1\endcsname\fi} + +\def\presetcenterpagebox {\doublesidedprintfalse - \normalexpanded{\noexpand\processallactionsinset[\@@lylocation]} - [ \v!middle=>{\setuppapersize[\c!left=\hss,\c!right=\hss,\c!top=\vss,\c!bottom=\vss]}, - \v!left=>{\setuppapersize[\c!left=,\c!right=\hss]}, - \v!right=>{\setuppapersize[\c!left=\hss,\c!right=]}, - \v!bottom=>{\setuppapersize[\c!top=\vss,\c!bottom=]}, - \v!top=>{\setuppapersize[\c!top=,\c!bottom=\vss]},% - \v!doublesided=>\doublesidedprinttrue, - \v!singlesided=>\doublesidedprintfalse]} + \page_location_reset + \processcommacommand[\@@lylocation]\dopresetcenterpagebox} \unexpanded\def\definelayout {\dodoubleargument\dodefinelayout} @@ -659,31 +716,41 @@ \def\dodefinelayout[#1][#2]% {\getparameters[\??ly#1][\c!state=\v!start,#2]} -% \def\dodosetuplayout[#1][#2]% -% {\ConvertToConstant\doifnot{#2}\v!reset % #2 ? -% {\getparameters[\??ly#1][#2]% -% \checkforems[#2]}} - \def\dodosetuplayout[#1][#2]% {\doifnot{#2}\v!reset{\getparameters[\??ly#1][#2]}} % global needed for non-doublesided standardmakeup +\unexpanded\def\setuplayout + {\dodoubleempty\dosetuplayout} + \def\dosetuplayout[#1][#2]% - {\globallet\currentlayout\empty % new, global + {\globallet\currentlayout\empty \ifsecondargument \dodosetuplayout[#1][#2]% \else\iffirstargument \doifassignmentelse{#1} {\dodosetuplayout[][#1]} - {\doifnot{#1}\v!reset{\xdef\currentlayout{#1}}}% new, global + {\doifelse{#1}\v!reset + {\let\@@lymethod\v!normal}% hardcodes, assumes a definition + {\xdef\currentlayout{#1}}}% \fi\fi \recalculatelayout - \checkcurrentlayout % here ? + %\checkcurrentlayout % here? + \dochecknextlayout % here? \presetcenterpagebox} -\unexpanded\def\setuplayout - {\dodoubleempty\dosetuplayout} +\def\installlayouthandler#1#2% + {\setgvalue{\??ly:\c!method:#1}{#2}} + +\installlayouthandler\v!default + {\checkcurrentlayout} + +\installlayouthandler\v!normal + {\checkcurrentlayout} + +\def\dochecknextlayout + {\executeifdefined{\??ly:\c!method:\@@lymethod}\checkcurrentlayout} \let\@@zaheight\!!zeropoint @@ -771,22 +838,33 @@ %D by the \type {top}, \type {bottom}, \type {left} and \type %D {right} parameters. -\def\centerpagebox#1% +\def\centerpagebox#1% we could test for a difference (saves packing) {\printpaperwidth \paperscale\printpaperwidth \printpaperheight\paperscale\printpaperheight - \setbox#1\vbox to \printpaperheight - {\@@pptop - \hbox to \printpaperwidth - {\ifdoublesidedprint - \doifbothsides - {\@@ppleft \box#1\@@ppright} - {\@@ppleft \box#1\@@ppright} - {\@@ppright\box#1\@@ppleft }% - \else - \@@ppleft \box#1\@@ppright - \fi}% - \par - \@@ppbottom}} + \ifdim\printpaperheight>\ht#1\relax + \donetrue + \else\ifdim\printpaperwidth>\wd#1\relax + \donetrue + \else + \donefalse + \fi\fi + \ifdone + \setbox#1\vbox to \printpaperheight + {\@@pptop + \page_location_top_fill + \hbox to \printpaperwidth + {\ifdoublesidedprint + \doifbothsides + {\@@ppleft \page_location_left_fill \box#1\page_location_right_fill\@@ppright}% + {\@@ppleft \page_location_left_fill \box#1\page_location_right_fill\@@ppright}% + {\@@ppright\page_location_right_fill\box#1\page_location_left_fill \@@ppleft }% + \else + \@@ppleft \page_location_left_fill \box#1\page_location_right_fill\@@ppright + \fi}% + \par + \page_location_bottom_fill + \@@ppbottom}% + \fi} \def\offsetprintbox#1% {\ifdim\topoffset=\zeropoint % \relax @@ -826,36 +904,42 @@ \fi} \def\orientpagebodybox#1#2#3% - {\ifnum#2#3>\zerocount - \setbox#1\vbox - {\edef\somerotation{\ifdoublesided\ifodd\realpageno#2\else#3\fi\else#2\fi}% - \dorotatebox\somerotation\hbox{\box#1}}% + {\ifnum\number#1\number#2>\zerocount + \setbox#3\vbox + {\edef\somerotation{\number\ifdoublesided\ifodd\realpageno#1\else#2\fi\else#1\fi}% + \dorotatebox\somerotation\hbox{\box#3}}% \fi} -\def\orientpaperbox#1% - {\orientpagebodybox{#1}\paperorientation\paperreverse} - -\def\orientprintbox#1% - {\orientpagebodybox{#1}\printorientation\printreverse} +\def\orientpaperbox{\orientpagebodybox\paperorientation\paperreverse} +\def\orientprintbox{\orientpagebodybox\printorientation\printreverse} \def\mirrorpagebodybox#1#2% - {\ifcase#2\or - \setbox#1\vbox{\domirrorbox\vbox{\box#1}}% + {\ifconditional#1\relax + \setbox#2\vbox{\domirrorbox\vbox{\box#2}}% \fi} -\def\mirrorpaperbox#1% - {\mirrorpagebodybox{#1}\papermirror} - -\def\mirrorprintbox#1% - {\mirrorpagebodybox{#1}\printmirror} +\def\mirrorpaperbox{\mirrorpagebodybox\papermirror} +\def\mirrorprintbox{\mirrorpagebodybox\printmirror} \def\scalepagebox#1% - {\ifdim\@@lyscale\points=\onepoint \else - \setbox#1\vbox{\scale[\c!sx=\@@lyscale,\c!sy=\@@lyscale]{\box#1}}% - \paperwidth \@@lyscale\paperwidth - \paperheight\@@lyscale\paperheight + {\ifdim\@@lyscale\points=\onepoint + \ifdim\@@lysx\points=\onepoint + \ifdim\@@lysy\points=\onepoint + \else + \doscalepagebox{#1}\@@lysx\@@lysy + \fi + \else + \doscalepagebox{#1}\@@lysx\@@lysy + \fi + \else + \doscalepagebox{#1}\@@lyscale\@@lyscale \fi} +\def\doscalepagebox#1#2#3% + {\setbox#1\vbox{\scale[\c!sx=#2,\c!sy=#3]{\box#1}}% + \paperwidth #2\paperwidth + \paperheight#3\paperheight} + \def\negateprintbox#1% {\ifnegateprintbox \negatecolorbox{#1}% @@ -910,8 +994,8 @@ \def\doaddpagecolormarks#1#2% {\makepagecutbox{#2}% - \ifnum\horizontalcutmarks>\plustwo \chardef\colormarkoffset\plusfour \fi - \ifnum\verticalcutmarks >\plustwo \chardef\colormarkoffset\plusfour \fi + \ifnum\horizontalcutmarks>\plustwo \def\colormarkoffset{\plusfour}\fi + \ifnum\verticalcutmarks >\plustwo \def\colormarkoffset{\plusfour}\fi #1{#2}} % NOG EENS NAGAAN WANNEER NU GLOBAL EN WANNEER NIET @@ -963,10 +1047,10 @@ \newdimen\innermakeupwidth % special purpose \newdimen\innermakeupmargin % special purpose -\chardef\innermakeupcompensation\plusone +\newconditional\innermakeupcompensation \settrue\innermakeupcompensation \def\compensatedinnermakeupmargin - {\dimexpr\ifnum\innermakeupcompensation=\plusone+\innermakeupmargin\else\zeropoint\fi\relax} + {\dimexpr\ifconditional\innermakeupcompensation+\innermakeupmargin\else\zeropoint\fi\relax} \def\freezetextwidth % \makeupwidth may be set to \textwidth {\textwidth\makeupwidth % which is a tricky but valid value @@ -1146,11 +1230,11 @@ %D \showsetup{showsetups} %D %showsetup{showmargins} -\fetchruntimecommand \showprint {page-run.mkii} -\fetchruntimecommand \showframe {page-run.mkii} -\fetchruntimecommand \showlayout {page-run.mkii} -\fetchruntimecommand \showsetups {page-run.mkii} -\fetchruntimecommand \showmargins {page-run.mkii} +\fetchruntimecommand \showprint {page-run} +\fetchruntimecommand \showframe {page-run} +\fetchruntimecommand \showlayout {page-run} +\fetchruntimecommand \showsetups {page-run} +\fetchruntimecommand \showmargins {page-run} %D The default dimensions are quite old and will not change. %D The funny fractions were introduced when we went from fixed @@ -1166,6 +1250,25 @@ %D since they could change while going to a new page, %D depending on the current font setting. +\setuppaper % (size) % only used in XY imposition + [\c!width=\zeropoint, + \c!height=\zeropoint, + \c!topspace=\zeropoint, + \c!backspace=\zeropoint, + \c!dx=\zeropoint, + \c!dy=\zeropoint, + \c!nx=1, + \c!ny=1, + \c!method=\v!normal] + +\setuppapersize + [\c!option=\v!max, + \c!top=, + \c!bottom=, + \c!left=, + \c!right=, + \c!location=] + \setuplayout [ \c!topspace=.08417508418\paperheight, % 2.5cm \c!top=\zeropoint, @@ -1201,8 +1304,10 @@ \c!style=, \c!color=, \c!marking=\v!off, - \c!location=, % \v!singlesided, but empty is signal + \c!location=,% \v!singlesided, but unset is signal (no other default, spoils arrange) \c!scale=1, + \c!sx=1, + \c!sy=1, \c!nx=1, \c!ny=1, \c!dx=\zeropoint, @@ -1220,27 +1325,6 @@ %D First we define a whole range of (DIN) papersizes, %D of which the A-series makes most sense. We enable checking. -%D We also set some of the parameters that will be used when -%D positioning the typeset paper onto the print paper. - -\setuppaper % (size) % only used in XY imposition - [\c!width=\zeropoint, - \c!height=\zeropoint, - \c!topspace=\zeropoint, - \c!backspace=\zeropoint, - \c!dx=\zeropoint, - \c!dy=\zeropoint, - \c!nx=1, - \c!ny=1, - \c!method=\v!normal] - -\setuppapersize - [\c!option=\v!max, - \c!top=, - \c!bottom=\vss, - \c!left=, - \c!right=\hss] - \definepapersize [A0] [\c!width=841mm,\c!height=1189mm] \definepapersize [A1] [\c!width=594mm,\c!height=841mm] \definepapersize [A2] [\c!width=420mm,\c!height=594mm] @@ -1368,10 +1452,15 @@ %D paper size with the typeset paper size. This setting should %D come after the first layout specification (already done). -\setuppapersize - [A4][A4] +% \definepapersize +% [\v!default] +% [ \c!width=\paperwidth, +% \c!height=\paperheight] -%D A few goodies: +% \definepapersize +% [samesized] +% [ \c!width=\paperwidth, +% \c!height=\paperheight] \definepapersize [oversized] @@ -1388,6 +1477,14 @@ [ \c!width=\dimexpr \paperheight+1.5cm\relax, \c!height=\dimexpr2\paperwidth +1.5cm\relax] +% \setuppapersize +% [A4][A4] + +\setuppapersize + [A4][samesized] + +%D A few goodies: + %D For orthogonality: \definepapersize |