diff options
Diffstat (limited to 'tex/context/base/mkxl/anch-box.mkxl')
-rw-r--r-- | tex/context/base/mkxl/anch-box.mkxl | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/tex/context/base/mkxl/anch-box.mkxl b/tex/context/base/mkxl/anch-box.mkxl new file mode 100644 index 000000000..570f8862d --- /dev/null +++ b/tex/context/base/mkxl/anch-box.mkxl @@ -0,0 +1,180 @@ +%D \module +%D [ file=anch-box, +%D version=2022.03.25, +%D title=\CONTEXT\ Anchoring Macros, +%D subtitle=Boxes, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%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 Anchoring Macros / Boxes} + +\unprotect + +\startMPpositiongraphic{mypos:boxanchor:arrow}{}% from,to,linecolor,text,alternative,leftedge,rightedge,distance} + anch_box_arrows_draw ; +\stopMPpositiongraphic + +\tolerant\permanent\protected\def\connectboxanchors[#1]#*[#2]#*[#3]#*[#4]#*#:#5#6% + {\begingroup + \defineboxanchor[#5]% + \setboxanchor[#5][#1][#3]\hpack{\xypos{\namespacedboxanchor{#5}}}% + \ifparameter#3\or\setupboxanchorcontent[#1][#3]\fi + \defineboxanchor[#6]% + \setboxanchor[#6][#2][#4]\hpack{\xypos{\namespacedboxanchor{#6}}}% + \ifparameter#4\or\setupboxanchorcontent[#1][#4]\fi + \startpositionoverlay{text-1}% will become configurable region + \setMPpositiongraphic + {\namespacedboxanchor{#5}}% + {\namedboxanchorcontentparameter{#1}\c!mp}% + {from=\namespacedboxanchor{#5},% + to=\namespacedboxanchor{#6},% + distance={\namedboxanchorcontentparameter{#1}\c!distance},% + dashtype={\namedboxanchorcontentparameter{#1}\c!dash},% + alternative={\namedboxanchorcontentparameter{#1}\c!alternative},% + text={\namedboxanchorcontentparameter{#1}\c!text},% + rulethickness={\namedboxanchorcontentparameter{#1}\c!rulethickness},% + linecolor=\namedboxanchorcontentparameter{#1}{\c!rulecolor}}% + \stoppositionoverlay + \endgroup} + +% dedicated or not + +\tolerant\permanent\protected\def\connectmatrixanchors[#1]#*[#2]#*[#3]#*[#4]#*#:#5#6% + {\begingroup + \doifelseinset{#5}{\m_anch_matrix_list}\donetrue\donefalse + \ifdone\else + \defineboxanchor[#5]% + \setboxanchor[#5][#1][#3]\hpack{\xypos{\namespacedboxanchor{#5}}}% + \xdef\m_anch_matrix_list{\m_anch_matrix_list,#5}% + \fi + \ifparameter#3\or\setupboxanchorcontent[#1][#3]\fi + \doifelseinset{#6}{\m_anch_matrix_list}\donetrue\donefalse + \ifdone\else + \defineboxanchor[#6]% + \setboxanchor[#6][#2][#4]\hpack{\xypos{\namespacedboxanchor{#6}}}% + \xdef\m_anch_matrix_list{\m_anch_matrix_list,#6}% + \fi + \ifparameter#4\or\setupboxanchorcontent[#1][#4]\fi + \startpositionoverlay{text-1}% will become configurable region + \setMPpositiongraphic + {\namespacedboxanchor{#5}}% + {\namedboxanchorcontentparameter{#1}\c!mp}% + {from=\namespacedboxanchor{#5},% + to=\namespacedboxanchor{#6},% + distance={\namedboxanchorcontentparameter{#1}\c!distance},% + dashtype={\namedboxanchorcontentparameter{#1}\c!dash},% + alternative={\namedboxanchorcontentparameter{#1}\c!alternative},% + text={\namedboxanchorcontentparameter{#1}\c!text},% + rulethickness={\namedboxanchorcontentparameter{#1}\c!rulethickness},% + linecolor=\namedboxanchorcontentparameter{#1}{\c!rulecolor},% + % matrix specific: + leftedge=\namespacedboxanchor\c!leftedge,% + rightedge=\namespacedboxanchor\c!rightedge}% + \stoppositionoverlay + \endgroup} + +\let\m_anch_matrix_list\empty + +\tolerant\permanent\protected\def\startmatrixanchors + {\glet\m_anch_matrix_list\empty + \defineboxanchor[\v!leftedge]% + \setboxanchor[\v!leftedge][\v!leftedge]\hpack{\xypos{\namespacedboxanchor\v!leftedge}}% + \defineboxanchor[\v!rightedge]% + \setboxanchor[\v!rightedge][\v!rightedge]\hpack{\xypos{\namespacedboxanchor\v!rightedge}}% + \setupmathfence[\c!leftsource=\v!leftedge,\c!rightsource=\v!rightedge]} + +\tolerant\permanent\protected\def\stopmatrixanchors + {\setupmathfence[\c!leftsource=,\c!rightsource=]% + \glet\m_anch_matrix_list\empty} + + +\defineboxanchorcontent + [arrow] + [\c!mp=mypos:boxanchor:arrow, + \c!distance=1.5\exheight, + \c!rulethickness=\linewidth, + \c!rulecolor=textcolor] + +\defineboxanchorcontent + [\v!top] + [arrow] + [\c!corner=\v!height, + \c!location=\v!depth, + \c!yoffset=.25\exheight, + \c!alternative=\v!top] + +\defineboxanchorcontent + [\v!bottom] + [arrow] + [\c!corner=\v!depth, + \c!location=\v!height, + \c!yoffset=-\namedboxanchorcontentparameter{top}\c!yoffset, + \c!alternative=\v!bottom] + +\defineboxanchorcontent + [\v!left] + [arrow] + [\c!corner={\v!middle,\v!left}, + \c!xoffset=-1.25\emwidth, + \c!alternative=\v!left] + +\defineboxanchorcontent + [\v!right] + [arrow] + [\c!corner={\v!middle,\v!right}, + \c!xoffset=-\namedboxanchorcontentparameter{left}\c!xoffset, + \c!alternative=\v!right] + +\defineboxanchorcontent + [\v!leftedge] + [\v!left] + [\c!xoffset=-.25\exheight] + +\defineboxanchorcontent + [\v!rightedge] + [\v!right] + [\c!xoffset=0.25\exheight] % we are centered + +\defineboxanchorcontent[\v!middle:\v!bottom][\v!bottom][\c!alternative=\v!middle,\c!yoffset=-.5\exheight] +\defineboxanchorcontent[\v!middle:\v!top ][\v!top ][\c!alternative=\v!middle,\c!yoffset=.5\exheight] +\defineboxanchorcontent[\v!middle:\v!left ][\v!left ][\c!alternative=\v!middle,\c!xoffset=-.5\exheight] +\defineboxanchorcontent[\v!middle:\v!right ][\v!right ][\c!alternative=\v!middle,\c!xoffset=.5\exheight] + +\defineboxanchorcontent + [\v!left:\v!bottom] + [\v!bottom] + [\c!alternative=\v!middle, + \c!corner={\v!left,\v!depth}, + \c!xoffset=-.25\exheight, + \c!yoffset=-.25\exheight] + +\defineboxanchorcontent + [\v!right:\v!bottom] + [\v!bottom] + [\c!alternative=\v!middle, + \c!corner={\v!right,\v!depth}, + \c!xoffset=.25\exheight, + \c!yoffset=-.25\exheight] + +\defineboxanchorcontent + [\v!left:\v!top] + [\v!top] + [\c!alternative=\v!middle, + \c!corner={\v!left,\v!height}, + \c!xoffset=-.25\exheight, + \c!yoffset=.25\exheight] + +\defineboxanchorcontent + [\v!right:\v!top] + [\v!top] + [\c!alternative=\v!middle, + \c!corner={\v!right,\v!height}, + \c!xoffset=.25\exheight, + \c!yoffset=.25\exheight] + +\protect |