summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/grayhints/grayhints.sty
blob: 4d901492d03a3eb7d0a4fe1742d141bdea13fd3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
%%
%% 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) 2017--2018                              %%
%%   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}
 [2018/11/01 v1.2 grayhints: Create gray hints in text fields]
\DeclareOption{usehyforms}{%
    \def\FormsRequirement{\RequirePackage{insdljs}[2017/03/02]}}
\def\FormsRequirement{\RequirePackage{eforms}[2017/02/27]}
\DeclareOption{usealtadobe}{\PackageWarningNoLine{grayhints}
  {The `usealtadobe' option is now deprecated.\MessageBreak
   The alternate functions are automatically loaded.\MessageBreak
   Please remove this grayhints package option}}
\DeclareOption{nocalcs}{\let\nocalcs\endinput}
\let\nocalcs\relax
\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}}
\def\gh@PriorFormat{event.target.savevalue=event.value;\jsR}
\newcommand\FailStringDef{continue editing}
\newcommand\EnterCommitFailDef{event.value=("\FailStringDef");}
\def\EnterCommitFailEvent#1{\def\@rgi{#1}\ifx\@rgi\@empty
  \def\gh@ECFE{\EnterCommitFailDef}\else\def\gh@ECFE{#1}\fi}
\EnterCommitFailEvent{}
\def\CommitSuccessEvent#1{\def\@rgi{#1}\ifx\@rgi\@empty
\let\gh@CSE\jsR\else\def\gh@CSE{\jsR\jsT #1\jsR}\fi}
\let\gh@CSE\jsR
\newcommand\FmtToGray[1]{%
  if(typeof event.target.savevalue=="undefined"){\jsR\jsT
   event.target.savevalue="";\jsR\jsT
   event.target.success=false;\jsR
  }\jsR
  if(typeof event.target.ghBuiltin=="undefined")%
    event.target.ghBuiltin=false;\jsR
  if(!event.target.ghBuiltin)\gh@PriorFormat
  event.target.ghBuildtin=false;\jsR\gh@FmtToGray{#1}}
\def\gh@FmtToGray#1{%
  if(typeof event.target.saverc=="undefined")%
    event.target.saverc=true;\jsR
  if(!event.target.saverc||event.value==""){\jsR\jsT
    if(event.target.savevalue!=""&&%
      !event.target.success){\jsR\jsT\gh@ECFE\jsR\jsT
      if(typeof app.pxceInfo!="undefined")%
        event.target.savevalue="";\jsR\jsT
    } else {\jsR\jsT\jsT
      event.target.success=false;\jsR\jsT\jsT
      event.value=("#1");\jsT\gh@CSE\jsT}\jsR
  } else {\jsR\jsT
      event.target.success=true;\gh@CSE}
}
\newcommand\KeyToGray{%
  if(event.willCommit&&event.value!=""&&!event.rc)\jsR\jsT
   event.target.success=false;\jsR
  event.target.saverc=event.rc;\jsR
  event.rc=true;\jsR
  if(event.willCommit&&event.value=="")%
    event.target.textColor=\gh@graycolor;\jsR
  if(event.willCommit)%
    event.target.savevalue=event.value;
}
\newcommand\CalcToGray{event.target.textColor=%
  (event.value=="")?\gh@graycolor:\gh@normalcolor;}
\newcommand\FocusToBlack{%
  if (typeof event.target.success=="undefined")%
    event.target.success=false;\jsR
  if(event.target.valueAsString==""%
    ||!event.target.success)\jsR\jsT
    event.target.textColor=\gh@normalcolor;
}
\newcommand\BlurToBlack{%
  if (!event.target.success||event.target.valueAsString=="")\jsR\jsT
   this.resetForm(event.target.name);\jsR
  event.target.savevalue="";\jsR
  event.target.textColor=(!event.target.success||%
  event.target.valueAsString=="")?\gh@graycolor:\gh@normalcolor;
}
\def\NumKey{EFNumber_Keystroke}
\def\NumFmt(#1){try{EFNumber_Format(#1)}catch(e){}}
\def\DateKey{EFDate_Keystroke}
\def\DateFmt(#1){%
  AFDate_Format(#1);\jsR
  event.target.ghBuiltin=true;
}
\def\DateKeyEx{EFDate_KeystrokeEx}
\def\DateFmtEx(#1){%
  AFDate_FormatEx(#1);\jsR
  event.target.ghBuiltin=true;
}
\def\PercentKey{EFPercent_Keystroke}
\def\PercentFmt(#1){%
  if(event.value!=""||%
    (typeof event.target.savevalue!="undefined"&&%
      event.target.savevalue!=""))%
    AFPercent_Format(#1);\jsR
  event.target.ghBuiltin=true;
}
\def\TimeKey{EFTime_Keystroke}\def\TimeFmt{EFTime_Format}
\def\TimeFmtEx(#1){try{EFTime_FormatEx(#1)}catch(e){}}
\def\SpecialKey{EFSpecial_Keystroke}
\def\SpecialKeyEx{EFSpecial_KeystrokeEx}
\def\SpecialFmt(#1){try{EFSpecial_Format(#1)}catch(e){}}
\def\RangeValidate{EFRange_Validate}
\def\SimpleCalc{EFSimple_Calculate}
\def\MergeChange{EFMergeChange}
\nodljsend
\begin{insDLJS}{altadbfncs}{gh: Support for Adobe built-in functions}
var EFNumber_Keystroke=AFNumber_Keystroke;
function EFNumber_Format(){
  event.target.savevalue=event.value;
  event.target.ghBuiltin=true;
  AFNumber_Format.apply(null,arguments);
}
var EFDate_Keystroke=AFDate_Keystroke;
function EFDate_Format(){
  event.target.savevalue=event.value;
  event.target.ghBuiltin=true;
  AFDate_Format.apply(null,arguments);
}
var EFDate_KeystrokeEx=AFDate_KeystrokeEx;
function EFDate_FormatEx(){
  event.target.savevalue=event.value;
  event.target.ghBuiltin=true;
  AFDate_FormatEx.apply(null,arguments);
}
var EFPercent_Keystroke=AFPercent_Keystroke;
function EFPercent_Format(){
  event.target.savevalue=event.value;
  event.target.ghBuiltin=true;
  AFPercent_Format.apply(null,arguments);
}
var EFTime_Keystroke=AFTime_Keystroke;
function EFTime_Format(){
  event.target.savevalue=event.value;
  event.target.ghBuiltin=true;
  AFTime_Format.apply(null,arguments);
}
function EFTime_FormatEx(){
  event.target.savevalue=event.value;
  ghBuiltin=true;
  AFTime_FormatEx.apply(null,arguments);
}
var EFSpecial_Keystroke=AFSpecial_Keystroke;
var EFSpecial_KeystrokeEx=AFSpecial_KeystrokeEx;
function EFSpecial_Format(){
  event.target.savevalue=event.value;
  event.target.ghBuiltin=true;
  AFSpecial_Format.apply(null,arguments);
}
var EFRange_Validate=AFRange_Validate;
var EFSimple_Calculate=AFSimple_Calculate;
var EFMergeChange=AFMergeChange;
\end{insDLJS}
\nocalcs
\begin{insDLJS}{ghsupport}{gh: 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'.