%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*- Mode: Latex -*- %%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% beamerinnerthemetechnicolor.sty --- 
%% Author          : Marc Joye
%% Last Modified On: Fri Oct 21 13:17:42 2011
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newif\ifmj@black\mj@blackfalse
\ifx\undefined\mj@blackcolor\else
  \csname mj@black\mj@blackcolor\endcsname
\fi
\newif\ifmj@firsttitlepage\mj@firsttitlepagetrue

\mode<presentation>

%--------------------------------------------------------------------
%--- General default settings
%--------------------------------------------------------------------
\setbeamertemplate{sections/subsections in toc}[square]
\setbeamertemplate{items}[square]

% Technicolor images
\ifmj@black
  \pgfdeclareimage[width=\paperwidth]{footertechnicolor}{beamerbfootertechnicolor.png}
  \pgfdeclareimage[width=87.5pt]{flogotechnicolor}{beamerblogotechnicolor.png}
  \pgfdeclareimage[width=59.5pt]{logotechnicolor}{beamerblogotechnicolor.png}
\else
  \pgfdeclareimage[width=\paperwidth]{footertechnicolor}{beamerfootertechnicolor.png}
  \pgfdeclareimage[width=87.5pt]{flogotechnicolor}{beamerlogotechnicolor.png}
  \pgfdeclareimage[width=59.5pt]{logotechnicolor}{beamerlogotechnicolor.png}
\fi

% Use Technicolor logo
\logo{\pgfuseimage{logotechnicolor}}

% Use default sample image for title page
\def\mj@titlegraphicprefix{beamersampletechnicolor}
\def\mj@titlegraphicimage{\mj@titlegraphicprefix11}
\def\mj@titlegraphicoptions{\@empty}
\long\def\titlegraphic{\@ifstar{\mj@titlegraphics}{\mj@titlegraphic}}
\def\mj@titlegraphic{\@ifnextchar [{\mj@@titlegraphic}{\mj@@titlegraphic[]}}
\def\mj@titlegraphics{\@ifnextchar [{\mj@@titlegraphics}{\mj@@titlegraphics[]}}
\def\mj@@titlegraphic[#1]#2{%
  \gdef\mj@titlegraphicoptions{#1}
  \gdef\mj@titlegraphicimage{#2}}
\def\mj@@titlegraphics[#1]#2{%
  \gdef\mj@titlegraphicoptions{#1}
  \ifnum#2>0
  \gdef\mj@titlegraphicimage{\mj@titlegraphicprefix#2}\fi}
\newlength{\mj@titlegraphicheight}
\setlength{\mj@titlegraphicheight}{.458\paperheight}
\renewcommand{\inserttitlegraphic}{%
  \includegraphics[width=\paperwidth,height=\mj@titlegraphicheight,\mj@titlegraphicoptions]{\mj@titlegraphicimage}}


%--------------------------------------------------------------------
%--- Blocks
%--------------------------------------------------------------------
\defbeamertemplateparent{blocks}[technicolor]{block begin,block end,%
  block alerted begin,block alerted end,%
  block example begin,block example end}
{}

% Correct default block template when block title is empty
% Default block
\defbeamertemplate{block begin}{technicolor}
{
  \par\vskip\medskipamount%
  \ifx\@empty\insertblocktitle\else%
    \begin{beamercolorbox}[colsep*=.75ex]{block title}
      {\usebeamerfont*{block title}\insertblocktitle}%
    \end{beamercolorbox}%
    {\parskip0pt\par}%
    \ifbeamercolorempty[bg]{block title}
    {}
    {\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
  \fi
  \usebeamerfont{block body}%
  \begin{beamercolorbox}[colsep*=.75ex,vmode]{block body}
    \ifbeamercolorempty[bg]{block body}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
\defbeamertemplate{block end}{technicolor}%
{\end{beamercolorbox}\vskip\smallskipamount}

% Alerted block
\defbeamertemplate{block alerted begin}{technicolor}
{
  \par\vskip\medskipamount%
  \ifx\@empty\insertblocktitle\else%
    \begin{beamercolorbox}[colsep*=.75ex]{block title alerted}
      {\usebeamerfont*{block title alerted}\insertblocktitle}%
    \end{beamercolorbox}%
    {\parskip0pt\par}%
    \ifbeamercolorempty[bg]{block title alerted}
    {}
    {\ifbeamercolorempty[bg]{block body alerted}{}{\nointerlineskip\vskip-0.5pt}}%
  \fi
  \usebeamerfont{block body alerted}%
  \begin{beamercolorbox}[colsep*=.75ex,vmode]{block body alerted}
    \ifbeamercolorempty[bg]{block body alerted}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
\defbeamertemplate{block alerted end}{technicolor}%
{\end{beamercolorbox}\vskip\smallskipamount}

% Example block
\defbeamertemplate{block example begin}{technicolor}
{
  \par\vskip\medskipamount%
  \ifx\@empty\insertblocktitle\else%
    \begin{beamercolorbox}[colsep*=.75ex]{block title example}
      {\usebeamerfont*{block title example}\insertblocktitle}%
    \end{beamercolorbox}%
    {\parskip0pt\par}%
    \ifbeamercolorempty[bg]{block title example}
    {}
    {\ifbeamercolorempty[bg]{block body example}{}{\nointerlineskip\vskip-0.5pt}}%
  \fi
  \usebeamerfont{block body example}%
  \begin{beamercolorbox}[colsep*=.75ex,vmode]{block body example}
    \ifbeamercolorempty[bg]{block body example}{\vskip-.25ex}{\vskip-.75ex}\vbox{}%
}
\defbeamertemplate{block example end}{technicolor}%
{\end{beamercolorbox}\vskip\smallskipamount}

\setbeamertemplate{blocks}[technicolor]


%--------------------------------------------------------------------
%--- Part page
%--------------------------------------------------------------------
\defbeamertemplate*{part page}{technicolor}[1][]{%
  \thispagestyle{empty}%
  %Dimension \beamer@tempdim is used to remove the (left) sidebar on part pages
  %when outer theme sidebar is used.
  \beamer@tempdim=\z@%
  \ifx\undefined\beamer@sidebarwidth\else%
    \ifx\beamer@sidebarside\beamer@lefttext%
      \advance\beamer@tempdim by \beamer@sidebarwidth%
    \fi%
    \addtolength{\textwidth}{\beamer@tempdim}%
  \fi%
  \vbox to\z@{\vspace*{25pt}\vss}%
  \vskip.17\paperheight%
  \vbox to16pt{\hskip-\beamer@tempdim%
    \begin{beamercolorbox}[ht=.17\paperheight,wd=\paperwidth,center,sep=\z@,dp=\z@]{separation line}%
      \mbox{}%
    \end{beamercolorbox}\vss}% 
  \vbox to.75\mj@titlegraphicheight{\hskip-\beamer@tempdim%
    \begin{beamercolorbox}[wd=\paperwidth,ht=\mj@titlegraphicheight,dp=\z@,sep=\z@]{titlegraphic}%
      \vspace*{12pt}%
      \begin{beamercolorbox}[sep=8pt,ht=5.5ex,dp=1ex,right,rightskip=-.5\beamer@rightmargin]{titlegraphic}
        {\usebeamerfont{part name}\partname~\insertromanpartnumber}%
      \end{beamercolorbox}
      \vbox to\z@{\vspace*{-12pt}%
        \begin{beamercolorbox}[sep=4mm,wd=\paperwidth,ht=2.25ex,dp=1ex,right]{title}
          \usebeamerfont{part title}\usebeamercolor[fg]{titlegraphic}\insertpart\par
        \end{beamercolorbox}\vss}\vskip.162\paperheight
    \end{beamercolorbox}\vss}%
  \vbox to\z@{\hskip-\beamer@tempdim%
    \begin{beamercolorbox}[wd=\paperwidth,dp=\z@,center,sep=\z@]{}%
      \pgfuseimage{footertechnicolor}%
    \end{beamercolorbox}\vss}%
  %
  \vskip.08\paperheight
  \vbox to\z@{%
    \hbox{\hskip\paperwidth\hskip-\beamer@tempdim\hskip-115pt\pgfuseimage{flogotechnicolor}}\vss}}

\setbeamertemplate{part page}[technicolor]


%--------------------------------------------------------------------
%--- Title page
%--------------------------------------------------------------------
% Page style "empty" with navigation symbols removed
\def\ps@mj@empty{%
  \let\@mkboth\@gobbletwo%
  \def\@oddhead{\begingroup%
    \setbox\beamer@tempbox=\hbox{\usebeamertemplate***{background canvas}\hyper@pagetransition\hyper@pageduration}%
    \beamer@tempdim=\ht\beamer@tempbox%
    \setbox\beamer@tempbox=\hbox{\lower\beamer@tempdim\hbox{\box\beamer@tempbox}}%
    \wd\beamer@tempbox=0pt\ht\beamer@tempbox=0pt\dp\beamer@tempbox=0pt%
    \setbox\@tempboxa=\hbox{\usebeamertemplate***{background}}%
    \beamer@tempdim=\ht\@tempboxa%
    \setbox\@tempboxa=\hbox{\lower\beamer@tempdim\hbox{\box\@tempboxa}}%
    \wd\@tempboxa=0pt\ht\@tempboxa=0pt\dp\@tempboxa=0pt%
    \vbox{\hbox{\hskip-\Gm@lmargin\raise\headheight\box\beamer@tempbox\box\@tempboxa}\hfil}%
    \endgroup}
  \def\@oddfoot{}
  \let\@evenhead\@oddhead
  \let\@evenfoot\@oddfoot}

\defbeamertemplate*{title page}{technicolor}[1][]{%
  \thispagestyle{mj@empty}%
  \beamer@plainframetrue%
  \beamer@tempdim=\z@%
  \ifx\undefined\beamer@sidebarwidth\else%
    \ifx\beamer@sidebarside\beamer@lefttext\advance\beamer@tempdim by \beamer@sidebarwidth\fi%
    \addtolength{\textwidth}{\beamer@tempdim}%
  \fi%
  \setbox\beamer@tempbox=\hbox{{\usebeamerfont{title}\inserttitle}}%
  \beamer@dima=\wd\beamer@tempbox\advance\beamer@dima8pt
  \vbox to\z@{\vspace*{25pt}\hskip-\beamer@tempdim%
    \ifmj@firsttitlepage%
      \ifx\@empty\insertsubtitle\ifdim\beamer@dima>\hsize\vskip\z@\fi\fi%
      \vbox to\z@{\vss%
        \begin{beamercolorbox}[sep=8pt,ht=5.5ex,dp=1ex,right,rightskip=-.5\beamer@rightmargin]{title}
          \usebeamerfont{title}\inserttitle%MJ
        \end{beamercolorbox}}
      \ifx\@empty\insertsubtitle\else%
        \vskip-1ex%
        \vbox to\z@{\hskip-\beamer@tempdim%
          \begin{beamercolorbox}[sep=8pt,ht=2.25ex,dp=1ex,right,rightskip=-.5\beamer@rightmargin]{title}
            \usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle
          \end{beamercolorbox}\vss}
      \fi%
    \fi%
  \vss}%
  \vskip.17\paperheight%
  \vbox to16pt{\hskip-\beamer@tempdim%
    \begin{beamercolorbox}[ht=.17\paperheight,wd=\paperwidth,sep=\z@,dp=\z@]{separation line}%
      \mbox{}%
    \end{beamercolorbox}\vss}%
  \vbox to.75\mj@titlegraphicheight{\hskip-\beamer@tempdim%
     \begin{beamercolorbox}[wd=\paperwidth,ht=\mj@titlegraphicheight,dp=\z@,left,sep=\z@]{titlegraphic}%
       \ifmj@firsttitlepage%
         \inserttitlegraphic%
       \else
         \vbox to\z@{\vss%
            \begin{beamercolorbox}[sep=8pt,ht=5.5ex,dp=1ex,right,rightskip=-1.5\beamer@rightmargin]{titlegraphic}
              \usebeamerfont{title}\inserttitle
          \end{beamercolorbox}}%
        \vskip.041\paperheight%
        \vbox to\z@{\vss%
          \begin{beamercolorbox}[sep=8pt,ht=2.25ex,dp=1ex,right,rightskip=-1.5\beamer@rightmargin]{title}
            \ifx\@empty\insertsubtitle\else%
              \usebeamerfont{subtitle}\usebeamercolor[fg]{titlegraphic}\insertsubtitle%
            \fi
          \end{beamercolorbox}}\vskip.162\paperheight
       \fi
     \end{beamercolorbox}\vss}%
  \vbox to\z@{\hskip-\beamer@tempdim%
    \begin{beamercolorbox}[wd=\paperwidth,dp=\z@,center,sep=\z@]{}%
      \pgfuseimage{footertechnicolor}%
    \end{beamercolorbox}\vss}%
  %
  \vskip.08\paperheight
  \vbox to\z@{%
    \hbox{\hskip\paperwidth\hskip-\beamer@tempdim\hskip-115pt\pgfuseimage{flogotechnicolor}}\vss}%
  \vbox to\z@{\hskip-\beamer@tempdim%
    \begin{beamercolorbox}[sep=8pt,left,wd=.7\paperwidth]{author}
      \ifx\@empty\insertauthor\else%
        \def\beamer@andtitle{\ \raisebox{1.5pt}{$\centerdot$}\enspace\ }
        \usebeamerfont{author}\insertauthor
      \fi
    \end{beamercolorbox}\vss}}

\setbeamertemplate{title page}[technicolor]


%--------------------------------------------------------------------
%--- Frame title
%--------------------------------------------------------------------
\setbeamertemplate{frametitle}{%
  \beamer@tempdim=\paperwidth
  \advance\beamer@tempdim by -\beamer@leftsidebar%
  \advance\beamer@tempdim by -\beamer@rightsidebar%
  \begin{beamercolorbox}[wd=\beamer@tempdim,ht=2.4ex,dp=1ex,leftskip=\beamer@leftmargin]{frametitle}%
    \usebeamercolor{frametitle}\usebeamerfont{frametitle}\insertframetitle
  \end{beamercolorbox}
  \nointerlineskip\vskip.2ex

  \advance\beamer@tempdim by -\beamer@leftmargin%
  \advance\beamer@tempdim by -7pt%
  \hbox to\beamer@tempdim{\usebeamercolor[fg]{separation line}{\rule{\beamer@tempdim}{.67pt}}}}


\mode<all>
