| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%% File: l3pdffield-pushbutton.dtx |
| 4 |
% |
| 5 |
% Copyright (C) 2021-2026 The LaTeX Project |
| 6 |
% |
| 7 |
% It may be distributed and/or modified under the conditions of the |
| 8 |
% LaTeX Project Public License (LPPL), either version 1.3c of this |
| 9 |
% license or (at your option) any later version. The latest version |
| 10 |
% of this license is in the file |
| 11 |
% |
| 12 |
% http://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
% This file is part of the "LaTeX PDF management bundle" (The Work in LPPL) |
| 15 |
% and all files in that bundle must be distributed together. |
| 16 |
% |
| 17 |
% ----------------------------------------------------------------------- |
| 18 |
% |
| 19 |
% The development version of the bundle can be found at |
| 20 |
% |
| 21 |
% https://github.com/latex3/pdfresources |
| 22 |
% |
| 23 |
% for those people who are interested. |
| 24 |
% |
| 25 |
%<*driver> |
| 26 |
\DocumentMetadata{} %no tagging, parent-child, no ua-2 yet, labels of widgets missing. |
| 27 |
\documentclass[full]{l3doc} |
| 28 |
%\usepackage{latex-lab-testphase-l3doc} |
| 29 |
|
| 30 |
\usepackage{array,booktabs,siunitx} |
| 31 |
\usepackage{l3pdffield,bearwear} |
| 32 |
\hypersetup{pdfauthor=The LaTeX Project, |
| 33 |
pdftitle=l3pdffield (LaTeX PDF management bundle)} |
| 34 |
\begin{document} |
| 35 |
\DocInput{\jobname.dtx} |
| 36 |
\end{document} |
| 37 |
%</driver> |
| 38 |
% \fi |
| 39 |
% \providecommand\hook[1]{\texttt{#1}} |
| 40 |
% \ExplSyntaxOn |
| 41 |
% \pdffield_appearance:nn {pdffield/bear} |
| 42 |
% { |
| 43 |
% \tikz\bear\bearwear[shirt=red,body~deco={\node[font=\tiny\bfseries,white]~at~(beartummy){Push};}]; |
| 44 |
% } |
| 45 |
% \ExplSyntaxOff |
| 46 |
% \title{^^A |
| 47 |
% The \pkg{l3pdffield-pushbutton} module\\ Commands to create pushbutton form fields ^^A |
| 48 |
% \\ \LaTeX{} PDF management bundle |
| 49 |
% } |
| 50 |
% |
| 51 |
% \author{^^A |
| 52 |
% The \LaTeX{} Project\thanks |
| 53 |
% {^^A |
| 54 |
% E-mail: |
| 55 |
% \href{mailto:[email protected]} |
| 56 |
% {[email protected]}^^A |
| 57 |
% }^^A |
| 58 |
% } |
| 59 |
% |
| 60 |
% \date{Version 0.97c, released 2026-05-26} |
| 61 |
% |
| 62 |
% \maketitle |
| 63 |
% \begin{documentation} |
| 64 |
% \section{\pkg{l3pdffield-pushbutton} Introduction} |
| 65 |
% This is the documentation for pushbutton fields, for general information about form fields |
| 66 |
% check the documentation l3pdffield. |
| 67 |
% |
| 68 |
% |
| 69 |
% |
| 70 |
% Please keep in mind |
| 71 |
% \begin{itemize} |
| 72 |
% \item Not every PDF viewer supports pushbuttons. |
| 73 |
% \item The handling can depend on settings in the PDF viewer. In adobe reader for |
| 74 |
% example I had to disable an option to avoid that it tries to create an appearance |
| 75 |
% itself |
| 76 |
% \item Standards like pdf/A disable features of form fields too |
| 77 |
% (as you typically can't change the PDF). |
| 78 |
% \item The compilations involving postscript/pdfmark (dvips with ps2pdf or dvips |
| 79 |
% with distiller) can require special setups. |
| 80 |
% \end{itemize} |
| 81 |
% \section{Pushbuttons} |
| 82 |
% Click me: |
| 83 |
% \ExplSyntaxOn |
| 84 |
% \group_begin: |
| 85 |
% \tl_set:Nn\l_tmpa_tl{app.alert('Hello!~I\'m~Bär!',3,0);} |
| 86 |
% \regex_replace_once:nnN{ä}{\x5Cu00E4}\l_tmpa_tl{} |
| 87 |
% \pdf_object_unnamed_write:ne{stream}{{}{\exp_not:o{\l_tmpa_tl}}} |
| 88 |
% \pdfannot_dict_put:nne{widget}{A}{<</S/JavaScript /JS~\pdf_object_ref_last:>>} |
| 89 |
% \pdffield_pushbutton:n{name=bear,appearance=pdffield/bear,width=23pt,height=30pt,depth=10pt} |
| 90 |
% \group_end: |
| 91 |
% \ExplSyntaxOff |
| 92 |
%^^A ps2pdf doesn't like the I\'m, need to find out the right escape. |
| 93 |
%^^A ps2pdf also requires an indirection (but distiller will probably require /Action |
| 94 |
%^^A instead of /A) |
| 95 |
%^^A \group_begin: |
| 96 |
%^^A \tl_set:Nn\l_tmpa_tl{app.alert('Hello!~Im~Bär!',3,0);} |
| 97 |
%^^A \regex_replace_once:nnN{ä}{\x5Cu00E4}\l_tmpa_tl{} |
| 98 |
%^^A \pdf_object_unnamed_write:ne{stream}{{}{\exp_not:o{\l_tmpa_tl}}} |
| 99 |
%^^A \pdf_object_unnamed_write:ne{dict}{/S/JavaScript /JS~\pdf_object_ref_last:} |
| 100 |
%^^A \pdfannot_dict_put:nne{widget}{A}{\pdf_object_ref_last:} |
| 101 |
%^^A \pdffield_pushbutton:n{name=bear,appearance=pdffield/bear,width=23pt,height=30pt,depth=10pt} |
| 102 |
%^^A \group_end:% |
| 103 |
% \bigskip |
| 104 |
% \subsection{Commands} |
| 105 |
% \begin{function}{\pdffield_pushbutton:n} |
| 106 |
% \begin{syntax} |
| 107 |
% \cs{pdffield_pushbutton:n} \Arg{key val list} |
| 108 |
% \end{syntax} |
| 109 |
% This creates a pushbutton. Unlike radio buttons and checkboxes pushbuttons |
| 110 |
% don't change their state and they don't store or represent a value. |
| 111 |
% Instead their purpose is to trigger an \emph{action}. Important |
| 112 |
% actions are for example Submit and Reset. |
| 113 |
% |
| 114 |
% Interfaces for such actions will be setup in another module later. |
| 115 |
% For now actions should be added through the widget dictionary. The following |
| 116 |
% for example setups a named action. |
| 117 |
% |
| 118 |
% \begin{verbatim} |
| 119 |
% \group_begin: |
| 120 |
% \pdfannot_dict_put:nnn {widget}{A}{<</S/Named /N/LastPage>>} |
| 121 |
% \sffamily\bfseries |
| 122 |
% \pdffield_pushbutton:n |
| 123 |
% {name=my/go, |
| 124 |
% width=4cm, |
| 125 |
% caption=go~to~last~page, |
| 126 |
% rollover-caption=click~me!} |
| 127 |
% \group_end: |
| 128 |
% \end{verbatim} |
| 129 |
% \begin{center} |
| 130 |
% \ExplSyntaxOn |
| 131 |
% \group_begin: |
| 132 |
% \pdfannot_dict_put:nnn {widget}{A}{<</S/Named /N/LastPage>>} |
| 133 |
% \sffamily\bfseries\pdffield_pushbutton:n |
| 134 |
% {name=my/go,width=4cm,caption=GO~TO~LAST~PAGE,rollover-caption=click~me!} |
| 135 |
% \group_end: |
| 136 |
% \ExplSyntaxOff |
| 137 |
% \end{center} |
| 138 |
% The list of allowed keys is described below. |
| 139 |
% The \meta{key val list} should at least set the name, without it the default name |
| 140 |
% |pushbutton| is used. |
| 141 |
% \end{function} |
| 142 |
% |
| 143 |
% \subsection{The look of the button} |
| 144 |
% Pushbuttons have no value. PDF compensates this by giving much more options to setup |
| 145 |
% the appearance. Beside the standard |AP| key there are number of settings in the |
| 146 |
% dynamic appearance dictionary |MK|. Sadly it is quite unclear how all this settings |
| 147 |
% interact (or should interact), and PDF viewers don't honor all of them. I was for |
| 148 |
% example not able to get the down appearance to show off. |
| 149 |
% |
| 150 |
% By default the code will draw (with l3draw) a button and place the caption and |
| 151 |
% rollover-caption on it. The caption will honor the surrounding font, fontsize and |
| 152 |
% the color, and will be placed on the baseline as described by the height and depth |
| 153 |
% keys. |
| 154 |
% |
| 155 |
% |
| 156 |
% |
| 157 |
% \subsection{Keys} |
| 158 |
% |
| 159 |
% The new pushbutton command accept all field and annot keys from l3pdffield. |
| 160 |
% A few keys are disabled or are forced to specific values. |
| 161 |
% The |appearance| keys have a more pushbutton specific |
| 162 |
% behaviour, other keys have other defaults than with the basic commands. |
| 163 |
% Additionally there |
| 164 |
% are a small number of keys specific to a pushbutton. |
| 165 |
% For convenience a number of important keys are documented here too, even if |
| 166 |
% they are already in the document from l3pdffield. |
| 167 |
% |
| 168 |
% Disabled keys are |
| 169 |
% \begin{itemize} |
| 170 |
% \item |V|, |DV|. As a pushbutton has no permanent state, |
| 171 |
% the keys should not be used. |
| 172 |
% \item |FT| is overwritten. |
| 173 |
% \item For pushbuttons only the field flags |ReadOnly|, |Required| and |NoExport| |
| 174 |
% make sense. |
| 175 |
% |Pushbutton| is set automatically by the code |
| 176 |
% as this is required for a pushbutton. |
| 177 |
% \end{itemize} |
| 178 |
% |
| 179 |
% \begin{function}{preset-pushbutton} |
| 180 |
% \begin{syntax} |
| 181 |
% |preset-pushbutton| = \Arg{key val list} |
| 182 |
% \end{syntax} |
| 183 |
% This allows to set default keys for a pushbutton. |
| 184 |
% \end{function} |
| 185 |
% |
| 186 |
% \begin{function}{name,T} |
| 187 |
% \begin{syntax} |
| 188 |
% |name| = \meta{partial name}\\ |
| 189 |
% |T| = \meta{partial name} |
| 190 |
% \end{syntax} |
| 191 |
% This sets the partial name of the field. The value |
| 192 |
% shouldn't contain a period, be not empty and sensibly consist of simple chars. |
| 193 |
% Additionally the value is used to create the field ID. |
| 194 |
% This means that pushbuttons with the same partial name are annotations |
| 195 |
% with the same field as parent. |
| 196 |
% The field ID is then internal and can not be used to |
| 197 |
% attach another annotation. |
| 198 |
% For explicit control of the field ID use the |fieldID| key. |
| 199 |
% \end{function} |
| 200 |
% |
| 201 |
% \begin{function}{fieldID} |
| 202 |
% \begin{syntax} |
| 203 |
% |fieldID| = \meta{field ID}\\ |
| 204 |
% \end{syntax} |
| 205 |
% \emph{For experts only!} |
| 206 |
% This allows to give the pushbutton field a specific ID. This is only useful |
| 207 |
% in the context of a larger fieldset or if you want to attach another annotation |
| 208 |
% to the field with \cs{pdffield_annot:n}. If used wrongly you can |
| 209 |
% easily create invalid fieldset. It allows you to create to fields with the |
| 210 |
% same partial name, but if you want to see both |
| 211 |
% you need to ensure that their full names are |
| 212 |
% different---for example by adding some parent fields. |
| 213 |
% \end{function} |
| 214 |
% |
| 215 |
% \begin{function}{parent} |
| 216 |
% \begin{syntax} |
| 217 |
% |parent| = \meta{field ID}\\ |
| 218 |
% \end{syntax} |
| 219 |
% This is only needed if the field should be part |
| 220 |
% of a larger fieldset. The value should be a field ID of a field created previously |
| 221 |
% with \cs{pdffield_field:nn}. |
| 222 |
% \end{function} |
| 223 |
% |
| 224 |
% \begin{function}{altname,TU} |
| 225 |
% \begin{syntax} |
| 226 |
% |altname| = \meta{string}\\ |
| 227 |
% |TU| = \meta{string}\\ |
| 228 |
% \end{syntax} |
| 229 |
% This is sets an alternative name for user interaction. |
| 230 |
% This name can only be set at the first pushbutton instance, when the field is initialized. |
| 231 |
% \end{function} |
| 232 |
% |
| 233 |
% \begin{function}{mappingname,TM} |
| 234 |
% \begin{syntax} |
| 235 |
% |mappingname| = \meta{string}\\ |
| 236 |
% |TM| = \meta{string}\\ |
| 237 |
% \end{syntax} |
| 238 |
% This is sets an alternative name for export. |
| 239 |
% This name can only be set at the first pushbutton instance, when the field is initialized. |
| 240 |
% \end{function} |
| 241 |
% |
| 242 |
% \begin{function}{width,height,depth} |
| 243 |
% \begin{syntax} |
| 244 |
% |width| = \meta{dim expression}\\ |
| 245 |
% |height| = \meta{dim expression}\\ |
| 246 |
% |depth| = \meta{dim expression} |
| 247 |
% \end{syntax} |
| 248 |
% These keys allow to set the dimensions of the pushbutton instance. |
| 249 |
% The value should be a dimension expression. By default |
| 250 |
% |width| is \qty{3}{\centi\meter}, |height| uses 1.05\cs{normalbaselineskip}, and |
| 251 |
% |depth| is 0.45\cs{normalbaselineskip}. |
| 252 |
% \end{function} |
| 253 |
% |
| 254 |
% \begin{function}{AP/N,appearance,AP/R,rollover-appearance,AP/D,down-appearance} |
| 255 |
% \begin{syntax} |
| 256 |
% |AP/N| = \meta{appearance name}\\ |
| 257 |
% |appearance| = \meta{appearance name}\\ |
| 258 |
% |AP/R| = \meta{appearance name}\\ |
| 259 |
% |rollover-appearance| = \meta{appearance name}\\ |
| 260 |
% |AP/D| = \meta{appearance name}\\ |
| 261 |
% |down-appearance| = \meta{appearance name} |
| 262 |
% \end{syntax} |
| 263 |
% This keys sets the normal appearance, the rollover appearance (when the |
| 264 |
% mouse hovers over the pushbutton) and the down appearance (when the |
| 265 |
% mouse clicks). They take as value a |
| 266 |
% \meta{appearance name} and expects that one form Xobjects |
| 267 |
% with this name has been created before. |
| 268 |
% It depends on the PDF viewer if such appearances |
| 269 |
% are shown. adobe reader for example ignores the down appearance. |
| 270 |
% \end{function} |
| 271 |
% |
| 272 |
% \begin{function}{action} |
| 273 |
% \begin{syntax} |
| 274 |
% |action| = .....\\ |
| 275 |
% \end{syntax} |
| 276 |
% This key doesn't exist yet. It will (probably) be added when a interface |
| 277 |
% for actions are added. |
| 278 |
% \end{function} |
| 279 |
% |
| 280 |
% \subsection{Using with hyperref} |
| 281 |
% The \cs{Pushbutton} command from hyperref also adds a label. Something like |
| 282 |
% this could more or less fake it. But be aware that the options are not |
| 283 |
% identical. |
| 284 |
% |
| 285 |
% \begin{verbatim} |
| 286 |
% \ExplSyntaxOn\makeatletter |
| 287 |
% \def\@PushButton[#1]#2{\LayoutPushButtonField{#2}{\pdffield_pushbutton:n {name=#2,#1}}} |
| 288 |
% \ExplSyntaxOff\makeatother |
| 289 |
% \end{verbatim} |
| 290 |
% |
| 291 |
% |
| 292 |
% \end{documentation} |
| 293 |
% |
| 294 |
% \begin{implementation} |
| 295 |
% \DoNotIndex |
| 296 |
% {\\ |
| 297 |
% ,\bitset_clear:N |
| 298 |
% ,\bitset_new:Nn |
| 299 |
% ,\bitset_set_false:Nn |
| 300 |
% ,\bitset_set_true:Nn |
| 301 |
% ,\bitset_to_arabic:N |
| 302 |
% ,\bool_new:N |
| 303 |
% ,\box_dp:N |
| 304 |
% ,\box_ht:N |
| 305 |
% ,\l_tmpa_box |
| 306 |
% ,\clist_map_inline:nn |
| 307 |
% ,\color_export:nnN |
| 308 |
% ,\color_set:nn |
| 309 |
% ,\color_set:nnn |
| 310 |
% ,\cs_new_protected:Npn |
| 311 |
% ,\cs_new_protected:cpn |
| 312 |
% ,\cs_set_eq:NN |
| 313 |
% ,\cs_gset_eq:cN |
| 314 |
% ,\cs_set_protected:Npn |
| 315 |
% ,\cs_generate_variant:Nn |
| 316 |
% ,\cs_gset_eq:NN |
| 317 |
% ,\csname |
| 318 |
% ,\dim_eval:n |
| 319 |
% ,\dim_new:N |
| 320 |
% ,\dim_set:N |
| 321 |
% ,\endcsname |
| 322 |
% ,\exp_args:Ne |
| 323 |
% ,\exp_args:Nne |
| 324 |
% ,\exp_args:Ne |
| 325 |
% ,\fboxsep |
| 326 |
% ,\group_begin: |
| 327 |
% ,\group_end: |
| 328 |
% ,\hbox_to_wd:nn |
| 329 |
% ,\hbox_set:Nn |
| 330 |
% ,\hfill |
| 331 |
% ,\hook_gput_code:nnn |
| 332 |
% ,\int_eval:n |
| 333 |
% ,\int_gincr:N |
| 334 |
% ,\int_new:N |
| 335 |
% ,\int_use:N |
| 336 |
% ,\l_keys_choice_int |
| 337 |
% ,\keys_define:nn |
| 338 |
% ,\keys_set:nn |
| 339 |
% ,\mode_leave_vertical: |
| 340 |
% ,\makebox |
| 341 |
% ,\msg_error:nnn |
| 342 |
% ,\msg_error:nnnn |
| 343 |
% ,\msg_new:nnn |
| 344 |
% ,\msg_warning:nn |
| 345 |
% ,\msg_warning:nnn |
| 346 |
% ,\msg_warning:nnnnn |
| 347 |
% ,\NeedsTeXFormat |
| 348 |
% ,\normalsize |
| 349 |
% ,\pdf_name_from_unicode_e:n |
| 350 |
% ,\pdf_object_if_exist:nTF |
| 351 |
% ,\pdf_object_if_exist:nF |
| 352 |
% ,\pdf_object_new:n |
| 353 |
% ,\pdf_object_ref:n |
| 354 |
% ,\pdf_object_ref_last: |
| 355 |
% ,\pdf_object_unnamed_write:nn |
| 356 |
% ,\pdf_object_write:nnn |
| 357 |
% ,\pdf_string_from_unicode:nnN |
| 358 |
% ,\pdfannot_box_ref_last: |
| 359 |
% ,\pdfannot_dict_put:nnn |
| 360 |
% ,\pdfannot_dict_put:nne |
| 361 |
% ,\pdfannot_dict_remove:nn |
| 362 |
% ,\pdfannot_widget_box:nnn |
| 363 |
% ,\pdfdict_if_empty:nTF |
| 364 |
% ,\pdfdict_get:nnN |
| 365 |
% ,\pdfdict_new:n |
| 366 |
% ,\pdfdict_put:nnn |
| 367 |
% ,\pdfdict_remove:nn |
| 368 |
% ,\pdfdict_use:n |
| 369 |
% ,\pdfmanagement_add:nnn |
| 370 |
% ,\pdfmeta_standard_verify:nTF |
| 371 |
% ,\pdfxform_if_exist:nTF |
| 372 |
% ,\pdfxform_new:nnn |
| 373 |
% ,\pdfxform_ref:n |
| 374 |
% ,\phantom |
| 375 |
% ,\prg_do_nothing: |
| 376 |
% ,\ProvidesExplPackage |
| 377 |
% ,\rule |
| 378 |
% ,\seq_gput_right:Nn |
| 379 |
% ,\seq_if_exist:NTF |
| 380 |
% ,\seq_new:N |
| 381 |
% ,\seq_use:Nn |
| 382 |
% ,\str_if_empty:NTF |
| 383 |
% ,\str_if_in:NnTF |
| 384 |
% ,\str_new:N |
| 385 |
% ,\strut |
| 386 |
% ,\strutbox |
| 387 |
% ,\tl_if_empty:NTF |
| 388 |
% ,\tl_if_empty:NT |
| 389 |
% ,\tl_if_empty:NF |
| 390 |
% ,\tl_put_left:Nn |
| 391 |
% ,\tl_if_empty:nTF |
| 392 |
% ,\tl_if_head_eq_charcode:nNTF |
| 393 |
% ,\tl_put_right:Nn |
| 394 |
% ,\tl_new:N |
| 395 |
% ,\tl_set:Nn |
| 396 |
% ,\tl_to_str:n |
| 397 |
% ,\use:c |
| 398 |
% } |
| 399 |
% \section{\pkg{l3pdffield-pushbutton} Implementation} |
| 400 |
% \begin{macrocode} |
| 401 |
%<*package> |
| 402 |
%<@@=pdffield> |
| 403 |
% \end{macrocode} |
| 404 |
% \subsection{Variables} |
| 405 |
% A variable to store the appearance code, and two dimensions |
| 406 |
% for the appearances. We can't use a single default |
| 407 |
% appearance, so we use a count. |
| 408 |
% \begin{variable} |
| 409 |
% { |
| 410 |
% ,\l_@@_pushbutton_appearance_code_tl |
| 411 |
% ,\l_@@_pushbutton_linewidth_dim |
| 412 |
% ,\l_@@_pushbutton_totalht_dim |
| 413 |
% ,\g_@@_pushbutton_cnt_int |
| 414 |
% } |
| 415 |
% A pushbutton can setup the appearance only after the texts are known, |
| 416 |
% so the code is stored and executed later. |
| 417 |
% \begin{macrocode} |
| 418 |
\tl_new:N \l_@@_pushbutton_appearance_code_tl |
| 419 |
\dim_new:N \l_@@_pushbutton_linewidth_dim |
| 420 |
\dim_new:N \l_@@_pushbutton_totalht_dim |
| 421 |
\int_new:N \g_@@_pushbutton_cnt_int |
| 422 |
% \end{macrocode} |
| 423 |
% \end{variable} |
| 424 |
% \subsection{Appearances} |
| 425 |
% The default appearances are a rectangular frame with some text. |
| 426 |
% |
| 427 |
% \begin{macro}[int] |
| 428 |
% { |
| 429 |
% \@@_pushbutton_default_appearances:, |
| 430 |
% pdffield/pushbutton/default-n, |
| 431 |
% pdffield/pushbutton/defaultrollover-n, |
| 432 |
% pdffield/pushbutton/defaultdown-n, |
| 433 |
% } |
| 434 |
% This defines the standard appearances. They are setup at the first |
| 435 |
% use of a pushbutton, and will adapt to the font family in use then. |
| 436 |
% \begin{macrocode} |
| 437 |
\dim_set:Nn \l_@@_pushbutton_linewidth_dim {0.4pt} |
| 438 |
\color_set:nn {pdffield/push/text}{black} |
| 439 |
\color_set:nn {pdffield/push/border}{black!95!white} |
| 440 |
\color_set:nn {pdffield/push/bordertop}{yellow!5!white} |
| 441 |
\color_set:nn {pdffield/push/borderbot}{black!50!white} |
| 442 |
\color_set:nn {pdffield/push/fill}{black!20!white} |
| 443 |
\cs_if_exist:NF \draw_set_linewidth:n |
| 444 |
{ \cs_set_eq:NN\draw_set_linewidth:n \draw_linewidth:n } |
| 445 |
\cs_new_protected:Npn \@@_pushbutton_default_appearances: |
| 446 |
{ |
| 447 |
\int_gincr:N \g_@@_pushbutton_cnt_int |
| 448 |
\exp_args:Ne |
| 449 |
\pdffield_appearance:nn {pdffield/pushbutton/default-\int_use:N \g_@@_pushbutton_cnt_int} |
| 450 |
{ |
| 451 |
\draw_begin: |
| 452 |
\color_set:nn {pdffield/push/text}{.} |
| 453 |
\dim_set:Nn \l_@@_pushbutton_totalht_dim |
| 454 |
{\l_@@_annot_ht_dim + \l_@@_annot_dp_dim} |
| 455 |
\draw_set_linewidth:n {\l_@@_pushbutton_linewidth_dim} |
| 456 |
\draw_path_rectangle_corners:nn |
| 457 |
{0.5\l_@@_pushbutton_linewidth_dim,0.5\l_@@_pushbutton_linewidth_dim} |
| 458 |
{ |
| 459 |
\l_@@_annot_wd_dim-0.5\l_@@_pushbutton_linewidth_dim, |
| 460 |
\l_@@_pushbutton_totalht_dim-0.5\l_@@_pushbutton_linewidth_dim |
| 461 |
} |
| 462 |
\color_fill:n {pdffield/push/border} |
| 463 |
\draw_path_use_clear:n { fill } |
| 464 |
\draw_path_rectangle_corners:nn |
| 465 |
{2\l_@@_pushbutton_linewidth_dim,2\l_@@_pushbutton_linewidth_dim} |
| 466 |
{ |
| 467 |
\l_@@_annot_wd_dim-2\l_@@_pushbutton_linewidth_dim, |
| 468 |
\l_@@_pushbutton_totalht_dim-2\l_@@_pushbutton_linewidth_dim |
| 469 |
} |
| 470 |
\color_fill:n {pdffield/push/bordertop} |
| 471 |
\draw_path_use_clear:n { fill } |
| 472 |
\draw_path_moveto:n |
| 473 |
{ |
| 474 |
2\l_@@_pushbutton_linewidth_dim, |
| 475 |
2\l_@@_pushbutton_linewidth_dim |
| 476 |
} |
| 477 |
\draw_path_lineto:n |
| 478 |
{5\l_@@_pushbutton_linewidth_dim,5\l_@@_pushbutton_linewidth_dim} |
| 479 |
\draw_path_lineto:n |
| 480 |
{ |
| 481 |
\l_@@_annot_wd_dim-5\l_@@_pushbutton_linewidth_dim, |
| 482 |
\l_@@_pushbutton_totalht_dim-5\l_@@_pushbutton_linewidth_dim |
| 483 |
} |
| 484 |
\draw_path_lineto:n |
| 485 |
{ |
| 486 |
\l_@@_annot_wd_dim-2\l_@@_pushbutton_linewidth_dim, |
| 487 |
\l_@@_pushbutton_totalht_dim-2\l_@@_pushbutton_linewidth_dim |
| 488 |
} |
| 489 |
\draw_path_lineto:n |
| 490 |
{ |
| 491 |
\l_@@_annot_wd_dim-2\l_@@_pushbutton_linewidth_dim, |
| 492 |
2\l_@@_pushbutton_linewidth_dim |
| 493 |
} |
| 494 |
\draw_path_close: |
| 495 |
\color_fill:n {pdffield/push/borderbot} |
| 496 |
\draw_path_use_clear:n { fill } |
| 497 |
\draw_path_rectangle_corners:nn |
| 498 |
{ |
| 499 |
1.5\l_@@_pushbutton_linewidth_dim, |
| 500 |
1.5\l_@@_pushbutton_linewidth_dim |
| 501 |
} |
| 502 |
{ |
| 503 |
\l_@@_annot_wd_dim-1.5\l_@@_pushbutton_linewidth_dim, |
| 504 |
\l_@@_pushbutton_totalht_dim-1.5\l_@@_pushbutton_linewidth_dim |
| 505 |
} |
| 506 |
\color_stroke:n {pdffield/push/border} |
| 507 |
\draw_path_use_clear:n { stroke } |
| 508 |
\draw_path_rectangle_corners:nn |
| 509 |
{4\l_@@_pushbutton_linewidth_dim,4\l_@@_pushbutton_linewidth_dim} |
| 510 |
{ |
| 511 |
\l_@@_annot_wd_dim-4\l_@@_pushbutton_linewidth_dim, |
| 512 |
\l_@@_pushbutton_totalht_dim-4\l_@@_pushbutton_linewidth_dim |
| 513 |
} |
| 514 |
\color_fill:n {pdffield/push/fill} |
| 515 |
\draw_path_use_clear:n { fill } |
| 516 |
\color_fill:n {pdffield/push/text} |
| 517 |
\draw_transform_shift:n |
| 518 |
{0.5 \l_@@_annot_wd_dim, \l_@@_annot_dp_dim } |
| 519 |
\hbox_set:Nn \l_tmpa_box { \makebox[0pt]{\l_@@_caption_tl} } |
| 520 |
\draw_box_use:N \l_tmpa_box |
| 521 |
\draw_end: |
| 522 |
} |
| 523 |
\exp_args:Ne |
| 524 |
\pdffield_appearance:nn {pdffield/pushbutton/defaultrollover-\int_use:N \g_@@_pushbutton_cnt_int} |
| 525 |
{ |
| 526 |
\draw_begin: |
| 527 |
\dim_set:Nn \l_@@_pushbutton_totalht_dim |
| 528 |
{\l_@@_annot_ht_dim + \l_@@_annot_dp_dim} |
| 529 |
\draw_set_linewidth:n {\l_@@_pushbutton_linewidth_dim} |
| 530 |
\draw_path_rectangle_corners:nn |
| 531 |
{0.5\l_@@_pushbutton_linewidth_dim,0.5\l_@@_pushbutton_linewidth_dim} |
| 532 |
{ |
| 533 |
\l_@@_annot_wd_dim-0.5\l_@@_pushbutton_linewidth_dim, |
| 534 |
\l_@@_pushbutton_totalht_dim-0.5\l_@@_pushbutton_linewidth_dim |
| 535 |
} |
| 536 |
\color_fill:n {pdffield/push/border} |
| 537 |
\draw_path_use_clear:n { fill } |
| 538 |
\draw_path_rectangle_corners:nn |
| 539 |
{2\l_@@_pushbutton_linewidth_dim,2\l_@@_pushbutton_linewidth_dim} |
| 540 |
{ |
| 541 |
\l_@@_annot_wd_dim-2\l_@@_pushbutton_linewidth_dim, |
| 542 |
\l_@@_pushbutton_totalht_dim-2\l_@@_pushbutton_linewidth_dim |
| 543 |
} |
| 544 |
\color_fill:n {pdffield/push/borderbot} |
| 545 |
\draw_path_use_clear:n { fill } |
| 546 |
\draw_path_moveto:n |
| 547 |
{ |
| 548 |
2\l_@@_pushbutton_linewidth_dim, |
| 549 |
2\l_@@_pushbutton_linewidth_dim |
| 550 |
} |
| 551 |
\draw_path_lineto:n |
| 552 |
{5\l_@@_pushbutton_linewidth_dim,5\l_@@_pushbutton_linewidth_dim} |
| 553 |
\draw_path_lineto:n |
| 554 |
{ |
| 555 |
\l_@@_annot_wd_dim-5\l_@@_pushbutton_linewidth_dim, |
| 556 |
\l_@@_pushbutton_totalht_dim-5\l_@@_pushbutton_linewidth_dim |
| 557 |
} |
| 558 |
\draw_path_lineto:n |
| 559 |
{ |
| 560 |
\l_@@_annot_wd_dim-2\l_@@_pushbutton_linewidth_dim, |
| 561 |
\l_@@_pushbutton_totalht_dim-2\l_@@_pushbutton_linewidth_dim |
| 562 |
} |
| 563 |
\draw_path_lineto:n |
| 564 |
{ |
| 565 |
\l_@@_annot_wd_dim-2\l_@@_pushbutton_linewidth_dim, |
| 566 |
2\l_@@_pushbutton_linewidth_dim |
| 567 |
} |
| 568 |
\draw_path_close: |
| 569 |
\color_fill:n {pdffield/push/bordertop} |
| 570 |
\draw_path_use_clear:n { fill } |
| 571 |
\draw_path_rectangle_corners:nn |
| 572 |
{ |
| 573 |
1.5\l_@@_pushbutton_linewidth_dim, |
| 574 |
1.5\l_@@_pushbutton_linewidth_dim |
| 575 |
} |
| 576 |
{ |
| 577 |
\l_@@_annot_wd_dim-1.5\l_@@_pushbutton_linewidth_dim, |
| 578 |
\l_@@_pushbutton_totalht_dim-1.5\l_@@_pushbutton_linewidth_dim |
| 579 |
} |
| 580 |
\color_stroke:n {pdffield/push/border} |
| 581 |
\draw_path_use_clear:n { stroke } |
| 582 |
\draw_path_rectangle_corners:nn |
| 583 |
{4\l_@@_pushbutton_linewidth_dim,4\l_@@_pushbutton_linewidth_dim} |
| 584 |
{ |
| 585 |
\l_@@_annot_wd_dim-4\l_@@_pushbutton_linewidth_dim, |
| 586 |
\l_@@_pushbutton_totalht_dim-4\l_@@_pushbutton_linewidth_dim |
| 587 |
} |
| 588 |
\color_fill:n {pdffield/push/fill} |
| 589 |
\draw_path_use_clear:n { fill } |
| 590 |
\color_fill:n {pdffield/push/text} |
| 591 |
\draw_transform_shift:n |
| 592 |
{0.5 \l_@@_annot_wd_dim, \l_@@_annot_dp_dim } |
| 593 |
\hbox_set:Nn \l_tmpa_box { \makebox[0pt]{\l_@@_rollover_caption_tl} } |
| 594 |
\draw_box_use:N \l_tmpa_box |
| 595 |
\draw_end: |
| 596 |
} |
| 597 |
\exp_args:Ne |
| 598 |
\pdffield_appearance:nn {pdffield/pushbutton/defaultdown-\int_use:N \g_@@_pushbutton_cnt_int} |
| 599 |
{ |
| 600 |
\draw_begin: |
| 601 |
\dim_set:Nn \l_@@_pushbutton_totalht_dim |
| 602 |
{\l_@@_annot_ht_dim + \l_@@_annot_dp_dim} |
| 603 |
\draw_set_linewidth:n {\l_@@_pushbutton_linewidth_dim} |
| 604 |
\draw_path_rectangle_corners:nn |
| 605 |
{0.5\l_@@_pushbutton_linewidth_dim,0.5\l_@@_pushbutton_linewidth_dim} |
| 606 |
{ |
| 607 |
\l_@@_annot_wd_dim-0.5\l_@@_pushbutton_linewidth_dim, |
| 608 |
\l_@@_pushbutton_totalht_dim-0.5\l_@@_pushbutton_linewidth_dim |
| 609 |
} |
| 610 |
\color_fill:n {pdffield/push/border} |
| 611 |
\draw_path_use_clear:n { fill } |
| 612 |
\draw_path_rectangle_corners:nn |
| 613 |
{2\l_@@_pushbutton_linewidth_dim,2\l_@@_pushbutton_linewidth_dim} |
| 614 |
{ |
| 615 |
\l_@@_annot_wd_dim-2\l_@@_pushbutton_linewidth_dim, |
| 616 |
\l_@@_pushbutton_totalht_dim-2\l_@@_pushbutton_linewidth_dim |
| 617 |
} |
| 618 |
\color_fill:n {pdffield/push/borderbot} |
| 619 |
\draw_path_use_clear:n { fill } |
| 620 |
\draw_path_moveto:n |
| 621 |
{ |
| 622 |
2\l_@@_pushbutton_linewidth_dim, |
| 623 |
2\l_@@_pushbutton_linewidth_dim |
| 624 |
} |
| 625 |
\draw_path_lineto:n |
| 626 |
{5\l_@@_pushbutton_linewidth_dim,5\l_@@_pushbutton_linewidth_dim} |
| 627 |
\draw_path_lineto:n |
| 628 |
{ |
| 629 |
\l_@@_annot_wd_dim-5\l_@@_pushbutton_linewidth_dim, |
| 630 |
\l_@@_pushbutton_totalht_dim-5\l_@@_pushbutton_linewidth_dim |
| 631 |
} |
| 632 |
\draw_path_lineto:n |
| 633 |
{ |
| 634 |
\l_@@_annot_wd_dim-2\l_@@_pushbutton_linewidth_dim, |
| 635 |
\l_@@_pushbutton_totalht_dim-2\l_@@_pushbutton_linewidth_dim |
| 636 |
} |
| 637 |
\draw_path_lineto:n |
| 638 |
{ |
| 639 |
\l_@@_annot_wd_dim-2\l_@@_pushbutton_linewidth_dim, |
| 640 |
2\l_@@_pushbutton_linewidth_dim |
| 641 |
} |
| 642 |
\draw_path_close: |
| 643 |
\color_fill:n {pdffield/push/bordertop} |
| 644 |
\draw_path_use_clear:n { fill } |
| 645 |
\draw_path_rectangle_corners:nn |
| 646 |
{ |
| 647 |
1.5\l_@@_pushbutton_linewidth_dim, |
| 648 |
1.5\l_@@_pushbutton_linewidth_dim |
| 649 |
} |
| 650 |
{ |
| 651 |
\l_@@_annot_wd_dim-1.5\l_@@_pushbutton_linewidth_dim, |
| 652 |
\l_@@_pushbutton_totalht_dim-1.5\l_@@_pushbutton_linewidth_dim |
| 653 |
} |
| 654 |
\color_stroke:n {pdffield/push/border} |
| 655 |
\draw_path_use_clear:n { stroke } |
| 656 |
\draw_path_rectangle_corners:nn |
| 657 |
{4\l_@@_pushbutton_linewidth_dim,4\l_@@_pushbutton_linewidth_dim} |
| 658 |
{ |
| 659 |
\l_@@_annot_wd_dim-4\l_@@_pushbutton_linewidth_dim, |
| 660 |
\l_@@_pushbutton_totalht_dim-4\l_@@_pushbutton_linewidth_dim |
| 661 |
} |
| 662 |
\color_fill:n {pdffield/push/fill} |
| 663 |
\draw_path_use_clear:n { fill } |
| 664 |
\color_fill:n {pdffield/push/text} |
| 665 |
\draw_transform_shift:n |
| 666 |
{0.5 \l_@@_annot_wd_dim, \l_@@_annot_dp_dim } |
| 667 |
\hbox_set:Nn \l_tmpa_box { \makebox[0pt]{\l_@@_down_caption_tl} } |
| 668 |
\draw_box_use:N \l_tmpa_box |
| 669 |
\draw_end: |
| 670 |
} |
| 671 |
} |
| 672 |
% \end{macrocode} |
| 673 |
% \end{macro} |
| 674 |
% |
| 675 |
%\subsection{Creating the field} |
| 676 |
% A field should be created if the name doesn't exist |
| 677 |
% \begin{macro}{ \@@_pushbutton_field:n } |
| 678 |
% \begin{macrocode} |
| 679 |
\cs_new_protected:Npn \@@_pushbutton_field:n #1 %name |
| 680 |
{ |
| 681 |
\pdf_object_if_exist:nF {@@/field/@@/pushbutton/#1} |
| 682 |
{ |
| 683 |
\@@_field:n { @@/pushbutton/#1 } |
| 684 |
} |
| 685 |
\keys_set:nn {pdffield}{parent={@@/pushbutton/#1}} |
| 686 |
} |
| 687 |
\cs_generate_variant:Nn \@@_pushbutton_field:n {V} |
| 688 |
% \end{macrocode} |
| 689 |
% \end{macro} |
| 690 |
% \subsection{Assembling the Pushbutton} |
| 691 |
% |
| 692 |
% \begin{macro}{\@@_pushbutton:n} |
| 693 |
% \begin{macrocode} |
| 694 |
\cs_new_protected:Npn \@@_pushbutton:n #1 |
| 695 |
{ |
| 696 |
\group_begin: |
| 697 |
\tl_set:Nn\l_@@_pushbutton_appearance_code_tl{} |
| 698 |
\cs_set_eq:NN\@@_appearance_handler:nnn \@@_pushbutton_appearance_handler:nnn |
| 699 |
% \end{macrocode} |
| 700 |
% Setting up the defaults. |
| 701 |
% \begin{macrocode} |
| 702 |
\keys_set:nn {pdffield} |
| 703 |
{ |
| 704 |
fieldID=, |
| 705 |
name=pushbutton, |
| 706 |
width = 3cm, |
| 707 |
height = 1.05\normalbaselineskip, |
| 708 |
depth = 0.45\normalbaselineskip, |
| 709 |
} |
| 710 |
% \end{macrocode} |
| 711 |
% Value keys should be undefined. |
| 712 |
% \begin{macrocode} |
| 713 |
\keys_set:nn { pdffield }{@@/preset/pushbutton,#1} |
| 714 |
\keys_set:nn { pdffield } |
| 715 |
{ |
| 716 |
,V= |
| 717 |
,DV= |
| 718 |
,setFf={Pushbutton} |
| 719 |
,FT= Btn |
| 720 |
} |
| 721 |
\tl_if_empty:NT\l_@@_fieldID_tl |
| 722 |
{ |
| 723 |
\pdfdict_get:nnN {l_@@/field}{T}\l_@@_fieldID_tl |
| 724 |
\tl_put_left:Nn \l_@@_fieldID_tl {@@/pushbutton/} |
| 725 |
} |
| 726 |
\tl_if_empty:NT\l_@@_pushbutton_appearance_code_tl |
| 727 |
{ |
| 728 |
\@@_pushbutton_default_appearances: |
| 729 |
\exp_args:Nne |
| 730 |
\keys_set:nn {pdffield} |
| 731 |
{ |
| 732 |
appearance = pdffield/pushbutton/default-\int_eval:n{ \g_@@_pushbutton_cnt_int}, |
| 733 |
down-appearance = pdffield/pushbutton/defaultdown-\int_eval:n{ \g_@@_pushbutton_cnt_int}, |
| 734 |
rollover-appearance = pdffield/pushbutton/defaultrollover-\int_eval:n{ \g_@@_pushbutton_cnt_int}, |
| 735 |
} |
| 736 |
} |
| 737 |
\l_@@_pushbutton_appearance_code_tl |
| 738 |
\@@_pushbutton_field:V\l_@@_fieldID_tl |
| 739 |
\@@_annot: |
| 740 |
\group_end: |
| 741 |
} |
| 742 |
% \end{macrocode} |
| 743 |
% \end{macro} |
| 744 |
% |
| 745 |
% \subsection{Keys} |
| 746 |
% Most keys are inherited from the generic field and annot keys. |
| 747 |
% We only need to handle the appearance in a special way. |
| 748 |
% |
| 749 |
% \begin{macro}{\@@_pushbutton_appearance_handler:nnn} |
| 750 |
% \begin{macrocode} |
| 751 |
\cs_new_protected:Npn \@@_pushbutton_appearance_handler:nnn #1 #2 #3 %name, type, text |
| 752 |
{ |
| 753 |
\tl_put_right:Nn \l_@@_pushbutton_appearance_code_tl |
| 754 |
{ |
| 755 |
\pdfxform_if_exist:nTF { #1 } |
| 756 |
{ |
| 757 |
\pdfannot_dict_put:nne {widget/AP}{#2}{\pdfxform_ref:n{#1}} |
| 758 |
} |
| 759 |
{ |
| 760 |
\msg_error:nnnn{pdffield}{appearance-missing}{#1}{#3} |
| 761 |
} |
| 762 |
} |
| 763 |
} |
| 764 |
% \end{macrocode} |
| 765 |
% \end{macro} |
| 766 |
% |
| 767 |
% \subsection{user commands} |
| 768 |
% \begin{macro}{\pdffield_pushbutton:n} |
| 769 |
% \begin{macrocode} |
| 770 |
\cs_set_eq:NN \pdffield_pushbutton:n \@@_pushbutton:n |
| 771 |
%</package> |
| 772 |
% \end{macrocode} |
| 773 |
% \end{macro} |
| 774 |
%\end{implementation} |
| 775 |
|
| 776 |
% \PrintIndex |