%
%   $Id: fpc.sty,v 1.25 2005/04/28 20:27:56 michael Exp $
%   This file is part of the FPC documentation.
%   Copyright (C) 1997, by Michael Van Canneyt
%
%   The FPC documentation is free text; you can redistribute it and/or
%   modify it under the terms of the GNU Library General Public License as
%   published by the Free Software Foundation; either version 2 of the
%   License, or (at your option) any later version.
%
%   The FPC Documentation is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%   Library General Public License for more details.
%
%   You should have received a copy of the GNU Library General Public
%   License along with the FPC documentation; see the file COPYING.LIB.  If not,
%   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
%   Boston, MA 02111-1307, USA.
%
\ProvidesPackage{fpc}[1996/12/09]
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{multicol}
\RequirePackage{epsfig}
\RequirePackage{xspace}
\RequirePackage{ifthen}
\RequirePackage{listings}
\RequirePackage{makeidx}
\RequirePackage{a4}
\RequirePackage{ifpdf}
\RequirePackage{fancyhdr}
\RequirePackage{afterpage}
\RequirePackage{float}
\ExecuteOptions{titlepage}
% Some style elements
\parindent 0pt%
\parskip 0.35\baselineskip%
% First, all definitions for latex only.
\newcommand{\docdescription}[1]{\def\@FPCDescription{#1}}
\gdef\@FPCDescription{}%
\newcommand{\docversion}[1]{\def\@FPCVersion{#1}}
\gdef\@FPCVersion{}%
% For backwards compatibility
\newcommand{\unitdescription}[1]{\def\@FPCDescription{#1}}
\newcommand{\unitversion}[1]{\def\@FPCVersion{#1}}
\renewcommand\maketitle{\begin{titlepage}%
  \let\footnotesize\small
  \let\footnoterule\relax
  \null\vfil
  \vskip 4cm%
  {\noindent\raggedright\Large\@title\\}%
  \noindent \rule{\linewidth}{1.5mm}\\%
  {\raggedleft\large%
      \begin{tabular}[t]{r}%
        \@FPCDescription \\
        Document version \@FPCVersion \\
        \@date
      \end{tabular}\par}%
   \vskip 5cm%
   {\noindent \large \textsf{\@author} \\%
    \rule{\linewidth}{0.5mm}}
  \@thanks
  \vfil\null
  \end{titlepage}%
  \setcounter{footnote}{0}%
  \let\thanks\relax\let\maketitle\relax
  \gdef\@thanks{}\gdef\@author{}\gdef\@title{}}
  % end of \maketitle
% For the \procedure and \function commands, we don't want heading numbers.
\setcounter{secnumdepth}{2}
% redefine the subsection command to leave less space,
%and to use sans serif
\renewcommand\subsection{\@startsection%
{subsection}%
{2}%
{\z@}%
{-4.25ex\@plus -1ex \@minus -.2ex}%
{1pt}%
{\normalfont\large\sffamily\bfseries}}
% Now, Let's define the \procedure and \function commands.
\newcommand{\FPClabel}[1]{%
\raggedleft\makebox[0pt][r]{\textsf{#1:}}
}
%
% FPC environments
%
% Lists
\newenvironment{FPCList}
{\begin{list}{}{%
  \renewcommand{\makelabel}[1]{\FPClabel{##1}\hfil\relax}
  \setlength{\labelwidth}{0pt}%
  \setlength{\leftmargin}{0pt}}%
  \setlength{\labelsep}{0pt}%
}
{\end{list}}
%
% remarks
%
\newenvironment{remark}{\par\makebox[0pt][r]{\bfseries{}Remark:\hspace{.25em}}}{\par}
% For Tables.
\newenvironment{FPCtable}[2]{\begin{table}[H]\caption{#2}\begin{center}\begin{tabular}{#1}}{\end{tabular}\end{center}\end{table}}
% The same, but with label in third argument (tab:#3)
\newenvironment{FPCltable}[3]{\begin{table}[H]\caption{#2}\label{tab:#3}\begin{center}\begin{tabular}{#1}}{\end{tabular}\end{center}\end{table}}
% Refs
%
\newcommand{\seefig}[1]{figure (\ref{fig:#1})\xspace}
\newcommand{\seefl}[2]{\textsf{#1} (\pageref{fu:#2})}
\newcommand{\seepl}[2]{\textsf{#1} (\pageref{pro:#2})}
\newcommand{\seetypel}[2]{\textsf{#1} (\pageref{ty:#2})}
\newcommand{\seeconstl}[2]{\textsf{#1} (\pageref{co:#2})}
\newcommand{\seevarl}[2]{\textsf{#1} (\pageref{var:#2})}
\newcommand{\seec}[1]{chapter \ref{ch:#1}, page \pageref{ch:#1}\xspace}
\newcommand{\sees}[1]{section \ref{se:#1}, page \pageref{se:#1}\xspace}
\newcommand{\seeo}[1]{\var{-#1} (see page \pageref{option:#1})\xspace}
\newcommand{\seet}[1]{table (\ref{tab:#1})\xspace}
%
% Function/procedure environments
%
\newenvironment{functionl}[2]{\subsection{#1}\index{#1}\label{fu:#2}\begin{FPCList}}{\end{FPCList}}
\newenvironment{procedurel}[2]{\subsection{#1}\index{#1}\label{pro:#2}\begin{FPCList}}{\end{FPCList}}
\newenvironment{method}[2]{\subsection{#1}\index{#1}\label{#2}\begin{FPCList}}{\end{FPCList}}
\newenvironment{property}[2]{\subsection{#1}\index{#1}\label{#2}\begin{FPCList}}{\end{FPCList}}
\newenvironment{function}[1]{\begin{functionl}{#1}{#1}}{\end{functionl}}
\newenvironment{procedure}[1]{\begin{procedurel}{#1}{#1}}{\end{procedurel}}
\newenvironment{typel}[2]{\subsection{#1}\index{#1}\label{ty:#2}\begin{FPCList}}{\end{FPCList}}
\newenvironment{type}[1]{\begin{typel}{#1}{#1}}{\end{typel}}
\newenvironment{constantl}[2]{\subsection{#1}\index{#1}\label{co:#2}\begin{FPCList}}{\end{FPCList}}
\newenvironment{constant}[1]{\begin{constantl}{#1}{#1}}{\end{constantl}}
\newenvironment{variablel}[2]{\subsection{#1}\index{#1}\label{var:#2}\begin{FPCList}}{\end{FPCList}}
\newenvironment{variable}[1]{\begin{variablel}{#1}{#1}}{\end{variablel}}
\newenvironment{ver2}{\par\textbf{version 2.0 only:}}{\par}
\newcommand{\Declaration}{\item[Declaration]\ttfamily}
\newcommand{\Description}{\item[Description]\rmfamily}
\newcommand{\Portability}{\item[Portability]\rmfamily}
\newcommand{\Errors}{\item[Errors]\rmfamily}
\newcommand{\VersionInfo}{\item[Version info]\rmfamily}
\newcommand{\Visibility}{\item[Visibility]\rmfamily}
\newcommand{\Access}{\item[Access]\rmfamily}
\newcommand{\Synopsis}{\item[Synopsis]\rmfamily}
\newcommand{\Arguments}{\item[Arguments]\rmfamily}
\newcommand{\SeeAlso}{\item[See also]\rmfamily}
%
% Ref without labels
%
\newcommand{\seef}[1]{\seefl{#1}{#1}}
\newcommand{\seep}[1]{\seepl{#1}{#1}}
\newcommand{\seetype}[1]{\seetypel{#1}{#1}}
\newcommand{\seevar}[1]{\seevarl{#1}{#1}}
\newcommand{\seeconst}[1]{\seeconstl{#1}{#1}}
%
% man page references don't need labels.
%
\newcommand{\seem}[2]{\texttt{#1} (#2) }
%
% HTML references
%
\newcommand{\seeurl}[2]{\htmladdnormallink{#1}{#2}}
%
% for easy typesetting of variables.
%
\newcommand{\var}[1]{\texttt {#1}}
\newcommand{\file}[1]{\textsf {#1}}
\newcommand{\key}[1]{\textsc{#1}}
\newcommand{\menu}[1]{\textbf{"#1"}}
%
% Useful references.
%
\newcommand{\progref}{\htmladdnormallink{Programmer's Guide}{../prog/prog.html}\xspace}
\newcommand{\fpdocref}{\htmladdnormallink{FPDoc Reference Guide}{../fpdoc/fpdoc.html}\xspace}
\newcommand{\refref}{\htmladdnormallink{Reference Guide}{../ref/ref.html}\xspace}
\newcommand{\userref}{\htmladdnormallink{User's Guide}{../user/user.html}\xspace}
\newcommand{\unitsref}{\htmladdnormallink{Unit Reference}{../rtl/index.html}\xspace}
\newcommand{\seecrt}{\htmladdnormallink{CRT}{../rtl/crt/index.html}\xspace}
\newcommand{\seelinux}{\htmladdnormallink{Linux}{../rtl/linux/index.html}\xspace}
\newcommand{\seestrings}{\htmladdnormallink{strings}{../rtl/strings/index.html}\xspace}
\newcommand{\seedos}{\htmladdnormallink{DOS}{../rtl/dos/index.html}\xspace}
\newcommand{\seegetopts}{\htmladdnormallink{getopts}{../rtl/getopts/index.html}\xspace}
\newcommand{\seeobjects}{\htmladdnormallink{objects}{../rtl/objects/index.html}\xspace}
\newcommand{\seegraph}{\htmladdnormallink{graph}{../rtl/graph/index.html}\xspace}
\newcommand{\seeprinter}{\htmladdnormallink{printer}{../rtl/printer/index.html}\xspace}
\newcommand{\seego}{\htmladdnormallink{GO32}{../rtl/go32/index.html}\xspace}
%
% Commands to reference these things.
%
\newcommand{\olabel}[1]{\label{option:#1}}
%
% some OSes
%
\newcommand{\linux}{\textsc{linux}\xspace}
\newcommand{\unix}{\textsc{unix}\xspace}
\newcommand{\dos}  {\textsc{dos}\xspace}
\newcommand{\msdos}{\textsc{ms-dos}\xspace}
\newcommand{\ostwo}{\textsc{os/2}\xspace}
\newcommand{\windows}{\textsc{Windows}\xspace}
\newcommand{\windowsnt}{\textsc{Windows NT}\xspace}
\newcommand{\macos}{{Mac OS}\xspace}
\newcommand{\fpc}{Free Pascal\xspace}
\newcommand{\gnu}{\textsc{gnu}\xspace}
\newcommand{\atari}{\textsc{Atari}\xspace}
\newcommand{\amiga}{\textsc{Amiga}\xspace}
\newcommand{\solaris}{\textsc{Solaris}\xspace}
\newcommand{\netware}{\textsc{Netware}\xspace}
\newcommand{\qnx}{\textsc{QNX Realtime platform}\xspace}
\newcommand{\beos}{\textsc{BeOS}\xspace}
\newcommand{\palmos}{\textsc{PalmOS}\xspace}
\newcommand{\netbsd}{\textsc{NetBSD}\xspace}
\newcommand{\openbsd}{\textsc{OpenBSD}\xspace}
\newcommand{\win}{\textsc{Win32}\xspace}
\newcommand{\freebsd}{\textsc{FreeBSD}\xspace}
\newcommand{\tp}{Turbo Pascal\xspace}
\newcommand{\delphi}{Delphi\xspace}
%
% Some versions
%
\newcommand{\fpcversion}{3.0.4}
%
% PDF stuff
%
\ifpdf
  \usepackage[pdftex,bookmarks=true,colorlinks=true,linkcolor=blue,pdfstartview={}]{hyperref}
  \usepackage{times}
  \usepackage[T1]{fontenc}
  \setcounter{secnumdepth}{2}
  \setcounter{tocdepth}{3}
  \pdfcompresslevel=9
  \pdfpagewidth=210mm
  \pdfpageheight=297mm
\else
\makeatletter
\@ifpackageloaded{tex4ht}{%
  \usepackage[tex4ht,bookmarks=true,colorlinks=true,linkcolor=blue]{hyperref}
}{%
  \usepackage[dvips,bookmarks=true,colorlinks=true,linkcolor=blue]{hyperref}
}%
\makeatother
\fi
%
% Fake Latex2Html support, so latex2html is not required
%
\RequirePackage{fakehtml}
%
% For examples
%
\makeatletter
\@ifpackageloaded{tex4ht}{%
\newcommand{\FPCexample}[1]{
\par \file{\textbf{Listing:} \exampledir/#1.pp}%
\HCode{<HR/>}%
\listinginput[9999]{5000}{\exampledir/#1.pp}%
\HCode{<HR/>}%
}%
\newcommand{\Cexample}[1]{
\par \file{\textbf{Listing:} \exampledir/#1.pp}%
\listinginput[9999]{5000}{\exampledir/#1.c}%
}
}{% else ifpackageloaded
\newcommand{\FPCexample}[1]{%
\par \file{\textbf{Listing:} \exampledir/#1.pp}%
\lstinputlisting{\exampledir/#1.pp}%
}% End of FPCExample
\newcommand{\Cexample}[1]{%
\par \file{\textbf{Listing:} \exampledir/#1.c}%
\lstinputlisting[language=c]{\exampledir/#1.c}%
}% End of CExample
}% End of ifpackageloaded.
\makeatother
\newcommand{\exampledir}{.}
\newcommand{\FPCexampledir}[1]{\renewcommand{\exampledir}{#1}}
%
% Picture including
%
\newcommand{\FPCpic}[3]{%
  \begin{figure}[ht]%
  \begin{center}
  \caption{#1}%
  \label{fig:#3}%
  \ifpdf%
    \epsfig{file=pics/#2/#3.png,width=\textwidth}%
  \else%
    \epsfig{file=pics/#2/#3.eps,width=\textwidth}%
  \fi%
  \end{center}
  \end{figure}%
}
%
% Categorical Function/procedure overviews
%
\newenvironment{funclist}{%
\par
\raisebox{-1em}{\makebox[\textwidth]{Name\hfill Description \hfill Page}}\\
\rule{\textwidth}{1pt}
\html{Name\hfill Description \hfill Page}
\begin{list}{}{%
\setlength{\rightmargin}{0pt}\setlength{\topsep}{0cm}\setlength{\partopsep}{0pt}%
\setlength{\itemsep}{0pt}\setlength{\labelwidth}{3.5cm}%
\setlength{\leftmargin}{4cm}%
\renewcommand{\makelabel}[1]{\textsf{##1\hfil}}%
}}%
{\end{list}}
\newcommand{\funcrefl}[3]{\item[#1] #3 \hfill\pageref{fu:#2}}
\newcommand{\funcref}[2]{\item[#1] #2 \hfill\pageref{fu:#1}}
\newcommand{\procrefl}[3]{\item[#1] #3 \hfill\pageref{pro:#2}}
\newcommand{\procref}[2]{\item[#1] #2 \hfill\pageref{pro:#1}}
%
% Set some listings options.
%
\makeatletter
\@ifpackageloaded{tex4ht}{%
\usepackage{moreverb}
}{%
  \usepackage{listings}%
  \lstset{language=Delphi}%
  \lstset{basicstyle=\sffamily\small}%
  \lstset{commentstyle=\itshape}%
  \lstset{keywordstyle=\bfseries}%
  \lstset{frame=tb}%
  \lstset{showstringspaces=false}%
} 
\makeatother
%
% Page settings
\setlength{\oddsidemargin}{20pt}
\addtolength{\textwidth}{39pt}
%
% FancyHeader settings.
%
\pagestyle{fancy}
\if@twoside % commands below work only for twoside option of \documentclass
   \fancyhead[LO,RE]{}
\else
   \fancyhead[LO]{}
\fi
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{\marginparwidth}
\addtolength{\headwidth}{-59pt}
%
% end of fpc.sty

