summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/fancytooltips/fancytooltips.sty
blob: d1c3c552a0e452a8809adb12c67192834673c741 (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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
%%
%% This is file `fancytooltips.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% fancytooltips.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2007 by Robert Marik <marik@mendelu.cz>
%% 
%% This file may be distributed and/or modified 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.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{fancytooltips}
    [2007/05/08 v1.3 fancytooltips.dtx  file]
\RequirePackage{everyshi}
\RequirePackage{graphicx}
\RequirePackage{xkeyval}
\RequirePackage{eso-pic}

\newif\ifcreatetips\createtipsfalse
\DeclareOptionX{createtips}{\createtipstrue}

\newif\ifTooltip@usepdftex\Tooltip@usepdftextrue
\DeclareOptionX{dvips}{\Tooltip@usepdftexfalse}

\newif\ifextratext\extratexttrue
\DeclareOptionX{noextratext}{\extratextfalse}

\newif\ifmovetips\movetipsfalse
\DeclareOptionX{movetips}{\movetipstrue}

\DeclareOptionX{filename}{\xdef\TooltipFilename{#1}}
\DeclareOptionX{pages}{\xdef\TooltipPages{#1}}

\ProcessOptionsX

\ifx\TooltipFilename\undefined
\PackageWarning{fancytooltips}{** The filename with tooltips is not given. **}
\fi

\ifTooltip@usepdftex
\RequirePackage[pdftex]{eforms}
\def\TooltipExtratext{\hbox to 0 pt{\smash
    {\raisebox{0.5em}{\includegraphics[width=0.7em]%
        {fancytipmark.pdf}}}\hss}}
\else
\RequirePackage[dvips]{eforms}
\def\TooltipExtratext{\hbox to 0 pt{\smash
    {\raisebox{0.5em}{\includegraphics[width=0.7em]%
        {fancytipmark.eps}}}\hss}}
\fi%\ifTooltip@usepdftex
\ifextratext\else\let\TooltipExtratext\relax\fi

\ifcreatetips
\newwrite\tipfile
\immediate\openout\tipfile fancytips.tex
\def\keytip#1{\write\tipfile{\string\tooltipname{#1}{\arabic{page}}}}
\else

\newdimen\buttontipwidth
\newdimen\buttontipheight
\AtBeginDocument{
\buttontipwidth=\paperwidth
\buttontipheight=\paperheight
}

\ifTooltip@usepdftex
\def\frametip@{%
  \pdfstartlink user{%
    /Subtype /Widget
    /F 6
    /T (ikona.\thepage)
    /FT /Btn
    /Ff 65536
    /H /N
    /BS << /W 1 /S /S >>
    /MK << /TP 1 /IF <</A[1.0 1.0]/SW /B>>  >>
  }%
  \vbox to \buttontipheight {\vss\hbox to \buttontipwidth{\hss}}\pdfendlink}
\else
\def\everyeqIcon#1{\def\every@eqIcon{#1}}
\def\every@eqIcon{}
\newcommand\eqIconFTT[4][]
{%
  \push@@Button{#1}{#2}{#3}{#4}{}{\eq@setButtonProps\eq@Button@driver}%
  {\eqIconDefaults\every@ButtonField\every@eqIcon}%
}
\def\eqIconDefaults
{%
  \rawPDF{}\S{}\mkIns{/TP 1 /IF<</A[1.0 1.0]/SW/B>>}\R{0}
  \CA{}\RC{}\AC{}\BC{}\BG{}\H{B}
  \textColor{0 g}\Ff{\FfReadOnly}
}
\def\frametip@{\eqIconFTT[\BC{}\BG{}\F{\FHidden}]%
  {ikona.\thepage}{\paperwidth}{\paperheight}}%
\fi%\ifTooltip@usepdftex

\def\frametip{%
  \expandafter\ifx \csname TooltipPage\thepage\endcsname\relax
  \else
  \setbox0=\hbox{\frametip@}%
  \hbox{\raise \dp0 \box0}
  \fi}%
\AddToShipoutPicture{\hbox to 0 pt{\frametip\hss}}
\definecolor{tooltipcolor}{rgb}{0,0,1}
\def\TooltipPage#1{\expandafter\gdef\csname TooltipPage#1\endcsname{#1}}
\def\tooltip#1#2{%
  \write\@auxout{\noexpand\TooltipPage{\thepage}}%
  \checkTipNumber{#2}\edef\TipNumber{\FindTipNumber{#2}}%
  \leavevmode
  \setbox0=\hbox{{\color{tooltipcolor}{#1}}}\hbox to 0 pt{{\copy0\TooltipExtratext\hss}}%
  \pushButton[\BC{}\BG{}\S{}\AA{\AAMouseExit{\JS{CloseTooltips();}}}
  \A{\JS{this.getField("ikona."+(this.pageNum+1)).hidden=false;
      try {app.clearInterval(animace);}catch (e) {}
      \ifmovetips nastav(\TipNumber);\fi
      zobraz(\TipNumber);
    }}]
  {TooltipField}{\wd0}{\ht0}}
\def\delayinterval{200}
\def\tooltipanim#1#2#3{%
  \write\@auxout{\noexpand\TooltipPage{\thepage}}%
  \checkTipNumber{#2}\edef\TipNumberA{\FindTipNumber{#2}}%
  \checkTipNumber{#3}\edef\TipNumberB{\FindTipNumber{#3}}%
  \leavevmode
  \setbox0=\hbox{{\color{tooltipcolor}{#1}}}\hbox to 0 pt{{\copy0\TooltipExtratext\hss}}%
  \pushButton[\BC{}\BG{}\S{}\AA{\AAMouseExit{\JS{CloseTooltips();}}}
  \A{\JS{
      try {app.clearInterval(animace);}catch (e) {}
      var cislo=\TipNumberA;
      \ifmovetips nastav(\TipNumberA);\fi
      function animuj()
      {
        if (cislo<\TipNumberB) cislo=cislo+1;
        this.getField('ikona.'+(this.pageNum+1)).buttonSetIcon(this.getField("animtiph."+cislo).buttonGetIcon());
      };
      this.getField('ikona.'+(this.pageNum+1)).buttonSetIcon(this.getField("animtiph."+\TipNumberA).buttonGetIcon());
      this.getField("ikona."+(this.pageNum+1)).hidden=false;
      animace=app.setInterval('animuj();', \delayinterval);
    }}
  ]{TooltipField}{\wd0}{\ht0}}
\ifTooltip@usepdftex
\def\TooltipPageopencloseJS{  \global\pdfpageattr{%
    /AA << /O << /S /JavaScript /JS (CloseTooltips();) >>  >>}%
}
\pdfximage{\TooltipFilename.pdf}%
\edef\TooltipPages{\the\pdflastximagepages}%
\else
\def\TooltipPageopencloseJS{
\literalps@out{%
     [ {ThisPage} << /AA <<
    /O << /S /JavaScript /JS (CloseTooltips();) >>
    >> >> /PUT pdfmark}}
\OpenAction{/S /JavaScript /JS (CloseTooltips();)}
\fi%\ifTooltip@usepdftex
\EveryShipout{\TooltipPageopencloseJS}%

\ifTooltip@usepdftex
\begin{insDLJS}[fancyTooltipsLoaded]{Tooltipsdljs}{DLJS for Tooltips}
  var animace;
  var fancyTooltipsLoaded = true;

  function CloseTooltips()
  {
    try {this.getField("ikona").hidden=true;}catch (e) {}
    try {app.clearInterval(animace);}catch (e) {}
  }

  function nastav(cislo)
  {
    var f=this.getField("ikona."+(this.pageNum+1));
    var g=this.getField("animtiph."+cislo);
    var sourf=f.rect;
    var sourg=g.rect;
    if ((mouseX+sourg[2]-sourg[0])<sourf[2])
    var percX=100*(mouseX-sourf[0])/((sourf[2]-sourf[0])-(sourg[2]-sourg[0]));
    else
    var percX=100*(mouseX-sourf[0]-(sourg[2]-sourg[0]))/((sourf[2]-sourf[0])-(sourg[2]-sourg[0]));
    var percY=100*(mouseY-sourf[3])/((sourf[1]-sourf[3])-(sourg[1]-sourg[3]));
    if (percX>100) percX=100;
    if (percY>100) percY=100;
    if (percX<0) percX=0;
    if (percY<0) percY=0;
    f.buttonAlignX=percX;
    f.buttonAlignY=percY;
  }

  function zobraz(cislo)
  {
    var f=this.getField("ikona."+(this.pageNum+1));
    var g=this.getField("animtiph."+cislo);
    f.hidden=false;
    f.buttonSetIcon(g.buttonGetIcon());
  }
\end{insDLJS}
\else
\begin{insDLJS}[fancyTooltipsLoaded]{Tooltipsdljs}{DLJS for Tooltips}
  var animace;
  var fancyTooltipsLoaded = true;

  function CloseTooltips()
  {
    try {this.getField("ikona").hidden=true;}catch (e) {}
    try {app.clearInterval(animace);}catch (e) {}
  }

  function ImportTooltips()
  {
    console.println("importing pictures");
    for (var i=1;i<=\TooltipPages;i++)
    {
      this.insertPages(this.numPages-1,"\TooltipFilename.pdf",(i-1),(i-1));
      var rozm=this.getPageBox("Crop",this.numPages-1);
      this.deletePages(this.numPages-1);
      var p=this.addField("animtiph."+i,"button",0,rozm);
      p.buttonPosition=position.iconOnly;
      p.hidden=true;
      this.getField("animtiph."+i).buttonImportIcon("\TooltipFilename.pdf",(i-1));
    }
    console.println("imported \TooltipPages pictures");
    return(1);
  }

  function nastav(cislo)
  {
    var f=this.getField("ikona."+(this.pageNum+1));
    var g=this.getField("animtiph."+cislo);
    var sourf=f.rect;
    var sourg=g.rect;
    if ((mouseX+sourg[2]-sourg[0])<sourf[2])
    var percX=100*(mouseX-sourf[0])/((sourf[2]-sourf[0])-(sourg[2]-sourg[0]));
    else
    var percX=100*(mouseX-sourf[0]-(sourg[2]-sourg[0]))/((sourf[2]-sourf[0])-(sourg[2]-sourg[0]));
    var percY=100*(mouseY-sourf[3])/((sourf[1]-sourf[3])-(sourg[1]-sourg[3]));
    if (percX>100) percX=100;
    if (percY>100) percY=100;
    if (percX<0) percX=0;
    if (percY<0) percY=0;
    f.buttonAlignX=percX;
    f.buttonAlignY=percY;
  }

  function zobraz(cislo)
  {
    var f=this.getField("ikona."+(this.pageNum+1));
    var g=this.getField("animtiph."+cislo);
    f.hidden=false;
    f.buttonSetIcon(g.buttonGetIcon());
  }
\end{insDLJS}
\fi
\newcount\tooltip@count
\ifTooltip@usepdftex
\newcommand*{\TooltipHidden}{%
  \count@=0
  \@whilenum\count@<\TooltipPages \do{%
    \tooltip@count=\count@
    \advance \tooltip@count by 1%
    \bgroup
    \immediate\pdfximage
    page \the\tooltip@count{\TooltipFilename.pdf}%
    \mbox{\leavevmode
      \vbox to 0 pt{\vss\hbox to 0 pt{\pdfstartlink user{%
        /Subtype /Widget
        /F 6
        /T (animtiph.\the\tooltip@count)
        /FT /Btn
        /Ff 65536
        /H /N
        /BS << /W 1 /S /S >>
        /MK <<
        /TP 1
        /I \the\pdflastximage\space 0 R
        /IF << /SW /A >>
        >>
      }%
      \phantom{\pdfrefximage \pdflastximage}%
      \pdfendlink\hss}}}%
    \egroup
    \advance\count@\@ne}%
}
\AddToShipoutPicture*{\hbox to 0 pt{\TooltipHidden}}
\else
\let\TooltipHidden\relax
\fi
\AtBeginDocument{\IfFileExists{fancytips.tex}{\input{fancytips.tex}
\PackageInfo{fancytooltips}{Inputting fancytips.tex.}}%
  {\PackageWarning{fancytooltips}{No file fancytips.tex!
      Your keywords for tooltips will not work!}}}

\def\tooltipname#1#2{\expandafter\xdef\csname FancyToolTip@#1\endcsname{#2}}

\def\FindTipNumber#1{\expandafter\ifx \csname FancyToolTip@#1\endcsname\relax
  #1\else\csname FancyToolTip@#1\endcsname\fi}

\def\checkTipNumber#1{\expandafter\ifx
  \csname FancyToolTip@#1\endcsname\relax \PackageWarning{fancytooltips}{No
    framenumber is assigned to keyword #1. I assume that #1 is the
    number of the frame.}%
  \fi}

\fi
\endinput
%%
%% End of file `fancytooltips.sty'.