Hi Wolfgang
Thanks once again !

\startMyFrame[Title=Thanks ]
\input knuth
\stopMyFrame

\startMyFrame[Title=once again !]
\input knuth
\stopMyFrame

Fabrice

2016-07-26 21:49 GMT+02:00 Wolfgang Schuster <schuster.wolfgang@gmail.com>:
26. Juli 2016 um 20:21
Hi Hans,
I think I was not very clear.



Title first framed : Hans

Title second framed : Hagen

You can pass a title to the optional framedtext argument (use camel case to avoid
using existing key names) and access the value later in the metapost graphic.

Thanks
Fabrice

\setupbodyfont[pagella,11pt]

\setupcolors[state=start]

\defineframedtext
  [MyFrame]
  [before={\blank},
   after={\blank},
   frame=off,
   background=MyFrame,
   width=\textwidth,
width=max,
   height=fit,
   style=italic]

\setvariables
  [text]
  [text1=Hans,
   text2=Hagen,]
  

\startuseMPgraphic{MyFrame}
 path b;
 picture p;
 p := textext.rt("\white\getvariable{text}{text1}");

 p := textext.rt("\white\framedtextparameter{Title}");

 p := p shifted (2BodyFontSize,OverlayHeight-ypart center p+.25ExHeight);
 b := boundingbox p leftenlarged .5EmWidth rightenlarged .5EmWidth;
 fill OverlayBox withcolor lightgray;
 fill b withcolor darkred;
 draw bottomboundary OverlayBox withpen pencircle scaled 1pt  withcolor darkred;
 draw topboundary OverlayBox withpen pencircle scaled 1pt  withcolor darkred;
 draw p;
 setbounds currentpicture to boundingbox currentpicture enlarged 2mm;
\stopuseMPgraphic

\defineoverlay
  [MyFrame]
  [\useMPgraphic{MyFrame}]

\starttext


\startMyFrame
\input knuth
\stopMyFrame

\startMyFrame
\input knuth
\stopMyFrame


\startMyFrame[Title=Hans]
\input knuth
\stopMyFrame

\startMyFrame[Title=Hagen]
\input knuth
\stopMyFrame

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________