%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% novathesisFiles/ChapStyles/bluebox.sty
%% NOVA thesis configuration file
%%
%% Customization for the BlueBox chapter style
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\typeout{NT FILE novathesisFiles/ChapStyles/bluebox.sty}%


%%=======================================================================
%% SAVEBOXES & COLORS
%%=======================================================================

\newsavebox{\@nt@bluebox@ChpNumBox}
\definecolor{ChapBlue}{rgb}{0.7,0.8,0.9}


%%=======================================================================
%% HELPERS
%%=======================================================================

\newcommand*{\thickhrulefill}{%
  \leavevmode\leaders\hrule height 1\p@ \hfill \kern \z@%
}

\newcommand*\BuildChpNum[2]{%
  \begin{tabular}[t]{@{}c@{}}%
    \makebox[0pt][c]{#1\strut}  \\[.5ex]%
    \colorbox{ChapBlue}{%
      \rule[-10em]{0pt}{0pt}%
      \rule{1ex}{0pt}\color{black}#2\strut%
      \rule{1ex}{0pt}}%
  \end{tabular}%
}


%%=======================================================================
%% CHAPTER STYLE
%%=======================================================================

\makechapterstyle{BlueBox}{%
  \renewcommand{\chapnamefont}{\large\scshape}%
  \renewcommand{\chapnumfont}{\Huge\bfseries}%
  \renewcommand{\chaptitlefont}{\raggedright\Huge\bfseries}%
  \setlength{\beforechapskip}{20pt}%
  \setlength{\midchapskip}{26pt}%
  \setlength{\afterchapskip}{40pt}%
  \renewcommand{\printchaptername}{}%
  \renewcommand{\chapternamenum}{}%
  \renewcommand{\printchapternum}{%
    \sbox{\@nt@bluebox@ChpNumBox}{%
      \BuildChpNum{\chapnamefont\@chapapp}%
      {\chapnumfont\thechapter}}}%
  \renewcommand{\printchapternonum}{%
    \sbox{\@nt@bluebox@ChpNumBox}{%
      \BuildChpNum{\chapnamefont\vphantom{\@chapapp}}%
      {\chapnumfont\hphantom{\thechapter}}}}%
  \renewcommand{\afterchapternum}{}%
  \renewcommand{\printchaptertitle}[1]{%
    \usebox{\@nt@bluebox@ChpNumBox}\hfill%
    \parbox[t]{\hsize-\wd\@nt@bluebox@ChpNumBox-1em}{%
      \vspace{\midchapskip}%
      \thickhrulefill\par
      \chaptitlefont ##1\par}}%
}

\chapterstyle{BlueBox}
