summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/page-plg.tex
blob: b8da7f88af7017ee84c67e18927412e07a70317d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
%D \module
%D   [       file=page-pls,
%D        version=2003.03.16,
%D          title=\CONTEXT\ Core Macros,
%D       subtitle=Page Setup,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright=PRAGMA-ADE]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\ifx\pageareabox\undefined \else \endinput \fi

\writestatus{loading}{Context Core Macros / Extra Page Building}

%D This feature has been present for a while but has never been
%D exploited: pluggable pagebuilders. The next example code
%D demonstrates the application of one such a plug-in. This variant
%D support \type {page}, \type {leftpage} and \type {rightpage}
%D definitions where specific areas are placed with the \type
%D {\pagearea} command.
%D
%D \starttyping
%D \setupheadertexts[the header text]
%D \setupfootertexts[a pretty long left footer text][something right]
%D \setupbottomtexts[a not so long bottom text][another right thing]
%D \setuptexttexts  [margin][something marginal][indeed]
%D
%D \startpagelayout[leftpage]
%D   \setupTABLE[offset=overlay]
%D   \setupTABLE[c][1][width=\leftmarginwidth]
%D   \bTABLE
%D     \bTR
%D       \bTD[nx=3,background=color,backgroundcolor=green]
%D         \pagearea[header][text][middle]
%D       \eTD
%D     \eTR
%D     \bTR
%D       \bTD \pagearea[text][margin][left] \eTD
%D       \bTD[nx=2] \pagearea[text] \eTD
%D     \eTR
%D     \bTR
%D       \bTD[nx=3,offset=overlay]
%D         {\bTABLE[width=.5\hsize]
%D            \bTR
%D              \bTD \pagearea[footer][text][left] \eTD
%D              \bTD \pagearea[bottom][text][left] \eTD
%D            \eTR
%D          \eTABLE}
%D        \eTD
%D     \eTR
%D   \eTABLE
%D \stoppagelayout
%D
%D \startpagelayout[rightpage]
%D   \setupTABLE[offset=overlay]
%D   \setupTABLE[c][1][width=\rightmarginwidth]
%D   \bTABLE
%D     \bTR
%D       \bTD[nx=3] \pagearea[header][text][middle] \eTD
%D     \eTR
%D     \bTR
%D       \bTD \pagearea[text][margin][left] \eTD
%D       \bTD[nx=2] \pagearea[text] \eTD
%D     \eTR
%D     \bTR
%D       \bTD[nx=3,offset=overlay]
%D         {\bTABLE[width=.5\hsize]
%D            \bTR
%D              \bTD \pagearea[bottom][text][right] \eTD
%D              \bTD \pagearea[footer][text][right] \eTD
%D            \eTR
%D          \eTABLE}
%D       \eTD
%D     \eTR
%D   \eTABLE
%D \stoppagelayout
%D
%D \setupcolors[state=start]
%D
%D \setupbackgrounds[text][background=color,backgroundcolor=blue]
%D \setupbackgrounds[header][text][background=color,backgroundcolor=red]
%D
%D \setuppagenumbering[alternative=doublesided,location=]
%D
%D \setuplayout[method=makeup]
%D
%D \definetextbackground
%D   [test]
%D   [state=start,
%D    background=color,
%D    backgroundcolor=yellow]
%D
%D \starttext
%D
%D \dorecurse{10}{\input tufte \par}
%D
%D \input tufte \starttest \input tufte \stoptest \input tufte
%D
%D \starttabulate
%D \NC test \NC \starttest \input tufte  \stoptest \NC \NR
%D \stoptabulate
%D
%D \dorecurse{10}{\input tufte \par}
%D
%D \stoptext
%D \stoptyping

\unprotect

\setvalue{\??ly\c!method\v!makeup}#1#2%
  {\setbox\pagebox\hbox
     {\vbox to \textheight
        {\offinterlineskip
         % optie
         \vskip-1\topskip
         \vskip\strutheight
         %
         \textwidth\makeupwidth
         \hsize\textwidth
         \boxmaxdepth\maxdepth
         \noindent
         \dopagecontents#1#2}}%
   \wd\pagebox\makeupwidth
   \ht\pagebox\textheight
   \dp\pagebox\zeropoint
   \hsize\paperwidth
   \vsize\paperheight
   \setbox\pagebox\vbox
     {\doifbothsidesoverruled
        {\let\!!stringa\v!page}
        {\let\!!stringa\v!rightpage}
        {\let\!!stringa\v!leftpage}%
      \getvalue{\??ly\c!method:\!!stringa}}%
   \wd\pagebox\paperwidth
   \ht\pagebox\paperheight
   \dp\pagebox\zeropoint}

\newbox\pageareabox

\def\pagearea
  {\dotripleempty\dopagearea}

\def\dopagearea[#1][#2][#3]%
  {\ifthirdargument
     \doifelse{#3}\v!left
       {\dodopagearea{#1}{#2}\c!lefttext}
       {\doifelse{#3}\v!right
          {\dodopagearea{#1}{#2}\c!righttext}
          {\dodopagearea{#1}{#2}\c!middletext}}%
   \else\ifsecondargument
     \doifbothsidesoverruled
       {\dodopagearea{#1}{#2}\c!righttext}
       {\dodopagearea{#1}{#2}\c!righttext}
       {\dodopagearea{#1}{#2}\c!lefttext }%
   \else
     \doif{#1}\v!text % copy due to trial runs in TABLE
       {\iftrialtypesetting
          \copy\pagebox
        \else
          \setbox\pagebox\vbox
            {\localstarttextcolor
               \box\pagebox
             \localstoptextcolor}%
          \localpositioningfalse
          \addtextbackground\pagebox
          \addtextgridlayer\pagebox
          \box\pagebox
        \fi}%
   \fi\fi}

\def\dodopagearea#1#2#3%
  {\setbox\pageareabox\vbox{\getvalue{\??tk#1#2#3}}%
   \ifsomebackgroundfound{#1#2}%
     \iftrialtypesetting
       \box\pageareabox
     \else
       \localframed
         [\??ma#1#2]
         [\c!width=\wd\pageareabox,
          \c!height=\ht\pageareabox,
          \c!offset=\v!overlay]
         {\box\pageareabox}%
     \fi
   \else
     \box\pageareabox
   \fi}

\setvalue{\??ly\c!method:\v!leftpage }{\getvalue{\??ly\c!method:\v!page}}
\setvalue{\??ly\c!method:\v!rightpage}{\getvalue{\??ly\c!method:\v!page}}

% \long\def\startpagelayout[#1]#2\stoppagelayout
%   {\long\setvalue{\??ly\c!method:#1}{#2}}

\long\def\startpagelayout
  {\bgroup\catcode`\^^M=\@@ignore\dostartpagelayout}

\long\def\dostartpagelayout[#1]#2\stoppagelayout
  {\egroup\long\setvalue{\??ly\c!method:#1}{#2}}

\protect \endinput