1# -*- coding: utf-8 -*-
2# Copyright (C) 2006-2007 Søren Roug, European Environment Agency
3#
4# This library is free software; you can redistribute it and/or
5# modify it under the terms of the GNU Lesser General Public
6# License as published by the Free Software Foundation; either
7# version 2.1 of the License, or (at your option) any later version.
8#
9# This library is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12# Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public
15# License along with this library; if not, write to the Free Software
16# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17#
18# Contributor(s):
19#
20
21
22from .namespaces import DRAWNS, STYLENS, PRESENTATIONNS
23from .element import Element
24
25
26def StyleRefElement(stylename=None, classnames=None, **args):
27    qattrs = {}
28    if stylename is not None:
29        f = stylename.getAttrNS(STYLENS, 'family')
30        if f == 'graphic':
31            qattrs[(DRAWNS,u'style-name')]= stylename
32        elif f == 'presentation':
33            qattrs[(PRESENTATIONNS,u'style-name')]= stylename
34        else:
35            raise ValueError("Style's family must be either 'graphic' or 'presentation'")
36    if classnames is not None:
37        f = classnames[0].getAttrNS(STYLENS, 'family')
38        if f == 'graphic':
39            qattrs[(DRAWNS,u'class-names')]= classnames
40        elif f == 'presentation':
41            qattrs[(PRESENTATIONNS,u'class-names')]= classnames
42        else:
43            raise ValueError("Style's family must be either 'graphic' or 'presentation'")
44    return Element(qattributes=qattrs, **args)
45
46
47def DrawElement(name=None, **args):
48    e = Element(name=name, **args)
49    if 'displayname' not in args:
50        e.setAttrNS(DRAWNS,'display-name', name)
51    return e
52
53# Autogenerated
54
55
56def A(**args):
57    return Element(qname=(DRAWNS,'a'), **args)
58
59
60def Applet(**args):
61    return Element(qname=(DRAWNS,'applet'), **args)
62
63
64def AreaCircle(**args):
65    return Element(qname=(DRAWNS,'area-circle'), **args)
66
67
68def AreaPolygon(**args):
69    return Element(qname=(DRAWNS,'area-polygon'), **args)
70
71
72def AreaRectangle(**args):
73    return Element(qname=(DRAWNS,'area-rectangle'), **args)
74
75
76def Caption(**args):
77    return StyleRefElement(qname=(DRAWNS,'caption'), **args)
78
79
80def Circle(**args):
81    return StyleRefElement(qname=(DRAWNS,'circle'), **args)
82
83
84def Connector(**args):
85    return StyleRefElement(qname=(DRAWNS,'connector'), **args)
86
87
88def ContourPath(**args):
89    return Element(qname=(DRAWNS,'contour-path'), **args)
90
91
92def ContourPolygon(**args):
93    return Element(qname=(DRAWNS,'contour-polygon'), **args)
94
95
96def Control(**args):
97    return StyleRefElement(qname=(DRAWNS,'control'), **args)
98
99
100def CustomShape(**args):
101    return StyleRefElement(qname=(DRAWNS,'custom-shape'), **args)
102
103
104def Ellipse(**args):
105    return StyleRefElement(qname=(DRAWNS,'ellipse'), **args)
106
107
108def EnhancedGeometry(**args):
109    return Element(qname=(DRAWNS,'enhanced-geometry'), **args)
110
111
112def Equation(**args):
113    return Element(qname=(DRAWNS,'equation'), **args)
114
115
116def FillImage(**args):
117    return DrawElement(qname=(DRAWNS,'fill-image'), **args)
118
119
120def FloatingFrame(**args):
121    return Element(qname=(DRAWNS,'floating-frame'), **args)
122
123
124def Frame(**args):
125    return StyleRefElement(qname=(DRAWNS,'frame'), **args)
126
127
128def G(**args):
129    return StyleRefElement(qname=(DRAWNS,'g'), **args)
130
131
132def GluePoint(**args):
133    return Element(qname=(DRAWNS,'glue-point'), **args)
134
135
136def Gradient(**args):
137    return DrawElement(qname=(DRAWNS,'gradient'), **args)
138
139
140def Handle(**args):
141    return Element(qname=(DRAWNS,'handle'), **args)
142
143
144def Hatch(**args):
145    return DrawElement(qname=(DRAWNS,'hatch'), **args)
146
147
148def Image(**args):
149    return Element(qname=(DRAWNS,'image'), **args)
150
151
152def ImageMap(**args):
153    return Element(qname=(DRAWNS,'image-map'), **args)
154
155
156def Layer(**args):
157    return Element(qname=(DRAWNS,'layer'), **args)
158
159
160def LayerSet(**args):
161    return Element(qname=(DRAWNS,'layer-set'), **args)
162
163
164def Line(**args):
165    return StyleRefElement(qname=(DRAWNS,'line'), **args)
166
167
168def Marker(**args):
169    return DrawElement(qname=(DRAWNS,'marker'), **args)
170
171
172def Measure(**args):
173    return StyleRefElement(qname=(DRAWNS,'measure'), **args)
174
175
176def Object(**args):
177    return Element(qname=(DRAWNS,'object'), **args)
178
179
180def ObjectOle(**args):
181    return Element(qname=(DRAWNS,'object-ole'), **args)
182
183
184def Opacity(**args):
185    return DrawElement(qname=(DRAWNS,'opacity'), **args)
186
187
188def Page(**args):
189    return Element(qname=(DRAWNS,'page'), **args)
190
191
192def PageThumbnail(**args):
193    return StyleRefElement(qname=(DRAWNS,'page-thumbnail'), **args)
194
195
196def Param(**args):
197    return Element(qname=(DRAWNS,'param'), **args)
198
199
200def Path(**args):
201    return StyleRefElement(qname=(DRAWNS,'path'), **args)
202
203
204def Plugin(**args):
205    return Element(qname=(DRAWNS,'plugin'), **args)
206
207
208def Polygon(**args):
209    return StyleRefElement(qname=(DRAWNS,'polygon'), **args)
210
211
212def Polyline(**args):
213    return StyleRefElement(qname=(DRAWNS,'polyline'), **args)
214
215
216def Rect(**args):
217    return StyleRefElement(qname=(DRAWNS,'rect'), **args)
218
219
220def RegularPolygon(**args):
221    return StyleRefElement(qname=(DRAWNS,'regular-polygon'), **args)
222
223
224def StrokeDash(**args):
225    return DrawElement(qname=(DRAWNS,'stroke-dash'), **args)
226
227
228def TextBox(**args):
229    return Element(qname=(DRAWNS,'text-box'), **args)
230