% \iffalse
%<*copyright>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% eForms package,            2004-3-15                 %%
%% Copyright (C) 2002-2004  D. P. Story                 %%
%%   dpstory@uakron.edu                                 %%
%%                                                      %%
%% This program can redistributed and/or modified under %%
%% the terms of the LaTeX Project Public License        %%
%% Distributed from CTAN archives in directory          %%
%% macros/latex/base/lppl.txt; either version 1 of the  %%
%% License, or (at your option) any later version.      %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%</copyright>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{eforms}
%<package> [2006/10/03 v1.0a Provides general eForms support (dps)]
%<*driver>
\documentclass{ltxdoc}
\usepackage[dviwindo,colorlinks,hyperindex]{hyperref}
\pdfstringdefDisableCommands{\let\\\textbackslash}
\OnlyDescription
\EnableCrossrefs
\CodelineIndex
\begin{document}
  \GetFileInfo{eforms.sty}
  \title{eForm: PDF Form support for \LaTeX}
  \author{D. P. Story\\
    Email: \texttt{dpstory@uakron.edu}}
  \date{processed \today}
  \maketitle
  \tableofcontents
  \let\Email\texttt
  \DocInput{eforms.dtx}
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \MakeShortVerb{|}
%
% \DoNotIndex{\def,\edef,\gdef,\xdef,\global,\long,\let}
% \DoNotIndex{\expandafter,\string,\the,\ifx,\else,\fi}
% \DoNotIndex{\csname,\endcsname,\relax,\begingroup,\endgroup}
% \DoNotIndex{\DeclareTextCommand,\DeclareTextCompositeCommand}
% \DoNotIndex{\space,\@empty,\special}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%    \section{Introduction}
% This {\LaTeX} code was a part of the \textsf{exerquiz} package. I decided it would be useful
% to others if I separated the two and make the forms part of \textsf{exerquiz} into a separate
% package.  The \textsf{eForms} Package is now a part of the {Acro\TeX} eDucation Bundle and is
% called by \textsf{exerquiz}, but it is  now a stand alone package for others who may want to
% use PDF form fields and JavaScript interactivity.
%
%    \section{Package Options}
% The package options consist mostly of driver options.
%    \subsection{Driver Options}
%     The \textsf{web} package passes these driver options to \textsf{exerquiz}.
%    These options are needed is \textsf{exerquiz} is used without
%    \textsf{web}; in this case, the options below must explicitly included.
%    Set the driver dependent code for the |quiz| environments.
%    \begin{macro}{dvipsone}
% Set the driver for \texttt{dvipsone}
%    \begin{macrocode}
\DeclareOption{dvipsone}{\def\eq@drivernum{0}%
    \PassOptionsToPackage{dvipsone}{insdljs}
    \PassOptionsToPackage{dvipsone}{hyperref}
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{dvips}
% Set the driver for \texttt{dvips}
%    \begin{macrocode}
\DeclareOption{dvips}{\def\eq@drivernum{0}%
    \PassOptionsToPackage{dvips}{insdljs}
    \PassOptionsToPackage{dvips}{hyperref}
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{pdftex}
% Set the driver for \texttt{pdftex}
%    \begin{macrocode}
\DeclareOption{pdftex}{\def\eq@drivernum{1}%
   \def\eq@driver{pdftex}\def\eq@drivercode{epdftex.def}
   \PassOptionsToPackage{pdftex}{insdljs}
   \PassOptionsToPackage{pdftex}{hyperref}
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{dvipdfm}
% Set the driver for \texttt{dvipdfm}
%    \begin{macrocode}
\DeclareOption{dvipdfm}{\def\eq@drivernum{2}%
     \def\eq@driver{dvipdfm}\def\eq@drivercode{edvipdfm.def}
     \PassOptionsToPackage{dvipdfm}{insdljs}
     \PassOptionsToPackage{dvipdfm}{hyperref}
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{textures}
% This option, and testing are due to Ross Moore  3/6/02
%    \begin{macrocode}
\DeclareOption{textures}{\def\eq@drivernum{3}%
  \def\eq@driver{textures}\def\eq@drivercode{epdfmark.def}%
  \PassOptionsToPackage{textures}{insdljs}%
  \PassOptionsToPackage{textures}{hyperref}
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{dviwindo}
%    Set \cmd{\eq@noformstrue}, this inserts an \cmd{\endinput} just after
%    the end of the |exercise| environment.  No quizzes for
%    \texttt{dviwindo}.
%    \begin{macrocode}
%\DeclareOption{dviwindo}{\def\eq@drivernum{4}\def\eq@driver{dviwindo}%
%    \PassOptionsToPackage{nodljs}{insdljs}
%    \PassOptionsToPackage{dviwindo}{hyperref}}
%    \end{macrocode}
%    \end{macro}
% If no driver is passed, assume it is
% dvipsone or dvips---\textsf{hyperref} defines the specials.
% Default driver dvipsone/dvips
%    \begin{macrocode}
% \def\eq@drivernum{0}
\def\eq@driver{dvipsone/dvips}
\def\eq@drivercode{epdfmark.def}
%    \end{macrocode}
% \subsection{Other Options}
%    \begin{macro}{preview}
% The preview option displays the bounding box of each form field with a frame box.
% Useful for laying out field with a dvi previewer.
%    \begin{macrocode}
\DeclareOption{preview}{\previewtrue}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{insdljs}}
\newif\ifpreview \previewfalse
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
\ProcessOptions
\RequirePackage{hyperref}
\RequirePackage{insdljs}
%    \end{macrocode}
% \changes{v1.0a}{2006/10/03}
% {
%   If exerquiz is not loaded, we do an automatic begin and end of Form.
%   Also, if exerquiz is loaded, then we use the driver declared in exerquiz;
%   otherwise, we set the default to 0 (dvipsone/dvips).
% }
% If exerquiz is not loaded, we insert \verb!\begin{Form}! and \verb!\end{Form}!,
% and if undefined, we set the default driver.
%    \begin{macrocode}
\@ifpackageloaded{exerquiz}{}{%
    \AtBeginDocument{\begin{Form}}
    \AtEndDocument{\end{Form}}
}
\@ifundefined{eq@drivernum}{%
    \PackageError{eForms}%
        {You  have not specified dvips, dvipsone, pdftex or dvipdfm
        \MessageBreak in the option list of the eforms package}
        {Place one of the driver names dvips, dvipsone, pdftex or dvipdfm
        \MessageBreak in the option list of the eforms package.}
}{}
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% When the \texttt{preview} option is used, draw a frame box
% around the \textit{inner} bounding rectangle.
%    \begin{macrocode}
%<*package>
%\newsavebox{\eq@tmpbox}
\@ifundefined{eq@tmpbox}{\newsavebox{\eq@tmpbox}}{}
\@ifundefined{eq@tmpdima}{\newdimen\eq@tmpdima}{}
%\newdimen\eq@tmpdima
\def\Bbox#1#2{%
    \hbox{\ifpreview\setlength\fboxrule{0.4pt}\setlength\fboxsep{0pt}%
    \@tempdima=#1\advance\@tempdima by-\fboxrule
    \@tempdimb=#2\advance\@tempdimb by-\fboxrule
    \fbox{\parbox[b][\@tempdimb][c]{\@tempdima}{\hfill\vfill}}\else
    \parbox[b][#2][c]{#1}{\hfill\vfill}\fi}%
}
%</package>
%    \end{macrocode}
%    \section{eForms Support}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% Listed below are the various types of form objects available in PDF.
%\begin{flushleft}
%\hyperref[button]{Button} : \hyperref[pushbutton]{Push buttons},
%                             \hyperref[checkbox]{Check boxes},
%                             \hyperref[radiobutton]{Radio Buttons}\\
%\hyperref[textfield]{Text Fields}\\
%\hyperref[choice]{Choice Fields}: \hyperref[listbox]{list box},
%                                  \hyperref[combobox]{combo box}\\
%Signature fields (not supported by Acro\TeX)\\
%\end{flushleft}
%
% The following macro, \cs{processAppArgs},  is  due in part to
% Dan Luecking. He proposed a very nice modification of my original
% macros.
%
% The macro \cmd{\processAppArgs} takes an \textit{even} number of arguments; it
% picks off two at a time, processes them, then picks off two more. The macro is meant to
% process the optional arguments of a form field.
%
% All legal arguments (see \nameref{eformvariables} for a detailed
% listing of the legal arguments) are of the form \verb+\name{arg}+.
% The macro takes two tokens at a time and constructs a macro
% \verb+\@eqname{arg}+. Each of the macros \verb+\eqname+ must be
% defined. Such a macro defines another macro as follows
% \verb+\def\eq@name{arg}+. For example if the user enters the token
% pair  \verb+\RC{Users}+, \cmd{\processAppArgs} will construct
% \verb+\@eqRC+, with argument \verb+{arg}+, this macro will be
% executed, which expands to \verb+\def\eq@RC{arg}+.  The macro
% \cmd{\eq@RC} may then be used within the construction of the
% widget object.
%
% The macro \cs{processAppArgs} also does the addition operation for
% \texttt{/F} and \texttt{/Ff} keys.
%    \begin{macrocode}
\def\processAppArgs#1#2{%
    \ifx\end#1% if #1=\end, #2=\@nil.
        \let\@next=\relax
    \else
%    \end{macrocode}
% If a token has a value of \cs{@empty} then it has been protected. It is skipped
% and there is no user redefinition of that form field attribute allowed. Normally,
% this is done for \cs{A} and \cs{AA} to prevent overwriting critical functionality.
%    \begin{macrocode}
        \ifx#1\@empty
            \def\@next{\processAppArgs}%
        \else
            \@getCmdName{\Ff}\edef\arg@Ff{\@CmdName}%
            \@getCmdName{#1}%
            \ifx\arg@Ff\@CmdName  % if \Ff, let's  add arguments
                \ifx\eq@Ff\@empty\def\eq@FfValue{0}\else
                    \expandafter\getFfValue\eq@Ff\@nil\fi
                \@tempcnta = \eq@FfValue
                \def\eq@arg{#2}%
                \ifx\eq@arg\@empty\else
                \advance\@tempcnta by#2\fi
                \edef\eq@Ff{/Ff \the\@tempcnta}%
                \def\@next{\processAppArgs}%
            \else
                \@getCmdName{\F}\edef\arg@F{\@CmdName}%
                \@getCmdName{#1}%
                \ifx\arg@F\@CmdName  % if \Ff, let's  add arguments
                \ifx\eq@F\@empty\def\eq@FValue{0}\else
                    \expandafter\getFValue\eq@F\@nil\fi
                \@tempcnta = \eq@FValue
                \def\eq@arg{#2}%
                \ifx\eq@arg\@empty\else
                \advance\@tempcnta by#2\fi
                \edef\eq@F{/F \the\@tempcnta}%
                \def\@next{\processAppArgs}%
                \else
                    \csname @eq%
                        \expandafter\@gobble\string#1\endcsname{#2}%
                    \def\@next{\processAppArgs}%
                \fi
            \fi
        \fi
    \fi
    \@next
}
%    \end{macrocode}
% Process the field defaults and the `every' changes. Build up the required command
% in a token list, then execute.
%    \begin{macrocode}
\def\@processEvery{\edef\eqtemp{}\toks0={}\@@processEvery}
\def\@@processEvery#1{%
    \ifx#1\end\def\@next{\the\toks0 }%
    \else
        \edef\eqtemp{\the\toks0 }%
        \toks0=\expandafter{\eqtemp
            \expandafter\processAppArgs#1\end\@nil}%
        \def\@next{\@@processEvery}%
    \fi
    \@next
}
%    \end{macrocode}
%    \begin{macrocode}
\newdimen\eqcenterWidget
%    \end{macrocode}
% This macro is used to vertically center text fields and buttons on a
% line. Seems to work well.
%    \begin{macrocode}
\def\centerWidget#1{%
    \eqcenterWidget=#1\relax
    \eqcenterWidget=.5\eqcenterWidget
    \advance\eqcenterWidget by -4bp
}
%    \end{macrocode}
% \subsection{eForm Variables}\label{eformvariables}
%
% \subsubsection{Key-Value Definitions}
%
% The following definitions are used in various field templates.
% Some convenience macros to help define the button attributes. The default
% values are defined within the button macros themselves. Use these macros
% within the optional argument of buttons and text fields to modify their
% appearance.
%
% You'll notice, for example, the macros listed are not actually defined. For example
% \cmd{\CA} is never actually defined; we define instead \cmd{\@eqCA} and \cmd{\eq@CA}.
% The macros \cmd{\processAppArgs} treats \cmd{\CA} as a token, and prefixes with
% \texttt{@eq} in a clever sort of way. It's done so that these macros cannot be used
% outside the optional macro arguments of the button and text field macros.
%
% \medskip\noindent\textbf{Entries common to all annotation dictionaries:}
% \texttt{F, BS, Border, AP, AS, T, A, AA}.
%
% \medskip\noindent\textsl{Annotation Flag Bit Field:} See \nameref{F} for values.
%    \begin{macrocode}
\def\@eqF#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@F=\@empty\else\def\eq@F{/F #1}\fi}\def\eq@F{}
% BS = Border Style: W, S, D     (dictionary, optional)
% \def\@eqBS#1{\def\eq@BS{#1}}  % deprecated
    \def\@eqW#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
        \let\eq@W=\@empty\else\def\eq@W{/W #1}\fi}
    \def\eq@W{}
    \def\@eqS#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
        \let\eq@S=\@empty\else\def\eq@S{/S/#1}\fi}
    \def\eq@S{}
% Link keys
\def\@eqBorder#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@Border=\@empty\else\def\eq@Border{/Border [#1]}\fi}%
\def\eq@Border{/Border [0 0 0]}
\def\@eqAP#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@AP=\@empty\else\def\eq@AP{/AP<<#1>>}\fi}%
    \def\eq@AP{}
    % In the AP dictionary for checkboxes is the `On' value.
    % It is introduced into AP by passing a TeX parameter
    % normally, this variable is not used.
    \def\@eqOn#1{\def\eq@On{/#1}}\def\eq@On{/Yes}
\def\@eqAS#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@AS=\@empty\else\def\eq@AS{/AS/#1}\fi}%
    \def\eq@AS{}
\def\@eqA#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@A=\@empty\else\def\eq@A{/A <<#1>>}\fi}\def\eq@A{}
\def\@eqAA#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@AA=\@empty\else\def\eq@AA{/AA <<#1>>}\fi}\def\eq@AA{}
%dps Need to define the keys for the AA dictionary: U, D, E, X, Fo, Bl, F, K, V, C
% Note: F is already defined as another key.
%    \end{macrocode}
% \textbf{Additional entries common to fields containing variable text:} \texttt{DR, DA, Q,
% DS, RV}.
%    \begin{macrocode}
% DA = Default appearance:            (required)
\def\@eqDA#1{\def\eq@DA{#1}}
\def\eq@DA{\eq@textFont\space\eq@textSize\space Tf \eq@textColor}%
% PDF form font
\def\@eqtextFont#1{\def\eq@textFont{/#1}}
\def\eq@textFont{/Helv}
% PDF form text size
\def\@eqtextSize#1{\def\eq@textSize{#1}}
\def\eq@textSize{9}
% Rich text value
\def\@eqRV#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@RV=\@empty\else\def\eq@RV{/RV(#1)\fi}}\def\eq@RV{}
% Rich text default style
\def\@eqDS#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@DS=\@empty\else\def\eq@DS{/DS(#1)\fi}}\def\eq@DS{}
% text color
\def\@eqtextColor#1{\def\eq@textColor{#1}}
\def\eq@textColor{0 g}
% quadding for text fields: Q=0 left-justified, Q=1 centered
%   Q=2 right-justified
% rich strings: DS and RV -- not supported at this time
\def\@eqQ#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@Q=\@empty\else\def\eq@Q{/Q #1}\fi}\def\eq@Q{}
%    \end{macrocode}
% \textbf{Entries common to all fields:} \texttt{TU, Ff, V, DV, A, AA}
%    \begin{macrocode}
% DV = default value (optional) value field reverts to when field is reset
\def\@eqDV#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@DV=\@empty\else\def\eq@DV{/DV(#1)}\fi}
    \def\eq@DV{}
% Unicoded DV
\def\@equDV#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@DV=\@empty\else\def\eq@DV{/DV<#1>}\fi}
% V = field value (optional)
\def\@eqV#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@V=\@empty\else\def\eq@V{/V(#1)}\fi}%
    \def\eq@V{}
% Unicoded V
\def\@equV#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@V=\@empty\else\def\eq@V{/V<#1>}\fi}%
% tool tip (optional, PDF 1.3)
\def\@eqTU#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@TU\@empty\else\def\eq@TU{/TU(#1)}\fi}
    \def\eq@TU{}
% tool tip, unicode version
\def\@equTU#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@TU\@empty\else\def\eq@TU{/TU<#1>}\fi}
% The Field flags bit field, these values are listed below.
\def\@eqFf#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@Ff=\@empty\else\def\eq@Ff{/Ff #1}\fi}
    \def\eq@Ff{}
%    \end{macrocode}
% \textbf{keys specific to text fields:} \texttt{MaxLen}
%    \begin{macrocode}
% text fields only. Restricts number of characters
% input. Require if a comb field.
\def\@eqMaxLen#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@MaxLen=\@empty\else\def\eq@MaxLen{/MaxLen #1}\fi}%
    \def\eq@MaxLen{}
% Highlight, used in text fields and link annotation. Possible values
% are None, Push, Outline, Invert (respectively, \H{N}, \H{P}, \H{O}, \H{I})
% The default highlighting is invert (I).
\def\@eqH#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@H=\@empty\else\def\eq@H{/H/#1}\fi}\def\eq@H{}
%    \end{macrocode}
% \textbf{Appearance characteristics dictionary:}
% MK =  R, BC, BG, CA, RC, AC, I,
%         RI, IX, IF, TP
%    \begin{macrocode}
\def\@eqMK#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@MK=\@empty\else\def\eq@MK{/MK << #1 >> }\fi}%
    \def\eq@MK{}
% MK dictionary
    \def\@eqR#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
        \let\eq@R=\@empty\else\def\eq@R{/R #1}\fi}
    \def\eq@R{}
    %   Boundary color
    \def\@eqBC#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
        \let\eq@BC=\@empty\else\def\eq@BC{/BC [#1]}\fi}
    \def\eq@BC{}
    %   Background color
    \def\@eqBG#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
        \let\eq@BG=\@empty\else\def\eq@BG{/BG [#1]}\fi}
    \def\eq@BG{}
    %   normal appearance text
    \def\@eqCA#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
        \let\eq@CA\@empty\let\ef@kvCA\@empty
        \else\def\eq@CA{#1}\def\ef@kvCA{/CA(#1)}\fi}
    \def\eq@CA{}\def\ef@kvCA{}
    % normal appearance text, unicode version
    \def\@equCA#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
        \let\eq@CA\@empty\let\ef@kvCA\@empty
        \else\def\eq@CA{#1}\def\ef@kvCA{/CA<#1>}\fi}
    %   Roll over text
    \def\@eqRC#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
        \let\eq@RC\@empty\let\ef@kvRC\@empty
        \else\def\eq@RC{#1}\def\ef@kvRC{/RC(#1)}\fi}
    \def\eq@RC{}\def\ef@kvRC{}
    %   Roll over text, unicode version
    \def\@equRC#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
        \let\eq@RC\@empty\let\ef@kvRC\@empty
        \else\def\eq@RC{#1}\def\ef@kvRC{/RC<#1>}\fi}
    %   Push text
    \def\@eqAC#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
        \let\eq@AC\@empty\let\ef@kvAC\@empty
        \else\def\eq@AC{#1}\def\ef@kvAC{/AC(#1)}\fi}
    \def\eq@AC{}\def\ef@kvAC{}
    %   Push text, unicode version
    \def\@equAC#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
        \let\eq@AC\@empty\let\ef@kvAC\@empty
        \else\def\eq@AC{#1}\def\ef@kvAC{/AC<#1>}\fi}
% Other keys of MK include: I, RI, IX, IF and TP
% If I haven't covered everything, use this macro to insert
% material into MK
\def\@eqmkIns#1{\def\eq@mkIns{#1}}\def\eq@mkIns{}
%    \end{macrocode}
% \textbf{Additional entries specific to choice fields:} \texttt{Opt, TI, I}
%    \begin{macrocode}
% an array of options in the list
\def\@eqOpt#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@Opt=\@empty\else\def\eq@Opt{/Opt [#1]}\fi}
    \def\eq@Opt{}
% for scrollable list boxes, the top index.
\def\@eqTI#1{\def\eq@arg{#1}\ifx\eq@arg\@empty
    \let\eq@TI=\@empty\else\def\eq@TI{/TI #1}\fi}
    \def\eq@TI{}
%    \end{macrocode}
% When all else fails, use the \cs{rawPDF} command to modify the widget.
%    \begin{macrocode}
\def\@eqrawPDF#1{\def\eq@rawPDF{#1}}\def\eq@rawPDF{}
%    \end{macrocode}
% \textbf{Specialized, non-PDF Spec, commands}
%    \begin{macrocode}
% Height of a widget
\def\@eqrectH#1{\def\eq@rectH{#1}}
% Width of a widget
\def\@eqrectW#1{\def\eq@rectW{#1}}
% autocenter
\def\@eqautoCenter#1{\let\autoCenter=#1}
\let\autoCenter=y
\def\@eqsymbolchoice#1{\expandafter\ifx\csname eq@#1\endcsname\relax
   \typeout{exerquiz: `#1' is not an acceptable option
   for \string\symbolechoice, inserting default, `check'.}
   \edef\symbol@choice{\eq@check}\else
   \edef\symbol@choice{\csname eq@#1\endcsname}\fi
}
\def\eq@protect#1{\let#1=\@empty}
%    \end{macrocode}
%    \begin{macro}{\DefaultHeightOfWidget}
%    \begin{macro}{\RBW}
%    \begin{macro}{\SFW}
% \cmd{\DefaultHeightOfWidget} is the default height of all form
% fields (except radio fields and checkboxes). \cmd{\RBW} is the
% default width of the \cmd{\RespBox}; and \cmd{\SFW} is the
% default width of the \cmd{\ScoreField}. Some widgets, such as
% buttons have width determined by the width of the text.
%    \begin{macrocode}
\def\tallywidth#1{\def\tally@width{#1}}
\def\tally@width{15bp}
% \def\DefaultHeightOfWidget{12bp}
\def\DefaultHeightOfWidget{11bp}
\def\RadioFieldSize{11bp}
\def\RBW{2in}
\def\SFW{1.5in}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%\subsection{Symbol Definitions}
% Some definitions for radio fields and checkboxes
%    \begin{macrocode}
\def\eq@check{4}
\def\eq@circle{l}
\def\eq@cross{8}
\def\eq@diamond{u}
\def\eq@square{n}
\def\eq@star{H}
%    \end{macrocode}
%    \begin{macro}{\symbolchoice}
% Use this macro to change the symbol used in radio and
% checkboxes.  The default is \cmd{\eq@check}.  This macro takes one
% argument: permissible values are: check, circle, cross, diamond,
% square, and star. The definition of \cs{symbolchoice} is given
% above in the definition of \cs{@eqsymbolchoice}.
%    \begin{macrocode}
\let\symbolchoice=\@eqsymbolchoice
%    \end{macrocode}
% Set the default to `check'.
%    \begin{macrocode}
\symbolchoice{check}
%    \end{macrocode}
%    \end{macro}
%\subsection{Convenience Commands for Writing Actions}
% Writing actions for eForms requires certain key-value combinations. The following
% commands provides the correct syntax, the code is inserted via the required
% argument of each.
%    \begin{macro}{\JS}
% A convenience command for writing JavaScript.
%    \begin{macrocode}
\providecommand\JS[1]{/S/JavaScript/JS(#1)}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\AAMouseUp}
%    \begin{macro}{\AAMouseDown}
%    \begin{macro}{\AAMouseEnter}
%    \begin{macro}{\AAMouseExit}
%    \begin{macro}{\AAOnFocus}
%    \begin{macro}{\AAOnBlur}
% Some convenient commands for writing actions. All the commands that begin with
% \texttt{AA} go into the ``additional actions'' of a field.
%    \begin{macrocode}
\newcommand\AAMouseUp[1]{/U<<#1>>}
\newcommand\AAMouseDown[1]{/D<<#1>>}
\newcommand\AAMouseEnter[1]{/E<<#1>>}
\newcommand\AAMouseExit[1]{/X<<#1>>}
\newcommand\AAOnFocus[1]{/Fo<<#1>>}
\newcommand\AAOnBlur[1]{/Bl<<#1>>}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \begin{macro}{\AAFormat}
%    \begin{macro}{\AAKeystroke}
%    \begin{macro}{\AAValidate}
%    \begin{macro}{\AACalculate}
% These four action events are Javascript only, so we use \cs{JS}
% to insert the appropriate code.
%    \begin{macrocode}
\newcommand\AAFormat[1]{/F<<\JS{#1}>>}
\newcommand\AAKeystroke[1]{/K<<\JS{#1}>>}
\newcommand\AAValidate[1]{/V<<\JS{#1}>>}
\newcommand\AACalculate[1]{/C<<\JS{#1}>>}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%\subsection{Default Colors for Checks, Crosses, and Borders}
%    \begin{macro}{\checkColor}
%    \begin{macro}{\crossColor}
%    \begin{macro}{\correctColor}
%    \begin{macro}{\wrongColor}
%    \begin{macro}{\eqDefaultColor}
% These five macros are used to define the colors for the checks,
% crosses and correct symbols.  These are controled by JavaScript,
% so use the correct syntax for defining colors here.
%    \begin{macrocode}
\newcommand\checkColor{["RGB", 0, .6, 0]}
\newcommand\crossColor{color.red}
\newcommand\correctColor{["RGB", 0, .6, 0]} % same as webgreen
\newcommand\wrongColor{color.red}
\newcommand\eqDefaultColor{color.black}
%    \end{macrocode}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
%    \end{macro}
% \subsubsection{Annotation Flag \texttt{/F} Definitions}\label{F}
%
%    \begin{macrocode}
\def\FHidden{2}                     % bit 2: hidden field
\def\FPrint{4}                      % bit 3: print
\def\FNoView{32}                    % bit 6: no view
\def\FLock{128}                     % bit 8: locked field (PDF 1.4)
%    \end{macrocode}
%\textbf{Notes:}\par
%\noindent\begin{tabular}{ll}
% Visible (and printable)       &|\F\FPrint|\\
%Hidden but printable          &|\F\FNoView\F\FPrint|\\
%Visible but doesn't print     &|\F{}|\\
%Hidden (and does not print)   &|\F\FHidden\F\FPrint|
%\end{tabular}
%
%\subsubsection{Field Flags /Ff Definitions}\label{Ff}
%    \begin{macrocode}
\def\FfReadOnly{1}                   % all
\def\FfRequired{2}                   % all
\def\FfNoExport{4}                   % all
\def\FfMultiline{4096}               % text
\def\FfPassword{8192}                % text
\def\FfNoToggleToOff{16384}          % radio
\def\FfRadio{32768}                  % radio
\def\FfPushButton{65536}             % Pushbuton
\def\FfCombo{131072}                 % choice
\def\FfEdit{262144}                  % combo
\def\FfSort{524288}                  % choice
\def\FfFileSelect{1048576}           % text (PDF 1.4)
\def\FfMultiSelect{2097152}          % choice (PDF 1.4)
\def\FfDoNotSpellCheck{4194304}      % text, combo (PDF 1.4)
\def\FfDoNotScroll{8388608}          % text (PDF 1.4)
\def\FfComb{16777216}                % text (PDF 1.5)
\def\FfRadiosInUnison{33554432}      % radio (PDF 1.5)
\def\FfCommitOnSelChange{67108864}   % choice (PDF 1.5)
\def\FfRichText{33554432}            % radio (PDF 1.5)
%    \end{macrocode}
% The keys \texttt{/F} and \texttt{/Ff} will be additive, that is,
% for example, \verb+\F\FHidden\F\FPrint+ will get \texttt{/F 6},
% a field that is both printable and hidden. These are the only
% flags that are additive this way. The following to macros
% are supportive of the additivity.
%    \begin{macrocode}
\def\getFfValue/Ff#1\@nil{\def\eq@FfValue{#1}}
\def\getFValue/F#1\@nil{\def\eq@FValue{#1}}
\def\@getCmdName#1{\edef\@CmdName{\expandafter\@gobble\string#1}}
%    \begin{macrocode}
\newcommand\everyTextField[1]{\def\every@TextField{#1}}
\def\every@TextField{}
%    \end{macrocode}
% Here, you can control the appearance of all the standard checkboxes, also
% effects radio fields of shortquiz and quiz.
%    \begin{macrocode}
\newcommand\everyCheckBox[1]{\def\every@CheckBox{#1}}
\def\every@CheckBox{}
%\newcommand\everysqCheckBox[1]{\def\every@sqCheckBox{#1}}
%\def\every@sqCheckBox{}
%\newcommand\everyqCheckBox[1]{\def\every@qCheckBox{#1}}
%\def\every@qCheckBox{}
%
\newcommand\everyRadioButton[1]{\def\every@RadioButton{#1}}
\def\every@RadioButton{}
%    \end{macrocode}
% Here, you can control the appearance of all the standard buttons.
%    \begin{macrocode}
\newcommand\everyButtonField[1]{\def\every@ButtonField{#1}}
\def\every@ButtonField{}
%\let\everyButtonField=\everyeqButtonField
\newcommand\everyPushButton[1]{\def\every@PushButton{#1}}
\def\every@PushButton{}
% Replace everyeqGenButten with everyPushButton
%\newcommand\everyeqIcon[1]{\def\every@eqIcon{#1}}
%\def\every@eqIcon{}
\newcommand\everyListBox[1]{\def\every@listBox{#1}}
\newcommand\everyComboBox[1]{\def\every@comboBox{#1}}
\def\every@listBox{}\def\every@comboBox{}
\newcommand\everyLink[1]{\def\every@Link{#1}}
\def\every@Link{}
\def\makeJSspecials
{%
    \def\\{\eqbs\eqbs}%         % define \\ to be \\
    \makespecialJS              % make \r=\jsR and \t=\jsT
}
%    \end{macrocode}
%    \begin{macro}{\eq@setButtonProps}
% This macro measure the width of the largest text on defined for the
% button, and then passes the this info on to a driver specific macro
% \#1, the first parameter.
%\begin{verbatim}
% #1 is the driver specific macro to build the button widget
% #2 are the button properties
%\end{verbatim}
% \subsection{Set Field Properties}
%    \begin{macrocode}
\def\eq@setButtonProps#1#2%
{%
    \makeJSspecials
    \processAppArgs#2\end\@nil  % set widget properties
    \Hy@pdfstringfalse
    \ifx\eq@rectW\@empty
        \sbox{\eq@tmpbox}{\ \eq@CA\ }\eq@tmpdima=\wd\eq@tmpbox
        \sbox{\eq@tmpbox}{\ \eq@RC\ }%
        \ifdim\eq@tmpdima>\wd\eq@tmpbox\else\eq@tmpdima=\wd\eq@tmpbox\fi%
        \sbox{\eq@tmpbox}{\ \eq@AC\ }%
        \ifdim\eq@tmpdima>\wd\eq@tmpbox\else\eq@tmpdima=\wd\eq@tmpbox\fi%
        \wd\eq@tmpbox = \eq@tmpdima
    \else
        \wd\eq@tmpbox=\eq@rectW
    \fi
    #1%
}
%    \end{macrocode}
%    \end{macro}
% Same as \cmd{\eq@setButtonProps} but does not measure the width of the
% field.  Simply lays in the optional parameters that modify the appearance
% then calls the driver specific macro to build the widget.
%\begin{verbatim}
% #1 is the driver specific macro to build the widget
% #2 are the widget properties
%\end{verbatim}
%    \begin{macrocode}
\def\eq@setWidgetProps#1#2%
{%
    \makeJSspecials
    \processAppArgs#2\end\@nil  % set widget properties
    #1%
}
%    \end{macrocode}
% \subsection{Choice Fields}\label{choice}
%
% This is the form template used for all choice fields, list box and combo box.
%    \begin{macrocode}
\def\common@choiceCode
{%
    /Subtype /Widget
    /T (\Fld@name)
    /FT /Ch
    \eq@Ff
    \eq@F
    \eq@TU
    \eq@TI
    /BS << \eq@W\eq@S >>
    /MK <<\eq@R\eq@BC\eq@BG\eq@mkIns>>
    /DA (\eq@DA)
    /Opt [\eq@Opt]
    \eq@DV\eq@V
    \eq@A\eq@AA
    \eq@rawPDF
}
%    \end{macrocode}
% \subsubsection{List Box}\label{listbox}
% The main list box code that can be used to build list box commands, such as
% \cs{listBox}, defined below.
%    \begin{macrocode}
\newcommand\list@@Box[8]
{%
    \begingroup
    \edef\Fld@name{#2}\def\eq@rectW{#3}\def\eq@rectH{#4}\def\eq@Opt{#5}%
    \def\eq@DA{\eq@textFont\space\eq@textSize\space Tf \eq@textColor}%
    \@processEvery#8\end\noindent#6#7{#1}%
}
%    \end{macrocode}
%    \begin{macro}{\listBox}
%\begin{verbatim}
% #1 = optional, used to enter any modification of the appearance/actions
% #2 = the title of the list box field
% #3 = the width of the bounding rectangle
% #4 = the height of the bounding rectangle
% #5 = the appearance/values of list.
%\end{verbatim}
%    \begin{macrocode}
\def\listBoxDefaults
{%
    \W{1}\S{I}\F{\FPrint}\BC{0 0 0}
}
\newcommand\listBox[5][]
{%
    \list@@Box{#1}{#2}{#3}{#4}{#5}{}{\eq@setWidgetProps
        \eq@choice@driver}{\listBoxDefaults\every@listBox}%
}
%    \end{macrocode}
%    \end{macro}
% \subsubsection{Combo Box}\label{combobox}
%    \begin{macrocode}
\newcommand\combo@@Box[8]
{%
   \begingroup
    \@eqFf{\FfCombo}\edef\Fld@name{#2}\def\eq@rectW{#3}%
    \def\eq@rectH{#4}\def\eq@Opt{#5}%
    \def\eq@DA{\eq@textFont\space\eq@textSize\space Tf \eq@textColor}%
    \@processEvery#8\end\noindent#6#7{#1}%
}
%    \end{macrocode}
%    \begin{macro}{\comboBox}
% A general combo box command.
%\begin{verbatim}
% #1 = optional, used to enter any modification of the appearance/actions
% #2 = the title of the radio field
% #3 = the width of the bounding rectangle
% #4 = the height of the bounding rectangle
% #5 = the appearance/values of list.
%\end{verbatim}
%    \begin{macrocode}
\def\comboBoxDefaults
{%
    \W{1}\S{I}\F{\FPrint}\BC{0 0 0}
}
\newcommand\comboBox[5][]
{%
    \combo@@Box{#1}{#2}{#3}{#4}{#5}{}{\eq@setWidgetProps
        \eq@choice@driver}{\comboBoxDefaults\every@comboBox}%
}
%    \end{macrocode}
%    \end{macro}
% \subsection{Button Fields}\label{button}
% Here is the field template for push button fields.
%    \begin{macrocode}
\def\common@pushButtonCode
{%
    /Subtype /Widget
    /T (\Fld@name)
    /FT /Btn
    \eq@Ff
    \eq@TU
    \eq@H
    \eq@F
    /BS <<\eq@W\eq@S >>
    /MK <<\eq@R\eq@BC\eq@BG%
            \ef@kvCA\ef@kvRC\ef@kvAC\eq@mkIns>>
%            /CA(\eq@CA)/RC(\eq@RC)/AC(\eq@AC)\eq@mkIns>>
    /DA (\eq@DA)
    \eq@A\eq@AA
    \eq@rawPDF
}
%    \end{macrocode}
% Here is the field template for check boxes and radio button fields fields.
%    \begin{macrocode}
\def\common@RadioCheckCode
{%
    /Subtype /Widget
    /T (\Fld@name)
    /FT /Btn
    \eq@Ff
    \eq@F
    \eq@TU
    /BS <<\eq@W\eq@S>>
    \eq@MK
    /DA (\eq@DA)
    \eq@AP
    \eq@AS
    \eq@DV\eq@V
    \eq@A\eq@AA
    \eq@rawPDF
}
%    \end{macrocode}
% \subsubsection{Push Button}\label{pushbutton}
% Here is the basic command for creating a button field. This is the building block
% for all other buttons.
%    \begin{macrocode}
\newcommand\push@@Button[7]
{%
    \begingroup
    \def\eq@Ff{/Ff \FfPushButton}%
    \def\eq@DA{\eq@textFont\space\eq@textSize\space Tf \eq@textColor}%
    \edef\Fld@name{#2}\def\eq@rectW{#3}\def\eq@rectH{#4}%
    \@processEvery#7\end\noindent#5#6{#1}%
}
%    \end{macrocode}
%    \begin{macro}{\pushButton}
%\begin{verbatim}
%#1 = optional, used to enter any modification of the appearance/actions
%#2 = the title of the button field
%#3 = the width of the bounding rectangle
%#4 = the height of the bounding rectangle
%\end{verbatim}
%    \begin{macrocode}
\def\pushButtonDefaults
{%
    \W{1}\S{B}\F{\FPrint}\BC{0 0 0}
    \H{P}\BG{.7529 .7529 .7529}
}
\newcommand\pushButton[4][]
{%
    \push@@Button{#1}{#2}{#3}{#4}{}{\eq@setButtonProps\eq@Button@driver}%
        {\pushButtonDefaults\every@PushButton}%
}
%    \end{macrocode}
%    \end{macro}
% \subsubsection{Check Box}\label{checkbox}
% The basic command for creating check boxes.
%    \begin{macrocode}
\newcommand\check@@Box[8]
{%
    \begingroup
    \def\@eqDV##1{\def\eq@arg{##1}\ifx\eq@arg\@empty\let\eq@DV=\@empty
        \else\def\eq@DV{/DV/##1}\fi}%
    \def\@eqV##1{\def\eq@arg{##1}\ifx\eq@arg\@empty
        \let\eq@V=\@empty\else\def\eq@V{/V/##1}\fi}%
    \edef\Fld@name{#2}\def\eq@rectW{#3}\def\eq@rectH{#4}\def\eq@On{/#5}%
    \@eqAP{/N <<\eq@On<<>>>> }\@eqtextFont{ZaDb}\@eqAS{Off}% \eq@On <<>>? \space/null
    \def\eq@DA{\eq@textFont\space\eq@textSize\space Tf \eq@textColor}%
    \@eqMK{\eq@R\eq@BC\eq@BG/CA(\symbol@choice)\eq@mkIns}%
    \@processEvery#8\end\noindent#6#7{#1}%
}
%    \end{macrocode}
%    \begin{macro}{\checkBox}
%\begin{verbatim}
%#1 = optional, used to enter any modification of the appearance/actions
%#2 = the title of the check box field
%#3 = the width of the bounding rectangle
%#4 = the height of the bounding rectangle
%#5 = the 'on value' or export value, the default is "Yes".
%\end{verbatim}
%    \begin{macrocode}
\def\checkBoxDefaults
{%
    \F{\FPrint}\W{1}\S{S}\BC{0 0 0}
}
\newcommand\checkBox[5][]
{%
    \check@@Box{#1}{#2}{#3}{#4}{#5}{}{\eq@setWidgetProps
        \eq@RadioCheck@driver}{\checkBoxDefaults\every@CheckBox}%
}
%    \end{macrocode}
%    \end{macro}
% \subsubsection{Radio Button}\label{radiobutton}
% The basic command for creating radio button fields.
%    \begin{macrocode}
% Basic command for building all radio buttons.
%    \end{macrocode}
%    \begin{macrocode}
\newcommand\radio@@Button[8]
{%
    \begingroup
    \def\@eqDV##1{\def\eq@arg{##1}\ifx\eq@arg\@empty\let\eq@DV=\@empty
        \else\def\eq@DV{/DV/##1}\fi}%
    \def\@eqV##1{\def\eq@arg{##1}\ifx\eq@arg\@empty\let\eq@V=\@empty
        \else\def\eq@V{/V/##1}\fi}%
    \def\eq@Ff{/Ff \FfRadio}\@eqtextFont{ZaDb}\@eqAS{Off}%
    \def\eq@DA{\eq@textFont\space\eq@textSize\space Tf \eq@textColor}%
    \@eqAP{/N <<\eq@On<<>>>>}%  \eq@On <<>>? /null
    \@eqMK{\eq@R\eq@BC\eq@BG/CA(\symbol@choice)\eq@mkIns}%
    \edef\Fld@name{#2}\def\eq@rectW{#3}\def\eq@rectH{#4}\def\eq@On{/#5}%
    \@processEvery#8\end\noindent#6#7{#1}%
}
%    \end{macrocode}
%    \begin{macro}{\radioButton}
%\begin{verbatim}
%#1 = optional, used to enter any modification of the appearance/actions
%#2 = the title of the radio button field
%#3 = the width of the bounding rectangle
%#4 = the height of the bounding rectangle
%#5 = the 'on value' or export value, the default is "Yes"
%\end{verbatim}
%    \begin{macrocode}
\def\radioButtonDefaults
{%
    \W{1}\S{S}\BC{0 0 0}\F{\FPrint}
}
\newcommand\radioButton[5][]
{%
    \radio@@Button{#1}{#2}{#3}{#4}{#5}{}{\eq@setWidgetProps
        \eq@RadioCheck@driver}{\radioButtonDefaults\every@RadioButton}%
}
%    \end{macrocode}
%    \end{macro}
%
% \subsection{Text Field}\label{textfield}
%
% The template for a text field.
%    \begin{macrocode}
\def\common@TextFieldCode
{%
    /Subtype /Widget
    /T (\Fld@name)
    /FT /Tx
    \eq@Ff
    \eq@F
    \eq@Q
    \eq@TU
    \eq@MaxLen
    /BS <<\eq@W\eq@S>>
    /MK <<\eq@R\eq@BC\eq@BG\eq@mkIns>>
    /DA (\eq@DA)
    \eq@DV\eq@V
    \eq@RV\eq@DS
    \eq@A\eq@AA
    \eq@rawPDF
}
%    \end{macrocode}
% The basic text field macro for constructing all other text fields.
%    \begin{macrocode}
\newcommand\text@@Field[7]
{%
    \begingroup
    \edef\Fld@name{#2}\def\eq@Title{#2}\def\eq@rectW{#3}\def\eq@rectH{#4}%
    \def\eq@DA{\eq@textFont\space\eq@textSize\space Tf \eq@textColor}%
    \@processEvery#7\end\noindent#5#6{#1}%
}
%    \end{macrocode}
%    \begin{macro}{\textField}
%\begin{verbatim}
%#1 = optional, used to enter any modification of the appearance/actions
%#2 = the title of the text field
%#3 = the width of the bounding rectangle
%#4 = the height of the bounding rectangle
%\end{verbatim}
%    \begin{macrocode}
\def\textFieldDefaults
{%
    \F{\FPrint}\BC{0 0 0}\W{1}\S{S}
}
\newcommand\textField[4][]
{%
    \text@@Field{#1}{#2}{#3}{#4}{}{\eq@setWidgetProps\eq@TextField}%
        {\textFieldDefaults\every@TextField}%
}
\let\eqTextField=\textField
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\calcTextField}
% This command creates a text field that is designed to be used a an
% automatic calculation field.  This works only for the those who use
% the distiller to make PDF and for users of dvipdfm.
%\begin{verbatim}
%#1 = optional, used to enter any modification of the appearance/actions
%#2 = the title of the text field
%#3 = the width of the bounding rectangle
%#4 = the height of the bounding rectangle
%\end{verbatim}
%    \begin{macrocode}
\def\textFieldDefaults
{%
    \F{\FPrint}\BC{0 0 0}\W{1}\S{S}
}
\newcommand\calcTextField[4][]
{%
    \text@@Field{#1}{#2}{#3}{#4}{}{\eq@setWidgetProps\eq@calcTextField}%
        {\textFieldDefaults\every@TextField}%
}
%    \end{macrocode}
%    \end{macro}
% \section{Additional Link Support}
%
% The links in \textsf{hyperref} are not sufficiently general to
% allow actions other than jumping. I've included a general link
% that increases the usage of the links provided by
% \textsf{hyperref}.
%    \begin{macrocode}
\def\common@LinkCode
{%
    \eq@A           % Action
    \eq@rawPDF      % everything else
}
%    \end{macrocode}
% The basic macro for create links.
%    \begin{macrocode}
\newcommand\set@@Link[7]
{%
    \begingroup
    \def\eq@rectW{#2}%
    \ifx\eq@rectW\@empty
        \def\link@@Box{#4}%
    \else
        \def\eq@rectH{#3}%
        \def\eq@arg{#4}\ifx\eq@arg\@empty
            \def\eq@content{\hfill\vfill}\else\def\eq@content{#4}\fi
        \def\link@@Box{\parbox[\eq@pos][\eq@rectH][\eq@innerpos]%
            {\eq@rectW}{\centering\eq@content}}%
    \fi
    \makeJSspecials
    \@processEvery#7\end\noindent#5#6{#1}%
}
%    \end{macrocode}
%    \begin{macro}{\setLinkText}
% Set a link around some text.
%\begin{verbatim}
%\setLinkText[\Border{}\A{/S/JavaScript/JS(this.pageNum=6;)}
%   \rawPDF{/C[1 0 0]}]{\textcolor{\@linkcolor}{Go There!}}
%\end{verbatim}
%    \begin{macrocode}
\def\set@LinkTextDefaults{\Border{0 0 0}}
\newcommand\setLinkText[2][]
{%
    \set@@Link{#1}{}{}{#2}{}{\eq@setWidgetProps\setLink@driver}%
        {\set@LinkTextDefaults\every@Link}%
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\setLinkBbox}
% Set a link around some text.
%\begin{verbatim}
%\setLinkBbox
%   [\Border{}\rawPDF{/Color{1 0 0}}]{50bp}{30bp}[b]{\centering Press Me!}
%\end{verbatim}
%    \begin{macrocode}
\def\set@LinkBboxDefaults{\Border{0 0 0}}
\newcommand\setLinkBbox[3][]
{%
    \@setLinkBbox{#1}{#2}{#3}%
}
\def\@setLinkBbox#1#2#3{\@ifnextchar[{\@@setLinkBbox{#1}{#2}{#3}}%
    {\@@setLinkBbox{#1}{#2}{#3}[c]}}
\def\@@setLinkBbox#1#2#3[#4]%
{%
    \@ifnextchar[{\@@@setLinkBbox{#1}{#2}{#3}{#4}}%
        {\@@@setLinkBbox{#1}{#2}{#3}{#4}[#4]}
}
\def\@@@setLinkBbox#1#2#3#4[#5]#6%
{%
    \def\eq@pos{#4}\def\eq@innerpos{#5}%
    \set@@Link{#1}{#2}{#3}{#6}{\eq@setWidgetProps\setLink@driver}%
        {}{\set@LinkBboxDefaults\every@Link}%
}
%    \end{macrocode}
%    \end{macro}

%    \section{Input Driver Specific Code}
% Now bring in driver dependent macros.  The macros defined are
% the answer macros for the \texttt{shortquiz} environment and most all
% for the \texttt{quiz} environment.  These macros make heavy use of
% JavaScript.  The method of introducing these JavaScripts and
% PDF code related elements depends on the driver.
%    \begin{macrocode}
\input{\eq@drivercode}
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%    \subsection{dvipsone and dvips}
%    \begin{macrocode}
%<*epdfmark>
%    \end{macrocode}
% This is the code for the \texttt{dvipsone} and \texttt{dvips}
% options.  These two are done together.  \textsf{hyperref}
% redefines the macro \cmd{\literalps@out} appropriate to each of
% these drivers.  Both use pdfmarks, so we can put them together.
% \par\medskip\noindent
% This sets the rectangle size allowing for a literal
% hyperlink---meaning we can insert arbitrary links actions.
%    \begin{macrocode}
\def\Rect#1{\pdf@rect{\textcolor{\@linkcolor}{#1}}}
%    \end{macrocode}
% Code to hide the solutions page to a quiz that has solutions.
%    \begin{macrocode}
\def\noPeek#1#2{\literalps@out{%
     [ {ThisPage} << \noPeekAction{#1}{#2} >> /PUT pdfmark}}
%    \end{macrocode}
% Driver dependent code (distiller) for choice fields, list and combo.
%    \begin{macrocode}
\def\eq@choice@driver
{%
    \centerWidget\eq@rectH\if\autoCenter n\eqcenterWidget=0pt\fi
    \pdf@rect{\lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}}%
    \literalps@out{%
    [ /Rect [pdf@llx pdf@lly pdf@urx pdf@ury]
        \common@choiceCode
    /ANN pdfmark}\endgroup
}
%    \end{macrocode}
% Driver dependent code (distiller) for push button fields.
%    \begin{macrocode}
\def\eq@Button@driver
{%
    \centerWidget\eq@rectH\if\autoCenter n\eqcenterWidget=0pt\fi
    \Hy@pdfstringtrue\ifx\eq@rectW\@empty\def\eq@rectW{\wd\eq@tmpbox}\fi
    \pdf@rect{\lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}}%
    \literalps@out{%
    [ /Rect [pdf@llx pdf@lly pdf@urx pdf@ury]
        \common@pushButtonCode
    /ANN pdfmark}\endgroup
}
%    \end{macrocode}
% Driver dependent code (distiller) for radio and button fields.
%    \begin{macrocode}
\def\eq@RadioCheck@driver
{%
    \centerWidget\eq@rectH\Hy@pdfstringtrue
    \if\autoCenter n\eqcenterWidget=0pt\fi
    \ifx\eq@rectW\@empty\def\eq@rectW{\wd\eq@tmpbox}\fi
    \pdf@rect{\lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}}%
    \literalps@out{%
    [ /Rect [pdf@llx pdf@lly pdf@urx pdf@ury]
        \common@RadioCheckCode
    /ANN pdfmark}\endgroup
}
\def\eq@l@check@driver
{%
    \pdf@rect{\makebox[\eq@tmpdima]{\phantom{\link@@Content}}}%
    \literalps@out{%
    [ /Rect [pdf@llx pdf@lly pdf@urx pdf@ury]
        \common@RadioCheckCode
    /ANN pdfmark}\endgroup
}
%    \end{macrocode}
% Driver dependent code for text fields.
%    \begin{macrocode}
\def\eq@TextField
{%
    \centerWidget\eq@rectH\if\autoCenter n\eqcenterWidget=0pt\fi
    \pdf@rect{\lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}}%
    \literalps@out{%
    [ /Rect [pdf@llx pdf@lly pdf@urx pdf@ury]
        \common@TextFieldCode
    /ANN pdfmark}\endgroup
}
\def\eq@calcTextField{\centerWidget\eq@rectH
    \if\autoCenter n\eqcenterWidget=0pt\fi
    \leavevmode\pdf@rect{\lower\eqcenterWidget\Bbox{\eq@rectW}%
    {\eq@rectH}}\literalps@out{%
    [ /_objdef {\Fld@name}
    /Rect [pdf@llx pdf@lly pdf@urx pdf@ury]
    \common@TextFieldCode
    /ANN pdfmark
    [ {corder} {\Fld@name} /APPEND pdfmark
    }\endgroup}
%    \end{macrocode}
% For processing the \texttt{pdfmark} with distiller, the key \texttt{/Action} is
% required (not \texttt{/A}). This macro converts \texttt{/A} to \texttt{/Action},
% and is used for the drivers using distiller.
%    \begin{macrocode}
\def\convertAToAction/A#1\@nil{\def\eq@A{/Action #1}}
%    \end{macrocode}
% Driver dependent code for links.
%    \begin{macrocode}
\def\setLink@driver
{%
    \ifx\eq@A\@empty\else\expandafter\convertAToAction\eq@A\@nil\fi
    \pdf@rect{\link@@Box}%
    \literalps@out{%
    [ /Rect [pdf@llx pdf@lly pdf@urx pdf@ury]
    \eq@Border
    \common@LinkCode
    /Subtype /Link
    /ANN pdfmark}%
    \endgroup
}
%    \end{macrocode}
%    \begin{macrocode}
%</epdfmark>
%    \end{macrocode}
%    \subsection{pdftex}
%    \begin{macrocode}
%<*epdftex>
%    \end{macrocode}
% Code used in the case of the \texttt{pdftex} option.
%\par\medskip\noindent
% Code to hide the solutions page to a quiz that has solutions.
%    \begin{macrocode}
\def\noPeek#1#2{\global\pdfpageattr=\expandafter{\noPeekAction{#1}{#2}}}
%    \end{macrocode}
% driver dependent code for choice fields
%    \begin{macrocode}
\def\eq@choice@driver
{%
    \centerWidget\eq@rectH\if\autoCenter n\eqcenterWidget=0pt\fi
    \hbox{\pdfstartlink user{\common@choiceCode}%
    \lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}\pdfendlink}%
    \endgroup
}
\def\eq@Button@driver
{%
    \centerWidget\eq@rectH
    \if\autoCenter n\eqcenterWidget=0pt\fi
    \ifx\eq@rectW\@empty\def\eq@rectW{\wd\eq@tmpbox}\fi
    \hbox{\pdfstartlink user{ \common@pushButtonCode }%
    \lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}\pdfendlink}%
    \endgroup
}
\def\eq@RadioCheck@driver
{%
    \centerWidget\eq@rectH
    \if\autoCenter n\eqcenterWidget=0pt\fi
    \ifx\eq@rectW\@empty\def\eq@rectW{\wd\eq@tmpbox}\fi
    \hbox{\pdfstartlink user{\common@RadioCheckCode}%
    \lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}\pdfendlink}%
    \endgroup
}
\def\eq@l@check@driver
{%
    \pdfstartlink user{\common@RadioCheckCode}%
    \makebox[\eq@tmpdima]{\phantom{\link@@Content}}%
    \pdfendlink\endgroup
}
\def\eq@TextField{\centerWidget\eq@rectH
    \if\autoCenter n\eqcenterWidget=0pt\fi
    \leavevmode\hbox{\pdfstartlink user{\common@TextFieldCode}%
    \lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}\pdfendlink}%
    \endgroup
}
\def\eq@calcTextField{\centerWidget\eq@rectH
    \if\autoCenter n\eqcenterWidget=0pt\fi
    \leavevmode\hbox{\pdfstartlink user{\common@TextFieldCode}%
    \lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}\pdfendlink}%
    \endgroup
}
\def\setLink@driver
{%
    \leavevmode\pdfstartlink
    attr {\eq@Border}%
    user{/Subtype/Link \common@LinkCode}%
    \Hy@colorlink{\@linkcolor}\link@@Box
    \close@pdflink
    \endgroup
}
%    \end{macrocode}
%    \begin{macrocode}
%</epdftex>
%    \end{macrocode}
%    \subsection{dvipdfm}
%    \begin{macrocode}
%<*edvipdfm>
%    \end{macrocode}
% Code to hide the solutions page to a quiz that has solutions.
%    \begin{macrocode}
\def\noPeek#1#2{\@pdfm@mark{put @thispage << \noPeekAction{#1}{#2} >> }}
%    \end{macrocode}
%    \begin{macrocode}
\def\eq@choice@driver
{%
    \centerWidget\eq@rectH\if\autoCenter n\eqcenterWidget=0pt\fi
    \leavevmode\setbox\pdfm@box=%
        \hbox{\lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}}%
    \@pdfm@mark{ann @\Fld@name\space\dvipdfm@setdim
    <<\common@choiceCode>>}\unhbox\pdfm@box\relax%
    \@pdfm@mark{put @afields @\Fld@name}% record in @afields array
\endgroup}
\def\eq@Button@driver
{%
    \centerWidget\eq@rectH
    \if\autoCenter n\eqcenterWidget=0pt\fi
    \ifx\eq@rectW\@empty\def\eq@rectW{\wd\eq@tmpbox}\fi
    \setbox\pdfm@box=%
        \hbox{\lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}}%
    \@pdfm@mark{ann @\Fld@name\space\dvipdfm@setdim
    << \common@pushButtonCode >>}\unhbox\pdfm@box\relax%
    \@pdfm@mark{put @afields @\Fld@name}% record in @afields array
    \endgroup
}
\def\eq@RadioCheck@driver
{%
    \centerWidget\eq@rectH\Hy@pdfstringtrue
    \if\autoCenter n\eqcenterWidget=0pt\fi
    \ifx\eq@rectW\@empty\def\eq@rectW{\wd\eq@tmpbox}\fi
    \setbox\pdfm@box=%
        \hbox{\lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}}%
    \@pdfm@mark{ann \dvipdfm@setdim
    <<\common@RadioCheckCode>>}\unhbox\pdfm@box\relax%
    \endgroup
}
\def\eq@l@check@driver
{%
    \setbox\pdfm@box=
      \hbox{\makebox[\eq@tmpdima]{\phantom{\link@@Content}}}%
        \@pdfm@mark{ann \dvipdfm@setdim<<\common@RadioCheckCode>>}%
        \unhbox\pdfm@box\relax\endgroup
}
\def\eq@TextField{\centerWidget\eq@rectH
    \if\autoCenter n\eqcenterWidget=0pt\fi
    \leavevmode\setbox\pdfm@box=%
        \hbox{\lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}}%
    \@pdfm@mark{ann @\Fld@name\space\dvipdfm@setdim
        << \common@TextFieldCode >>}\unhbox\pdfm@box\relax%
    \@pdfm@mark{put @afields @\Fld@name}% record in @afields array
    \endgroup
}
\def\eq@calcTextField{\centerWidget\eq@rectH
    \if\autoCenter n\eqcenterWidget=0pt\fi
    \leavevmode\hbox{\setbox\pdfm@box=%
        \hbox{\lower\eqcenterWidget\Bbox{\eq@rectW}{\eq@rectH}}%
    \@pdfm@mark{ann @\Fld@name\space\dvipdfm@setdim
    << \common@TextFieldCode >>}\unhbox\pdfm@box\relax}%
    \@pdfm@mark{put @afields @\Fld@name}% record in @afields array
    \@pdfm@mark{put @corder  @\Fld@name}%
    \endgroup
}
\def\setLink@driver
{%
    \leavevmode\@pdfm@mark{bann
    <</Subtype/Link\eq@Border\common@LinkCode>>}%
    \Hy@colorlink{\@linkcolor}\link@@Box\hyper@linkend
    \endgroup
}
%</edvipdfm>
%    \end{macrocode}
%  \Finale
\endinput