[latex3-commits] [git/LaTeX3-latex3-pdfresources] radiobuttons: finish radiobutton, docu, small changes (7d37599)
Ulrike Fischer
fischer at troubleshooting-tex.de
Wed May 26 17:45:23 CEST 2021
Repository : https://github.com/latex3/pdfresources
On branch : radiobuttons
Link : https://github.com/latex3/pdfresources/commit/7d3759996ede4e112656388c477a4131872c5a9a
>---------------------------------------------------------------
commit 7d3759996ede4e112656388c477a4131872c5a9a
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Wed May 26 17:45:23 2021 +0200
finish radiobutton, docu, small changes
>---------------------------------------------------------------
7d3759996ede4e112656388c477a4131872c5a9a
l3pdffield-radiobutton.dtx | 421 +++++++++++++++++++++++++++++++--------------
l3pdffield-textfield.dtx | 70 +++++---
l3pdffield.dtx | 1 +
3 files changed, 336 insertions(+), 156 deletions(-)
diff --git a/l3pdffield-radiobutton.dtx b/l3pdffield-radiobutton.dtx
index d0265b6..89911f8 100644
--- a/l3pdffield-radiobutton.dtx
+++ b/l3pdffield-radiobutton.dtx
@@ -71,7 +71,16 @@
% This is the documentation for radio buttons fields, for general information about form fields
% check the documentation l3pdffield.
%
-%
+% \begin{center}
+% \ExplSyntaxOn
+% \pdffield_radio:n{name=A,value=A,default=B}\quad
+% \pdffield_radio:n{name=A,value=B}\quad
+% \pdffield_radio:n{name=A,value=C}\par\medskip
+% \pdffield_radio:n{name=A,value=A}\quad
+% \pdffield_radio:n{name=A,value=B}\quad
+% \pdffield_radio:n{name=A,value=C}\par
+% \ExplSyntaxOff
+% \end{center}
%
% Please keep in mind
% \begin{itemize}
@@ -92,16 +101,18 @@
% they have like checkboxes two \enquote{states}:
% checked and unchecked.
%
-% The difference is that checkboxes are either \enquote{clones} which
-% are checked and unchecked together,
-% or are independent of each other. Radio buttons on the other side build groups
-% where checking one of the buttons uncheck all other buttons.
+% The difference is that multiple checkboxes are either \enquote{clones} of each other
+% which are checked and unchecked together,
+% or they are independent of each other.
+% Radio buttons on the other side build \emph{groups}
+% where checking one of the buttons unchecks all other buttons.
% The elements of a such a radio button group are annotations of one field which
-% has a flag set which make it into a radio button group.
+% has a flag set which makes it into a radio button group.
%
% In a checkbox field the two states have the
% fix names |/Yes| and |/Off|.
%
+% \begin{center}
% \begin{tikzpicture}[level 2/.style={level distance=7mm},
% level 1/.style={sibling distance=25mm},
% level 2/.style={sibling distance=15mm}]
@@ -116,15 +127,31 @@
% }}
% ;
% \end{tikzpicture}
+% \end{center}
%
% In radio buttons
% the off state should still always have the name |/Off|\footnote{%
% the PDF reference doesn't say anything about this, but various tests showed that
% one better should stick to this name, with other names the buttons disappeared.}
-% but the on state should be the value. The field dictionary should then set
-% in the |/V| key the start value (this doesn't necessarly mean that the button
-% is also selected from the begin on, this can be set independantly).
+% but the on state should be a specific value for every button.
+% The field dictionary should then set
+% in the |/V| key as the value of one of the button.
+% This button is then set as selected and all the other are deselected when the
+% PDF is opened or reset.
%
+% It is theoretically possible to control the start appearance state for every
+% button so e.g. all buttons could have the \enquote{selected} state when the PDF is opened.
+% But as soon as one button is clicked
+% you get one selected button and the other are unselected. You can't select or
+% deselect all buttons. The PDF reference mentions an flag |NoToggleToOff| but this
+% doesn't do anything, at least not in the PDF viewers I tried. For this
+% reason setting special start states is currently not supported: it complicates the code and the
+% input for no real gain.
+%
+%
+% The values of the individual buttons can be coded as annotation state names:
+%
+% \begin{center}
% \begin{tikzpicture}[level 2/.style={level distance=7mm},
% level 1/.style={sibling distance=25mm},
% level 2/.style={sibling distance=15mm}]
@@ -143,13 +170,15 @@
% }}
% ;
% \end{tikzpicture}
+% \end{center}
%
-% It can be awkward to have to use the values also as names of appearances states, it
+% But it can be awkward to have to use the values also as names of appearances states, it
% makes it for example difficult to use unicode for the value names, so there is another
% option: One can set up an |/Opt| array which contains the values as strings,
% and used \enquote{named numbers} as appearance state name: The numbers
% |/0|, |/1| point then to the index position in the array.
%
+% \begin{center}
% \begin{tikzpicture}[level 2/.style={level distance=7mm},
% level 1/.style={sibling distance=25mm},
% level 2/.style={sibling distance=15mm}]
@@ -170,6 +199,7 @@
% }}
% ;
% \end{tikzpicture}
+% \end{center}
%
% This method is clearly more flexible, and so it is used in this module.
%
@@ -182,64 +212,57 @@
% \begin{verbatim}
% \pdffield_radio:n
% {
-% group = A, %required, can also be given as name=A or T=A
-% choice = button1, %required, on-state of this button
-% default = button4 %default of the group, if not given choice (button1) is used
-% %should refer to an existing button!
-% %It will set the V and the DV key
-% %button4 will be checked
+% group = A, % required, can also be given as name=A or T=A
+% value = button1, % required, on-state of this button
+% default = button4 % default of the group,
+% % if not given choice (button1) is used
+% % should refer to an existing button!
+% % It will set the V and the DV key
+% % button4 will be checked
% }
% \pdffield_radio:n
% {
-% group = A, %required, can also be given as name=A or T=A
-% choice = button2 %required, export value of this button
+% group = A, % required, can also be given as name=A or T=A
+% value = button2 % required, export value of this button
% }
% \pdffield_radio:n
% {
-% group = A, %required, can also be given as name=A or T=A
-% choice = button3, %required, choice/export value of this button
+% group = A, % required, can also be given as name=A or T=A
+% value = button3, % required, choice/export value of this button
% }
% \pdffield_radio:n
% {
-% group = A, %required, can also be given as name=A or T=A
-% choice = button4 %required, choice/export value of this button
+% group = A, % required, can also be given as name=A or T=A
+% value = button4 % required, choice/export value of this button
% }
% \end{verbatim}
%
%
-% It is theoretically possible to control the start appearance state for every
-% button so e.g. all buttons could have the \enquote{selected} state when the PDF is opened.
-% But as soon as one button is clicked
-% you get one selected button and the other are unselected. You can't select or
-% deselect all buttons. The PDF reference mentions an flag |NoToggleToOff| but this
-% doesn't do anything, at least not in the PDF viewers I tried. For this
-% reason this function is currently not supported.
-%
-% If two radio field annotations use the same |choice| value they are selected and
-% unselected together, like checkboxes with the same /Yes state. This can be used
+% If two radio field annotations use the same |value| they are selected and
+% unselected together, like checkboxes with the same |/Yes| state. This can be used
% to build radio groups which works \enquote{in unison}. The flag |RadiosInUnison|
% is neither needed for this (but doesn't harm either) nor
% does it change the behaviour, at least again not in the PDF viewers I tried.
%
%
-%
-%
% \bigskip
% \subsection{Commands}
% \begin{function}{\pdffield_radio:n}
% \begin{syntax}
% \cs{pdffield_radio:n}\Arg{key val list}
% \end{syntax}
-% This creates a radio button to check and uncheck. The list of allowed keys is described below.
-% The \meta{key val list} should at least set the name, without it the default name
+% This creates a radio button to check and uncheck.
+% The list of allowed keys is described below.
+% The \meta{key val list} should at least set the group name,
+% without it the default group
% |radio| is used. Radiobuttons with the same
-% name belong to the same field and if checked, the others are unchecked.
+% group name belong to the same field and if checked, the others are unchecked.
% The default appearance
% is a circle frame with a black bullet in it for the checked case.
-% The default appearance is setup at the first use. It dimension are quadratic.
+% The default appearance is setup at the first use. Its geometry is quadratic.
%
% The first radio button setups the field and should also set the button which
-% is selected when the PDF is opened.
+% should be shown as selected when the PDF is opened.
% \end{function}
%
%
@@ -251,6 +274,7 @@
% behaviour, other keys have other defaults than with the basic commands.
% Additionally there
% are a small number of keys specific to a radio button.
+% |value| and |default| have a special meaning.
%
%
% Disabled keys are
@@ -258,12 +282,13 @@
% \item |V|, |DV|, |AS|: they are set by the other keys.
% \item |FT| is overwritten.
% \item For radio buttons only the field flags |ReadOnly|, |Required|, |NoExport|,
-% |NoToggleToOff] and |RadiosInUnison| make sense. The last two are as mentioned
+% |NoToggleToOff| and |RadiosInUnison| make sense. The last two are as mentioned
% above probably useless.
% |Radio| is set automatically automatically by the code
% as this is required for a radio button set.
% \end{itemize}
%
+%
% \begin{function}{preset-radio}
% \begin{syntax}
% |preset-radio| = \Arg{key-val-list}
@@ -271,12 +296,14 @@
% This allows to set default keys for a radio button.
% \end{function}
%
-% \begin{function}{name,T}
+% \begin{function}{group,name,T}
% \begin{syntax}
+% |group| = \meta{partial name}\\
% |name| = \meta{partial name}\\
% |T| = \meta{partial name}
% \end{syntax}
-% Both keys set the partial name of the field. The value
+% These keys set the partial name of the field. They all do the same
+% thing, use the one you are more comfortable with. 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 radio buttons with the same partial name are annotations
@@ -286,6 +313,27 @@
% For explicit control of the field ID use the |fieldID| key.
% \end{function}
%
+% \begin{function}{value}
+% \begin{syntax}
+% |value| = \meta{string}
+% \end{syntax}
+% With this key you set the export value name for the individual buttons.
+% Every button should have a value.
+% buttons with the same value are checked in unison. The value can use unicode.
+% \end{function}
+%
+% \begin{function}{default}
+% \begin{syntax}
+% |default| = \meta{string}
+% \end{syntax}
+% With this key you set the button which is checked when the PDF is opened.
+% The key must be used in the command of the first button. If it is missing
+% the value of the first button is used as default.
+% \meta{string} should be identical to a |value| of one of the buttons of the group.
+% This is not checked, buttons can be created on various pages, so it would
+% require a label/ref system to keep track of the names.
+% \end{function}
+
% \begin{function}{fieldID}
% \begin{syntax}
% |fieldID| = \meta{field ID}\\
@@ -309,14 +357,6 @@
% with \cs{pdffield_field:nn}.
% \end{function}
%
-% \begin{function}{button} %???????name????????
-% \begin{syntax}
-% |button| = \meta{string}\\
-% \end{syntax}
-% This set the name/export value of the single button. buttons with the same
-% value are set in unison. The string can use unicode.
-% \end{function}
-%
%
% \begin{function}{width,height,depth}
% \begin{syntax}
@@ -343,54 +383,147 @@
% mouse clicks). They take as value a
% \meta{partial appearance name} and expects that \emph{two} form Xobjects
% \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.
-% \end{function}
-% \begin{function}{checked}
-% \begin{syntax}
-% |checked| = |true|\verb"|"|false|
-% \end{syntax}
-% This is a boolean key which allows to set if the
-% checkbox should be initially checked or not. It sets the |/V| and |/DV| key of the field
-% and the |/AS| key of the annotation instance. It is possible to use different
-% values for different instances, if one wants to confuse the user.
+% has been created. The initial value is |pdffield/radio/default|
+% for the normal appearance and shows a button.
+% The down appearance enlarges the middle button a bit to give a visual feed back.
% \end{function}
%
-%
% \subsection{Using with hyperref}
-% The \cs{CheckBox} command from hyperref also prints a label, something that the
-% command here doesn't do. A redefinition like the following should allow \cs{CheckBox}
-% to use the commands of this module. Be aware that the behaviour will not be identical!
-% Not every setting and key from \pkg{hyperref} has been copied.
+% Radio buttons in hyperref are created with \cs{ChoiceMenu} command, and
+% they also print a label. choices are actually a different field type and
+% so created with different commands. It is not quite clear yet,
+% how this could be mapped.
%
-% \begin{verbatim}
-% \ExplSyntaxOn\makeatletter
-% \def\@CheckBox[#1]#2{\LayoutCheckField{#2}{\pdffield_checkbox:n {name=#2,#1}}}
-% \ExplSyntaxOff\makeatother
-% \end{verbatim}
-%
-% \subsection{Some background}
-% For some general background about fieldsets, fields and field annotations, please
-% check \pkg{l3pdffield}. Here are only some remarks about the special case of
-% checkboxes.
-%
-% A checkbox consist of a field along with one or more field annotations.
-% The annotations can appear on more than one page or locations and if one instance
-% is checked all other instances follows and are checked too.
-%
-% A checkbox has two different looks: checked and unchecked. The hyperref
-% implementation uses symbolic names for the two states and adds some
-% values with the /MK key and lets the PDF viewer
-% create a look from them. But this doesn't work reliably and is one of the reasons
-% why a reimplementation is needed. Also newer PDF versions
-% deprecate the /NeedAppearances setting and require that such a look,
-% an \enquote{appearance}, is given as form XObjects.
-% So the code forces the use of two appearances.
%
% \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
+% ,\exp_args:Nc
+% ,\fboxsep
+% ,\fp_eval:n
+% ,\f at size
+% ,\group_begin:
+% ,\group_end:
+% ,\hbox_to_wd:nn
+% ,\hfill
+% ,\hook_gput_code:nnn
+% ,\int_eval:n
+% ,\int_compare:nNnT
+% ,\int_compare:nNnTF
+% ,\int_incr:N
+% ,\int_new:N
+% ,\int_use:N
+% ,\int_zero: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
+% ,\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_unnamed_write:nx
+% ,\pdf_object_write:nx
+% ,\pdf_object_write:nn
+% ,\pdf_string_from_unicode:nnN
+% ,\pdfannot_box_ref_last:
+% ,\pdfannot_dict_put:nnn
+% ,\pdfannot_dict_put:nnx
+% ,\pdfdict_put:nnx
+% ,\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
+% ,\RequirePackage
+% ,\rule
+% ,\seq_gput_right:Nn
+% ,\seq_gput_right:cV
+% ,\seq_gput_left:cV
+% ,\seq_if_in:cVF
+% ,\seq_map_break:
+% ,\seq_map_inline:Nn
+% ,\seq_new:c
+% ,\seq_use:cn
+% ,\seq_if_exist:NTF
+% ,\seq_new:N
+% ,\seq_use:Nn
+% ,\smash
+% ,\str_if_empty:NTF
+% ,\str_if_in:NnTF
+% ,\str_if_eq:nVTF
+% ,\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_eq:NnF
+% ,\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-radiobutton} Implementation}
% \begin{macrocode}
%<*package>
@@ -398,24 +531,41 @@
\RequirePackage{l3draw}
% \end{macrocode}
% \subsection{Variables}
+% \begin{variable}
+% {
+% \l_@@_radio_value_tl
+% ,\l_@@_radio_default_tl
+% ,\l_@@_radio_value_num_int
+% ,\l_@@_radio_appearance_code_tl
+% }
+% variables to hold the value, its index numbers and the default value.
+% radio buttons can setup the appearance only after the value is known,
+% so the code is stored and executed later.
% \begin{macrocode}
-\tl_new:N \l_@@_radio_button_tl
+\tl_new:N \l_@@_radio_value_tl
\tl_new:N \l_@@_radio_default_tl
-\int_new:N \l_@@_radio_button_num_int
+\int_new:N \l_@@_radio_value_num_int
\tl_new:N \l_@@_radio_appearance_code_tl
% \end{macrocode}
-% \subsection{Messages}
-% \begin{macrocode}
-% \end{macrocode}
+% \end{variable}
+%
% \subsection{Appearances}
% The default appearances are a circle with button in it.
% Every appearance should have two versions and follow the naming
% module/\meta{name}/Yes and module/\meta{name}/Off.
-% \begin{macro}{@@/radio/default_appearances:}
-% This defines the standard appearance. It is setup at the first
+%
+% \begin{macro}
+% {
+% \@@_radio_default_appearances:,
+% pdffield/radio/default/Yes,
+% pdffield/radio/default/Off,
+% pdffield/radio/defaultdown/Yes,
+% pdffield/radio/defaultdown/Off
+% }
+% This defines the standard appearances. They are setup at the first
% use of a radiobutton.
% \begin{macrocode}
-\cs_new_protected:cn {@@/radio/default_appearances:}
+\cs_new_protected:Npn \@@_radio_default_appearances:
{
\pdffield_appearance:nn {pdffield/radio/default/Yes}
{
@@ -456,13 +606,14 @@
\draw_path_use_clear:n { fill }
\draw_end:
}
- \cs_gset_eq:cN {@@/radio/default_appearances:} \prg_do_nothing:
+ \cs_gset_eq:NN \@@_radio_default_appearances: \prg_do_nothing:
}
% \end{macrocode}
% \end{macro}
%
%\subsection{Creating the field}
-% A field should be created if the name doesn't exist
+% A field should be created if the name doesn't exist yet
+% \begin{macro}{\@@_radio_field:n}
% \begin{macrocode}
\cs_new_protected:Npn \@@_radio_field:n #1 %name
{
@@ -501,17 +652,23 @@
}
\cs_generate_variant:Nn \@@_radio_field:n {V}
% \end{macrocode}
+% \end{macro}
+%
% \subsection{Assembling the radio}
-% we use two arguments to separate name, label, default from the rest.
+%
% \begin{macro}{\@@_radio:n}
+% The argument are key-val settings.
+% At first we map the handlers. To setup the appearance we need the
+% Opt array, so the appearance handler only stores the code.
% \begin{macrocode}
\cs_new_protected:Npn \@@_radio:n #1
{
\group_begin:
\cs_set_eq:NN\@@_appearance_handler:nnn \@@_radio_appearance_handler:nnn
+ \cs_set_eq:NN\@@_value_handler:n \@@_radio_value_handler:n
+ \cs_set_eq:NN\@@_default_handler:n \@@_radio_default_handler:n
% \end{macrocode}
-% Setting up the defaults. To setup the appearance we need the
-% Opt array, so the appearance handler only stores the code
+% Setting up the defaults.
% \begin{macrocode}
\tl_set:Nn\l_@@_radio_appearance_code_tl{}
\keys_set:nn {pdffield}
@@ -541,26 +698,26 @@
% \end{macrocode}
% Retrieve the number for the label
% \begin{macrocode}
- \seq_if_in:cVF { g_@@_radio_opt_ \l_@@_fieldID_tl _seq }\l_@@_radio_button_tl
+ \seq_if_in:cVF { g_@@_radio_opt_ \l_@@_fieldID_tl _seq }\l_@@_radio_value_tl
{
- \seq_gput_right:cV { g_@@_radio_opt_ \l_@@_fieldID_tl _seq }\l_@@_radio_button_tl
+ \seq_gput_right:cV { g_@@_radio_opt_ \l_@@_fieldID_tl _seq }\l_@@_radio_value_tl
}
- \int_zero:N \l_@@_radio_button_num_int
+ \int_zero:N \l_@@_radio_value_num_int
\exp_args:Nc
\seq_map_inline:Nn { g_@@_radio_opt_ \l_@@_fieldID_tl _seq }
{
- \str_if_eq:nVTF { ##1 } \l_@@_radio_button_tl
+ \str_if_eq:nVTF { ##1 } \l_@@_radio_value_tl
{
\seq_map_break:
}
{
- \int_incr:N \l_@@_radio_button_num_int
+ \int_incr:N \l_@@_radio_value_num_int
}
}
% \end{macrocode}
% Annotations with the default value are set to on, the rest to off
% \begin{macrocode}
- \int_compare:nNnTF { \l_@@_radio_button_num_int } = 0
+ \int_compare:nNnTF { \l_@@_radio_value_num_int } = 0
{ \pdfannot_dict_put:nnx {widget}{AS}{/0} }
{ \pdfannot_dict_put:nnx {widget}{AS}{/Off} }
% \end{macrocode}
@@ -568,11 +725,11 @@
% \begin{macrocode}
\tl_if_empty:NT\l_@@_radio_appearance_code_tl
{
- \use:c {@@/radio/default_appearances:}
+ \@@_radio_default_appearances:
\keys_set:nn {pdffield}
{
appearance = pdffield/radio/default,
- down-appearance = pdffield/radio/default,
+ down-appearance = pdffield/radio/defaultdown,
}
}
\l_@@_radio_appearance_code_tl
@@ -582,36 +739,37 @@
% \end{macrocode}
% \end{macro}
%
-% \subsection{Keys}
+% \subsection{Keys and handlers}
% Most keys are inherited simply the ones from the generic field and annot keys.
-% The label keys sets the export value. default the button which is checked on.
-% It is in the annot group, so that it can be set after the label.
+% We define a group key, as the name is better.
+% The value key sets the export value. default the button which is checked on.
+% At first the two handlers
+% \begin{macro}{\@@_radio_value_handler:n,\@@_radio_default_handler:n}
% \begin{macrocode}
-\keys_define:nn { pdffield }
- {
- ,radiogroup .meta:n = {T=#1}
- ,choice .code:n =
- {
- \pdf_string_from_unicode:nnN {utf8/string}{#1}\l_@@_radio_button_tl
- }
- ,radiodefault .code:n =
- {
- \pdf_string_from_unicode:nnN {utf8/string}{#1}\l_@@_radio_default_tl
- }
- }
+\cs_new_protected:Npn \@@_radio_value_handler:n #1
+ {
+ \pdf_string_from_unicode:nnN {utf8/string}{#1}\l_@@_radio_value_tl
+ }
+\cs_new_protected:Npn \@@_radio_default_handler:n #1
+ {
+ \pdf_string_from_unicode:nnN {utf8/string}{#1}\l_@@_radio_default_tl
+ }
% \end{macrocode}
-% And a key to set a dedicated field ID
+% \end{macro}
+%
+% \begin{macro}{group}
% \begin{macrocode}
\keys_define:nn { pdffield }
{
- fieldID .tl_set:N = \l_@@_fieldID_tl
+ group .meta:n = {T=#1}
}
% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\@@_radio_appearance_handler:nnn}
% The handler for the appearances stores only the code
% as it must be executed rather late.
% \begin{macrocode}
-
\cs_new_protected:Npn \@@_radio_appearance_handler:nnn #1 #2 #3 %name, type, text
{
\tl_put_right:Nn \l_@@_radio_appearance_code_tl
@@ -621,7 +779,7 @@
\pdf_object_unnamed_write:nx
{dict}
{
- /\int_use:N \l_@@_radio_button_num_int
+ /\int_use:N \l_@@_radio_value_num_int
\c_space_tl \pdfxform_ref:n { #1/Yes}
/Off ~ \pdfxform_ref:n { #1/Off}
}
@@ -637,7 +795,7 @@
%
% \end{macro}
%
-% \subsection{user commands}
+% \subsection{User commands}
% \begin{macro}{\pdffield_radio:n}
% \begin{macrocode}
\cs_set_eq:NN \pdffield_radio:n \@@_radio:n
@@ -645,3 +803,4 @@
% \end{macrocode}
% \end{macro}
%\end{implementation}
+% \PrintIndex
diff --git a/l3pdffield-textfield.dtx b/l3pdffield-textfield.dtx
index 85f3f09..9df309c 100644
--- a/l3pdffield-textfield.dtx
+++ b/l3pdffield-textfield.dtx
@@ -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}
@@ -472,35 +477,39 @@
%<@@=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:Npn {\@@_textfield_default_appearances:}
+\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:NN \@@_textfield_default_appearances: \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
{
@@ -512,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\@@_V_handler:nN \@@_textfield_V_handler:nN
- \@@_textfield_default_appearances:
+ \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}
{
@@ -535,9 +549,10 @@
depth = \fp_eval:n {0.3*\f at 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?
@@ -555,6 +570,9 @@
% warning
}
}
+% \end{macrocode}
+% Now the postprocessing.
+% \begin{macrocode}
\keys_set:nn { pdffield }
{
,FT= Tx
@@ -572,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:
@@ -589,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}
{
@@ -608,22 +629,20 @@
,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_V_handler:nN #1#2
{
\pdf_string_from_unicode:nnN {utf8/string}{#1}#2
}
% \end{macrocode}
-%
+% \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
{
@@ -634,7 +653,8 @@
\keys_set:nn{pdffield}{DV={#1}}
}
% \end{macrocode}
-% \subsection{user commands}
+% \end{macro}
+% \subsection{User command}
% \begin{macro}{\pdffield_textfield:n}
% \begin{macrocode}
\cs_set_eq:NN \pdffield_textfield:n \@@_textfield:n
diff --git a/l3pdffield.dtx b/l3pdffield.dtx
index 0b8b973..3162cb5 100644
--- a/l3pdffield.dtx
+++ b/l3pdffield.dtx
@@ -1846,6 +1846,7 @@
}
\keys_set:nn{ pdffield / setup }{preset-checkbox={}}
\keys_set:nn{ pdffield / setup }{preset-textfield={}}
+\keys_set:nn{ pdffield / setup }{preset-radio={}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@@_style_create:nn}
More information about the latex3-commits
mailing list.