\NeedsTeXFormat{LaTeX2e}
\def\PackageName{bclogo}
\def\fileversion{v2.26}
\def\filedate{2011/07/06}
\ProvidesPackage{bclogo}
   [\filedate\space\fileversion]
\RequirePackage{xkeyval,ifthen}

%% Les options globales du package sont au nombre de 2: tikz ou pstricks
\newif\ifbclogotikz%
\newif\ifbclogoblur
\define@key{bclogo.sty}{tikz}[]{\bclogotikztrue}%
\define@key{bclogo.sty}{pstricks}[]{\bclogotikzfalse}%
\define@key{bclogo.sty}{blur}[]{\bclogoblurtrue}%
\newlength{\logowidth}\setlength{\logowidth}{17pt}%
\ProcessOptionsX%


\RequirePackage{graphicx}%
\ifbclogotikz%
\RequirePackage{tikz}%
\usetikzlibrary{shadows}% pour l'ombre
\usetikzlibrary{decorations.pathmorphing} % pour la barre ondulee
\else%
\ifbclogoblur\RequirePackage{pst-blur}\fi%
\RequirePackage{pstricks}%
\RequirePackage{pst-grad}%
\RequirePackage{pst-coil}% pour la barre ondulee
\fi%
\edef\Gin@extensions{.mps,\Gin@extensions}
\RequirePackage{ifpdf}
\ifpdf\relax\else\DeclareGraphicsRule{mps}{eps}{*}{}\fi
% les symboles
% ==============================================================================

% la fleur
\newcommand\bcfleur{\includegraphics[width=\logowidth]{bc-fleur}}
% une note (Thomas Labarussias)
\newcommand\bcnote{\includegraphics[width=\logowidth]{bc-note}}
% panneau chantier (Jean-Michel Sarlat)
\newcommand\bcpanchant{\includegraphics[width=\logowidth]{bc-aux-301}}
% ours
%\newcommand\bcours{\begingroup\input{bc-ours.tex}\endgroup}
\newcommand\bcours{\includegraphics[width=\logowidth]{bc-ours}}
% etoile
%\newcommand\bcetoile{\begingroup\input{bc-etoile.tex}\endgroup}
\newcommand\bcetoile{\includegraphics[width=\logowidth]{bc-etoile}}
% attention
%\newcommand\bcattention{\begingroup\input{bc-attention.tex}\endgroup}
\newcommand\bcattention{\includegraphics[width=\logowidth]{bc-attention}}
% attention P.Fradin
\newcommand\bctakecare{\includegraphics[width=\logowidth]{bc-takecare}}
% lampe P.Fradin
\newcommand\bclampe{\includegraphics[width=\logowidth]{bc-lampe}}
% coeur
\newcommand\bccoeur{\includegraphics[width=\logowidth]{bc-coeur}}
% ornement (tire du site http://openclipart.org )
\newcommand\bcorne{\includegraphics[width=\logowidth]{bc-orne}}
% danger (Francois)
\newcommand\bcdanger{\includegraphics[width=\logowidth]{bc-danger}}
% smiley bonne humeur (Francois)
\newcommand\bcsmbh{\includegraphics[width=\logowidth]{bc-smiley-bonnehumeur}}
% smiley bonne humeur (Francois)
\newcommand\bcsmmh{\includegraphics[width=\logowidth]{bc-smiley-mauvaisehumeur}}
% le trefle
\newcommand\bctrefle{\includegraphics[width=\logowidth]{bc-trefle}}
% le livre
\newcommand\bcbook{\includegraphics[width=\logowidth]{bc-book}}
% point d'interrogation
\newcommand\bcquestion{\includegraphics[width=\logowidth]{bc-inter}}
% crayon anne-sophie philippe
\newcommand\bccrayon{\includegraphics[width=\logowidth]{bc-crayon}}
% info (thomas labarrussias)
\newcommand\bcinfo{\includegraphics[width=\logowidth]{bc-info}}
% plume
\newcommand\bcplume{\includegraphics[width=\logowidth]{bc-plume}}
% le pic LaTeX
\newcommand\bcspadesuit{{\centering \huge $\spadesuit$}}
% logos Alphonse Capriani
\newcommand\bcbombe{\includegraphics[width=\logowidth]{bc-bombe}}
\newcommand\bccube{\includegraphics[width=\logowidth]{bc-cube}}
\newcommand\bcdallemagne{\includegraphics[width=\logowidth]{bc-dallemagne}}
\newcommand\bcdautriche{\includegraphics[width=\logowidth]{bc-dautriche}}
\newcommand\bcdbelgique{\includegraphics[width=\logowidth]{bc-dbelgique}}
\newcommand\bcdbulgarie{\includegraphics[width=\logowidth]{bc-dbulgarie}}
\newcommand\bcdfrance{\includegraphics[width=\logowidth]{bc-dfrance}}
\newcommand\bcditalie{\includegraphics[width=\logowidth]{bc-ditalie}}
\newcommand\bcdluxembourg{\includegraphics[width=\logowidth]{bc-dluxembourg}}
\newcommand\bcdpaysbas{\includegraphics[width=\logowidth]{bc-dpaysbas}}
\newcommand\bcdodecaedre{\includegraphics[width=\logowidth]{bc-dodecaedre}}
\newcommand\bceclaircie{\includegraphics[width=\logowidth]{bc-eclaircie}}
\newcommand\bcicosaedre{\includegraphics[width=\logowidth]{bc-icosaedre}}
\newcommand\bcinterdit{\includegraphics[width=\logowidth]{bc-interdit}}
\newcommand\bcneige{\includegraphics[width=\logowidth]{bc-neige}}
\newcommand\bcoctaedre{\includegraphics[width=\logowidth]{bc-octaedre}}
\newcommand\bcpluie{\includegraphics[width=\logowidth]{bc-pluie}}
\newcommand\bcpoisson{\includegraphics[width=\logowidth]{bc-poisson}}
\newcommand\bcsoleil{\includegraphics[width=\logowidth]{bc-soleil}}
\newcommand\bcstop{\includegraphics[width=\logowidth]{bc-stop}}
\newcommand\bctetraedre{\includegraphics[width=\logowidth]{bc-tetraedre}}
\newcommand\bccalendrier{\includegraphics[width=\logowidth]{bc-calendrier}}
\newcommand\bchorloge{\includegraphics[width=\logowidth]{bc-horloge}}
\newcommand\bcyin{\includegraphics[width=\logowidth]{bc-yin}}
\newcommand\bcrosevents{\includegraphics[width=\logowidth]{bc-rosevents}}
% fin alphonse
% Vincent Pantaloni route glissante
\newcommand\bcdz{\includegraphics[width=\logowidth]{bc-dz}}
% François Pétiard
\newcommand\bcvelo{\includegraphics[width=\logowidth]{bc-velo}}
\newcommand\bcoeil{\includegraphics[width=\logowidth]{bc-oeil}}
\newcommand\bcpeaceandlove{\includegraphics[width=\logowidth]{bc-peaceandlove}}
\newcommand\bcnucleaire{\includegraphics[width=\logowidth]{bc-nucleaire}}
\newcommand\bcfemme{\includegraphics[width=\logowidth]{bc-femme}}
\newcommand\bchomme{\includegraphics[width=\logowidth]{bc-homme}}
\newcommand\bcloupe{\includegraphics[width=\logowidth]{bc-loupe}}
\newcommand\bcrecyclage{\includegraphics[width=\logowidth]{bc-recyclage}}
\newcommand\bcvaletcoeur{\includegraphics[width=\logowidth]{bc-valetcoeur}}
\newcommand\bccle{\includegraphics[width=\logowidth]{bc-cle}}
\newcommand\bcclefa{\includegraphics[width=\logowidth]{bc-clefa}}
\newcommand\bcclesol{\includegraphics[width=\logowidth]{bc-clesol}}
\newcommand\bcfeujaune{\includegraphics[width=\logowidth]{bc-feujaune}}
\newcommand\bcfeurouge{\includegraphics[width=\logowidth]{bc-feurouge}}
\newcommand\bcfeutricolore{\includegraphics[width=\logowidth]{bc-feutricolore}}
\newcommand\bcfeuvert{\includegraphics[width=\logowidth]{bc-feuvert}}
\newcommand\bcoutil{\includegraphics[width=\logowidth]{bc-outil}}
\newcommand\bctrombone{\includegraphics[width=\logowidth]{bc-trombone}}
% fin François
% =========================== La fonction listable =============================

\newcommand{\titrebclogo}{Liste des \texttt{bclogo}}
\newcommand\bccaption[1]{\addcontentsline{bcl}{bclogo}{#1}}
\newcommand\listofbclogo{\section*{\titrebclogo}\@starttoc{bcl}}
\newcommand\l@bclogo[2]{\par\noindent #1,~\textit{page~#2}}
\newcounter{bclogocompteur} % idee de Francois Petiard

% ======================================= les keys =============================

\newlength{\bcval@epBarre} % on definit une longueur : l'epaisseur de la barre en point
\newlength{\bcval@framesep} % on definit une longueur : l'epaisseur de la marge en point
\newlength{\bcval@tailleOndu} % on definit une longueur : taille d'une ondulation
\newlength{\bcval@borderWidth} % on definit une longueur : epaisseur du bord
\define@key{bclogo}{logo}[\bcfleur]{\def\bcval@logo{#1}}
\define@key{bclogo}{couleur}[white]{\def\bcval@couleur{#1}}
\define@key{bclogo}{arrondi}[0]{\def\bcval@arrondi{#1}}
\define@key{bclogo}{epOmbre}[0.125]{\def\bcval@epOmbre{#1}}
\define@key{bclogo}{arrondi}[0]{\def\bcval@arrondi{#1}}
\define@key{bclogo}{couleurOmbre}[black]{\def\bcval@couleurOmbre{#1}}
\define@key{bclogo}{couleurBarre}[black]{\def\bcval@couleurBarre{#1}}
\define@key{bclogo}{couleurBord}[black]{\def\bcval@couleurBord{#1}} % modification Philippe Fortemps
\define@key{bclogo}{imageBarre}[]{\def\bcval@imageBarre{#1}}
\define@key{bclogo}{motifBarre}[*]{\def\bcval@motifBarre{#1}}
\define@key{bclogo}{marge}[4]{\setlength{\bcval@framesep}{#1 pt}\ifbclogotikz\else\setlength{\psframesep}{#1 pt}\fi}
\define@key{bclogo}{sousTitre}[]{\def\bcval@sousTitre{#1}}
\define@key{bclogo}{epBarre}[1.5]{\setlength{\bcval@epBarre}{#1 pt}}
\define@key{bclogo}{epBord}[0.8]{\setlength{\bcval@borderWidth}{#1 pt}}%
\define@key{bclogo}{tailleOndu}[2.5]{\setlength{\bcval@tailleOndu}{#1 pt}}
\define@boolkey{bclogo}{cadreTitre}[true]{}
\define@boolkey{bclogo}{noborder}[true]{}
\define@boolkey{bclogo}{ombre}[true]{}
\define@boolkey{bclogo}{avecBarre}[true]{}
\define@boolkey{bclogo}{blur}[true]{}
\define@choicekey{bclogo}{barre}{none,line,snake,motif,zigzag,imageExt,imageClip, wave}[line]{%
\ifthenelse{\equal{#1}{none}}{\KV@bclogo@avecBarrefalse}%
{\def\bc@barre{\@nameuse{bc@barre#1}}}%
}%

% selection par defaut
\presetkeys{bclogo}{logo,barre,couleur,arrondi,couleurOmbre,couleurBarre,epOmbre,epBarre,epBord,tailleOndu,ombre=false,cadreTitre=false, avecBarre=true,noborder=false,marge,sousTitre, couleurBord,blur=false}{}%

% les differente commande de barre vertical a gauche

\newcommand{\bc@barreline}{\color{\bcval@couleurBarre}\vrule width \bcval@epBarre}%

\newcommand{\bc@barremotif}{%
\begin{minipage}{\logowidth}\color{\bcval@couleurBarre}\centering%
\vbox to \bc@invboxh{\cleaders\vbox{\vss \bcval@motifBarre \vss}\vfill}%
\end{minipage}}

\newcommand{\bc@barrewave}{%
\begin{minipage}{\logowidth}\color{\bcval@couleurBarre}\centering%
\vbox to \bc@invboxh{\cleaders\vbox{\vss $\leftwave\right.$ \vss}\vfill}%
\end{minipage}}

\newcommand{\bc@barresnake}{%
\begin{minipage}{\logowidth}\centering
\ifbclogotikz
\begin{tikzpicture}[decoration={snake,segment length=2.66\bcval@tailleOndu, amplitude=\bcval@tailleOndu}]
\draw[decorate,line width=1pt, color=\bcval@couleurBarre](0,\bc@invboxh)--(0,0);\end{tikzpicture}%
\else
\psset{unit=1pt}
\begin{pspicture}(0,0)(0,\bc@invboxh)
\pszigzag[coilarm=0pt,coilwidth=2\bcval@tailleOndu,linewidth=1pt, linearc=1pt,coilheight=1.33,linecolor=\bcval@couleurBarre](0,\bc@invboxh)(0,0)
\end{pspicture}%
\fi
\end{minipage}}%

\newcommand{\bc@barrezigzag}{%
\begin{minipage}{\logowidth}\centering
\ifbclogotikz
\begin{tikzpicture}[decoration={zigzag,segment length=2.66\bcval@tailleOndu, amplitude=\bcval@tailleOndu}]
\draw[decorate,line width=1pt,color=\bcval@couleurBarre](0,\bc@invboxh)--(0,0);\end{tikzpicture}%
\else
\psset{unit=1pt}
\begin{pspicture}(0,0)(0,\bc@invboxh)
\pszigzag[coilarm=0pt,coilwidth=2\bcval@tailleOndu,linewidth=1pt,coilheight=1.33,linecolor=\bcval@couleurBarre](0,\bc@invboxh)(0,0)
\end{pspicture}%
\fi
\end{minipage}}%

\newcommand{\bc@barreimageExt}{% l'image est deformee
\begin{minipage}{\logowidth}\centering
\includegraphics[width=\logowidth,height=\bc@invboxh]{\bcval@imageBarre}
\end{minipage}
}%

\newcommand{\bc@barreimageClip}{%
\begin{minipage}{\logowidth}\centering
\includegraphics[viewport=0 0 \logowidth~ \bc@invboxh,%
clip=true]{\bcval@imageBarre}%
\end{minipage}
}%


%======================= Quelques definitions===================================
% boite globale
\newsavebox{\bc@envbox}
% boite interieure la ligne 2 du tableau barre + texte
\newsavebox{\bc@invbox}
% pour la hauteur de la boite
\newlength{\bc@invboxh}\newlength{\bc@invboxd}
%%% precaution JCC
\newcommand*\bclogotitre{}
\newcommand\styleSousTitre[1]{\normalsize \textit{#1}}
\newcommand\bcStyleTitre[1]{\large \textbf{#1}}
%======================= L'environnement =======================================

\newenvironment*{bclogo}[2][]{%
  \setkeys{bclogo}{#1}%on recupere les options
  % on definit les commandes qui seront utilisees dans la seconde
  % parti de l'environnement
  % la commande pour le titre
  \renewcommand*\bclogotitre{#2}%
  % La commande pour les coins arrondis
  \newcommand{\arr}{\bcval@arrondi}%
  % deux types de titres
  \ifKV@bclogo@cadreTitre% si cadreTitre = true
  \newcommand{\structitre}{%
    \ifbclogotikz% cadreTitre tizk
    \hfil
    \begin{tikzpicture}\node[rectangle, thick, top color=red!60!green!40, bottom color=white,draw]{\large #2};%
    \end{tikzpicture}%
    \hfil%
    \else% cadreTitre pstricks
    \hfil
    \psframebox[fillstyle=gradient,gradmidpoint=0.2, gradangle=0,gradbegin=red!60!green!40, gradend=white]{\large  #2}%
    \hfil%
    \fi%
  }%
  \else%sinon cadreTitre = false
  \newcommand{\structitre}{\bcStyleTitre{#2} \styleSousTitre{\bcval@sousTitre}}%
  \fi%
  \begin{lrbox}{\bc@invbox}%
\begin{minipage}{\dimexpr\linewidth-2\bcval@framesep-2\bcval@borderWidth-\logowidth-\ifKV@bclogo@ombre\bcval@epOmbre cm\else0pt\fi\relax}%
}%
{%
\end{minipage}%
\end{lrbox}%
% calcul de la hauteur totale de la boite interieure
\settoheight{\bc@invboxh}{\usebox{\bc@invbox}}%
\settodepth{\bc@invboxd}{\usebox{\bc@invbox}}%
\addtolength{\bc@invboxh}{\bc@invboxd}%

  % on commence la boite interieur ou est le texte et la barre vertical
  \begin{lrbox}{\bc@envbox}%
   \begin{tabular}{@{}c@{}p{\dimexpr\linewidth-2\bcval@framesep-2\bcval@borderWidth-\logowidth-\ifKV@bclogo@ombre\bcval@epOmbre cm\else0pt\fi+0pt}@{}}%
\begin{minipage}{\logowidth}%
\refstepcounter{bclogocompteur}\bccaption{\bclogotitre}\bcval@logo%
\end{minipage}%
&%
   \ifKV@bclogo@cadreTitre%
 \begin{minipage}{\dimexpr\linewidth-2\bcval@framesep-\logowidth-\ifKV@bclogo@ombre\bcval@epOmbre cm\else0pt\fi}\structitre\end{minipage}%
   \else\structitre\fi\tabularnewline%
   \ifKV@bclogo@avecBarre% si il y a une barre verticale
   \bc@barre&\usebox{\bc@invbox}%
   \else\multicolumn{2}{c}{\usebox{\bc@invbox}}%
   \fi%
   \end{tabular}%
  \end{lrbox}%
% Affiche l'ensemble dans un cadre en couleur.
  \ifbclogotikz% tikz
  \par\noindent%
  \begin{tikzpicture}%
    \ifKV@bclogo@ombre%cadre ombre
    \ifKV@bclogo@blur%blur
    \node[%
preaction={line width=6,line join=round,opacity=0.1,draw=\bcval@couleurOmbre,transform canvas={xshift=\bcval@epOmbre cm, yshift=-\bcval@epOmbre cm}},%
preaction={line width=5,line join=round,opacity=0.15,draw=\bcval@couleurOmbre,transform canvas={xshift=\bcval@epOmbre cm, yshift=-\bcval@epOmbre cm}},%
preaction={line width=4,line join=round,opacity=0.2,draw=\bcval@couleurOmbre,transform canvas={xshift=\bcval@epOmbre cm, yshift=-\bcval@epOmbre cm}},%
preaction={line width=3,line join=round,opacity=0.3,draw=\bcval@couleurOmbre,transform canvas={xshift=\bcval@epOmbre cm, yshift=-\bcval@epOmbre cm}},%
preaction={line width=2,line join=round,opacity=0.4,draw=\bcval@couleurOmbre,transform canvas={xshift=\bcval@epOmbre cm, yshift=-\bcval@epOmbre cm}},%
preaction={line width=1,line join=round,opacity=0.5,draw=\bcval@couleurOmbre,transform canvas={xshift=\bcval@epOmbre cm, yshift=-\bcval@epOmbre cm}},%
general shadow={fill=\bcval@couleurOmbre,opacity=1,shadow xshift=\bcval@epOmbre cm, shadow yshift=-\bcval@epOmbre cm},%
fill=\bcval@couleur,shape=rectangle,line width=\bcval@borderWidth, inner sep=\bcval@framesep, rounded corners=\arr cm,%
draw=\ifKV@bclogo@noborder none\else \bcval@couleurBord\fi]{\usebox{\bc@envbox}};%
    \else%ombre sans blur
    \node[fill=\bcval@couleur,shape=rectangle,line width=\bcval@borderWidth, inner sep=\bcval@framesep, rounded corners=\arr cm,%
    general shadow={fill=\bcval@couleurOmbre, shadow xshift=\bcval@epOmbre cm, shadow yshift=-\bcval@epOmbre cm}, draw=\ifKV@bclogo@noborder none\else \bcval@couleurBord\fi]{\usebox{\bc@envbox}};%
    \fi% fin ifblur
    \else%cadre sans ombre
    \node[fill=\bcval@couleur,thick, shape=rectangle,line width=\bcval@borderWidth, inner sep=\bcval@framesep,rounded corners=\arr cm, draw=\ifKV@bclogo@noborder none\else \bcval@couleurBord\fi]{\usebox{\bc@envbox}};%
    \fi%
  \end{tikzpicture}%
  %\par%
  \else%  pstricks
  \noindent%
  \ifKV@bclogo@ombre%cadre ombre
    \ifKV@bclogo@blur%blur
    \psframebox[cornersize=absolute,linearc=\dimexpr\arr cm * 2,fillstyle=solid, shadow=true, blur=true, shadowsize=\bcval@epOmbre cm,%
    shadowcolor=\bcval@couleurOmbre, fillcolor=\bcval@couleur,linewidth=\bcval@borderWidth, linestyle=\ifKV@bclogo@noborder none\else solid\fi,linecolor=\bcval@couleurBord]{\usebox{\bc@envbox}}%
    \else%
    \psframebox[cornersize=absolute,linearc=\dimexpr\arr cm * 2,fillstyle=solid, shadow=true, shadowsize=\bcval@epOmbre cm,%
    shadowcolor=\bcval@couleurOmbre, fillcolor=\bcval@couleur,linewidth=\bcval@borderWidth,linestyle=\ifKV@bclogo@noborder none\else solid\fi,linecolor=\bcval@couleurBord]{\usebox{\bc@envbox}}%
    \fi%
  \else%cadre sans ombre
  \psframebox[cornersize=absolute,linearc=\dimexpr\arr cm * 2  ,fillstyle=solid, fillcolor=\bcval@couleur,linewidth=\bcval@borderWidth, linestyle=\ifKV@bclogo@noborder none\else solid\fi,linecolor=\bcval@couleurBord]{\usebox{\bc@envbox}}%
  \fi%
  \fi%fin
  \ifKV@bclogo@ombre\vspace*{\bcval@epOmbre cm}\fi%
\hspace*{0pt}\par}%
