\ProvidesPackageRCS $Header: /cvsroot/latex-beamer/latex-beamer/base/beamerbaseboxes.sty,v 1.22 2004/10/28 16:42:54 tantau Exp $

% Copyright 2003 by Till Tantau <tantau@users.sourceforge.net>.
%
% This program can be redistributed and/or modified under the terms
% of the GNU Public License, version 2.

\RequirePackage{keyval}

\def\beamerboxesdeclarecolorscheme#1#2#3{% scheme name, upper color, lower color
  \setbeamercolor{@scheme upper #1}{fg=white,bg=#2}
  \setbeamercolor{@scheme lower #1}{bg=#3}
}

\define@key{beamerboxes}{scheme}{\def\bmb@upper{@scheme upper #1}\def\bmb@lower{@scheme lower #1}}
\define@key{beamerboxes}{upper}{\def\bmb@upper{#1}}
\define@key{beamerboxes}{lower}{\def\bmb@lower{#1}}
\define@key{beamerboxes}{width}{\edef\bmb@width{#1}}
\define@key{beamerboxes}{shadow}[true]{\csname bmb@shadow#1\endcsname}

\newif\ifbmb@shadow
\newbox\bmb@box
\newbox\bmb@colorbox
\newbox\bmb@boxshadow
\newbox\bmb@boxshadowball
\newbox\bmb@boxshadowballlarge
\newdimen\bmb@temp
\newdimen\bmb@dima
\newdimen\bmb@dimb
\newdimen\bmb@prevheight

\newcommand\beamerboxesrounded[2][]{%
  \global\let\beamer@firstlineitemizeunskip=\relax%
  \vbox\bgroup%
  \setkeys{beamerboxes}{upper=block title,lower=block body,width=\textwidth,shadow=false}%
  \setkeys{beamerboxes}{#1}%
  {%
    \usebeamercolor{\bmb@lower}%
    \globalcolorstrue%
    \colorlet{lower.bg}{bg}%
  }%
  {%
    \usebeamercolor{\bmb@upper}%
    \globalcolorstrue%
    \colorlet{upper.bg}{bg}%
  }%
  %
  % Typeset head
  %
  \vskip4bp
  \setbox\bmb@box=\hbox{%
    \begin{minipage}[b]{\bmb@width}%
      \usebeamercolor[fg]{\bmb@upper}%
      #2%
    \end{minipage}}%
  \ifdim\wd\bmb@box=0pt%
    \setbox\bmb@box=\hbox{}%
    \ht\bmb@box=1.5pt%
    \bmb@prevheight=-4.5pt%
  \else%
    \wd\bmb@box=\bmb@width%
    \bmb@temp=\dp\bmb@box%
    \ifdim\bmb@temp<1.5pt%
      \bmb@temp=1.5pt%
    \fi%
    \setbox\bmb@box=\hbox{\raise\bmb@temp\hbox{\box\bmb@box}}%
    \dp\bmb@box=0pt%
    \bmb@prevheight=\ht\bmb@box%
  \fi%
  \bmb@temp=\bmb@width%
  \bmb@dima=\bmb@temp\advance\bmb@dima by2.2bp%
  \bmb@dimb=\bmb@temp\advance\bmb@dimb by4bp%
  \hbox{%
    \begin{pgfpicture}{0bp}{-\ht\bmb@box}{0bp}{-\ht\bmb@box}
      \ifdim\wd\bmb@box=0pt%
        \color{lower.bg}%
      \else%        
        \color{upper.bg}%
      \fi%  
      \pgfqmoveto{-4}{-1}
      \pgfqcurveto{-4}{1.2}{-2.2}{3}{0}{3}
      \pgflineto{\pgfpoint{\bmb@temp}{3bp}}
      \pgfcurveto%
      {\pgfpoint{\bmb@dima}{3bp}}%
      {\pgfpoint{\bmb@dimb}{1.2bp}}%
      {\pgfpoint{\bmb@dimb}{-1bp}}%
      \bmb@dima=-\ht\bmb@box%
      \advance\bmb@dima by-2pt%
      \pgflineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
      \pgflineto{\pgfpoint{-4bp}{\bmb@dima}}
      \pgffill
    \end{pgfpicture}%
    \copy\bmb@box%
  }%
  \nointerlineskip%
  \vskip-1pt%
  \ifdim\wd\bmb@box=0pt%
  \else%
  \hbox{%
    \begin{pgfpicture}{0pt}{0pt}{\bmb@width}{6pt}
      \bmb@dima=\bmb@width%
      \advance\bmb@dima by8bp%
      \pgfrect[clip]{\pgfpoint{-4bp}{-1bp}}{\pgfpoint{\bmb@dima}{8bp}}
      \pgfputat{\pgfpoint{-4bp}{0bp}}{\pgfbox[left,base]{\pgfuseshading{bmb@transition}}}%
    \end{pgfpicture}%
  }%
  \nointerlineskip%
  \vskip-0.5pt%
  \fi%
  \ifbmb@shadow%
    \setbox\bmb@boxshadow=\hbox{\pgfuseshading{bmb@shadow}}%
    \setbox\bmb@boxshadowball=\hbox{\pgfuseshading{bmb@shadowball}}%
    \setbox\bmb@boxshadowballlarge=\hbox{\pgfuseshading{bmb@shadowballlarge}}%
  \fi%
  \setbox\bmb@colorbox=\hbox{\color{lower.bg}}%
  \setbox\bmb@box=\hbox\bgroup\begin{minipage}[b]{\bmb@width}%
    \vskip2pt%
    \usebeamercolor[fg]{\bmb@lower}%
    \colorlet{beamerstructure}{upper.bg}%
    \colorlet{structure}{upper.bg}%
    %\color{.}%
  }

\def\endbeamerboxesrounded{%
  \end{minipage}\egroup%
  \wd\bmb@box=\bmb@width%
  \bmb@temp=\dp\bmb@box%
  \advance\bmb@temp by.5pt%
  \setbox\bmb@box=\hbox{\raise\bmb@temp\hbox{\box\bmb@box}}%
  \dp\bmb@box=0pt%
  \bmb@temp=\wd\bmb@box%
  \bmb@dima=\bmb@temp\advance\bmb@dima by2.2bp%
  \bmb@dimb=\bmb@temp\advance\bmb@dimb by4bp%
  \hbox{%
    \begin{pgfpicture}{0bp}{0bp}{0bp}{0bp}
      \ifbmb@shadow%
      \pgfputat{\pgfpoint{4bp}{-3bp}}{\pgfbox[center,center]{\copy\bmb@boxshadowball}}
      \begin{pgfscope}
        {%
        \advance\bmb@temp by-1bp%
        \pgfrect[clip]{\pgfpoint{\bmb@temp}{-7bp}}{\pgfpoint{9bp}{9bp}}%
        }%
        \pgfputat{\pgfpoint{\bmb@temp}{1bp}}{\pgfbox[center,center]{\box\bmb@boxshadowballlarge}}
      \end{pgfscope}
      \begin{pgfscope}
        \advance\bmb@temp by-4bp%
        \pgfrect[clip]{\pgfpoint{4bp}{-7bp}}{\pgfpoint{\bmb@temp}{5bp}}
        \pgfputat{\pgfpoint{4bp}{-7bp}}{\pgfbox[left,base]{\copy\bmb@boxshadow}}%
      \end{pgfscope}
      \begin{pgfscope}
        \advance\bmb@temp by 4bp%
        \bmb@dima=\ht\bmb@box%
        \advance\bmb@dima by\bmb@prevheight%
        \advance\bmb@dima by 4bp%
        \pgfrect[clip]{\pgfpoint{\bmb@temp}{1bp}}{\pgfpoint{4bp}{\bmb@dima}}
        \advance\bmb@dima by-4bp%
        \pgfputat{\pgfpoint{\bmb@temp}{\bmb@dima}}{\pgfbox[center,center]{\box\bmb@boxshadowball}}
        \advance\bmb@dima by-1bp%
        \pgfrect[clip]{\pgfpoint{\bmb@temp}{1bp}}{\pgfpoint{4bp}{\bmb@dima}}
        \advance\bmb@temp by4bp%
        \pgfputat{\pgfpoint{\bmb@temp}{-3bp}}%
        {\begin{pgfrotateby}{\pgfdegree{90}}\pgfbox[left,base]{\box\bmb@boxshadow}\end{pgfrotateby}}%
      \end{pgfscope}
      \fi%
      \unhbox\bmb@colorbox%
      \pgfqmoveto{-4}{1}
      \pgfqcurveto{-4}{-1.2}{-2.2}{-3}{0}{-3}
      \pgflineto{\pgfpoint{\the\bmb@temp}{-3bp}}
      \pgfcurveto%
      {\pgfpoint{\the\bmb@dima}{-3bp}}%
      {\pgfpoint{\the\bmb@dimb}{-1.2bp}}%
      {\pgfpoint{\the\bmb@dimb}{1bp}}%
      {
      \bmb@dima=\ht\bmb@box%
      \pgflineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
      \pgflineto{\pgfpoint{-4bp}{\bmb@dima}}
      \pgffill
      }
      {
        \color{black!50!bg}
        \pgfsetlinewidth{0pt}
        \pgfmoveto{\pgfpoint{\bmb@dimb}{-.5bp}}
        \bmb@dima=\ht\bmb@box%
        \advance\bmb@dima by\bmb@prevheight%
        \advance\bmb@dima by 1bp%
        \pgflineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
        \pgfstroke
        \bmb@temp=\bmb@dima
        \advance\bmb@dima by 1bp%
        \color{black!31!bg}
        \pgfmoveto{\pgfpoint{\bmb@dimb}{\bmb@temp}}
        \pgflineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
        \pgfstroke
        \advance\bmb@dima by 1bp%
        \advance\bmb@temp by 1bp%
        \color{black!19!bg}
        \pgfmoveto{\pgfpoint{\bmb@dimb}{\bmb@temp}}
        \pgflineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
        \pgfstroke
        \advance\bmb@dima by 1bp%
        \advance\bmb@temp by 1bp%
        \color{black!6!bg}
        \pgfmoveto{\pgfpoint{\bmb@dimb}{\bmb@temp}}
        \pgflineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
        \pgfstroke
        \advance\bmb@dima by 1.5bp%
        \advance\bmb@temp by 1bp%
        \color{bg}
        \pgfmoveto{\pgfpoint{\bmb@dimb}{\bmb@temp}}
        \pgflineto{\pgfpoint{\bmb@dimb}{\bmb@dima}}
        \pgfstroke
      }
      {
      }      
    \end{pgfpicture}%
    \box\bmb@box%
  }%
  \ifbmb@shadow%
    \vskip4bp minus 2bp%
  \else%
    \vskip2bp%
  \fi%
  \egroup% of \vbox\bgroup
}

%
% Shadings
%

% Shadows
\pgfdeclareradialshading[black,bg]{bmb@shadowball}{\pgforigin}{%
  color(0bp)=(black!50!bg); color(4bp)=(bg)}
\pgfdeclareradialshading[black,bg]{bmb@shadowballlarge}{\pgforigin}{%
  color(0bp)=(black!50!bg); color(4bp)=(black!50!bg); color(8bp)=(bg)}
\pgfdeclareverticalshading[black,bg]{bmb@shadow}{30cm}{%
  color(0bp)=(bg); color(4bp)=(black!50!bg); color(8bp)=(black!50!bg)}

% Transition line
\pgfdeclareverticalshading[lower.bg,upper.bg]{bmb@transition}{30cm}{%
  color(0pt)=(lower.bg); color(2pt)=(lower.bg); color(4pt)=(upper.bg)}

