diff options
author | Karl Berry <karl@freefriends.org> | 2017-03-20 23:05:30 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-03-20 23:05:30 +0000 |
commit | 3ab396090f30955eb1ece56905cb5bda36e7b22b (patch) | |
tree | 8accb43050d4b3f1b19306486e8266b5cdcaf789 /Master/texmf-dist | |
parent | 9629eb95a35b6c79d6d31ff27653d3a006b25b9b (diff) |
grayhints (20mar17)
git-svn-id: svn://tug.org/texlive/trunk@43561 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/grayhints/README.md | 27 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/grayhints/doc/grayhints_man.pdf | bin | 0 -> 415594 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/grayhints/doc/grayhints_man.tex | 469 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/grayhints/examples/gh-eforms.pdf | bin | 0 -> 37442 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/grayhints/examples/gh-eforms.tex | 126 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/grayhints/examples/gh-hyperref.tex | 131 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/grayhints/grayhints.dtx | 348 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/grayhints/grayhints.ins | 58 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/grayhints/grayhints.sty | 119 |
9 files changed, 1278 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/grayhints/README.md b/Master/texmf-dist/doc/latex/grayhints/README.md new file mode 100644 index 00000000000..5bda721fde6 --- /dev/null +++ b/Master/texmf-dist/doc/latex/grayhints/README.md @@ -0,0 +1,27 @@ +The graphicxbox Package +Author: D. P. Story +Dated: 2017-03-02 + +This package provides JavaScript code snippets to create 'gray hints'. Gray +hints, as I term them, are text that appears initially in a text field that +gives a short hint as to what the contents of the text field should be; for +example, a text field might contain the hint 'First Name', or a date field +might read 'yyyy/mm/dd'. As soon as the field comes into focus, the hint +disappears. It reappears when the field is blurred and the user did not enter +any text into the field. + +Dependent packages: + (1) eforms (2017/02/27) to use the field fields of eforms. + (2) insdljs (2017/03/02) a minimal requirement when using form fields defined + by hyperref when calculation fields are used. + (3) Hyperref form fields may be used without eforms or insdljs, but the gray + hints for calculation fields will not appear. + +Package works for dvips/Distiller, pdflatex, lualatex, and xelatex. + +Enjoy! + +Now, I must get back to my retirement. + +dps +dpstory at uakron dot edu diff --git a/Master/texmf-dist/doc/latex/grayhints/doc/grayhints_man.pdf b/Master/texmf-dist/doc/latex/grayhints/doc/grayhints_man.pdf Binary files differnew file mode 100644 index 00000000000..2113116e40f --- /dev/null +++ b/Master/texmf-dist/doc/latex/grayhints/doc/grayhints_man.pdf diff --git a/Master/texmf-dist/doc/latex/grayhints/doc/grayhints_man.tex b/Master/texmf-dist/doc/latex/grayhints/doc/grayhints_man.tex new file mode 100644 index 00000000000..c5ff2503be1 --- /dev/null +++ b/Master/texmf-dist/doc/latex/grayhints/doc/grayhints_man.tex @@ -0,0 +1,469 @@ +\documentclass{article} +\usepackage[fleqn]{amsmath} +\usepackage[ + web={centertitlepage,designv,forcolorpaper,tight*,latextoc,pro}, + eforms,aebxmp +]{aeb_pro} +\usepackage{grayhints}\previewOff +\usepackage{graphicx,array,fancyvrb} +\usepackage{aeb_mlink} +%\usepackage{myriadpro} +%\usepackage{calibri} +\usepackage[altbullet]{lucidbry} + +\def\hardspace{{\fontfamily{cmtt}\selectfont\symbol{32}}} + +\usepackage{acroman} +\usepackage[active]{srcltx} + +\urlstyle{tt} +\renewcommand\LayoutTextField[2]{#2} + + +%\def\tutpath{doc/tutorial} +%\def\tutpathi{tutorial} +%\def\expath{../examples} + +\def\STRUT{\rule{0pt}{14pt}} + + +\DeclareDocInfo +{ + university={\AcroTeX.Net}, + title={The \textsf{grayhints} Package}, + author={D. P. Story}, + email={dpstory@acrotex.net}, + subject=Documentation for the grayhints, + talksite={\url{www.acrotex.net}}, + version={v1.0, 2017/03/02}, + Keywords={LaTeX, form field, hints, AcroTeX}, + copyrightStatus=True, + copyrightNotice={Copyright (C) \the\year, D. P. Story}, + copyrightInfoURL={http://www.acrotex.net} +} + +\universityLayout{fontsize=Large} +\titleLayout{fontsize=LARGE} +\authorLayout{fontsize=Large} +\tocLayout{fontsize=Large,color=aeb} +\sectionLayout{indent=-62.5pt,fontsize=large,color=aeb} +\subsectionLayout{indent=-31.25pt,color=aeb} +\subsubsectionLayout{indent=0pt,color=aeb} +\subsubDefaultDing{\texorpdfstring{$\bullet$}{\textrm\textbullet}} + +\chngDocObjectTo{\newDO}{doc} +\begin{docassembly} +var titleOfManual="The grayhints Package"; +var manualfilename="Manual_BG_Print_grayhints.pdf"; +var manualtemplate="Manual_BG_Brown.pdf"; // Blue, Green, Brown +var _pathToBlank="C:/Users/Public/Documents/ManualBGs/"+manualtemplate; +var doc; +var buildIt=false; +if ( buildIt ) { + console.println("Creating new " + manualfilename + " file."); + doc = \appopenDoc({cPath: _pathToBlank, bHidden: true}); + var _path=this.path; + var pos=_path.lastIndexOf("/"); + _path=_path.substring(0,pos)+"/"+manualfilename; + \docSaveAs\newDO ({ cPath: _path }); + doc.closeDoc(); + doc = \appopenDoc({cPath: manualfilename, oDoc:this, bHidden: true}); + f=doc.getField("ManualTitle"); + f.value=titleOfManual; + doc.flattenPages(); + \docSaveAs\newDO({ cPath: manualfilename }); + doc.closeDoc(); +} else { + console.println("Using the current "+manualfilename+" file."); +} +var _path=this.path; +var pos=_path.lastIndexOf("/"); +_path=_path.substring(0,pos)+"/"+manualfilename; +\addWatermarkFromFile({ + bOnTop:false, + bOnPrint:false, + cDIPath:_path +}); +\executeSave(); +\end{docassembly} + + +\begin{document} + +\maketitle + +\selectColors{linkColor=black} +\tableofcontents +\selectColors{linkColor=webgreen} + + +\section{Introduction} + +We often see in HTML pages or in compiled executable applications, form +fields (text fields, input fields) that require user input. The untouched +field has text within it informing the user of the nature of the data to be +entered into the field. This, usually, grayed hint immediately disappears +when the user focus the cursor on the field. We illustrate the concept with +an example or two. +\begin{quote} + \textField[\textColor{\matchGray} + \TU{Enter your first name so I can get to know you better} + \AA{\AAFormat{\FmtToGray{First Name}} + \AAKeystroke{\KeyToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}} + }]{NameFirst1}{2in}{11bp}\vcgBdry[\medskipamount] + \textField[\textColor{\matchGray} + \TU{Enter your favorite date, in the indicated format} + \AA{\AAKeystroke{AFDate_KeystrokeEx("yyyy/mm/dd");\r\KeyToGray} + \AAFormat{AFDate_FormatEx("yyyy/mm/dd");\r\FmtToGray{yyyy/mm/dd}} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}} + }]{DateField1}{1in}{11bp}\cgBdry[1.5em] + \pushButton[\CA{Reset} + \TU{Press to clear to clear all fields.} + \A{\JS{this.resetForm();}}]{reset}{}{11bp} +\end{quote} + Of course, the usual tooltips may also be provided.\medskip\noindent + + It is not natural for Adobe form fields to do this, it takes some support + code for it to work properly; scripts for the Keystroke, Format, OnFocus, + and OnBlur events are needed. + +\section{Package options} + +Without passing any options, the \pkg{eforms} package of \AEB, dated +2017/02/27, is required and a document JavaScript function +\texttt{AllowCalc()} is automatically embedded in the document; however there +are options to modify this default setup. +\begin{description} + \item[\texttt{usehyforms}] By default, this package requires + \pkg{eforms}, dated 2017/02/27; however, if you are more + comfortable using the form fields of \pkg{hyperref}, specify the + option \texttt{usehyforms}.\footnote{\pkg{eforms} and + \pkg{hyperref} form fields can be used in one document.} When + \texttt{usehyforms} is specified, \pkg{insdljs} dated 2017/03/02 or + later is required. This requirement is to support the + \texttt{usealtadobe}, discussed next. + \item[\texttt{nocalcs}] If this option is taken, the document + JavaScript function \texttt{AllowCalc()} is not embedded in the document. The + implications are that you are not using any calculation fields. + \item[\texttt{usealtadobe}] If you have the \app{Acrobat} application, + you can edit form fields. When you write custom formatting scripts + (as does this package) using Adobe's built-in functions, such as + \texttt{AFNumber\_Keystroke} and \texttt{AFNumber\_Format}, the + user-interface for editing the custom script is not available. The + \texttt{usealtadobe} option is passed to \pkg{insldjs}; + \pkg{insdljs}, in turn, inputs alternate names for the common + \app{Adobe} built-ins. Refer to + \hyperref[s:altadobfuncs]{Section~\ref*{s:altadobfuncs}} for more + information. + + \item[\texttt{nodljs}] When this option is specified, there are no + requirements placed on this package; that is, neither \pkg{eforms} + nor \pkg{insdljs} are required. +\end{description} + +\paragraph*{Demo file:} \texttt{gh-eforms.tex,\;gh-hyperref.tex}. The latter file +uses the \opt{usehyforms} option (and \pkg{hyperref} form fields), while the former uses the \pkg{eforms} package. + +\section{Creating a form field with a gray hint} + +In this documentation, we use \pkg{eforms} form fields to illustrate concepts, the demonstration file +\texttt{gh-hyperref.tex} has the form field markup for the case of \pkg{hyperref} forms. + +There are two cases: (1) an ordinary variable text form field (this includes +text fields and editable combo boxes) with no calculate script; (2) same as +(1), but the field has a calculate script. + +\subsection{Variable text field, no calculate script} + +When there is no calculate script, to obtain a gray hint, it is necessary to +supply scripts for the Format, Keystroke, OnFocus, and OnBlur events. The +scripts are all defined in the \pkg{grayhints} package. In addition, the +color of the text in the text field must be appropriate. We illustrate, +\begin{Verbatim}[xleftmargin=\parindent,commandchars=!(),numbers=left,numbersep=3bp,fontsize=\small] +\textField[!color(gray)\TU{Enter your first name so I can get to know you better} + \textColor{\matchGray}\AA{% + \AAKeystroke{\KeyToGray} + \AAFormat{\FmtToGray{First Name}} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}} +}]{NameFirst}{2in}{11bp} +\end{Verbatim} +By default, the text color is black and the grayed hint text is light gray. +The tool tip (\cs{TU}) is grayed out, as it is optional. In line~(2) we match +the color for the text to the gray color using the command \cs{matchGray} of +\pkg{grayhints}. Within the argument of \cs{AA}, the \cs{AAFormat}, +\cs{AAKeystroke}, \cs{AAOnFocus}, and \cs{AAOnBlur} scripts are inserted. +\begin{quote} +\begin{description} + \item{Keystroke Script:} In line~(3), \cs{KeyToGray} is placed within + the argument of \cs{AAKeystroke}. This script changes the color + of the text to gray when the field is empty. + \item{Format Script:} The script snippet \cs{FmtToGray} takes a + single argument, which is the text of the hint. In line~(4) + the hint is `First Name'. + \item{OnFocus Script:} The code snippet \cs{FocusToBlack} is inserted + into the argument of \cs{OnFocus}, as seen in line~(5). When the + field comes into focus, this script changes the color to the + normal color (usually black). + \item{OnBlur Script:} In line~(6), the \cs{BlurToBlack} script is + placed within the argument of \cs{OnBlur}, in the manner + indicated. When the field loses focus (is blurred), the script + changes the color of text to gray if the field is empty or to + its normal color (usually black), otherwise. +\end{description} +\end{quote} +The \pkg{hyperref} form field counterpart to the above example is, +\begin{Verbatim}[xleftmargin=\parindent,commandchars=!(),numbers=left,numbersep=3bp,fontsize=\small] +\TextField[name={NameFirst}, + height=11bp,width=2in, + color=\matchGray, + keystroke=\KeyToGray, + format=\FmtToGray{First Name}, + onfocus=\FocusToBlack, + onblur=\BlurToBlack]{} +\end{Verbatim} +The two fields appear side-by-side: +\begin{quote} +\textField[\autoCenter{n}\textColor{\matchGray} + \TU{Enter your first name so I can get to know you better} + \AA{\AAFormat{\FmtToGray{First Name}} + \AAKeystroke{\KeyToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}} +}]{NameFirst2}{2in}{11bp}\cgBdry[0.5em] +\TextField[name={NameFirst3}, + height=11bp,width=2in, + color=\matchGray, + keystroke=\KeyToGray, + format=\FmtToGray{First Name}, + onfocus=\FocusToBlack, + onblur=\BlurToBlack]{}\cgBdry[0.5em] +\pushButton[\CA{Reset}\autoCenter{n} + \TU{Press to clear to clear all fields.} + \A{\JS{this.resetForm();}}]{reset}{}{11bp} +\end{quote} +Both fields appear in the `default' appearance. + + +\subsection{Variable text field, with calculate script} + +If you want to make calculations based on entries in other fields, you will need +the code snippet \cs{CalcToGray} as part of your calculate script. +\begin{Verbatim}[xleftmargin=\parindent,commandchars={!~@},numbers=left,numbersep=3bp,fontsize=\small] +\textField[!color~gray@\TU{The total for first and second integers} + \textColor{\matchGray}\AA{% + \AAKeystroke{AFNumber_Keystroke(0,1,0,0,"",true);\r\KeyToGray} + \AAFormat{AFNumber_Format(0,1,0,0,"",true);\r\FmtToGray{Total}} + \AACalculate{var cArray=new Array("Integer");\r + if(AllowCalc(cArray))AFSimple_Calculate("SUM", cArray );\r + \CalcToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}}} +]{TotalNumbers}{1in}{11bp} +\end{Verbatim} +The use of \cs{r} is optional, the author uses this to format the script +within the user-interface of \app{Acrobat}. The \cs{textColor} (line~(2)), +\cs{AAOnFocus} (line~(8)), and \cs{AAOnBlur} (line~(8)) are the same as earlier presented. +Several comments are needed for the \cs{AAKeystroke}, \cs{AAFormat} and \cs{AACalculate} lines. +\begin{itemize} + \item This is a number field, so we use the built-in functions + \texttt{AFNumber\_Keystroke} and \texttt{AFNumber\_Format} provided + by the \app{Adobe Acrobat} and \app{Adobe Acrobat Reader} + distributions. In lines~(3) and~(4), the \cs{KeyToGray} and + \cs{FmtToGray} code snippets follow the built-ins.\footnote{As a general rule, + the code snippets \cs{KeyToGray}, \cs{FmtToGray}, and + \cs{CalcToGray} should inserted after any built-in functions.} + \item For the Calculate event, special techniques are used. We define + an array \texttt{cArray} (line~(5)) consisting of the names of all + the dependent fields we use to calculate the value of this field. + In line~(6), we make the calculation (\texttt{AFSimple\_Calculate}) + only if the document JavaScript function \texttt{AllowCalc(cArray)} + returns true. The function returns true only if at least one of the + fields is not empty. Following the calculation comes the code + snippet \cs{CalcToGray}; this changes the text color to gray if the + field is empty and to the normal color (usually black) otherwise. + + The function \texttt{AllowCalc()} is defined for all options except + for the \opt{nodljs} option. +\end{itemize} +Let's go to the examples. Build three fields (four actually), in the first two +enter integers, the other two fields compute their sum. +\begin{quote}\previewOff +\ding{172}\ \textField[\TU{Enter an integer} + \textColor{\matchGray}\AA{% + \AAKeystroke{AFNumber_Keystroke(0,1,0,0,"",true);\r\KeyToGray} + \AAFormat{AFNumber_Format(0,1,0,0,"",true);\r\FmtToGray{First Integer}} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}}} +]{Integer.First}{1in}{11bp}\vcgBdry[3bp] +\ding{173}\ \textField[\TU{Enter an integer} + \textColor{\matchGray}\AA{% + \AAKeystroke{AFNumber_Keystroke(0,1,0,0,"",true);\r\KeyToGray} + \AAFormat{AFNumber_Format(0,1,0,0,"",true);\r\FmtToGray{Second Integer}} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}}} +]{Integer.Second}{1in}{11bp}\vcgBdry[3bp] +\ding{174}\ \textField[\TU{The total for first and second integers} + \textColor{\matchGray}\AA{% + \AAKeystroke{AFNumber_Keystroke(0,1,0,0,"",true);\KeyToGray} + \AAFormat{AFNumber_Format(0,1,0,0,"",true);\r\FmtToGray{Total}} + \AACalculate{var cArray=new Array("Integer");\r + if (AllowCalc(cArray)) AFSimple_Calculate("SUM", cArray );\r\CalcToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}}} +]{TotalNumbers}{1in}{11bp}\vcgBdry[3bp] +\ding{175}\ \textField[\TU{The total for first and second integers} + \textColor{\matchGray}\AA{% + \AAKeystroke{AFNumber_Keystroke(0,1,0,0,"",true);\r\KeyToGray} + \AAFormat{AFNumber_Format(0,1,0,0,"",true);\r\FmtToGray{Total}} + \AACalculate{var cArray=new Array("Integer");\r + AFSimple_Calculate("SUM", cArray );\r\CalcToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}}} +]{TotalNumbers1}{1in}{11bp}\cgBdry[1em] +\pushButton[\CA{Reset} + \TU{Press to clear to clear all fields.} + \A{\JS{this.resetForm();}}]{reset}{}{11bp} +\end{quote} +Enter numbers into the first two text fields (\ding{172} and \ding{173}), the +totals of these two fields appear in the last two fields (\ding{174} and +\ding{175}). Total field \ding{174} uses the recommended script +\texttt{if(AllowCalc(cArray)} (see line~(6) above), whereas field \ding{175} +does not. Initially, they both behave the same way until you press the reset +button. For field \ding{174} the gray hint appears, for field \ding{175} the +number zero (0) appears. This is because the calculation was allowed to go +forward, and the calculated value is zero even through none of the dependent +fields have a value. If you want the gray hint in the total field, you must +use the conditional \texttt{if(AllowCalc(cArray)}.\footnote{Hence, don't use the \opt{nodljs} option.} + +\subsection{Changing the colors for gray hints} + +For the fields in which the gray hint scripts are used, there are two colors +that are relevant, the normal color (defaults to black) and the gray color +(defaults to light gray). The command +\cs{normalGrayColors\darg{\ameta{normalcolor}}\darg{\ameta{graycolor}}} sets +this pair of colors. The arguments for \cs{normalGrayColors} are JavaScript +colors; they may be in any of the following four forms: (1) a JavaScript +color array \texttt{["RGB",1,0,0]}; (2) a predefined JavaScript color, such +as \texttt{color.red}; (3) a declared (or named) {\LaTeX} color such as +\texttt{red}; or (4) a non-declared {\LaTeX} color such as +\texttt{[rgb]\darg{1,0,0}}. If the package \pkg{xcolor} is not loaded, only +methods (1) and (2) are supported. + +The package default is +\cs{normalGrayColors\darg{color.black}\darg{color.ltGray}}. The predefined +JavaScript colors are, +\begin{quote} +% \setlength\tabcolsep{3pt} + \setlength{\extrarowheight}{1pt} + \begin{tabular}{>{\ttfamily}l>{\ttfamily}l>{\ttfamily}l} + \multicolumn{3}{>{\sffamily}c}{Color Models}\\\hline + \multicolumn{1}{>{\sffamily}c}{GRAY}& + \multicolumn{1}{>{\sffamily}c}{RGB}& + \multicolumn{1}{>{\sffamily}c}{CMYK}\\ + color.black&color.red&color.cyan\\ + color.white&color.green&color.magenta\\ + color.dkGray&color.blue\\ + color.gray\\ + color.ltGray + \end{tabular} +\end{quote} +All these colors are defined in the {\LaTeX} color packages, except for possibly \texttt{dkGray}, +\texttt{gray}, and \texttt{ltGray}. These three are defined in \pkg{grayhints}. + +We repeat the `First Name' example with different declared colors. We begin by declaring, +\begin{Verbatim}[xleftmargin=\parindent,fontsize=\small] +\normalGrayColors{blue}{magenta} +\end{Verbatim} +then build a `gray hinted' field, +\begin{quote}\previewOff\normalGrayColors{blue}{magenta}% + \textField[\textColor{\matchGray} + \TU{Enter your first name so I can get to know you better} + \AA{\AAFormat{\FmtToGray{First Name}} + \AAKeystroke{\KeyToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}} + }]{NameFirst4}{2in}{11bp}\cgBdry[1em] +\pushButton[\CA{Reset} + \TU{Press to clear to clear all fields.} + \A{\JS{this.resetForm();}}]{reset}{}{11bp} +\end{quote} + +\subsection{Remarks on the + \texorpdfstring{\protect\opt{usealtadobe}}{usealtadobe} option}\label{s:altadobfuncs} + +The \opt{usealtadobe} option is useful for developers who have the +\app{Adobe} application and who wish to develop and test scripts that extend +in the current work. The \opt{usealtadobe} option inputs from \pkg{insdljs} the following +alternate names. As a general rule, all Adobe built-in format, validate, and calculation functions +that begin with `AF' are given alternate names that begin with `EF'. More specifically, the table +below lists the effected functions. +\begin{quote} +\begin{tabular}{>{\ttfamily}l>{\ttfamily}l} +\multicolumn{1}{>{\sffamily\bfseries}l}{Adobe function name}&% +\multicolumn{1}{>{\sffamily\bfseries}l}{Alternate function name}\\ +AFNumber\_Keystroke&EFNumber\_Keystroke\\ +AFNumber\_Format&EFNumber\_Format\\ +AFPercent\_Keystroke&EFPercent\_Keystroke\\ +AFPercent\_Format&EFPercent\_Format\\ +AFDate\_Format&EFDate\_Format\\ +AFDate\_Keystroke&EFDate\_Keystroke\\ +AFDate\_FormatEx&EFDate\_FormatEx\\ +AFTime\_Keystroke&EFTime\_Keystroke\\ +AFTime\_Format&EFTime\_Format\\ +AFTime\_FormatEx&EFTime\_FormatEx\\ +AFDate\_KeystrokeEx&EFDate\_KeystrokeEx\\ +AFSpecial\_Keystroke&EFSpecial\_Keystroke\\ +AFSpecial\_Format&EFSpecial\_Format\\ +AFSpecial\_KeystrokeEx&EFSpecial\_KeystrokeEx\\ +AFRange\_Validate&EFRange\_Validate\\ +AFRange\_Validate&EFRange\_Validate\\ +AFSimple\_Calculate&EFSimple\_Calculate\\ +AFMergeChange&EFMergeChange +\end{tabular} +\end{quote} + +\begin{figure}[htb] +\begin{minipage}[t]{.5\linewidth-2.5pt}\kern0pt\centering +%\setlength{\fboxsep}{0pt}% +{\setlength{\fboxsep}{0pt}{\includegraphics[width=\linewidth]{graphics/numFmt-noshowcustom}}}% +\end{minipage}\hfill +\begin{minipage}[t]{.5\linewidth-2.5pt}\kern0pt\centering +{\setlength{\fboxsep}{0pt}{\includegraphics[width=\linewidth]{graphics/numFmt-showcustom}}}% +\end{minipage}\\[3pt] +\makebox[.5\linewidth-2.5pt][c]{(a)\ Using \texttt{AFNumber\_Format}}\hfill +\makebox[.5\linewidth-2.5pt][c]{(b)\ Using \texttt{EFNumber\_Format}}% +\caption{Format tab: `AF' versus `EF' functions}\label{fig:AltAdbFncs} +\end{figure} + +\hyperref[fig:AltAdbFncs]{Figure~\ref*{fig:AltAdbFncs}} shows the impact of using the `EF' functions. On the left, +\texttt{AFNumber\_Format} is used to format a number field that uses gray hints using the code +\begin{Verbatim}[xleftmargin=\parindent] +AFNumber_Format(0,1,0,0,"",true)\r\FmtToGray +\end{Verbatim} +As can be seen in sub-figure\,(a), or more accurately not seen, the code is +not seen through the user-interface of \app{Acrobat}. In sub-figure\,(b) the +underlying code is seen (and therefore editable through the user-interface) +because the `EF' version of the function was used: +\begin{Verbatim}[xleftmargin=\parindent] +\try{EFNumber_Format(0,1,0,0,"",true)}catch(e){}\r\FmtToGray +\end{Verbatim} +Note this code is wrapped in a \texttt{try/catch} construct; this is +optional. The \pkg{insdljs} package defines a helper command \cs{dlTC} to do the wrapping for you: +\begin{Verbatim}[xleftmargin=\parindent] +\dlTC{EFNumber_Format(0,1,0,0,"",true)}\r\FmtToGray +\end{Verbatim} +When using \app{pdflatex} or \app{xelatex}, \texttt{try/catch} appears not to +be needed, but when \app{Adobe Distiller} is used, \app{Acrobat} throws an +exception when the file is first created. The \texttt{try/\penalty0catch} suppresses +(catches) the exception. + + +\section{My retirement} + +Now, I simply must get back to it. \dps + +\end{document} diff --git a/Master/texmf-dist/doc/latex/grayhints/examples/gh-eforms.pdf b/Master/texmf-dist/doc/latex/grayhints/examples/gh-eforms.pdf Binary files differnew file mode 100644 index 00000000000..add08324cd3 --- /dev/null +++ b/Master/texmf-dist/doc/latex/grayhints/examples/gh-eforms.pdf diff --git a/Master/texmf-dist/doc/latex/grayhints/examples/gh-eforms.tex b/Master/texmf-dist/doc/latex/grayhints/examples/gh-eforms.tex new file mode 100644 index 00000000000..555e4af77c7 --- /dev/null +++ b/Master/texmf-dist/doc/latex/grayhints/examples/gh-eforms.tex @@ -0,0 +1,126 @@ +\documentclass{article} +\usepackage[designiv]{web} +\usepackage[usealtadobe]{grayhints}\previewOff + + +\addtoWebHeight{1in} +\def\cs#1{\texttt{\char`\\#1}} +\parindent0pt + + +\begin{document} + +\begin{center} + \large\bfseries Gray Hints +\end{center} +The `gray hint' technique requires modifications to the Format, +Keystroke, OnFocus, and OnBlur events.\medskip + +\textField[\textColor{\matchGray} + \TU{Enter your first name} + \AA{\AAFormat{\FmtToGray{First Name}} + \AAKeystroke{\KeyToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}} +}]{Name.First}{2in}{11bp}\cgBdry[1em] +\textField[\textColor{\matchGray} + \TU{Enter your last name} + \AA{\AAFormat{\FmtToGray{Last Name}} + \AAKeystroke{\KeyToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}} +}]{Name.Last}{2in}{11bp}\cgBdry[1em]\vcgBdry[3bp] +\textField[\textColor{\matchGray} + \TU{Enter a date of your choosing} + \AA{\AAKeystroke{AFDate_KeystrokeEx("yyyy/mm/dd");\r\KeyToGray} + \AAFormat{AFDate_FormatEx("yyyy/mm/dd");\r\FmtToGray{yyyy/mm/dd}} + \AAKeystroke{\KeyToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}} +}]{Datefield}{1in}{11bp}\cgBdry[1em]\vcgBdry[6bp] + + +The next three fields perform calculations, the last one is the sum of the +first two. These are fields formatted as numbers. To prevent `Total' field +from displaying a zero (0) when the dependent fields are empty (and to +display its gray hint instead), a document JavaScript function was developed, +named \texttt{AllowCalc(cArray)}. This function returns \texttt{true} if any +of the fields listed in \texttt{cArray} has a value and returns +\texttt{false}, otherwise.\vcgBdry[6bp] + +\textField[\TU{Enter an integer} + \textColor{\matchGray}\AA{% + \AAKeystroke{EFNumber_Keystroke(0,1,0,0,"",true);\r\KeyToGray} + \AAFormat{EFNumber_Format(0,1,0,0,"",true);\r\FmtToGray{First Integer}} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}}} +]{Integer.First}{1in}{11bp}\vcgBdry[3bp] +\textField[\TU{Enter an integer} + \textColor{\matchGray}\AA{% + \AAKeystroke{EFNumber_Keystroke(0,1,0,0,"",true);\r\KeyToGray} + \AAFormat{EFNumber_Format(0,1,0,0,"",true);\r\FmtToGray{Second Integer}} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}}} +]{Integer.Second}{1in}{11bp}\vcgBdry[3bp] +\textField[\TU{The total for first and second integers} + \textColor{\matchGray}\AA{% + \AAKeystroke{EFNumber_Keystroke(0,1,0,0,"",true);\r\KeyToGray} + \AAFormat{EFNumber_Format(0,1,0,0,"",true);\r\FmtToGray{Total}} + \AACalculate{var cArray=new Array("Integer");\r + if (AllowCalc(cArray)) AFSimple_Calculate("SUM", cArray );\r\CalcToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}}} +]{TotalNumbers}{1in}{11bp}\vcgBdry[6bp] + + + +The gray hint technique can apply to editable combo boxes as well.\vcgBdry[3bp] +\comboBox[\textColor{\matchGray} + \TU{Enter or choose your favorite food}\Ff{\FfEdit} + \AA{\AAFormat{\FmtToGray{Enter your favorite food}} + \AAKeystroke{\KeyToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}} +}]{combo}{1.65in}{11bp}{(Meat)(Potatoes)(Rice)(Onions)(Pickles)}\cgBdry[1em] +\pushButton[\CA{Reset} + \TU{Press to clear to clear all fields.} + \A{\JS{this.resetForm();}}]{reset}{}{11bp}\vcgBdry[6bp] + +The color scheme of the gray hints is changed using +\cs{normalGrayColors}. The initial value of \cs{textColor}, which sets the +color of the text, must match, for appearance sake, the choice for the gray +color; for this reason, the \cs{matchGray} command was developed.\vcgBdry[6bp] + +\normalGrayColors{blue}{magenta} +%\normalGrayColors{color.blue}{color.magenta} + +\textField[\textColor{\matchGray} + \TU{Enter your favorite pet's name} + \AA{\AAFormat{\FmtToGray{Pet's name}} + \AAKeystroke{\KeyToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}} +}]{Pet}{1in}{11bp} + +\end{document} + + +\begin{document} +\begin{center}\large\bfseries Gray Hints +\end{center} +The `gray hint' technique requires the modification of the Format, +Calculate, OnFocus, and OnBlur events.\medskip + +\textField[\textColor{\matchGray} + \TU{Enter your first name}\AA{% +\AAFormat{\FmtToGray{First Name}} + \AAKeystroke{\KeyToGray} + \AAOnFocus{\JS{\FocusToBlack}} + \AAOnBlur{\JS{\BlurToBlack}}}]{Name.First}{2in}{11bp}\vcgBdry[3bp] + + +\pushButton[\CA{Reset} + \TU{Press to clear to clear all fields.} + \A{\JS{this.resetForm();}}]{reset}{}{11bp} + +\end{document} diff --git a/Master/texmf-dist/doc/latex/grayhints/examples/gh-hyperref.tex b/Master/texmf-dist/doc/latex/grayhints/examples/gh-hyperref.tex new file mode 100644 index 00000000000..dcb240477ab --- /dev/null +++ b/Master/texmf-dist/doc/latex/grayhints/examples/gh-hyperref.tex @@ -0,0 +1,131 @@ +\documentclass{article} +\usepackage[designiv]{web} +\usepackage[usehyforms]{grayhints} + +\addtoWebHeight{1in} +\def\cs#1{\texttt{\char`\\#1}} +\parindent0pt + + +\begin{document} +\begin{Form} +\begin{center}\large\bfseries Gray Hints +\end{center} +The `gray hint' technique requires modifications to the Format, +Keystroke, OnFocus, and OnBlur events.\medskip + +\renewcommand\LayoutTextField[2]{#2} +\renewcommand\LayoutChoiceField[2]{#2} + +\TextField[% + name={Name.First}, + height=11bp, + width=2in, + color={\matchGray}, + keystroke=\KeyToGray, + format={\FmtToGray{First Name}}, + onfocus={\FocusToBlack}, + onblur={\BlurToBlack}]{First Name:}\quad +\TextField[% + name={Name.Laat}, + height=11bp, + width=2in, + color={\matchGray}, + keystroke=\KeyToGray, + format={\FmtToGray{Last Name}}, + onfocus={\FocusToBlack}, + onblur={\BlurToBlack}]{}\medskip + +\TextField[% + name=Datefield, + height=11bp, + width=1in, + color={\matchGray}, + keystroke={AFDate_KeystrokeEx("yyyy/mm/dd");\KeyToGray}, + format={AFDate_FormatEx("yyyy/mm/dd");\FmtToGray{yyyy/mm/dd}}, + onfocus={\FocusToBlack}, + onblur={\BlurToBlack}]{}\medskip + +The next three fields perform calculations, the last one is the sum of the +first two. These are fields formatted as numbers. To prevent `Total' field +from displaying a zero (0) when the dependent fields are empty (and to +display its gray hint instead), a document JavaScript function was developed, +named \texttt{AllowCalc(cArray)}. This function returns \texttt{true} if any +of the fields listed in \texttt{cArray} has a value and returns +\texttt{false}, otherwise.\smallskip + +\TextField[% + name=Integer.First, + height=11bp, + width=1in, + color={\matchGray}, + keystroke={AFNumber_Keystroke(0,1,0,0,"",true);\KeyToGray}, + format={AFNumber_Format(0,1,0,0,"",true); \FmtToGray{First Integer}}, + onfocus=\FocusToBlack, + onblur=\BlurToBlack +]{}\smallskip + +\TextField[% + name=Integer.Second, + height=11bp, + width=1in, + color=\matchGray, + keystroke={AFNumber_Keystroke(0,1,0,0,"",true); \KeyToGray}, + format={AFNumber_Format(0,1,0,0,"",true); \FmtToGray{Second Integer}}, + onfocus=\FocusToBlack, + onblur=\BlurToBlack +]{}\smallskip + +\TextField[% + name=TotalNumber, + height=11bp, + width=1in, + color=\matchGray, + keystroke={AFNumber_Keystroke(0,1,0,0,"",true);\KeyToGray}, + format={AFNumber_Format(0,1,0,0,"",true); \FmtToGray{Total}}, + calculate={var cArray=new Array("Integer"); + if (AllowCalc(cArray))AFSimple_Calculate("SUM", cArray ); \CalcToGray}, + onfocus=\FocusToBlack, + onblur=\BlurToBlack +]{}\medskip + +The gray hint technique can apply to editable combo boxes as well.\smallskip + +\ChoiceMenu[% + name=combo, + combo, + width=1.65in, + height=11bp, + color={\matchGray}, + edit, + keystroke=\KeyToGray, + format={\FmtToGray{Enter your favorite food}}, + onfocus=\FocusToBlack, + onblur=\BlurToBlack +]{}{Meat,Potatoes,Rice,Onions,Pickles}\medskip + +The color scheme of the gray hints can be changed using +\cs{normalGrayColors}. The initial value of \cs{textColor}, which sets the +color of the text, must match, for appearance sake, the choice for the gray +color; for this reason, the \cs{matchGray} command was developed.\smallskip + +\normalGrayColors{color.blue}{color.magenta} + +\TextField[% + name=Pet, + width=1in, + height=11bp, + color=\matchGray, + keystroke=\KeyToGray, + format=\FmtToGray{Pet's name}, + onfocus=\FocusToBlack, + onblur=\BlurToBlack +]{Pet}\medskip + +\PushButton[% + height=11bp, + name=reset, + onclick={this.resetForm();}]{Reset}\medskip + +\end{Form} +\end{document} diff --git a/Master/texmf-dist/source/latex/grayhints/grayhints.dtx b/Master/texmf-dist/source/latex/grayhints/grayhints.dtx new file mode 100644 index 00000000000..9756703cf75 --- /dev/null +++ b/Master/texmf-dist/source/latex/grayhints/grayhints.dtx @@ -0,0 +1,348 @@ +%\iffalse +% makeindex -s gglo.ist -o grayhints.gls grayhints.glo +% makeindex -s gind.ist -o grayhints.ind grayhints.idx +%<*copyright> +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% grayhints.sty package, %% +%% Copyright (C) 2016 D. P. Story %% +%% dpstory@uakron.edu %% +%% %% +%% This program can redistributed and/or modified under %% +%% the terms of the LaTeX Project Public License %% +%% Distributed from CTAN archives in directory %% +%% macros/latex/base/lppl.txt; either version 1.2 of the %% +%% License, or (at your option) any later version. %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%</copyright> +%<package>\NeedsTeXFormat{LaTeX2e}[1997/12/01] +%<package>\ProvidesPackage{grayhints} +%<package> [2017/03/02 v1.0 grayhints: Create gray hints in text fields] +%<*driver> +\documentclass{ltxdoc} +\usepackage{xcolor} +\usepackage[colorlinks,hyperindex=false]{hyperref} +\usepackage{grayhints} +%\pdfstringdefDisableCommands{\let\\\textbackslash} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\gdef\brpr#1{\texttt{\char123\relax#1\char125\relax}} +\let\darg\brpr +\let\env\texttt +\let\opt\texttt +\let\app\textsf +\let\pkg\textsf +\def\visispace{\symbol{32}} +\def\ameta#1{\ensuremath{\langle\textit{\texttt{#1}}\rangle}} +\def\meta#1{\textsl{\texttt{#1}}} +\def\SUB#1{\ensuremath{{}_{\mbox{\scriptsize\ttfamily#1}}}} +%\def\cs#1{\texttt{\bslash#1}} +\DeclareRobustCommand{\tmspace}[3]{% + \ifmmode\mskip#1#2\else\kern#1#3\fi\relax} +\renewcommand{\,}{\tmspace+\thinmuskip{.1667em}} +\let\thinspace\, +\renewcommand{\!}{\tmspace-\thinmuskip{.1667em}} +\let\negthinspace\! +\renewcommand{\:}{\tmspace+\medmuskip{.2222em}} +\let\medspace\: +\newcommand{\negmedspace}{\tmspace-\medmuskip{.2222em}} +\renewcommand{\;}{\tmspace+\thickmuskip{.2777em}} +\let\thickspace\; +\newcommand{\negthickspace}{\tmspace-\thickmuskip{.2777em}} +\makeatletter +\renewcommand{\paragraph} + {\@startsection{paragraph}{4}{0pt}{6pt}{-3pt} + {\normalfont\normalsize\bfseries}} +\renewenvironment{quote}[1][] + {\def\@rgi{#1}\ifx\@rgi\@empty + \let\rghtm\@empty\else\def\rghtm{\rightmargin\leftmargin}\fi + \list{}{\rghtm} %{\rightmargin\leftmargin}% + \item\relax} + {\endlist} +\makeatother +\InputIfFileExists{aebdocfmt.def}{\PackageInfo{grayhints}{Inputting aebdocfmt.def}} + {\def\IndexOpt{\DescribeMacro}\def\IndexKey{\DescribeMacro}\let\setupFullwidth\relax + \PackageInfo{grayhints}{aebdocfmt.def cannot be found}} +\begin{document} +\def\CMD#1{\textbackslash#1} + \GetFileInfo{grayhints.sty} + \title{\textsf{grayhints}: Create gray hints in text fields} + \author{D. P. Story\\ + Email: \texttt{dpstory@acrotex.net}} + \date{processed \today} + \maketitle + \tableofcontents + \let\Email\texttt + \DocInput{grayhints.dtx} +\IfFileExists{\jobname.ind}{\newpage\setupFullwidth\par\PrintIndex}{\paragraph*{Index} The index goes here.\\Execute + \texttt{makeindex -s gind.ist -o grayhints.ind grayhints.idx}\\on the command line and recompile + \texttt{grayhints.dtx}.} +\IfFileExists{\jobname.gls}{\PrintChanges}{\paragraph*{Change History} The list of changes goes here.\\Execute + \texttt{makeindex -s gglo.ist -o grayhints.gls grayhints.glo}\\on the command line and recompile + \texttt{grayhints.dtx}.} +\end{document} +%</driver> +% \fi +% \MakeShortVerb{|} +% +% \InputIfFileExists{aebdonotindex.def}{\PackageInfo{web}{Inputting aebdonotindex.def}} +% {\PackageInfo{web}{cannot find aebdonotindex.def}} +% +% \begin{macrocode} +%<*package> +% \end{macrocode} +% \section{Description}\previewOff +% We often see in HTML pages or compiled executable applications, form fields (text fields, input fields) +% that require user input. The untouched field has text within it informing the user +% of the nature of the data to be entered into the field. This, usually, grayed hint immediately +% disappears when the user focus the cursor on the field. Lest I be accused of being too obtuse, we +% illustrate with an example or two. +%\begin{quote} +% \textField[\textColor{\matchGray} +% \TU{Enter your first name so I can get to know you better} +% \AA{\AAFormat{\FmtToGray{First Name}} +% \AAKeystroke{\KeyToGray} +% \AAOnFocus{\JS{\FocusToBlack}} +% \AAOnBlur{\JS{\BlurToBlack}} +% }]{NameFirst}{2in}{11bp}\vcgBdry[\medskipamount] +% \textField[\textColor{\matchGray} +% \TU{Enter your favorite date, in the indicated format} +% \AA{\AAKeystroke{AFDate_KeystrokeEx("yyyy/mm/dd");\KeyToGray} +% \AAFormat{AFDate_FormatEx("yyyy/mm/dd");\FmtToGray{yyyy/mm/dd}} +% \AAOnFocus{\JS{\FocusToBlack}} +% \AAOnBlur{\JS{\BlurToBlack}} +% }]{DateField}{1in}{11bp}\cgBdry[1.5em] +% \pushButton[\CA{Reset} +% \TU{Press to clear to clear all fields.} +% \A{\JS{this.resetForm();}}]{reset}{}{11bp} +%\end{quote} +% Of course, the usual tooltips may also be provided.\medskip\noindent +% +% It is not natural for Adobe form fields to do this, it takes a lot of support code for +% it to work properly; the Keystroke, Format, OnFocus, and OnBlur events are needed. The +% verbatim listing of the first example field above is, +% +%\begin{quote} +%|\textField[\textColor{\matchGray}|\\ +%| \TU{Enter your first name so I can get to know you better}|\\ +%| \AA{\AAFormat{\FmtToGray{First Name}}|\\ +%| \AAKeystroke{\KeyToGray}|\\ +%| \AAOnFocus{\JS{\FocusToBlack}}|\\ +%| \AAOnBlur{\JS{\BlurToBlack}}|\\ +%|}]{NameFirst}{2in}{11bp}| +%\end{quote} +% Code snippets are inserted into the Keystroke, Format, +% OnFocus, and OnBlur events. +% +% \paragraph*{Demo files:} \texttt{gh-eforms.tex}, \texttt{hg-hyperref.tex}. +% +% \section{Documentation and Code} +% The \pkg{eforms} package is preferred, but you can use the form field macros of \pkg{hyperref}. +% Any options specified for the \pkg{grayhints} package +% are passed on to \pkg{insdljs}. One useful option is \opt{usealtadobe}\IndexOpt{usealtadobe}, used for creating +% custom formatting routines that also use Adobe's built-in formatting functions. The \opt{usealtadobe} +% option is only useful if the document author has the Adobe application to edit form fields. If the document +% author does not want to use \pkg{eforms}, he/she can pass the option \opt{usehyforms}\IndexOpt{usehyforms} to use the form +% fields of \pkg{hyperref}, in this case \pkg{insdljs} is required. For the last option, \opt{nodljs}\IndexOpt{nodljs} +% is for users of \pkg{hyperref} forms who do not want to use \pkg{insdljs}. In the latter case, +% the option \opt{usehyforms} should not be used for that will include \pkg{insdljs}. +% \begin{macrocode} +\DeclareOption{usehyforms}{% + \def\FormsRequirement{\RequirePackage{insdljs}[2017/03/02]}} +\def\FormsRequirement{\RequirePackage{eforms}[2017/02/27]} +\DeclareOption{nocalcs}{\let\nodljsend\endinput} +\DeclareOption{nodljs}{\let\FormsRequirement\relax + \let\nodljsend\endinput} +\let\nodljsend\relax +\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{insdljs}} +\ProcessOptions +\FormsRequirement +% \end{macrocode} +% We include \texttt{eqcolor.def}, a component of \pkg{exerquiz} to help parse colors, +% and to match JS colors with PDF colors. +% \begin{macrocode} +\@ifundefined{jsColor}{\let\eq@YES=y\let\eq@NO=n% + \InputIfFileExists{eqcolor.def} + {\PackageInfo{grayhints}{Inputting eqcolor.def from exerquiz}} + {\PackageError{grayhints}{cannot find eqcolor.def belonging + to exerquiz}{Refresh your file name database and try again.}} +}{} +% \end{macrocode} +% +% \subsection{JavaScript snippets for Field JavaScript} +% Code snippets are inserted in to the Format, Calculate, +% OnFocus, and OnBlur events, as illustrated above. +% +% \begin{macro}{\normalGrayColors}\hspace{-\marginparsep}\thinspace +% \darg{\ameta{normalcolor}}\darg{\ameta{graycolor}} There are two colors +% in play, the normal color of the text field (\ameta{normalcolor}) and +% the color of the ``grayed'' text (\ameta{graycolor}). We set the defaults +% to \texttt{color.black} and \texttt{color.ltGray}, respectively. The two parameters +% are JavaScipt colors: array type \texttt{["RGB", 1, 0, 0]}, or predefined type +% \texttt{color.blue}. The command \cs{jsColor} is used to assign colors (taken from +% \texttt{eqcolor.def} of \pkg{exerquiz}). +% \begin{macrocode} +\newcommand{\normalGrayColors}[2]{\def\gh@rgi{#1}\def\gh@rgii{#2}% + \ifx\gh@rgi\@empty\else + \jsColor\gh@normalcolor{#1}\gh@chkTr@nsparency\fi + \ifx\gh@rgii\@empty\else\jsColor\gh@graycolor{#2}\m@tchGray\fi} +\def\gh@normalcolor{}\def\gh@graycolor{} +\AtEndOfPackage{\normalGrayColors{color.black}{color.ltGray}} +% \end{macrocode} +% \end{macro} +% There are several predefined JavaScript colors the user can specify. We need to +% convert them to PDF color too. +% \begin{macrocode} +\definecolor{ltGray}{gray}{0.75} +\definecolor{gray}{gray}{.5} +\definecolor{dkGray}{gray}{.25} +\def\gh@pd@transparent{ltGray}\def\gh@transparent{transparent} +\def\gh@pd@black{black}\def\gh@pd@white{white} +\def\gh@pd@dkGray{dkGray}\def\gh@pd@gray{gray}\def\gh@pd@ltGray{ltGray} +\def\gh@pd@red{red}\def\gh@pd@green{green}\def\gh@pd@blue{blue} +\def\gh@pd@cyan{cyan}\def\gh@pd@magenta{magenta} +\def\gh@pd@yellow{yellow} +% \end{macrocode} +% Convert the JS color for \cs{gh@graycolor} to a matching PDF color that can be +% used by the \cs{textColor} property of a form field. Here, we use commands defined +% in the \texttt{eqcolor.def} file from \pkg{exerquiz}. This command defines the user +% command \DescribeMacro{\matchGray}\cs{matchGray}. +% \begin{macrocode} +\def\m@tchGray{\eq@checkRawJSColor{\gh@graycolor}% + \ifx\eqpredefineJSCol\eq@NO +% \end{macrocode} +% \cs{gh@graycolor} is a JavaScript array +% \begin{macrocode} + \let\matchGray\@empty + \expandafter\gh@extr@ctJSModelInfo\gh@graycolor\@nil + \ifx\@rgi\@empty\else\edef\matchGray{\@rgi}\fi + \ifx\@rgii\@empty\else\edef\matchGray{\matchGray\space\@rgii}\fi + \ifx\@rgiii\@empty\else + \edef\matchGray{\matchGray\space\@rgiii}\fi + \ifx\@rgiv\@empty\else\edef\matchGray{\matchGray\space\@rgiv}\fi + \else +% \end{macrocode} +% \cs{gh@graycolor} is a predefined color (\texttt{color.ltGray}) +% \begin{macrocode} + \expandafter\gh@getColorFromPrefined\gh@graycolor\@nil + \@ifundefined{gh@pd@\pd@color}{% + \def\gh@graycolor{color.ltGray}\def\pd@color{ltGray}% + \PackageWarning{grayhints} + {The color.\pd@color\space is undefined,\MessageBreak + substituting color.ltGray}}{\ifx\pd@color\gh@transparent + \def\gh@graycolor{color.ltGray}\def\pd@color{ltGray}% + \PackageWarning{grayhints} + {A transparent color is not supported,\MessageBreak + using color.ltGray instead}\fi + }% + \edef\matchGray{\@nameuse{gh@pd@\pd@color}}% + \fi} +\def\gh@chkTr@nsparency{\eq@checkRawJSColor{\gh@normalcolor}% + \ifx\eqpredefineJSCol\eq@YES + \expandafter\gh@getColorFromPrefined\gh@normalcolor\@nil + \@ifundefined{gh@pd@\pd@color}{\def\gh@normalcolor{color.black}% + \PackageWarning{grayhints} + {The color.\pd@color\space is undefined,\MessageBreak + substituting color.black}}{}% + \ifx\pd@color\gh@transparent\def\gh@normalcolor{color.black}% + \PackageWarning{grayhints} + {A transparent color is not supported,\MessageBreak + using color.black instead}\fi + \fi +} +% \end{macrocode} +% Various supporting macros to extract information. +% \begin{macrocode} +\def\gh@extr@ctJSModelInfo[#1,#2]\@nil{% + \gh@getspecv@lues#2,,,,\@nil}% +\def\gh@getspecv@lues#1,#2,#3,#4,#5\@nil{% + \def\@rgi{#1}\def\@rgii{#2}\def\@rgiii{#3}\def\@rgiv{#4}} +\def\gh@getColorFromPrefined color.#1\@nil{\def\pd@color{#1}} +% \end{macrocode} +% \begin{macro}{\FmtToGray}\hspace{-\marginparsep}\thinspace +% \darg{\ameta{grayhint}} This command is placed in the Format event. It places the hint +% \ameta{grayhint} as the formatting text string when the field is empty. +% If a built-in Adobe function is also used, use \cs{FmtToGray} after it; for example, +% \begin{quote} +% |\AAFormat{AFNumber_Format(0,1,0,0,"",true);|\\ +% |\FmtToGray{|\ameta{grayhint}|}}| +% \end{quote} +% \begin{macrocode} +\newcommand\FmtToGray[1]{if(event.value=="")event.value=("#1");} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\KeyToGray} +% This command is placed in the Keystroke event. It changes +% the color to `gray' (\cs{gh@graycolor}) if the field is empty. +% If a built-in Adobe function is also used, use \cs{KeyToGray} after it; for example, +% \begin{quote} +% |\AAFormat{AFNumber_Keystroke(0,1,0,0,"",true);|\\ +% |\KeyToGray}| +% \end{quote} +% \begin{macrocode} +\newcommand\KeyToGray{if(event.value=="")% + event.target.textColor=\gh@graycolor;} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\CalcToGray} +% The \cs{CalcToGray} is a Calculate script, it is needed only in a form field that performs +% a calculation. If a built-in Adobe function is also used, use \cs{KeyToGray} after it; for example, +% \begin{quote} +% |\AACalculate{var cArray=new Array("Integer");\r|\\ +% |if (AllowCalc(cArray)) AFSimple_Calculate("SUM", cArray );\r|\\ +% |\CalcToGray}| +% \end{quote} +% \begin{macrocode} +\newcommand\CalcToGray{event.target.textColor=% + (event.value=="")?\gh@graycolor:\gh@normalcolor;} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\FocusToBlack} +% A command placed within the OnFocus event. When the field comes into focus, and +% the field is empty, the color for the text is turned to black. This can be redefined +% to another color. +% \begin{macrocode} +\newcommand\FocusToBlack{if(event.target.valueAsString=="")% + event.target.textColor=\gh@normalcolor;} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\BlurToBlack} +% A command placed within the OnBlur event. It sets the text color to gray or black, +% depending on whether the field is empty or not. My be redefined with different colors. +% \begin{macrocode} +\newcommand\BlurToBlack{event.target.textColor=% + (event.target.valueAsString=="")?\gh@graycolor:\gh@normalcolor;} +% \end{macrocode} +% \end{macro} +% +% \subsection{Document JavaScript to support gray hints} +% Technically speaking, the only lines really required are +% the ones defining the +% function \texttt{AllowCalc}, and this is used only when you are +% creating a series of calculation fields that performs arithmetic operations +% on the dependent fields. +% \begin{macrocode} +\nodljsend +\begin{insDLJS}{ghsupport}{grayhints: Support for the Calculate Event} +% \end{macrocode} +% In order to get the gray hints to appear in the terminal field of a calculation group, +% we cannot perform the calculate when all the dependent fields are empty. \texttt{cArray} +% is an array of all dependent fields involved in the calculation. The use of this function +% is illustrated in \texttt{grayhints.tex}. +% \begin{macrocode} +function AllowCalc(cArray) { + var f,g; + for (var i=0; i<cArray.length; i++) { + f=this.getField(cArray[i]); + g=f.getArray(); + for (var j=0; j<g.length; j++) + if (g[j].valueAsString!="") return true; + } + return false; +} +\end{insDLJS} +% \end{macrocode} +% \begin{macrocode} +%</package> +% \end{macrocode} +\endinput diff --git a/Master/texmf-dist/source/latex/grayhints/grayhints.ins b/Master/texmf-dist/source/latex/grayhints/grayhints.ins new file mode 100644 index 00000000000..064332eb747 --- /dev/null +++ b/Master/texmf-dist/source/latex/grayhints/grayhints.ins @@ -0,0 +1,58 @@ +%% +%% This file will generate fast loadable files and documentation +%% driver files from the doc files in this package when run through +%% LaTeX or TeX. +%% +%% Copyright 2016 D. P. Story +%% ------------------------------------------- +%% +%% It may be distributed under the conditions of the LaTeX Project Public +%% License, either version 1.2 of this license or (at your option) any +%% later version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.2 or later is part of all distributions of LaTeX +%% version 1999/12/01 or later. +%% +%% --------------- start of docstrip commands ------------------ +%% +\def\filedate{2016/01/12} +\def\batchfile{grayhints.ins} + +\input docstrip +\ifx\generate\undefined + \Msg{**********************************************} + \Msg{*} + \Msg{* This installation requires docstrip} + \Msg{* version 2.4 or later.} + \Msg{*} + \Msg{* An older version of docstrip has been input} + \Msg{*} + \Msg{**********************************************} + \errhelp{Move or rename old docstrip.tex and get a newer one.} + \errmessage{Old docstrip in input path} + \batchmode + \csname @@end\endcsname\end +\fi + +\keepsilent +\askforoverwritefalse +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\preamble +\endpreamble + +\generate +{% + \file{grayhints.sty}{\from{grayhints.dtx}{copyright,package}} +} + +\Msg{***************************************************************} +\Msg{*} +\Msg{* \space To finish the installation you have to copy the files } +\Msg{*} +\Msg{* \space *.sty, *.cfg and *.def into a directory searched by TeX} +\Msg{*} +\Msg{***************************************************************} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\endinput diff --git a/Master/texmf-dist/tex/latex/grayhints/grayhints.sty b/Master/texmf-dist/tex/latex/grayhints/grayhints.sty new file mode 100644 index 00000000000..ac23dad98a7 --- /dev/null +++ b/Master/texmf-dist/tex/latex/grayhints/grayhints.sty @@ -0,0 +1,119 @@ +%% +%% This is file `grayhints.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% grayhints.dtx (with options: `copyright,package') +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% grayhints.sty package, %% +%% Copyright (C) 2016 D. P. Story %% +%% dpstory@uakron.edu %% +%% %% +%% This program can redistributed and/or modified under %% +%% the terms of the LaTeX Project Public License %% +%% Distributed from CTAN archives in directory %% +%% macros/latex/base/lppl.txt; either version 1.2 of the %% +%% License, or (at your option) any later version. %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\NeedsTeXFormat{LaTeX2e}[1997/12/01] +\ProvidesPackage{grayhints} + [2017/03/02 v1.0 grayhints: Create gray hints in text fields] +\DeclareOption{usehyforms}{% + \def\FormsRequirement{\RequirePackage{insdljs}[2017/03/02]}} +\def\FormsRequirement{\RequirePackage{eforms}[2017/02/27]} +\DeclareOption{nocalcs}{\let\nodljsend\endinput} +\DeclareOption{nodljs}{\let\FormsRequirement\relax + \let\nodljsend\endinput} +\let\nodljsend\relax +\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{insdljs}} +\ProcessOptions +\FormsRequirement +\@ifundefined{jsColor}{\let\eq@YES=y\let\eq@NO=n% + \InputIfFileExists{eqcolor.def} + {\PackageInfo{grayhints}{Inputting eqcolor.def from exerquiz}} + {\PackageError{grayhints}{cannot find eqcolor.def belonging + to exerquiz}{Refresh your file name database and try again.}} +}{} +\newcommand{\normalGrayColors}[2]{\def\gh@rgi{#1}\def\gh@rgii{#2}% + \ifx\gh@rgi\@empty\else + \jsColor\gh@normalcolor{#1}\gh@chkTr@nsparency\fi + \ifx\gh@rgii\@empty\else\jsColor\gh@graycolor{#2}\m@tchGray\fi} +\def\gh@normalcolor{}\def\gh@graycolor{} +\AtEndOfPackage{\normalGrayColors{color.black}{color.ltGray}} +\definecolor{ltGray}{gray}{0.75} +\definecolor{gray}{gray}{.5} +\definecolor{dkGray}{gray}{.25} +\def\gh@pd@transparent{ltGray}\def\gh@transparent{transparent} +\def\gh@pd@black{black}\def\gh@pd@white{white} +\def\gh@pd@dkGray{dkGray}\def\gh@pd@gray{gray}\def\gh@pd@ltGray{ltGray} +\def\gh@pd@red{red}\def\gh@pd@green{green}\def\gh@pd@blue{blue} +\def\gh@pd@cyan{cyan}\def\gh@pd@magenta{magenta} +\def\gh@pd@yellow{yellow} +\def\m@tchGray{\eq@checkRawJSColor{\gh@graycolor}% + \ifx\eqpredefineJSCol\eq@NO + \let\matchGray\@empty + \expandafter\gh@extr@ctJSModelInfo\gh@graycolor\@nil + \ifx\@rgi\@empty\else\edef\matchGray{\@rgi}\fi + \ifx\@rgii\@empty\else\edef\matchGray{\matchGray\space\@rgii}\fi + \ifx\@rgiii\@empty\else + \edef\matchGray{\matchGray\space\@rgiii}\fi + \ifx\@rgiv\@empty\else\edef\matchGray{\matchGray\space\@rgiv}\fi + \else + \expandafter\gh@getColorFromPrefined\gh@graycolor\@nil + \@ifundefined{gh@pd@\pd@color}{% + \def\gh@graycolor{color.ltGray}\def\pd@color{ltGray}% + \PackageWarning{grayhints} + {The color.\pd@color\space is undefined,\MessageBreak + substituting color.ltGray}}{\ifx\pd@color\gh@transparent + \def\gh@graycolor{color.ltGray}\def\pd@color{ltGray}% + \PackageWarning{grayhints} + {A transparent color is not supported,\MessageBreak + using color.ltGray instead}\fi + }% + \edef\matchGray{\@nameuse{gh@pd@\pd@color}}% + \fi} +\def\gh@chkTr@nsparency{\eq@checkRawJSColor{\gh@normalcolor}% + \ifx\eqpredefineJSCol\eq@YES + \expandafter\gh@getColorFromPrefined\gh@normalcolor\@nil + \@ifundefined{gh@pd@\pd@color}{\def\gh@normalcolor{color.black}% + \PackageWarning{grayhints} + {The color.\pd@color\space is undefined,\MessageBreak + substituting color.black}}{}% + \ifx\pd@color\gh@transparent\def\gh@normalcolor{color.black}% + \PackageWarning{grayhints} + {A transparent color is not supported,\MessageBreak + using color.black instead}\fi + \fi +} +\def\gh@extr@ctJSModelInfo[#1,#2]\@nil{% + \gh@getspecv@lues#2,,,,\@nil}% +\def\gh@getspecv@lues#1,#2,#3,#4,#5\@nil{% + \def\@rgi{#1}\def\@rgii{#2}\def\@rgiii{#3}\def\@rgiv{#4}} +\def\gh@getColorFromPrefined color.#1\@nil{\def\pd@color{#1}} +\newcommand\FmtToGray[1]{if(event.value=="")event.value=("#1");} +\newcommand\KeyToGray{if(event.value=="")% + event.target.textColor=\gh@graycolor;} +\newcommand\CalcToGray{event.target.textColor=% + (event.value=="")?\gh@graycolor:\gh@normalcolor;} +\newcommand\FocusToBlack{if(event.target.valueAsString=="")% + event.target.textColor=\gh@normalcolor;} +\newcommand\BlurToBlack{event.target.textColor=% + (event.target.valueAsString=="")?\gh@graycolor:\gh@normalcolor;} +\nodljsend +\begin{insDLJS}{ghsupport}{grayhints: Support for the Calculate Event} +function AllowCalc(cArray) { + var f,g; + for (var i=0; i<cArray.length; i++) { + f=this.getField(cArray[i]); + g=f.getArray(); + for (var j=0; j<g.length; j++) + if (g[j].valueAsString!="") return true; + } + return false; +} +\end{insDLJS} +\endinput +%% +%% End of file `grayhints.sty'. |