1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Screen Macros Progress Bars}
15
16\unprotect
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\installcorenamespace{interactionbar}
61
62\installframedcommandhandler \??interactionbar {interactionbar} \??interactionbar
63
64\unexpanded\def\interactionbar
65 {\dodoubleempty\scrn_bar_direct}
66
67\def\scrn_bar_direct[#tag][#settings]
68 {\iflocation
69 \begingroup
70 \doifelseassignment{#tag}
71 {\let\currentinteractionbar\empty
72 \setupcurrentinteractionbar[#tag]
73 \edef\currentinteractionbar{\interactionbarparameter\c!alternative}}
74 {\edef\currentinteractionbar{#tag}
75 \ifsecondargument\setupcurrentinteractionbar[#settings]\fi}
76 \doif{\interactionbarparameter\c!state}\v!start
77 {\interactionbarparameter\c!command}
78 \endgroup
79 \fi}
80
81\newdimen\d_scrn_bar_width
82\newdimen\d_scrn_bar_height
83\newdimen\d_scrn_bar_depth
84\newdimen\d_scrn_bar_distance
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105\unexpanded\def\interactionbuttons
106 {\dodoubleempty\scrn_bar_buttons}
107
108\def\scrn_bar_buttons
109 {\iflocation
110 \expandafter\scrn_bar_buttons_status
111 \else
112 \expandafter\scrn_bar_buttons_ignore
113 \fi}
114
115\def\scrn_bar_buttons_status[#settings][#list]
116 {\doif{\interactionbarparameter\c!state}\v!start
117 {\ifsecondargument
118 \scrn_bar_buttons_indeed[#settings][#list]
119 \else
120 \scrn_bar_buttons_indeed[][#settings]
121 \fi}}
122
123\def\scrn_bar_buttons_ignore[#settings][#list]
124 {}
125
126\def\scrn_bar_buttons_indeed[#settings][#list]
127 {\begingroup
128
129 \setupcurrentinteractionbar[#settings]
130 \d_scrn_bar_width \interactionbarparameter\c!width\relax
131 \d_scrn_bar_distance\interactionbarparameter\c!distance\relax
132 \ifzeropt\d_scrn_bar_width
133 \d_scrn_bar_width1.5\emwidth
134 \fi
135 \doifnothing{\interactionbarparameter\c!height}{\letinteractionbarparameter\c!height\v!broad}
136 \doifnothing{\interactionbarparameter\c!depth }{\letinteractionbarparameter\c!depth\zeropoint}
137 \letinteractionbarparameter\c!background\empty
138 \setbox2\hbox{\inheritedinteractionbarframed{\symbol[\interactionparameter\c!symbolset][\v!previouspage]}}
139 \scratchheight\ht2
140 \letinteractionbarparameter\c!strut\v!no
141
142 \scratchcounterone\zerocount
143 \processallactionsinset
144 [#list]
145 [ \v!page=>\advance\scratchcounterone\plusfour,
146 \v!subpage=>\advance\scratchcounterone\plusfour,
147 \s!unknown=>\advance\scratchcounterone\plusone]
148 \ifzeropt\d_scrn_bar_width
149 \scratchdimenone\dimexpr2\emwidth\d_scrn_bar_distance\relax
150 \scratchdimentwo\dimexpr\scratchcounterone\scratchdimenone\d_scrn_bar_distance\relax
151 \else
152 \scratchdimenone\d_scrn_bar_width
153 \scratchdimentwo\dimexpr\scratchcounterone\d_scrn_bar_distance\d_scrn_bar_distance\relax
154 \advance\scratchdimenone \scratchdimentwo
155 \divide\scratchdimenone \scratchcounterone
156 \scratchdimentwo\d_scrn_bar_width
157 \fi
158 \hbox to \scratchdimentwo
159 {\setnostrut
160 \startsymbolset[\interactionparameter\c!symbolset]
161 \setupbuttons
162 [#settings,
163 \c!height=\the\scratchheight,
164 \c!width=\the\scratchdimenone]
165 \processallactionsinset
166 [#list]
167 [ \v!page=>\scrn_bar_goto\v!firstpage
168 \scrn_bar_goto\v!nextpage
169 \scrn_bar_goto\v!previouspage
170 \scrn_bar_goto\v!lastpage,
171 \v!subpage=>\scrn_bar_goto\v!firstsubpage
172 \scrn_bar_goto\v!nextsubpage
173 \scrn_bar_goto\v!previoussubpage
174 \scrn_bar_goto\v!lastsubpage,
175 \s!unknown=>\scrn_bar_goto\commalistelement]
176 \unskip
177 \stopsymbolset}
178 \endgroup}
179
180\def\scrn_bar_goto#action
181 {\button{\symbol[#action]}[#action]\hss}
182
183
184
185\def\scrn_bar_alternative_a
186 {\d_scrn_bar_width \interactionbarparameter\c!width
187 \d_scrn_bar_distance\interactionbarparameter\c!distance
188 \d_scrn_bar_height \interactionbarparameter\c!height
189 \d_scrn_bar_depth \interactionbarparameter\c!depth
190 \noindent\hbox to \d_scrn_bar_width \bgroup
191 \dontcomplain
192 \setupblackrules[\c!height=\v!max,\c!depth=\v!max]
193 \scratchdimentwo\dimexpr\d_scrn_bar_width4\emwidth\relax
194 \processaction
195 [\interactionbarparameter\c!step]
196 [ \v!small=>\scratchcounter 20,
197 \v!medium=>\scratchcounter 10,
198 \v!big=>\scratchcounter 5,
199 \s!unknown=>\scratchcounter 10]
200 \scratchdimenone\dimexpr\scratchdimentwo\scratchcounter\relax
201 \setupblackrules[\c!width=\scratchdimenone]
202 \setbox\scratchbox\hbox to \d_scrn_bar_width
203 {\hskip2\emwidth
204 \setbox\scratchbox\hpack{\blackrule[\c!color=\interactionbarparameter\c!backgroundcolor]}
205 \dorecurse\scratchcounter
206 {\hss\normalexpanded{\directgotodumbbox{\copy\scratchbox}[page(\the\numexpr\recurselevel*\lastpage\scratchcounter\relax)]}}
207 \hss
208 \hskip2\emwidth}
209 \wd\scratchbox\zeropoint
210 \box \scratchbox
211 \setupblackrules[\c!width=\emwidth]
212 \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[\v!firstpage]}
213 \hskip\emwidth
214 \ifnum\realpageno>\plusone
215 \hskip\zeropoint\s!plus\numexpr\realpageno\plustwo\relax \s!sp\relax
216 \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[\v!previouspage)]}
217 \fi
218 \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[page(\number\realpageno)]}
219 \ifnum\realpageno<\lastpage\relax
220 \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[\v!nextpage]}
221 \hskip\zeropoint\s!plus\numexpr\lastpage\realpageno\plusone\relax \s!sp\relax
222 \fi
223 \hskip\emwidth
224 \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[\v!lastpage]}
225 \egroup}
226
227\def\scrn_bar_alternative_b
228 {\ifnum\lastpage>\firstpage\relax
229 \interactionbuttons[\v!firstpage,\v!previouspage,\v!nextpage,\v!lastpage]
230 \fi}
231
232\def\scrn_bar_alternative_c
233 {\ifnum\lastpage>\plusone
234 \d_scrn_bar_width\interactionbarparameter\c!width
235 \hbox to \d_scrn_bar_width
236 {\setupblackrules[\c!height=\interactionbarparameter\c!height,\c!depth=\interactionbarparameter\c!depth,\c!width=\emwidth]
237 \scratchdimen\dimexpr(\d_scrn_bar_width4\emwidth)\numexpr\lastpage\minusone\relax\relax
238 \scratchdimenone\numexpr\realpageno\minusone\relax\scratchdimen
239 \scratchdimentwo\numexpr\lastpage\realpageno\relax\scratchdimen
240 \directgotospecbox\interactionbarparameter{\blackrule}[\v!firstpage]
241 \hss
242 \directgotospecbox\interactionbarparameter{\blackrule[\c!width=\scratchdimenone]}[\v!previouspage]
243 \blackrule[\c!color=\interactionbarparameter\c!contrastcolor]
244 \directgotospecbox\interactionbarparameter{\blackrule[\c!width=\scratchdimentwo]}[\v!nextpage]
245 \hss
246 \directgotospecbox\interactionbarparameter{\blackrule}[\v!lastpage]}
247 \fi}
248
249\unexpanded\def\scrn_bar_goto_a#whereto
250 {\symbol[\ifcase#whereto\v!previous\or\v!somewhere\or\v!next\fi]}
251
252\unexpanded\def\scrn_bar_goto_b#whereto
253 {\vrule\s!height\d_scrn_bar_height\s!depth\d_scrn_bar_depth\s!width\scratchdimenone\relax}
254
255\unexpanded\def\scrn_bar_goto_c#whereto
256 {\symbol[\ifcase#whereto\v!previous\or\v!somewhere\or\v!somewhere\or\v!somewhere\or\v!next\fi}
257
258\unexpanded\def\scrn_bar_goto_d#whereto
259 {\vrule \s!width\scratchdimenone \ifcase#whereto
260 \s!height \d_scrn_bar_height \s!depth \d_scrn_bar_depth \or
261 \s!height.5\d_scrn_bar_height \s!depth.5\d_scrn_bar_depth \or
262 \s!height \d_scrn_bar_height \s!depth \d_scrn_bar_depth \or
263 \s!height.5\d_scrn_bar_height \s!depth.5\d_scrn_bar_depth \else
264 \s!height \d_scrn_bar_height \s!depth \d_scrn_bar_depth \fi}
265
266\newconstant\c_scrn_bar_mode
267
268\unexpanded\def\scrn_bar_goto_x#command
269 {\doifelse{\interactionbarparameter\c!symbol}\v!yes
270 {\setupsymbolset[\interactionparameter\c!symbolset]
271 \let\scrn_bar_goto_indeed\scrn_bar_goto_a}
272 {\let\scrn_bar_goto_indeed\scrn_bar_goto_b}
273 \dorecurse\nofsubpages
274
275 {\scratchcounter\therealsubpageno\recurselevel
276 \c_scrn_bar_mode
277 \ifnum\scratchcounter<\realpageno \zerocount \else
278 \ifnum\scratchcounter=\realpageno \plusone \else
279 \plustwo \fi\fi
280 \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\scrn_bar_goto_indeed\c_scrn_bar_mode}[page(\the\scratchcounter)]}
281 #command}
282 \unskip}
283
284\def\scrn_bar_alternative_d
285 {\ifnum\nofsubpages>\plusone \doif{\namedcounterparameter\s!subpage\c!state}\v!start{
286 \d_scrn_bar_width \interactionbarparameter\c!width
287 \d_scrn_bar_distance\interactionbarparameter\c!distance
288 \d_scrn_bar_height \interactionbarparameter\c!height
289 \d_scrn_bar_depth \interactionbarparameter\c!depth
290 \scratchdimenone\d_scrn_bar_width
291 \noindent\hbox{\scrn_bar_goto_x{\hskip\d_scrn_bar_distance}}
292 }\fi}
293
294\def\scrn_bar_alternative_e
295 {\ifnum\nofsubpages>\plusone \doif{\namedcounterparameter\s!subpage\c!state}\v!start{
296 \d_scrn_bar_width \interactionbarparameter\c!width
297 \d_scrn_bar_distance\interactionbarparameter\c!distance
298 \d_scrn_bar_height \interactionbarparameter\c!height
299 \d_scrn_bar_depth \interactionbarparameter\c!depth
300 \scratchdimentwo\dimexpr\nofsubpages\d_scrn_bar_distance\d_scrn_bar_distance\relax
301 \scratchdimenone\dimexpr(\d_scrn_bar_width\scratchdimentwo)\nofsubpages\relax
302 \ifdim\scratchdimenone<\d_scrn_bar_distance
303 \scrn_bar_alternative_f
304 \else
305 \noindent\hbox to \d_scrn_bar_width{\scrn_bar_goto_x{\hss}\unskip}
306 \fi
307 }\fi}
308
309\def\scrn_bar_alternative_f
310 {\ifnum\nofsubpages>\plusone \doif{\namedcounterparameter\s!subpage\c!state}\v!start{
311 \d_scrn_bar_width \interactionbarparameter\c!width
312 \d_scrn_bar_distance\interactionbarparameter\c!distance
313 \d_scrn_bar_height \interactionbarparameter\c!height
314 \d_scrn_bar_depth \interactionbarparameter\c!depth
315 \noindent \hbox to \d_scrn_bar_width \bgroup
316 \doloop
317 {\scratchcounterthree\numexpr(\nofsubpages\recurselevel)\plusone\relax
318 \scratchdimentwo\d_scrn_bar_distance
319 \multiply\scratchdimentwo \scratchcounterthree
320 \advance\scratchdimentwo \d_scrn_bar_distance
321 \scratchdimenone\d_scrn_bar_width
322 \advance\scratchdimenone \scratchdimentwo
323 \divide\scratchdimenone \scratchcounterthree
324 \ifdim\scratchdimenone<\d_scrn_bar_distance\else
325 \scratchcountertwo\recurselevel
326 \exitloop
327 \fi}
328 \ifnum\scratchcounterthree>\plusone
329
330 \advance\scratchcounterthree \minustwo
331 \scratchdimenone\d_scrn_bar_distance
332 \scratchdimenone\scratchcounterthree\scratchdimenone
333 \advance\scratchdimenone \d_scrn_bar_width
334 \advance\scratchcounterthree \plusone
335 \divide\scratchdimenone \scratchcounterthree
336 \fi
337 \doifelse{\interactionbarparameter\c!symbol}\v!yes
338 {\setupsymbolset[\interactionparameter\c!symbolset]
339 \let\scrn_bar_goto_indeed\scrn_bar_goto_c}
340 {\let\scrn_bar_goto_indeed\scrn_bar_goto_d}
341 \scratchcounterthree\numexpr\realpageno\plustwo\relax
342 \scratchcounterfour\numexpr\realpageno\plustwo\relax
343 \ifnum\scratchcounterthree<\plusone \scratchcounterthree\plusone \fi
344 \scratchcounterfive\zerocount
345 \dostepwiserecurse\firstsubpage\lastsubpage\plusone
346 {\donefalse
347 \advance\scratchcounterfive \plusone
348 \ifnum\recurselevel=\firstsubpage\relax \donetrue \fi
349 \ifnum\recurselevel=\lastsubpage \relax \donetrue \fi
350 \scratchcountersix\therealsubpageno\recurselevel\relax
351 \c_scrn_bar_mode
352 \ifdone
353 \ifnum\scratchcountersix<\realpageno
354 \zerocount
355 \else\ifnum\scratchcountersix>\realpageno
356 \plustwo
357 \else
358 \plusfour
359 \fi\fi
360 \else
361 \ifnum\scratchcounterfive=\scratchcountertwo
362 \ifnum\scratchcountersix<\realpageno
363 \plusone
364 \else\ifnum\scratchcountersix>\realpageno
365 \plusthree
366 \else
367 \plustwo
368 \fi\fi
369 \else
370 \minusone
371 \fi
372 \fi
373 \ifnum\c_scrn_bar_mode<\zerocount\else
374 \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\scrn_bar_goto_indeed\c_scrn_bar_mode}[realpage(\the\scratchcountersix)]}
375 \hss
376 \scratchcounterfive\zerocount
377 \fi}
378 \unskip
379 \egroup
380 }\fi}
381
382\def\scrn_bar_alternative_g
383 {\ifnum\lastsubpage>\firstsubpage\relax
384 \interactionbuttons[\v!firstsubpage,\v!previoussubpage,\v!nextsubpage,\v!lastsubpage]
385 \fi}
386
387\setupinteractionbar
388 [\c!state=\v!start,
389 \c!alternative=a,
390 \c!symbol=\v!no,
391 \c!width=10\emwidth,
392 \c!height=.5\emwidth,
393 \c!depth=\zeropoint,
394 \c!distance=.5\emwidth,
395 \c!step=\v!medium,
396 \c!foregroundcolor=\interactionbarparameter\c!color,
397 \c!foregroundstyle=\interactionbarparameter\c!style,
398 \c!color=\interactionparameter\c!color,
399 \c!contrastcolor=\interactionparameter\c!contrastcolor,
400 \c!style=,
401 \c!frame=\v!on,
402 \c!background=color,
403 \c!backgroundcolor=gray,
404 \c!samepage=\v!yes]
405
406\defineinteractionbar[a][\c!command=\scrn_bar_alternative_a]
407\defineinteractionbar[b][\c!command=\scrn_bar_alternative_b,\c!height=\v!broad]
408\defineinteractionbar[c][\c!command=\scrn_bar_alternative_c,\c!height=\v!max,\c!depth=\v!max]
409\defineinteractionbar[d][\c!command=\scrn_bar_alternative_d,\c!width=.5\emwidth]
410\defineinteractionbar[e][\c!command=\scrn_bar_alternative_e]
411\defineinteractionbar[f][\c!command=\scrn_bar_alternative_f]
412\defineinteractionbar[g][\c!command=\scrn_bar_alternative_g,\c!height=\v!broad]
413
414\protect \endinput
415 |