pack-bar.mkiv /size: 3352 b    last modification: 2021-10-28 13:50
1%D \module
2%D   [       file=pack-bar,
3%D        version=2009.06.26,
4%D          title=\CONTEXT\ Packaging Macros,
5%D       subtitle=Bars,
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 Packaging Macros / Bars}
15
16
17\unprotect
18
19%D This code has been moved from scrn-int to here (was some old
20%D experimental code). It could be in scrn-bar but it's static. In
21%D the meantime the interface has been adapted to a key|/|value one.
22%D
23%D \startbuffer
24%D  \dorecurse{10}{
25%D      \ruledhbox{\horizontalpositionbar[n=#1,min=1,max=10,text=!,color=red]}
26%D      \par
27%D  }
28%D \stopbuffer
29%D
30%D \typebuffer \stoplinecorrection \getbuffer \stoplinecorrection
31%D
32%D \startbuffer
33%D  \dorecurse{10}{
34%D      \ruledhbox{\horizontalgrowingbar[n=#1,min=1,max=10,text=!,color=red]}
35%D      \par
36%D  }
37%D \stopbuffer
38%D
39%D \typebuffer \stoplinecorrection \getbuffer \stoplinecorrection
40
41\installcorenamespace{positionbar}
42
43\installsimplecommandhandler \??positionbar {positionbar} \??positionbar
44
45\setuppositionbar
46  [\c!min=1,
47   \c!max=1,
48   \c!n=1,
49   \c!text=?,
50   \c!width=\emwidth,
51   \c!height=\strutheight,
52   \c!depth=\strutdepth]
53
54\unexpanded\def\horizontalpositionbar[#1]%
55  {\hbox to \hsize
56     {\setuppositionbar[#1]%
57      \usepositionbarstyleandcolor\c!style\c!color
58      \hskip\zeropoint\s!plus \positionbarparameter\c!n  \s!fill
59      \hskip\zeropoint\s!plus-\positionbarparameter\c!min\s!fill
60      \positionbarparameter\c!text\relax
61      \hskip\zeropoint\s!plus \positionbarparameter\c!max\s!fill
62      \hskip\zeropoint\s!plus-\positionbarparameter\c!n  \s!fill}}
63
64\unexpanded\def\verticalpositionbar[#1]%
65  {\vbox to \vsize
66     {\hsize\positionbarparameter\c!width
67      \setuppositionbar[#1]%
68      \usepositionbarstyleandcolor\c!style\c!color
69      \vskip\zeropoint\s!plus \positionbarparameter\c!n  \s!fill
70      \vskip\zeropoint\s!plus-\positionbarparameter\c!min\s!fill
71      \positionbarparameter\c!text\relax
72      \vskip\zeropoint\s!plus \positionbarparameter\c!max\s!fill
73      \vskip\zeropoint\s!plus-\positionbarparameter\c!n  \s!fill}}
74
75\unexpanded\def\horizontalgrowingbar[#1]%
76  {\hpack to \hsize
77     {\setuppositionbar[#1]%
78      \usepositionbarstyleandcolor\c!style\c!color
79      \vrule\s!width\zeropoint\s!height\positionbarparameter\c!height\s!depth\positionbarparameter\c!depth
80      \leaders\vrule\hskip\zeropoint\s!plus\numexpr\positionbarparameter\c!n-\positionbarparameter\c!min+\plusone\relax\s!fill
81      \hskip\zeropoint\s!plus \positionbarparameter\c!max\s!fill
82      \hskip\zeropoint\s!plus-\positionbarparameter\c!n  \s!fill}}
83
84\unexpanded\def\verticalgrowingbar[#1]%
85  {\vpack to \vsize
86     {\hsize\positionbarparameter\c!width
87      \setuppositionbar[#1]%
88      \usepositionbarstyleandcolor\c!style\c!color
89      \hrule\s!width\positionbarparameter\c!width\s!height\zeropoint\s!depth\zeropoint
90      \leaders\hrule\vskip\zeropoint\s!plus\numexpr\positionbarparameter\c!n-\positionbarparameter\c!min+\plusone\relax\s!fill
91      \vskip\zeropoint\s!plus \positionbarparameter\c!max\s!fill
92      \vskip\zeropoint\s!plus-\positionbarparameter\c!n  \s!fill}}
93
94\protect \endinput
95