scrn-wid.mklx /size: 25 Kb    last modification: 2023-12-21 09:44
1%D \module
2%D   [       file=scrn-int,
3%D        version=2011.02.27, % moved from scrn-int
4%D          title=\CONTEXT\ Core Macros,
5%D       subtitle=Widgets,
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 Interaction Macros / Widgets}
15
16\registerctxluafile{scrn-wid}{autosuffix}
17
18% todo: expansion in comments (default is expanded)
19% todo: check renderings ... acrobat crashes too easily on missing one
20
21\unprotect
22
23%D Attachments (mkiv upgraded):
24%D
25%D As usual in \CONTEXT\ we separate the general definition (frontend)
26%D and the rendering (backend).
27
28% hack: x\footnote{x\inleftmargin[scope=local]{\attachment[location=high,file=i-context.pdf]}}x
29
30% old but stil valid method:
31%
32% \useattachment[test.tex]
33% \useattachment[whatever][test.tex]
34% \useattachment[whatever][newname][test.tex]
35% \useattachment[whatever][title][newname][test.tex]
36%
37% new method:
38%
39% \registerattachment[sometag][specification] % name file author title subtitle
40%
41% \attachment[sometag][extra specs]
42% \attachment[test.tex]
43% \attachment[file=test.tex]
44% \attachment[file=test.tex,method=hidden]
45% \attachment[name=newname,file=test.tex]
46% \attachment[title=mytitle,name=newname,file=test.tex]
47%
48% indirect
49%
50% \defineattachment[whatever5][file=test.tex] \attachment[whatever5][method=hidden]
51% \defineattachment[whatever5][file=test.tex,method=hidden] \attachment[whatever5]
52%
53% direct (no definitions)
54%
55% \attachment[test][file=oeps.tex,title=Oeps,author=Hans,subtitle=TeX File,method=hidden]
56% \attachment[label=test,file=oeps.tex,title=Oeps,author=Hans,subtitle=TeX File,method=hidden]
57%
58% autolabel:
59%
60% \attachment[file=oeps.tex,title=Oeps,author=Hans,subtitle=TeX File,method=hidden]
61%
62% % \setupattachments[\c!symbol={symbol-normal,symbol-down}]
63
64% startattachment -> temp file
65
66\newbox\b_scrn_attachment_collect
67\newbox\b_scrn_attachment_link
68\newbox\b_scrn_attachment_symbol
69
70\installcorenamespace{attachment}
71\installcorenamespace{attachmentlocation}
72\installcorenamespace{attachmentmethod}
73
74\installcommandhandler \??attachment {attachment} \??attachment
75
76\aliased\let\setupattachments\setupattachment % convenience and compatibility
77
78\setupattachment
79  [\c!state=\v!start,
80   \c!color=\interactionparameter\c!color,
81  %\c!textlayer=,
82  %\c!symbol=,
83  %\c!title=,
84  %\c!subtitle=,
85  %\c!file=, % input filename
86  %\c!name=, % new filename
87  %\c!author=,
88  %\c!method=, % \v!hidden = not in menu
89  %\c!buffer=
90   \c!symbol=,
91   \c!distance=\emwidth,
92   \c!width=\v!fit,
93   \c!height=\v!fit,
94   \c!depth=\v!fit,
95   \c!location=\v!high]
96
97\mutable\lettonothing\currentattachmentdepth
98\mutable\lettonothing\currentattachmentheight
99\mutable\lettonothing\currentattachmentregistered
100\mutable\lettonothing\currentattachmentsymbol
101\mutable\lettonothing\currentattachmentwidth
102
103\permanent\tolerant\protected\def\registerattachment[#tag]#spacer[#S#settings]% we save (globally) at the lua end
104  {\ifarguments\else
105     \begingroup
106     \cdef\currentattachment{_}%
107     \setupcurrentattachment[#settings,\s!parent=\??attachment]%
108     \clf_registerattachment
109        tag        {#tag}%
110        registered {#tag}%
111        title      {\attachmentparameter\c!title}%
112        subtitle   {\attachmentparameter\c!subtitle}%
113        author     {\attachmentparameter\c!author}%
114        file       {\attachmentparameter\c!file}%
115        name       {\attachmentparameter\c!name}%
116        buffer     {\attachmentparameter\c!buffer}%
117        mimetype   {\attachmentparameter\c!type}%
118     \relax
119     \endgroup
120   \fi}
121
122\appendtoks
123    \frozen\instance\protected\edefcsname        \currentattachment\endcsname{\scrn_attachment_direct[\currentattachment]}%
124    \frozen\instance\protected\edefcsname\e!start\currentattachment\endcsname{\scrn_attachment_start [\currentattachment]}%
125    \frozen\instance\protected\edefcsname\e!stop \currentattachment\endcsname{\scrn_attachment_stop                      }%
126\to \everydefineattachment
127
128\permanent\tolerant\protected\def\scrn_attachment_direct[#tag]#spacer[#registered]#spacer[#S#settings]%
129  {\iflocation
130     \bgroup
131     \cdef\currentattachment{#tag}%
132     \ifcstok{\attachmentparameter\c!state}\v!start
133       \ifempty{#registered}%
134         \scrn_attachment_inject[\v!auto][]%
135       \orelse\ifhastok={#registered}%
136          \scrn_attachment_inject[\v!auto][#registered]%
137       \else
138          \scrn_attachment_inject[#registered][#settings]%
139       \fi
140     \fi
141     \egroup
142   \fi}
143
144\tolerant\protected\def\scrn_attachment_start[#tag]#spacer[#registered]#spacer[#S#settings]%
145  {\cdef\currentattachment{#tag}%
146   \unless\iflocation
147     \expandafter\scrn_attachment_start_ignore
148   \orelse\ifcstok{\attachmentparameter\c!state}\v!start
149     \expandafter\scrn_attachment_start_indeed
150   \else
151     \expandafter\scrn_attachment_start_ignore
152   \fi[#registered][#settings]}
153
154\protected\def\scrn_attachment_stop
155  {}
156
157\def\scrn_attachment_start_indeed[#registered][#S#settings]%
158  {\bgroup
159   \ifempty{#registered}%
160     \def\scrn_attachment_stop{\scrn_attachment_inject[\v!auto][\c!buffer=\v!attachment]\egroup}%
161   \else
162     \doifelseassignment{#registered}
163       {\def\scrn_attachment_stop{\scrn_attachment_inject[\v!auto][\c!buffer=\v!attachment,#registered]\egroup}}%
164       {\def\scrn_attachment_stop{\scrn_attachment_inject[#registered][\c!buffer=\v!attachment,#settings]\egroup}}%
165   \fi
166   \grabbufferdatadirect\v!attachment{\e!start\currentattachment}{\e!stop\currentattachment}}
167
168\def\scrn_attachment_start_ignore
169  {\expandafter\ignoreupto\csname\e!stop\currentattachment\endcsname}
170
171\def\scrn_attachment_inject[#registered][#S#settings]%
172  {\edef\currentattachmentregistered{#registered}%
173   \setupattachment[\currentattachment][#settings]%
174   \expandnamespaceparameter\??attachmentmethod\attachmentparameter\c!method\v!normal}
175
176\defcsname\??attachmentmethod\v!normal\endcsname
177  {\edef\currentattachmentsymbol{\attachmentparameter\c!symbol}%
178   \edef\currentattachmentwidth {\attachmentparameter\c!width }%
179   \edef\currentattachmentheight{\attachmentparameter\c!height}%
180   \edef\currentattachmentdepth {\attachmentparameter\c!depth }%
181   \ifempty\currentattachmentsymbol
182     \ifx\currentattachmentwidth \v!fit\edef\currentattachmentwidth {.5\emwidth}\fi
183     \ifx\currentattachmentheight\v!fit\edef\currentattachmentheight{.5\emwidth}\fi
184     \ifx\currentattachmentdepth \v!fit\let \currentattachmentdepth \zeropoint\fi
185   \else
186     \clf_presetsymbollist{\attachmentparameter\c!symbol}%
187     % we cannot yet ask for the wd/ht/dp of an xform else we could use those
188     \setbox\b_scrn_attachment_symbol\hbox{\symbol[\lastpredefinedsymbol]}%
189     \ifx\currentattachmentwidth \v!fit\edef\currentattachmentwidth {\wd\b_scrn_attachment_symbol}\fi
190     \ifx\currentattachmentheight\v!fit\edef\currentattachmentheight{\ht\b_scrn_attachment_symbol}\fi
191     \ifx\currentattachmentdepth \v!fit\edef\currentattachmentdepth {\dp\b_scrn_attachment_symbol}\fi
192   \fi
193   \clf_insertattachment
194     tag               {\currentattachment}%
195     registered        {\currentattachmentregistered}%
196     width             \dimexpr\currentattachmentwidth \relax
197     height            \dimexpr\currentattachmentheight\relax
198     depth             \dimexpr\currentattachmentdepth \relax
199     color             {\attachmentparameter\c!color}%
200     colormodel        \c_attr_colormodel
201     colorvalue        \rawcolorattribute{\attachmentparameter\c!color}%
202     transparencyvalue \rawtransparencyattribute{\attachmentparameter\c!color}%
203     symbol            {\currentattachmentsymbol}%
204     layer             {\attachmentparameter\c!textlayer}%
205     % these will be overloaded by registered when available
206     title             {\attachmentparameter\c!title}%
207     subtitle          {\attachmentparameter\c!subtitle}%
208     author            {\attachmentparameter\c!author}%
209     file              {\attachmentparameter\c!file}%
210     name              {\attachmentparameter\c!name}%
211     buffer            {\attachmentparameter\c!buffer}%
212     mimetype          {\attachmentparameter\c!type}%
213   \relax
214   \wd\b_scrn_attachment_link\currentattachmentwidth
215   \ht\b_scrn_attachment_link\currentattachmentheight
216   \dp\b_scrn_attachment_link\currentattachmentdepth
217   \expandnamespaceparameter\??attachmentlocation\attachmentparameter\c!location\s!unknown}
218
219\defcsname\??attachmentmethod\v!hidden\endcsname
220  {\clf_insertattachment
221     tag        {\currentattachment}%
222     registered {\currentattachmentregistered}%
223     method     {\v!hidden}%
224     title      {\attachmentparameter\c!title}%
225     subtitle   {\attachmentparameter\c!subtitle}%
226     author     {\attachmentparameter\c!author}%
227     file       {\attachmentparameter\c!file}%
228     name       {\attachmentparameter\c!name}%
229     buffer     {\attachmentparameter\c!buffer}%
230     mimetype   {\attachmentparameter\c!type}%
231   \relax}
232
233\protected\def\scrn_attachment_flush_traced
234  {\hpack\bgroup
235     \blackrule % can be a fast one
236       [ \c!color=trace:r,
237         \c!width=\wd\b_scrn_attachment_link,
238        \c!height=\ht\b_scrn_attachment_link,
239         \c!depth=\dp\b_scrn_attachment_link]%
240     \kern-\wd\b_scrn_attachment_link
241     \box\b_scrn_attachment_link
242   \egroup}
243
244\protected\def\scrn_attachment_flush_normal
245  {\box\b_scrn_attachment_link}
246
247\installtextracker
248  {attachments.anchors}
249  {\let\scrn_attachment_flush\scrn_attachment_flush_traced}
250  {\let\scrn_attachment_flush\scrn_attachment_flush_normal}
251
252\let\scrn_attachment_flush\scrn_attachment_flush_normal
253
254\defcsname\??attachmentlocation\v!inmargin   \endcsname{\inmargin     {\scrn_attachment_flush}}
255\defcsname\??attachmentlocation\v!leftedge   \endcsname{\inleftedge   {\scrn_attachment_flush}}
256\defcsname\??attachmentlocation\v!rightedge  \endcsname{\inrightedge  {\scrn_attachment_flush}}
257\defcsname\??attachmentlocation\v!leftmargin \endcsname{\inleftmargin {\scrn_attachment_flush}}
258\defcsname\??attachmentlocation\v!rightmargin\endcsname{\inrightmargin{\scrn_attachment_flush}}
259\defcsname\??attachmentlocation\v!high       \endcsname{\high         {\scrn_attachment_flush}}
260
261\defcsname\??attachmentlocation\v!none\endcsname
262  {\global\setbox\b_scrn_attachment_collect\hbox\bgroup
263     \ifvoid\b_scrn_attachment_collect\else
264       \box\b_scrn_attachment_collect
265       \hskip\attachmentparameter\c!distance\relax
266     \fi
267     \scrn_attachment_flush
268   \egroup}
269
270\defcsname\??attachmentlocation\s!unknown\endcsname
271  {\ifvoid\b_scrn_attachment_collect\else
272     \box\b_scrn_attachment_collect
273   \fi}
274
275\permanent\protected\def\placeattachments
276  {\ifvoid\b_scrn_attachment_collect\else
277     \box\b_scrn_attachment_collect
278   \fi}
279
280\defineattachment[attachment]
281
282% \ifx\currentinterface\defaultinterface \else
283%     \defineattachment[\v!attachment]
284% \fi
285
286% backward compatible:
287
288\permanent\tolerant\protected\def\useattachment[#tag]#spacer[#title]#spacer[#name]#spacer[#file]%
289  {\ifarguments\or
290     \registerattachment[#tag][title=#tag,name=#tag,file=#tag]%
291   \or
292     \registerattachment[#tag][title=#title,name=#title,file=#title]%
293   \or
294     \registerattachment[#tag][title=#title,name=#title,file=#name]%
295   \or
296     \registerattachment[#tag][title=#title,name=#name,file=#file]%
297   \fi}
298
299%D Comments:
300
301% test
302%
303% \startcomment
304%   hello beautiful\\world
305% \stopcomment
306%
307% test
308%
309% \startcomment[hello]
310%   hello << eerste >>
311%   beautiful
312%   world
313% \stopcomment
314%
315% test
316%
317% \startcomment[hello][color=green,width=10cm,height=3cm]
318%   hello
319%   beautiful
320%   world
321% \stopcomment
322%
323% test
324%
325% \startcomment[hello][color=red,width=4cm,height=3cm]
326%   hello
327%
328%   beautiful
329%
330%   world
331% \stopcomment
332%
333% test
334%
335% \startcomment[symbol=Help]
336%   Do we want this kind of rubish?
337% \stopcomment
338%
339% test
340%
341% \definesymbol [comment-normal][{\externalfigure[cow.pdf]}]
342% \definesymbol [comment-down]  [{\externalfigure[cow.pdf]}]
343%
344% \def\CowSymbol#1#2%
345%  {\scale
346%     [\c!height=#1]
347%     {\startMPcode
348%        loadfigure "koe.mp" number 1 ;
349%        refill currentpicture withcolor #2 ;
350%      \stopMPcode}}
351%
352% \definesymbol [comment-normal]
353%   [\CowSymbol{4ex}{red}]
354%
355% \definesymbol [comment-down]
356%   [\CowSymbol{4ex}{green}]
357%
358% \setupcomment
359%   [\c!symbol={comment-normal,comment-down},
360%    \c!option=\v!buffer]
361%
362% \startcomment[hello]
363%     oeps
364% \stopcomment
365%
366% test
367%
368% \setupcomment
369%   [\c!symbol=normal,
370%    \c!option=max,width=10cm]
371%
372% \startcomment[hello]
373%     oeps
374% \stopcomment
375%
376% test
377
378%D The implementation is mostly the same as for attachments but sharing code
379%D will not make it cleaner.
380
381\installcorenamespace{comment}
382\installcorenamespace{commentlocation}
383
384\installcommandhandler \??comment {comment} \??comment
385
386\newbox\b_scrn_comment_collect
387\newbox\b_scrn_comment_rendering
388\newbox\b_scrn_comment_link
389\newbox\b_scrn_comment_symbol
390
391\setupcomment
392  [\c!state=\v!start,
393   \c!distance=\emwidth,
394   \c!color=\interactionparameter\c!color,
395   \c!space=\v!no,
396   \c!symbol=,
397  %\c!title=,
398  %\c!option=,
399  %\c!textlayer=,
400   \c!width=\v!fit,
401   \c!height=\v!fit,
402   \c!depth=\v!fit,
403   \c!nx=40,
404   \c!ny=10,
405   \c!buffer=\v!comment,
406   \c!location=\v!high]
407
408\mutable\lettonothing\currentcommentdepth
409\mutable\lettonothing\currentcommentheight
410\mutable\lettonothing\currentcommentsymbol
411\mutable\lettonothing\currentcommentwidth
412
413\appendtoks
414    \frozen\protected\instance\edefcsname        \currentcomment\endcsname{\scrn_comment_argument[\currentcomment]}%
415    \frozen\protected\instance\edefcsname\e!start\currentcomment\endcsname{\scrn_comment_start   [\currentcomment]}%
416    \frozen\protected\instance\edefcsname\e!stop \currentcomment\endcsname{\scrn_comment_stop                     }%
417\to \everydefinecomment
418
419\tolerant\protected\def\scrn_comment_argument[#category]#spacer[#title]#spacer[#S#settings]#:#text%%
420  {\iflocation
421     \cdef\currentcomment{#category}%
422     \ifcstok{\commentparameter\c!state}\v!start
423       \ifhastok={#title}
424         \setupcurrentcomment[#title]%
425       \else
426         \setupcurrentcomment[\c!title=#title,#settings]%
427       \fi
428       \clf_assignbuffer{\v!comment}{#text}\catcodetable\relax% todo: expansion control, but expanded by default (xml)
429       \scrn_comment_inject
430     \fi
431   \fi
432   \ignorespaces}
433
434\tolerant\protected\def\scrn_comment_start[#category]#spacer[#title]#spacer[#S#settings]%
435  {\cdef\currentcomment{#category}%
436   \unless\iflocation
437     \expandafter\scrn_comment_start_ignore
438   \orelse\ifcstok{\commentparameter\c!state}\v!start
439     \expandafter\scrn_comment_start_indeed
440   \else
441     \expandafter\scrn_comment_start_ignore
442   \fi[#title][#settings]}
443
444\def\scrn_comment_start_indeed[#title][#S#settings]%
445  {\bgroup
446   \doifelseassignment{#title}
447     {\setupcurrentcomment[#title]}
448     {\setupcurrentcomment[\c!title=#title,#settings]}%
449   \protected\def\scrn_comment_stop{\scrn_comment_inject\egroup}%
450   \grabbufferdatadirect\v!comment{\e!start\currentcomment}{\e!stop\currentcomment}}
451
452\def\scrn_comment_start_ignore
453  {\expandafter\ignoreupto\csname\e!stop\currentcomment\endcsname}
454
455\protected\def\scrn_comment_stop
456  {}
457
458\installcorenamespace{commentmethods}
459
460\protected\def\scrn_comment_inject
461  {\expandnamespaceparameter\??commentmethods\commentparameter\c!method\v!normal}
462
463%D Beware: comments symbols don't scale in acrobat (cf. spec but somewhat
464%D weird, esp because for instance attachment symbols do scale).
465
466\defcsname\??commentmethods\v!normal\endcsname
467  {\edef\currentcommentsymbol{\commentparameter\c!symbol}%
468   \edef\currentcommentwidth {\commentparameter\c!width }%
469   \edef\currentcommentheight{\commentparameter\c!height}%
470   \edef\currentcommentdepth {\commentparameter\c!depth }%
471   \ifempty\currentcommentsymbol
472     \ifx\currentcommentwidth \v!fit\edef\currentcommentwidth {.5\emwidth}\fi
473     \ifx\currentcommentheight\v!fit\edef\currentcommentheight{.5\emwidth}\fi
474     \ifx\currentcommentdepth \v!fit\let \currentcommentdepth \zeropoint\fi
475   \else
476     \clf_presetsymbollist{\commentparameter\c!symbol}%
477     % we cannot yet ask for the wd/ht/dp of an xform else we could use those
478     \setbox\b_scrn_comment_symbol\hbox{\symbol[\lastpredefinedsymbol]}%
479     \ifx\currentcommentwidth \v!fit\edef\currentcommentwidth {\wd\b_scrn_comment_symbol}\fi
480     \ifx\currentcommentheight\v!fit\edef\currentcommentheight{\ht\b_scrn_comment_symbol}\fi
481     \ifx\currentcommentdepth \v!fit\edef\currentcommentdepth {\dp\b_scrn_comment_symbol}\fi
482   \fi
483   \clf_insertcomment
484     tag               {\currentcomment}%
485     title             {\commentparameter\c!title}%
486     subtitle          {\commentparameter\c!subtitle}%
487     author            {\commentparameter\c!author}%
488     width             \dimexpr\currentcommentwidth\relax
489     height            \dimexpr\currentcommentheight\relax
490     depth             \dimexpr\currentcommentdepth\relax
491     nx                {\commentparameter\c!nx}%
492     ny                {\commentparameter\c!ny}%
493     colormodel        \c_attr_colormodel
494     colorvalue        \rawcolorattribute{\commentparameter\c!color}%
495     transparencyvalue \rawtransparencyattribute{\commentparameter\c!color}%
496     option            {\commentparameter\c!option}% % todo
497     symbol            {\commentparameter\c!symbol}%
498     buffer            {\commentparameter\c!buffer}% {\v!comment}%
499     layer             {\commentparameter\c!textlayer}%
500     space             {\commentparameter\c!space}%
501   \relax
502   \wd\b_scrn_comment_link\currentcommentwidth
503   \ht\b_scrn_comment_link\currentcommentheight
504   \dp\b_scrn_comment_link\currentcommentdepth
505   \expandnamespaceparameter\??commentlocation\commentparameter\c!location\s!unknown}
506
507\aliased\letcsname\??commentmethods\v!hidden\endcsname\donothing
508
509\protected\def\scrn_comment_flush_traced
510  {\hpack\bgroup
511     \blackrule % can be a fast one
512       [ \c!color=trace:y,
513         \c!width=\wd\b_scrn_comment_link,
514        \c!height=\ht\b_scrn_comment_link,
515         \c!depth=\dp\b_scrn_comment_link]%
516     \kern-\wd\b_scrn_comment_link
517     \box\b_scrn_comment_link
518   \egroup}
519
520\protected\def\scrn_comment_flush_normal
521  {\box\b_scrn_comment_link}
522
523\installtextracker
524  {comments.anchors}
525  {\let\scrn_comment_flush\scrn_comment_flush_traced}
526  {\let\scrn_comment_flush\scrn_comment_flush_normal}
527
528\let\scrn_comment_flush\scrn_comment_flush_normal
529
530% todo: dedicated margin classes
531
532\defcsname\??commentlocation\v!inmargin   \endcsname{\inmargin     {\scrn_comment_flush}}
533\defcsname\??commentlocation\v!leftedge   \endcsname{\inleftedge   {\scrn_comment_flush}}
534\defcsname\??commentlocation\v!rightedge  \endcsname{\inrightedge  {\scrn_comment_flush}}
535\defcsname\??commentlocation\v!leftmargin \endcsname{\inleftmargin {\scrn_comment_flush}}
536\defcsname\??commentlocation\v!rightmargin\endcsname{\inrightmargin{\scrn_comment_flush}}
537\defcsname\??commentlocation\v!high       \endcsname{\high         {\scrn_comment_flush}}
538
539\defcsname\??commentlocation\v!none\endcsname
540  {\global\setbox\b_scrn_comment_collect\hbox\bgroup
541     \ifvoid\b_scrn_comment_collect\else
542       \box\b_scrn_comment_collect
543       \hskip\commentparameter\c!distance\relax
544     \fi
545     \scrn_comment_flush
546   \egroup}
547
548\defcsname\??commentlocation\s!unknown\endcsname
549  {\ifvoid\b_scrn_comment_collect\else
550     \box\b_scrn_comment_collect
551   \fi}
552
553\permanent\protected\def\placecomments
554  {\ifvoid\b_scrn_comment_collect\else
555     \box\b_scrn_comment_collect
556   \fi}
557
558\definecomment[comment]
559
560% \ifx\currentinterface\defaultinterface \else
561%     \definecomment[\v!comment]
562% \fi
563
564%D Conform Michals recommendations support for the old movie (and sound) annotations
565%D has been removed. This also means that movies are no longer a valid external figure
566%D format. So be it.
567%D
568%D Renderings (adapted to \MKIV\ by Michal Vlasák). We no longer have the \MKII\ internal
569%D and external rendering because over time all this widget stuff changed in \PDF\ and
570%D Acrobat.
571%D
572%D \starttyping
573%D \setupinteraction[state=start]
574%D
575%D \starttext
576%D     \startTEXpage[offset=10pt]
577%D       % \definerenderingwindow[myrenderingwindow][width=\textwidth, height=\textwidth]
578%D       % \definerenderingwindow[myrenderingwindow][width=\textwidth, height=\textwidth, openpageaction=StartRendering{myvideo}]
579%D         \definerenderingwindow[myrenderingwindow][width=\textwidth, height=\textwidth, openpageaction=StartCurrentRendering, closepageaction=StopCurrentRendering]
580%D       % \userendering[myvideo][video/mp4][edited.mp4][embed=yes, auto]
581%D         \userendering[myvideo][video/mp4][woodwork.mp4][embed=yes, auto]
582%D         % auto = openpageaction=StartCurrentRendering, closepageaction=StopCurrentRendering
583%D         \placerenderingwindow[myrenderingwindow][myvideo]
584%D         \blank
585%D         \goto{start}[StartRendering{myvideo}]
586%D         \goto{stop}[StopRendering{myvideo}]
587%D     \stopTEXpage
588%D \stoptext
589%D \stoptyping
590
591\mutable\lettonothing\currentrendering
592\mutable\lettonothing\currentrenderingwindow
593
594\permanent\tolerant\protected\def\userendering[#tag]#spacer[#mime]#spacer[#file]#spacer[#option]%
595  {\clf_registerrendering
596     label    {#tag}%
597     mime     {#mime}%
598     filename {#file}%
599     option   {#option}%
600   \relax}
601
602\permanent\tolerant\protected\let\useexternalrendering\userendering
603
604\permanent\def\renderingoption#tag{\clf_renderingvar{#tag}{option}}
605
606\newdimension\d_scrn_rendering_width  \d_scrn_rendering_width  8cm
607\newdimension\d_scrn_rendering_height \d_scrn_rendering_height 6cm
608
609\let\m_scrn_rendering_page\!!zerocount
610
611%D \starttyping
612%D \definerenderingwindow[soundplace][width=0pt, height=0pt]
613%D \useexternalrendering[mainsound][audio/mp3][sound.mp3][embed=yes]
614%D \placerenderingwindow[soundplace][mainsound]
615%D \stoptyping
616
617\installcorenamespace{renderingwindow}
618
619\installframedcommandhandler \??renderingwindow {renderingwindow} \??renderingwindow
620
621\appendtoks
622    \resetrenderingwindowparameter\c!openpageaction
623    \resetrenderingwindowparameter\c!closepageaction
624    \setrenderingwindowparameter  \c!width          {\d_scrn_rendering_width }%
625    \setrenderingwindowparameter  \c!height         {\d_scrn_rendering_height}%
626    \letrenderingwindowparameter  \c!align          \v!flushleft
627\to \everypresetrenderingwindow
628
629\permanent\tolerant\protected\def\placerenderingwindow[#window]#spacer[#rendering]% do all in lua
630  {\bgroup
631   \edef\currentrendering{\ifparameter#rendering\or#rendering\else#window\fi}%
632   % create fall back if needed
633   \edef\currentrenderingwindow{\namedrenderingwindowparameter{#window}\c!width}% stupid test, we need a proper one here
634   \ifempty\currentrenderingwindow
635     \let\currentrenderingwindow\s!default
636     \definerenderingwindow[\currentrenderingwindow]% why not global
637   \else
638     \edef\currentrenderingwindow{#window}%
639   \fi
640   \ifx\currentrenderingwindow\s!default
641     \d_scrn_rendering_height\vsize
642     \d_scrn_rendering_width \hsize
643     \let\m_scrn_rendering_page\realpageno
644   \else
645     \d_scrn_rendering_height\renderingwindowparameter\c!height
646     \d_scrn_rendering_width \renderingwindowparameter\c!width
647     \let\m_scrn_rendering_page\realpageno
648   \fi
649   \letrenderingwindowparameter\c!offset\v!overlay
650   \inheritedrenderingwindowframed
651     {\vfilll
652      \dontleavehmode
653      \clf_insertrenderingwindow
654        label     {\currentrendering}%
655        width     \d_scrn_rendering_width
656        height    \d_scrn_rendering_height
657        option    {\renderingoption\currentrendering}%
658        page      \m_scrn_rendering_page
659        openpage  {\renderingwindowparameter\c!openpageaction}%
660        closepage {\renderingwindowparameter\c!closepageaction}%
661      \relax
662      \hfill}%
663   \egroup}
664
665%D Linkedlists (not tested in mkvi):
666
667% %D The next mechanism, linked lists, is quite old and
668% %D is \MKIV'd for completeness. I will finish the
669% %D configuration part when I need it.
670% %D
671% %D \starttyping
672% %D \setupinteraction[state=start]
673% %D \definelinkedlist[demo]
674% %D \dorecurse{10}{\linkedlistelement[demo]{link \recurselevel} \page}
675% %D \stoptyping
676%
677% \definesystemvariable {lk}   % LinK
678%
679% \installcommandhandler\??lk{linkedlist}\??lk
680%
681% \let\setupbutton\setuplinkedlists\setuplinkedlist
682%
683% \appendtoks
684%     \clf_definelinkedlist{\currentlinkedlist}%
685% \to \everydefinelinkedlist
686%
687% \def\setlinkedlistproperties#1#2#3#4#5#6%
688%   {\def\currentlink {#1}%
689%    \def\noflinks    {#2}%
690%    \def\firstlink   {#3}%
691%    \def\previouslink{#4}%
692%    \def\nextlink    {#5}%
693%    \def\lastlink    {#6}}
694%
695% \def\linkedlistelement[#1]#2% currently no view support
696%   {\dontleavehmode\hbox\bgroup
697%    #2%
698%    \iflocation
699%      \edef\currentlinkedlist{#1}%
700%      \ifcsname\??lk\currentlinkedlist\s!parent\endcsname
701%        \hskip\linkedlistparameter\c!distance\relax
702%        \clf_addlinklistelement{\currentlinkedlist}%
703%        \expanded{\ctxlatecommand{enhancelinkedlist("\currentlinkedlist",\currentlink)}}% can also be done at the lua end
704%        \dogotosomepage  {\??lk\currentlinkedlist}\gotobegincharacter \firstlink
705%        \ifnum\noflinks>\plustwo
706%          \dogotosomepage{\??lk\currentlinkedlist}\gobackwardcharacter\previouslink
707%          \dogotosomepage{\??lk\currentlinkedlist}\goforwardcharacter \nextlink
708%        \fi
709%        \dogotosomepage  {\??lk\currentlinkedlist}\gotoendcharacter   \lastlink
710%      \else
711%        \writestatus\m!interactions{no such linked list: \currentlinkedlist}%
712%      \fi
713%    \fi
714%    \egroup}
715%
716% \setuplinkedlists
717%   [\c!distance=.25em,
718%    \c!width=\v!fit,
719%    \c!location=\v!low,
720%    \c!color=\interactionparameter\c!color,
721%    \c!frame=\v!off,
722%    \c!background=,
723%    \c!backgroundcolor=]
724
725\protect \endinput
726