page-mrk.mkiv /size: 8134 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=page-mrk,
3
%D version=2011.05.23, % moved from page-lay
4
%D title=\CONTEXT\ Page Macros,
5
%D subtitle=Cutmarks and Colorbars,
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
/
Cutmarks
and
Colorbars
}
15 16
\unprotect
17 18
%D This module implements curmarks and depends on \METAPOST.
19
%D
20
%D \starttyping
21
%D \setuplayout[marking=on,location=middle]
22
%D \setuplayout[marking=page,location=middle]
23
%D \setuplayout[marking=empty,location=middle]
24
%D \setuplayout[marking={color,page},location=middle]
25
%D \setuplayout[marking={one,page},location=middle]
26
%D \setuplayout[marking={two,page},location=middle]
27
%D \setuplayout[marking={four,page},location=middle]
28
%D \stoptyping
29 30
\def
\pagecutmarklength
{
5
mm
}
31
\def
\pagecutmarkoffset
{
3
mm
}
% slightly larger than before, and now a fixed size
32
\def
\pagecutmarkmargin
{
1
0
cm
}
33 34
% maybe all these should be global
35 36
\newconditional
\c_page_marks_add_more_color
37
\newconditional
\c_page_marks_add_more_marking
38
\newconditional
\c_page_marks_add_more_lines
39
\newconditional
\c_page_marks_add_page_lines
40
\newconditional
\c_page_marks_add_more_number
41 42
\newcount
\c_page_marks_max
43
\newcount
\c_page_marks_nx
44
\newcount
\c_page_marks_ny
45 46
\startuniqueMPgraphic
{
print:color
}
{
w,h,l,o
}
47
loadmodule
"
crop
"
;
48
page_marks_add_color
(
\MPvar
w
,
\MPvar
h
,
\MPvar
l
,
\MPvar
o
)
;
49
\stopuniqueMPgraphic
50 51
\startuniqueMPgraphic
{
print:marking
}
{
w,h,l,o
}
52
loadmodule
"
crop
"
;
53
page_marks_add_marking
(
\MPvar
w
,
\MPvar
h
,
\MPvar
l
,
\MPvar
o
)
;
54
\stopuniqueMPgraphic
55 56
\startuniqueMPgraphic
{
print:lines
}
{
w,h,l,o,x,y
}
57
loadmodule
"
crop
"
;
58
page_marks_add_lines
(
\MPvar
w
,
\MPvar
h
,
\MPvar
l
,
\MPvar
o
,
\MPvar
x
,
\MPvar
y
,
59
\ifconditional
\c_page_marks_add_page_lines
tru
\else
fals
\fi
e
)
;
60
\stopuniqueMPgraphic
61 62
\startuseMPgraphic
{
print:number
}
{
w,h,l,o,n
}
63
loadmodule
"
crop
"
;
64
page_marks_add_number
(
\MPvar
w
,
\MPvar
h
,
\MPvar
l
,
\MPvar
o
,
\MPvar
n
)
;
65
\stopuseMPgraphic
66 67
\def
\page_marks_add_color
68
{
\setlayoutcomponentattribute
{
\v!print
:
\v!color
}
%
69
\setbox
\scratchbox
\hpack
\layoutcomponentboxattribute
\bgroup
70
\uniqueMPgraphic
71
{
print:color
}
%
72
{
w
=
\the
\scratchwidth
,
h
=
\the
\scratchheight
,
%
73
l
=
\pagecutmarklength
,
o
=
\pagecutmarkoffset
}
%
74
\egroup
75
\wd
\scratchbox\scratchwidth
\ht
\scratchbox\scratchheight
\dp
\scratchbox\scratchdepth
76
\hskip
-
\scratchwidth
\box
\scratchbox
}
77 78
\def
\page_marks_add_marking
79
{
\setlayoutcomponentattribute
{
\v!print
:
\v!marking
}
%
80
\setbox
\scratchbox
\hpack
\layoutcomponentboxattribute
\bgroup
81
\uniqueMPgraphic
82
{
print:marking
}
%
83
{
w
=
\the
\scratchwidth
,
h
=
\the
\scratchheight
,
%
84
l
=
\pagecutmarklength
,
o
=
\pagecutmarkoffset
}
%
85
\egroup
86
\wd
\scratchbox\scratchwidth
\ht
\scratchbox\scratchheight
\dp
\scratchbox\scratchdepth
87
\hskip
-
\scratchwidth
\box
\scratchbox
}
88 89
\def
\page_marks_add_lines
90
{
\setlayoutcomponentattribute
{
\v!print
:
\v!lines
}
%
91
\setbox
\scratchbox
\hpack
\layoutcomponentboxattribute
\bgroup
92
\uniqueMPgraphic
93
{
print:lines
}
%
94
{
w
=
\the
\scratchwidth
,
h
=
\the
\scratchheight
,
%
95
l
=
\pagecutmarklength
,
o
=
\pagecutmarkoffset
,
%
96
x
=
\the
\c_page_marks_nx
,
y
=
\the
\c_page_marks_ny
}
%
97
\egroup
98
\wd
\scratchbox\scratchwidth
\ht
\scratchbox\scratchheight
\dp
\scratchbox\scratchdepth
99
\hskip
-
\scratchwidth
\box
\scratchbox
}
100 101
\def
\page_marks_add_number
102
{
\setlayoutcomponentattribute
{
\v!print
:
\v!number
}
%
103
\setbox
\scratchbox
\hpack
\layoutcomponentboxattribute
\bgroup
104
\useMPgraphic
105
{
print:number
}
%
106
{
w
=
\the
\scratchwidth
,
h
=
\the
\scratchheight
,
%
107
l
=
\pagecutmarklength
,
o
=
\pagecutmarkoffset
,
%
108
n
=
\number\ifcase
\arrangeno
\realpageno
\else
\arrangeno
\fi
}
%
109
\egroup
110
\wd
\scratchbox\scratchwidth
\ht
\scratchbox\scratchheight
\dp
\scratchbox\scratchdepth
111
\hskip
-
\scratchwidth
\box
\scratchbox
}
112 113
\def
\page_marks_add_page_indeed
#
1
%
114
{
\setbox
#
1
\hpack
\bgroup
115
\resetvisualizers
116
\let
\objectoffset
\pagecutmarkmargin
117
%\infofont
118
\scratchwidth
\wd
#
1
%
119
\scratchheight
\ht
#
1
%
120
\scratchdepth
\dp
#
1
%
121
\box
#
1
\relax
122
\page_marks_add_lines
123
\egroup
}
124 125
\def
\page_marks_add_more_indeed
#
1
%
126
{
\setbox
#
1
\hbox
\bgroup
127
\resetvisualizers
128
\let
\objectoffset
\pagecutmarkmargin
129
\infofont
130
\scratchwidth
\wd
#
1
% these can move out
131
\scratchheight
\ht
#
1
%
132
\scratchdepth
\dp
#
1
%
133
\box
#
1
\relax
134
\ifconditional
\c_page_marks_add_more_color
135
\page_marks_add_color
136
\fi
137
\ifconditional
\c_page_marks_add_more_marking
138
\page_marks_add_marking
139
\fi
140
\ifconditional
\c_page_marks_add_more_lines
141
\page_marks_add_lines
142
\fi
143
\ifconditional
\c_page_marks_add_more_number
144
\page_marks_add_number
145
\fi
146
\global\advance
\c_page_marks_max
\minusone
147
\ifnum
\c_page_marks_max
>
\zerocount
\else
148
\glet
\page_marks_add_more
\gobbleoneargument
149
\glet
\page_marks_add_page
\gobbleoneargument
150
\fi
151
\egroup
}
152 153
\let
\page_marks_add_page
\gobbleoneargument
154
\let
\page_marks_add_more
\gobbleoneargument
155 156
\installcorenamespace
{
layoutmarking
}
157 158
\unexpanded
\def
\installpagecutmark
#
1
#
2
%
159
{
\setvalue
{
\??layoutmarking
#
1
}{
#
2
}}
160 161
% \installpagecutmark\v!off
162
% {}
163 164
% \installpagecutmark\v!text
165
% {\settrue\c_page_marks_add_more_lines
166
% \settrue\c_page_marks_add_more_number
167
% \let\pagecutmarksymbol\empty
168
% \let\pagecutmarkbottomtext\extrapagecutmarkbottomtext}
169 170
\installpagecutmark
\v!on
171
{
%settrue\c_page_marks_add_page_lines
172
\settrue
\c_page_marks_add_more_lines
173
\settrue
\c_page_marks_add_more_number
}
174 175
\installpagecutmark
\v!page
176
{
\settrue
\c_page_marks_add_page_lines
177
\settrue
\c_page_marks_add_more_lines
178
\settrue
\c_page_marks_add_more_number
}
179 180
\installpagecutmark
\v!empty
181
{
%settrue\c_page_marks_add_page_lines
182
\settrue
\c_page_marks_add_more_lines
}
183 184
\installpagecutmark
\v!color
185
{
%settrue\c_page_marks_add_page_lines
186
\settrue
\c_page_marks_add_more_lines
187
\settrue
\c_page_marks_add_more_color
188
\settrue
\c_page_marks_add_more_marking
189
\settrue
\c_page_marks_add_more_number
}
190 191
\installpagecutmark
\v!one
{
\global
\c_page_marks_max
\plusone
}
% first page
192
\installpagecutmark
\v!two
{
\global
\c_page_marks_max
\plustwo
}
% first two pages
193
\installpagecutmark
\v!four
{
\global
\c_page_marks_max
\plusfour
}
% first four pages
194 195
\unexpanded
\def
\page_marks_set
#
1
%
196
{
\begincsname
\??layoutmarking
#
1
\endcsname
}
197 198
\appendtoks
199
\setfalse
\c_page_marks_add_page_lines
200
\setfalse
\c_page_marks_add_more_color
201
\setfalse
\c_page_marks_add_more_marking
202
\setfalse
\c_page_marks_add_more_lines
203
\setfalse
\c_page_marks_add_more_number
204
\global
\c_page_marks_max
\maxcount
205
\rawprocesscommacommand
[
\layoutparameter
\c!marking
]
\page_marks_set
206
\ifnum
\c_page_marks_max
<
\maxcount
207
\ifconditional
\c_page_marks_add_page_lines
\else
208
\ifconditional
\c_page_marks_add_more_color
\else
209
\ifconditional
\c_page_marks_add_more_marking
\else
210
\ifconditional
\c_page_marks_add_more_lines
\else
211
\ifconditional
\c_page_marks_add_more_number
\else
212
\settrue
\c_page_marks_add_page_lines
213
\settrue
\c_page_marks_add_more_number
214
\fi\fi\fi\fi\fi
215
\fi
216
\ifconditional
\c_page_marks_add_page_lines
217
\let
\page_marks_add_page
\page_marks_add_page_indeed
218
\else
219
\let
\page_marks_add_page
\gobbleoneargument
220
\fi
221
% we can get a double set of (overlayed) lines .. needs to be redone (too many objects anyway)
222
\ifconditional
\c_page_marks_add_more_lines
223
\let
\page_marks_add_more
\page_marks_add_more_indeed
224
\else
\ifconditional
\c_page_marks_add_more_color
225
\let
\page_marks_add_more
\page_marks_add_more_indeed
226
\else
\ifconditional
\c_page_marks_add_more_marking
227
\let
\page_marks_add_more
\page_marks_add_more_indeed
228
\else
\ifconditional
\c_page_marks_add_more_number
229
\let
\page_marks_add_more
\page_marks_add_more_indeed
230
\else
231
\let
\page_marks_add_more
\gobbleoneargument
232
\fi\fi\fi\fi
233
\to
\everysetuplayout
234 235
\setuplayout
236
[
\c!marking
=
\v!off
]
237 238
\protect
\endinput
239