pack-fen.mkiv / last modification: 2020-01-30 14:16
%D \module
%D   [       file=pack-fen,
%D        version=2011.07.21,
%D          title=\CONTEXT\ Packaging Macros,
%D       subtitle= Fences for Ruled Content,
%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 Packaging Macros / Fences for Ruled Content}

%D \startbuffer
%D \useMPlibrary[meta-imp-hooks.mkiv]
%D
%D \framed[frame=off,bottomframe=righthook]{Bottom right hook}
%D \stopbuffer
%D
%D \typebuffer
%D
%D \startlinecorrection
%D \getbuffer
%D \stoplinecorrection

\unprotect

\def\installleftframerenderer#1#2%
  {\setvalue{\??framedleft\v!on#1}{\whateverleftframe{#2}}%
   \expandafter\let\csname\??framedleft\v!off#1\expandafter\endcsname\csname\??framedleft\v!on#1\endcsname}

\def\installrightframerenderer#1#2%
  {\setvalue{\??framedright\v!on#1}{\whateverrightframe{#2}}%
   \expandafter\let\csname\??framedright\v!off#1\expandafter\endcsname\csname\??framedright\v!on#1\endcsname}

\def\installtopframerenderer#1#2%
  {\setvalue{\??framedtop\v!on#1}{\whatevertopframe{#2}}%
   \expandafter\let\csname\??framedtop\v!off#1\expandafter\endcsname\csname\??framedtop\v!on#1\endcsname}

\def\installbottomframerenderer#1#2%
  {\setvalue{\??framedbottom\v!on#1}{\whateverbottomframe{#2}}%
   \expandafter\let\csname\??framedbottom\v!off#1\expandafter\endcsname\csname\??framedbottom\v!on#1\endcsname}

\ifdefined \pack_framed_overlay_initialize_indeed

    \let\setinstalledframedimensions\pack_framed_overlay_initialize_indeed

\else

    \def\setinstalledframedimensions
      {\d_overlay_width       \frameddimenwd
       \d_overlay_height      \dimexpr\frameddimenht+\frameddimendp\relax
       \d_overlay_depth       \frameddimendp
       \d_overlay_linewidth   \ruledlinewidth
       \edef\overlaycolor    {\framedparameter\c!backgroundcolor}%
       \edef\overlaylinecolor{\framedparameter\c!framecolor}}

\fi

\newbox\b_framed_rendered

\def\whateverleftframe#1%
  {\setinstalledframedimensions
   \setbox\b_framed_rendered\vpack to \d_overlay_height{\vss#1\vss}%
   \setbox\b_framed_rendered\hpack to \zeropoint{\box\b_framed_rendered\hss}%
   \ht\b_framed_rendered\zeropoint
   \dp\b_framed_rendered\zeropoint
   \box\b_framed_rendered}

\def\whateverrightframe#1%
  {\setinstalledframedimensions
   \setbox\b_framed_rendered\vpack to \d_overlay_height{\vss#1\vss}%
   \setbox\b_framed_rendered\hpack to \zeropoint{\hss\box\b_framed_rendered}%
   \ht\b_framed_rendered\zeropoint
   \dp\b_framed_rendered\zeropoint
   \box\b_framed_rendered}

\def\whatevertopframe#1%
  {\setinstalledframedimensions
   \setbox\b_framed_rendered\hpack to \d_overlay_width{\hss#1\hss}%
   \setbox\b_framed_rendered\vpack to \zeropoint{\box\b_framed_rendered\vss}%
   \ht\b_framed_rendered\zeropoint
   \dp\b_framed_rendered\zeropoint
   \box\b_framed_rendered
   \nointerlineskip}

\def\whateverbottomframe#1%
  {\setinstalledframedimensions
   \setbox\b_framed_rendered\hpack to \d_overlay_width{\hss#1\hss}%
   \setbox\b_framed_rendered\vpack to \zeropoint{\vss\box\b_framed_rendered}%
   \ht\b_framed_rendered\zeropoint
   \dp\b_framed_rendered\zeropoint
   \box\b_framed_rendered}

\protect \endinput