1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Interaction Macros Widgets}
15
16\registerctxluafile{scrnwid}{}
17
18
19
20
21\unprotect
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\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\let\setupattachments\setupattachment
77
78\setupattachment
79 [\c!state=\v!start,
80 \c!color=\interactionparameter\c!color,
81
82
83
84
85
86
87
88
89
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\unexpanded\def\registerattachment
98 {\dodoubleempty\scrn_attachment_register}
99
100\def\scrn_attachment_register[#tag][#settings]
101 {\ifsecondargument
102 \begingroup
103 \def\currentattachment{}
104 \setupcurrentattachment[#settings,\s!parent=\??attachment]
105 \clf_registerattachment
106 tag {#tag}
107 registered {#tag}
108 title {\attachmentparameter\c!title}
109 subtitle {\attachmentparameter\c!subtitle}
110 author {\attachmentparameter\c!author}
111 file {\attachmentparameter\c!file}
112 name {\attachmentparameter\c!name}
113 buffer {\attachmentparameter\c!buffer}
114 mimetype {\attachmentparameter\c!type}
115 \relax
116 \endgroup
117 \else
118
119 \fi}
120
121\appendtoks
122 \setuevalue \currentattachment {\scrn_attachment_direct{\currentattachment}}
123 \setuevalue{\e!start\currentattachment}{\scrn_attachment_start {\currentattachment}}
124 \setuevalue{\e!stop \currentattachment}{\scrn_attachment_stop }
125\to \everydefineattachment
126
127\unexpanded\def\scrn_attachment_direct#tag
128 {\edef\currentattachment{#tag}
129 \doifelselocation
130 {\dodoubleempty\scrn_attachment_direct_status}
131 {\dodoubleempty\scrn_attachment_direct_ignore}}
132
133\def\scrn_attachment_direct_status
134 {\doifelse{\attachmentparameter\c!state}\v!start
135 \scrn_attachment_direct_indeed
136 \scrn_attachment_direct_ignore}
137
138\def\scrn_attachment_direct_indeed[#registered][#settings]
139 {\bgroup
140 \doifelsenothing{#registered}
141 {\scrn_attachment_inject[\v!auto][]}
142 {\doifelseassignment{#registered}
143 {\scrn_attachment_inject[\v!auto][#registered]}
144 {\scrn_attachment_inject[#registered][#settings]}}
145 \egroup}
146
147\def\scrn_attachment_direct_ignore[#tag][#settings]
148 {}
149
150\unexpanded\def\scrn_attachment_start#tag
151 {\edef\currentattachment{#tag}
152 \doifelselocation
153 {\dodoubleempty\scrn_attachment_start_indeed}
154 {\dodoubleempty\scrn_attachment_start_ignore}}
155
156\unexpanded\def\scrn_attachment_stop
157 {}
158
159\def\scrn_attachment_start_indeed
160 {\doif{\attachmentparameter\c!state}\v!start
161 {\scrn_attachment_start_indeed}
162 {\scrn_attachment_start_ignore}}
163
164\def\scrn_attachment_start_indeed[#registered][#settings]
165 {\bgroup
166 \doifelsenothing{#registered}
167 {\def\scrn_attachment_stop{\scrn_attachment_inject[\v!auto][\c!buffer=\v!attachment]\egroup}}
168 {\doifelseassignment{#registered}
169 {\def\scrn_attachment_stop{\scrn_attachment_inject[\v!auto][\c!buffer=\v!attachment,#registered]\egroup}}
170 {\def\scrn_attachment_stop{\scrn_attachment_inject[#registered][\c!buffer=\v!attachment,#settings]\egroup}}}
171 \grabbufferdatadirect\v!attachment{\e!start\currentattachment}{\e!stop\currentattachment}}
172
173\def\scrn_attachment_start_ignore
174 {\expandafter\gobbleuntil\csname\e!stop\currentattachment\endcsname}
175
176\def\scrn_attachment_inject[#registered][#settings]
177 {\edef\currentattachmentregistered{#registered}
178 \setupattachment[\currentattachment][#settings]
179 \expandnamespaceparameter\??attachmentmethod\attachmentparameter\c!method\v!normal}
180
181\setvalue{\??attachmentmethod\v!normal}
182 {\edef\currentattachmentsymbol{\attachmentparameter\c!symbol}
183 \edef\currentattachmentwidth {\attachmentparameter\c!width }
184 \edef\currentattachmentheight{\attachmentparameter\c!height}
185 \edef\currentattachmentdepth {\attachmentparameter\c!depth }
186 \ifx\currentattachmentsymbol\empty
187 \ifx\currentattachmentwidth \v!fit\edef\currentattachmentwidth {.5\emwidth}\fi
188 \ifx\currentattachmentheight\v!fit\edef\currentattachmentheight{.5\emwidth}\fi
189 \ifx\currentattachmentdepth \v!fit\let \currentattachmentdepth \zeropoint\fi
190 \else
191 \clf_presetsymbollist{\attachmentparameter\c!symbol}
192
193 \setbox\b_scrn_attachment_symbol\hbox{\symbol[\lastpredefinedsymbol]}
194 \ifx\currentattachmentwidth \v!fit\edef\currentattachmentwidth {\wd\b_scrn_attachment_symbol}\fi
195 \ifx\currentattachmentheight\v!fit\edef\currentattachmentheight{\ht\b_scrn_attachment_symbol}\fi
196 \ifx\currentattachmentdepth \v!fit\edef\currentattachmentdepth {\dp\b_scrn_attachment_symbol}\fi
197 \fi
198 \clf_insertattachment
199 tag {\currentattachment}
200 registered {\currentattachmentregistered}
201 width \dimexpr\currentattachmentwidth \relax
202 height \dimexpr\currentattachmentheight\relax
203 depth \dimexpr\currentattachmentdepth \relax
204 color {\attachmentparameter\c!color}
205 colormodel \c_attr_colormodel
206 colorvalue \numexpr\thecolorattribute{\attachmentparameter\c!color}\relax
207 transparencyvalue \numexpr\thetransparencyattribute{\attachmentparameter\c!color}\relax
208 symbol {\currentattachmentsymbol}
209 layer {\attachmentparameter\c!textlayer}
210
211 title {\attachmentparameter\c!title}
212 subtitle {\attachmentparameter\c!subtitle}
213 author {\attachmentparameter\c!author}
214 file {\attachmentparameter\c!file}
215 name {\attachmentparameter\c!name}
216 buffer {\attachmentparameter\c!buffer}
217 mimetype {\attachmentparameter\c!type}
218 \relax
219 \wd\b_scrn_attachment_link\currentattachmentwidth
220 \ht\b_scrn_attachment_link\currentattachmentheight
221 \dp\b_scrn_attachment_link\currentattachmentdepth
222 \expandnamespaceparameter\??attachmentlocation\attachmentparameter\c!location\s!unknown}
223
224\setvalue{\??attachmentmethod\v!hidden}
225 {\clf_insertattachment
226 tag {\currentattachment}
227 registered {\currentattachmentregistered}
228 method {\v!hidden}
229 title {\attachmentparameter\c!title}
230 subtitle {\attachmentparameter\c!subtitle}
231 author {\attachmentparameter\c!author}
232 file {\attachmentparameter\c!file}
233 name {\attachmentparameter\c!name}
234 buffer {\attachmentparameter\c!buffer}
235 mimetype {\attachmentparameter\c!type}
236 \relax}
237
238\unexpanded\def\scrn_attachment_flush_traced
239 {\hpack\bgroup
240 \blackrule
241 [ \c!color=trace:r,
242 \c!width=\wd\b_scrn_attachment_link,
243 \c!height=\ht\b_scrn_attachment_link,
244 \c!depth=\dp\b_scrn_attachment_link]
245 \kern\wd\b_scrn_attachment_link
246 \box\b_scrn_attachment_link
247 \egroup}
248
249\unexpanded\def\scrn_attachment_flush_normal
250 {\box\b_scrn_attachment_link}
251
252\installtextracker
253 {attachments.anchors}
254 {\let\scrn_attachment_flush\scrn_attachment_flush_traced}
255 {\let\scrn_attachment_flush\scrn_attachment_flush_normal}
256
257\let\scrn_attachment_flush\scrn_attachment_flush_normal
258
259\setvalue{\??attachmentlocation\v!inmargin }{\inmargin {\scrn_attachment_flush}}
260\setvalue{\??attachmentlocation\v!leftedge }{\inleftedge {\scrn_attachment_flush}}
261\setvalue{\??attachmentlocation\v!rightedge }{\inrightedge {\scrn_attachment_flush}}
262\setvalue{\??attachmentlocation\v!leftmargin }{\inleftmargin {\scrn_attachment_flush}}
263\setvalue{\??attachmentlocation\v!rightmargin}{\inrightmargin{\scrn_attachment_flush}}
264\setvalue{\??attachmentlocation\v!high }{\high {\scrn_attachment_flush}}
265
266\setvalue{\??attachmentlocation\v!none}
267 {\global\setbox\b_scrn_attachment_collect\hbox\bgroup
268 \ifvoid\b_scrn_attachment_collect\else
269 \box\b_scrn_attachment_collect
270 \hskip\attachmentparameter\c!distance\relax
271 \fi
272 \scrn_attachment_flush
273 \egroup}
274
275\setvalue{\??attachmentlocation\s!unknown}
276 {\ifvoid\b_scrn_attachment_collect\else
277 \box\b_scrn_attachment_collect
278 \fi}
279
280\unexpanded\def\placeattachments
281 {\ifvoid\b_scrn_attachment_collect\else
282 \box\b_scrn_attachment_collect
283 \fi}
284
285\defineattachment[attachment]
286
287
288
289
290
291
292
293\unexpanded\def\useattachment
294 {\doquadrupleempty\scrn_attachment_use}
295
296\def\scrn_attachment_use[#tag][#title][#name][#file]
297 {\iffourthargument
298 \registerattachment[#tag][title=#title,name=#name,file=#file]
299 \else\ifthirdargument
300 \registerattachment[#tag][title=#title,name=#title,file=#name]
301 \else\ifsecondargument
302 \registerattachment[#tag][title=#title,name=#title,file=#title]
303 \else
304 \registerattachment[#tag][title=#tag,name=#tag,file=#tag]
305 \fi\fi\fi}
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\installcorenamespace{comment}
390\installcorenamespace{commentlocation}
391
392\installcommandhandler \??comment {comment} \??comment
393
394\newbox\b_scrn_comment_collect
395\newbox\b_scrn_comment_rendering
396\newbox\b_scrn_comment_link
397\newbox\b_scrn_comment_symbol
398
399\setupcomment
400 [\c!state=\v!start,
401 \c!distance=\emwidth,
402 \c!color=\interactionparameter\c!color,
403 \c!space=\v!no,
404 \c!symbol=,
405
406
407
408 \c!width=\v!fit,
409 \c!height=\v!fit,
410 \c!depth=\v!fit,
411 \c!nx=40,
412 \c!ny=10,
413 \c!buffer=\v!comment,
414 \c!location=\v!high]
415
416\appendtoks
417 \setuevalue \currentcomment {\scrn_comment_argument{\currentcomment}}
418 \setuevalue{\e!start\currentcomment}{\scrn_comment_start {\currentcomment}}
419 \setuevalue{\e!stop \currentcomment}{\scrn_comment_stop }
420\to \everydefinecomment
421
422\unexpanded\def\scrn_comment_argument#category
423 {\def\currentcomment{#category}
424 \doifelselocation
425 {\dodoubleempty\scrn_comment_argument_status}
426 {\dodoubleempty\scrn_comment_argument_ignore}}
427
428\def\scrn_comment_argument_status
429 {\doifelse{\commentparameter\c!state}\v!start
430 \scrn_comment_argument_indeed
431 \scrn_comment_argument_ignore}
432
433\def\scrn_comment_argument_indeed[#title][#settings]#text
434 {\doifelseassignment{#title}
435 {\setupcurrentcomment[#title]}
436 {\setupcurrentcomment[\c!title=#title,#settings]}
437 \clf_assignbuffer{\v!comment}{#text}\catcodetable\relax
438 \scrn_comment_inject
439 \ignorespaces}
440
441\def\scrn_comment_argument_ignore[#title][#settings]#text
442 {\ignorespaces}
443
444\unexpanded\def\scrn_comment_start#category
445 {\def\currentcomment{#category}
446 \doifelselocation
447 {\dodoubleempty\scrn_comment_start_status}
448 {\dodoubleempty\scrn_comment_start_ignore}}
449
450\def\scrn_comment_start_status
451 {\doifelse{\commentparameter\c!state}\v!start
452 {\scrn_comment_start_indeed}
453 {\scrn_comment_start_ignore}}
454
455\def\scrn_comment_start_indeed[#title][#settings]
456 {\bgroup
457 \doifelseassignment{#title}
458 {\setupcurrentcomment[#title]}
459 {\setupcurrentcomment[\c!title=#title,#settings]}
460 \unexpanded\def\scrn_comment_stop{\scrn_comment_inject\egroup}
461 \grabbufferdatadirect\v!comment{\e!start\currentcomment}{\e!stop\currentcomment}}
462
463\def\scrn_comment_start_ignore
464 {\expandafter\gobbleuntil\csname\e!stop\currentcomment\endcsname}
465
466\unexpanded\def\scrn_comment_stop
467 {}
468
469\installcorenamespace{commentmethods}
470
471\unexpanded\def\scrn_comment_inject
472 {\expandnamespaceparameter\??commentmethods\commentparameter\c!method\v!normal}
473
474
475
476
477\setvalue{\??commentmethods\v!normal}
478 {\edef\currentcommentsymbol{\commentparameter\c!symbol}
479 \edef\currentcommentwidth {\commentparameter\c!width }
480 \edef\currentcommentheight{\commentparameter\c!height}
481 \edef\currentcommentdepth {\commentparameter\c!depth }
482 \ifx\currentcommentsymbol\empty
483 \ifx\currentcommentwidth \v!fit\edef\currentcommentwidth {.5\emwidth}\fi
484 \ifx\currentcommentheight\v!fit\edef\currentcommentheight{.5\emwidth}\fi
485 \ifx\currentcommentdepth \v!fit\let \currentcommentdepth \zeropoint\fi
486 \else
487 \clf_presetsymbollist{\commentparameter\c!symbol}
488
489 \setbox\b_scrn_comment_symbol\hbox{\symbol[\lastpredefinedsymbol]}
490 \ifx\currentcommentwidth \v!fit\edef\currentcommentwidth {\wd\b_scrn_comment_symbol}\fi
491 \ifx\currentcommentheight\v!fit\edef\currentcommentheight{\ht\b_scrn_comment_symbol}\fi
492 \ifx\currentcommentdepth \v!fit\edef\currentcommentdepth {\dp\b_scrn_comment_symbol}\fi
493 \fi
494 \clf_insertcomment
495 tag {\currentcomment}
496 title {\commentparameter\c!title}
497 subtitle {\commentparameter\c!subtitle}
498 author {\commentparameter\c!author}
499 width \dimexpr\currentcommentwidth\relax
500 height \dimexpr\currentcommentheight\relax
501 depth \dimexpr\currentcommentdepth\relax
502 nx {\commentparameter\c!nx}
503 ny {\commentparameter\c!ny}
504 colormodel \c_attr_colormodel
505 colorvalue \numexpr\thecolorattribute{\commentparameter\c!color}\relax
506 transparencyvalue \numexpr\thetransparencyattribute{\commentparameter\c!color}\relax
507 option {\commentparameter\c!option}
508 symbol {\commentparameter\c!symbol}
509 buffer {\commentparameter\c!buffer}
510 layer {\commentparameter\c!textlayer}
511 space {\commentparameter\c!space}
512 \relax
513 \wd\b_scrn_comment_link\currentcommentwidth
514 \ht\b_scrn_comment_link\currentcommentheight
515 \dp\b_scrn_comment_link\currentcommentdepth
516 \expandnamespaceparameter\??commentlocation\commentparameter\c!location\s!unknown}
517
518\letvalue{\??commentmethods\v!hidden}\donothing
519
520\unexpanded\def\scrn_comment_flush_traced
521 {\hpack\bgroup
522 \blackrule
523 [ \c!color=trace:y,
524 \c!width=\wd\b_scrn_comment_link,
525 \c!height=\ht\b_scrn_comment_link,
526 \c!depth=\dp\b_scrn_comment_link]
527 \kern\wd\b_scrn_comment_link
528 \box\b_scrn_comment_link
529 \egroup}
530
531\unexpanded\def\scrn_comment_flush_normal
532 {\box\b_scrn_comment_link}
533
534\installtextracker
535 {comments.anchors}
536 {\let\scrn_comment_flush\scrn_comment_flush_traced}
537 {\let\scrn_comment_flush\scrn_comment_flush_normal}
538
539\let\scrn_comment_flush\scrn_comment_flush_normal
540
541
542
543\setvalue{\??commentlocation\v!inmargin }{\inmargin {\scrn_comment_flush}}
544\setvalue{\??commentlocation\v!leftedge }{\inleftedge {\scrn_comment_flush}}
545\setvalue{\??commentlocation\v!rightedge }{\inrightedge {\scrn_comment_flush}}
546\setvalue{\??commentlocation\v!leftmargin }{\inleftmargin {\scrn_comment_flush}}
547\setvalue{\??commentlocation\v!rightmargin}{\inrightmargin{\scrn_comment_flush}}
548\setvalue{\??commentlocation\v!high }{\high {\scrn_comment_flush}}
549
550\setvalue{\??commentlocation\v!none}
551 {\global\setbox\b_scrn_comment_collect\hbox\bgroup
552 \ifvoid\b_scrn_comment_collect\else
553 \box\b_scrn_comment_collect
554 \hskip\commentparameter\c!distance\relax
555 \fi
556 \scrn_comment_flush
557 \egroup}
558
559\setvalue{\??commentlocation\s!unknown}
560 {\ifvoid\b_scrn_comment_collect\else
561 \box\b_scrn_comment_collect
562 \fi}
563
564\unexpanded\def\placecomments
565 {\ifvoid\b_scrn_comment_collect\else
566 \box\b_scrn_comment_collect
567 \fi}
568
569\definecomment[comment]
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588\installcorenamespace{externalsoundtracks}
589
590\installsetuponlycommandhandler \??externalsoundtracks {externalsoundtracks}
591
592\setupexternalsoundtracks
593 [\c!option=]
594
595\unexpanded\def\useexternalsoundtrack
596 {\dodoubleargument\scrn_soundtrack_indeed}
597
598\def\scrn_soundtrack_indeed[#tag][#filename]
599 {\clf_registersoundclip
600 tag {#tag}
601 file {#filename}
602 \relax}
603
604\def\checksoundtrack#tag
605 {\iflocation
606 \clf_insertsoundclip
607 tag {#tag}
608 repeat {\directexternalsoundtracksparameter\c!option}
609 \relax
610 \fi}
611
612
613
614
615
616
617\let\currentrendering\empty
618
619\definereference[StartCurrentRendering] [\v!StartRendering {\currentrendering}]
620\definereference[StopCurrentRendering] [\v!StopRendering {\currentrendering}]
621\definereference[PauseCurrentRendering] [\v!PauseRendering {\currentrendering}]
622\definereference[ResumeCurrentRendering][\v!ResumeRendering{\currentrendering}]
623
624\unexpanded\def\useexternalrendering{\doquadrupleempty\scrn_rendering_use}
625\unexpanded\def\setinternalrendering{\dodoubleempty \scrn_rendering_set}
626
627\def\scrn_rendering_use[#tag][#mime][#file][#option]
628 {\clf_registerrendering
629 type {external}
630 label {#tag}
631 mime {#mime}
632 filename {#file}
633 option {#option}
634 \relax}
635
636\def\scrn_rendering_set[#tag][#option]
637 {\bgroup
638 \dowithnextbox
639 {\clf_registerrendering
640 type {internal}
641 label {#tag}
642 mime {IRO}
643 filename {#tag}
644 option {#option}
645 \relax
646 \let\objectoffset\zeropoint
647 \setobject{IRO}{#tag}\hpack{\box\nextbox}
648 \egroup}
649 \hbox}
650
651\def\renderingtype #tag{\clf_renderingvar{#tag}{type}}
652\def\renderingoption#tag{\clf_renderingvar{#tag}{option}}
653
654\newdimen\d_scrn_rendering_width \d_scrn_rendering_width 8cm
655\newdimen\d_scrn_rendering_height \d_scrn_rendering_height 6cm
656
657\let\m_scrn_rendering_page\!!zerocount
658
659\installcorenamespace{renderingwindow}
660
661\installframedcommandhandler \??renderingwindow {renderingwindow} \??renderingwindow
662
663\appendtoks
664 \letrenderingwindowparameter\c!openpageaction \empty
665 \letrenderingwindowparameter\c!closepageaction\empty
666 \setrenderingwindowparameter\c!width {\d_scrn_rendering_width }
667 \setrenderingwindowparameter\c!height {\d_scrn_rendering_height}
668 \letrenderingwindowparameter\c!align \v!flushleft
669\to \everypresetrenderingwindow
670
671\unexpanded\def\placerenderingwindow
672 {\dodoubleempty\scrn_rendering_place_window}
673
674\def\scrn_rendering_place_window[#window][#rendering]
675 {\bgroup
676 \edef\currentrendering{\ifsecondargument#rendering\else#window\fi}
677
678 \edef\currentrenderingwindow{\namedrenderingwindowparameter{#window}\c!width}
679 \ifx\currentrenderingwindow\empty
680 \let\currentrenderingwindow\s!default
681 \definerenderingwindow[\currentrenderingwindow]
682 \else
683 \edef\currentrenderingwindow{#window}
684 \fi
685 \edef\currentrenderingtype{\renderingtype\currentrendering}
686 \ifx\currentrenderingtype\s!internal
687 \getobjectdimensions{IRO}\currentrendering
688 \d_scrn_rendering_height\dimexpr\objectheight\objectdepth\relax
689 \d_scrn_rendering_width\objectwidth\relax
690 \dogetobjectreferencepage{IRO}\currentrendering\m_scrn_rendering_page
691 \else\ifx\currentrenderingwindow\s!default
692 \d_scrn_rendering_height\vsize
693 \d_scrn_rendering_width \hsize
694 \let\m_scrn_rendering_page\realpageno
695 \else
696 \d_scrn_rendering_height\renderingwindowparameter\c!height
697 \d_scrn_rendering_width \renderingwindowparameter\c!width
698 \let\m_scrn_rendering_page\realpageno
699 \fi\fi
700
701
702
703 \letrenderingwindowparameter\c!offset\v!overlay
704 \inheritedrenderingwindowframed
705 {\vfilll
706 \dontleavehmode
707 \clf_insertrenderingwindow
708 label {\currentrendering}
709 width \d_scrn_rendering_width
710 height \d_scrn_rendering_height
711 option {\renderingoption\currentrendering}
712 page \m_scrn_rendering_page
713 \relax
714 \hfill}
715 \egroup}
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777\protect \endinput
778 |