diff options
Diffstat (limited to 'tex/context/base/scrn-bar.mkiv')
-rw-r--r-- | tex/context/base/scrn-bar.mkiv | 398 |
1 files changed, 398 insertions, 0 deletions
diff --git a/tex/context/base/scrn-bar.mkiv b/tex/context/base/scrn-bar.mkiv new file mode 100644 index 000000000..fd274419d --- /dev/null +++ b/tex/context/base/scrn-bar.mkiv @@ -0,0 +1,398 @@ +%D \module +%D [ file=scrn-bar, % was part of scrn-int +%D version=1995.01.01, +%D title=\CONTEXT\ Core Macros, +%D subtitle=Progress Bars, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +\writestatus{loading}{ConTeXt Screen Macros / Progress Bars} + +\unprotect + +%D The code is a bit upgraded to \MKIV\ but the output is mostly the same. +%D In retrospect this shoul dhave been a module. + +% todo: replace blackrule by stupid rules + +% \setupinteraction[state=start] +% \setupsubpagenumber[state=start] +% +% \startsetups bars +% \vbox +% {\hsize 5cm +% \hbox{\interactionbar[a]}\blank +% \hbox{\interactionbar[b]}\blank +% \hbox{\interactionbar[c]}\blank +% \hbox{\interactionbar[d]}\blank +% \hbox{\interactionbar[e]}\blank +% \hbox{\interactionbar[f]}\blank +% \hbox{\interactionbar[g]}\blank +% } +% \stopsetups +% +% \setupheadertexts[\setups{bars}] +% +% \starttext +% \dorecurse{10}{test \page } +% \stoptext + +\presetlocalframed[\??ib] + +%D First the usual definition code. + +\let\currentinteractionbar\empty + +\def\setinteractionbarparameter#1#2#3{\@EA\def\csname\??ib#1#2\endcsname{#3}} +\def\letinteractionbarparameter #1#2{\@EA\let\csname\??ib#1#2\endcsname} + +\def\interactionbarparameter #1{\csname\dointeractionbarparameter{\??ib\currentinteractionbar}#1\endcsname} +\def\namedinteractionbarparameter#1#2{\csname\dointeractionbarparameter{\??ib#1}#2\endcsname} +\def\interactionbarparameterhash #1{\dointeractionbarparameterhash {\??ib\currentinteractionbar}#1} + +\def\dointeractionbarparameter #1#2{\ifcsname#1#2\endcsname#1#2\else\expandafter\dointeractionbarparentparameter \csname#1\s!parent\endcsname#2\fi} +\def\dointeractionbarparameterhash#1#2{\ifcsname#1#2\endcsname #1\else\expandafter\dointeractionbarparentparameterhash\csname#1\s!parent\endcsname#2\fi} + +\def\dointeractionbarparentparameter #1#2{\ifx#1\relax\s!empty\else\dointeractionbarparameter #1#2\fi} +\def\dointeractionbarparentparameterhash#1#2{\ifx#1\relax \else\dointeractionbarparameterhash#1#2\fi} + +\def\defineinteractionbar{\dodoubleargument\dodefineinteractionbar} +\def\setupinteractionbar {\dodoubleempty \dosetupinteractionbar} +\def\interactionbar {\dodoubleempty \dointeractionbar} + +\def\dosetupinteractionbar[#1][#2]% + {\ifsecondargument + \getparameters[\??ib#1][#2]% + \else + \getparameters[\??ib][#1]% + \fi} + +\def\dodefineinteractionbar[#1][#2]% + {\getparameters + [\??ib#1]% + [\s!parent=\??ib,% +% \c!foregroundcolor=\interactionbarparameter\c!color,% +% \c!foregroundstyle=\interactionbarparameter\c!style,% + #2]} + +\def\dointeractionbar[#1][#2]% + {\iflocation + \begingroup + \doifnot{#1}\v!reset % obsolete, no caching any more + {\doifassignmentelse{#1} + {\getparameters[\??ib][#2]% + \edef\currentinteractionbar{\interactionbarparameter\c!alternative}}% + {\edef\currentinteractionbar{#1}% + \ifsecondargument\getparameters[\??ib#1][#2]\fi}% + \doif{\interactionbarparameter\c!state}\v!start + {\interactionbarparameter\c!command}}% + \endgroup + \fi} + +\newdimen\interactionbarwidth +\newdimen\interactionbarheight +\newdimen\interactionbardepth +\newdimen\interactionbardistance + +%D Interaction buttons, in fact a row of tiny buttons, are +%D typically only used for navigational purposed. The next +%D macro builds such a row based on a specification list. +%D +%D \startbuffer +%D \interactionbuttons[width=\hsize][page,PreviousJump,ExitViewer] +%D \stopbuffer +%D +%D \typebuffer +%D +%D gives +%D +%D \getbuffer +%D +%D Apart from individual entries, one can use \type{page} and +%D \type {subpage} as shortcuts to their four associated buttons. +%D The symbols are derived from the symbols linked to the +%D entries. + +\def\interactionbuttons + {\dodoubleempty\dointeractionbuttons} + +\def\dointeractionbuttons[#1][#2]% er is een verdeel macro \horizontalfractions + {\iflocation + \begingroup + % beware, is already set \let\currentinteractionbar\empty + \doif{\interactionbarparameter\c!state}\v!stop\locationfalse + \iflocation + \ifsecondargument + \let\menuparameter\interactionbarparameter + \setupinteractionbar[#1]% + \interactionbarwidth\interactionbarparameter\c!width + \ifdim\interactionbarwidth=\zeropoint + \interactionbarwidth1.5\emwidth + \fi + \doifnothing\@@ibheight{\letinteractionbarparameter\c!height\v!broad}% + \doifnothing\@@ibdepth {\letinteractionbarparameter\c!depth\!!zeropoint}%%% + \setbox2\hbox{\localframed[\??ib\currentinteractionbar][\c!background=]{\symbol[\@@iasymbolset][\v!previouspage]}}% + \!!heighta\ht2 % needed because we default to nothing + \setupinteractionbar[\c!strut=\v!no]% + \setinteractionparameter\c!width\!!zeropoint + \!!counta\zerocount % new, was 1 + \processallactionsinset + [#2] + [ \v!page=>\advance\!!counta 4, + \v!subpage=>\advance\!!counta 4, + \s!unknown=>\advance\!!counta 1]% + \ifdim\interactionbarwidth=\zeropoint + \!!widtha\dimexpr2\emwidth+\interactionbardistance\relax + \!!widthb\dimexpr\!!counta\!!widtha-\interactionbardistance\relax + \else + \!!widtha\interactionbarwidth + \!!widthb\dimexpr\!!counta\interactionbardistance-\interactionbardistance\relax + \advance\!!widtha -\!!widthb + \divide\!!widtha \!!counta + \!!widthb\interactionbarwidth + \fi + \hbox to \!!widthb + {\setnostrut + \processallactionsinset + [#2] + [ \v!page=>\interactionbargotox\v!firstpage \interactionbargotox\v!nextpage \interactionbargotox\v!previouspage \interactionbargotox\v!lastpage, + \v!subpage=>\interactionbargotox\v!firstsubpage\interactionbargotox\v!nextsubpage\interactionbargotox\v!previoussubpage\interactionbargotox\v!lastsubpage, + \s!unknown=>\interactionbargotox\commalistelement]% + \unskip}% + \else + \interactionbuttons[][#1]% + \fi + \fi + \endgroup + \fi} + +\def\interactionbargotox#1% + {\normalexpanded{\noexpand\dodocomplexbutton +% {\??ib\currentinteractionbar}% + {\??ib}% + [\c!height=\the\!!heighta,\c!width=\the\!!widtha]% + {\noexpand\symbol[\@@iasymbolset][#1]}% + [#1]}% + \hss} + +\def\interactionbara + {\iflocation + \interactionbarwidth \interactionbarparameter\c!width + \interactionbardistance\interactionbarparameter\c!distance + \interactionbarheight \interactionbarparameter\c!height + \interactionbardepth \interactionbarparameter\c!depth + \noindent\hbox to \interactionbarwidth \bgroup + \dontcomplain + \setupblackrules[\c!height=\v!max,\c!depth=\v!max]% + \!!widthb\dimexpr\interactionbarwidth-4\emwidth\relax + \processaction + [\interactionbarparameter\c!step] + [ \v!small=>\scratchcounter 20, + \v!medium=>\scratchcounter 10, + \v!big=>\scratchcounter 5, + \s!unknown=>\scratchcounter 10]% + \!!widtha\dimexpr\!!widthb/\scratchcounter\relax + \setupblackrules[\c!width=\!!widtha]% + \setbox\scratchbox\hbox to \interactionbarwidth + {\hskip2\emwidth + \setbox\scratchbox\hbox{\blackrule[\c!color=\interactionbarparameter\c!backgroundcolor]}% + \dorecurse\scratchcounter + {\hss\normalexpanded{\directgotodumbbox{\copy\scratchbox}[page(\the\numexpr\recurselevel*\lastpage/\scratchcounter\relax)]}}% + \hss + \hskip2\emwidth}% + \wd\scratchbox\zeropoint + \box \scratchbox + \setupblackrules[\c!width=\emwidth]% + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[\v!firstpage]}% + \hskip\emwidth + \ifnum\realpageno>\plusone + \hskip\zeropoint\!!plus\numexpr\realpageno-\plustwo\relax \s!sp\relax % cm gives overflow + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[\v!previouspage)]}% + \fi + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[page(\number\realpageno)]}% todo: \v!currentpage + \ifnum\realpageno<\lastpage\relax + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[\v!nextpage]}% + \hskip\zeropoint\!!plus\numexpr\lastpage-\realpageno-\plusone\relax \s!sp\relax % cm gives overflow + \fi + \hskip\emwidth + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\blackrule}[\v!lastpage]}% + \egroup + \fi} + +\def\interactionbarb + {\ifnum\lastpage>\firstpage\relax + \interactionbuttons[\v!firstpage,\v!previouspage,\v!nextpage,\v!lastpage]% + \fi} + +\def\interactionbarc + {\iflocation \ifnum\lastpage>\plusone + \interactionbarwidth\interactionbarparameter\c!width + \hbox to \interactionbarwidth + {\setupblackrules[\c!height=\interactionbarparameter\c!height,\c!depth=\interactionbarparameter\c!depth,\c!width=\emwidth]% + \scratchdimen\dimexpr(\interactionbarwidth-4\emwidth)/\numexpr\lastpage+\minusone\relax\relax + \!!widtha\numexpr\realpageno+\minusone\relax\scratchdimen + \!!widthb\numexpr\lastpage-\realpageno\relax\scratchdimen + \directgotospecbox\interactionbarparameter{\blackrule}[\v!firstpage]% + \hss + \directgotospecbox\interactionbarparameter{\blackrule[\c!width=\!!widtha]}[\v!previouspage]% + \blackrule[\c!color=\interactionbarparameter\c!contrastcolor]% + \directgotospecbox\interactionbarparameter{\blackrule[\c!width=\!!widthb]}[\v!nextpage]% + \hss + \directgotospecbox\interactionbarparameter{\blackrule}[\v!lastpage]}% + \fi \fi} + +\unexpanded\def\@@commoninteractionbargotoa#1% + {\symbol[\ifcase#1\v!previous\or\v!somewhere\or\v!next\fi]} + +\unexpanded\def\@@commoninteractionbargotob#1% + {\vrule\!!height\interactionbarheight\!!depth\interactionbardepth\!!width\!!widtha\relax} + +\unexpanded\def\@@commoninteractionbargotoc#1% + {\symbol[\ifcase#1\v!previous\or\v!somewhere\or\v!somewhere\or\v!somewhere\or\v!next\fi} + +\unexpanded\def\@@commoninteractionbargotod#1% + {\vrule \!!width\!!widtha \ifcase#1% + \!!height \interactionbarheight \!!depth \interactionbardepth \or + \!!height.5\interactionbarheight \!!depth.5\interactionbardepth \or + \!!height \interactionbarheight \!!depth \interactionbardepth \or + \!!height.5\interactionbarheight \!!depth.5\interactionbardepth \else + \!!height \interactionbarheight \!!depth \interactionbardepth \fi} + +\unexpanded\def\@@commoninteractionbarx#1% + {\doifelse{\interactionbarparameter\c!symbol}\v!yes + {\setupsymbolset[\@@iasymbolset]% + \let\dogotox\@@commoninteractionbargotoa} + {\let\dogotox\@@commoninteractionbargotob}% + \dorecurse\nofsubpages + {\scratchcounter\numexpr\recurselevel+\firstsubpage+\minusone\relax + \chardef\what + \ifnum\scratchcounter<\realpageno \zerocount \else + \ifnum\scratchcounter=\realpageno \plusone \else + \plustwo \fi\fi + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\dogotox\what}[page(\the\scratchcounter)]}% + #1}% + \unskip} + +\def\interactionbard + {\iflocation \ifnum\nofsubpages>\plusone \doif{\structurecounterparameter\s!subpage\c!state}\v!start{% + \interactionbarwidth \interactionbarparameter\c!width + \interactionbardistance\interactionbarparameter\c!distance + \interactionbarheight \interactionbarparameter\c!height + \interactionbardepth \interactionbarparameter\c!depth + \!!widtha\interactionbarwidth + \noindent\hbox{\@@commoninteractionbarx{\hskip\interactionbardistance}}% + }\fi \fi} + +\def\interactionbare + {\iflocation \ifnum\nofsubpages>\plusone \doif{\structurecounterparameter\s!subpage\c!state}\v!start{% + \begingroup + \interactionbarwidth \interactionbarparameter\c!width + \interactionbardistance\interactionbarparameter\c!distance + \interactionbarheight \interactionbarparameter\c!height + \interactionbardepth \interactionbarparameter\c!depth + \!!widthb\dimexpr\nofsubpages\interactionbardistance-\interactionbardistance\relax % (n-1) + \!!widtha\dimexpr(\interactionbarwidth-\!!widthb)/\nofsubpages\relax + \ifdim\!!widtha<\interactionbardistance + \interactionbarf + \else + \noindent\hbox to \interactionbarwidth{\@@commoninteractionbarx{\hss}\unskip}% + \fi + \endgroup + }\fi\fi} + +\def\interactionbarf + {\iflocation \ifnum\nofsubpages>\plusone \doif{\structurecounterparameter\s!subpage\c!state}\v!start{% + \interactionbarwidth \interactionbarparameter\c!width + \interactionbardistance\interactionbarparameter\c!distance + \interactionbarheight \interactionbarparameter\c!height + \interactionbardepth \interactionbarparameter\c!depth + \noindent \hbox to \interactionbarwidth \bgroup + \doloop + {\!!countc\numexpr(\nofsubpages/\recurselevel)+\plusone\relax % rounding + \!!widthb\interactionbardistance + \multiply\!!widthb \!!countc + \advance\!!widthb -\interactionbardistance + \!!widtha\interactionbarwidth + \advance\!!widtha -\!!widthb + \divide\!!widtha \!!countc + \ifdim\!!widtha<\interactionbardistance\else + \!!countb\recurselevel + \exitloop + \fi}% + \ifnum\!!countc>\plusone + % this is not that well tested + \advance\!!countc \minustwo + \!!widtha-\interactionbardistance + \!!widtha\!!countc\!!widtha + \advance\!!widtha \interactionbarwidth + \advance\!!countc \plusone + \divide\!!widtha \!!countc + \fi + \doifelse{\interactionbarparameter\c!symbol}\v!yes + {\setupsymbolset[\@@iasymbolset]% + \let\dogotox\@@commoninteractionbargotoc}% + {\let\dogotox\@@commoninteractionbargotod}% + \!!countc\numexpr\realpageno-\plustwo\relax + \!!countd\numexpr\realpageno+\plustwo\relax + \ifnum\!!countc<\plusone \!!countc\plusone \fi + \!!countf\zerocount + \dostepwiserecurse\firstsubpage\lastsubpage\plusone + {\!!doneafalse + \advance\!!countf \plusone + \ifnum\recurselevel=\firstsubpage\relax \!!doneatrue \fi + \ifnum\recurselevel=\lastsubpage \relax \!!doneatrue \fi + \chardef\what \if!!donea + \ifnum\recurselevel<\realpageno \zerocount \else + \ifnum\recurselevel>\realpageno \plustwo \else + \plusfour \fi\fi + \else \ifnum\!!countf=\!!countb + \ifnum\recurselevel<\realpageno \plusone \else + \ifnum\recurselevel>\realpageno \plusthree \else + \plustwo \fi\fi + \fi \fi + \normalexpanded{\directgotospecbox\noexpand\interactionbarparameter{\dogotox\what}[page(\recurselevel)]}% + \hss + \!!countf\zerocount}% + \unskip + \egroup + }\fi\fi} + +\def\interactionbarg + {\iflocation \ifnum\lastsubpage>\firstsubpage\relax % no test for state? + \interactionbuttons[\v!firstsubpage,\v!previoussubpage,\v!nextsubpage,\v!lastsubpage]% + \fi \fi} + +\setupinteractionbar + [\c!state=\v!start, + \c!alternative=a, + \c!symbol=\v!no, + \c!width=10\emwidth, + \c!height=.5\emwidth, + \c!depth=\zeropoint, + \c!distance=.5\emwidth, + \c!step=\v!medium, + \c!foregroundcolor=\interactionbarparameter\c!color, + \c!foregroundstyle=\interactionbarparameter\c!style, + \c!color=\@@iacolor, + \c!contrastcolor=\@@iacontrastcolor, + \c!style=, + \c!frame=\v!on, + \c!background=color, + \c!backgroundcolor=gray, + \c!samepage=\v!yes, + \c!unknownreference=\v!yes] + +\defineinteractionbar[a][\c!command=\interactionbara] +\defineinteractionbar[b][\c!command=\interactionbarb,\c!height=\v!broad] +\defineinteractionbar[c][\c!command=\interactionbarc,\c!height=\v!max,\c!depth=\v!max] +\defineinteractionbar[d][\c!command=\interactionbard,\c!width=.5\emwidth] +\defineinteractionbar[e][\c!command=\interactionbare] +\defineinteractionbar[f][\c!command=\interactionbarf] +\defineinteractionbar[g][\c!command=\interactionbarg,\c!height=\v!broad] + +\protect \endinput |