blob: 07e5b3e16d3a83e565bed021be96d3103465a636 (
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
|
%%
%% This is file `cooltooltips.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% cooltooltips.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% Copyright (C) 2006 by Scott Pakin <scott+ctip@pakin.org>
%%
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3b 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.3b or later is part of all distributions of LaTeX version
%% 2006/01/07 or later.
%%
\NeedsTeXFormat{LaTeX2e}[2001/06/01]
\ProvidesPackage{cooltooltips}
[2006/03/07 v1.0 Cool PDF tooltips]
\RequirePackage{ifpdf}
\newcommand*{\ctip@form@fields}{}
\ifpdf
\AtEndDocument{%
\immediate\pdfobj {
<<
/Fields [\ctip@form@fields]
/NeedAppearances true
>>
}%
\pdfcatalog {
/AcroForm \the\pdflastobj\space 0 R
}%
}
\fi
\ifpdf
\setbox\@tempboxa=\hbox{}
\immediate\pdfxform\@tempboxa
\edef\ctip@empty@icon{\the\pdflastxform}
\fi
\newcommand*{\ctip@tip@number}{0}
\newcommand*{\ctip@make@Text}[3][0 1 0]{%
\pdfannot width 0pt height 0pt depth 0pt {
/Subtype /Text
/C [#1]
/Subj (#2)
/Contents (#3)
/NM (ctip Text \ctip@tip@number)
/AP <<
/N \ctip@empty@icon\space 0 R
/D \ctip@empty@icon\space 0 R
/R \ctip@empty@icon\space 0 R
>>
/Open false
}%
}
\newcommand*{\ctip@current@page}{1}
\newcommand*{\ctip@last@invis}{0}
\let\ctip@label=\label
\newcommand*{\ctip@update@pagenum}{%
\ctip@label{ctip:tip:\ctip@tip@number}%
\expandafter\let\expandafter\ctip@refname
\csname r@ctip:tip:\ctip@tip@number\endcsname
\@ifundefined{ctip@refname}{%
\xdef\ctip@current@page{\thepage}%
}{%
\def\ctip@secondofN##1##2##3!{%
\xdef\ctip@current@page{##2}%
}%
\expandafter\ctip@secondofN\ctip@refname!%
}%
}
\newcommand*{\ctip@make@invisible@Widget}{%
\pdfannot width 0pt height 0pt depth 0pt {
/Subtype /Widget
/FT /Btn
/T (ctip invisible Widget \ctip@current@page)
/DA (/Helv 10 Tf 0 0 0 rg)
/Ff 65536
/F 2
/AA <<
/Fo <<
/Type /Action
/S /JavaScript
/JS (event.target.display = display.hidden)
>>
>>
}%
}
\newsavebox{\ctip@content@box}
\newcommand*{\ctip@unfocus@js}{%
var ctipField =
this.getField("ctip invisible Widget \ctip@current@page");
ctipField.display = display.visible;
ctipField.setFocus();
}
\newcommand*{\ctip@enter@js}{%
if (!global.ctip_disable_popups) {
var ctipText =
this.getAnnot(this.pageNum, "ctip Text \ctip@tip@number");
ctipText.popupOpen = true;
\ctip@unfocus@js
}
}
\newcommand*{\ctip@exit@js}{%
if (!global.ctip_disable_popups) {
var ctipText =
this.getAnnot(this.pageNum, "ctip Text \ctip@tip@number");
ctipText.popupOpen = false;
\ctip@unfocus@js
}
}
\newcommand*{\ctip@make@Widget}[3][0 1 0]{%
\setlength{\@tempdima}{\wd\ctip@content@box}%
\addtolength{\@tempdima}{\fboxsep}%
\setlength{\@tempdimb}{\ht\ctip@content@box}%
\addtolength{\@tempdimb}{0.5\fboxsep}%
\setlength{\@tempdimc}{\dp\ctip@content@box}%
\addtolength{\@tempdimc}{0.5\fboxsep}%
\hspace*{-0.5\fboxsep}%
\immediate
\pdfobj {
<<
/Type /Action
/S /URI
/URI (#2)
>>
}%
\edef\ctip@action@object{\the\pdflastobj\space 0 R}%
\makebox[0pt][l]{%
\advance\fboxrule by 0.9999pt
\pdfannot width \@tempdima
height \@tempdimb
depth \@tempdimc {
/Subtype /Link
/A \ctip@action@object
/Border [0 0 \strip@pt\fboxrule]
/C [#1]
}%
}%
\pdfannot width \@tempdima
height \@tempdimb
depth \@tempdimc {
/Subtype /Widget
/FT /Btn
/T (ctip Field \ctip@tip@number)
/TU (#3)
/DA (/Helv 10 Tf 0 0 0 rg)
/Ff 65536
/BS <<
/Type /Border
/W \strip@pt\fboxrule
>>
/MK <<
/BC [#1]
/TP 1
>>
/AA <<
/E <<
/Type /Action
/S /JavaScript
/JS (\ctip@enter@js)
>>
/X <<
/Type /Action
/S /JavaScript
/JS (\ctip@exit@js)
>>
/U <<
/Type /Action
/S /JavaScript
/JS (\ctip@unfocus@js)
/Next \ctip@action@object
>>
>>
}
\xdef\ctip@form@fields{\ctip@form@fields\space\the\pdflastannot\space 0 R}
}
\DeclareRobustCommand{\cooltooltip}[1][0 1 0]{%
\def\ctip@popup@color{#1}%
\ctip@cooltooltip@i
}
\newcommand*{\ctip@cooltooltip@i}[6][\ctip@popup@color]{%
\savebox{\ctip@content@box}{#6}%
\@tempcnta=\ctip@tip@number
\advance\@tempcnta by 1
\xdef\ctip@tip@number{\the\@tempcnta}%
\ctip@update@pagenum
\@tempcnta=\ctip@last@invis
\@tempcntb=\ctip@current@page
\ifnum\@tempcnta<\@tempcntb
\ctip@make@invisible@Widget
\xdef\c@ctip@last@invis{\ctip@current@page}%
\fi
\makebox[0pt][l]{%
\ctip@make@Widget[#1]{#4}{#5}%
\makebox[\paperwidth][r]{%
\ctip@make@Text[\ctip@popup@color]{#2}{#3}%
}%
}%
\usebox{\ctip@content@box}%
}
\DeclareRobustCommand{\cooltooltiptoggle}[1]{%
\savebox{\ctip@content@box}{#1}%
\makebox[0pt][l]{%
\pdfannot width \wd\ctip@content@box
height \ht\ctip@content@box
depth \dp\ctip@content@box {
/Subtype /Link
/Border [0 0 0]
/A <<
/Type /Action
/S /JavaScript
/JS (
global.ctip_disable_popups = !global.ctip_disable_popups;
var ctipField;
var i;
for (i=1; (ctipField=this.getField("ctip Field " + i)); i++)
ctipField.display =
global.ctip_disable_popups ? display.hidden : display.visible;
)
>>
}%
}%
\usebox{\ctip@content@box}%
}
\RequirePackage{ifpdf}
\ifpdf
\else
\PackageWarning{cooltooltips}{%
Not running pdfLaTeX in PDF mode; disabling cooltooltips%
}
\renewcommand*{\ctip@cooltooltip@i}[6][]{\mbox{#6}}
\fi
\endinput
%%
%% End of file `cooltooltips.sty'.
|