diff options
author | Karl Berry <karl@freefriends.org> | 2012-09-28 22:49:39 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-09-28 22:49:39 +0000 |
commit | 02339c48110d49c5009d1553b3df1629e77e53cc (patch) | |
tree | 782c829c3c160327103800c54a9a9c6421cbce59 /Master/texmf-dist/tex/latex/ocgx | |
parent | 0ed5ceced7eb70c664f715399d598f21d542e0c9 (diff) |
new tikz package ocgx (28sep12)
git-svn-id: svn://tug.org/texlive/trunk@27845 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/ocgx')
-rw-r--r-- | Master/texmf-dist/tex/latex/ocgx/ocgx.sty | 111 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/ocgx/tikzlibraryocgx.code.tex | 120 |
2 files changed, 231 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/ocgx/ocgx.sty b/Master/texmf-dist/tex/latex/ocgx/ocgx.sty new file mode 100644 index 00000000000..5df7a1bb52c --- /dev/null +++ b/Master/texmf-dist/tex/latex/ocgx/ocgx.sty @@ -0,0 +1,111 @@ +% Copyright (C) 2012 by Paul Gaborit +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. + +\NeedsTeXFormat{LaTeX2e}[1994/06/01] +\def\ocgxversion{0.2} +\ProvidesPackage{ocgx}[2012/09/27 v\ocgxversion{} manage OCG in PDF document] +\RequirePackage{ocg} + +%%%% small patch to ocg.sty %%%% +% called from the aux file +\def\@ocg@makeknown#1#2#3{% #1: OCG name, #2: OC id, #3: on/off + \@ifundefined{OCG#2}{% + \message{OCG#2}% + \expandafter\gdef\csname OCG#2\endcsname{#1}% + \immediate\pdfobj{<< /Type /OCG /Name (#1) >>}% new ocg + \xdef\@ocg@curocg{\the\pdflastobj\space 0 R}% reference to id + % *** PATCH *** + \expandafter\xdef\csname OCGpdfobj#2\endcsname{\@ocg@curocg} + % *** END OF PATCH *** + \xdef\@ocg@ocgs{\@ocg@ocgs\space\@ocg@curocg}% list of all OCGs in "first defined" order + \ifnum#3=1 %on + \xdef\@ocg@ocgson{\@ocg@ocgson\space\@ocg@curocg}% list of all default-on OCGs + \else% + \xdef\@ocg@ocgsoff{\@ocg@ocgsoff\space\@ocg@curocg}% list of all default-off OCGs + \fi% + \xdef\@ocg@layersnames{% + \@ocg@layersnames\space/OC#2\space\@ocg@curocg% name-to-id mapping + }% + }{% + \message{OCG#2 reopened}% + % layer reopened + }% +} +%%%% END OF PATCH %%%% + +\csname ocgx@end:ENDOFOCGS\endcsname +\def\ocgx@listOCG#1 {% + \unless\ifcsname ocgx@end:#1\endcsname + \ifcsname OCGpdfobj#1\endcsname + \expandafter\def\expandafter\ocgx@list\expandafter{% + \ocgx@list + \csname OCGpdfobj#1\endcsname\space}% + \fi% + \expandafter\ocgx@listOCG + \fi +} + +\long\def\switchocg#1#2{% + \def\ocgx@list{}% + \ocgx@listOCG#1 ENDOFOCGS % + \leavevmode% + \pdfstartlink user {% + /Subtype /Link + /A << /S/SetOCGState /State [/Toggle \ocgx@list] >> + /Border [0 0 0] + }% + #2\pdfendlink% +} + +\long\def\showocg#1#2{% + \def\ocgx@list{}% + \ocgx@listOCG#1 ENDOFOCGS % + \leavevmode% + \pdfstartlink user {% + /Subtype/Link + /A << /S/SetOCGState + /State [/ON \ocgx@list] >> + /Border [0 0 0] + }% + #2\pdfendlink% +} + +\long\def\hideocg#1#2{% + \def\ocgx@list{}% + \ocgx@listOCG#1 ENDOFOCGS % + \leavevmode% + \pdfstartlink user {% + /Subtype/Link + /A << /S/SetOCGState + /State [/OFF \ocgx@list] >> + /Border [0 0 0] + }% + #2\pdfendlink% +} + +\long\def\actionsocg#1#2#3#4{% + \def\ocgx@list{}% + \ocgx@listOCG#1 ENDOFOCGS % + \edef\ocgx@toswitch{\ocgx@list}% + % + \def\ocgx@list{}% + \ocgx@listOCG#1 ENDOFOCGS % + \edef\ocgx@toshow{\ocgx@list}% + % + \def\ocgx@list{}% + \ocgx@listOCG#1 ENDOFOCGS % + \edef\ocgx@tohide{\ocgx@list}% + % + \leavevmode% + \pdfstartlink user{% + /Subtype/Link + /A << /S/SetOCGState + /State [/Toggle \ocgx@toswitch /ON \ocgx@toshow /OFF \ocgx@tohide] >> + /Border [0 0 0] + }% + #4\pdfendlink% +} diff --git a/Master/texmf-dist/tex/latex/ocgx/tikzlibraryocgx.code.tex b/Master/texmf-dist/tex/latex/ocgx/tikzlibraryocgx.code.tex new file mode 100644 index 00000000000..0ad0b30f912 --- /dev/null +++ b/Master/texmf-dist/tex/latex/ocgx/tikzlibraryocgx.code.tex @@ -0,0 +1,120 @@ +% Copyright (C) 2012 by Paul Gaborit +% +% This file may be distributed and/or modified +% +% 1. under the LaTeX Project Public License and/or +% 2. under the GNU Public License. + +\RequirePackage{ocgx} + +\makeatletter +\tikzset{ + ocg/.style={ocg/.cd,#1,/tikz/.cd}, + ocg={ + % parameters + name/.store in=\ocgx@name, + visibity/.store in=\ocgx@visibility, + status/.is choice, + status/visible/.style={visibity=1}, + status/invisible/.style={visibity=0}, + % default values + name=, + status=visible, + % ref + ref/.style={ + /tikz/execute at begin scope={\ocg{\ocgx@name}{#1}{\ocgx@visibility}}, + /tikz/execute at end scope={\endocg}, + }, + }, + switch ocg/.style={ + postaction={ + path picture={ + \path let + \p1 = (path picture bounding box.south west), + \p2 = (path picture bounding box.north east), + \p3 = (\x2-\x1,\y2-\y1) + in + (path picture bounding box.center) + node[inner sep=0pt,anchor=center,outer sep=0pt] + {\switchocg{#1}{\phantom{\rule{\x3}{\y3}}}}; + } + }, + }, + switch ocg with mark on/.style 2 args={ + postaction={ + path picture={ + \begin{ocg}{#1}{#1}{1} + \draw + (path picture bounding box.south west) + -- + (path picture bounding box.north east) + (path picture bounding box.south east) + -- + (path picture bounding box.north west) + ; + \end{ocg} + }, + switch ocg={#1 #2}, + } + }, + switch ocg with mark off/.style 2 args={ + postaction={ + path picture={ + \begin{ocg}{#1}{#1}{0} + \draw + (path picture bounding box.south west) + -- + (path picture bounding box.north east) + (path picture bounding box.south east) + -- + (path picture bounding box.north west) + ; + \end{ocg} + }, + switch ocg={#1 #2}, + } + }, + show ocg/.style={ + postaction={ + path picture={ + \path let + \p1 = (path picture bounding box.south west), + \p2 = (path picture bounding box.north east), + \p3 = (\x2-\x1,\y2-\y1) + in + (path picture bounding box.center) + node[inner sep=0pt,anchor=center] + {\showocg{#1}{\phantom{\rule{\x3}{\y3}}}}; + }, + }, + }, + hide ocg/.style={ + postaction={ + path picture={ + \path let + \p1 = (path picture bounding box.south west), + \p2 = (path picture bounding box.north east), + \p3 = (\x2-\x1,\y2-\y1) + in + (path picture bounding box.center) + node[inner sep=0pt,anchor=center] + {\hideocg{#1}{\phantom{\rule{\x3}{\y3}}}}; + }, + }, + }, + actions ocg/.style n args={3}{ + postaction={ + path picture={ + \path let + \p1 = (path picture bounding box.south west), + \p2 = (path picture bounding box.north east), + \p3 = (\x2-\x1,\y2-\y1) + in + (path picture bounding box.center) + node[inner sep=0pt,anchor=center] + {\actionsocg{#1}{#2}{#3}{\phantom{\rule{\x3}{\y3}}}}; + }, + }, + }, +} +\makeatother |