1#!/usr/bin/env python
2
3from plasTeX import Command, Environment
4from plasTeX.Base import textbf, textit, textsl, textrm, textsf
5from plasTeX.Base import List, label, newcommand, newenvironment
6from plasTeX.Base import renewcommand, renewenvironment
7from plasTeX.Base import itemize, enumerate_, description
8from plasTeX.Base import part, section, subsection, subsubsection
9from plasTeX.Base import tableofcontents, thebibliography, appendix
10from plasTeX.Base import abstract, verse, quotation, quote, footnote
11from plasTeX.Packages.color import color
12from plasTeX.Packages.graphicx import includegraphics
13from plasTeX.Packages.hyperref import hypertarget, hyperlink
14from plasTeX.Packages.article import *
15
16class frame(Command):
17    args = '< overlay > self'
18    subtitle = None
19
20    def invoke(self, tex):
21        # This macro can be an environment or a command each
22        # with different arguments.
23        if self.macroMode == Command.MODE_BEGIN or \
24           self.macroMode == Command.MODE_END:
25            f = self.ownerDocument.createElement('frameenv')
26            f.parentNode = self.parentNode
27            f.macroMode = self.macroMode
28            f.invoke(tex)
29            # Add to frames collection
30            if self.macroMode == Command.MODE_BEGIN:
31                f.addToFrames()
32            return [f]
33        # Add to frames collection
34        self.addToFrames()
35        return Command.invoke(self, tex)
36
37    def addToFrames(self):
38        """ Add this frame to the frame collection """
39        u = self.ownerDocument.userdata
40        frames = u.get('frames')
41        if frames is None:
42            frames = []
43            u['frames'] = frames
44        frames.append(self)
45
46class frameenv(Environment):
47    args = '< overlay > < defaultoverlay > [ options:dict ] { title } { subtitle }'
48    subtitle = None
49    forcePars = True
50
51    def addToFrames(self):
52        """ Add this frame to the frame collection """
53        u = self.ownerDocument.userdata
54        frames = u.get('frames')
55        if frames is None:
56            frames = []
57            u['frames'] = frames
58        frames.append(self)
59
60class frametitle(Command):
61    args = '< overlay > [ shorttitle ] self'
62    def invoke(self, tex):
63        Command.invoke(self, tex)
64        self.ownerDocument.userdata['frames'][-1].title = self
65
66class framesubtitle(Command):
67    args = '< overlay > self'
68    def invoke(self, tex):
69        Command.invoke(self, tex)
70        self.ownerDocument.userdata['frames'][-1].subtitle = self
71
72class setbeamertemplate(Command):
73    args = '< overlay > theme [ options ] [ suboptions ]'
74
75class setbeamersize(Command):
76    args = 'options:dict'
77
78class logo(Command):
79    args = '< overlay > self'
80
81class setbeamercolor(Command):
82    args = 'mode color'
83
84class pause(Command):
85    args = '[ number:int ]'
86
87class onslide(Command):
88    args = '*+ < overlay > { self }'
89
90class only(Command):
91    args = '< overlay > self < overlay2 >'
92
93class onlyenv(Environment):
94    args = '< overlay >'
95
96class uncover(Command):
97    args = '< overlay > self'
98
99class uncoverenv(Environment):
100    args = uncover.args
101
102class visible(Command):
103    args = '< overlay > self'
104
105class visibleenv(Environment):
106    args = visible.args
107
108class invisible(Command):
109    args = '< overlay > self'
110
111class invisibleenv(Environment):
112    args = invisible.args
113
114class alt(Command):
115    args = '< overlay > default alternative < overlay2 >'
116
117class altenv(Environment):
118    args = '< overlay > begin end alternatebegin alternate end < overlay2 >'
119
120class temporal(Command):
121    args = '< overlay > before default after'
122
123class alert(Command):
124    args = '< overlay > self'
125
126class overlayarea(Environment):
127    args = 'width height'
128
129class overprint(Environment):
130    args = 'width'
131
132List.item.args = '< alert >' + List.item.args + '< alert2 >'
133textbf.args = '< overlay >' + textbf.args
134textit.args = '< overlay >' + textit.args
135textsl.args = '< overlay >' + textsl.args
136textrm.args = '< overlay >' + textrm.args
137textsf.args = '< overlay >' + textsf.args
138color.args = '< overlay >' + color.args
139label.args = '< overlay >' + label.args
140includegraphics.args = '< overlay >' + includegraphics.args
141newcommand.args = '< overlay >' + newcommand.args
142renewcommand.args = '< overlay >' + renewcommand.args
143newenvironment.args = '< overlay >' + newenvironment.args
144renewenvironment.args = '< overlay >' + renewenvironment.args
145itemize.args = '[ overlay ]'
146enumerate_.args = '[ overlay ] [ template ]'
147description.args = '[ overlay ] [ longtext ]'
148section.args = '< overlay >' + section.args
149subsection.args = '< overlay >' + subsection.args
150subsubsection.args = '< overlay >' + subsubsection.args
151part.args = '< overlay >' + part.args
152thebibliography.bibitem.args = '< overlay >' + thebibliography.bibitem.args
153appendix.args = '< overlay >' + appendix.args
154hypertarget.args = '< overlay >' + hypertarget.args
155hyperlink.args = '< overlay >' + hyperlink.args + '< overlay2 >'
156tableofcontents.args = '[ options:dict ]' + tableofcontents.args
157abstract.args = '< overlay >' + abstract.args
158verse.args = '< overlay >' + verse.args
159quotation.args = '< overlay >' + quotation.args
160quote.args = '< overlay >' + quote.args
161footnote.args = '< overlay > [ options:dict ]' + footnote.args
162
163class resetcounteronoverlays(Command):
164    args = 'counter'
165
166class resetcountonoverlays(Command):
167    args = 'count'
168
169class action(Command):
170    args = '< action > self'
171
172class actionenv(Environment):
173    args = '< action >'
174
175class beamerdefaultoverlayspecification(Command):
176    args = 'overlay'
177
178class AtBeginSection(Command):
179    args = '[ special ] text'
180
181class AtBeginSubsection(AtBeginSection):
182    pass
183
184class AtBeginSubsubsection(AtBeginSection):
185    pass
186
187class partpage(Command):
188    pass
189
190class AtBeginPart(Command):
191    args = 'text'
192
193class lecture(Command):
194    args = '[ shorttitle ] title { label }'
195
196class includeonlylecture(Command):
197    args = 'label'
198
199class AtBeginLecture(Command):
200    args = 'text'
201
202class beamerbutton(Command):
203    args = 'self'
204
205class beamergotobutton(Command):
206    args = 'self'
207
208class beamerskipbutton(Command):
209    args = 'self'
210
211class beamerreturnbutton(Command):
212    args = 'self'
213
214class HyperlinkCommand(Command):
215    args = '< overlay > self < overlay2 >'
216
217class hyperlinkslideprev(HyperlinkCommand):
218    pass
219
220class hyperlinkslidenext(HyperlinkCommand):
221    pass
222
223class hyperlinkframestart(HyperlinkCommand):
224    pass
225
226class hyperlinkframeend(HyperlinkCommand):
227    pass
228
229class hyperlinkframestartnext(HyperlinkCommand):
230    pass
231
232class hyperlinkframeendprev(HyperlinkCommand):
233    pass
234
235class hyperlinkpresentationstart(HyperlinkCommand):
236    pass
237
238class hyperlinkpresentationend(HyperlinkCommand):
239    pass
240
241class hyperlinkappendixstart(HyperlinkCommand):
242    pass
243
244class hyperlinkappendixend(HyperlinkCommand):
245    pass
246
247class hyperlinkdocumentstart(HyperlinkCommand):
248    pass
249
250class hyperlinkdocumentend(HyperlinkCommand):
251    pass
252
253class againframe(Command):
254    args = '< overlay > [ default ] [ options:dict ] name'
255
256class framezoom(Command):
257    args = '< buttonoverlay > < zoomedoverlay > [ options:dict ] ( pos:list ) ( zoom:list )'
258
259class structure(Command):
260    args = '< overlay > self'
261
262class structureenv(Environment):
263    args = '< overlay >'
264
265class block(Environment):
266    args = '< action > title < action2 >'
267
268class alertblock(Environment):
269    args = '< action > title < action2 >'
270
271class exampleblock(Environment):
272    args = '< action > title < action2 >'
273
274#
275# Theorems
276#
277
278# theorem.args = '< action > [ text ] < action2 >'
279# corollary.args = '< action > [ text ] < action2 >'
280# definition.args = '< action > [ text ] < action2 >'
281# definitions.args = '< action > [ text ] < action2 >'
282# fact.args = '< action > [ text ] < action2 >'
283# example.args = '< action > [ text ] < action2 >'
284# examples.args = '< action > [ text ] < action2 >'
285
286class beamercolorbox(Environment):
287    args = '[ options:dict ] color'
288
289class beamerboxesrounded(Environment):
290    args = '[ options:dict ] title'
291
292class columns(Environment):
293    args = '[ options:dict ]'
294
295class column(Command):
296    args = '[ placement ] width'
297    def invoke(self, tex):
298        # This macro can be an environment or a command each
299        # with different arguments.
300        if self.macroMode == Command.MODE_BEGIN or \
301           self.macroMode == Command.MODE_END:
302            f = self.ownerDocument.createElement('columnenv')
303            f.parentNode = self.parentNode
304            f.macroMode = self.macroMode
305            res = f.invoke(tex)
306            if res is None:
307                res = [f]
308            return res
309        return Command.invoke(self, tex)
310
311class columnenv(Environment):
312    args = column.args
313
314class movie(Command):
315    args = '[ options:dict ] text filename:str'
316
317class hyperlinkmovie(Command):
318    args = '[ options:dict ] label text'
319
320class animate(Command):
321    args = '< overlay >'
322
323class animatevalue(Command):
324    args = '< interval > name start end'
325
326class multiinclude(Command):
327    args = '[ overlay ] [ options:dict ] filename:str'
328
329class sound(Command):
330    args = '[ options:dict ] text filename:str'
331
332class hyperlinksound(Command):
333    args = '[ options:dict ] label text'
334
335class hyperlinkmute(Command):
336    args = 'text'
337
338#
339# Transitions
340#
341
342class TransitionCommand(Command):
343    args = '< overlay > [ options:dict ]'
344
345class transblindshorizontal(TransitionCommand):
346    pass
347
348class transblindsvertical(TransitionCommand):
349    pass
350
351class transboxin(TransitionCommand):
352    pass
353
354class transboxout(TransitionCommand):
355    pass
356
357class transdissolve(TransitionCommand):
358    pass
359
360class transglitter(TransitionCommand):
361    pass
362
363class transsplitverticalout(TransitionCommand):
364    pass
365
366class transsplitverticalin(TransitionCommand):
367    pass
368
369class transsplithorizontalin(TransitionCommand):
370    pass
371
372class transsplithorizontalout(TransitionCommand):
373    pass
374
375class transwipe(TransitionCommand):
376    pass
377
378class transduration(Command):
379    args = '< overlay > seconds:int'
380
381#
382# Themes
383#
384
385class usetheme(Command):
386    args = '[ options:dict ] name:list:str'
387
388class usecolortheme(Command):
389    args = '[ options:dict ] name:list:str'
390
391class usefonttheme(Command):
392    args = '[ options:dict ] name:list:str'
393
394class useinnertheme(Command):
395    args = '[ options:dict ] name:list:str'
396
397class useoutertheme(Command):
398    args = '[ options:dict ] name:list:str'
399
400class addheadbox(Command):
401    args = 'color template'
402
403class addfootbox(Command):
404    args = 'color template'
405