%% start of file `koma-moderncvclassic.sty' v0.5
%% Copyright 2010--2012 Salome Södergran (salome.soedergran@gmx.ch)
%%
%% Adaption of moderncv, theme classic
%% (Copyright 2006-2008 Xavier Danaux (xdanaux@gmail.com))
%% for use with Komascript-classes.
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.

% ==============================
%     IDENTIFICATION
% ==============================

\ProvidesPackage{koma-moderncvclassic}[2012/01/04 v0.5]
\NeedsTeXFormat{LaTeX2e}

% ==============================
%     OPTIONS
% ==============================
\newcommand*{\mycolor}{}
\DeclareOption{myblue}{\renewcommand*{\mycolor}{myblue}} 
\DeclareOption{blue}{\renewcommand*\mycolor{blue}}
\DeclareOption{red}{\renewcommand*\mycolor{red}}
\DeclareOption{green}{\renewcommand*\mycolor{green}}
\DeclareOption{cyan}{\renewcommand*\mycolor{cyan}}
\DeclareOption{magenta}{\renewcommand*\mycolor{magenta}}
\DeclareOption{yellow}{\renewcommand*\mycolor{yellow}}
\DeclareOption{black}{\renewcommand*\mycolor{black}}
\DeclareOption{white}{\renewcommand*\mycolor{white}}
\DeclareOption{gray}{\renewcommand*\mycolor{gray}}
\DeclareOption{darkgray}{\renewcommand*\mycolor{darkgray}}
\DeclareOption{lightgray}{\renewcommand*\mycolor{lightgray}}
\ExecuteOptions{myblue} % execute default option
\ProcessOptions\relax % execute given option

% ==============================
%     PACKAGES
% ==============================

\RequirePackage{ifthen,%
ifpdf,%
xcolor,%
lmodern,%
marvosym,%  symbols like \Telefon, \Letter, \Email
url,%
graphicx,%
hyperref%
}

%\hypersetup{%
%  breaklinks,
%  baseurl       = http://,%
%  pdfborder     = 0 0 0,%
%  pdfpagemode   = UseNone,%
%%  pdfstartview  = XYZ,%
%  pdfstartpage  = 1,%
%  pdfcreator    = \LaTeX{},%
%  pdfproducer   = \LaTeX}
%\AtEndOfClass{%
%  \AtBeginDocument{%
%    \hypersetup{%
%      pdfauthor     = \firstname~\familyname,%
%      pdftitle      = \title~\firstname~\familyname,%
%%      pdfsubject    = %\firstname~\familyname,%
%      pdfkeywords   = \firstname~\familyname{} curriculum vit\ae{}}}}
%\urlstyle{tt}

% ==============================
%     DEFINITIONS
% ==============================

% providelength (< Joseph Wright)
\newcommand*\providelength[1]{%
  \begingroup
    \escapechar\m@ne
    \xdef\@gtempa{\string#1}%
  \endgroup
  \@ifundefined{\@gtempa}%
    {\newskip#1}%
    {}%
}

% SYMBOLS
\newcommand*{\listitemsymbol}{\textbullet}
\newcommand*{\addresssymbol}{}
\newcommand*{\mobilesymbol}{\Mobilefone}
\newcommand*{\phonesymbol}{\Telefon}
\newcommand*{\faxsymbol}{\FAX}
\newcommand*{\emailsymbol}{\Letter}

% COLORS
\xdefinecolor{myblue}{rgb}{0.2,0.3,0.65}
% already predefined in xcolor:
% red, green, blue, cyan, magenta, yellow, black, white, darkgray, gray, lightgray
\colorlet{colortheme}{\mycolor}% color for  mycolor is given in preamble as package option
\colorlet{firstnamecolor}{black}
\colorlet{familynamecolor}{firstnamecolor}
\colorlet{acadtitlecolor}{firstnamecolor}
\colorlet{addresscolor}{firstnamecolor}
\colorlet{quotecolor}{firstnamecolor}
\colorlet{sectionrectanglecolor}{colortheme}
\colorlet{sectiontitlecolor}{colortheme}
\colorlet{subsectiontitlecolor}{colortheme}
\colorlet{hintcolor}{black}

% FONTS
\renewcommand*{\ttdefault}{pcr}
\newcommand*{\firstnamefont}{\fontsize{34}{36}\sffamily\mdseries\upshape}
\newcommand*{\familynamefont}{\firstnamefont}
\newcommand*{\acadtitlefont}{\LARGE\sffamily\mdseries\slshape}
\newcommand*{\addressfont}{\normalsize\rmfamily\mdseries\slshape}
\newcommand*{\quotefont}{\large\slshape}
\newcommand*{\hintfont}{\small\sffamily}
\setkomafont{section}{\Large\sffamily\mdseries\upshape}
\setkomafont{subsection}{\large\sffamily\mdseries\upshape}

% LENGTHS
\setlength\lineskip{1\p@}
\setlength\normallineskip{1\p@}
\renewcommand\baselinestretch{}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\setlength\columnsep{10\p@}
\setlength\columnseprule{0\p@}
%
% hintscolumnwidth
\newlength{\hintscolumnwidth}
\providelength{\myhintscolumnwidth}
\ifdim\myhintscolumnwidth=\z@
  \setlength\hintscolumnwidth{2,79cm}
\else
  \setlength{\hintscolumnwidth}{\myhintscolumnwidth}
\fi

% separatorcolumnwidth
\newlength{\separatorcolumnwidth}
\setlength{\separatorcolumnwidth}{0.025\textwidth}
% maincolumnwidth
\newlength{\maincolumnwidth}
  \setlength{\maincolumnwidth}{\textwidth}%
  \addtolength{\maincolumnwidth}{-\separatorcolumnwidth}%
  \addtolength{\maincolumnwidth}{-\hintscolumnwidth}%
% quotewidth
\newlength{\quotewidth}
% doubleitem lengths
\newlength{\doubleitemmaincolumnwidth}
  \setlength{\doubleitemmaincolumnwidth}{\maincolumnwidth}%
  \addtolength{\doubleitemmaincolumnwidth}{-\hintscolumnwidth}%
  \addtolength{\doubleitemmaincolumnwidth}{-\separatorcolumnwidth}%
  \setlength{\doubleitemmaincolumnwidth}{0.5\doubleitemmaincolumnwidth}%
% listitem lengths
\newlength{\listitemsymbolwidth}
\settowidth{\listitemsymbolwidth}{\listitemsymbol{}~}
\newlength{\listitemmaincolumnwidth}
  \setlength{\listitemmaincolumnwidth}{\maincolumnwidth}%
  \addtolength{\listitemmaincolumnwidth}{-\listitemsymbolwidth}%
% listdoubleitem lengths
\newlength{\listdoubleitemmaincolumnwidth}
  \setlength{\listdoubleitemmaincolumnwidth}{\maincolumnwidth}%
  \addtolength{\listdoubleitemmaincolumnwidth}{-\listitemsymbolwidth}%
 \setlength{\listdoubleitemmaincolumnwidth}{0.475\listdoubleitemmaincolumnwidth}%
\newlength{\cvcompcolumnwidth}
  \setlength{\cvcompcolumnwidth}{\textwidth}
  \addtolength{\cvcompcolumnwidth}{-3\separatorcolumnwidth}
  \addtolength{\cvcompcolumnwidth}{-2\hintscolumnwidth}
  \setlength{\cvcompcolumnwidth}{.5\cvcompcolumnwidth}

% ==============================
%     STYLES
% ==============================

\newcommand*{\firstnamestyle}[1]{{\firstnamefont\color{firstnamecolor}#1}}
\newcommand*{\familynamestyle}[1]{{\familynamefont\color{familynamecolor}#1}}
\newcommand*{\acadtitlestyle}[1]{{\acadtitlefont\color{acadtitlecolor}#1}}
\newcommand*{\addresstyle}[1]{{\addressfont\color{addresscolor}#1}}
\newcommand*{\quotestyle}[1]{{\quotefont\color{quotecolor}#1}}
\newcommand*{\sectionstyle}[1]{\usekomafont{section}\color{sectiontitlecolor}#1}\newcommand*{\subsectionstyle}[1]{\usekomafont{subsection}\color{subsectiontitlecolor}#1}
\newcommand*{\hintstyle}[1]{{\hintfont\color{hintcolor}#1}}

% ==============================
%     TITLE
% ==============================

% \title{}% to avoid LaTeX complaining that \maketitle is a called without first a call to \title
\renewcommand*{\maketitle}{}%

%   setmaketitlenamemaxwidth to the full name length, capped by \maketitlenamemaxwidth
\newlength{\maketitlenamemaxwidth}
\setlength{\maketitlenamemaxwidth}{.525\textwidth}
\newlength{\maketitlenamefullwidth}
\settowidth{\maketitlenamefullwidth}{\firstnamestyle{\firstname~}\familynamestyle{\familyname}}
\newlength{\maketitlenamewidth}
\ifnum\maketitlenamemaxwidth<\maketitlenamefullwidth\setlength{\maketitlenamewidth}{\maketitlenamemaxwidth}\else\setlength{\maketitlenamewidth}{\maketitlenamefullwidth}\fi

%  other lengths
\newlength{\photowidth}
\newcommand{\photo}[3][frame]{%
  \newcommand{\pictureframe}{#1}%
  \setlength{\photowidth}{#2}%
  \newcommand{\photoname}{#3}} 

\newlength{\maketitledetailswidth}
  \setlength{\maketitledetailswidth}{\textwidth}%
  \addtolength{\maketitledetailswidth}{-\maketitlenamewidth}%
 \addtolength{\maketitledetailswidth}{-\separatorcolumnwidth}%
 \AtBeginDocument{%
  \addtolength{\maketitledetailswidth}{-\photowidth}}

\newif\if@firstdetailselement\@firstdetailselementtrue
\newcommand*{\maketitledetailsnewline}{
  \if@firstdetailselement%
    \@firstdetailselementfalse%
  \else%
    \\[.2em]\fi}

\renewcommand*{\maketitle}{%
  % name and title
  \begin{minipage}[b]{\maketitlenamewidth}%
    \firstnamestyle{%
\firstname~}\familynamestyle{%
\familyname}%
    \ifthenelse{\equal{%
\acadtitle}{}}{}{\\[1.25em]\acadtitlestyle{%
\acadtitle}}%
  \end{minipage}%
  % optional data
\begin{minipage}[b]{\maketitledetailswidth}%
    \raggedleft\addressfont\color{addresscolor}%
    \ifthenelse{\isundefined{\addressstreet}}{}{%
      \maketitledetailsnewline%
      \addresssymbol~\addressstreet%
      \ifthenelse{\isundefined{\addresscity}}{}{\\\addresscity}}%
    \ifthenelse{\isundefined{\mobile}}{}{\maketitledetailsnewline\mobilesymbol~\mobile}%
    \ifthenelse{\isundefined{\phone}}{}{\maketitledetailsnewline\phonesymbol~\phone}%
    \ifthenelse{\isundefined{\faxnr}}{}{\maketitledetailsnewline\faxsymbol~\faxnr}%
    \ifthenelse{\isundefined{\email}}{}{\maketitledetailsnewline\emailsymbol~\emaillink{\email}}%
    \ifthenelse{\isundefined{\extrainfo}}{}{\maketitledetailsnewline\extrainfo}%
  \end{minipage}%
% optional photo
  \ifthenelse{\isundefined{\photoname}}%
    {}%
    {\hspace*{\separatorcolumnwidth}%
     \ifthenelse{\equal{\pictureframe}{noframe}}
      {\begin{minipage}[b]{\photowidth}
         \includegraphics[width=\photowidth]{\photoname}
       \end{minipage}}
      {\color{firstnamecolor}%
       \framebox{\includegraphics[width=\photowidth]{\photoname}}}} 
% optional quote
  \ifthenelse{\isundefined{%
\quote}}%
    {}%
    {\centering{\begin{minipage}{\quotewidth}\centering\quotestyle{\quote}\end{minipage}}%\\[2.5em]
}%
}

% ==============================
%     SECTIONS & ELEMENTS
% ==============================

% SECTIONS

\renewcommand*{\section}[1]{%
	\vspace*{3.5ex \@plus 1ex \@minus .2ex}%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{part}{#1}%
\parbox[m]{\hintscolumnwidth}{\raggedleft\hintfont{\color{sectionrectanglecolor}\rule{\hintscolumnwidth}{1ex}}}%
  \hspace{\separatorcolumnwidth}%
  \parbox[m]{\maincolumnwidth}{\sectionstyle{#1}}\\[1ex]}

% usage: \subsection{title}
\renewcommand*{\subsection}[1]{%
  \cvline[0.45em]{}{\subsectionstyle{#1}}\vspace{0.5ex}}

% ELEMENTS

% draws a colored rectangle
% usage: \colorrule[optional height]{width}
%\newcommand*{\colorrule}[2][1ex]{{\color{sectionrectanglecolor}{\rule{#2}{#1}}}}

% usage: \cvline{margintext}{linetext}
% from moderncv.cls
\newcommand*{\cvline}[3][.25em]{%
\begin{tabular}{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
 	  \raggedleft\hintfont{#2} &{#3}%
  \end{tabular}\\[#1]}
%

% usage: \cvdoubleitem{head 1}{description 1}{head 2}{description 2}:
\newcommand*{\cvdoubleitem}[4]{%
  \cvline{#1}{%
    \begin{minipage}[t]{\doubleitemmaincolumnwidth}#2\end{minipage}%
    \hfill%
    \begin{minipage}[t]{\hintscolumnwidth}\raggedleft%
      \hintfont{#3}\end{minipage}%
    \hspace*{\separatorcolumnwidth}%
    \begin{minipage}[t]{\doubleitemmaincolumnwidth}#4\end{minipage}}}


% usage: \cventry{years}{degree/job title}{institution/employer}{localization}{optionnal: grade/...}{optional: comment/job description}
\newcommand*{\cventry}[6]{%
  \cvline{#1}{%
    {\bfseries#2}%
    \ifx#3\else{, {\slshape#3}}\fi%
    \ifx#4\else{, #4}\fi%
    \ifx#5\else{, #5}\fi%
    .%
    \ifx#6\else{\newline{}\begin{minipage}[t]{\linewidth}\small#6\end{minipage}}\fi
    }}%

% usage (inside 'language' cvsection environment): \cvlanguage{name}{level}{comment}
\newcommand*{\cvlanguage}[3]{%
  \cvline{#1}{\begin{minipage}[t]{.225\maincolumnwidth}\textbf{#2}\end{minipage}\hfill\begin{minipage}[t]{0.725\maincolumnwidth}\raggedleft\footnotesize\itshape #3\end{minipage}}}

% usage (inside 'computer skills' cvsection environment): \cvcomputer{category}{programs}{category}{programs}
\newcommand*{\cvcomputer}[4]{\cvdoubleitem{#1}{\small#2}{#3}{\small#4}}

%  \cvlistdoubleitem{#1}{\small#2}{#3}{\small#4}}
% = original definition from moderncv.cls, result looks odd; new try:
%\begin{tabular*}{\textwidth}[t]{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\cvcompcolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\cvcompcolumnwidth}
%}
%\raggedleft{#1} &\raggedright{#2} &\raggedleft{#3} &\raggedright{#4}
%\end{tabular*}}

% usage: \link[optional text]{link}
\newcommand*{\link}[2][]{%
  \ifthenelse{\equal{#1}{}}%
    {\href{#2}{#2}}%
    {\href{#2}{#1}}}

% usage: \httplink[optional text]{link}
\newcommand*{\httplink}[2][]{%
  \ifthenelse{\equal{#1}{}}%
    {\href{http://#2}{#2}}%
    {\href{http://#2}{#1}}}

% usage: \emaillink[optional text]{link}
\newcommand*{\emaillink}[2][]{%
  \ifthenelse{\equal{#1}{}}%
    {\href{mailto:#2}{#2}}%
    {\href{mailto:#2}{#1}}}

% ==============================
%     VARIA
% ==============================

\raggedbottom
\onecolumn

\endinput

%% end of file `koma-moderncvclassic.sty'.