summaryrefslogtreecommitdiff
path: root/texmf-dist/tex/latex/aeb-pro/create_icon.def
blob: f1b6e7b5dbb8768ee465937750f097957af41bf9 (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
%%
%% This is file `create_icon.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% aeb_pro.dtx  (with options: `copyright,createicon')
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% aeb_pro.sty package,                                 %%
%% Copyright (C) 2006--2019  D. P. Story                %%
%%   dpstory@acrotex.net                                %%
%%                                                      %%
%% This program can redistributed and/or modified under %%
%% the terms of the LaTeX Project Public License        %%
%% Distributed from CTAN archives in directory          %%
%% macros/latex/base/lppl.txt; either version 1.2 of    %%
%% the License, or (at your option) any later version.  %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{docassembly}{%
\execJS{docassembly}
}{\endexecJS}
\let\ap@mrk\@empty
\def\ap@gobtocomma#1,{}
\providecommand\chngDocObjectTo[2]{%
    \def#1##1\ap@mrk{#2,\ap@gobtocomma##1}}
\def\ap@TF{aebTrustedFunctions}
\def\theDocObject{this}
\providecommand\DeclareJSHelper[2]{%
    \def#1##1({\ap@TF(##1\theDocObject,#2,\ap@mrk}}
\DeclareJSHelper{\importIcon}{aebImportIcon}
\let\predocassemJS\@empty
\def\aeb@image@cnt{0}
\define@key{importIcons}{name}[]{\def\importIcons@name{#1}}
\define@key{importIcons}{path}[]{\def\importIcons@path{#1}}
\define@key{importIcons}{page}[]{\def\importIcons@page{#1}}
\define@key{importIcons}{placement}[]{\def\importIcons@placement{#1}}
\define@boolkey{importIcons}{embedonly}[true]{}
\define@key{importIcons}{firstpage}[]{\def\importIcons@firstpage{#1}}
\define@key{importIcons}{lastpage}[]{\def\importIcons@lastpage{#1}}
\newcommand{\aebp@getFace}[1][0]{%
    \def\importIcons@face{#1}\aebp@getPlacement}
\def\aebp@getPlacement#1\@nil{\def\importIcons@fieldname{#1}%
    \expandafter\ap@strpspcs\importIcons@fieldname\@nil
    \edef\importIcons@fieldname{\to@nilarg}%
}
\newcommand{\declareMultiImages}[1]{%
    \edef\@tforExp{\noexpand\@tfor\noexpand\@dipArgs:=#1}%
    \@tforExp\do{%
        \expandafter\declareImageAndPlacement
        \expandafter{\@dipArgs}%
    }%
}
\newcommand{\declareImageAndPlacement}[1]{%
    \edef\@tempexp{\noexpand\setkeys{importIcons}{name,path,page,%
        placement,embedonly=false,#1}}\@tempexp
    \ifx\importIcons@name\@empty{\count0=\aeb@image@cnt
    \advance\count0by1\relax\xdef\aeb@image@cnt{\the\count0}}%
    \edef\importIcons@name{aebImage\aeb@image@cnt}\fi
    \ifx\importIcons@path\@empty
        \PackageError{aeb_pro}{The `path' key is required}
            {Please give the path of the icon.}\fi
    \ifx\importIcons@placement\@empty\ifKV@importIcons@embedonly\else
        \PackageWarningNoLine{aeb_pro}{%
        The `placement' key was not found for the\MessageBreak
        image named "\importIcons@name".\MessageBreak
        Specify this key, or insert the image manually in\MessageBreak
        the docassembly environment.}\fi\fi
    \xdef\predocassemJS{\predocassemJS
            var retn=\importIcon({cName:"\importIcons@name",%
            cDIPath:"\importIcons@path"%
            \ifx\importIcons@page\@empty\else,%
            nPage:\importIcons@page\fi});^^J%
        if ( retn==-1 ) console.println("The file
        \string\"\importIcons@path\string\" could not be opened.");^^J%
        if ( retn==-2 ) console.println("Selected page
        (page=\importIcons@page) for \string\"\importIcons@path\string\"
        is invalid.");^^J}%
    \ifx\importIcons@placement\@empty\else
        \@for\@fieldname:=\importIcons@placement\do{%
            \expandafter\aebp@getFace\@fieldname\@nil
            \xdef\predocassemJS{\predocassemJS
            var f = this.getField("\importIcons@fieldname");^^J%
            if ( f == null ) console.println("The field
                \string\"\importIcons@fieldname\string\"
                    does not exist.");^^J%
            try { f.buttonSetIcon(this.getIcon("\importIcons@name"),%
                \importIcons@face); }
            catch(e){};^^J}%
        }%
    \fi
}
\@onlypreamble\declareImageAndPlacement
\newcommand{\iconNameI}[1]{\def\IconNameI(##1){#1}}
\iconNameI{#1+"."+i}
\@onlypreamble\iconNameI
\newcommand{\embedMultiPageImages}[1]{%
    \setkeys{importIcons}{name,path,page,placement,%
        firstpage,lastpage,#1}%
    \ifx\importIcons@firstpage\@empty
        \def\importIcons@firstpage{1}\else
        {\count0=\importIcons@firstpage}\fi
    \ifx\importIcons@lastpage\@empty
        \def\importIcons@lastpage{this.numPages}\else
        {\count0=\importIcons@lastpage}\fi
    \ifx\importIcons@name\@empty
        \PackageError{aeb_pro}{The `name' key is required}
        {Please give the icon family a name.}\fi
    \ifx\importIcons@path\@empty
        \PackageError{aeb_pro}{The `path' key is required}
            {Please give the path of the icon.}\fi
    \def\r{^^J}\def\t{\space\space\space\space}%
    \let\predocassemJSPlace\@empty
    \ifx\importIcons@placement\@empty\else
        \@for\@fieldname:=\importIcons@placement\do{%
            \expandafter\aebp@getFace\@fieldname\@nil
            \edef\predocassemJSPlace{\predocassemJSPlace\t
            var f = this.getField("\importIcons@fieldname."+i);\r\t
            if ( f == null ) console.println("The field
                \string\"\importIcons@fieldname."+i+"\string\"
                    does not exist.");\r\t
            try { f.buttonSetIcon(this.getIcon(%
\IconNameI("\importIcons@name")),%
                \importIcons@face); }
            catch(e){};\r}%
        }%
    \fi
    \xdef\predocassemJS{\predocassemJS
        var l=\importIcons@lastpage-\importIcons@firstpage+1;\r
        for (var i=0; i<l; i++) {\r\t
            var retn=\importIcon({%
                cName:\IconNameI("\importIcons@name"),%
                cDIPath:"\importIcons@path",%
                nPage:\importIcons@firstpage+i-1});\r\t
            if ( retn==-1 ) console.println("The file
            \string\"\importIcons@path\string\" could not
                be opened.");\r\t
            if ( retn==-2 ) console.println("Selected page
            (page="+(i+1)+") for \string\"\importIcons@path\string\"
            is invalid.");\r
            \predocassemJSPlace
        }\r
        var oIcon=this.getIcon("nullIcon");\r
        if ( oIcon == null )
            this.addIcon("nullIcon", this.createIcon("", 0, 0));\r
    }%
}
\@onlypreamble\embedMultiPageImages
\newcommand{\insertPreDocAssembly}{\predocassemJS}
\let\importAndSetImages\insertPreDocAssembly
\newcommand{\placeImage}[4][]{\pushButton[%
    \BC{}\BG{}\S{S}\Ff{\FfReadOnly}\autoCenter{n}\FB{true}
    #1\I{null}\TP{1}]{#2}{#3}{#4}}
\endinput
%%
%% End of file `create_icon.def'.