summaryrefslogtreecommitdiff
path: root/tex/context/base/s-pre-02.tex
blob: 2ec882b723e66561458d3f284f320ee1268d3fbc (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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
%D \module
%D   [      file=s-pre-02,
%D        version=1998.04.21,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Presentation Environment 2,
%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. 

%D This environment can be used to typeset interactive
%D presentations. This module was first used at the 1998 
%D publishers conference of the European Portable Document 
%D Association.

\usemodule[pre-general] % mode=step 

%D \macros
%D   {setupbodyfont, switchtobodyfont, setuplayout}
%D
%D At \PRAGMA\ we prefer using the Lucida Bright fonts, but 
%D one can of course load another typeface. 

\setupbodyfont
  [lbr,14.4pt]

\setuplayout
  [style={\switchtobodyfont[12pt]}]

%D \macros
%D   {setuppapersize, setuplayout}
%D
%D The papersize suits the screen dimensions. The layout is 
%D rather simple. We use the whole width of the screen and only
%D have navigational tools at the bottom of the screen.

\setuppapersize
  [S6][S6]

\setuplayout
  [backspace=1cm,
   topspace=1cm,
   margin=0pt,
   header=0pt,
   footer=0pt,
   bottomdistance=.875cm,
   bottom=1cm,
   width=fit,
   height=fit]

%D \macros
%D   {setupwhitespace, setuptyping}
%D
%D We don't have much height, so we use a more cramped 
%D spacing. Verbatim text looks better when indented. 
%D

\setupwhitespace
  [medium]

\setuptyping
  [margin=standard]

%D \macros
%D   {definecolor, setupcolors}
%D
%D Of course we enable color. We define some logical colors,
%D of which most default to the same green shade. 

\definecolor [Backgrounds] [r= 0, g=.7, b=.4]
\definecolor [Actions]     [Backgrounds]
\definecolor [Lines]       [Actions]
\definecolor [Page]        [r=.8, g=.8, b=.8]

%\definecolor [Actions] [r=  1, g=.9, b=.5]
%\definecolor [Actions] [r= .1, g=.5, b=.9]
%\definecolor [Actions] [r=  1, g=.3, b=.1]

\setupcolors
  [state=start]

%D \macros
%D   {setupinteraction, setupinteractionscreen}
%D   
%D We still have to enable interaction mode. We go full 
%D screen!

\setupinteraction
  [state=start,
   color=Actions]

\setupinteractionscreen
  [option=max,
   width=fit,
   height=fit]

%D \macros
%D   {setupitemize}
%D
%D And why not bring some color in itemizations too?

\setupitemize
  [color=Backgrounds] 

%D \macros
%D   {defineoverlay, setupbackgrounds}
%D 
%D The navigational elements and the backgrounds are 
%D provided by \METAPOST. The next few macros are meant for the
%D more experienced \CONTEXT\ user. When, as demonstrated 
%D here, we make the dimensions part of the name, we can be 
%D sure that new ones are generated when we change the page 
%D size in between. 
%D 
%D When \METAPOST\ is used, it makes sense to generate the
%D graphics at runtime. This is supported when one enables
%D system calls in the local \type {texmf.cnf} file and add the
%D switch \type {\runMPgraphicstrue} to the local file \type
%D {cont-sys.tex}. When direct processing is disabled or not 
%D supported, \TEXEXEC\ will tke care of graphic generation. 

\def\MPpagebackground#1#2#3%
  {\startreusableMPgraphic{pb:#1#2#3}
     delta := #3 ;
     fill unitsquare
       xscaled #1 yscaled #2
       withcolor \MPcolor{Page};
     draw unitsquare
       xscaled (#1-2delta) yscaled (#2-2delta)
       shifted (delta,delta)
       withpen pencircle scaled .5delta
       withcolor \MPcolor{Backgrounds} ; 
   \stopreusableMPgraphic
   \reuseMPgraphic{pb:#1#2#3}}

\defineoverlay
  [PageBackground]
  [\MPpagebackground{\overlaywidth}{\overlayheight}{.25cm}]

\setupbackgrounds
  [page]
  [background=PageBackground]

%D \macros
%D   {setuptexttexts}
%D
%D By clicking on the text area, one goes to the next page. 
%D We could also have use the overlay mechanism, but this 
%D takes more settings and requires to generate the backgounds 
%D each page. 
%D 
%D \starttypen 
%D \defineoverlay[BackgroundButton][\BackgroundButton]
%D \setupbackgrounds[text][text][background=BackgroundButton]
%D \setupbackgrounds[state=repeat]
%D \stoptypen
%D
%D We go for the fast one. 

\def\MPtextbackground#1#2#3%
  {\startreusableMPgraphic{tx:#1#2#3}
     delta := #3 ;
     draw unitsquare
       xscaled #1 yscaled #2
       withpen pencircle scaled .5delta
       withcolor \MPcolor{Backgrounds} ; 
   \stopreusableMPgraphic
   \reuseMPgraphic{tx:#1#2#3}}

\defineoverlay
  [TextBackground]
  [\MPtextbackground{\overlaywidth}{\overlayheight}{.125cm}]

\def\BackgroundButton%
  {\button
     [background=TextBackground,
      backgroundoffset=.25cm,
      frame=off,
      height=\vsize,
      width=\hsize]{}[nextpage]}

\setuptexttexts
  [\BackgroundButton]
  []

%D \macros
%D   {setupbottomtexts}
%D
%D At the bottom of the screen, we show three buttons. These
%D direct us to the previous or next jump or exit the document.

% much too complicated, can be done in a few lines nowadays

\def\MPright#1#2%
  {\startreusableMPgraphic{rt:#1#2}
     z1 = ( 0,    0) ;
     z2 = (#1, .5y3) ;
     z3 = ( 0,   #2) ;
     path p ; p := z1--z2--z3--cycle;
     lw := #2/5 ; pickup pencircle scaled lw;
     filldraw p withcolor \MPcolor{Backgrounds} ;
     set_outer_boundingbox currentpicture;
   \stopreusableMPgraphic
   \reuseMPgraphic{rt:#1#2}}

\def\MPleft#1#2%
  {\startreusableMPgraphic{lt:#1#2}
     z1 = (#1,    0) ;
     z2 = ( 0, .5y3) ;
     z3 = (#1,   #2) ;
     path p ; p := z1--z2--z3--cycle;
     lw := #2/5 ; pickup pencircle scaled lw;
     filldraw p withcolor \MPcolor{Backgrounds} ;
     set_outer_boundingbox currentpicture;
   \stopreusableMPgraphic
   \reuseMPgraphic{lt:#1#2}}

\def\MPcircle#1#2%
  {\startreusableMPgraphic{ci:#1#2}
     rx := #1; ry := #2; 
     path p ; p := fullcircle xscaled rx yscaled ry;
     lw := #2/5 ; pickup pencircle scaled lw;
     filldraw p withcolor \MPcolor{Backgrounds} ;
     set_outer_boundingbox currentpicture;
   \stopreusableMPgraphic
   \reuseMPgraphic{ci:#1#2}}

\def\MPwhat#1#2%
  {\startreusableMPgraphic{wh:#1#2} % could be rotated unitsquare
     z1 = (   0,  0) ;
     z2 = (  #1,  0) ;
     z3 = (.5x2, #2) ;
     path p ; p := z1--z2--z3--cycle;
     lw := #2/5 ; pickup pencircle scaled lw;
     filldraw p withcolor \MPcolor{Backgrounds} ;
     set_outer_boundingbox currentpicture;
   \stopreusableMPgraphic
   \reuseMPgraphic{wh:#1#2}}

\unexpanded\def\BackwardButton%
  {\gotobox{\MPleft{\the\bottomheight}{\the\bottomheight}}[previouspage]}

\unexpanded\def\ForwardButton%
  {\gotobox{\MPright{\the\bottomheight}{\the\bottomheight}}[nextpage]}

\unexpanded\def\ExitButton%
  {\gotobox{\MPcircle{\the\bottomheight}{\the\bottomheight}}[CloseDocument]}

\unexpanded\def\WhateverButton%
  {\doifreferencefoundelse{Whatever}
     {\gotobox{\MPwhat{\the\bottomheight}{\the\bottomheight}}[Whatever]}
     {}}

\def\BottomButton%
  {\button
     [frame=off,
      height=\bottomheight,
      width=.3\textwidth]{}[Topics]}

\setupbottomtexts
  [\BottomButton
   \hfill
   \WhateverButton
   \kern2\bottomheight
   \BackwardButton
   \kern.5\bottomheight
   \ExitButton 
   \kern.5\bottomheight
   \ForwardButton
   \kern.5\bottomheight]
  [] % redundant

% an alternative way: 
%
% \setupinteractionmenu[bottom][state=start]
%
% \setupinteraction[menu=on]
%
% \startinteractionmenu[bottom]
%   \button[frame=off,height=\bottomheight,width=.3\textwidth]{}[Topics]
%   \hfill
%   \doifreferencefoundelse{Whatever}
%     {\gotobox{\MPwhat{\the\bottomheight}{\the\bottomheight}}[Whatever]}{}%
%   \kern2\bottomheight
%   \gotobox{\MPleft{\the\bottomheight}{\the\bottomheight}}[previouspage]%
%   \kern.5\bottomheight
%   \gotobox{\MPcircle{\the\bottomheight}{\the\bottomheight}}[CloseDocument]%
%   \kern.5\bottomheight
%   \gotobox{\MPright{\the\bottomheight}{\the\bottomheight}}[nextpage]%
%   \kern.5\bottomheight
% \stopinteractionmenu

%D \macros
%D   {TitlePage, Topics, Topic, Subject}
%D
%D A presentation after loading this module looks like:
%D
%D \starttypen
%D \TitlePage {About Whatever\\Topics}
%D
%D \Topics {Todays Talk}
%D
%D \Topic {Some topic}
%D
%D .....
%D
%D \Topic {Next Topic}
%D
%D .....
%D \stoptypen

%D \macros
%D  {StartTitlePage, TitlePage}
%D
%D The titlepage is rather simple and can be typeset in two 
%D ways: 
%D
%D \starttypen
%D \StartTitlePage
%D text \\ text \\ text 
%D \StopTitlepage
%D \stoptypen
%D
%D or as one||liner:
%D
%D \starttypen
%D \TitlePage{text\\text\\text} 
%D \stoptypen
%D 
%D The first alternative can be used for more complicated 
%D title pages.  

\def\StartTitlePage%
  {\startstandardmakeup
   \bfd\setupinterlinespace
   \setupalign[middle]
   \vfil
   \let\\=\vfil}

\def\StopTitlePage%
  {\vfil\vfil\vfil
   \stopstandardmakeup}

\def\TitlePage#1%
  {\StartTitlePage#1\StopTitlePage}

%D \macros
%D   {definehead}
%D
%D The commands \type{\Topic} and \type{\Subject} are defined
%D as copies of head. We use \type{\Nopic} for internal 
%D purposes. 

\definehead [Topic]   [chapter]
\definehead [Subject] [section]

\definehead [Nopic]   [title]

%D \macros
%D   {setuphead}
%D
%D We use our own command for typesetting the titles. We hide
%D sectionnumbers from viewing. Each topic is followed by a
%D list of subjects that belong to the topic.

\setuphead
  [Topic, Nopic]
  [after={\blank[3*medium]},
   number=no,
   style=\tfb,
   page=yes,
   alternative=middle]

\setuphead
  [Subject]
  [after=\blank,
   number=no,
   page=yes,
   continue=no,
   style=\tfa]

%D The next piece of code is new. 

%D \macros
%D   {setuplist}
%D
%D When found, the subject list is automatically placed 
%D after the topic head. 

\setuplist
  [Topic,Subject]
  [alternative=g,
   interaction=all,
   before=,
   after=]

\def\Topics#1% 
  {\determinelistcharacteristics[Topic]
   \ifcase\utilitylistlength\else
     \Nopic[Topics]{#1}
     \startcolumns
     \placelist[Topic][criterium=all]
     \stopcolumns
   \fi}

\def\Subjects% 
  {\determinelistcharacteristics[Subject][criterium=Topic]
   \ifcase\utilitylistlength\else
     \placelist[Subject][criterium=Topic]
   \fi}

\setuphead
  [Topic]
  [after={\blank[3*medium]\Subjects}]

\endinput