summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ocgtools
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-05-14 18:26:13 +0000
committerKarl Berry <karl@freefriends.org>2010-05-14 18:26:13 +0000
commit5ab9979378ea2f59c6a36d0bbf12e47d6300fc67 (patch)
treec3a2c20f18da5e557a7dab77bcfb6b36d7c12c18 /Master/texmf-dist/tex/latex/ocgtools
parent1d489c5acd49115955f035380e9ec36c51701827 (diff)
ocgtools 0.8 (11may10)
git-svn-id: svn://tug.org/texlive/trunk@18248 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/ocgtools')
-rw-r--r--Master/texmf-dist/tex/latex/ocgtools/ocgtools.sty209
1 files changed, 146 insertions, 63 deletions
diff --git a/Master/texmf-dist/tex/latex/ocgtools/ocgtools.sty b/Master/texmf-dist/tex/latex/ocgtools/ocgtools.sty
index 5e86007d9a6..02cc7c0e961 100644
--- a/Master/texmf-dist/tex/latex/ocgtools/ocgtools.sty
+++ b/Master/texmf-dist/tex/latex/ocgtools/ocgtools.sty
@@ -22,8 +22,8 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{ocgtools}
- [2010/04/10 v0.6 ocgtools.dtx file]
-\def\ocgtools@msg{If message does not disappear after a short time, the
+ [2010/05/10 v0.8 ocgtools.dtx file]
+\def\ocgtools@msg{If this message does not disappear after a short time, the
author either did not compile the \LaTeX{} file three times, or your
PDF viewer does not support OCG. Use Adobe Reader!}
@@ -32,12 +32,20 @@
\ifx\definecolor\undefined\RequirePackage{color}\fi
\ifx\href\undefined\RequirePackage[pdftex]{hyperref}\fi
\definecolor{ocgpaper}{rgb}{1,1,0.2}
+\definecolor{ocgfontcolor}{rgb}{0,0,0}
+\def\defaultocgpapercolor{ocgpaper}
+\def\defaultocgfontcolor{ocgfontcolor}
\definecolor{ocgbg}{rgb}{0,0,0}
\RequirePackage{graphicx}
\RequirePackage{pifont}
\RequirePackage{ocg}
+\RequirePackage{xkeyval}
+
+\newif\if@ocgtools@insideminilayer
+\def\ocgclosechar{{\color{red}\def\temp{red}%
+ \ifx\temp\ocgt@@ls@bg\if@ocgtools@insideminilayer\color{black}\fi\fi
+ \ding{56}}}
-\def\ocgclosechar{\ding{56}}
\RequirePackage{atbegshi}
\RequirePackage[pdftex]{eforms}
\newif\if@ocgtools@transparent\@ocgtools@transparentfalse
@@ -48,8 +56,6 @@
\def\ocgtools@initialvisibility{1}}
\newif\ifocg@hide@button\ocg@hide@buttontrue
\DeclareOption{nobutton}{\ocg@hide@buttonfalse}
-\newif\ifocgtools@noocg\ocgtools@noocgfalse
-\DeclareOption{noocg}{\ocgtools@noocgtrue}
\def\ocgtools@progressmsg{\lower \layerVshift\hbox to 0 pt{ %space
\textField[\V{OCGtools: processing OCG's ...}\BG{1}
\textColor{1 0 0} \textSize{10}]%
@@ -61,14 +67,48 @@
\DeclareOption{mouseover}{\@ocgtools@mouseovertrue \@ocgtools@minimouseovertrue}
\newif\if@ocgtools@pageclose \@ocgtools@pageclosetrue
\DeclareOption{nopageclose}{\@ocgtools@pageclosefalse}
+\newif\if@ocgtools@inactive\@ocgtools@inactivefalse
+\DeclareOption{inactive}{\@ocgtools@inactivetrue}
+\DeclareOption{noocg}{\@ocgtools@inactivetrue}
+\newif\if@ocgtools@active\@ocgtools@activefalse
+\DeclareOption{active}{\@ocgtools@activetrue}
+
\ProcessOptions
+\if@ocgtools@active\@ocgtools@inactivefalse\fi
+\newdimen\layerHshift \layerHshift=-1in
+\newdimen\layerVshift \layerVshift=0pt
+
+\if@ocgtools@inactive
+ \newcommand\ocgpicture[2][]{\leavevmode\includegraphics[#1]{#2}}
+ \newcommand\ocgtext[3][0pt]{\leavevmode #2}
+ \newcommand\ocgtoolsplacepicture[3]{}
+ \newcommand\ocgtoolsplacetext[3]{}
+ \newcommand\ocgtoolsplaceminitext[7]{}
+ \newcommand\ocgminitext[3][0pt]{\leavevmode #2}%
+ \let\ocgminitextlt\ocgminitext
+ \let\ocgminitextrt\ocgminitext
+ \let\ocgminitextlb\ocgminitext
+ \let\ocgminitextrb\ocgminitext
+ \PackageWarning{ocgtools}{Ocgtools inactive}%
+\expandafter\endinput\fi
+
\def\ocgtools@JS#1{\JS{DirtyBeforeOCGtools=this.dirty; #1
this.dirty=DirtyBeforeOCGtools;}}
+\@ifpackageloaded{fancytooltips}{%
+ \let\TooltipPageopencloseJS\relax
+ \ifx\fancytooltips@pdfpageattrJS\undefined
+ \def\@ocgtools@fancytooltips{var DirtyBeforeCloseTooltip=this.dirty;
+ CloseTooltips(); this.dirty=DirtyBeforeCloseTooltip;}
+ \else
+ \let\@ocgtools@fancytooltips\fancytooltips@pdfpageattrJS
+ \fi
+ }{\def\@ocgtools@fancytooltips{}}
+
\edef\ocgtools@pdfpageattr{
/AA << /O << /S /JavaScript /JS
(
- try{
+ if (typeof(ocgtoolsOCGs)!="undefined"){
var temp = ocgtoolsOCGs.length;
\if@ocgtools@pageclose
for(var i=0; ocgtoolsOCGs && i<ocgtoolsOCGs.length;i++)
@@ -77,7 +117,7 @@
}
\fi
}
- catch (e){
+ else {
app.focusRect = false;
var DirtyBeforeOCGtools=this.dirty;
var iniocgtoolsOCGs = this.getOCGs();
@@ -103,6 +143,7 @@
this.getField("OcgtoolsBtn.HideButton.main").hidden = true;
this.dirty=false;
\fi
+ \@ocgtools@fancytooltips
)
>> >>
}
@@ -120,17 +161,14 @@
\newskip\ocgtools@bottom@skip
\newdimen\ocgtools@maxheight
\newdimen\ocgtools@maxwidth
-\newdimen\layerHshift \layerHshift=0pt
-\newdimen\layerVshift \layerVshift=0pt
-\ifx\@Rightmargin\undefined\else
- \layerVshift=3pt
-\fi
-\ifx\PDFSCR@Warning\undefined\else
- \layerVshift=\@Bottommargin
-\fi
+\def\ocgtools@save@position{\pdfsavepos
+\write\@auxout{\string\global\string\advance\string \layerVshift \the\pdflastypos sp\string\relax}%
+\write\@auxout{\string\global\string\advance\string \layerHshift \the\pdflastxpos sp\string\relax}%
+\global\let\ocgtools@save@position\relax
+}
\newtoks\ocgtools@layer@toks
-\ocgtools@layer@toks{}
+\ocgtools@layer@toks{\ocg@place@text{0}{1}{5cm}}
\newbox\ocgtools@box@a
\newbox\ocgtools@box@b
\newif\ifocg@page@contains@layer
@@ -138,8 +176,10 @@
\let\ocgtools@shipoutstart@hook\relax
\let\ocgtools@shipoutend@hook\relax
\AtBeginShipout{%
+\expandafter\global\expandafter\pdfpageattr\expandafter{\ocgtools@pdfpageattr}
\setbox\AtBeginShipoutBox=\hbox{%
\ocgtools@shipoutstart@hook
+\ocgtools@save@position
\hbox to 0 pt{\box\AtBeginShipoutBox\hss}\kern -1in\kern \layerHshift
\ocg@page@contains@layerfalse
\lower \layerVshift \hbox{\the\ocgtools@layer@toks}%
@@ -154,17 +194,20 @@
\kern 1in \kern -\layerHshift%
}%
}
+\ifx\ocgtools@AfterHideBtn\undefined\def\ocgtools@AfterHideBtn{}\fi
\def\ocgtools@HideBtn{\pushButton[\W{0}\BG{}\S{S}\BC{}\H{N}\F{\FHidden}\A{\ocgtools@JS{
for(var i=0; ocgtoolsOCGs && i<ocgtoolsOCGs.length;i++)
{
ocgtoolsOCGs[i].state = false;
}
\ifocg@hide@button this.getField("OcgtoolsBtn.HideButton").hidden = true; \fi
+ \ocgtools@AfterHideBtn
}}]{OcgtoolsBtn.HideButton.main}{\paperwidth}{\paperheight}}
+\ifx\ocgtools@AfterHideMiniLayer\undefined\def\ocgtools@AfterHideMiniLayer{}\fi
\newcommand\ocgtools@HideMiniLayer[1]
-{\setbox\ocgtools@box@a=\hbox{{\color{red}\ocgclosechar}}%
+{\setbox\ocgtools@box@a=\hbox{{\ocgclosechar}}%
\hbox to \wd\ocgtools@box@a%
-{\hbox{{\color{red}\ocgclosechar}}\hss%
+{\hbox{{\ocgclosechar}}\hss%
\hbox{\pushButton[\W{0}\S{S}\BG{}\BC{}\H{N}%
\F{\FHidden}\A{\ocgtools@JS{
for(var i=0; ocgtoolsOCGs && i<ocgtoolsOCGs.length;i++)
@@ -173,12 +216,14 @@
ocgtoolsOCGs[i].state = false;
}
this.getField("OcgtoolsBtn.HideButton.mini.#1").hidden = true;
+ \ocgtools@AfterHideMiniLayer
}}]%
{OcgtoolsBtn.HideButton.mini.#1}{\wd\ocgtools@box@a}{\ht\ocgtools@box@a}}}}
+\ifx\ocgtools@AfterHideLayers\undefined\def\ocgtools@AfterHideLayers{}\fi
\newcommand\ocgtools@HideLayers[1]{%
-\setbox\ocgtools@box@a=\hbox{{\color{red}\ocgclosechar}}%
+\setbox\ocgtools@box@a=\hbox{{\ocgclosechar}}%
\hbox to \wd\ocgtools@box@a%
-{\hbox{{\color{red}\ocgclosechar}}\hss%
+{\hbox{{\ocgclosechar}}\hss%
\hbox{\pushButton[\W{0}\S{S}\BG{}\BC{}\H{N}%
\F{\FHidden}\A{\ocgtools@JS{
for(var i=0; ocgtoolsOCGs && i<ocgtoolsOCGs.length;i++)
@@ -188,6 +233,7 @@
\ifocg@hide@button
this.getField("OcgtoolsBtn.HideButton.main").hidden = true;
\fi
+ \ocgtools@AfterHideLayers
}}]%
{OcgtoolsBtn.HideButton.corner.#1}{\wd\ocgtools@box@a}{\ht\ocgtools@box@a}}}}
\newcommand{\ocgtools@ToggleLayer}[2]{%
@@ -305,18 +351,13 @@
\def\posFile{\jobname.pos}
\def\posOpen{\openout\posHandle=\posFile}
\def\posClose{\closeout\posHandle}
-\ifocgtools@noocg
-\else
\AtBeginDocument{\InputIfFileExists{\posFile}{}{}%
\ocgtools@maxheight=0.9\paperheight
\ocgtools@maxwidth=0.9\paperwidth
\expandafter\global\expandafter\def\csname ocgtools@textcontent@0\endcsname
-{{\color{red}\bfseries\ocgtools@msg}}
-\expandafter\ocgtools@layer@toks\expandafter{\the\ocgtools@layer@toks
-\ocg@place@text{0}{1}{5cm}}
+{{\color{red}\bfseries\ocgtools@msg}}%
\posOpen}
\AtEndDocument{\posClose}
-\fi
\newcommand\ocgpicture[2][]{%
\global\advance\ocgtools@layercount by 1%
@@ -327,40 +368,71 @@
\the\ocgtools@layercount}{\thepage}{#2}}%
}
+\define@key{ocg@key}{width}[0pt]{\def\ocgt@@ls@width{#1}}
+\define@key{ocg@key}{background}[ocgpaper]{\def\ocgt@@ls@bg{#1}}
+\define@key{ocg@key}{bg}[ocgpaper]{\def\ocgt@@ls@bg{#1}}
+\define@key{ocg@key}{color}[ocgfontcolor]{\def\ocgt@@ls@fg{#1}}
+\define@key{ocg@key}{fg}[ocgfontcolor]{\def\ocgt@@ls@fg{#1}}
+
+\newtoks\ocg@pdflastxpos\ocg@pdflastxpos{\the\pdflastxpos}
+\newtoks\ocg@pdflastypos\ocg@pdflastypos{\the\pdflastypos}
+\newtoks\ocg@pagetoks\ocg@pagetoks{\thepage}
+
+\def\ocgtools@setdefault{\def\ocgt@@ls@bg{\defaultocgpapercolor}%
+\def\ocgt@@ls@fg{\defaultocgfontcolor}%
+\def\ocgt@@ls@width{0pt}}
+
\newcommand\ocgtext[3][0pt]{%
+\ocgtools@setdefault
+\setkeys*{ocg@key}{#1}%
+\ifx\XKV@rm\empty\setkeys{ocg@key}{#1}\else\setkeys{ocg@key}{width=#1}\fi
\global\advance\ocgtools@layercount by 1%
\ocgtools@ToggleLayer{\the\ocgtools@layercount}%
{\leavevmode{\ocgtextstart #2\ocgtextend}}%
-\expandafter\write\expandafter\posHandle\expandafter{%
-\expandafter\string\expandafter\ocgtoolsplacetext\expandafter{%
-\the\ocgtools@layercount}{\thepage}{#1}}%
+\edef\ocgtools@act{\write\posHandle{\noexpand\string\noexpand\ocgtoolsplacetext{\the\ocgtools@layercount}{\the\ocg@pagetoks}{width=\ocgt@@ls@width,bg=\ocgt@@ls@bg,fg=\ocgt@@ls@fg}}}%
+\ocgtools@act
\expandafter\global\expandafter\def
\csname ocgtools@textcontent@\the\ocgtools@layercount\endcsname{#3}%
}
\newcommand\ocgminitextlt[3][0pt]{%
-\ocg@minitext@lefttrue\do@ocg@minitext{#1}{#2}{#3}{lt}}%
+\ocg@minitext@bottomfalse\ocg@minitext@lefttrue
+\do@ocg@minitext{#1}{#2}{#3}{lt}}%
\newcommand\ocgminitextrt[3][0pt]{%
-\ocg@minitext@leftfalse\do@ocg@minitext{#1}{#2}{#3}{rt}}%
+\ocg@minitext@bottomfalse\ocg@minitext@leftfalse
+\do@ocg@minitext{#1}{#2}{#3}{rt}}%
\newcommand\ocgminitextlb[3][0pt]{%
-\ocg@minitext@lefttrue\do@ocg@minitext{#1}{#2}{#3}{lb}}%
+\ocg@minitext@bottomtrue\ocg@minitext@lefttrue
+\do@ocg@minitext{#1}{#2}{#3}{lb}}%
\newcommand\ocgminitextrb[3][0pt]{%
-\ocg@minitext@leftfalse\do@ocg@minitext{#1}{#2}{#3}{rb}}%
+\ocg@minitext@bottomtrue\ocg@minitext@leftfalse
+\do@ocg@minitext{#1}{#2}{#3}{rb}}%
\let\ocgminitext\ocgminitextrt
\long\def\do@ocg@minitext#1#2#3#4{%
+\ocgtools@setdefault
+\setkeys*{ocg@key}{#1}%
+\ifx\XKV@rm\empty\setkeys{ocg@key}{#1}\else\setkeys{ocg@key}{width=#1}\fi
\global\advance\ocgtools@layercount by 1\relax%
\leavevmode
\ifocg@minitext@left
- \vbox to 0 pt{\kern 0.5\baselineskip\hbox to 0 pt{\hss\pdfsavepos}\vss}%
+ \ifocg@minitext@bottom
+ \vbox to 0 pt{\kern 0.7\baselineskip\pdfsavepos\vss}%
+ \else
+ \vbox to 0 pt{\vss\pdfsavepos\kern 0.7\baselineskip}%
+ \fi
\fi
\ocgtools@ToggleMiniLayer{\the\ocgtools@layercount}%
{{\ocgtextstart #2\ocgtextend}}%
-\ifocg@minitext@left\else\pdfsavepos\fi
-\expandafter\write\expandafter\posHandle\expandafter{%
-\expandafter\string\expandafter\ocgtoolsplaceminitext\expandafter
-{\the\ocgtools@layercount}{\thepage}{\the\pdflastxpos}%
-{\the\pdflastypos}{}{#1}{#4}}%
+\ifocg@minitext@left\else
+ \ifocg@minitext@bottom
+ \vbox to 0 pt{\kern 0.7\baselineskip\pdfsavepos\vss}%
+ \else
+ \vbox to 0 pt{\vss\pdfsavepos\kern 0.7\baselineskip}%
+ \fi
+\fi
+\edef\ocgtools@act{\write\posHandle{\noexpand\string\noexpand\ocgtoolsplaceminitext{\the\ocgtools@layercount}{\the\ocg@pagetoks}{\the\ocg@pdflastxpos}{\the\ocg@pdflastypos}{}{width=\ocgt@@ls@width,bg=\ocgt@@ls@bg,fg=\ocgt@@ls@fg}{#4}}}%
+\ocgtools@act
\expandafter\global\expandafter\def
\csname ocgtools@minitextcontent@\the\ocgtools@layercount\endcsname{#3}%
}%
@@ -432,30 +504,39 @@
\fi
}
+\let\ocgtools@pict@envelope\relax
\def\ocgtools@drawpicture#1#2{\vbox to \paperheight{\vbox to 0 pt{{%
\ocgtools@transparent\color{ocgbg}%
\hrule width \paperwidth height \paperheight}\vss}\vss
\hbox to \paperwidth{\hss
-\setbox\ocgtools@box@a=\hbox{\includegraphics[height=\ocgtools@maxheight]{#1}}%
+\setbox\ocgtools@box@a=\hbox{\ocgtools@pict@envelope{%
+ \includegraphics[height=\ocgtools@maxheight]{#1}}}%
\ifdim\wd\ocgtools@box@a>\ocgtools@maxwidth
- \includegraphics[width=\ocgtools@maxwidth]{#1}\else \box\ocgtools@box@a
+ \ocgtools@pict@envelope{\includegraphics[width=\ocgtools@maxwidth]{#1}}%
+ \else \box\ocgtools@box@a
\fi
\hss}%
\vss
\hbox to \paperwidth {\hss\ocgtools@HideLayers{#2}}}}
\newdimen\ocg@textdimen
-
-\long\def\ocgtools@drawtext#1#2#3{\vbox to \paperheight{%
+\let\ocgtools@text@envelope\relax
+\long\def\ocgtools@drawtext#1#2#3{%
+\ocgtools@setdefault
+\setkeys*{ocg@key}{#1}%
+\ifx\XKV@rm\empty\setkeys{ocg@key}{#1}\else\setkeys{ocg@key}{width=#1}\fi
+\vbox to \paperheight{%
\vbox to 0 pt{{\ocgtools@transparent\color{ocgbg}%
\hrule width \paperwidth height \paperheight}\vss}\vss\hbox to \paperwidth
{\hss
-\ocg@textdimen=#1
-\ifdim\ocg@textdimen=0pt
- \setbox\ocgtools@box@a=\hbox{\colorbox{ocgpaper}{#2}}%
+\ifdim\ocgt@@ls@width=0pt
+ \setbox\ocgtools@box@a=\hbox{\expandafter\colorbox\expandafter{\ocgt@@ls@bg}%
+ {\expandafter\color\expandafter{\ocgt@@ls@fg}\ocgtools@text@envelope{#2}}}%
\else
- \setbox\ocgtools@box@a=\hbox{\colorbox{ocgpaper}%
- {\vbox{\hsize=#1\relax\rightskip 0 pt plus 1 fil\relax #2}}}%
+ \setbox\ocgtools@box@a=\hbox{\expandafter\colorbox{\expandafter\ocgt@@ls@bg}%
+ {\vbox{\hsize=\ocgt@@ls@width\relax\linewidth=\ocgt@@ls@width\relax
+ \rightskip 0 pt plus 1 fil\relax
+ \expandafter\color\expandafter{\ocgt@@ls@fg}\ocgtools@text@envelope{#2}}}}%
\fi
\setbox\ocgtools@box@b\hbox{\resizebox{!}{\ocgtools@maxheight}{\copy\ocgtools@box@a}}%
\ifdim\wd\ocgtools@box@b>\ocgtools@maxwidth
@@ -465,15 +546,25 @@
\fi
\hss}%
\vss
-\hbox to \paperwidth {\hss\ocgtools@HideLayers{#3}}}}
+\hbox to \paperwidth {\hss\ocgtools@HideLayers{#3}}%
+}%
+}
\def\ocg@empty{}
-\newcommand\ocgtools@drawminitext[3]{\ocg@textdimen=#1
-\ifdim\ocg@textdimen=0pt
- \setbox\ocgtools@box@a=\hbox{\colorbox{ocgpaper}{#2\ }}%
-\else \setbox\ocgtools@box@a=\hbox{\colorbox{ocgpaper}%
- {\vbox{\hsize=#1\relax\rightskip 0 pt plus 1 fil\relax #2}}}%
+\let\ocgtools@minitext@envelope\relax
+\newcommand\ocgtools@drawminitext[3]{%
+\@ocgtools@insideminilayertrue
+\ocgtools@setdefault
+\setkeys*{ocg@key}{#1}%
+\ifx\XKV@rm\empty\setkeys{ocg@key}{#1}\else\setkeys{ocg@key}{width=#1}\fi
+\ifdim\ocgt@@ls@width=0pt
+ \setbox\ocgtools@box@a=\hbox{\colorbox{\ocgt@@ls@bg}{\expandafter\color
+ \expandafter{\ocgt@@ls@fg}\ocgtools@minitext@envelope{#2}\ }}%
+\else \setbox\ocgtools@box@a=\hbox{\colorbox{\ocgt@@ls@bg}%
+ {\vbox{\hsize=\ocgt@@ls@width\relax\linewidth=\ocgt@@ls@width\relax
+ \rightskip 0 pt plus 1 fil\relax
+ \expandafter\color\expandafter{\ocgt@@ls@fg}\ocgtools@minitext@envelope{#2}}}}%
\fi
\def\temp{#3}%
\ifx\temp\ocg@empty
@@ -483,17 +574,9 @@
\vbox to 0 pt{\hbox to 0 pt{\hss
\ocgtools@HideMiniLayer{#3}}\vss}}%
\fi
+\@ocgtools@insideminilayerfalse
}
-\ifocgtools@noocg
- \renewcommand\ocgpicture[2][]{\leavevmode\includegraphics[#1]{#2}}
- \renewcommand\ocgtext[3][0pt]{\leavevmode #2}
- \long\def\do@ocg@minitext#1#2#3#4{\leavevmode #2}%
- \renewcommand\ocgtoolsplacepicture[3]{}
- \renewcommand\ocgtoolsplacetext[3]{}
- \renewcommand\ocgtoolsplaceminitext[7]{}
-\fi
-
\endinput
%%
%% End of file `ocgtools.sty'.