%
%  Cezary Sobaniec <cezary.sobaniec@cs.put.poznan.pl>
%
%  $Id: csbeamer.sty 3012 2012-07-05 20:22:47Z sobaniec $
%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{csbeamer}[2012/01/30 v1.0 CS presentations]

\usepackage{dcslib}[2012/01/30]

\useoutertheme{shadow}
\useinnertheme{rounded}
\usecolortheme{whale}


\ifunicodeengine
  \setprimaryfont[Scale=0.97]{Myriad Pro}
  \setallsansfonts[Scale=0.95]{Comic Sans MS}
  \setallsansfonts[Scale=0.94]{Ubuntu}
  \setallsansfonts[Scale=0.97]{Trebuchet MS}
  \setallsansfonts[Scale=0.93]{Open Sans}
  \setallsansfonts[Scale=1.0]{Calibri}
  \setallsansfonts[Scale=0.97]{Myriad Pro}
  \setallmonofonts[Scale=0.95]{Lekton}
  \lstset{basewidth=0.5em}
\else
  \usefonttheme{professionalfonts}
  \usepackage[scaled]{luximono}
\fi


\setbeamertemplate{headline}[default]
\setbeamertemplate{blocks}[default]

% colors
\setbeamercolor{block title}{fg=black,bg=black!12}
\setbeamercolor{block body}{fg=black,bg=black!6}
\setbeamercolor{block title example}{parent=block title}
\setbeamercolor{block body example}{parent=block body}
\mode<handout>{
  \usecolortheme{seagull}
  \setbeamercolor*{palette primary}{fg=black,bg=white}
  \setbeamercolor*{palette quaternary}{fg=black,bg=black!5}
  \setbeamercolor{block title}{fg=black,bg=black!6}
  \setbeamercolor{block body}{fg=black,bg=black!3}
  \setbeamercolor{block title example}{fg=black,bg=black!6}
  \setbeamercolor{block body example}{fg=black,bg=black!3}
}

\setbeamersize{text margin left=1cm,text margin right=1cm}
\setbeamerfont{author in head/foot}{series=\bfseries}
\setbeamerfont{title in head/foot}{series=\bfseries}

\newlength{\footerauthorlength}
\setlength{\footerauthorlength}{0.35\paperwidth}
\newlength{\footertitlelength}
\setlength{\footertitlelength}{0.65\paperwidth}
\defbeamertemplate*{footline}{shadow theme}
{%
  \leavevmode%
  \hbox{\begin{beamercolorbox}[wd=\footerauthorlength,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm plus1fill]{author in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=\footertitlelength,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm plus1fil]{title in head/foot}%
    \usebeamerfont{title in head/foot}\beamer@shorttitle\hfill[\insertframenumber/\inserttotalframenumber]
  \end{beamercolorbox}}%
  \vskip0pt%
}

% description
\setbeamersize{description width={2.5em}}
\setbeamerfont{description item}{series=\bfseries}

\setbeamerfont{itemize/enumerate subbody}{size=}
\setbeamerfont{itemize/enumerate subsubbody}{size=\small}

% no navigation symbols
\setbeamertemplate{navigation symbols}{}


% download button
\newcommand{\examplesbaseurl}{http://www.cs.put.poznan.pl/csobaniec/examples}
\newcommand{\downloadbuttonname}{Download}
\mode<presentation>{
  % download button
  \newcommand{\download}[2][\downloadbuttonname]{%
    {\parbox{\textwidth}{\vspace{-4.5em}\hfill\href{\examplesbaseurl/#2}{\beamergotobutton{#1}}}}}
}
\mode<handout>{
  % download button
  \renewcommand{\download}[2][]{}
}


% listings
\lstset{language=c}
\lstset{basicstyle=\scriptsize\ttfamily,
        language=,
        xleftmargin=0em,
        frame=none,
        framesep=0pt,
        keywordstyle=\bfseries\color{dkgreen},
        commentstyle=\itshape\color{dkblue},
        stringstyle=\color{dkred},
        directivestyle=\color{directive}
}
\lstset{language=}

\renewcommand{\codeincp}[2][]{\lstinputlisting[#1]{#2}}
\renewcommand{\codeincn}[2][]{\lstinputlisting[xleftmargin=1.8em,numbers=left,#1]{#2}}


% fonts
\DeclareOption{tmtt}{
  \renewcommand{\ttdefault}{tmtt}
  \lstset{basewidth=0.5em}
}

% hyperref
\hyperbaseurl{file://}
\hypersetup{breaklinks,colorlinks,urlcolor=structure,linkcolor=structure,%
            citecolor=structure,%
            pdfpagemode=none}


% url
\def\UrlFont{\fontfamily{lmss}\selectfont}


\DeclareOption{luxi}{
  \renewcommand{\ttdefault}{ul9}
  \lstset{basewidth={0.6em,0.45em}}
}

\DeclareOption{sectoc}{
  \AtBeginSection[]{
    \ifthenelse{\equal{\arabic{framenumber}}{1}}{}{%
      \begin{frame}<beamer>[plain]{}
	\tableofcontents[currentsection]
      \end{frame}
      \addtocounter{framenumber}{-1}
    }
  }
}

\DeclareOption{ssectoc}{
  \AtBeginSubsection[]{
    \ifthenelse{\equal{\arabic{framenumber}}{1}}{}{%
      \begin{frame}<beamer>[plain]{}
	\tableofcontents[currentsection,currentsubsection]
      \end{frame}
      \addtocounter{framenumber}{-1}
    }
  }
}

\AtBeginDocument{
  \let\origtableofcontents=\tableofcontents
  \def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
  \def\gobbletableofcontents#1{\origtableofcontents}
}
\newcommand{\heading}[1]{\addvspace{2ex}{\sffamily\bfseries #1}\par}

% LyX-Code
\providecommand{\lyxcodesetup}{}


\ProcessOptions\relax
