scrn-fld.mkvi /size: 36 Kb    last modification: 2021-10-28 13:50
1
%D \module
2
%D [ file=scrn-fld,
3
%D version=1997.05.18,
4
%D title=\CONTEXT\ Screen Macros,
5
%D subtitle=Fields,
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
% There is still some leftover code from mkii, where we need to
15
% be sparse with hash entries and so have a somewhat complex
16
% setup mechanism.
17 18
% interaction checking
19 20
\writestatus
{
loading
}
{
ConTeXt
Screen
Macros
/
Fields
}
21 22
\unprotect
23 24
\registerctxluafile
{
scrn
-
fld
}
{
}
25 26
%D In \MKII\ we had to cheat a bit with setups in order not to run
27
%D out of memory with thousands of fields, which we happen to need at
28
%D that time. In \MKIV\ we can store some data at the \LUA\ end and
29
%D use a somewhat slower but quite okay inheritance mechanism. For
30
%D this reason we now have split definitions, although the old method
31
%D is still somewhat supported. The clone and copy commands are
32
%D somewhat obsolete for several reasons: we can now use inheritance
33
%D and autocloning has been supported for a while. In most cases
34
%D cloning (especially with check boxes) the acrobat browser is not
35
%D stable enough with respect to appearance handling.
36
%D
37
%D A fieldcategory is nothing more than a collection of settings.
38
%D
39
%D \starttyping
40
%D \definefieldcategory
41
%D [all-email]
42
%D [height=1cm,
43
%D width=14cm,
44
%D style=sstf]
45
%D \stoptyping
46
%D
47
%D A definition can refer to this category:
48
%D
49
%D \starttyping
50
%D \definefieldbody [email] [type=line,category=all-email,default=pragma@xs4all.nl]
51
%D \stoptyping
52
%D
53
%D A copy of a field is made as follows:
54
%D
55
%D \starttyping
56
%D \definefieldbody [xmail] [email]
57
%D \stoptyping
58
%D
59
%D You can also be more specific:
60
%D
61
%D \starttyping
62
%D \definefieldbody[buttona][type=check,values={one,two}]
63
%D \definefieldbody[buttonb][type=check,values={three,four}]
64
%D \definefieldbody[buttonc][buttona][values={three,four}]
65
%D \stoptyping
66
%D
67
%D Actually typesetting a field happens this way:
68
%D
69
%D \starttyping
70
%D \fieldbody [Email]
71
%D \fieldbody [Email] [width=6cm]
72
%D \fieldbody [eMAIL]
73
%D \fieldbody [eMAIL] [width=7cm]
74
%D
75
%D \fieldbody [buttona]
76
%D \fieldbody [buttona]
77
%D \fieldbody [buttonb]
78
%D \fieldbody [buttonb]
79
%D \fieldbody [buttonc]
80
%D \fieldbody [buttonc]
81
%D \stoptyping
82
%D
83
%D So, you can call up a field many times and quite some parameters
84
%D can be set.
85
%D
86
%D Because there are persistent problems with acrobat rendering
87
%D associated appearance streams (some messy /MK interferende) we
88
%D also support native (built-in dingbat) symbols: check, circle,
89
%D cross, diamond, square and star.
90
%D
91
%D \starttyping
92
%D \definefield[test1][check]
93
%D \definefield[test2][check]
94
%D
95
%D \fieldbody[test1][width=1em,height=\strutht,depth=\strutdp,symbol=check]
96
%D \fieldbody[test1][width=1em,height=\strutht,depth=\strutdp,symbol=circle]
97
%D \fieldbody[test2][width=1em,height=\strutht,depth=\strutdp,symbol=square]
98
%D \stoptyping
99
%D
100
%D When submitting a form, we need to tell the driver module
101
%D that we want \FDF\ or \HTML.
102 103
\installcorenamespace
{
forms
}
104 105
\installdirectcommandhandler
\??forms
{
forms
}
106 107
\appendtoks
108
\clf_setformsmethod
{
\formsparameter
\c!method
}
%
109
\to
\everysetupforms
110 111
\setupforms
112
[
\c!method
=
XML
]
% no need for everyjob initialization as this is the default
113 114
\appendtoks
115
\iflocation
116
\clf_exportformdata
{
\formsparameter
\c!export
}
%
117
\fi
118
\to
\everystoptext
119 120
%D We need to initialize symbols in a special way so that they
121
%D can be used as rendering for a widget.
122 123
\unexpanded
\def
\presetfieldsymbols
[
#
list
]
% slow
124
{
\processcommacommand
[
#
list
]
\scrn_symbols_preset
}
125 126
\def
\scrn_symbols_preset
#
set
%
127
{
\processcommalist
[
#
set
]
\scrn_symbols_preset_indeed
}
%
128 129
\def
\scrn_symbols_preset_indeed
#
tag
%
130
{
\doifelseobjectfound
{
SYM
}
{
#
tag
}
131
{
}
132
{
\settightobject
{
SYM
}
{
#
tag
}
\hbox
{
\symbol
[
#
tag
]
}
% % todo: set this as immediate xform
133
\page_otr_add_special_content
{
\hskip
-
\maxdimen
\getobject
{
SYM
}
{
#
tag
}
}
}
}
% and then force it into the file
134 135
\let
\dosetfieldsymbol
\scrn_symbols_preset_indeed
136 137
\def
\dogetfieldsymbol
#
tag
%
138
{
\getobject
{
SYM
}
{
#
tag
}
}
139 140
\unexpanded
\def
\definedefaultsymbols
% used ?
141
{
\definesymbol
[
defaultyes
]
[
\mathematics
{
\times
}
]
%
142
\definesymbol
[
defaultno
]
[
\mathematics
{
\cdot
}
]
}
143 144
%D Now comes the real code:
145 146
\installcorenamespace
{
fieldcategory
}
147
\installcorenamespace
{
fieldbody
}
148 149
\installcommandhandler
\??fieldcategory
{
fieldcategory
}
\??fieldcategory
150
\installcommandhandler
\??fieldbody
{
fieldbody
}
\??fieldbody
151 152
\newbox
\b_scrn_field_body
153 154
\setupfieldcategory
155
[
\c!alternative
=
\v!normal
,
% normal clone copy
156
\c!type
=
\v!line
,
% line text ...
157
\c!width
=
5
em
,
158
\c!height
=
1
em
,
159
\c!depth
=
\zeropoint
,
160
\c!align
=
\v!flushleft
,
161
\c!option
=
\v!printable
,
% maybe we need a globaloptions and marge them
162
\c!n
=
1
0
2
4
]
163 164
\def
\scrn_field_check_category
165
{
\edef
\currentfieldbodycategory
{
\fieldbodyparameter
\c!category
}
%
166
\ifx
\currentfieldbodycategory
\empty
167
\letfieldbodyparameter
\s!parent
\??fieldcategory
168
%\setevalue{\currentfieldbodyhash\s!parent}{\namedfieldcategoryhash\empty}% to WS: not hash !
169
\else
170
\normalexpanded
{
\setfieldbodyparameter
{
\s!parent
}
{
\??fieldcategory
\currentfieldbodycategory
}
}
%
171
%\setevalue{\currentfieldbodyhash\s!parent}{\namedfieldcategoryhash\currentfieldbodycategory}% to WS: not hash !
172
\fi
}
173 174
\appendtoks
% we cannot use parent .. maybe s!parent has to change
175
\ifx
\currentfieldbodyparent
\empty
176
\scrn_field_check_category
177
\clf_definefield
178
name
{
\currentfieldbody
}
%
179
alternative
{
normal
}
%
180
type
{
\fieldbodyparameter
\c!type
}
%
181
category
{
\fieldbodyparameter
\c!category
}
%
182
values
{
\fieldbodyparameter
\c!values
}
%
183
default
{
\fieldbodyparameter
\c!default
}
%
184
\relax
185
\else
186
\clf_clonefield
187
children
{
\currentfieldbody
}
%
188
alternative
{
clone
}
%
189
parent
{
\currentfieldbodyparent
}
%
190
category
{
\fieldbodyparameter
\c!category
}
%
191
values
{
\fieldbodyparameter
\c!values
}
%
192
default
{
\fieldbodyparameter
\c!default
}
%
193
\relax
194
\fi
195
\to
\everydefinefieldbody
196 197
\unexpanded
\def
\fieldbody
198
{
\dodoubleempty
\scrn_field_body
}
199 200
\def
\scrn_field_body
[
#
tag
]
[
#
settings
]
%
201
{
\iflocation
202
\hbox
\bgroup
203
\edef
\currentfieldbody
{
#
tag
}
%
204
\ifsecondargument
205
\setupcurrentfieldbody
[
#
settings
]
%
206
\fi
207
\scrn_field_body_typeset
208
\box
\b_scrn_field_body
209
\egroup
210
\fi
}
211 212
\def
\scrn_field_body_typeset
% todo: fieldsymbol (checkfields /MK mess)
213
{
\edef
\currentfieldframecolor
{
\fieldbodyparameter
\c!fieldframecolor
}
%
214
\ifx
\currentfieldframecolor
\empty
\else
215
\getcolorattributevalue
\currentfieldframecolor
\currentfieldframecolorvalue
216
% == \edef\currentfieldframecolorvalue{\thecolorattribute\currentfieldframecolor}%
217
\fi
218
\edef
\currentfieldbackgroundcolor
{
\fieldbodyparameter
\c!fieldbackgroundcolor
}
%
219
\ifx
\currentfieldbackgroundcolor
\empty
\else
220
\getcolorattributevalue
\currentfieldbackgroundcolor
\currentfieldbackgroundcolorvalue
221
% == \edef\currentfieldbackgroundcolorvalue{\thecolorattribute\currentfieldbackgroundcolor}%
222
\fi
223
\usefieldbodystyleandcolor
\c!style
\c!color
224
\clf_insertfield
225
{
\currentfieldbody
}
%
226
{
%
227
title
{
\currentfieldbody
}
228
width
\dimexpr
\fieldbodyparameter
\c!width
\relax
229
height
\dimexpr
\fieldbodyparameter
\c!height
\relax
230
depth
\dimexpr
\fieldbodyparameter
\c!depth
\relax
231
align
{
\fieldbodyparameter
\c!align
}
%
232
length
{
\fieldbodyparameter
\c!n
}
%
233
fontstyle
{
\fontstyle
}
%
234
fontalternative
{
\fontalternative
}
%
235
fontsize
{
\fontbody
}
%
236
fontsymbol
{
\fieldbodyparameter
\c!symbol
}
%
237
color
{
\fieldbodyparameter
\c!color
}
%
238
colorvalue
\c_attr_color
239
\ifx
\currentfieldbackgroundcolor
\empty
\else
240
backgroundcolor
{
\currentfieldbackgroundcolor
}
%
241
backgroundcolorvalue
\numexpr
\currentfieldbackgroundcolorvalue
\relax
242
\fi
243
\ifx
\currentfieldframecolor
\empty
\else
244
framecolor
{
\currentfieldframecolor
}
%
245
framecolorvalue
\numexpr
\currentfieldframecolorvalue
\relax
246
\fi
247
layer
{
\fieldbodyparameter
\c!fieldlayer
}
%
248
option
{
\fieldbodyparameter
\c!option
}
%
249
clickin
{
\fieldbodyparameter
\c!clickin
}
%
250
clickout
{
\fieldbodyparameter
\c!clickout
}
%
251
regionin
{
\fieldbodyparameter
\c!regionin
}
%
252
regionout
{
\fieldbodyparameter
\c!regionout
}
%
253
afterkey
{
\fieldbodyparameter
\c!afterkey
}
%
254
format
{
\fieldbodyparameter
\c!format
}
%
255
validate
{
\fieldbodyparameter
\c!validate
}
%
256
calculate
{
\fieldbodyparameter
\c!calculate
}
%
257
focusin
{
\fieldbodyparameter
\c!focusin
}
%
258
focusout
{
\fieldbodyparameter
\c!focusout
}
%
259
openpage
{
\fieldbodyparameter
\c!openpage
}
%
260
closepage
{
\fieldbodyparameter
\c!closepage
}
%
261
}
%
262
\relax
}
263 264
%D The sets are used in grouped calculations.
265
%D
266
%D [name] [set]
267 268
\unexpanded
\def
\definefieldbodyset
269
{
\dodoubleempty
\scrn_field_define_set
}
270 271
\def
\scrn_field_define_set
[
#
tag
]
[
#
list
]
%
272
{
\clf_definefieldset
{
#
tag
}
{
#
list
}
}
273 274
\let
\dodefinefieldset
\definefieldbodyset
% compatibility
275 276
%D A few testing macros:
277 278
\def
\doifelsefieldbody
#
tag
{
\clf_doifelsefield
{
#
tag
}
}
279
\def
\doifelsefieldcategory
#
tag
{
\clf_doifelsefieldcategory
{
#
tag
}
}
280 281
\let
\doiffieldbodyelse
\doifelsefieldbody
282
\let
\doiffieldcategoryelse
\doifelsefieldcategory
283 284
\let
\doiffieldelse
\doifelsefieldbody
% compatibility / will be dropped
285
\let
\doifelsefield
\doifelsefieldbody
% compatibility / will be dropped
286 287
%D We still support the traditional method of defining fields:
288
%D
289
%D \starttyping
290
%D \definefield [name] [type] [category] [values] [default]
291
%D
292
%D \definefield [WWWW] [text] [textsetup] [default text]
293
%D \definefield [XXXX] [push] [pushsetup] [yes,no] [yes]
294
%D \definefield [XXXX] [check] [checksetup] [yes,no] [yes]
295
%D \definefield [YYYY] [combo] [combosetup] [a,b,c,d] [b]
296
%D \definefield [ZZZZ] [radio] [radiosetup] [W,X,Y,Z] [Y]
297
%D
298
%D \definesubfield [W] [subsetup] [p,q]
299
%D \definesubfield [X,Y] [subsetup] [p,r]
300
%D \definesubfield [Z] [subsetup] [y,z]
301
%D
302
%D evt \definemainfield ... wanneer geplaatst voor subs gegeven
303
%D
304
%D \clonefield [XXXX] [XX,YY] [mysetup] [on,off]
305
%D \clonefield [Z] [AA,BB] [somesetup] [true,false]
306
%D \clonefield [Z] [CC,DD] [anothersetup]
307
%D
308
%D \copyfield [XXXX] [PP,QQ,RR]
309
%D \stoptyping
310
%D
311
%D Keep in mind that you can also use \type {\definefieldbody} to
312
%D achieve the same.
313 314
\unexpanded
\def
\definefield
{
\doquintupleempty
\scrn_field_define_field
}
315
\unexpanded
\def
\definesubfield
{
\dotripleempty
\scrn_field_define_subfield
}
316
\unexpanded
\def
\clonefield
{
\doquadrupleempty
\scrn_field_clone_field
}
317
\unexpanded
\def
\copyfield
{
\dodoubleempty
\scrn_field_copy_field
}
318 319
\let
\definemainfield
\definefield
% obsolete !
320 321
\def
\scrn_field_define_field
[
#
tag
]
[
#
type
]
[
#
category
]
[
#
values
]
[
#
default
]
%
322
{
\definefieldbody
[
#
tag
]
[
\c!type
=
#
type
,
\c!category
=
#
category
,
\c!values
=
{
#
values
}
,
\c!default
=
{
#
default
}
]
}
323 324
\def
\scrn_field_define_subfield
[
#
tag
]
[
#
category
]
[
#
values
]
%
325
{
\definefieldbody
[
#
tag
]
[
\c!type
=
sub
,
\c!category
=
#
category
,
\c!values
=
{
#
values
}
]
}
326 327
\def
\scrn_field_clone_field
[
#
parent
]
[
#
tag
]
[
#
category
]
[
#
values
]
%
328
{
\definefieldbody
[
#
tag
]
[
#
parent
]
[
\c!category
=
#
category
,
\c!values
=
{
#
values
}
]
}
329 330
\def
\scrn_field_copy_field
[
#
parent
]
[
#
tag
]
%
331
{
\definefieldbody
[
#
tag
]
[
#
parent
]
}
332 333
%D We hook fields into the (viewer based) layering mechanism
334
%D (implemented as properties).
335 336
\appendtoks
337
\let
\currentfieldcategory
\empty
338
\doifelse
{
\interactionparameter
\c!fieldlayer
}
\v!auto
339
{
\setupcurrentfieldcategory
[
\c!fieldlayer
=
\currentviewerlayer
]
}
%
340
{
\setupcurrentfieldcategory
[
\c!fieldlayer
=
]
}
%
341
\to
\everysetupinteraction
342 343
\setupinteraction
344
[
\c!fieldlayer
=
\v!auto
]
% auto by default
345 346
%D The \type {\fieldbody} is the more bare one. One step further goes
347
%D \type {\fitfield}, in fact it (now) uses a dedicated instance of
348
%D framed: \type {fitfieldframed}.
349
%D
350
%D \starttyping
351
%D \ruledhbox{\fieldbody[Email][height=\strutht,depth=\strutdp,style=normal]}
352
%D \ruledhbox{\fitfield[Email][height=\strutht,depth=\strutdp,style=normal]}
353
%D \ruledhbox{\fitfield[buttona]}
354
%D \stoptyping
355 356
\newbox
\b_scrn_field_fit_symbol
357 358
\defineframed
359
[
fitfieldframed
]
360
[
\c!strut
=
\v!no
,
361
\c!frame
=
off
,
362
\c!offset
=
\v!overlay
,
363
\c!align
=
]
364 365
\unexpanded
\def
\fitfield
366
{
\dodoubleempty
\scrn_field_fit
}
367 368
\def
\scrn_field_fit
[
#
tag
]
[
#
settings
]
%
369
{
\iflocation
370
\begingroup
371
\edef
\currentdefaultfieldvalue
{
\clf_getdefaultfieldvalue
{
#
tag
}
}
%
372
\setbox
\b_scrn_field_fit_symbol
\hbox
{
\symbol
[
\currentdefaultfieldvalue
]
}
%
373
\fitfieldframed
374
{
\fieldbody
[
#
tag
]
375
[
\c!width
=
\wd
\b_scrn_field_fit_symbol
,
376
\c!height
=
\ht
\b_scrn_field_fit_symbol
,
377
\c!depth
=
\dp
\b_scrn_field_fit_symbol
,
378
#
settings
]
}
%
379
\endgroup
380
\fi
}
381 382
%D The traditional field command does some labeling and
383
%D boxing:
384 385
\installcorenamespace
{
fieldlabel
}
386
\installcorenamespace
{
fieldcontent
}
387
\installcorenamespace
{
fieldtotal
}
388 389
\installparameterhandler
\??fieldlabel
{
fieldlabelframed
}
390
\installparameterhandler
\??fieldcontent
{
fieldcontentframed
}
391
\installparameterhandler
\??fieldtotal
{
fieldtotalframed
}
392 393
\installparametersethandler
\??fieldcontent
{
fieldcontentframed
}
394 395
\installsetuphandler
\??fieldlabel
{
fieldlabelframed
}
396
\installsetuphandler
\??fieldcontent
{
fieldcontentframed
}
397
\installsetuphandler
\??fieldtotal
{
fieldtotalframed
}
398 399
\installinheritedframed
{
fieldlabelframed
}
400
\installinheritedframed
{
fieldcontentframed
}
401
\installinheritedframed
{
fieldtotalframed
}
402 403
\unexpanded
\def
\setupfield
{
\doquintupleempty
\scrn_field_setup_field
}
404
\unexpanded
\def
\setupfields
{
\doquadrupleempty
\scrn_field_setup_fields
}
405 406
\setupfieldcontentframed
407
[
\c!align
=
\v!flushleft
,
408
\c!strut
=
\v!no
,
409
\s!parent
=
\??regularframed
]
% needs checking
410 411
\setupfieldcontentframed
% independent
412
[
\c!alternative
=
\v!normal
,
413
\c!type
=
\v!line
,
414
\c!width
=
5
em
,
415
\c!height
=
\lineheight
,
416
\c!depth
=
\zeropoint
,
417
\c!align
=
\v!flushleft
,
418
\c!option
=
\v!printable
,
419
\c!n
=
1
0
2
4
]
420 421
\setupfieldlabelframed
422
[
\c!style
=
,
423
\c!color
=
,
424
\c!align
=
\v!flushleft
,
425
\s!parent
=
\??regularframed
]
% needs checking
426 427
\setupfieldtotalframed
428
[
%\c!alternative={\v!label,\v!frame,\v!horizontal},
429
\c!strut
=
\v!no
,
430
\c!align
=
,
431
\s!parent
=
\??regularframed
]
% needs checking
432 433
% \setupcurrent
434 435
\def
\scrn_field_setup_field
[
#
tag
]
[
#
variant
]
[
#
totalsettings
]
[
#
labelsettings
]
[
#
fieldsettings
]
%
436
{
\iffifthargument
437
\definefieldcategory
[
#
tag
]
[
\s!parent
=
\??fieldcontent
#
tag
,
#
fieldsettings
]
%
438
\setupfieldtotalframed
[
#
tag
]
[
\s!parent
=
\??fieldtotal
,
\c!alternative
=
{
#
variant
}
,
#
totalsettings
]
%
439
\setupfieldlabelframed
[
#
tag
]
[
\s!parent
=
\??fieldlabel
,
#
labelsettings
]
%
440
\setupfieldcontentframed
[
#
tag
]
[
\s!parent
=
\??fieldcontent
,
#
fieldsettings
]
%
441
\else
\iffourthargument
442
\definefieldcategory
[
#
tag
]
[
\s!parent
=
\??fieldcontent
#
tag
,
#
labelsettings
]
%
443
\setupfieldtotalframed
[
#
tag
]
[
\s!parent
=
\??fieldtotal
,
\c!alternative
=
{
#
variant
}
,
#
totalsettings
]
%
444
\setupfieldlabelframed
[
#
tag
]
[
\s!parent
=
\??fieldlabel
]
%
445
\setupfieldcontentframed
[
#
tag
]
[
\s!parent
=
\??fieldcontent
,
#
labelsettings
]
%
446
\else
\ifthirdargument
447
\definefieldcategory
[
#
tag
]
[
\s!parent
=
\??fieldcontent
#
tag
,
#
totalsettings
]
%
448
\setupfieldtotalframed
[
#
tag
]
[
\s!parent
=
\??fieldtotal
,
\c!alternative
=
{
#
variant
}
]
%
449
\setupfieldlabelframed
[
#
tag
]
[
\s!parent
=
\??fieldlabel
]
%
450
\setupfieldcontentframed
[
#
tag
]
[
\s!parent
=
\??fieldcontent
,
#
totalsettings
]
%
451
\else
\ifsecondargument
452
\definefieldcategory
[
#
tag
]
[
\s!parent
=
\??fieldcontent
#
tag
,
#
variant
]
%
453
\setupfieldtotalframed
[
#
tag
]
[
\s!parent
=
\??fieldtotal
]
%
454
\setupfieldlabelframed
[
#
tag
]
[
\s!parent
=
\??fieldlabel
]
%
455
\setupfieldcontentframed
[
#
tag
]
[
\s!parent
=
\??fieldcontent
,
#
variant
]
%
456
\fi
\fi
\fi
\fi
}
457 458
\def
\scrn_field_setup_fields
[
#
variant
]
[
#
totalsettings
]
[
#
labelsettings
]
[
#
fieldsettings
]
%
459
{
\iffourthargument
460
\setupfieldtotalframed
[
\c!alternative
=
{
#
variant
}
,
#
totalsettings
]
%
461
\setupfieldlabelframed
[
#
labelsettings
]
%
462
\setupfieldcontentframed
[
#
fieldsettings
]
%
463
\else
\ifthirdargument
464
\setupfieldtotalframed
[
#
variant
]
%
465
\setupfieldlabelframed
[
#
totalsettings
]
%
466
\setupfieldcontentframed
[
#
labelsettings
]
%
467
\else
\ifsecondargument
468
\setupfieldtotalframed
[
#
variant
]
%
469
\setupfieldcontentframed
[
#
totalsettings
]
%
470
\else
471
\setupfieldtotalframed
[
#
variant
]
%
472
\fi
\fi
\fi
}
473 474
% just to get the chain right for no category:
475 476
\definefieldcategory
[
]
[
\s!parent
=
\??fieldcontent
]
477
%setupfieldtotalframed [][\s!parent=\??fieldtotal]
478
%setupfieldlabelframed [][\s!parent=\??fieldlabel]
479
%setupfieldcontentframed[][\s!parent=\??fieldcontent]
480 481
% no longer supported:
482 483
\let
\resetfields
\relax
484 485
\def
\scrn_field_load_scripts
{
\useJSscripts
[
fld
]
\glet
\scrn_field_load_scripts
\relax
}
486 487
\newconditional
\fieldlabelshown
488
\newconditional
\fieldframeshown
489
\newconditional
\fieldisvertical
490
\newconditional
\fieldishorizontal
491 492
\unexpanded
\def
\field
493
{
\dodoubleempty
\scrn_field_direct
}
494 495
\def
\scrn_field_direct
[
#
tag
]
[
#
label
]
% can be sped up with \setupcurrentfieldtotalframed etc
496
{
\iflocation
497
\dontleavehmode
498
\begingroup
499
\scrn_field_load_scripts
500
\edef
\currentfieldbody
{
#
tag
}
%
501
\edef
\currentfieldlabel
{
#
label
}
%
502
\edef
\currentfieldcategory
{
\clf_getfieldcategory
{
#
tag
}
}
%
503
\ifx
\currentfieldlabel
\empty
504
\let
\currentfieldlabel
\currentfieldbody
505
\fi
506
\ifx
\currentfieldcategory
\empty
507
\setupfieldtotalframed
[
\currentfieldbody
]
[
\s!parent
=
\??fieldtotal
]
%
508
\setupfieldlabelframed
[
\currentfieldbody
]
[
\s!parent
=
\??fieldlabel
]
%
509
\setupfieldcontentframed
[
\currentfieldbody
]
[
\s!parent
=
\??fieldcontent
]
%
510
\definefieldcategory
[
\currentfieldbody
]
%
511
\setupfieldbody
[
\currentfieldbody
]
[
\c!category
=
\currentfieldbody
]
%
512
\let
\currentfieldcategory
\currentfieldbody
513
\fi
514
\let
\currentfieldtotalframed
\currentfieldcategory
515
\let
\currentfieldlabelframed
\currentfieldcategory
516
\let
\currentfieldcontentframed
\currentfieldcategory
517
\scrn_field_analyze_setups
518
\ifconditional
\fieldframeshown
519
\inheritedfieldtotalframedframed
% lower framedoffset
520
\bgroup
521
\else
522
\vbox
523
\bgroup
524
\fi
525
\dontcomplain
526
\ifconditional
\fieldlabelshown
527
\scrn_field_set_label_box
528
\fi
529
\scrn_field_set_content_box
530
\ifconditional
\fieldlabelshown
531
\ifconditional
\fieldisvertical
532
\scrn_field_flush_vertical
533
\else
534
\scrn_field_flush_horizontal
535
\fi
536
\else
537
\scrn_field_flush_content
538
\fi
539
\egroup
540
\endgroup
541
\fi
}
542 543
% opties: veld, label, kader, vertikaal/horizontaal
544 545
\newbox
\b_scrn_field_label
546
\newbox
\b_scrn_field_content
547 548
% lower framedoffset
549 550
\def
\scrn_field_set_label_box
551
{
\setbox
\b_scrn_field_label
\hbox
552
{
\reshapeframeboxtrue
% else wrong dimensions % still needed?
553
\inheritedfieldlabelframedframed
554
{
\currentfieldlabel
}
}
}
555 556
% \c!fieldoffset=-\framedoffset,\c!fieldbackgroundcolor=,
557
% \hbox{\lower\@@fdfieldoffset\hbox{\typesetfield}}
558 559
\def
\scrn_field_set_content_box
560
{
\setbox
\b_scrn_field_content
\hbox
561
{
\reshapeframeboxtrue
% else wrong dimensions (to be checked)
562
\doifnothing
{
\fieldcontentframedparameter
\c!height
}
563
{
\ifconditional
\fieldisvertical
564
\setfieldcontentframedparameter
\c!height
{
6
ex
}
%
565
\else
\ifconditional
\fieldishorizontal
566
\setfieldcontentframedparameter
\c!height
{
\vsize
}
%
567
\else
568
\setfieldcontentframedparameter
\c!height
{
2
cm
}
%
569
\fi
\fi
}
%
570
\doifnothing
{
\fieldcontentframedparameter
\c!width
}
571
{
\ifconditional
\fieldisvertical
572
\setfieldcontentframedparameter
\c!width
{
\hsize
}
%
573
\else
\ifconditional
\fieldishorizontal
574
\setfieldcontentframedparameter
\c!width
{
2
0
em
}
%
575
\else
576
\setfieldcontentframedparameter
\c!width
{
2
cm
}
%
577
\fi
\fi
}
%
578
\inheritedfieldcontentframedframed
% lower framedoffset
579
{
\fieldbody
580
[
\currentfieldbody
]
581
[
\c!width
=
\framedwidth
,
\c!height
=
\framedheight
]
}
}
}
582 583 584
\def
\scrn_field_flush_vertical
585
{
\vbox
586
{
\copy
\b_scrn_field_label
587
\fieldtotalframedparameter
\c!inbetween
588
\copy
\b_scrn_field_content
}
}
589 590
\def
\scrn_field_flush_horizontal
591
{
\hbox
592
{
\vbox
\ifdim
\ht
\b_scrn_field_content
>
\ht
\b_scrn_field_label
to
\ht
\b_scrn_field_content
\fi
593
{
\fieldtotalframedparameter
\c!before
594
\copy
\b_scrn_field_label
595
\fieldtotalframedparameter
\c!after
}
%
596
\hskip
\fieldtotalframedparameter
\c!distance
597
\vbox
\ifdim
\ht
\b_scrn_field_label
>
\ht
\b_scrn_field_content
to
\ht
\b_scrn_field_label
\fi
598
{
\fieldtotalframedparameter
\c!before
599
\box
\b_scrn_field_content
600
\fieldtotalframedparameter
\c!after
}
}
}
601 602
\def
\scrn_field_flush_content
603
{
\box
\b_scrn_field_content
}
604 605
%D todo: replace \processallactionsinset
606 607
\def
\scrn_field_analyze_setups
608
{
\setfalse
\fieldlabelshown
609
\setfalse
\fieldframeshown
610
\setfalse
\fieldishorizontal
611
\setfalse
\fieldisvertical
612
\normalexpanded
{
\processallactionsinset
[
\fieldtotalframedparameter
\c!alternative
]
}
613
[
\v!reset
=
>
\setfalse
\fieldlabelshown
614
\setfalse
\fieldframeshown
615
\setfalse
\fieldishorizontal
616
\setfalse
\fieldisvertical
,
617
\v!label
=
>
\settrue
\fieldlabelshown
,
618
\v!frame
=
>
\settrue
\fieldframeshown
,
619
\v!horizontal
=
>
\settrue
\fieldishorizontal
,
620
\v!vertical
=
>
\settrue
\fieldisvertical
]
%
621
\ifconditional
\fieldisvertical
622
\setupfieldtotalframed
[
\c!distance
=
\zeropoint
,
\c!inbetween
=
\vskip
\d_framed_local_offset
,
\c!align
=
\v!right
,
\c!width
=
2
0
em
]
%
623
\else
\ifconditional
\fieldishorizontal
624
\setupfieldtotalframed
[
\c!distance
=
\d_framed_local_offset
,
\c!inbetween
=
,
\c!align
=
\c!left
,
\c!height
=
1
0
ex
]
%
625
\else
626
\setupfieldtotalframed
[
\c!distance
=
\zeropoint
,
\c!inbetween
=
,
\c!align
=
\c!left
]
%
627
\fi
\fi
628
\setupfieldtotalframed
[
\c!n
=
,
\c!before
=
,
\c!after
=
\vss
,
\c!style
=
,
\c!color
=
]
}
629 630
%D Common stuff (obsolete)
631 632 633
\newcount
\c_scrn_field_system_n
634 635
\def
\currentsystemfield
{
sys
:
:
\number
\c_scrn_field_system_n
}
636 637
\unexpanded
\def
\nextsystemfield
638
{
\global
\advance
\c_scrn_field_system_n
\plusone
}
639 640
%D \CONTEXT\ had tooltips right from the moment that it
641
%D supported fields. Due to the at that moment somewhat
642
%D limited \PDF\ specification, they were implemented
643
%D using \JAVASCRIPT, but nowadays more kind of actions
644
%D are supported, so we can do without. The \MKIV\ version
645
%D also supports definition of tooltips and configuration.
646
%D
647
%D \starttyping
648
%D before \tooltip[right]{inbetween}{a very nice tip} after\par
649
%D before \tooltip[align=normal]{inbetween}{a very\\nice tip} after\par
650
%D before \tooltip[middle]{inbetween}{a very nice tip} after\par
651
%D before \tooltip[left]{inbetween}{a very nice tip} after\par
652
%D \stoptyping
653 654
\newbox
\b_scrn_tooltip_anchor
655
\newbox
\b_scrn_tooltip_text
656
\newcount
\c_scrn_tooltip_n
657 658
\installcorenamespace
{
tooltip
}
659 660
\installframedcommandhandler
\??tooltip
{
tooltip
}
\??tooltip
661 662
\setuptooltip
663
[
\c!location
=
\v!right
,
664
\c!frame
=
\v!off
,
665
\c!offset
=
.
1
ex
,
666
\c!background
=
\v!color
,
667
\c!backgroundcolor
=
gray
]
668 669
\appendtoks
670
\setuevalue
\currenttooltip
{
\scrn_tooltip_direct
{
\currenttooltip
}
}
%
671
\to
\everydefinetooltip
672 673
\unexpanded
\def
\scrn_tooltip_direct
#
tag
%
674
{
\def
\currenttooltip
{
#
tag
}
%
675
\doifelselocation
676
{
\dosingleempty
\scrn_tooltip_indeed
}
677
{
\dosingleempty
\scrn_tooltip_ignore
}
}
678 679
\def
\scrn_tooltip_ignore
[
#
settings
]
#
anchortext
#
tiptext
%
680
{
#
anchortext
}
681 682
\def
\scrn_tooltip_indeed
[
#
settings
]
#
anchortext
#
tiptext
% a more modern aproach (push buttons)
683
{
\dontleavehmode
\hbox
\bgroup
684
\dontcomplain
685
\global
\advance
\c_scrn_tooltip_n
\plusone
686
\edef
\currenttooltipname
{
tooltip
:
\number
\c_scrn_tooltip_n
}
%
687
\setbox
\b_scrn_tooltip_anchor
\hbox
688
{
\strut
#
anchortext
}
%
689
\doifelseassignment
{
#
settings
}
690
{
\setupcurrenttooltip
[
#
settings
]
}
%
691
{
\setupcurrenttooltip
[
\c!location
=
#
settings
]
}
%
692
\setbox
\b_scrn_tooltip_text
\hbox
693
{
\lettooltipparameter
\c!location
\empty
694
\inheritedtooltipframed
{
#
tiptext
}
}
%
695
\definesymbol
696
[
\currenttooltipname
:
txt
]
697
[
\copy
\b_scrn_tooltip_text
]
%
698
\definefieldbody
699
[
\currenttooltipname
:
txt
]
700
[
\c!type
=
push
,
701
\c!width
=
\wd
\b_scrn_tooltip_text
,
702
\c!height
=
\ht
\b_scrn_tooltip_text
,
703
\c!depth
=
\dp
\b_scrn_tooltip_text
,
704
\c!option
=
\v!hidden
,
705
\c!values
=
\currenttooltipname
:
txt
]
%
706
\setbox
\b_scrn_tooltip_text
\hbox
707
{
\fieldbody
[
\currenttooltipname
:
txt
]
}
%
708
\setbox
\b_scrn_tooltip_text
\hbox
709
{
\strut
\lower
\dimexpr
.
2
5
ex
+
\ht
\b_scrn_tooltip_text
\relax
\box
\b_scrn_tooltip_text
}
%
710
\edef
\currenttooltiplocation
{
\tooltipparameter
\c!location
}
%
711
\ifx
\currenttooltiplocation
\v!left
712
\hsmashed
{
\hskip
\wd
\b_scrn_tooltip_anchor
\llap
{
\box
\b_scrn_tooltip_text
}
}
%
713
\else
\ifx
\currenttooltiplocation
\v!middle
714
\hsmashed
to
\wd
\b_scrn_tooltip_anchor
{
\hss
\box
\b_scrn_tooltip_text
\hss
}
%
715
\else
716
\hsmashed
{
\box
\b_scrn_tooltip_text
}
%
717
\fi
\fi
718
\definesymbol
719
[
\currenttooltipname
:
but
]
720
[
\hphantom
{
\copy
\b_scrn_tooltip_anchor
}
]
%
721
\definefieldbody
722
[
\currenttooltipname
:
but
]
723
[
\c!type
=
push
,
724
\c!regionin
=
action
(
show
{
\currenttooltipname
:
txt
}
)
,
725
\c!regionout
=
action
(
hide
{
\currenttooltipname
:
txt
}
)
,
726
\c!width
=
\wd
\b_scrn_tooltip_anchor
,
727
\c!height
=
\ht
\b_scrn_tooltip_anchor
,
728
\c!depth
=
\dp
\b_scrn_tooltip_anchor
]
%
729
\hsmashed
{
\fieldbody
[
\currenttooltipname
:
but
]
}
%
730
\egroup
731
#
anchortext
}
% when hyphenated the text wil stick out ... such are fields and we cannot use a link here
732 733
\definetooltip
[
tooltip
]
734 735
%D From messages on the mailing list we can conclude that
736
%D fieldstacks are used so we keep them in the core:
737
%D
738
%D \starttyping
739
%D \definesymbol[one] [one]
740
%D \definesymbol[two] [two]
741
%D \definesymbol[three][three]
742
%D
743
%D \definefieldstack[mine][one,two,three]
744
%D \fieldstack[mine]
745
%D \fieldstack[mine]
746
%D
747
%D \goto{walk field}[Walk{mine}]
748
%D \stoptyping
749 750
% todo: expand #symbols
751 752
\installcorenamespace
{
fieldstack
}
753 754
\unexpanded
\def
\definefieldstack
755
{
\dotripleargument
\scrn_fieldstack_define
}
756 757
\def
\scrn_fieldstack_define
[
#
tag
]
[
#
symbols
]
[
#
settings
]
%
758
{
\ifcsname
\??fieldstack
#
tag
\endcsname
759
% already done
760
\else
761
%setgvalue{\??fieldstack#tag}{\scrn_fieldstack_construct[#tag][#symbols][#settings]}%
762
\setxvalue
{
\??fieldstack
#
tag
}
{
\scrn_fieldstack_construct
[
#
tag
]
[
#
symbols
]
[
\normalunexpanded
{
#
settings
}
]
}
%
763
\fi
}
764 765
\unexpanded
\def
\fieldstack
766
{
\dotripleempty
\scrn_fieldstack_direct
}
767 768
\def
\scrn_fieldstack_direct
[
#
tag
]
[
#
symbols
]
[
#
settings
]
%
769
{
\ifsecondargument
770
\scrn_fieldstack_define
[
#
tag
]
[
#
symbols
]
[
#
settings
]
%
771
\fi
772
\csname
\??fieldstack
#
tag
\endcsname
}
773 774
\newbox
\b_scrn_fieldstack_box
775 776
\definesymbol
[
\s!empty
]
[
]
777 778
\def
\scrn_fieldstack_add
#
tag
#
settings
#
symbol
%
779
{
\advance
\scratchcounter
\plusone
780
\edef
\currentfieldstackname
{
#
tag
:
\number
\scratchcounter
}
%
781
\ifnum
\scratchcounter
=
\fieldcategoryparameter
\c!start
\relax
782
\definefieldbody
[
\currentfieldstackname
]
[
\c!type
=
check
,
\c!values
=
{
#
symbol
,
\s!empty
}
,
\c!default
=
{
#
symbol
}
]
%
783
\else
784
\definefieldbody
[
\currentfieldstackname
]
[
\c!type
=
check
,
\c!values
=
{
#
symbol
,
\s!empty
}
,
\c!default
=
\s!empty
]
%
785
\fi
786
\setbox
\b_scrn_fieldstack_box
\hbox
{
\symbol
[
#
symbol
]
}
%
787
\setcollector
788
[
fieldstack
]
789
{
\fieldbody
790
[
\currentfieldstackname
]
791
[
\c!option
=
{
\v!readonly
}
,
792
\c!width
=
\wd
\b_scrn_fieldstack_box
,
793
\c!height
=
\ht
\b_scrn_fieldstack_box
,
794
\c!depth
=
\dp
\b_scrn_fieldstack_box
,
795
#
settings
]
}
}
796 797
\unexpanded
\def
\scrn_fieldstack_construct
[
#
tag
]
[
#
symbols
]
[
#
settings
]
% start=n, 0 == leeg
798
{
\iflocation
799
\dontleavehmode
800
\begingroup
801
\setupfieldcategory
[
\c!start
=
1
,
#
settings
]
% was just \??fieldcategory
802
\scrn_field_load_scripts
803
\definecollector
804
[
fieldstack
]
%
805
[
\c!corner
=
\v!middle
,
806
\c!location
=
\v!middle
]
%
807
\scratchcounter
\zerocount
808
\processcommalist
[
#
symbols
]
{
\scrn_fieldstack_add
{
#
tag
}
{
#
settings
}
}
%
809
\flushcollector
[
fieldstack
]
%
810
\endgroup
811
\fi
}
812 813
%D Another goodie. Two actions can be hookes into an overlay.
814
%D
815
%D \starttyping
816
%D \defineviewerlayer[test]
817
%D
818
%D \startviewerlayer[test]Hide Me\stopviewerlayer
819
%D
820
%D \defineoverlay
821
%D [WithTest]
822
%D [{\overlayrollbutton[HideLayer{test}][VideLayer{test}]}]
823
%D
824
%D \framed[background=WithTest]{toggle}
825
%D \stoptyping
826 827
\newcount
\c_scrn_rollbutton_n
828 829
\unexpanded
\def
\overlayrollbutton
830
{
\dodoubleargument
\scrn_rollbutton_overlay
}
831 832
\unexpanded
\def
\scrn_rollbutton_overlay
[
#
regionin
]
[
#
regionout
]
%
833
{
\iffirstargument
834
\scrn_rollbutton_overlay_indeed
[
#
regionin
]
[
#
regionout
]
%
835
\else
836
\expandafter
\scrn_rollbutton_overlay_indeed
837
\fi
}
838 839
% \def\scrn_rollbutton_overlay_indeed#regionin#regionout%
840
% {\iflocation
841
% \bgroup
842
% \global\advance\c_scrn_rollbutton_n\plusone
843
% \definesymbol
844
% [rollbutton:\number\c_scrn_rollbutton_n]
845
% [{\framed[\c!frame=\v!off,\c!width=\overlaywidth,\c!height=\overlayheight]{}}]%
846
% \definefieldbody
847
% [rollbutton:\number\c_scrn_rollbutton_n]
848
% [\c!type=push,
849
% \c!regionin={#regionin},
850
% \c!regionout={#regionout},
851
% \c!values=\currentsystemfield,
852
% \c!default=\currentsystemfield]%
853
% \fitfield[\currentsystemfield]%
854
% \egroup
855
% \fi}
856 857
\def
\scrn_rollbutton_overlay_indeed
#
regionin
#
regionout
%
858
{
\iflocation
859
\bgroup
860
\global
\advance
\c_scrn_rollbutton_n_button
\plusone
861
\global
\advance
\c_scrn_rollbutton_n_symbol
\plusone
862
\definesymbol
863
[
rollsymbol
:
\number
\c_scrn_rollbutton_n_symbol
]
864
[
{
\framed
[
\c!frame
=
\v!off
,
\c!width
=
\overlaywidth
,
\c!height
=
\overlayheight
]
{
}
}
]
%
865
% \definefieldbody
866
% [rollbutton:\number\c_scrn_rollbutton_n_button]
867
% [\c!type=push,
868
% \c!values=rollsymbol:\number\c_scrn_rollbutton_n_symbol,
869
% \c!default=rollsymbol:\number\c_scrn_rollbutton_n_symbol]%
870
% \fitfield
871
% [rollbutton:\number\c_scrn_rollbutton_n_button]%
872
% [\c!regionin={#regionin},
873
% \c!regionout={#regionout}]%
874
%
875
\definefield
876
[
rollbutton
:
\number
\c_scrn_rollbutton_n_button
]
[
push
]
[
rollbutton
]
877
[
rollsymbol
:
\number
\c_scrn_rollbutton_n_symbol
]
%
878
\fitfield
879
[
rollbutton
:
\number
\c_scrn_rollbutton_n_button
]
%
880
[
\c!regionin
=
{
#
regionin
}
,
\c!regionout
=
{
#
regionout
}
]
%
881
%
882
\egroup
883
\fi
}
884 885
% \protect \endinput % THE FOLLOWING CODE IS NOT CHECKED
886 887
%D I will redo these when I need them.
888 889
% \setupinteraction[state=start]
890
%
891
% \definepushbutton [reset]
892
%
893
% \startuniqueMPgraphic{whatever}{color}
894
% fill fullcircle xysized (OverlayWidth,OverlayHeight) withcolor \MPvar{color} ;
895
% \stopuniqueMPgraphic
896
%
897
% \definepushsymbol [reset] [n] [\uniqueMPgraphic{whatever}{color=red}]
898
% \definepushsymbol [reset] [r] [\uniqueMPgraphic{whatever}{color=green}]
899
% \definepushsymbol [reset] [d] [\uniqueMPgraphic{whatever}{color=blue}]
900
%
901
% \starttext
902
% \startTEXpage
903
% \pushbutton [reset] [page(2)]
904
% \stopTEXpage
905
% \startTEXpage
906
% \pushbutton [reset] [page(1)]
907
% \stopTEXpage
908
% \stoptext
909 910
\newcount
\c_scrn_pushbutton_n
911 912
\unexpanded
\def
\definepushbutton
% name optional setup
913
{
\dodoubleempty
\scrn_pushbutton_define
}
914 915
\def
\scrn_pushbutton_define
[
#
tag
]
[
#
settings
]
%
916
{
\scrn_pushbutton_define_variant
{
#
tag
}
{
n
}
{
push
}
%
917
\scrn_pushbutton_define_variant
{
#
tag
}
{
r
}
{
\symbol
[
pushsymbol
:
#
tag
:
n
]
}
%
918
\scrn_pushbutton_define_variant
{
#
tag
}
{
d
}
{
\symbol
[
pushsymbol
:
#
tag
:
r
]
}
%
919
\setvalue
{
pushbutton
:
#
tag
}
{
\scrn_pushbutton_handle
{
#
tag
}
{
#
settings
}
}
}
920 921
\def
\scrn_pushbutton_define_variant
#
tag
#
variant
#
content
%
922
{
\doifelsesymboldefined
{
pushsymbol
:
#
tag
:
#
variant
}
923
\donothing
924
{
\definesymbol
[
pushsymbol
:
#
tag
:
#
variant
]
[
{
#
content
}
]
}
}
925 926
\def
\scrn_pushbutton_handle
#
tag
#
settings
#
reference
%
927
{
\bgroup
928
\global
\advance
\c_scrn_pushbutton_n
\plusone
929
\setupfield
930
[
pushbutton
]
%
931
[
\c!frame
=
\v!overlay
,
%
932
\c!offset
=
\v!overlay
,
%
933
\c!clickout
=
{
#
reference
}
,
%
934
#
settings
]
%
935
\definefield
936
[
pushbutton
:
\number
\c_scrn_pushbutton_n
]
%
937
[
push
]
%
938
[
pushbutton
]
%
939
[
pushsymbol
:
#
tag
:
n
,
pushsymbol
:
#
tag
:
r
,
pushsymbol
:
#
tag
:
d
]
%
940
\fitfield
941
[
pushbutton
:
\number
\c_scrn_pushbutton_n
]
%
942
\egroup
}
943 944
\unexpanded
\def
\definepushsymbol
945
{
\dotripleargument
\scrn_pushsymbol_define
}
946 947
\def
\scrn_pushsymbol_define
[
#
tag
]
[
#
variant
]
% [#reference]
948
{
\definesymbol
[
pushsymbol
:
#
tag
:
#
variant
]
}
949 950
\def
\pushbutton
951
{
\dodoubleargument
\scrn_pushbutton_direct
}
952 953
\def
\scrn_pushbutton_direct
[
#
tag
]
[
#
variant
]
%
954
{
\executeifdefined
{
pushbutton
:
#
tag
}
\gobbleoneargument
{
#
variant
}
}
955 956
%D We plug into the menu system
957 958
\unexpanded
\def
\scrn_menu_psh_start
[
#
reference
]
#
text
\stoppsh
959
{
\starttxt
\pushbutton
[
\currentinteractionmenu
]
[
#
reference
]
\stoptxt
}
960 961
\unexpanded
\def
\scrn_menu_psh_direct
[
#
reference
]
#
text
\\
962
{
\scrn_menu_psh_start
[
#
reference
]
\stoprob
}
963 964
\appendtoks
965
\let
\startpsh
\scrn_menu_psh_start
966
\let
\stoppsh
\relax
967
\let
\psh
\scrn_menu_psh_direct
968
\to
\everysetmenucommands
969 970
%D Another goodie: (unchecked in \MKIV)
971 972
% calls:
973
% {..} [JS..]
974
% [left] {..} [JS..]
975
% [a=b] {..} [JS..]
976
% [left] [a=b] {..} [JS..]
977
%
978
% \setupbuttons[offset=0pt,frame=off] % alternative=hidden
979
%
980
% \rollbutton {Manuals} [JS(Goto_File{show-man.pdf})]
981
% \rollbutton {Articles} [JS(Goto_File{show-art.pdf})]
982
% \rollbutton {Papers} [JS(Goto_File{show-pap.pdf})]
983
% \rollbutton {Presentations} [JS(Goto_File{show-pre.pdf})]
984
% \rollbutton {Resources} [JS(Goto_File{show-res.pdf})]
985
%
986
% \rob [JS(...)] bla bla \\
987 988
% \definecolor[rollover:n][red]
989
% \definecolor[rollover:r][green]
990
% \definecolor[rollover:d][blue]
991 992
\definepalet
993
[
rollover
]
994
[
n
=
red
,
995
r
=
green
,
996
d
=
blue
]
997 998
\newcount
\c_scrn_rollbutton_n_button
999
\newcount
\c_scrn_rollbutton_n_symbol
1000 1001
\def
\lastrollbuttonindex
{
\the
\c_scrn_rollbutton_n_button
}
1002 1003
\unexpanded
\def
\rollbutton
1004
{
\dodoubleempty
\scrn_rollbutton
}
1005 1006
\def
\scrn_rollbutton_symbol_m
1007
{
\scrn_rollbutton_symbol_indeed
1008
\interactionmenuparameter
1009
\inheritedinteractionmenuframed
1010
\setinteractionmenuparameter
1011
\useinteractionmenustyleandcolor
}
1012 1013
\def
\scrn_rollbutton_symbol_b
1014
{
\scrn_rollbutton_symbol_indeed
1015
\buttonparameter
1016
\inheritedbuttonframed
1017
\setbuttonparameter
1018
\usebuttonstyleandcolor
}
1019 1020
\setupfield
1021
[
rollbutton
]
1022
[
\c!frame
=
\v!off
,
1023
\c!offset
=
\v!overlay
]
1024 1025
\def
\scrn_rollbutton
[
#
tag
]
[
#
settings
]
#
text
[
#
reference
]
%
1026
{
\dontleavehmode
1027
\bgroup
1028
\global
\advance
\c_scrn_rollbutton_n_button
\plusone
1029
\global
\advance
\c_scrn_rollbutton_n_symbol
\plusone
1030
\iffirstargument
1031
\ifsecondargument
1032
\edef
\currentinteractionmenu
{
#
tag
}
%
1033
\setupcurrentinteractionmenu
[
#
settings
]
%
1034
\let
\scrn_rollbutton_symbol
\scrn_rollbutton_symbol_m
1035
\else
1036
\doifelseassignment
{
#
tag
}
1037
{
\let
\currentbutton
\empty
1038
\setupcurrentbutton
[
#
tag
]
%
1039
\let
\scrn_rollbutton_symbol
\scrn_rollbutton_symbol_b
}
%
1040
{
\edef
\currentinteractionmenu
{
#
tag
}
%
1041
\let
\scrn_rollbutton_symbol
\scrn_rollbutton_symbol_m
}
%
1042
\fi
1043
\else
1044
\let
\scrn_rollbutton_symbol
\scrn_rollbutton_symbol_b
1045
\fi
1046
% todo: share symbols, tricky since different dimensions (maybe \unique...)
1047
\definesymbol
[
rollsymbol
:
\number
\c_scrn_rollbutton_n_symbol
:
n
]
[
\scrn_rollbutton_symbol
{
n
}
{
#
text
}
]
%
1048
\definesymbol
[
rollsymbol
:
\number
\c_scrn_rollbutton_n_symbol
:
r
]
[
\scrn_rollbutton_symbol
{
r
}
{
#
text
}
]
%
1049
\definesymbol
[
rollsymbol
:
\number
\c_scrn_rollbutton_n_symbol
:
d
]
[
\scrn_rollbutton_symbol
{
d
}
{
#
text
}
]
%
1050
\definefield
1051
[
rollbutton
:
\number
\c_scrn_rollbutton_n_button
]
[
push
]
[
rollbutton
]
1052
[
rollsymbol
:
\number
\c_scrn_rollbutton_n_symbol
:
n
,
%
1053
rollsymbol
:
\number
\c_scrn_rollbutton_n_symbol
:
r
,
%
1054
rollsymbol
:
\number
\c_scrn_rollbutton_n_symbol
:
d
]
%
1055
\fitfield
1056
[
rollbutton
:
\number
\c_scrn_rollbutton_n_button
]
%
1057
[
\c!clickout
=
{
#
reference
}
]
%
1058
\egroup
}
1059 1060
\unexpanded
\def
\scrn_rollbutton_symbol_indeed
#
getparameter
#
inheritedframed
#
setparameter
#
usestyleandcolor
#
what
#
text
%
1061
{
\definecolor
[
rollover
]
[
rollover
:
#
what
]
%
1062
\doifelse
{
#
what
}
{
n
}
% ?
1063
{
\doifelse
{
#
getparameter
\c!alternative
}
\v!hidden
\phantom
\hbox
}
\hbox
1064
{
#
setparameter
\c!framecolor
{
rollover
}
%
1065
#
setparameter
\c!backgroundcolor
{
rollover
}
%
1066
#
setparameter
\c!color
{
rollover
}
%
1067
#
inheritedframed
{
#
usestyleandcolor
\c!style
\c!color
{
#
text
}
}
}
}
1068 1069
%D We plug into the menu system
1070 1071
\unexpanded
\def
\scrn_menu_rob_start
[
#
reference
]
#
text
\stoprob
1072
{
\starttxt
\rollbutton
[
\currentinteractionmenu
]
{
\ignorespaces
#
text
\unskip
}
[
#
reference
]
\stoptxt
}
1073 1074
\unexpanded
\def
\scrn_menu_rob_direct
[
#
reference
]
#
text
\\
1075
{
\scrn_menu_rob_start
[
#
reference
]
#
text
\stoprob
}
1076 1077
\appendtoks
1078
\let
\startrob
\scrn_menu_rob_start
1079
\let
\stoprob
\relax
1080
\let
\rob
\scrn_menu_rob_direct
1081
\to
\everysetmenucommands
1082 1083
\protect
\endinput
1084