page-mak.mklx /size: 8163 b    last modification: 2021-10-28 13:51
1
%D \module
2
%D [ file=page-mak, % copied from main-001,
3
%D version=1997.03.31,
4
%D title=\CONTEXT\ Page Macros,
5
%D subtitle=Simple MakeUp,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
\writestatus
{
loading
}
{
ConTeXt
Page
Macros
/
MakeUp
}
15 16
\unprotect
17 18
%D \macros
19
%D {definemakeup, setupmakeup, startmakeup}
20
%D
21
%D A makeup is a separate page, like a title page or colofon. There is one standard
22
%D makeup page, but you can define more if needed.
23
%D
24
%D \starttyping
25
%D \startstandardmakeup
26
%D My Fancy Title
27
%D \stopstandardmakeup
28
%D \stoptyping
29
%D
30
%D The associated commands are:
31
%D
32
%D \showsetup{definemakeup}
33
%D \showsetup{setupmakeup}
34
%D \showsetup{startmakeup}
35
%D
36
%D New is that we have a layout with the same name so one can set up a special
37
%D layout that then gets used.
38 39
\installcorenamespace
{
makeup
}
40
\installcorenamespace
{
makeupdoublesided
}
41 42
\installcommandhandler
\??makeup
{
makeup
}
\??makeup
43 44
\appendtoks
45
\frozen
\instance
\setuevalue
{
\e!start
\currentmakeup
\e!makeup
}
{
\startmakeup
[
\currentmakeup
]
}
%
46
\frozen
\instance
\setuevalue
{
\e!stop
\currentmakeup
\e!makeup
}
{
\stopmakeup
}
%
47
\doifelselayoutdefined
\currentmakeup
\donothing
{
\definelayout
[
\currentmakeup
]
}
% new
48
\to
\everydefinemakeup
49 50
%D The \type {\start}||\type {\stop} macros are used for both the direct and
51
%D indirect way. The parameterless call will build a simple box.
52 53
\permanent
\tolerant
\protected
\def
\startmakeup
[
#
1
]
#
*
[
#
2
]
%
54
{
\ifparameters
55
\expandafter
\page_makeup_start_nop
56
\else
57
\expandafter
\page_makeup_start_yes
58
\fi
[
#
1
]
[
#
2
]
}
59 60
\aliased
\let
\stopmakeup
\relax
61 62
%D The simple case: just a box with text dimensions.
63 64
\protected
\def
\page_makeup_start_nop
[
#
name
]
[
#
settings
]
% dummies
65
{
\page
66
\setupheader
[
\c!state
=
\v!empty
]
%
67
\setupfooter
[
\c!state
=
\v!empty
]
%
68
\bgroup
69
\forgetall
% else indented flush
70
\dontcomplain
71
\vbox
to
\textheight
\bgroup
72
\setsystemmode
\v!makeup
73
\hsize
\textwidth
74
\enforced
\let
\stopmakeup
\page_makeup_stop_nop
}
75 76
\permanent
\protected
\def
\page_makeup_stop_nop
77
{
\egroup
78
\egroup
79
\page
}
80 81
%D The normal variant.
82 83
\newbox
\b_page_makeup
84
\newtoks
\t_page_makeup_every_setup
85 86
\def
\page_makeup_start_yes
[
#
name
]
% [#settings]%
87
{
\doifelsecommandhandler
\??makeup
{
#
name
}
\page_makeup_start_indeed
\page_makeup_start_nop
[
#
name
]
}
%
88 89
% case 1:
90
%
91
% \setuplayout[height=5cm]
92
%
93
% case 2:
94
%
95
% \definelayout[crap][height=10cm]
96
% \definelayout[standard][crap]
97
%
98
% case 3:
99
%
100
% \setuplayout[standard][height=15cm]
101
%
102
% case 4:
103
%
104
% \definelayout[whatever][height=2cm]
105
% \setuplayout[whatever]
106 107
\def
\page_makeup_start_indeed
[
#
name
]
[
#
settings
]
%
108
{
% the next grouping hack is somewhat messy:
109
\begingroup
110
% we need to figure out the current layout
111
\xdef
\m_page_makeup_name
{
#
name
}
%
112
\let
\currentmakeup
\m_page_makeup_name
113
\let
\currentlayout
\m_page_makeup_name
114
\xdef
\m_page_makeup_layout_parent
{
\layoutparameter
\s!parent
}
%
115
\setupcurrentmakeup
[
#
settings
]
%
116
\edef
\p_page
{
\makeupparameter
\c!page
}
%
117
\ifempty
\p_page
118
\endgroup
119
\page
% new, so best not have dangling mess here like references (we could capture then and flush embedded)
120
\orelse
\ifx
\p_page
\v!no
121
% nothing
122
\endgroup
123
\else
124
\normalexpanded
{
\endgroup
\page
[
\p_page
]
}
%
125
\fi
126
% some dirty trickery (sorry) for determining if we have
127
% - a layout definition at all
128
% - inherit from the parent of that definition
129
% - inherit from the current layout otherwise
130
\ifx
\m_page_makeup_name
\currentlayout
131
% we already use the layout
132
\orelse
\ifx
\m_page_makeup_layout_parent
\??layout
133
% we inherit from the current layout
134
\normalexpanded
{
\setuplayout
[
#
name
]
[
\s!parent
=
\??layout
\currentlayout
]
}
% is remembered but checked later anyway
135
% \else
136
% we have an inherited layout
137
\fi
138
\startlayout
[
#
name
]
% includes \page
139
\bgroup
140
%\edef\currentmakeup{#name}%
141
\let
\currentmakeup
\m_page_makeup_name
142
\setupcurrentmakeup
[
#
settings
]
%
143
\setsystemmode
\v!makeup
144
\the
\t_page_makeup_every_setup
145
\makeupparameter
\c!commands
% hm, what is this one doing here ?
146
\forgetall
% else indented flush
147
\dontcomplain
148
\global
\setbox
\b_page_makeup
\vbox
to
\makeupparameter
\c!height
\bgroup
149
\usemakeupstyleandcolor
\c!style
\c!color
150
\hsize
\makeupparameter
\c!width
151
\usealignparameter
\makeupparameter
152
\usesetupsparameter
\makeupparameter
% lua(..),xml(...,..),tex(..)
153
\makeupparameter
\c!top
154
\enforced
\let
\stopmakeup
\page_makeup_stop_yes
}
155 156
\permanent
\protected
\def
\page_makeup_stop_yes
157
{
\endgraf
158
\makeupparameter
\c!bottom
159
\egroup
160
\strc_pagenumbers_page_state_push
% new
161
\makeupparameter
\c!before
\relax
162
\begingroup
163
\ifdim
\ht
\b_page_makeup
>
\vsize
164
\ht
\b_page_makeup
\vsize
% is already set to \textheight (maybe set dp to 0)
165
\fi
166
\setuppagenumber
[
\c!state
=
\makeupparameter
\c!pagestate
]
%
167
\doif
{
\makeupparameter
\c!location
}
\v!top
{
\topskip
\zeropoint
}
%
168
\edef
\p_reference
{
\makeupparameter
\c!reference
}
%
169
\dontleavehmode
170
\usereferenceparameter
\makeupparameter
171
\box
\b_page_makeup
% could be whole box being destination
172
\the
\t_page_makeup_every_setup
173
\page
174
\endgroup
175
\makeupparameter
\c!after
\relax
176
\ifdoublesided
\ifodd
\realpageno
\else
177
\csname
\??makeupdoublesided
\makeupparameter
\c!doublesided
\endcsname
178
\fi
\fi
179
\strc_pagenumbers_page_state_pop
% new
180
\egroup
181
\stoplayout
% includes \page
182
\ifx
\m_page_makeup_name
\currentlayout
183
\orelse
\ifx
\m_page_makeup_layout_parent
\??layout
184
\normalexpanded
{
\setuplayout
[
\m_page_makeup_name
]
[
\s!parent
=
\??layout
]
}
% is remembered but checked later anyway
185
\fi
}
186 187
\setvalue
{
\??makeupdoublesided
\v!yes
}
%
188
{
\emptyhbox
189
\page
}
190 191
\setvalue
{
\??makeupdoublesided
\v!empty
}
%
192
{
\the
\t_page_makeup_every_setup
193
% == \page[\v!dummy]
194
\page
[
\v!blank
]
%
195
\emptyhbox
196
\page
}
197 198
%D Probably obsolete (but used in one manual by Taco):
199 200
\permanent
\protected
\def
\startcolumnmakeup
% don't change
201
{
\bgroup
202
\getrawnoflines
\textheight
% raw as we can have topskip
203
\setbox
\scratchbox
\vbox
to
\dimexpr
\noflines
\lineheight
-
\lineheight
+
\topskip
\relax
204
\bgroup
205
\forgetall
}
206 207
\permanent
\protected
\def
\stopcolumnmakeup
208
{
\egroup
209
\dp
\scratchbox
\zeropoint
210
\wd
\scratchbox
\textwidth
211
\box
\scratchbox
212
\egroup
213
\page_otr_command_synchronize_hsize
}
214 215
%D The text surrounding the main body text can be influenced by setting their
216
%D associated status variables. The connection between them is made by the following
217
%D macro:
218 219
\appendtoks
% this might need a revision
220
\setupfooter
[
\c!state
=
\makeupparameter
\c!footerstate
]
%
221
\setupheader
[
\c!state
=
\makeupparameter
\c!headerstate
]
%
222
\setuptext
[
\c!state
=
\makeupparameter
\c!textstate
]
%
223
\setupbottom
[
\c!state
=
\makeupparameter
\c!bottomstate
]
%
224
\setuptop
[
\c!state
=
\makeupparameter
\c!topstate
]
%
225
\to
\t_page_makeup_every_setup
226 227
%D The standard page template is defined as follows:
228 229
\setupmakeup
230
[
\c!width
=
\innermakeupwidth
,
% example in manual / was \makeupwidth
231
\c!height
=
\textheight
,
% example in manual
232
%\c!commands=,
233
%\c!setups=,
234
%\c!color=,
235
%\c!align=,
236
%\c!before=,
237
%\c!after=,
238
%\c!location=,
239
\c!page
=
\v!right
,
240
\c!doublesided
=
\v!empty
,
241
\c!top
=
\vss
,
242
\c!bottom
=
\vss
,
243
\c!bottomstate
=
\v!normal
,
244
\c!topstate
=
\v!normal
,
245
\c!textstate
=
\v!normal
,
246
\c!headerstate
=
\v!stop
,
247
\c!footerstate
=
\v!stop
,
248
\c!pagestate
=
\v!stop
]
% in manual ! ! !
249
% \c!pagestate=\v!start]
250 251
\definemakeup
252
[
\v!standard
]
253
[
\c!width
=
\innermakeupwidth
,
254
\c!height
=
\textheight
,
255
\c!page
=
\v!right
,
256
\c!doublesided
=
\v!empty
]
257 258
\definemakeup
259
[
\v!text
]
260
[
\c!topstate
=
\v!start
,
261
\c!headerstate
=
\v!start
,
262
\c!textstate
=
\v!start
,
263
\c!footerstate
=
\v!start
,
264
\c!bottomstate
=
\v!start
,
265
\c!doublesided
=
\v!no
,
266
\c!page
=
\v!yes
,
267
\c!top
=
\pseudostrut
\ignorespaces
,
268
\c!bottom
=
\obeydepth
\vss
]
269 270
\definemakeup
271
[
\v!page
]
272 273
\definemakeup
274
[
\v!middle
]
275
[
\v!standard
]
276 277
% \definelayout[standard]
278
% \definelayout[text]
279 280
\protect
281