From 98a6e65fb1f21718c474d11e296da23fba0f4cc4 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 16 Jul 2006 23:19:40 +0000 Subject: new package cooltooltips (15mar06) git-svn-id: svn://tug.org/texlive/trunk@1865 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/latex/cooltooltips/cooltooltips.sty | 243 +++++++++++++++++++++ 1 file changed, 243 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/cooltooltips/cooltooltips.sty (limited to 'Master/texmf-dist/tex/latex/cooltooltips') diff --git a/Master/texmf-dist/tex/latex/cooltooltips/cooltooltips.sty b/Master/texmf-dist/tex/latex/cooltooltips/cooltooltips.sty new file mode 100644 index 00000000000..07e5b3e16d3 --- /dev/null +++ b/Master/texmf-dist/tex/latex/cooltooltips/cooltooltips.sty @@ -0,0 +1,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 +%% +%% 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'. -- cgit v1.2.3