% This is is the ConTeXt file for the `chronosys' package.
%
% The maintener of this work is Mathieu Long.
% email : mlong.tex@hotmail.fr
% the `chronosys' package consists in the 9 files :
%  -- `docchronosys_en.tex' and `docchronosys_en.pdf' (english manual)
%  -- `docchronosys_fr.tex' and `docchronosys_fr.pdf' (french manual)
%  -- README
%  -- `chronosys.tex' (file for plain TeX)
%  -- `chronosyschr.tex' (main file of the `chronosys' package)
%  -- `chronosys.sty' (file for LaTeX)
%  -- `x-chronosys.tex' (file for ConTeXt)
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Mathieu Long.
%
\usemodule[tikz]
\catcode`\@=11
\catcode`\!=11
\def\!chr@verif#1#2{\ifdefined#2\error!message \fi #1#2} %
\defineframed[chreventframedcolorbox][background=color,backgroundcolor=\!chr@eventcolorbox,frame=off,backgroundoffset=\z@,location=low]
\defineframed[chrperiodframedcolorbox][background=color,backgroundcolor=\!chr@periodcolorbox,frame=off,backgroundoffset=\z@,location=low]
\let\!chreventcolorbox\chreventframedcolorbox
\let\!chrperiodcolorbox\chrperiodframedcolorbox
\input chronosyschr.tex

\def\setupchronology{\dosingleempty\dosetupchronology}
\def\dosetupchronology[#1]{\iffirstargument \!chrtraitingargvirgule{#1}{!chrdefault}\fi}

\def\setupchronoevent{\def\@@string@a{event}\dodoubleempty\dosetupchronoeventandperiode}
\def\dosetupchronoeventandperiode[#1][#2]{\iffirstargument
\ifsecondargument
\def\@@string@a{#1}\def\@@string@b{#2}\else\def\@@string@b{#1}\fi \expandafter\!chr@parcoursoptions\@@string@b,\end\fi}

\def\setupchronoperiode{\def\@@string@a{periode}\dodoubleempty\dosetupchronoeventandperiode}
\def\definechronoperiode{\dosingleempty\dodefinechronoperiode}
\!chrverif\def\dodefinechronoperiode[#1]{%
\iffirstargument
\def\@@string@a{#1}%
\!chrverifdefines{%
\expandafter\expandafter\expandafter\!chrtraitingargvirgule\expandafter\expandafter\expandafter{\csname !chr#1defaultoptions\endcsname}{!chr@period}%
\!chrtraiteoneargument\dochronoperiode}%
\if!chrverifdefines
\expandafter\def\csname !chr#1defaultoptions\endcsname{textdepth=15pt, dates=true,
color=\!chrperiodedef@ultcolor, datesstyle=\relax,
startdate=true, stopdate=true, textstyle=\relax,
dateselevation=0pt, ifcolorbox=true,
colorbox=white, bottomdepth=0pt, topheight=\!chrheight}\fi\fi
\ifnexttoken[{\!chr@defineorsetupoptions}{}}

\def\definechronoevent{\dosingleempty\dodefinechronoevent}
\!chrverif\def\dodefinechronoevent[#1]{%
\iffirstargument
\def\@@string@a{#1}%
\!chrverifdefines{%
\expandafter\expandafter\expandafter\!chrtraitingargvirgule\expandafter\expandafter\expandafter{\csname !chr#1defaultoptions\endcsname}{!chr@event}%
\!chrtraiteoneargument\dochronoevent}%
\if!chrverifdefines
\expandafter\def\csname !chr#1defaultoptions\endcsname{barre=true, icon=\relax,
markdepth=10pt, textstyle=\relax, mark=true,
date=true, datesseparation=\space, conversionmonth=true,
datestyle=\relax, datesstyle=\relax, year=true,
iconheight=0.5\!chrheight, ifcolorbox=true, colorbox=white,
textwidth=\relax}\fi\fi
\ifnexttoken[{\!chr@defineorsetupoptions}{}}

\setupchronoevent[!!eventgradu@tion][datesstyle=\tfxx]
\setupchronoperiode[!!periodegradu@tion][datesstyle=\tfxx]


\catcode`\@=12
\catcode`\!=12
\endinput