% \iffalse meta-comment
%
% p2e-drivers.dtx
% Time-stamp: "p2e-drivers.dtx 2004-06-25 08:23:34 CEST Friday hubertjg"
%
%
% Copyright (C) 2003, 2004
% Rolf Niepraschk, Rolf.Niepraschk@ptb.de
% Hubert Gaesslein, HubertJG@open.mind.de
%
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
%
% This work has the LPPL maintenance status "author-maintained".
%
% This work consists of all files listed in manifest.txt.
%
%
% This file is part of the New Implementation of the Standard LaTeX
% picture commands (package pict2e). It complements the file
% drivers.dtx from the Standard LaTeX `Graphics Bundle'.
%
%
%<template, >\ProvidesFile{p2e-template.def}
%<dvips,    >\ProvidesFile{p2e-dvips.def}
%<xdvi,     >\ProvidesFile{p2e-xdvi.def}
%<pdftex,   >\ProvidesFile{p2e-pdftex.def}
%<vtex,     >\ProvidesFile{p2e-vtex.def}
%<dvipdfm,  >\ProvidesFile{p2e-dvipdfm.def}
%<textures, >\ProvidesFile{p2e-textures.def}
%<pctexps,  >\ProvidesFile{p2e-pctexps.def}
%<pctex32,  >\ProvidesFile{p2e-pctex32.def}
%
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{p2e-drivers.dtx}
%</driver>
%
%<cfg>\ProvidesFile{pict2e.cfg}%
        [2004/06/25 v0.1r
%<*!cfg>
                          Driver-dependant file (RN,HjG)]
%</!cfg>
%<cfg>                          pict2e configuration for teTeX/TeXLive]
%
%<*driver>
\documentclass{ltxdoc}
  \GetFileInfo{p2e-drivers.dtx}
  \def\docdate{2004/06/25}
\begin{document}
  \title{Graphics drivers for \textsf{pict2e}\thanks
    {This document corresponds to \textsf{\filename} \fileversion,
     dated \filedate, documentation dated \docdate.}}
  \author{Rolf Niepraschk\thanks{\texttt{Rolf.Niepraschk@ptb.de}}
     \,and Hubert G\"a{\ss}lein\thanks{\texttt{HubertJG@open.mind.de}}}
  \date{\filedate}
 % \maketitle
  \DocInput{p2e-drivers.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{101}
%
% \changes{v0.1g}{2003/11/07}{Translated documentation to English (HjG)}
% \changes{v0.1g}{2003/11/07}{Added driver \texttt{dvipdfm} (RN)}
% \changes{v0.1h}{2003/11/12}{Move check for \texttt{ver@\backslash Gin@driver}
%   to package pict2e (RN,HjG)}
% \changes{v0.1h}{2003/11/12}{General cleaning (RN,HjG)}
% \changes{v0.1h}{2003/11/12}{More general cleaning (HjG)}
% \changes{v0.1i}{2003/11/22}{M-x delete-trailing-whitespace (HjG)}
% \changes{v0.1j}{2003/12/13}{Resurrect reference to latexbugs address (HjG)}
% \changes{v0.1j}{2003/12/13}{Try new driver for \textsf{xdvi}---to no avail (HjG)}
% \changes{v0.1k}{2003/12/18}{Polish up documentation (HjG)}
% \changes{v0.1l}{2003/12/19}{Some tentative entries for new drivers (HjG)}
% \changes{v0.1l}{2003/12/19}{Polish up documentation (HjG)}
% \changes{v0.1m}{2003/12/21}{Polish up documentation (HjG)}
% \changes{v0.1o}{2004/02/19}{Fix some typos (HjG)}
% \changes{v0.1p}{2004/03/26}{Minor changes to documentation (HjG)}
% \changes{v0.1q}{2004/04/22}{Added lppl (RN/HjG)}
% \changes{v0.1r}{2004/06/25}{Small fixes in documentation (HjG)}
%
% \newcommand*\PS{PostScript}
% \newcommand*\PDF{PDF}
% \newcommand*\teTeX{te\kern-.11em\TeX}
% \newcommand*\TeXlive{\TeX live}
%
% \makeatletter
% \@ifundefined{ifdeveloping}{\newif\ifdeveloping}{} ^^A false by default
% \makeatother
%
% \ifdeveloping
%   \makeatletter
%
%   \newcommand*\isodattim{}
%   \begingroup
%     \count@\time
%     \divide\count@ 60
%     \count2=-\count@
%     \multiply\count2 60
%     \advance\count2 \time
%     \xdef\isodattim{^^A
%       \the\year-\two@digits{\the\month}-\two@digits{\the\day}^^A
%       ~\two@digits{\the\count@}:\two@digits{\the\count2}}
%   \endgroup
%
%   \newcommand*\ps@myfootings{^^A cf. \ps@plain
%     \let\@mkboth\@gobbletwo
%     \let\@oddhead\@empty
%     \let\@evenhead\@empty
%     \def\@oddfoot{\reset@font
%       \rlap{\textsf{\filename}~\fileversion~\filedate}^^A
%       \hfil\thepage\hfil
%       \llap{\TeX ed \texttt{\isodattim}}}^^A
%     \def\@evenfoot{\reset@font
%       \rlap{\TeX ed \texttt{\isodattim}}^^A
%       \hfil\thepage\hfil
%       \llap{\filedate~\fileversion~\textsf{\filename}}}^^A
%   }
%   \pagestyle{myfootings}
%   \let\pagestyle\@gobble
%   \let\thispagestyle\@gobble
%
%   \makeatother
% \else
%   \makeatletter
% ^^A   \ifdim\overfullrule>\z@\else\let\ps@myfootings\ps@plain\fi
%   \makeatother
% \fi
%
%
% \maketitle
%
%
% \section{Driver files}
%
% This file implements some of the currently supported drivers for
% the new version of the \textsf{pict2e} package.
% If the driver you use is not in this list then a `\texttt{.def}'
% file may be distributed with the pict2e package,
% or may be distributed with the standard \LaTeX\ graphics bundle,
% or may be distributed with your driver.
%
% If not, send us some details of the driver's |\special| syntax, and
% we will try to produce a suitable file.
%
% Note that some of these files are for graphics drivers to which we
% have no access, so they are untested.
% Please send any corrections to the latexbugs address or directly to
% the authors.
%
% \StopEventually{}
%
% \subsection{Template}
%
% A template for a \textsf{pict2e} driver file.
%
% \begin{macro}{\pIIe@mode}
% This macro serves as an indicator to the \textsf{pict2e} package
% which mode the driver supports:
%
% \smallskip
% \begin{tabular}{rl}
% $-1$ & inapt\slash incapable (default,
%        already set in \textsf{pict2e}) \\
% $0$  & standard \LaTeX\ only           \\
% $1$  & \PS                             \\
% $2$  & \PDF                            \\
%      & (other values are reserved for future use)
% \end{tabular}
% \smallskip
%
% \noindent
% Incapable drivers should not alter the default value given by the
% \textsf{pict2e} package, or set it explicitly to $-1$.
% ^^A (Or set it to $0$ to request standard \LaTeX\ mode.)
%    \begin{macrocode}
%<*template>
\def\pIIe@mode{-1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pIIe@code}
% The \textsf{pict2e} package expects the driver file to define the
% \cmd{\pIIe@code} command in a suitable way.
%
% This command should locally establish the standard \PS\slash\PDF\
% coordinate system
% (i.e., a cartesian coordinate system
% with positive x-axis pointing right
% and positive y-axis pointing up,
% and with unit $1\,\mathrm{bp} = 1/72\,\mathrm{in}$),
% albeit with the origin at \TeX's current point instead of the lower
% left corner of the page.
%
% Furthermore, it should save and restore the graphics state
% (|gsave|\slash|grestore| in \PS, |q|\slash|Q| in \PDF.)
% This may be achieved by using appropriate \cmd{\special} (or
% \cmd{\pdfliteral}, respectively) commands.
%
% Moreover, this command should preserve (i.e., it should not change)
% the current colour as defined by the user via the commands of the
% \textsf{color} package from the graphics bundle.
%
% Thus, the \cmd{\Gin@PS@restored} command that various
% \meta{driver}|.def| files from the graphics bundle provide should
% usually come close to what is expected here.
%    \begin{macrocode}
\def\pIIe@code#1{}
%</template>
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{dvips}
%
% A \textsf{pict2e} driver file for the \textsf{dvips} driver.
%
% \begin{macro}{\pIIe@mode}
% We are about to generate \PS\ code.
%    \begin{macrocode}
%<*dvips>
\def\pIIe@mode{1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pIIe@code}
% In this case the code inserted by the driver on behalf of the
% \cmd{\Gin@PS@restored} command performs a ``|0| |setgray|''
% operation, thus resetting any colour the user might have set by
% means of the \textsf{color} package.
% \ (See also \LaTeX\ problem report graphics/3569.) \ ^^A
% We therefore have to resort to the following kludge:
% As long as we output only simple picture objects, our operations are
% ``atomic.''
% Hence, we won't need to set colours or gray shades within the \PS\
% code generated by \textsf{pict2e};
% thus the offending |setgray| operator may as well be a no-op.
% To keep this redefinition local, we enclose the call to
% \cmd{\Gin@PS@restored} by a |save|\slash|restore| pair.
% \changes{v0.1}{2003/08/27}{Fix for dvips' \cmd{\Gin@PS@restored}
%    (prevent resetting current color to black). (HjG,RN)}
%    \begin{macrocode}
\def\pIIe@code#1{%
  \Gin@PS@raw{save /setgray { pop } def}%
  \Gin@PS@restored{#1}%
  \Gin@PS@raw{restore}%
}
%</dvips>
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{pdftex}
%
% A \textsf{pict2e} driver file for the \textsf{pdftex} driver.
%
% \begin{macro}{\pIIe@mode}
% We are about to generate \PDF\ code.
% (Only, if pdf\TeX\ is actually generating \PDF;
% otherwise nothing will be output.)
%    \begin{macrocode}
%<*pdftex>
\begingroup
  \@ifundefined{pdfoutput}{}{%
    \ifnum\pdfoutput>0\relax
      \gdef\pIIe@mode{2}
    \fi
  }
\endgroup
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pIIe@code}
% The save\slash restore operators are necessary here to prevent the
% change of the CTM (scaling and rotation operations) that
% \textsf{pict2e} inserts from propagating.
%    \begin{macrocode}
\ifcase\pIIe@mode\relax \or\or
  \def\pIIe@code#1{\pdfliteral{ q #1 Q }}
\fi
%</pdftex>
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{vtex}
%
% A \textsf{pict2e} driver file for the \textsf{vtex} driver.
%
% \begin{macro}{\pIIe@mode}
% With \textsf{V\TeX}, we should use \PS\ code also for \PDF\ mode
% (Email from Michael Vulis, MicroPress).
%    \begin{macrocode}
%<*vtex>
\begingroup
  \@ifundefined{VTeXversion}{}{%
    \ifnum\OpMode>0\relax
      \ifnum\OpMode<3\relax
        \gdef\pIIe@mode{1}%
      \fi
    \fi
  }
\endgroup
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pIIe@code}
% Here |\Gin@PS@restored| suffices as provided by the graphics driver
% file |vtex.def|.
%    \begin{macrocode}
\ifcase\pIIe@mode\relax \or
  \let\pIIe@code\Gin@PS@restored
\fi
%</vtex>
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{dvipdfm}
%
% A \textsf{pict2e} driver file for the \textsf{dvipdfm} driver.
%
% \begin{macro}{\pIIe@mode}
% We are about to generate \PDF\ code.
%    \begin{macrocode}
%<*dvipdfm>
\def\pIIe@mode{2}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pIIe@code}
% This seems to be sufficient.
%    \begin{macrocode}
\def\pIIe@code#1{\special{pdf: content #1}}
%</dvipdfm>
%    \end{macrocode}
% \end{macro}
%
%
%\iffalse
% \subsection{xdvi}
%
% A \textsf{pict2e} driver file for the \textsf{xdvi} driver.
%
% \begin{macro}{\pIIe@mode}
% We are about to generate \PS\ code.
%    \begin{macrocode}
%<*xdvi>
\def\pIIe@mode{1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pIIe@code}
% As long as our operations are ``atomic,'' we won't need to set
% colours or gray shades within our code, hence the offending
% \verb+setgray+ operator may as well be a no-op.
% See also \LaTeX\ problem report graphics/3569.
% \changes{v0.1}{2003/08/27}{Fix for dvips' \cmd{\Gin@PS@restored}
% (prevent resetting current color to black). (HjG,RN)}
%    \begin{macrocode}
\def\pIIe@code#1{%
 % \Gin@PS@raw{save /setgray { pop } def}%
  \Gin@PS@restored{#1}%
 % \Gin@PS@raw{restore}%
}
%</xdvi>
%    \end{macrocode}
% \end{macro}
%\fi
%
%
% \subsection{dvipdf}
%
% A \textsf{pict2e} driver file for the \textsf{dvipdf} driver
% (not yet implemented).
%
% \begin{macro}{\pIIe@mode}
%    \begin{macrocode}
%<*dvipdf>
 %\def\pIIe@mode{-1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pIIe@code}
% This is the same as the definition for |\Gin@PS@restored|
% in |dvipdf.def| as defined in |drivers.dtx|!
% Better use the higher-level macro instead of the |\special|?
%    \begin{macrocode}
 %\def\pIIe@code#1{\special{" #1}} % \Gin@PS@restored{#1}
%</dvipdf>
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{textures}
%
% A \textsf{pict2e} driver file for the \textsf{textures} driver
% (not yet implemented).
%
% \begin{macro}{\pIIe@mode}
%    \begin{macrocode}
%<*textures>
 % \def\pIIe@mode{-1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pIIe@code}
%    \begin{macrocode}
 % \def\pIIe@code#1{}
%</textures>
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{dvipsone}
%
% A \textsf{pict2e} driver file for the \textsf{dvipsone} driver
% (not yet implemented).
%
% \begin{macro}{\pIIe@mode}
%    \begin{macrocode}
%<*dvipsone>
 % \def\pIIe@mode{-1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pIIe@code}
%    \begin{macrocode}
 % \def\pIIe@code#1{}
%</dvipsone>
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{pctexps}
%
% A \textsf{pict2e} driver file for the \textsf{pctexps} driver
% (not yet implemented).
%
% \begin{macro}{\pIIe@mode}
%    \begin{macrocode}
%<*pctexps>
 % \def\pIIe@mode{-1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pIIe@code}
%    \begin{macrocode}
 % \def\pIIe@code#1{}
%</pctexps>
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{pctex32}
%
% A \textsf{pict2e} driver file for the \textsf{pctex32} driver
% (not yet implemented).
%
% \begin{macro}{\pIIe@mode}
%    \begin{macrocode}
%<*pctex32>
 % \def\pIIe@mode{-1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\pIIe@code}
%    \begin{macrocode}
 % \def\pIIe@code#1{}
%</pctex32>
%    \end{macrocode}
% \end{macro}
%
%
% \section{A Sample Configuration File}
%
% ^^A Preamble?
%
% This one is taken from |color.cfg| of the
% \teTeX\slash\TeXlive\ distributions.
%    \begin{macrocode}
%<*cfg>
%% Select an appropriate default driver.
\begingroup
  \chardef\x=0 %
  % check pdfTeX
  \@ifundefined{pdfoutput}{}{%
    \ifcase\pdfoutput
    \else
      \chardef\x=1 %
    \fi
  }%
  % check VTeX
  \@ifundefined{OpMode}{}{%
    \chardef\x=2 %
  }%
\expandafter\endgroup
\ifcase\x
  % default case
  \ExecuteOptions{dvips}%
\or
  % pdfTeX is running in pdf mode
  \ExecuteOptions{pdftex}%
\else
  % VTeX is running
  \ExecuteOptions{vtex}%
\fi
%    \end{macrocode}
% You can also specify other options to the \textsf{pict2e} package in
% the configuration file.
% For example, if you prefer PSTricks-like arrows, just uncomment the
% line below.
%    \begin{macrocode}
%% \ExecuteOptions{pstarrows}
%</cfg>
%    \end{macrocode}
%
% \Finale
\endinput
