\startenvironment env_scMaterials

\enableregime[utf]
\mainlanguage[it]
\setupinteraction[state=start]

%\setuppapersize[A5][A4, landscape]

%%%

%% the original format
\setuppapersize[A5][A5]

%% two pages side by side
%\setuppapersize[A5][A4, landscape]
%\setuparranging[2SIDE]


%% print:
%\setuppapersize[A5][A4, landscape]
%\setuparranging[2*2]  %% print in A4 double sided, cut pages and bind
%\setuppagenumbering[alternative={singlesided,doublesided}]
%\setupbackgrounds[rightpage][leftframe=on]
%% end print

\setupcolors[state=start]

%%%%%%%%%%%%%%% Colors %%%%%%%%%%%%%%%

%% SC colors %%
\definecolor [SCwhite] [r=1.0, g=1.0, b=1.0] 
\definecolor [SCblack] [r=0.0, g=0.0, b=0.0] 
\definecolor [SCblue] [r=0.0, g=0.0, b=0.75] 
\definecolor [SCred] [r=0.75, g=0.0, b=0.0] 

\definecolor [SCgrey] [r=0.376, g=0.376, b=0.376] 
\definecolor [SCgreen] [r=0.0, g=0.45, b=0.0] 
%%%%%%%%%%%%

%% CIRMA colors %%
\definecolor[cirmaBlue] [r=.0,g=.2,b=.6] 
%\definecolor[cirmaGrey] [r=.2,g=.2,b=.2] %lighter follows
\definecolor[cirmaGrey] [r=.3,g=.3,b=.3] 
\definecolor[cirmaOrange] [r=1,g=.6,b=.0] 
% another grey
\definecolor[bgGrey] [r=.9,g=.9,b=.9] 
%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




%% Define the color for bodyfont
\definecolor [fontColor][black]

\setupfootertexts[{\color[cirmaBlue]\tfxx  Andrea Valle \hfill tSCIRMA }]
\setuppagenumbering[location=footer, sectionnumber=yes, state=start]

\setupfooter[state=start]


\setuphead[chapter]
[style=\ss\tfc, before={\startframedtext[width=local, foregroundcolor=white, background=color, backgroundcolor=cirmaBlue, framecolor=cirmaOrange,offset=.25cm,
rulethickness=0.05cm, frame=off, topframe=on,  bottomframe=on]},after={\stopframedtext\blank[.25\textheight]},
]




\setuphead[section][style=\ss\tfb, before={\startframedtext[frame=off]\color[cirmaGrey]}, after={\color[cirmaBlue]\textrule\color[fontColor]\stopframedtext}]


\setuphead[subsection][style=\ss\tfb,before={\startframedtext[frame=off]\color[cirmaGrey]}, after={\color[cirmaOrange]\textrule\color[fontColor]\stopframedtext}]


\setupframedtexts[width=local, framecolor=cirmaOrange]

%\setuplayout[marking=on, margin=0pt, width=fit]
%[width=fit,
%              rightmargin=1.5cm,
%              leftmargin=1.5cm,
%              leftmargindistance=0pt,
%              rightmargindistance=0pt,
%              height=fit, 
%              header=0pt, 
%              footer=20pt, 
%              topspace=1.5cm, 
%              backspace=1.5cm,
%%              cutspace=1.5cm, 
%              bottomspace=8pt,
%              location=singlesided]


%\setupfootertexts[{\color[blue]\tfxx  a.a. 2005-06 \hfill Andrea Valle \type{<}andrea.valle@unito.it\type{>} \hfill \currentdate}]

%\setupfooter[state=stop]

\setupcombinations[distance=5pt]

%\setupframed[frame=on,height=.9\textheight,width=.9\textwidth,top=\vss,bottom=\vss,align=right]

%%\setuplabels[]
%\setupcaption[figure][number=no]

\definetypeface[tSCIRMA][rm][Xserif][Palatino]
\definetypeface[tSCIRMA][tt][Xmono][LM Typewriter Regular]
\definetypeface[tSCIRMA][ss][Xsans][Optima]

\setupbodyfont[tSCIRMA, 10pt]

%\setupbodyfont[sansserif]
\setuptyping[color=black] %% redundant?


%%%% Some defs %%%%%%%%

\define[1]\Note{\blank{\tt [Lavori in corso:  #1]}\blank}
\define[1]\Code{{\tt #1}}
\define[1]\Line{\startnarrower\tfx\startlines\blank{\tt #1}\blank\stoplines\tfa\stopnarrower}
\define[1]\Url{\startnarrower #1 \stopnarrower}
%%%%%%
\define[1]\Ex{\tfx \input code/#1 \tfa} 
% "code" folder is where you put the examples
% code must be ascii and result from processing  
% .sc files (ASCII, not rtf) in scToConTeXt.py 
% usage: \Ex{testSC}
%%%%%%




% stolen from wiki

% different colors for frame in code and interpreter

\defineframedtext
  [framedSC]
  [framecolor=cirmaBlue,
   strut=yes,
   offset=2mm,
   width=local,
   align=right]

\definetyping[SC][option=commands, 
					tab=2,numbering=line,
					bodyfont=4pt, %% does not work: ?
                    before={\startframedSC\tfx},
                    after={\tfa\stopframedSC}]




\defineframedtext
  [framedcode]
  [framecolor=cirmaOrange,
   strut=yes,
   offset=2mm,
   width=local,
   align=right]

\definetyping[code][numbering=line,
                    bodyfont=8pt,
                    before={\startframedcode\tfx},
                    after={\tfa\stopframedcode}]

\defineenumeration 
[Osservazione] 
[location=top, 
text=Osservazione, 
inbetween=\blank,
after=\blank] 
 
 
\stopenvironment 