% output=pdftex output=en
%
% copyright=pragma-ade readme=readme.pdf licence=cc-by-nc-sa

\environment back-0

\setuplayout[backspace=1.5cm,cutspace=.5cm,topspace=.5cm]

\startuniqueMPgraphic{xxx}
  interim linecap := butt ; 
  pickup pencircle scaled 1pt ; 
  linear_shade(OverlayBox,1,\MPcolor{red},white) ;
  draw lrcorner OverlayBox -- llcorner OverlayBox shifted (-1cm,0) ;
  draw llcorner OverlayBox -- ulcorner OverlayBox ;
  setbounds currentpicture to OverlayBox enlarged 1cm ;  
\stopuniqueMPgraphic

\defineoverlay[xxx][\uniqueMPgraphic{xxx}]

\startuseMPgraphic{mpos:par:columnset:side}
% span_multi_column_pars := true ; 
  interim linecap := butt ; 
  path p ; color c, w ; c := \MPcolor{red} ; w := white ; 
  for i=1 upto nofmultipars : 
    p := llcorner multipars[i] -- ulcorner multipars[i] -- cycle ;
    p := p leftenlarged 1cm ; 
    if multilocs[i]=1 :  
      linear_shade(p,8,c,w) ; 
    elseif multilocs[i]=2 : 
      linear_shade(p topenlarged    (-.5*bbheight(p)),8,c,w) ; 
      linear_shade(p bottomenlarged (-.5*bbheight(p)),8,w,c) ; 
    else : 
      linear_shade(p,8,w,c) ; 
    fi ;
    draw lrcorner p -- urcorner p withpen pencircle scaled 1pt ;
  endfor ; 
\stopuseMPgraphic


\setupindenting[big]

\setuprandomize[medium]

\definecolumnset[two][n=2,distance=1.5cm]

\definetextbackground
  [test]
  [location=paragraph,
   background=color,
   backgroundcolor=red,
   mp=mpos:par:columnset:side,
   methode=mpos:par:columnset,
   before=,
   after=]

\setupnarrower
  [before=,after=]

\def\StartSpecialFrame#1%
  {\testpagina[4][0pt]\blank[2*big]
   \snaptogrid\hbox
     {\hskip-1cm
      \framed
        [frame=off,
         background=color,
         backgroundcolor=green,
         height=1cm,
         width=1cm]
        {\ss\bfd X}%
      \framed
        [offset=.25cm,
         align={right,lohi},
         frame=off,
         background=xxx,
         height=1cm,
         width=\hsize]
        {#1}}
   \vskip-\strutdepth % optie maken in background
   \starttextbackground[test]
   \vskip\strutdepth
   \startnarrower[left]}

\def\StopSpecialFrame 
  {\stopnarrower
   \stoptextbackground
   \blank}

\starttext

\startcolumnset[two]

\dorecurse{10}
  {\StartSpecialFrame{something \recurselevel}
     \fakewords{10}{500}
     \placefigure{}{\framed{test}}
     \fakewords{10}{500}
   \StopSpecialFrame} 

\stopcolumnset 

\stoptext
