summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.dtx')
-rw-r--r--macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.dtx215
1 files changed, 186 insertions, 29 deletions
diff --git a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.dtx b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.dtx
index a8ea21042f..395955714f 100644
--- a/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.dtx
+++ b/macros/latex/contrib/pdfmanagement-testphase/l3pdffield-textfield.dtx
@@ -53,7 +53,7 @@
% }^^A
% }
%
-% \date{Version 0.95c, released 2021-03-17}
+% \date{Version 0.95e, released 2021-06-14}
%
% \maketitle
% \begin{documentation}
@@ -187,6 +187,7 @@
% Disabled keys are
% \begin{itemize}
% \item |FT| is overwritten.
+% \item |AS| is cleared.
% \item |DA| is overwritten.
% Locally use |fontcolor|, |fontsize| and |font| instead.
% Globally you can set the |DA| key in the catalog with for example
@@ -200,6 +201,10 @@
% set to 10 if it hasn't been set previously.
% \end{itemize}
%
+% The keys |value| and |default| are mapped to |V| and |DV| for this field type, see
+% below.
+%
+%
% \begin{function}{preset-textfield}
% \begin{syntax}
% |preset-textfield| = \Arg{key-val-list}
@@ -246,6 +251,7 @@
% with \cs{pdffield_field:nn}.
% \end{function}
%
+%
% \begin{function}{altname,TU}
% \begin{syntax}
% |altname| = \meta{string}\\
@@ -291,6 +297,25 @@
% make sense for a textfield).
% \end{function}
%
+% \begin{function}{V,value}
+% \begin{syntax}
+% |V| = \meta{text}\\
+% |value| = \meta{text}
+% \end{syntax}
+% This sets the start text in the field. The keys have an effect only at the first
+% instance of the textfield, when the field is initialized.
+% \end{function}
+%
+% \begin{function}{DV,default}
+% \begin{syntax}
+% |DV| = \meta{text}\\
+% |default| = \meta{text}
+% \end{syntax}
+% This sets the text which is shown if the form is reset.
+% The keys have an effect only at the first
+% instance of the textfield, when the field is initialized.
+% \end{function}
+%
% \begin{function}{fontcolor}
% \begin{syntax}
% |fontcolor| = \meta{color expression} \verb"|" [\meta{model}]\Arg{values}\\
@@ -340,41 +365,151 @@
% \end{documentation}
%
% \begin{implementation}
+% \DoNotIndex
+% {\\
+% ,\bitset_clear:N
+% ,\bitset_new:Nn
+% ,\bitset_set_false:Nn
+% ,\bitset_set_true:Nn
+% ,\bitset_to_arabic:N
+% ,\bitset_item:Nn
+% ,\bool_new:N
+% ,\box_dp:N
+% ,\box_ht:N
+% ,\clist_map_inline:nn
+% ,\color_export:nnN
+% ,\color_set:nn
+% ,\color_set:nnn
+% ,\color_select:n
+% ,\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
+% ,\c_space_tl
+% ,\csname
+% ,\dim_eval:n
+% ,\dim_new:N
+% ,\dim_to_decimal_in_bp:n
+% ,\endcsname
+% ,\exp_args:Ne
+% ,\fboxsep
+% ,\fp_eval:n
+% ,\f@size
+% ,\group_begin:
+% ,\group_end:
+% ,\hbox_to_wd:nn
+% ,\hfill
+% ,\hook_gput_code:nnn
+% ,\int_eval:n
+% ,\int_compare:nNnT
+% ,\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
+% ,\paperheight
+% ,\paperwidth
+% ,\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
+% ,\quark_if_no_value:NT
+% ,\raisebox
+% ,\rule
+% ,\seq_gput_right:Nn
+% ,\seq_if_exist:NTF
+% ,\seq_new:N
+% ,\seq_use:Nn
+% ,\smash
+% ,\str_if_empty:NTF
+% ,\str_if_in:NnTF
+% ,\str_new:N
+% ,\strut
+% ,\strutbox
+% ,\tl_put_right:Nn
+% ,\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-textfield} Implementation}
% \begin{macrocode}
%<*package>
%<@@=pdffield>
% \end{macrocode}
% \subsection{Variables}
+% \begin{variable}
+% {
+% \l_@@_DA_fontcolor_tl, \l_@@_DA_fontsize_dim, \l_@@_DA_fontname_tl
+% }
+% Variables for the font setup in the DA key.
% \begin{macrocode}
\tl_new:N \l_@@_DA_fontcolor_tl
\dim_new:N \l_@@_DA_fontsize_dim
\tl_new:N \l_@@_DA_fontname_tl
% \end{macrocode}
-% \subsection{Messages}
-% \begin{macrocode}
-% \end{macrocode}
+% \end{variable}
+%
% \subsection{Appearances}
-% The default appearances are a cross (\cs{texttimes}),
-% Every appearance should have two versions and follow the naming
-% module/\meta{name}/Yes and module/\meta{name}/Off.
-% \begin{macro}{@@/textfield/default_appearances:}
+% The default appearance is a light gray background.
+%
+% \begin{macro}{\@@_textfield_default_appearance:}
% This defines the standard appearance. It is setup at the first
% use of a textfield.
% \begin{macrocode}
-\cs_new_protected:cn {@@/textfield/default_appearance:}
+\cs_new_protected:Npn {\@@_textfield_default_appearance:}
{
\pdffield_appearance:nn {pdffield/textfield/default}
{
{ \color_select:n{black!5!white}\rule{\paperwidth}{\paperheight} }
}
- \cs_gset_eq:cN {@@/textfield/default_appearance:} \prg_do_nothing:
+ \cs_gset_eq:NN \@@_textfield_default_appearance: \prg_do_nothing:
}
% \end{macrocode}
% \end{macro}
%
%\subsection{Creating the field}
-% A field should be created if the name doesn't exist
+% \begin{macro}{\@@_textfield_field:n}
+% A field should be created only if the name doesn't exist
% \begin{macrocode}
\cs_new_protected:Npn \@@_textfield_field:n #1 %name
{
@@ -386,17 +521,22 @@
}
\cs_generate_variant:Nn \@@_textfield_field:n {V}
% \end{macrocode}
+% \end{macro}
+%
% \subsection{Assembling the textfield}
-
+%
% \begin{macro}{\@@_textfield:n}
+% At first we map the handler and setup the appearance.
% \begin{macrocode}
\cs_new_protected:Npn \@@_textfield:n #1
{
\group_begin:
- \cs_set_eq:NN\@@_value_handler:nN \@@_textfield_value_handler:nN
- \use:c {@@/textfield/default_appearance:}
+ \cs_set_eq:NN\@@_V_handler:nN \@@_textfield_V_handler:nN
+ \cs_set_eq:NN\@@_value_handler:n \@@_textfield_value_handler:n
+ \cs_set_eq:NN\@@_default_handler:n \@@_textfield_default_handler:n
+ \@@_textfield_default_appearance:
% \end{macrocode}
-% Setting up the defaults.
+% Setting up the defaults and processing the keys.
% \begin{macrocode}
\keys_set:nn {pdffield}
{
@@ -409,9 +549,10 @@
depth = \fp_eval:n {0.3*\f@size} pt,
% font defaults!!
}
-% \end{macrocode}
-% \begin{macrocode}
\keys_set:nn { pdffield }{@@/preset/textfield,#1}
+% \end{macrocode}
+% We need to check if Comb is used and setup some flags in this case.
+% \begin{macrocode}
\int_compare:nNnT {\bitset_item:Nn \l_@@_Ff_bitset {Comb}}={1}
{
% warning if set?
@@ -429,6 +570,9 @@
% warning
}
}
+% \end{macrocode}
+% Now the postprocessing.
+% \begin{macrocode}
\keys_set:nn { pdffield }
{
,FT= Tx
@@ -446,12 +590,14 @@
%\l_@@_text_DAextra_tl
}
}
+% \end{macrocode}
+% If no field ID exists, we get it from the T key.
+% \begin{macrocode}
\tl_if_empty:NT\l_@@_fieldID_tl
{
\pdfdict_get:nnN {l_@@/field}{T}\l_@@_fieldID_tl
\tl_put_left:Nn \l_@@_fieldID_tl {@@/textfield/}
}
-
\@@_textfield_field:V\l_@@_fieldID_tl
\@@_annot:
\group_end:
@@ -463,6 +609,7 @@
% 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}{fontcolor,fontsize,font}
% \begin{macrocode}
\keys_define:nn {pdffield}
{
@@ -482,23 +629,32 @@
,fontsize .groups:n = {textfield}
}
% \end{macrocode}
-% And a key to set a dedicated field ID
-% \begin{macrocode}
-\keys_define:nn { pdffield }
- {
- fieldID .tl_set:N = \l_@@_fieldID_tl
- }
-% \end{macrocode}
+% \end{macro}
%
% \subsection{Handler}
+% \begin{macro}{\@@_textfield_V_handler:nN}
+% The handler for V/DV, it creates a string.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_textfield_value_handler:nN #1#2
+\cs_new_protected:Npn \@@_textfield_V_handler:nN #1#2
{
- \pdf_string_from_unicode:nnN {utf8/string}{#1}#2
+ \pdf_string_from_unicode:nnN {utf16/hex}{#1}#2
}
% \end{macrocode}
-%
-% \subsection{user commands}
+% \end{macro}
+% \begin{macro}{\@@_textfield_value_handler:n,\@@_textfield_default_handler:n}
+% The handler for value and default. They simply map to V,DV here.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_textfield_value_handler:n #1
+ {
+ \keys_set:nn{pdffield}{V={#1}}
+ }
+\cs_new_protected:Npn \@@_textfield_default_handler:n #1
+ {
+ \keys_set:nn{pdffield}{DV={#1}}
+ }
+% \end{macrocode}
+% \end{macro}
+% \subsection{User command}
% \begin{macro}{\pdffield_textfield:n}
% \begin{macrocode}
\cs_set_eq:NN \pdffield_textfield:n \@@_textfield:n
@@ -506,3 +662,4 @@
% \end{macrocode}
% \end{macro}
%\end{implementation}
+%\PrintIndex