s-pre-22.tex /size: 9538 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=s-pre-22,
3
%D version=2000.08.07,
4
%D title=\CONTEXT\ Style File,
5
%D subtitle=Presentation Environment 22,
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
%D This style was made on behalf of the \PDFTEX\ presentation
15
%D at \TUG\ 2000. It cycled a summary of each talk, with name
16
%D and title. When documenting this style, I changed
17
%D reprocessing into pushing on layers.
18
%D
19
%D A \quote {problem} like this can be solved in several ways:
20
%D
21
%D \startitemize
22
%D \item writing a lot of semi||complex \TEX\ code as shown
23
%D \item keeping track of positions and draw everything on the
24
%D page layer
25
%D \item defining an overlay for each summary and changing the
26
%D order when flushing
27
%D \item maintaining a so called field stack
28
%D \stopitemize
29
%D
30
%D We go for the first method. We assume that summaries are
31
%D simple text snippets.
32 33
\startmode
[
asintended
]
\setupbodyfont
[
lbr
]
\stopmode
34 35
\setupbodyfont
[
1
4
.
4
pt
]
36 37
%D We use the whole page area.
38 39
\setuppapersize
40
[
S
6
][
S
6
]
41 42
\setuplayout
43
[
topspace
=
0
cm
,
44
backspace
=
0
cm
,
45
header
=
0
pt
,
46
footer
=
0
pt
,
47
width
=
middle
,
48
height
=
middle
]
49 50
%D We define a couple of matching colors and gray scales.
51
%D Watch out, some are really meant to look dim.
52 53
\setupcolors
54
[
state
=
start
]
55 56
\definecolor
[
PageColor
]
[
s
=
.
5
0
]
57
\definecolor
[
TextColor
]
[
s
=
.
8
0
]
58
\definecolor
[
DoneColor
]
[
s
=
.
6
5
]
59 60
\definecolor
[
TopColor
]
[
r
=
.
5
,
g
=
.
6
,
b
=
.
7
]
61
\definecolor
[
BotColor
]
[
r
=
.
6
,
g
=
.
7
,
b
=
.
5
]
62
\definecolor
[
DotColor
]
[
r
=
.
7
,
g
=
.
5
,
b
=
.
6
]
63 64
%D We will use foreground colors. Because these can interfere
65
%D with the colors they overload, we can bets make sure that
66
%D we don't have local colors.
67 68
\setupinteraction
69
[
state
=
start
,
70
color
=
,
71
contrastcolor
=]
72 73
%D The presentation is supposed to cycle automatically.
74 75
\setupinteractionscreen
76
[
option
=
max
,
77
delay
=
5
]
78 79
\setuppagetransitions
80 81
%D We will use random positioning of objects.
82 83
\setupsystem
84
[
random
=
medium
]
85 86
%D We have two kind of graphics: the page background and
87
%D the shape around the textual elements.
88 89
\defineoverlay
[
shape
]
[
\uniqueMPgraphic
{
shape
}
]
90
\defineoverlay
[
page
]
[
\reuseMPgraphic
{
page
}
]
91 92
\startreusableMPgraphic
{
page
}
93
StartPage
;
94
filldraw
Page
withcolor
\MPcolor
{
PageColor
}
;
95
pickup
pencircle
scaled
.375
cm
;
96
for
i
=
1
upto
200
:
97
drawdot
center
Page
randomized
(
PaperWidth
,
PaperHeight
)
98
withcolor
\MPcolor
{
DotColor
}
;
99
endfor
;
100
StopPage
;
101
\stopreusableMPgraphic
102 103
\startuniqueMPgraphic
{
shape
}
104
path
p
;
105
p
:
=
unitsquare
xyscaled
(
OverlayWidth
,
OverlayHeight
)
superellipsed
.90
;
106
draw
p
withpen
pencircle
scaled
.50
cm
withcolor
\MPcolor
{
PageColor
}
;
107
fill
p
withcolor
OverlayColor
;
108
draw
p
withpen
pencircle
scaled
.25
cm
withcolor
OverlayLineColor
;
109
currentpicture
:
=
currentpicture
xysized
(
OverlayWidth
,
OverlayHeight
)
;
110
\stopuniqueMPgraphic
111 112
%D The resizing at the end is needed to get a nice inverted
113
%D hyperlink when we click on it in a browser.
114 115
%D Behind the page we put a forward button:
116 117
\defineoverlay
[
forward
]
[
\overlaybutton
{
forward
}
]
118 119
%D The content will be managed by means of two layers.
120 121
\definelayer
[
main
]
\defineoverlay
[
main
]
[
\composedlayer
{
main
}
]
122
\definelayer
[
temp
]
\defineoverlay
[
temp
]
[
\composedlayer
{
temp
}
]
123 124
%D The first layer will hold everything to be shown, while
125
%D the second one gets the data we currently focus on.
126
%D Therefore the first layer will not be flushed each page.
127 128
\setuplayer
129
[
main
]
130
[
state
=
repeat
]
131 132
%D All the overlays go onto the page area.
133 134
\setupbackgrounds
135
[
page
]
136
[
background
=
{
page
,
forward
,
main
,
temp
}
]
137 138
%D We have to collect all data before we typeset it. Each
139
%D element will be typeset dim and bright. The dim
140
%D alternatives will be collected on the main layer, but each
141
%D bring one goes onto a box stack.
142 143
\initializeboxstack
{
Summary
}
144
\initializeboxstack
{
Subtext
}
145 146
%D The macros that take care of all this manipulations look
147
%D more complicated than they actually are. We use a
148
%D scratchbox to collect and inspect data. Also, because we
149
%D typeset each element twice, we need to make sure that we use
150
%D the same random seed for both.
151 152
\doglobal
\newcounter
\CurrentSummary
153 154
\def
\StartSummary
% bottom bot-title top-title
155
{
\dodoublegroupempty
\doStartSummary
}
156 157
\def
\doStartSummary
#
1
#
2
%
158
{
\doglobal
\increment
\CurrentSummary
159
\setbox
\scratchbox
=
\hbox
{
\strut
#
1
}
160
\getrandomseed
\RandomSeed
161
\setlayer
[
main
]
162
{
\RandomSubtextBox
{
DoneColor
}{
BotColor
}{
BotColor
}}
163
\setrandomseed
\RandomSeed
164
\savebox
{
Subtext
}{
\CurrentSummary
}
165
{
\RandomSubtextBox
{
TextColor
}{
BotColor
}{
black
}}
166
\setbox
\scratchbox
=
\hbox
\bgroup
167
\setbox
\scratchbox
=
\hbox
{
\bfb
\setstrut\strut\quad
#
2
\quad
}
%
168
\SetAcceptableWidth
169
\framed
[
offset
=
0
pt
,
width
=
fit
,
frame
=
off
,
align
=
middle
,
strut
=
no
]
170
\bgroup
\setupwhitespace
[
big
]
171
\doifsomething
{
#
2
}{
\noindent\box
\scratchbox
\blank
}}
172 173
\def
\StopSummary
174
{
\egroup
\egroup
175
\getrandomseed
\RandomSeed
176
\setlayer
[
main
]
177
{
\RandomSummaryBox
{
DoneColor
}{
TopColor
}{
TopColor
}}
178
\setrandomseed
\RandomSeed
179
\savebox
{
Summary
}{
\CurrentSummary
}
180
{
\RandomSummaryBox
{
TextColor
}{
TopColor
}{
black
}}}
181 182
%D A \type {\doStartSummary#1#2#3\StopSummary} could have been
183
%D used too but this one is less sensitive for catcode changes
184
%D (not that we expect problems like this in this kind of
185
%D application).
186 187
%D The width is either derived from the width ot the title or
188
%D at random. The final width of the box is detemined by the
189
%D content.
190 191
\def
\SetAcceptableWidth
192
{
\scratchdimen
=
.
5
\makeupwidth
193
\ifdim
\wd
\scratchbox
>
.
5
\makeupwidth
194
\getrandomdimen
\hsize
{
\wd
\scratchbox
}{
.
8
\makeupwidth
}
%
195
\else
196
\getrandomdimen
\hsize
{
.
5
\makeupwidth
}{
.
7
\makeupwidth
}
%
197
\fi
}
198 199
%D The subtext box goes at the bottom, somewhere in the right
200
%D corner.
201 202
\def
\RandomSubtextBox
#
1
#
2
#
3
%
203
{
\vbox
to
\makeupheight
204
{
\vfill
205
\hbox
to
\makeupwidth
206
{
\hfill
207
\button
208
[
offset
=
2
ex
,
frame
=
off
,
background
=
shape
,
strut
=
no
,
209
backgroundcolor
=#
1
,
framecolor
=#
2
,
foregroundcolor
=#
3
]
210
{
\copy
\scratchbox
}
%
211
[
previouspage
]
%
212
\getrandomdimen
\scratchdimen
{
.
5
cm
}{
2
.
5
cm
}
%
213
\hskip
\scratchdimen
}
214
\getrandomdimen
\scratchdimen
{
.
5
cm
}{
1
.
5
cm
}
215
\vskip
\scratchdimen
}}
216 217
%D The main text goes in the top half of the page, not to
218
%D far from the center. The last \type {\vskip} makes sure
219
%D that we don't clash with the subtexts.
220 221
\definereference
[
thispage
][
page
(
\CurrentSummary
)]
222 223
\def
\RandomSummaryBox
#
1
#
2
#
3
%
224
{
\vbox
to
\makeupheight
225
{
\getrandomdimen
\scratchdimen
{
.
5
cm
}
\makeupheight
226
\vskip
0
pt
plus
\scratchdimen
227
\hbox
to
\makeupwidth
228
{
\getrandomdimen
\scratchdimen
{
.
5
cm
}
\makeupwidth
229
\hskip
0
pt
plus
\scratchdimen
230
\button
231
[
offset
=
3
ex
,
frame
=
off
,
background
=
shape
,
strut
=
no
,
232
backgroundcolor
=#
1
,
framecolor
=#
2
,
foregroundcolor
=#
3
]
233
{
\copy
\scratchbox
}
%
234
[
thispage
]
%
235
\getrandomdimen
\scratchdimen
{
.
5
cm
}
\makeupwidth
236
\hskip
0
pt
plus
\scratchdimen
}
237
\getrandomdimen
\scratchdimen
{
.
5
cm
}
\makeupheight
238
\vskip
0
pt
plus
\scratchdimen
239
\vskip
.
2
\makeupheight
}}
240 241
%D Because we conly collect data, we hav eto make sure that at
242
%D some moment it is processed and flushed. The following loop
243
%D does this.
244 245
\def
\BuildPage
246
{
\dorecurse
{
\CurrentSummary
}
247
{
\startstandardmakeup
248
\setlayer
[
temp
]
{
\foundbox
{
Summary
}
\recurselevel
}
249
\setlayer
[
temp
]
{
\foundbox
{
Subtext
}
\recurselevel
}
250
\stopstandardmakeup
}}
251 252
%D We hook this macro into the \type {\stoptext} macro.
253 254
\appendtoks
\BuildPage
\to
\everystoptext
255 256
%D We still need a title page.
257 258
\def
\TitlePage
%
259
{
\dodoublegroupempty
\doTitlePage
}
260 261
\long\def
\doTitlePage
#
1
#
2
%
262
{
\ifsecondargument
263
\MakeTitlePage
{
#
1
}{
#
2
}
264
\else
\iffirstargument
265
\MakeTitlePage
{
\currentdate
}{
#
1
}
266
\else
267
\MakeTitlePage
{
\currentdate
}{
Welcome
}
268
\fi\fi
}
269 270
\def
\MakeTitlePage
#
1
#
2
%
271
{
\StartSummary
{
#
1
}{
#
2
}
\StopSummary
}
272 273
%D For old times sake:
274 275
\long\def
\StartTopic
#
1
\StopTopic
{
\StartSummary
#
1
\StopSummary
}
276 277
\doifnotmode
{
demo
}{
\endinput
}
278 279
%D The demo text.
280 281
\starttext
282 283
\TitlePage
{
Indeed
}{
The
Title
Page
}
284 285
\StartSummary
{
Alpha
}{
Title
}
286
A
simple
and
not
too
long
text
just
to
show
the
topic
.
287
A
simple
and
not
too
long
text
just
to
show
the
topic
.
288
A
simple
and
not
too
long
text
just
to
show
the
topic
.
289
\StopSummary
290 291
\StartSummary
{
Beta
and
Gamma
}{
Another
Title
}
292
A
simple
and
not
too
long
text
just
to
show
the
topic
.
293
A
simple
and
not
too
long
text
just
to
show
the
topic
.
294
\StopSummary
295 296
\StartSummary
{
Delta
}{
Some
Title
}
297
A
simple
and
not
too
long
text
just
to
show
the
topic
.
298
\StopSummary
299 300
\StartSummary
{
Epsilon
}{
What
A
Title
}
301
A
simple
and
not
too
long
text
just
to
show
the
topic
.
302
A
simple
and
not
too
long
text
just
to
show
the
topic
.
303
A
simple
and
not
too
long
text
just
to
show
the
topic
.
304
\StopSummary
305 306
\StartSummary
{
Zeta
,
Eta
and
Theta
}{
Eh
,
A
Title
}
307
A
simple
and
not
too
long
text
just
to
show
the
topic
.
308
A
simple
and
not
too
long
text
just
to
show
the
topic
.
309
A
simple
and
not
too
long
text
just
to
show
the
topic
.
310
\StopSummary
311 312
\StartSummary
{
Omega
}
313
A
simple
and
not
too
long
text
just
to
show
the
topic
.
314
A
simple
and
not
too
long
text
just
to
show
the
topic
.
315
A
simple
and
not
too
long
text
just
to
show
the
topic
.
316
A
simple
and
not
too
long
text
just
to
show
the
topic
.
317
\StopSummary
318 319
\stoptext
320