% \iffalse meta-comment
%
% Copyright (C) 2014 by Henry Menke <henrimenke@gmail.com>
% Copyright (C) 2019 by Benjamin Berg <benjamin@sipsolutions.net>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% 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
%
% This work has the LPPL maintenance status `maintained'.
% 
% The Current Maintainer of this work is Benjamin Berg.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{sdapspdf.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{sdapspdf}
%<*package>
    [2015/04/10 v0.1 Initial version of SDAPS pdf package]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{sdapspdf}[2015/04/10]
%\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{sdapspdf.dtx}
\end{document}
%</driver>
% \fi
%
% \CheckSum{0}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v0.1}{2015/01/14}{Initial version}
%
% \GetFileInfo{sdapspdf.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
% 
%
% \title{The \textsf{sdapspdf} package\thanks{This document
%   corresponds to \textsf{sdapspdf}~\fileversion, dated \filedate.}}
% \author{Benjamin Berg \\ \texttt{benjamin@sipsolutions.net}}
%
% \maketitle
%
% \section{Documentation}
%
% Please refer to \url{https://sdaps.org/class-doc} for documentation.
%
% \StopEventually{\PrintChanges\PrintIndex}
%
% \section{Implementation}
%
% This package uses the \LaTeX3 language internally, so we need to enable it.
%    \begin{macrocode}
% We need at least 2011-08-23 for \keys_set_known:nnN
\RequirePackage{expl3}[2011/08/23]
%\RequirePackage{xparse}
\ExplSyntaxOn
%    \end{macrocode}
%
% And we need a number of other packages.
%    \begin{macrocode}
\ExplSyntaxOff

\RequirePackage{sdapsbase}
\RequirePackage{hyperref}


\ExplSyntaxOn

%    \end{macrocode}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \subsection{PDF Support}
%
% This package adds basic overlays to SDAPS boxes so that they become editable.
% It is also possible to pre-fill them using overrides or the normal mechanism
% to set variables for box drawing.
%
%    \begin{macrocode}


\bool_new:N \l__sdaps_pdf_form_bool
\bool_new:N \l__sdaps_pdf_checkbox_default_bool
\tl_new:N \l__sdaps_pdf_checkboxsymbol_tl

\keys_define:nn { sdaps / checkbox / overlay / pdfform }
{
  pdf_form         .bool_set:N  = \l__sdaps_pdf_form_bool,
  pdf_form         .initial:n   = false,

  default          .bool_set:N  = \l__sdaps_pdf_checkbox_default_bool,
  default          .initial:n   = false,

  checkboxsymbol   .tl_set:N  = \l__sdaps_pdf_checkboxsymbol_tl,
  checkboxsymbol   .initial:n   = 8,
}

\cs_new_protected_nopar:Nn \_sdaps_pdf_overlay_checkbox_form:
{
  \keys_set_known:nV { sdaps / checkbox / overlay / pdfform } \l_sdaps_parse_unknown_tl %

  \bool_if:NT \l__sdaps_pdf_form_bool {
    \node[anchor=center,inner~sep=0pt,outer~sep=0pt] at ($(\l_sdaps_x_dim, \l_sdaps_y_dim) + 0.5*(\l_sdaps_width_dim, -\l_sdaps_height_dim)$) {
      \CheckBox[name=\l_sdaps_var_tl,bordersep=0,borderwidth=0pt,checkboxsymbol=\l__sdaps_pdf_checkboxsymbol_tl,bordercolor=,backgroundcolor=,checked=\bool_if:nTF\l__sdaps_pdf_checkbox_default_bool{true}{false},height=\l_sdaps_checkbox_height_dim,width=\l_sdaps_checkbox_width_dim]{\ignorespaces}
    };
  }
}
\seq_put_left:Nn \g__sdaps_checkbox_overlays_seq \_sdaps_pdf_overlay_checkbox_form:


\cs_new_protected_nopar:Nn \_sdaps_pdf_overlay_text_form:
{
  \keys_set_known:nV { sdaps / checkbox / overlay / pdfform } \l_sdaps_parse_unknown_tl %

  \bool_if:NT \l__sdaps_pdf_form_bool {
    \node[anchor=center,inner~sep=2pt,outer~sep=0pt] at ($(\l_sdaps_x_dim, \l_sdaps_y_dim) + 0.5*(\l_sdaps_width_dim, -\l_sdaps_height_dim)$) {
      \dim_set:Nn \l_sdaps_width_dim { \l_sdaps_width_dim - 4pt }
      \dim_set:Nn \l_sdaps_height_dim { \l_sdaps_height_dim - 4pt }

      \TextField[name=\l_sdaps_var_tl,bordersep=0pt,borderwidth=0pt,bordercolor=,backgroundcolor=,multiline=true,height=\l_sdaps_height_dim,width=\l_sdaps_width_dim]{\ignorespaces}
    };
  }
}
\seq_put_left:Nn \g__sdaps_textbox_overlays_seq \_sdaps_pdf_overlay_text_form:



\ExplSyntaxOff

%
%    \end{macrocode}
%

% \Finale
\endinput
