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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
%D \module
%D [ file=page-log, % moved here from main-001
%D version=1997.03.31,
%D title=\CONTEXT\ Page Macros,
%D subtitle=Logos,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\writestatus{loading}{Context Page Macros / Logos}
\unprotect
\startmessages dutch library: layouts
7: beeldmerken berekenen
\stopmessages
\startmessages english library: layouts
7: calculating logospace
\stopmessages
\startmessages german library: layouts
7: berechne Platz des Logo
\stopmessages
\startmessages czech library: layouts
7: pocita se misto pro logo
\stopmessages
\startmessages italian library: layouts
7: calcolo dello spazio per logo
\stopmessages
\startmessages norwegian library: layouts
7: beregner plass for logo
\stopmessages
\startmessages romanian library: layouts
7: se calculeaza spatiul pentru logo
\stopmessages
\startmessages french library: layouts
7: calcul de l'espace pour le logo
\stopmessages
%D Although logos can conveniently be implemented on top of
%D background and text areas, we provide a dedicated mechanism
%D here. One reason is that such a separate mechanism cannot
%D interfere with the other ones, but an even more important
%D reason is that logos are kind of special in the sense that
%D they have a short life span and may change after the first
%D page.
%D \macros
%D {recalculatelogos,addlogobackground}
%D
%D The interface to the other low level page building routines
%D is provided by a macro that signals changes in layout
%D specifications:
%D
%D \starttyping
%D \recalculatelogos
%D \stoptyping
%D
%D as well as a simple placement macro:
%D
%D \starttyping
%D \addlogobackground <box>
%D \stoptyping
%D
%D In no way the following boolean switch should be used
%D directly.
\newif\ifnewlogos
\def\recalculatelogos
{\global\newlogostrue}
%D The current state of logos is registered in a status
%D variable \type {\logostatus}.
%D
%D \starttabulate[|l|l|l|]
%D \NC 0 \NC don't place \NC remains 0 \NC \NR
%D \NC 1 \NC place now \NC remains 1 \NC \NR
%D \NC 2 \NC calulate and place \NC becomes 1 \NC \NR
%D \NC 3 \NC calculate and place once \NC becomes 2 \NC \NR
%D \stoptabulate
\chardef\logostatus=0
\def\addlogobackground#1% todo: dimension spec
{\ifcase\logostatus \else
\ifcase\logostatus
% no logos to take care of
\or % 1
\ifnewlogos
\chardef\logostatus2
\setlogoboxes
\chardef\logostatus1
\global\newlogosfalse
\fi
\or % 2
\setlogoboxes
\chardef\logostatus1
\or % 3
\setlogoboxes
\global\chardef\logostatus2
\fi
\setbox#1\vbox
{\offinterlineskip
\doifmarginswapelse
{\copy\leftlogos}
{\copy\rightlogos}
\box#1}%
\fi}
%D For efficiency reasons (and since logos seldom change inside
%D a document) we can save the left and right hand (or first
%D and following page) logos in boxes. The areas are slightly
%D different from the ones used in backgrounds and text
%D placement, but still related to the page layout. The {\em
%D left} and {\em right edge}, as well as {\em top} and {\em
%D bottom} touch the bounding box of the paper and are
%D therefore not the sams as their background adn text
%D counterparts. In addition there are {\em left}, {\em right}
%D and {\em middle} areas as well as a {\em page} one.
\newbox\leftlogos
\newbox\rightlogos
\def\setlogoboxes
{\showmessage\m!layouts7\empty
\dosetlogobox\leftlogos\relax
\ifdubbelzijdig
\dosetlogobox\rightlogos\doswapmargins
\fi}
\def\dosetlogobox#1#2%
{\global\setbox#1\vbox to \paperheight
{\dontcomplain % needed here ?
\calculatereducedvsizes % needed here ?
\offinterlineskip
#2\relax
\vskip-\topspace
\dodosetlogobox\v!top\blap
\vskip\topspace
\dodosetlogobox\v!header\blap
\vskip\headerheight
\vskip\headerdistance
\dodosetlogobox\v!text\blap
\vskip\textheight
\vskip\footerdistance
\vskip\footerheight
\dodosetlogobox\v!footer \tlap
\vfilll
\dodosetlogobox\v!bottom\tlap
\vskip\topspace}
\smashbox#1}
\def\dodosetlogobox#1#2%
{\hbox % width equals \makeupwidth
{\def\docommando##1%
{\donefalse
\ifnum\logostatus=3 \ExpandBothAfter
\doifinset{\getvalue{\??lo#1##1}}\requestedlogos\donetrue
\else
\doifvalue{\??lo#1##1\c!state}\v!start\donetrue
\fi
\ifdone
#2{\hbox{\getvalue{\??lo#1##1\c!command}}}%
\fi}%
\def\dodocommando##1##2##3##4##5##6%
{\hsmash
{\hskip-\texthoffset
\hbox to \paperwidth
{\rlap{\docommando##1}\hss\llap{\docommando##6}}%
\hskip-\paperwidth
\hbox to \paperwidth
{\hskip\texthoffset
\hskip-\leftmarginwidth
\hskip-\leftmargindistance
\hbox to \leftmarginwidth{\docommando##2\hss}%
\hskip\leftmargindistance
\hbox to \makeupwidth{\docommando##3\hss\docommando##4}%
\hskip\rightmargindistance
\hbox to \rightmarginwidth{\hss\docommando##5}%
\hfill}}}%
\normalbaselines
\settexthoffset
\hsmash
{\hbox to \makeupwidth{\hss\docommando\c!middle\hss}}%
\hsmash
{\hskip-\texthoffset
\hbox to \paperwidth{\docommando\v!page\hss}}%
\swapmargins
\doifbothsidesoverruled
\dodocommando
\v!leftedge \v!leftmargin \v!left
\v!right \v!rightmargin \v!rightedge
\orsideone
\dodocommando
\v!leftedge \v!leftmargin \v!left
\v!right \v!rightmargin \v!rightedge
\orsidetwo
\dodocommando
\v!rightedge \v!rightmargin \v!right
\v!left \v!leftmargin \v!leftedge
\od}}
%D The user interface is relatively simple and provides
%D macros for assigning logos to logo areas as well as
%D forcing placement.
%D
%D \showsetup{definelogo}
%D \showsetup{placelogos}
\let\definedlogos \empty
\let\requestedlogos\empty
\long\def\dodefinelogo[#1][#2][#3][#4]%
{\addtocommalist{#1}\definedlogos
\long\setvalue{\??lo#2#3}{#1}%
\getparameters[\??lo#2#3][#4]%
\global\chardef\logostatus2 }
\def\definelogo
{\doquadrupleargument\dodefinelogo}
\def\placelogos
{\dosingleempty\doplacelogos}
\def\doplacelogos[#1]%
{\xdef\requestedlogos{\iffirstargument#1\else\definedlogos\fi}%
\global\chardef\logostatus3 }
\protect \endinput
|