[latex3-commits] [git/LaTeX3-latex3-pdfresources] radiobuttons: working on pushbutton appearance (80ddaaa)
Ulrike Fischer
fischer at troubleshooting-tex.de
Mon May 31 00:21:42 CEST 2021
Repository : https://github.com/latex3/pdfresources
On branch : radiobuttons
Link : https://github.com/latex3/pdfresources/commit/80ddaaa1ed066098e2052346fb5ec0b464e7184f
>---------------------------------------------------------------
commit 80ddaaa1ed066098e2052346fb5ec0b464e7184f
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Mon May 31 00:21:42 2021 +0200
working on pushbutton appearance
>---------------------------------------------------------------
80ddaaa1ed066098e2052346fb5ec0b464e7184f
l3pdffield-pushbutton.dtx | 147 +++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 132 insertions(+), 15 deletions(-)
diff --git a/l3pdffield-pushbutton.dtx b/l3pdffield-pushbutton.dtx
index 79fa90a..307c775 100644
--- a/l3pdffield-pushbutton.dtx
+++ b/l3pdffield-pushbutton.dtx
@@ -358,7 +358,22 @@
%<@@=pdffield>
% \end{macrocode}
% \subsection{Variables}
-% There are no specific variables.
+% \begin{variable}
+% {
+% ,\l_@@_pushbutton_caption_tl
+% ,\l_@@_pushbutton_rollover_caption_tl
+% ,\l_@@_pushbutton_down_caption_tl
+% ,\l_@@_pushbutton_appearance_code_tl
+% }
+% a pushbutton can setup the appearance only after the texts are known,
+% so the code is stored and executed later.
+% \begin{macrocode}
+\tl_new:N \l_@@_pushbutton_caption_tl
+\tl_new:N \l_@@_pushbutton_rollover_caption_tl
+\tl_new:N \l_@@_pushbutton_down_caption_tl
+\tl_new:N \l_@@_pushbutton_appearance_code_tl
+% \end{macrocode}
+% \end{variable}
% \subsection{Messages}
% There are no specific messages.
% \subsection{Appearances}
@@ -366,7 +381,7 @@
%
% \begin{macro}
% {
-% \@@_pushbutton_default_appearances:n,
+% \@@_pushbutton_default_appearances:,
% pdffield/pushbutton/defaultN,
% pdffield/pushbutton/defaultR,
% pdffield/pushbutton/defaultD,
@@ -374,20 +389,97 @@
% This defines the standard appearance. It is setup at the first
% use of a pushbutton, and will adapt to the font family in use then.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_pushbutton_default_appearances:n #1 % text
- { \dim_show:N\l_@@_annot_wd_dim \dim_show:N\l_@@_annot_ht_dim
+\dim_new:N \l_@@_pushbutton_linewidth_dim
+\dim_set:Nn \l_@@_pushbutton_linewidth_dim {0.6pt}
+\dim_new:N \l_@@_pushbutton_totalht_dim
+\color_set:nn {pdffield/push/text}{black}
+\color_set:nn {pdffield/push/border}{black!95!white}
+\color_set:nn {pdffield/push/bordertop}{yellow!5!white}
+\color_set:nn {pdffield/push/borderbot}{black!50!white}
+\color_set:nn {pdffield/push/fill}{black!20!white}
+
+\cs_new_protected:Npn \@@_pushbutton_default_appearances:
+ {
\pdffield_appearance:nn {pdffield/pushbutton/defaultN}
{
- { \color_select:n{black!5!white}\rule{3cm}{0.5cm}
- \llap{\makebox[3cm]{\color_select:n{black}PUSH}}}
+ \draw_begin:
+ \dim_set:Nn \l_@@_pushbutton_totalht_dim
+ {\l_@@_annot_ht_dim + \l_@@_annot_dp_dim}
+ \draw_linewidth:n {\l_@@_pushbutton_linewidth_dim}
+ \draw_path_rectangle_corners:nn
+ {0.5\l_@@_pushbutton_linewidth_dim,0.5\l_@@_pushbutton_linewidth_dim}
+ {
+ \l_@@_annot_wd_dim-0.5\l_@@_pushbutton_linewidth_dim,
+ \l_@@_pushbutton_totalht_dim-0.5\l_@@_pushbutton_linewidth_dim
+ }
+ \color_fill:n {@@/push/border}
+ \draw_path_use_clear:n { fill }
+ \draw_path_rectangle_corners:nn
+ {2\l_@@_pushbutton_linewidth_dim,2\l_@@_pushbutton_linewidth_dim}
+ {
+ \l_@@_annot_wd_dim-2\l_@@_pushbutton_linewidth_dim,
+ \l_@@_pushbutton_totalht_dim-2\l_@@_pushbutton_linewidth_dim
+ }
+ \color_fill:n {@@/push/bordertop}
+ \draw_path_use_clear:n { fill }
+ \draw_path_moveto:n
+ {
+ 2\l_@@_pushbutton_linewidth_dim,
+ 2\l_@@_pushbutton_linewidth_dim
+ }
+ \draw_path_lineto:n
+ {5\l_@@_pushbutton_linewidth_dim,5\l_@@_pushbutton_linewidth_dim}
+ \draw_path_lineto:n
+ {
+ \l_@@_annot_wd_dim-5\l_@@_pushbutton_linewidth_dim,
+ \l_@@_pushbutton_totalht_dim-5\l_@@_pushbutton_linewidth_dim
+ }
+ \draw_path_lineto:n
+ {
+ \l_@@_annot_wd_dim-2\l_@@_pushbutton_linewidth_dim,
+ \l_@@_pushbutton_totalht_dim-2\l_@@_pushbutton_linewidth_dim
+ }
+ \draw_path_lineto:n
+ {
+ \l_@@_annot_wd_dim-2\l_@@_pushbutton_linewidth_dim,
+ 2\l_@@_pushbutton_linewidth_dim
+ }
+ \draw_path_close:
+ \color_fill:n {@@/push/borderbot}
+ \draw_path_use_clear:n { fill }
+ \draw_path_rectangle_corners:nn
+ {
+ 1.5\l_@@_pushbutton_linewidth_dim,
+ 1.5\l_@@_pushbutton_linewidth_dim
+ }
+ {
+ \l_@@_annot_wd_dim-1.5\l_@@_pushbutton_linewidth_dim,
+ \l_@@_pushbutton_totalht_dim-1.5\l_@@_pushbutton_linewidth_dim
+ }
+ \color_stroke:n {@@/push/border}
+ \draw_path_use_clear:n { stroke }
+ \draw_path_rectangle_corners:nn
+ {4\l_@@_pushbutton_linewidth_dim,4\l_@@_pushbutton_linewidth_dim}
+ {
+ \l_@@_annot_wd_dim-4\l_@@_pushbutton_linewidth_dim,
+ \l_@@_pushbutton_totalht_dim-4\l_@@_pushbutton_linewidth_dim
+ }
+ \color_fill:n {fill}
+ \draw_path_use_clear:n { fill }
+ \color_fill:n {@@/push/textcolor}
+ \draw_transform_shift:n
+ {0.5 \l_@@_annot_wd_dim, 0.3\l_@@_pushbutton_totalht_dim}
+ \hbox_set:Nn \l_tmpa_box { \makebox[0pt]{\l_@@_pushbutton_caption_tl} }
+ \draw_box_use:N \l_tmpa_box
+ \draw_end:
}
- \pdffield_appearance:nn {pdffield/pushbutton/defaultR}
+ \pdffield_appearance:nn {pdffield/pushbutton/defaultrollover}
{
- { \color_select:n{yellow!50!white}\rule{\paperwidth}{\paperheight} }
+ { \color_select:n{black!50!white}\rule{\paperwidth}{\paperheight} }
}
- \pdffield_appearance:nn {pdffield/pushbutton/defaultD}
+ \pdffield_appearance:nn {pdffield/pushbutton/defaultdown}
{
- { \color_select:n{blue}\rule{\paperwidth}{\paperheight} }
+ { \color_select:n{black}\rule{\paperwidth}{\paperheight} }
}
\cs_gset_eq:NN \@@_pushbutton_default_appearances:n \prg_do_nothing:
}
@@ -416,8 +508,8 @@
\cs_new_protected:Npn \@@_pushbutton:n #1
{
\group_begin:
- \@@_pushbutton_default_appearances:n {TEXT}
- % \cs_set_eq:NN\@@_appearance_handler:nnn \@@_checkbox_appearance_handler:nnn
+ \tl_set:Nn\l_@@_pushbutton_appearance_code_tl{}
+ \cs_set_eq:NN\@@_appearance_handler:nnn \@@_pushbutton_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}
@@ -427,9 +519,6 @@
{
fieldID=,
name=pushbutton,
- appearance = pdffield/pushbutton/defaultN,
- down-appearance = pdffield/pushbutton/defaultD,
- rollover-appearance = pdffield/pushbutton/defaultR,
width = 3cm,
height = \normalbaselineskip,
}
@@ -449,6 +538,16 @@
\pdfdict_get:nnN {l_@@/field}{T}\l_@@_fieldID_tl
\tl_put_left:Nn \l_@@_fieldID_tl {@@/pushbutton/}
}
+ \tl_if_empty:NT\l_@@_pushbutton_appearance_code_tl
+ {
+ \@@_radio_default_appearances:
+ \keys_set:nn {pdffield}
+ {
+ appearance = pdffield/pushbutton/default,
+ down-appearance = pdffield/radio/defaultdown,
+ rollover-appearance = pdffield/radio/defaultrollover,
+ }
+ }
\@@_pushbutton_field:V\l_@@_fieldID_tl
\@@_annot:
\group_end:
@@ -475,6 +574,24 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@@_pushbutton_appearance_handler:nnn}
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_pushbutton_appearance_handler:nnn #1 #2 #3 %name, type, text
+ {
+ \tl_put_right:Nn \l_@@_pushbutton_appearance_code_tl
+ {
+ \pdfxform_if_exist:nTF { #1 }
+ {
+ \pdfannot_dict_put:nnx {widget/AP}{#2}{\pdf_xform_ref:n{#1}}
+ }
+ {
+ \msg_error:nnnn{pdffield}{appearance-missing}{#1}{#3}
+ }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \subsection{user commands}
% \begin{macro}{\pdffield_pushbutton:n}
% \begin{macrocode}
More information about the latex3-commits
mailing list.