summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/x-res-01.tex
blob: 82c1116dec53b40c59d9979b27de26e541d8fb2a (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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
%D \module
%D   [      file=x-fig-01,
%D        version=2001.03.21,
%D          title=\CONTEXT\ Style File,
%D       subtitle=Figure Base Generation,
%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 See \type {x-fig-00.tex} and \type {x-fig-04.tex} for more
%D information on how to use and generate figure databases.
%D This file loads the file named \type {\jobfilename}
%D (\TEXEXEC\ will set this variable). You can apply this
%D style to a database by saying:
%D
%D \starttyping
%D texexec --pdf --use=fig-make yourfile.xml
%D \stoptyping
%D
%D The following modes are supported:
%D
%D \starttabulate[|lT|l|]
%D \NC letter  \NC map the preview on letter size  \NC \NR
%D \NC compact \NC use an alternative presentation \NC \NR
%D \stoptabulate
%D
%D The resulting file has the following characteristics:
%D
%D \startitemize[packed]
%D \item  the document is split into three sections: first each
%D       figure is shown at its own page, then an overview of
%D       figures is shown with some data alongside, and
%D       finally an index and table of contents shows up
%D \item  there is no title page, which means that one can
%D       access a figure by page number without offset
%D \item  the document is opened at the first overview page,
%D       that is, when the viewer supports it
%D \item  the graphic is shown 3~times: on a page of its own,
%D       scaled to a fixed dimension, and relative to a4 or
%D       letter paper size
%D \item  the labels can be accessed in an index and list at
%D       the end of the document
%D \stopitemize
%D
%D We use named destinations, which means that one can
%D access a figure by name from an external application.

\usemodule[res-00]

\autoXMLnamespace[rl]

\setupoutput[pdftex] \overcomePDFspacefalse

\setjobfullname {xml} % default suffix

\doifnothing  {\jobfullname}    {\end}
\doiffileelse {\jobfullname} {} {\end}

\def\StartDescription
  {\bgroup}

\def\StopDescription
  {\subject {Figure collection}
   \starttabulate[|lBe|p|]
   \doifXMLdataelse{rl:organization}
     {\NC organization \NC \XMLflush{rl:organization} \NC \NR}{}
   \doifXMLdataelse{rl:project}
     {\NC project      \NC \XMLflush{rl:project}      \NC \NR}{}
   \doifXMLdataelse{rl:product}
     {\NC product      \NC \XMLflush{rl:product}      \NC \NR}{}
   \doifXMLdataelse{rl:comment}
     {\NC comment      \NC \XMLflush{rl:comment}      \NC \NR}{}
   \stoptabulate
   \blank[2*big]
   \egroup}

\def\StartFigureA
  {\bgroup
   \XMLassign{rl:file}{unknown}}

\defineoverlay[page][\overlaybutton{Description}]

\startbuffer[unknown]
  \framed
    [width=\XMLpar{rl:dummy}{width}{12cm},
     height=\XMLpar{rl:dummy}{height}{8cm},
     background=color,
     backgroundcolor=gray,
     foregroundcolor=darkred,
     align={lohi,middle}, % normal,
     frame=off]
    {\bf \XMLflush{rl:dummy}}
\stopbuffer

\useexternalfigure[unknown][unknown][type=buffer,object=no]

% \def\externalfigurereplacement#1#2#3%
%   {\getbuffer[rl-unknown]}

\def\StopFigureA
  {\doglobal\increment\CurrentPage
   \setupbackgrounds[page][background=page]
   \doifelsenothing{\XMLflush{rl:label}}
     {\expanded{\definereference[Description][about: \XMLflush{rl:file}]}%
      \expanded{\pagereference[\XMLflush{rl:file}]}}
     {\expanded{\definereference[Description][about: \XMLflush{rl:label}]}%
      \expanded{\pagereference[\XMLflush{rl:label}]}}
   \pagefigure[\XMLflush{rl:file}]
   \setupbackgrounds[page][background=]
   \egroup}

\def\StartFigureB
  {\StartFigureA}

\defineregister
  [figureindex]
  [figureindices]

\setupregister
  [figureindex]
  [ownnumber=yes,
   criterium=text,
   interaction=text,
   indicator=no]

\definelist
  [figurelist]

\setuplist
  [figurelist]
  [criterium=text,
   pagenumber=no,
   width=2em,
   interaction=all]

\setupcolors
  [state=start]

\setuptolerance
  [verytolerant]

% Ulgy:

\startmode[letter] % downward compatible
  \enablemode[previewpage-letter]
\stopmode

\startnotmode[previewpage-letter,previewpage-S6]
  \enablemode[previewpage-A4]
\stopnotmode

%startbuffer[paper]
\startsetups[paper]
\startmode[previewpage-A4]
  \framed
    [width=210mm,height=297mm,offset=overlay,frame=off,
     background=color,backgroundcolor=white]
    {\externalfigure[\XMLflush{rl:file}][reset=yes]}
\stopmode
\startmode[previewpage-letter]
  \framed
    [width=8.5in,height=11in,offset=overlay,frame=off,
     background=color,backgroundcolor=white]
    {\externalfigure[\XMLflush{rl:file}][reset=yes]}
\stopmode
\startmode[previewpage-S6]
  \framed
    [width=600pt,height=450pt,offset=overlay,frame=off,
     background=color,backgroundcolor=white]
    {\externalfigure[\XMLflush{rl:file}][reset=yes]}
\stopmode
\stopsetups
%stopbuffer

\setupbuttons
  [offset=10pt,
   width=broad,
   strut=no,
   rulethickness=1pt,
   framecolor=darkred]

\definecolor[XMLRLcolor][white]

\def\StopFigureB
  {\doglobal\increment\CurrentPage
   \doifelsenothing{\XMLflush{rl:label}}
     {\expanded{\definereference[Figure][\XMLflush{rl:file}]}%
      \expanded{\definereference[GridPg][grid:\XMLflush{rl:file}]}}
     {\expanded{\definereference[Figure][\XMLflush{rl:label}]}%
      \expanded{\definereference[GridPg][grid:\XMLflush{rl:label}]}}%
   \button
     {\hbox to \hsize
        {\forgetall \dontcomplain
         \doifelsenothing{\XMLflush{rl:label}}
           {\expanded{\pagereference[about: \XMLflush{rl:file}]}}
           {\expanded{\pagereference[about: \XMLflush{rl:label}]}}%
         % moved here, because descriptions may be absent
         \ifnum\CurrentPage=1 \pagereference[begin]\fi
         %
         \expanded{\writetolist[figurelist]{\CurrentPage}{\XMLflush{rl:label}}}%
         \expanded{\figureindex{\CurrentPage}{\XMLflush{rl:label}}}%
         \startnotmode[compact]%
           \vbox to 100pt
             {\hsize30pt
              \vskip5pt
              \hbox to \hsize{\hss\strut\bf\CurrentPage\hss}%
              \vfill}%
           \advance\hsize by -30pt
         \stopnotmode
         \startmode[compact]%
           \advance\hsize by -10pt
           \hskip10pt
         \stopmode
         \button % \framed
           [width=150pt,height=100pt,offset=10pt,frame=off,
            background=color,backgroundcolor=white,color=]
           {\externalfigure
              [\XMLflush{rl:file}]
              [maxheight=80pt,frame=off,maxwidth=130pt,factor=max]}%
           [GridPg]%
         \freezedimenmacro\naturalfigurewidth \let\FigWid\naturalfigurewidth
         \freezedimenmacro\naturalfigureheight\let\FigHei\naturalfigureheight
         \advance\hsize by -150pt
         \hskip10pt
         \advance\hsize by -10pt
         \vbox to 100pt
           {\hsize40pt
           %\externalfigure
           %  [paper]
           %  [type=buffer,frame=on,
           %   framecolor=darkred,rulethickness=.5pt,
           %   width=40pt,object=no]
            \framed
              [offset=overlay,
               framecolor=darkred,
               rulethickness=.5pt]
              {\scale[width=40pt]{\setups[paper]}}% {\disableXML\getbuffer[paper]}}%
            \startmode[compact]%
              \vfill
              \hbox to \hsize{\hss\strut\bf\CurrentPage\hss}%
            \stopmode
            \vfill}%
         \advance\hsize by -40pt
         \hskip10pt
         \advance\hsize by -10pt
         \vbox to 100pt
           {\blank[disable]
            \starttabulate[|Bel|p|]
            \NC file \NC \XMLflush{rl:file} \NC \NR
            \doifXMLdata{rl:label}
              {\NC label \NC \XMLflush{rl:label} \NC \NR}
            \NC w$\times$h \NC \FigWid$\times$\FigHei \NC \NR
            \doifXMLdata{rl:copyright}
              {\NC copyright \NC \XMLflush{rl:copyright} \NC \NR}
            \doifXMLdata{rl:status}
              {\doif{\XMLflush{rl:status}}{obsolete}
                 {\NC status \NC \bf\darkred\XMLflush{rl:status} \NC \NR}
                 {\NC status \NC \XMLflush{rl:status} \NC \NR}}
            \doifXMLdata{rl:comment}
              {\NC comment \NC \XMLflush{rl:comment} \NC \NR}
            \stoptabulate
            \vfill}}}%
     [Figure]
  \vskip10pt
  \egroup}

\def\StartFigureC
  {\StartFigureA}

\def\StopFigureC
  {\doglobal\increment\NumberOfFigures
   \egroup}

\setuplayout
  [topspace=15pt,backspace=15pt,
   header=0pt,footer=0pt,bottom=20pt,bottomdistance=10pt,
   width=middle,height=fit]

\setupbackgrounds
  [page]
  [background=,
   backgroundcolor=gray]

\setupinteractionscreen
  [width=max,
   height=max]

\setupcolors
  [state=start]

\setupinteraction
  [style=,
   color=,
   contrastcolor=,
   state=start]

\setuphead
  [section]
  [style=bfb]

% \setupbodyfont
%   [pos]

\setupinteractionmenu
  [bottom]
  [left=\hfill,
   middle=\hskip10pt,
   frame=off,
   style=bold,
   background=color,
   backgroundcolor=darkred,
   foregroundcolor=white]

\startinteractionmenu[bottom]
  \but [begin]         begin   \\
  \but [index]         index   \\
  \but [list]          list    \\
  \but [CloseDocument] close   \\
  \but [PreviousJump]  go back \\
\stopinteractionmenu

\setupinteraction
  [openaction=begin]

\defineXMLenvironment [rl:figurelibrary] \StartLibrary \StopLibrary
\defineXMLenvironment [rl:library]       \StartLibrary \StopLibrary

\starttext

\def\StartLibrary{\mainlanguage[\XMLpar{rl:library}{language}{en}]}
\def\StopLibrary {}

\defineXMLignore      [rl:description]
\defineXMLenvironment [rl:figure]      \StartFigureC \StopFigureC

\doglobal\newcounter\CurrentPage

\processXMLfilegrouped{\jobfullname}

\increment\NumberOfFigures

\defineXMLignore      [rl:description]
\defineXMLenvironment [rl:figure]      \StartFigureA \StopFigureA

\doglobal\newcounter\CurrentPage

\processXMLfilegrouped{\jobfullname}

\setuppapersize
  [S6][S6]

\setupbackgrounds
  [page]
  [background=color]

\setupinteraction
  [menu=on]

\defineXMLenvironment [rl:description] \StartDescription \StopDescription
\defineXMLenvironment [rl:figure]      \StartFigureB     \StopFigureB

\doglobal\newcounter\CurrentPage

\processXMLfilegrouped{\jobfullname} \page

\subject [list] {List of figures}

\placelist[figurelist] \page

\subject [index] {Index of figures}

\startcolumns
\placeregister[figureindex]
\stopcolumns

\doifmodeelse{clipgrid-distance,clipgrid-steps}{\page}{\stoptext}

\startuniqueMPgraphic{clipgrid}{dx,dy,nx,ny,type}
  numeric gdx, gdy, lbx, lby ;
  if \MPvar{type}=1 :
    gdx := \MPvar{dy} ;
    gdy := \MPvar{dx} ;
  else :
    gdx := OverlayWidth /\MPvar{nx} ;
    gdy := OverlayHeight/\MPvar{ny} ;
  fi ;
  lbx := gdx ;
  lby := gdy ;
  defaultfont  := "\truefontname{Mono}" ;
  defaultscale := .5 ;
  numeric pen ; pen := .25pt ;
  def MyGrid text t =
    draw vlingrid (0,OverlayWidth ,gdy,OverlayWidth ,OverlayHeight) t ;
    draw hlingrid (0,OverlayHeight,gdx,OverlayHeight,OverlayWidth ) t ;
  enddef ;
  pickup pencircle scaled pen ;
  MyGrid withcolor white ;
  MyGrid dashed evenly scaled pen ;
  draw OverlayBox withcolor white ;
  draw OverlayBox dashed evenly scaled pen ;
  draw vlinlabel.bot(0,eps+OverlayWidth /lby,2,OverlayWidth ) ;
  draw hlinlabel.lft(0,eps+OverlayHeight/lbx,2,OverlayHeight) ;
  setbounds currentpicture to OverlayBox enlarged (2*EmWidth) ;
\stopuniqueMPgraphic

\presetMPvariable[clipgrid][dx=10pt]
\presetMPvariable[clipgrid][dy=10pt]
\presetMPvariable[clipgrid][nx=10]
\presetMPvariable[clipgrid][ny=10]

\startmode[clipgrid-distance]
  \defineoverlay[grid][\uniqueMPgraphic{clipgrid}{type=1}]
\stopmode

\startmode[clipgrid-steps]
  \defineoverlay[grid][\uniqueMPgraphic{clipgrid}{type=2}]
\stopmode

\setupexternalfigures
  [background={color,foreground,grid},
   backgroundcolor=white]

\def\StartFigureD
  {\StartFigureA}

\def\StopFigureD
  {\doglobal\increment\CurrentPage
   \setupbackgrounds[page][background=page]
   \startpagefigure[\XMLflush{rl:file}][offset=20pt]%
     \doifelsenothing{\XMLflush{rl:label}}
       {\expanded{\definereference[Description][about: \XMLflush{rl:file}]}%
        \expanded{\pagereference[grid:\XMLflush{rl:file}]}}
       {\expanded{\definereference[Description][about: \XMLflush{rl:label}]}%
        \expanded{\pagereference[grid:\XMLflush{rl:label}]}}
   \stoppagefigure
  %\pagefigure[\XMLflush{rl:file}][offset=20pt]
   \setupbackgrounds[page][background=]
   \egroup}

\defineXMLignore      [rl:description]
\defineXMLenvironment [rl:figure]      \StartFigureD \StopFigureD

\doglobal\newcounter\CurrentPage

\processXMLfilegrouped{\jobfullname} \page

\stoptext