summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.dtx')
-rw-r--r--macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.dtx187
1 files changed, 165 insertions, 22 deletions
diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.dtx
index 681a8d7059..413b9ee317 100644
--- a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.dtx
+++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-checkbox.dtx
@@ -68,7 +68,7 @@
% }^^A
% }
%
-% \date{Version 0.95d, released 2021-05-14}
+% \date{Version 0.95e, released 2021-06-14}
%
% \maketitle
% \begin{documentation}
@@ -116,14 +116,17 @@
% The |appearance| keys have a more checkbox specific
% behaviour, other keys have other defaults than with the basic commands.
% Additionally there
-% are a small number of keys specific to a checkbox.
+% are a small number of keys specific to a checkbox.
+% For convenience a number of important keys are documented here too, even if
+% they are already in the document from l3pdffield.
%
%
% Disabled keys are
% \begin{itemize}
% \item |V|, |DV|, |AS|: use |checked| instead.
% \item |FT| is overwritten.
-% \item For checkboxes only the field flags |ReadOnly|, |Required| and |NoExport| make sense.
+% \item For checkboxes only the field flags |ReadOnly|, |Required| and |NoExport|
+% make sense.
% |Radio|, |Pushbotton| are set automatically automatically by the code
% as this is required for a checkbox.
% \end{itemize}
@@ -140,7 +143,7 @@
% |name| = \meta{partial name}\\
% |T| = \meta{partial name}
% \end{syntax}
-% This sets like the |T| key for fields the partial name of the field. The value
+% This sets the partial name of the field. The value
% shouldn't contain a period, be not empty and sensibly consist of simple chars.
% Additionally the value is used to create the field ID.
% This means that checkboxes with the same partial name are annotations
@@ -157,7 +160,8 @@
% \end{syntax}
% \emph{For experts only!}
% This allows to give the checkbox field a specific ID. This is only useful
-% in the context of a larger fieldset or if you want to attach another annotation
+% in the context of a larger fieldset, if for example you want to use
+% the same partial name for more than one field, or if you want to attach another annotation
% to the field with \cs{pdffield_annot:n}. If used wrongly you can
% easily create invalid fieldset. It allows you to create to fields with the
% same partial name, but if you want to see both
@@ -219,8 +223,9 @@
% \meta{partial appearance name}|/Yes| and \meta{partial appearance name}|/Off|
% has been created. The initial value is |pdffield/checkbox/default|
% for the normal appearance and shows a \cs{texttimes}.
-% The other appearance are not set by default.
+% The other appearances are not set by default.
% \end{function}
+%
% \begin{function}{checked}
% \begin{syntax}
% |checked| = |true|\verb"|"|false|
@@ -231,6 +236,13 @@
% values for different instances, if one wants to confuse the user.
% \end{function}
%
+% \begin{function}{value,default}
+% \begin{syntax}
+% |value| = |Yes|\verb"|"|Off|\\
+% |default| = |Yes|\verb"|"|Off|\\
+% \end{syntax}
+% With checkboxes this two key are simply an alternative input for |checked|.
+% \end{function}
%
% \subsection{Using with hyperref}
% The \cs{CheckBox} command from hyperref also prints a label, something that the
@@ -265,26 +277,123 @@
% \end{documentation}
%
% \begin{implementation}
+% \DoNotIndex
+% {\\
+% ,\bitset_clear:N
+% ,\bitset_new:Nn
+% ,\bitset_set_false:Nn
+% ,\bitset_set_true:Nn
+% ,\bitset_to_arabic:N
+% ,\bool_new:N
+% ,\box_dp:N
+% ,\box_ht:N
+% ,\clist_map_inline:nn
+% ,\color_export:nnN
+% ,\color_set:nn
+% ,\color_set:nnn
+% ,\cs_new_protected:Npn
+% ,\cs_new_protected:cpn
+% ,\cs_set_eq:NN
+% ,\cs_gset_eq:cN
+% ,\cs_set_protected:Npn
+% ,\cs_generate_variant:Nn
+% ,\cs_gset_eq:NN
+% ,\csname
+% ,\dim_eval:n
+% ,\dim_new:N
+% ,\endcsname
+% ,\exp_args:Ne
+% ,\fboxsep
+% ,\group_begin:
+% ,\group_end:
+% ,\hbox_to_wd:nn
+% ,\hfill
+% ,\hook_gput_code:nnn
+% ,\int_eval:n
+% ,\l_keys_choice_int
+% ,\keys_define:nn
+% ,\keys_set:nn
+% ,\mode_leave_vertical:
+% ,\msg_error:nnn
+% ,\msg_error:nnnn
+% ,\msg_new:nnn
+% ,\msg_warning:nn
+% ,\msg_warning:nnn
+% ,\msg_warning:nnnnn
+% ,\NeedsTeXFormat
+% ,\normalsize
+% ,\pdf_name_from_unicode_e:n
+% ,\pdf_object_if_exist:nTF
+% ,\pdf_object_if_exist:nF
+% ,\pdf_object_new:nn
+% ,\pdf_object_ref:n
+% ,\pdf_object_ref_last:
+% ,\pdf_object_unnamed_write:nn
+% ,\pdf_object_write:nn
+% ,\pdf_string_from_unicode:nnN
+% ,\pdfannot_box_ref_last:
+% ,\pdfannot_dict_put:nnn
+% ,\pdfannot_dict_remove:nn
+% ,\pdfannot_widget_box:nnn
+% ,\pdfdict_if_empty:nTF
+% ,\pdfdict_get:nnN
+% ,\pdfdict_new:n
+% ,\pdfdict_put:nnn
+% ,\pdfdict_remove:nn
+% ,\pdfdict_use:n
+% ,\pdfmanagement_add:nnn
+% ,\pdfmeta_standard_verify:nTF
+% ,\pdfxform_if_exist:nTF
+% ,\pdfxform_new:nnn
+% ,\pdfxform_ref:n
+% ,\phantom
+% ,\prg_do_nothing:
+% ,\ProvidesExplPackage
+% ,\rule
+% ,\seq_gput_right:Nn
+% ,\seq_if_exist:NTF
+% ,\seq_new:N
+% ,\seq_use:Nn
+% ,\str_if_empty:NTF
+% ,\str_if_in:NnTF
+% ,\str_new:N
+% ,\strut
+% ,\strutbox
+% ,\tl_if_empty:NTF
+% ,\tl_if_empty:NT
+% ,\tl_if_empty:NF
+% ,\tl_put_left:Nn
+% ,\tl_if_empty:nTF
+% ,\tl_if_head_eq_charcode:nNTF
+% ,\tl_new:N
+% ,\tl_set:Nn
+% ,\tl_to_str:n
+% ,\use:c
+% }
% \section{\pkg{l3pdffield-checkbox} Implementation}
% \begin{macrocode}
%<*package>
%<@@=pdffield>
% \end{macrocode}
% \subsection{Variables}
-% \begin{macrocode}
-% \end{macrocode}
+% There are no specific variables.
% \subsection{Messages}
-% \begin{macrocode}
-% \end{macrocode}
+% There are no specific messages.
% \subsection{Appearances}
-% The default appearances are a cross (\cs{texttimes}),
-% Every appearance should have two versions and follow the naming
+% The default appearances are a quadratic frame with cross (\cs{texttimes}) if
+% checked.
+% User appearances should have two versions and follow the naming
% module/\meta{name}/Yes and module/\meta{name}/Off.
-% \begin{macro}{@@/checkbox/default_appearances:}
+% \begin{macro}
+% {
+% \@@_checkbox_default_appearances:,
+% pdffield/checkbox/default/Yes,
+% pdffield/checkbox/default/Off
+% }
% This defines the standard appearance. It is setup at the first
% use of a checkbox, and will adapt to the font family in use then.
% \begin{macrocode}
-\cs_new_protected:cn {@@/checkbox/default_appearances:}
+\cs_new_protected:Npn \@@_checkbox_default_appearances:
{
\pdffield_appearance:nn {pdffield/checkbox/default/Yes}
{
@@ -302,13 +411,14 @@
[ \dim_eval:n { \box_ht:N\strutbox+\box_dp:N\strutbox } ]
{ \phantom{\texttimes} \strut }
}
- \cs_gset_eq:cN {@@/checkbox/default_appearances:} \prg_do_nothing:
+ \cs_gset_eq:NN \@@_checkbox_default_appearances: \prg_do_nothing:
}
% \end{macrocode}
% \end{macro}
%
%\subsection{Creating the field}
% A field should be created if the name doesn't exist
+% \begin{macro}{ \@@_checkbox_field:n }
% \begin{macrocode}
\cs_new_protected:Npn \@@_checkbox_field:n #1 %name
{
@@ -320,15 +430,18 @@
}
\cs_generate_variant:Nn \@@_checkbox_field:n {V}
% \end{macrocode}
+% \end{macro}
% \subsection{Assembling the checkbox}
-
+%
% \begin{macro}{\@@_checkbox:n}
% \begin{macrocode}
\cs_new_protected:Npn \@@_checkbox:n #1
{
\group_begin:
- \use:c {@@/checkbox/default_appearances:}
+ \@@_checkbox_default_appearances:
\cs_set_eq:NN\@@_appearance_handler:nnn \@@_checkbox_appearance_handler:nnn
+ \cs_set_eq:NN\@@_value_handler:n \@@_checkbox_value_handler:n
+ \cs_set_eq:NN\@@_default_handler:n \@@_checkbox_default_handler:n
% \end{macrocode}
% Setting up the defaults.
% \begin{macrocode}
@@ -369,6 +482,8 @@
% Most keys are inherited simply the ones from the generic field and annot keys.
% A key to decide if the box is initially checked or not.
% We stay in the same family so that we can build a style.
+% \begin{macro}{checked}
+% This is a key specific for checkbox, it sets both field and annotation keys.
% \begin{macrocode}
\keys_define:nn { pdffield }
{
@@ -388,15 +503,41 @@
,checked .default:n = {true}
,checked .groups:n = {checkbox}
}
-% \end{macrocode}
-% And a key to set a dedicated field ID
-% \begin{macrocode}
-\keys_define:nn { pdffield }
+\keys_define:nn { pdffield }
{
- fieldID .tl_set:N = \l_@@_fieldID_tl
+ ,__value .choice:
+ ,__value / Off .code:n =
+ {
+ \pdfdict_put:nnx { l_@@/field }{V} { /Off }
+ \pdfdict_put:nnx { l_@@/field }{DV}{ /Off }
+ \pdfannot_dict_put:nnn {widget}{AS}{ /Off }
+ }
+ ,__value / Yes .code:n =
+ {
+ \pdfdict_put:nnx { l_@@/field }{V} { /Yes }
+ \pdfdict_put:nnx { l_@@/field }{DV}{ /Yes }
+ \pdfannot_dict_put:nnn {widget}{AS}{ /Yes }
+ }
}
% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@@_checkbox_value_handler:n,\@@_checkbox_default_handler:n}
+% |value| and |default| do the same as checked.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_checkbox_value_handler:n #1
+ {
+ \keys_set:nn{pdffield}{__value={#1}}
+ }
+\cs_new_protected:Npn \@@_checkbox_default_handler:n #1
+ {
+ \keys_set:nn{pdffield}{__value={#1}}
+ }
+% \end{macrocode}
+% \end{macro}
% \begin{macro}{\@@_checkbox_appearance_handler:nnn}
+% Appearances must create a dictionary, so we define a special handler.
+% \Arg{name} is the xform name without the /Yes, /Off, \Arg{type} is N, R, or D,
+% \Arg{text} is a word for the error message.
% \begin{macrocode}
\cs_new_protected:Npn \@@_checkbox_appearance_handler:nnn #1 #2 #3 %name, type, text
{
@@ -431,3 +572,5 @@
% \end{macrocode}
% \end{macro}
%\end{implementation}
+
+% \PrintIndex