% \iffalse meta-comment % % Copyright (C) 2004 by Robert Marik % ----------------------------------------------------- % % 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. % % \fi % % \iffalse %<*driver> \ProvidesFile{fancytooltips.dtx} % %\NeedsTeXFormat{LaTeX2e}[1999/12/01] %\ProvidesPackage{fancytooltips} %<*package> [2007/02/20 v1.1 fancytooltips.dtx file] % % %<*driver> \documentclass{ltxdoc} \EnableCrossrefs \CodelineIndex \RecordChanges \usepackage[pdftex]{eforms} \usepackage[pdftex]{color} \usepackage[filename=tip]{fancytooltips} \buttontipwidth=2cm \buttontipheight=2cm \begin{document} \color{black} \DocInput{fancytooltips.dtx} \PrintChanges \PrintIndex \end{document} % % \fi % % \CheckSum{332} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z % Digits \0\1\2\3\4\5\6\7\8\9 % Exclamation \! Double quote \" Hash (number) \# % Dollar \$ Percent \% Ampersand \& % Acute accent \' Left paren \( Right paren \) % Asterisk \* Plus \+ Comma \, % Minus \- Point \. Solidus \/ % Colon \: Semicolon \; Less than \< % Equals \= Greater than \> Question mark \? % Commercial at \@ Left bracket \[ Backslash \\ % Right bracket \] Circumflex \^ Underscore \_ % Grave accent \` Left brace \{ Vertical bar \| % Right brace \} Tilde \~} % % % \changes{v1.0}{2007/02/15}{Initial version} % \changes{v1.1}{2007/02/20}{Clener code, better documentation, fix % for bug with delayinterval macro, support for dvips and DIstiller % users.} % % \GetFileInfo{fancytooltips.dtx} % % \DoNotIndex{\newcommand,\newenvironment} % % % \title{The \textsf{fancytooltips} package\thanks{This document % corresponds to \textsf{fancytooltips}~\fileversion, dated \filedate.}} % \author{Robert Marik \\ \texttt{marik@mendelu.cz}} % % \maketitle % % \section{Introduction} % % \null\hfill\TooltipHidden\frametip\\ % The package |fancytooltips| is a package for \LaTeX. The pdf can be % created by pdflatex or by latex + dvips + % AdobeDistiller\footnote{not free ps2pdf} + Adobe % Acrobat\footnote{not free Adobe Reader.}. It allows to create % tooltips in a similar way like |cooltooltips| package, but the % tooltip is a page from another PDF file. In this way you can use % also mathematics, pictures and animations in your tooltips. The % resulting PDF file can be used also with free Abobe Reader. % % The \color{black}tooltips are activated by |MouseOver| action with % pressed |Shift| button down or by |MouseDown| action. The tooltips % are deactivated after closing page or by moving mouse outside the % link. You can try the links \tooltip{here}{1} (Einstein's formula) % and also \tooltipanim{here}{2}{7} (animation -- numbers from 1 to % 6). Tooltip appears on the right boundary of the first paragraph. % You have to use the free Adobe Reader or nonfree Adobe Acrobat to % see the effect (xpdf, evince and others fail to work with % JavaScripts). For more examples how the presentation may look like % see the |example.pdf| and |example-min.pdf| files in the |examples| % subdirectory. % % The buttons are created using |eforms.sty| which is a part of % AcroTeX bundle. % % \section{Usage} % \subsection{The file with tooltips} % The file with tooltips is an ordinary pdf file, one tooltip per % page, tooltips should be in the top right corner at the page, in a % colored box and the rest of the page should be % transparent\footnote{See the example file \texttt{tooltipy.tex} and % \texttt{tooltipy.pdf} which make use of \texttt{geometry.sty} % package to set the page dimensions and \texttt{\string\colorbox} % and \texttt{minipage} to make the box with tooltip}. We also % provide simple cross referencing mechanism to reffer to the % tooltips. If the pdf file is created by \LaTeX, % \DescribeMacro{\keytip} you can define keywords to reffer to the % pages using |\keytip| command. Simply put % |\usepackage[createtips]{fancytooltips}| into preamble and write % \texttt{\string\keytip}\marg{foo} in document. This writes % information about keyword \meta{foo} and the pagenumber into file % |fancytips.tex|. % % \subsection{The file with presentation -- pdf\LaTeX users} % In the file with presentation, the user is responsible % \begin{itemize} % \item to include package |eforms| with |pdftex| option before % loading fancytooltips package, and % \item input either |color| or |xcolor| package in the % preamble. % \end{itemize} % This is not convenient for the user, but everybody uses different % package and from this reason, this part is left to the user. (And % among others, the |color| or |xcolor| package is probably inputted % by the package which is used to build the presentation.) % % To input the tooltips from file \meta{foo.pdf} call the package with % \meta{filename} option |\usepackage[filename=foo]{fancytooltips}|, % input images for tooltips somewhere in the document using % \DescribeMacro{\TooltipHidden} macro |\TooltipHidden| % \DescribeMacro{\frametip} and put the macro |\frametip| on every % page\footnote{In the current document the \texttt{\string\frametip} % command was used only once in the first paragraph, since we have % tooltips in this paragraph only and the tooltips in the top right % corner of the page would be outside of the screen in most cases.} % in the right top corner of your document\footnote{See the file % \texttt{example.tex} and \texttt{example-min.tex} to know how to % achieve this with the \texttt{pdfscrren.sty} presentation bundle % and pure \texttt{article.cls} class, respectively.}. % \DescribeMacro{\buttontipwidth} \DescribeMacro{\buttontipheight} The % dimensions of button with tooltips (created by |\frametip| macro) % are stored in the |\buttontipwidth| and |\buttontipheight| length % variables. If the page with tooltip is bigger, it is resized to fit % into the button. You can change it for example by % |\buttontipwidth=4in|. To get expected results (tooltips in the top % right corner) these lengths should be equal or constant multiples of % the page dimensions of the file with tooltips. The button is inside % a box with zero dimensions and hence the box produced by |\frametip| % command has zero dimensions. % % % \DescribeMacro{\tooltip} The user can put the tooltip into her or % his presentation using the command % \texttt{\string\tooltip}{\marg{stuff}\marg{keyword-or-pagenumber}} % where \meta{stuff} is the printed text in \meta{tooltipcolor} color % and \meta{keyword-or-pagenumber} is either the pagenumber of the % tooltip in the external file or the keyword defined by |\keytip| % command. \DescribeMacro{\TooltipExtratext} The printed text % \meta{stuff} is followed by |\TooltipExtratext| command. The default % value is small blue soap in a box with zero dimensions, as you have % seen in the second paragraph of this documentation. There is a % package option |noextratext| which defines |\TooltipExtratext| to be % empty. % % \DescribeMacro{\tooltipanim} The user can put a series (animation) of % tooltips into the presentation by using % \texttt{\string\tooltipanim}\marg{stuff}\marg{start}\marg{end} % command, where \meta{start} and \meta{end} are keywords defined by % |\keytip| command or page numbers. \DescribeMacro{\delayinterval} % The delay between two frames is |\delayinterval| milliseconds. The % default value is 200, you can change it by command % |\def\delayinterval{100}|. % \subsection{Changes for dvips users} % dvips users have to specify option |dvips| in both |fancytips| and % |eforms| packages. They have to use also a |pages| option with the % number of pages in the PDF file with tooltips. You have to call the % package by % something like this:\\ % |\usepackage[dvips]{eforms}|\\ % |\usepackage[dvips,filename=tooltipy,pages=27]{fancytooltips}| % % You have to |latex| and |dvips| your file. This produces % |filename.ps| and |Tooltipsdljs.fdf| files. Distill the pdf file % into |filename.pdf| and open this file by Adobe Acrobat - this % imports macros from |Tooltipsdljs.fdf| file. In Acrobat's JavaScript % console (|Crtl+J|) run (|Ctrl+Enter|) the command |ImportIcons();| % which is defined for the document and it imports the icons and % returns 1. The file with pdf icon must be in the working directory. % Then save the file under another name. % % \StopEventually{} % % \section{Implementation} % \begin{macrocode} %<*package> \RequirePackage{everyshi} \RequirePackage{graphicx} \RequirePackage{xkeyval} \newif\ifcreatetips\createtipsfalse \DeclareOptionX{createtips}{\createtipstrue} \newif\ifTooltip@usepdftex\Tooltip@usepdftextrue \DeclareOptionX{dvips}{\Tooltip@usepdftexfalse} \newif\ifextratext\extratexttrue \DeclareOptionX{noextratext}{\extratextfalse} \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 \def\TooltipExtratext{\hbox to 0 pt{\smash {\raisebox{0.5em}{\includegraphics[width=1em]% {fancytooltipsmark.pdf}}}\hss}} \else \def\TooltipExtratext{\hbox to 0 pt{\smash {\raisebox{0.5em}{\includegraphics[width=1em]% {fancytooltipsmark.eps}}}\hss}} \fi%\ifTooltip@usepdftex \ifextratext\else\let\TooltipExtratext\relax\fi \ifcreatetips % \end{macrocode} % This part (three lines) is processed if the option |createtips| is % used. In the opposite case we process the second part, up to the end % of the package. % \begin{macrocode} \newwrite\tipfile \immediate\openout\tipfile fancytips.tex \def\keytip#1{\write\tipfile{\string\tooltipname{#1}{\arabic{page}}}} \else % \end{macrocode} % If dvips is used, we define icons by the command |\eqIcon| stolen % from |exerquiz.sty|. The following definitions are verbatim copy from % |exerquiz.sty|. The definition of |\eqIconDefaults| contains some % customizations. % \begin{macrocode} \ifTooltip@usepdftex\else \ifx\everyeqIcon\undefined \newcommand\everyeqIcon[1]{\def\every@eqIcon{#1}} \def\every@eqIcon{} \newcommand\eqIcon[4][] {% \push@@Button{#1}{#2}{#3}{#4}{}{\eq@setButtonProps\eq@Button@driver}% {\eqIconDefaults\every@ButtonField\every@eqIcon}% } \fi%\ifx\everyeqIcon\undefined \def\eqIconDefaults {% \rawPDF{}\S{}\mkIns{/TP 1 /IF<>}\R{270} \CA{}\RC{}\AC{}\BC{}\BG{}\H{B} \textColor{0 g}\Ff{\FfReadOnly} } \fi%\ifTooltip@usepdftex % \end{macrocode} % Macro |\frametip| creates button in which tooltips appear. You have % to use macro |\frametip| on every page in your presentation in right % top corner (see the directory |examples|). % \begin{macrocode} \def\frametip{\vbox to 0 pt{\hbox to 0 pt{\hss\buttontip}\vss}} \newdimen\buttontipwidth \buttontipwidth=5in \newdimen\buttontipheight \buttontipheight=5in \ifTooltip@usepdftex \def\buttontip{% \pdfstartlink user{% /Subtype /Widget /F 6 /T (ikona) /FT /Btn /Ff 65536 /H /N /BS << /W 1 /S /S >> /MK << /TP 1 /IF <> >> }% \vbox to \buttontipheight {\vss\hbox to \buttontipwidth{\hss}}\pdfendlink} \else \def\buttontip{% \eqIcon[\BC{}\BG{}\F{\FHidden}]{ikona}{\buttontipwidth}{\buttontipheight} } \fi%\ifTooltip@usepdftex % \end{macrocode} % In the macros |\tooltip| and |\tooltipanim| we print the text into % box with zero dimensions and then we build a button which covers % this text and has an associated JavaScript action. % \begin{macrocode} \definecolor{tooltipcolor}{rgb}{0,0,1} \def\tooltip#1#2{\checkTipNumber{#2}% \edef\TipNumber{\FindTipNumber{#2}}% \setbox0=\hbox{{\color{tooltipcolor}{#1}}}\hbox to 0 pt{{\copy0\TooltipExtratext\hss}}% \pushButton[\BC{}\BG{}\S{}\AA{ \AAMouseExit{\JS{CloseTooltips();}} \AAMouseEnter{\JS{ try {app.clearInterval(animace);}catch (e) {} if (event.shift) {this.getField("ikona").hidden=false; this.getField('ikona').buttonSetIcon(this.getField("animtiph\TipNumber").buttonGetIcon());}}} } \A{\JS{this.getField("ikona").hidden=false; try {app.clearInterval(animace);}catch (e) {} this.getField('ikona').buttonSetIcon(this.getField("animtiph\TipNumber").buttonGetIcon());}}] {TooltipField}{\wd0}{\ht0}} \def\delayinterval{200} \def\tooltipanim#1#2#3{% \checkTipNumber{#2}\edef\TipNumberA{\FindTipNumber{#2}}% \checkTipNumber{#3}\edef\TipNumberB{\FindTipNumber{#3}}% \setbox0=\hbox{{\color{tooltipcolor}{#1}}}\hbox to 0 pt{{\copy0\TooltipExtratext\hss}}% \pushButton[\BC{}\BG{}\S{}\AA{ \AAMouseExit{\JS{CloseTooltips();}} \AAMouseEnter{\JS{ var cislo=\TipNumberA; try {app.clearInterval(animace);}catch (e) {} function animuj() { if (cislo<\TipNumberB) cislo=cislo+1; this.getField('ikona').buttonSetIcon(this.getField("animtiph"+cislo).buttonGetIcon()); }; if (event.shift) { this.getField('ikona').buttonSetIcon(this.getField("animtiph"+\TipNumberA).buttonGetIcon()); this.getField("ikona").hidden=false; animace=app.setInterval('animuj();', \delayinterval); } }} } \A{\JS{ try {app.clearInterval(animace);}catch (e) {} var cislo=\TipNumberA; function animuj() { if (cislo<\TipNumberB) cislo=cislo+1; this.getField('ikona').buttonSetIcon(this.getField("animtiph"+cislo).buttonGetIcon()); }; this.getField('ikona').buttonSetIcon(this.getField("animtiph"+\TipNumberA).buttonGetIcon()); this.getField("ikona").hidden=false; animace=app.setInterval('animuj();', \delayinterval); }} ]{TooltipField}{\wd0}{\ht0}} % \end{macrocode} % This code for |pdftex| closes tooltip if the page is closed. % \begin{macrocode} \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}[clearTooltips]{Tooltipsdljs}{My Private DLJS for Tooltips} var animace; function CloseTooltips() { this.getField("ikona").hidden=true; try {app.clearInterval(animace);}catch (e) {} } \end{insDLJS} \else \begin{insDLJS}[clearTooltips]{Tooltipsdljs}{My Private DLJS for Tooltips} var animace; function CloseTooltips() { this.getField("ikona").hidden=true; try {app.clearInterval(animace);}catch (e) {} } function ImportTooltips() { for (var i=1;i<=\TooltipPages;i++) {this.getField("animtiph"+i).buttonImportIcon("\TooltipFilename.pdf",(i-1));} return(1); } \end{insDLJS} \fi % \end{macrocode} % A cycle is used to create hidden buttons. Each button has associated a page % from the file with tooltips as icon. These icons are invoked by JavaScripts % defined in |\tooltip| and |\tooltipanim| macros. % \begin{macrocode} \newcount\tooltip@count \ifTooltip@usepdftex \newcommand*{\TooltipHidden}{% \count@=0 \@whilenum\count@<\TooltipPages \do{% \tooltip@count=\count@ \advance \tooltip@count by 1 \bgroup \immediate\pdfximage width 0 pt height 0 pt depth 0 pt page \the\tooltip@count{\TooltipFilename.pdf}% \mbox{\leavevmode \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 >> >> }% \pdfendlink}% \egroup \advance\count@\@ne}% } \else \def\TooltipHidden{% \count@=0 \@whilenum\count@<\TooltipPages \do{% \tooltip@count=\count@ \advance \tooltip@count by 1 \bgroup \eqIcon[\BC{}\BG{}\F{\FHidden}] {animtiph\the\tooltip@count}{0cm}{0cm}% \egroup \advance\count@\@ne}% } \fi % \end{macrocode} % The keywords for the tooltips can be stored in the file % |fancytips.tex|. The topics in this file are created by |\keytip| % macro (see the first part of the code). % \begin{macrocode} \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 % % \end{macrocode} % % \Finale \endinput