pack-bar.mkiv /size: 3268 b    last modification: 2020-07-01 14:35
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
{
\setuppositionbar
[#
1
]
%
67
\usepositionbarstyleandcolor
\c!style\c!color
68
\vskip
\zeropoint
\s!plus
\positionbarparameter
\c!n
\s!fill
69
\vskip
\zeropoint
\s!plus
-
\positionbarparameter
\c!min\s!fill
70
\positionbarparameter
\c!text
\relax
71
\vskip
\zeropoint
\s!plus
\positionbarparameter
\c!max\s!fill
72
\vskip
\zeropoint
\s!plus
-
\positionbarparameter
\c!n
\s!fill
}}
73 74
\unexpanded
\def
\horizontalgrowingbar
[#
1
]
%
75
{
\hpack
to
\hsize
76
{
\setuppositionbar
[#
1
]
%
77
\usepositionbarstyleandcolor
\c!style\c!color
78
\leaders\vrule\hskip
\zeropoint
\s!plus
\numexpr
\positionbarparameter
\c!n
-
\positionbarparameter
\c!min
+
\plusone
\relax
\s!fill
79
\vrule
\s!width
\zeropoint
\s!height
\positionbarparameter
\c!height\s!depth
\positionbarparameter
\c!depth
80
\hskip
\zeropoint
\s!plus
\positionbarparameter
\c!max\s!fill
81
\hskip
\zeropoint
\s!plus
-
\positionbarparameter
\c!n
\s!fill
}}
82 83
\unexpanded
\def
\verticalgrowingbar
[#
1
]
%
84
{
\vpack
to
\vsize
85
{
\setuppositionbar
[#
1
]
%
86
\usepositionbarstyleandcolor
\c!style\c!color
87
\leaders\hrule\vskip
\zeropoint
\s!plus
\numexpr
\positionbarparameter
\c!n
-
\positionbarparameter
\c!min
+
\plusone
\relax
\s!fill
88
\hrule
\s!width
\positionbarparameter
\c!width\s!height
\zeropoint
\s!depth
\zeropoint
89
\vskip
\zeropoint
\s!plus
\positionbarparameter
\c!max\s!fill
90
\vskip
\zeropoint
\s!plus
-
\positionbarparameter
\c!n
\s!fill
}}
91 92
\protect
\endinput
93