%% This file is part of the Hagenberg Thesis package
%% Author: Wilhelm Burger (wilbur@ieee.org)
%% GitHub: https://github.com/Digital-Media/HagenbergThesis
%% File encoding: UTF-8

\ProvidesPackage{hgbtheme-fhooe24}[2025/02/24]%%AUTO
\RequirePackage{hgbdict}
\RequirePackage{forloop}
\RequirePackage{tikz}
\RequirePackage[absolute]{textpos}

% FH OÖ CD defines 15 square boxes horizontally on the page, thus one is 14mm wide
\setlength{\TPHorizModule}{14mm}
\setlength{\TPVertModule}{\TPHorizModule}

% Theres a margin of one box/module in the CD so we set the origin to that to avoid offset
\textblockorigin{\TPHorizModule}{\TPHorizModule}
\setlength{\parindent}{0pt}

%% Define various language-dependent text chunks to be used below -------------

\hgbDictionarySet{declaration-date}{english}%
	{\hgb@GetMonthName{english}{\hgb@SubmissionMonth} \hgb@SubmissionDay, \hgb@SubmissionYear}%
	
\hgbDictionarySet{declaration-date}{german}%
	{am \hgb@SubmissionDay.~\hgb@GetMonthName{german}{\hgb@SubmissionMonth} \hgb@SubmissionYear}%

%% Initialization (optional) --------------------------------------------------

\AddToHook{hgb@InitThemeHook}{%
	\typeout{hgbtheme-fhooe24: initializing theme}%
	% add initialization code if needed
}%

%% Structure of front pages ---------------------------------------------------

\renewcommand{\hgb@MakeFrontPages}{  %% stub defined in hgbthesis.cls
  \hgb@MakeTitlePage%
	\ifthenelse{\equal{\hgb@ThesisType}{internship}}%
		{\hgb@MakeCompanyPage}%
		{}%
	\ifthenelse{\boolean{hgb@IsProposal}}%
		{}% no copyright/declaration pages for proposals
		{%
			\hgb@MakeCopyrightPage%
			\hgb@MakeDeclarationPage%
		}%
}%
		
%% Title page ---------------------------------------------------

\newcommand{\hgb@MakeTitlePage}{%
\begin{titlepage}%
	% background image -----------------------------------------
	\AddToHookNext{shipout/background}{
		\begin{tikzpicture}[remember picture,overlay]
			\node at (current page.center) {
					\includegraphics{hgbtheme-fhooe24-coverbackground.pdf} % was 'fhooe-cover'
			};
		\end{tikzpicture}
	}

	\hgb@TitlePageFont%

	% author --------------------------------------------------
	\begin{textblock}{10}[0,1](0,7)
		{\Large\hgb@Author\par}%
	\end{textblock}

	% title --------------------------------------------------
	\begin{SwitchLanguage}{\hgb@MainLanguage}% thesis title is assumed to be in main document language!
		\begin{textblock}{10}(0,8)
			\raggedright% set ragged right to avoid hyphenation
			{\huge\bfseries\linespread{1.0}\selectfont\hgb@Title\par}%
			\vspace{5mm}% add space between title and subtitle
			{\LARGE\bfseries\linespread{1.0}\selectfont\hgb@SubTitle\par}%
		\end{textblock}
	\end{SwitchLanguage}%

	% thesis type ---------------------------------------------
	\begin{textblock}{10}[0,1](0,12)
		{\Large\@addspaces{\MakeUppercase{\hgb@ThesisName}}%
		\ifthenelse{\boolean{hgb@IsProposal}}%
			{\space\space(\@addspaces{\MakeUppercase{\hgb@ProposalName}})}{}\par}
	\end{textblock}

	% program type, program name ---------------------------------
	\begin{textblock}{10}(0,13)
		{\large \hgb@ProgramType\par}%
		{\large\hgb@ProgramName\par}%
	\end{textblock}

	% institution, place of study ---------------------------------------------
	\begin{textblock}{10}(0,14)
		{\large\hgb@Institution\par}%
		{\large\hgb@PlaceOfStudy\par}%
	\end{textblock}

	% submission year  ---------------------------------
	\begin{textblock}{10}[0,1](0,16)
		{\large\hgb@SubmissionYear\par}%
	\end{textblock}

	% advisors(s) -------------------------------------
	\ifthenelse{\equal{\hgb@ThesisType}{internship}}%
		{}%
		{%
			\begin{textblock}{10}(0,17)
				\ifthenelse{\hgb@AdvisorCount > 0}%
					{%
						\@makeAdvisorTable% defined below
					}%
					{%
						\color{red}No advisor(s) specified!\\
					}%
			\end{textblock}
		}%

	\null%	required to tell LaTeX that there is a non-empty content box
\end{titlepage}%
}

%% Advisor Table ----------------------------------------

\newcommand{\@makeAdvisorTable}{%
  \newcounter{C}%
	\renewcommand{\arraystretch}{1.25}%
  \begin{tabular}{@{}ll@{}}%
    \forloop{C}{1}{\not{\value{C} > \hgb@AdvisorCount}}{%   see 'forloop' package
      \hgb@getAdvisorRole{\theC}: & \hgb@getAdvisorName{\theC}%
      \ifthenelse{\value{C} < \hgb@AdvisorCount}{\\}{}% avoid extra \\ in last line!
    }%
  \end{tabular}%
}

%% Copyright/License Page ----------------------------------------

\newcommand{\hgb@MakeCopyrightPage}{%
  \newpage
  \thispagestyle{plain}
  \rule{0mm}{1mm}
  \vspace*{75mm}
  \begin{center}
  \textsf{\copyright\ Copyright\ \hgb@SubmissionYear\ \hgb@Author}
  \end{center}
  \vspace{8mm}
  \hgbJustifyOrCenter{\hgbDictionaryGet{\hgb@License}{\hgb@TitleLanguage}}% defined in hgb.sty
}

%% Declaration Page ----------------------------------------

\newcommand{\hgb@MakeDeclarationPage}{
	\chapter{\hgbDictionaryGet{declaration-title}{\hgb@TitleLanguage}}
	\noindent%
	\hgbDictionaryGet{declaration-text}{\hgb@TitleLanguage}%
	\par
	\vspace{10mm}
	\noindent
	{\hgb@PlaceOfStudy, \hgbDictionaryGet{declaration-date}{\hgb@TitleLanguage}}%
	\par
	\vspace{12mm}
	\noindent
	\hgb@Author
}

%% Company Page for Internship Reports ------------------------------

\newcommand{\hgb@MakeCompanyPage}{%
	\newpage
	\thispagestyle{plain}
	\rule{0mm}{1mm}
	\begin{center}
		\vspace{25mm} 
		{\hgbDictionaryGet{internship}{\hgb@TitleLanguage}:}
		\\
		\vspace{3mm}
		{\Large\sf\hgb@CompanyName\\ \mbox{}}
		\\
		{\sf \hgb@CompanyUrl}
		\\
		\vspace{45mm} 
		\ifthenelse{\hgb@AdvisorCount = 1}%
			{%
				{\hgbDictionaryGet{internship-contact-single}{\hgb@TitleLanguage}:}%
			}%
			{}%
		\ifthenelse{\hgb@AdvisorCount > 1}%
			{%
				{\hgbDictionaryGet{internship-contact-multiple}{\hgb@TitleLanguage}:}%
			}%
			{}%
		\par\vspace{6mm}%
		\ifthenelse{\hgb@AdvisorCount > 0}%
			{%
				\large\sffamily\@makeAdvisorTable% defined above
			}%
			{%
				\color{red}No advisor(s) specified!\\
			}%
	\end{center}
}
