diff options
author | Hans Hagen <pragma@wxs.nl> | 2003-09-26 00:00:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2003-09-26 00:00:00 +0200 |
commit | 70b6b86404ca9e9de782a577d1dfda3b15f0544d (patch) | |
tree | 91a5d9d80b0e611d40cfaf1f6d69d9fbdcf683c6 /tex/context/base/page-lyr.tex | |
parent | 006ade39648b1d3cdc89a4bdc16cbe29882d70d3 (diff) | |
download | context-70b6b86404ca9e9de782a577d1dfda3b15f0544d.tar.gz |
stable 2003.09.26
Diffstat (limited to 'tex/context/base/page-lyr.tex')
-rw-r--r-- | tex/context/base/page-lyr.tex | 193 |
1 files changed, 100 insertions, 93 deletions
diff --git a/tex/context/base/page-lyr.tex b/tex/context/base/page-lyr.tex index b40e36337..bd76ab558 100644 --- a/tex/context/base/page-lyr.tex +++ b/tex/context/base/page-lyr.tex @@ -2,7 +2,7 @@ %D [ file=page-lyr, %D version=2000.10.20, %D title=\CONTEXT\ Page Macros, -%D subtitle=Layers, +%D subtitle=Layers, %D author=Hans Hagen, %D date=\currentdate, %D copyright={PRAGMA / Hans Hagen \& Ton Otten}] @@ -11,29 +11,29 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\writestatus{loading}{Context Page Macros / Layers} +\writestatus{loading}{Context Page Macros / Layers} \unprotect -% When being backgrounds layers get the background offset -% displacement. Should be an option, on by default +% When being backgrounds layers get the background offset +% displacement. Should be an option, on by default % (compatibility). %D The layering mechanism implemented here is independent of %D the output routine, but future extensions may depend on a -%D more close cooperation. +%D more close cooperation. %D First we overload a macro from \type {core-rul}. From now on %D we accept a (optional) argument: the specific layer it %D will go in. This means that we can move an overlay from one %D background to the other using the dimensions of the parent. -\ifx\undefined\defineoverlay \message{loaded to early} \wait \fi +\ifx\undefined\defineoverlay \message{loaded to early} \wait \fi \def\defineoverlay {\dotripleempty\dodefineoverlay} -\def\dodefineoverlay[#1][#2][#3]% overlay [layer] content +\def\dodefineoverlay[#1][#2][#3]% overlay [layer] content {\ifthirdargument \writestatus{BEWARE}{This (overlay definition) has changed!}% temp \def\docommando##1% @@ -47,24 +47,24 @@ \fi \processcommalist[#1]\docommando} -%D When tracing is turned on, a couple of boxes will -%D show up as well as the reference point. +%D When tracing is turned on, a couple of boxes will +%D show up as well as the reference point. \newif\iftracelayers % \tracelayerstrue -%D This handy constant saved some string memory. +%D This handy constant saved some string memory. \def\@@layerbox{@@layerbox} -%D \macros +%D \macros %D {definelayer} %D -%D Each layer gets its own (global) box. This also means that -%D the data that goes into a layer, is typeset immediately. -%D Each layer automatically gets an associated overlay, +%D Each layer gets its own (global) box. This also means that +%D the data that goes into a layer, is typeset immediately. +%D Each layer automatically gets an associated overlay, %D which can be used in any background assignment. -% todo : links/rechts +% todo : links/rechts \def\definelayer {\dodoubleargument\dodefinelayer} @@ -77,7 +77,7 @@ \c!x=\!!zeropoint,\c!y=\!!zeropoint,\c!positie=\v!nee, \c!regel=0,\c!kolom=0, \c!breedte=\nextboxwd,\c!hoogte=\nextboxht, - \c!offset=\!!zeropoint,\c!rotatie=, % geen 0 ! + \c!offset=\!!zeropoint,\c!rotatie=, % geen 0 ! \c!hoffset=\!!zeropoint,\c!voffset=\!!zeropoint, \c!plaats=rb,\c!positie=\v!nee,\c!pagina=, \c!methode=\v!overlay, @@ -95,11 +95,11 @@ \resetlayer[#1]% \fi} -%D \macros +%D \macros %D {setuplayer} %D -%D After a layer is defined, you can change its -%D characteristics. +%D After a layer is defined, you can change its +%D characteristics. \def\setuplayer {\dodoubleargument\dosetuplayer} @@ -108,17 +108,17 @@ {\def\docommando##1{\getparameters[\??ll##1][#2]}% \processcommalist[#1]\docommando} -%D \macros +%D \macros %D {setlayer} -%D +%D %D Data is moved into a layer with the following macro. When %D \type {position} is set, relative positioning is used, with %D the current point as reference point. Otherwise the topleft -%D corner is used as reference point. -%D -%D \starttypen -%D \setlayer [identifier] [optional parameters] {data} -%D \stoptypen +%D corner is used as reference point. +%D +%D \starttypen +%D \setlayer [identifier] [optional parameters] {data} +%D \stoptypen \def\currentlayerdata{0} @@ -158,7 +158,7 @@ \let\lastlayerxpos\!!zeropoint \let\lastlayerypos\!!zeropoint -% todo left/right +% todo left/right \def\setlastlayerpos#1% {\edef\layerpage{\MPp{lyr:\currentlayerdata}}% @@ -176,7 +176,7 @@ \def\dodefinelayerpreset[#1][#2]% {\setvalue{\??ll\??ll#1}{\dopresetlayer{#2}}} -\def\dopresetlayer#1#2#3% #1=list #2=tag #3=list +\def\dopresetlayer#1#2#3% #1=list #2=tag #3=list {\getparameters[\??ll#2][#1,#3]} \letempty\currentlayer @@ -187,18 +187,18 @@ \newdimen\layerheight \def\dododosetlayer[#1][#2][#3]% will be sped up - {% we use the global width, never change this + {% we use the global width, never change this \def\currentlayer{#1}% \@@layerxsiz\layerparameter\c!breedte \@@layerysiz\layerparameter\c!hoogte \layerwidth \@@layerxsiz \layerheight\@@layerysiz - % preroll + % preroll \getparameters[\??ll#1][#3]% - % presets and real roll + % presets and real roll \doifdefined{\??ll\??ll\layerparameter\c!preset} {\getvalue{\??ll\??ll\layerparameter\c!preset}{#1}{#3}}% - % that was real slow + % that was real slow \doifvalue{\??ll#1\c!positie}\v!overlay % slow {\getparameters[\??ll#1] [\c!breedte=\zeropoint, @@ -210,14 +210,14 @@ [\c!plaats=\v!hoog, \c!rotatie=\layerparameter\c!rotatie] {\flushnextbox}}}% - % no, not local + % no, not local % \@@layerxsiz\layerparameter\c!breedte - % \@@layerysiz\layerparameter\c!hoogte - % never change that + % \@@layerysiz\layerparameter\c!hoogte + % never change that \@@layerxpos\layerparameter\c!x \@@layerypos\layerparameter\c!y \doifelsevalue{\??ll#1\c!hoffset}\v!max - {\@@layerxoff\@@layerxsiz} + {\@@layerxoff\@@layerxsiz} {\@@layerxoff\layerparameter\c!hoffset}% \doifelsevalue{\??ll#1\c!voffset}\v!max {\@@layeryoff\@@layerysiz} @@ -246,7 +246,7 @@ \advance\scratchcounter\layoutlines \advance\scratchcounter\plusone \setevalue{\??ll#1\c!regel}{\the\scratchcounter}% - \fi + \fi \ifdim\@@layerysiz>\zeropoint \advance\@@layerypos-\@@layerysiz \@@layerypos-\@@layerypos @@ -259,7 +259,7 @@ \advance\scratchcounter \layoutcolumns \advance\scratchcounter \plusone \setevalue{\??ll#1\c!kolom}{\the\scratchcounter}% - \fi + \fi \ifdim\@@layerxsiz>\zeropoint \advance\@@layerxpos-\@@layerxsiz \@@layerxpos-\@@layerxpos @@ -277,11 +277,11 @@ {\edef\layerpage{:\layerpage}% \doifundefined{\@@layerbox#2#1\layerpage} {\global\expandafter\newbox\csname\@@layerbox#2#1\layerpage\endcsname}}% - \dontcomplain % more comfortable + \dontcomplain % more comfortable \global\setbox\csname\@@layerbox#2#1\layerpage\endcsname\vbox - to \layerparameter\c!hoogte % new, otherwise no negative y possible + to \layerparameter\c!hoogte % new, otherwise no negative y possible {\offinterlineskip - \hsize\layerparameter\c!breedte % new, keep box small + \hsize\layerparameter\c!breedte % new, keep box small \ifvoid\csname\@@layerbox#1\layerpage\endcsname\else \ht\csname\@@layerbox#2#1\layerpage\endcsname\zeropoint \dp\csname\@@layerbox#2#1\layerpage\endcsname\zeropoint @@ -297,13 +297,13 @@ \setbox\nextbox\hbox {\alignedbox[\layerparameter\c!plaats]\vbox{\flushnextbox}}% \fi - \ifnum\layerparameter\c!regel=\zerocount\else % no \ifcase, can be negative + \ifnum\layerparameter\c!regel=\zerocount\else % no \ifcase, can be negative \advance\@@layerypos \layerparameter\c!regel\lineheight - \advance\@@layerypos \topskip + \advance\@@layerypos \topskip \advance\@@layerypos-\lineheight \advance\@@layerypos-\nextboxht \fi - \ifnum\layerparameter\c!kolom=\zerocount\else % no \ifcase, can be negative + \ifnum\layerparameter\c!kolom=\zerocount\else % no \ifcase, can be negative \advance\@@layerxpos \layoutcolumnoffset{\layerparameter\c!kolom}% \fi \ifdone @@ -330,15 +330,15 @@ %D not even that complicated. It mainly comes down to skipping %D to the right place and placing a box on top of or below the %D existing content. In the case of position tracking, another -%D reference point is chosen. +%D reference point is chosen. %D \macros -%D {flushlayer} +%D {flushlayer} %D %D When we flush a layer, we flush both the main one and the -%D page dependent one (when defined). This feature is more -%D efficient in \ETEX\ since there testing for an undefined -%D macro does not takes hash space. +%D page dependent one (when defined). This feature is more +%D efficient in \ETEX\ since there testing for an undefined +%D macro does not takes hash space. % \unexpanded\def\flushlayer[#1]% % {\doifnotvalue{\??ll#1\c!status}{\v!stop} @@ -346,12 +346,12 @@ % {\doflushlayer1{#1}{#1}} % {\doflushlayer0{#1}{#1:\realfolio}} % \stopoverlay}} -% +% % \def\doflushlayer#1#2#3% % {\ifundefined{\@@layerbox#3}% % \ifcase#1\else\writestatus{layer}{unknown layer #3}\fi % \else -% \doifvalue{\??ll#2\c!optie}{\v!test} +% \doifvalue{\??ll#2\c!optie}{\v!test} % {\traceboxplacementtrue\tracelayerstrue}% % \iftracelayers \ruledvbox \else \vbox \fi to \overlayheight % {\forgetall @@ -363,7 +363,7 @@ % \doifnotvalue{\??ll#2\c!positie}{\v!ja} % {\doifvalue{\??ll#2\c!status}{\v!herhaal} % {\let\next\copy}}% -% \fi +% \fi % \next\csname\@@layerbox#3\endcsname % \hss}% % \vss}% @@ -372,15 +372,15 @@ \unexpanded\def\flushlayer[#1]% {\doifelsevalue{\??ll#1\c!dubbelzijdig}\v!ja {\doifundefinedelse{\@@layerbox#1}% - {\dodoflushlayerA[#1]} + {\dodoflushlayerA[#1]} {\doifbothsidesoverruled \dodoflushlayerB[#1][\v!links]% left \orsideone - \dodoflushlayerB[#1][\v!rechts]% right + \dodoflushlayerB[#1][\v!rechts]% right \orsidetwo \dodoflushlayerB[#1][\v!links]% left \od}} - {\dodoflushlayerA[#1]}} + {\dodoflushlayerA[#1]}} \def\dodoflushlayerA[#1]% {\doifnotvalue{\??ll#1\c!status}\v!stop @@ -398,7 +398,7 @@ {\dodoflushlayer0{#1}{#2#1:\realfolio}} \stopoverlay}} -% \def\dodoflushlayer#1#2#3% +% \def\dodoflushlayer#1#2#3% % {\ifundefined{\@@layerbox#3}% % \ifcase#1\else\writestatus{layer}{unknown layer #3}\fi % \else @@ -407,8 +407,8 @@ % \doifelsevalue{\??ll#2\c!methode}\v!tekst\donetrue\donefalse % \iftracelayers \ruledvbox \else \vbox \fi \ifdone \else to \overlayheight \fi % {\forgetall -% \hbox \ifdone \else to \overlaywidth \fi -% {% klopt dit? #3 en niet #2 ? +% \hbox \ifdone \else to \overlaywidth \fi +% {% klopt dit? #3 en niet #2 ? % \doifvalue{\??ll#3\realfolio\c!positie}\v!ja % {\xypos{lyr:#3:\realfolio}}% % \let\next\box @@ -416,13 +416,13 @@ % \doifnotvalue{\??ll#2\c!positie}\v!ja % {\doifvalue{\??ll#2\c!status}\v!herhaal % {\let\next\copy}}% -% \fi +% \fi % \next\csname\@@layerbox#3\endcsname % \hss}% % \vss}% % \fi} -\def\dodoflushlayer#1#2#3% +\def\dodoflushlayer#1#2#3% {\ifundefined{\@@layerbox#3}% \ifcase#1\else\writestatus{layer}{unknown layer #3}\fi \else @@ -431,8 +431,8 @@ \doifelsevalue{\??ll#2\c!methode}\v!tekst\donetrue\donefalse \iftracelayers \ruledvbox \else \vbox \fi \ifdone \else to \overlayheight \fi {\forgetall - \hbox \ifdone \else to \overlaywidth \fi - {% klopt dit? #3 en niet #2 ? + \hbox \ifdone \else to \overlaywidth \fi + {% klopt dit? #3 en niet #2 ? \doifvalue{\??ll#3\realfolio\c!positie}\v!ja {\xypos{lyr:#3:\realfolio}}% \let\next\box @@ -440,7 +440,7 @@ \doifnotvalue{\??ll#2\c!positie}\v!ja {\doifvalue{\??ll#2\c!status}\v!herhaal {\let\next\copy}}% - \fi + \fi \doifoverlayelse{#3} {\next\csname\@@layerbox#3\endcsname}% {\startlayoutcomponent{l:#3}{layer #3}% @@ -451,58 +451,65 @@ \fi} %D \macros -%D {composedlayer} +%D {composedlayer,placelayer,tightlayer} %D -%D This is a handy shortcut, which saves a couple of braces -%D when we use it as parameter. This name also suits better -%D to other layering commands. +%D This is a handy shortcut, which saves a couple of braces +%D when we use it as parameter. This name also suits better +%D to other layering commands. \def\composedlayer#1{\flushlayer[#1]} \let\placelayer\flushlayer +\def\tightlayer[#1]% + {\hbox + {\def\currentlayer{#1}% todo: left/right + \hsize\layerparameter\c!breedte + \vsize\layerparameter\c!hoogte + \composedlayer{#1}}} + %D \macros -%D {resetlayer} +%D {resetlayer} %D -%D This macro hardly needs an explanation (and is seldom -%D needed as well). +%D This macro hardly needs an explanation (and is seldom +%D needed as well). \def\doresetlayer#1% - {\ifundefined{\@@layerbox#1}\else + {\ifundefined{\@@layerbox#1}\else \global\setbox\csname\@@layerbox#1\endcsname\emptybox \fi} \def\resetlayer[#1]% {\doresetlayer{#1}% \doifvalue{\??ll#1\c!dubbelzijdig}\v!ja % kind of redundant test - {\doresetlayer{\v!links #1}% - \doresetlayer{\v!rechts#1}}% - \doresetlayer{#1:\realfolio}} + {\doresetlayer{\v!links #1}% + \doresetlayer{\v!rechts#1}}% + \doresetlayer{#1:\realfolio}} %D \macros %D {setMPlayer} -%D -%D The following layer macro uses the positions that are -%D registered by \METAPOST. +%D +%D The following layer macro uses the positions that are +%D registered by \METAPOST. %D %D \starttypen -%D \definelayer[test] -%D +%D \definelayer[test] +%D %D \setMPlayer [test] [somepos-1] {Whatever we want here!} %D \setMPlayer [test] [somepos-2] {Whatever we need there!} %D \setMPlayer [test] [somepos-3] {\externalfigure[cow.mps][width=2cm]} -%D +%D %D \startuseMPgraphic{oeps} -%D draw fullcircle scaled 10cm withcolor red ; -%D register ("somepos-1",2cm,3cm,center currentpicture) ; -%D register ("somepos-2",8cm,5cm,(-1cm,-2cm)) ; -%D register ("somepos-3",0cm,0cm,(-2cm,2cm)) ; +%D draw fullcircle scaled 10cm withcolor red ; +%D register ("somepos-1",2cm,3cm,center currentpicture) ; +%D register ("somepos-2",8cm,5cm,(-1cm,-2cm)) ; +%D register ("somepos-3",0cm,0cm,(-2cm,2cm)) ; %D \stopuseMPgraphic -%D +%D %D \getMLlayer[test]{\useMPgraphic{oeps}} %D \stoptypen -%D -%D The last line is equivalent to +%D +%D The last line is equivalent to %D %D \starttypen %D \framed @@ -530,8 +537,8 @@ \c!kader=\v!uit, \c!offset=\v!overlay,#2]} -% Some day this (old) mechanism will be combined/integrated -% in overlays +% Some day this (old) mechanism will be combined/integrated +% in overlays \newskip\xposition \newskip\yposition \newskip\xdimension \newskip\ydimension @@ -583,7 +590,7 @@ \dodoubleargument\getparameters[\??ps]} \def\calculateposition#1#2#3#4#5#6#7#8#9% - {\setdimensionwithunit\scratchskip{#1}\@@pseenheid + {\setdimensionwithunit\scratchskip{#1}\@@pseenheid \scratchskip#8\scratchskip \scratchskip#9\scratchskip \advance\scratchskip #4\relax @@ -612,7 +619,7 @@ \calculateposition{#4}\@@psystap\yposition \@@psyoffset\scratchdimen\ydimension\yoffset \@@psyschaal\@@psyfactor - \vbox to \zeropoint % kan beter. + \vbox to \zeropoint % kan beter. {\vskip\yposition \hbox to \zeropoint {\hskip\xposition @@ -631,7 +638,7 @@ \resetpositioning -\setuppositioning +\setuppositioning [\c!eenheid=\s!cm, \c!factor=1, \c!schaal=1, @@ -641,4 +648,4 @@ \c!xoffset=\!!zeropoint, \c!yoffset=\!!zeropoint] -\protect \endinput +\protect \endinput |