1
2import mingc
3
4# should raise an exception if return is non-zero:
5mingc.Ming_init()
6
7def Ming_setCubicThreshold(t):
8    mingc.Ming_setCubicThreshold(t)
9
10def Ming_setScale(scale):
11    mingc.Ming_setScale(scale)
12
13def Ming_getScale():
14    return mingc.Ming_getScale()
15
16def Ming_useSWFVersion(num):
17    mingc.Ming_useSWFVersion(num)
18
19def Ming_setSWFCompression( level ):
20    return mingc.Ming_setSWFCompression( level )
21
22def Ming_useConstants(flag):
23   mingc.Ming_useConstants(flag)
24
25def Ming_collectGarbage():
26   mingc.Ming_collectGarbage()
27
28class SWFBase:
29
30    def __init__(self, o):
31        self.this = o
32
33    # reportedly useful for zope/zwiff:
34    def set(self, name, val):
35        setattr(self, name, val)
36
37
38class SWFCXform(SWFBase):
39
40    def __init__(rAdd=0, gAdd=0, bAdd=0, aAdd=0, rMult=1.0, gMult=1.0, bMult=1.0, aMult=1.0):
41        self.this = mingc.newSWFCXform(rAdd, gAdd, bAdd, aAdd, rMult, gMult, bMult, aMult)
42
43    def __del__(self):
44        mingc.destroySWFCXform(self.this)
45
46    def setColorAdd(self, rAdd, gAdd, bAdd, aAdd=0xff):
47        mingc.SWFCXform_setColorAdd(self.this, rAdd, gAdd, bAdd, aAdd)
48
49    def setColorMult(self, rMult, gMult, bMult, aMult):
50        mingc.SWFCXform_setColorMult(self.this, rMult, gMult, bMult, aMult)
51
52class SWFRect(SWFBase):
53
54    def __init__(self, minX, maxX, minY, maxY):
55        self.this = mingc.newSWFRect(minX, maxX, minY, maxY)
56
57    def __del__(self):
58        mingc.destroySWFRect(self.this)
59
60    def getWidth(self):
61        return mingc.SWFRect_getWidth(self.this)
62
63    def getHeight(self):
64        return mingc.SWFRect_getHeight(self.this)
65
66class SWFShadow(SWFBase):
67    def __init__(self, angle, distance, strength):
68        self.this = mingc.newSWFShadow(angle, distance, strength)
69
70    def __del__(self):
71        mingc.destroySWFShadow(self.this)
72
73class SWFBlur(SWFBase):
74    def __init__(self, blurX, blurY, passes):
75        self.this = mingc.newSWFBlur(blurX, blurY, passes)
76
77    def __del__(self):
78        mingc.destroySWFBlur(self.this)
79
80class SWFFilterMatrix(SWFBase):
81    def __init__(self, cols, rows, values):
82        vals = floatArray(cols * rows)
83        for i in range(0, cols*rows):
84            vals[i] = values[i]
85        self.this = mingc.newSWFFilterMatrix(cols, rows, vals)
86
87    def __del__(self):
88        mingc.destroySWFFilterMatrix(self.this)
89
90SWFFILTER_TYPE_DROPSHADOW = mingc.SWFFILTER_TYPE_DROPSHADOW
91SWFFILTER_TYPE_BLUR = mingc.SWFFILTER_TYPE_BLUR
92SWFFILTER_TYPE_GLOW = mingc.SWFFILTER_TYPE_GLOW
93SWFFILTER_TYPE_BEVEL = mingc.SWFFILTER_TYPE_BEVEL
94SWFFILTER_TYPE_GRADIENTGLOW = mingc.SWFFILTER_TYPE_GRADIENTGLOW
95SWFFILTER_TYPE_CONVOLUTION = mingc.SWFFILTER_TYPE_CONVOLUTION
96SWFFILTER_TYPE_COLORMATRIX = mingc.SWFFILTER_TYPE_COLORMATRIX
97SWFFILTER_TYPE_GRADIENTBEVEL = mingc.SWFFILTER_TYPE_GRADIENTBEVEL
98
99SWFFILTER_MODE_INNER = mingc.SWFFILTER_MODE_INNER
100SWFFILTER_MODE_KO = mingc.SWFFILTER_MODE_KO
101SWFFILTER_MODE_COMPOSITE = mingc.SWFFILTER_MODE_COMPOSITE
102SWFFILTER_MODE_ONTOP = mingc.SWFFILTER_MODE_ONTOP
103
104SWFFILTER_FLAG_CLAMP = mingc.SWFFILTER_FLAG_CLAMP
105SWFFILTER_FLAG_PRESERVE_ALPHA = mingc.SWFFILTER_FLAG_PRESERVE_ALPHA
106
107class SWFFilter(SWFBase):
108    def __del__(self):
109        mingc.destroySWFFilter(self.this)
110
111    def __init__(self, type, arg1=None, arg2=None, arg3=None, arg4=None, arg5=None):
112        if type == SWFFILTER_TYPE_DROPSHADOW:
113            #color, blur, shadow, flags
114            if not isinstance(arg2, SWFBlur):
115                raise AttributeError, "3. parameter has to be SWFBlur"
116            if not isinstance(arg3, SWFShadow):
117                raise AttributeError, "4. parameter has to be SWFShadow"
118            self.this = mingc.newDropShadowFilter(arg1, arg2.this, arg3.this, arg4)
119        elif type == SWFFILTER_TYPE_BLUR:
120            #blur
121            if not isinstance(arg1, SWFBlur):
122                raise AttributeError, "2. parameter has to be SWFBlur"
123            self.this = mingc.newBlurFilter(arg1.this)
124        elif type == SWFFILTER_TYPE_GLOW:
125            #color, blur, strength, flags
126            if not isinstance(arg2, SWFBlur):
127                raise AttributeError, "3. parameter has to be SWFBlur"
128            self.this = mingc.newGlowFilter(arg1, arg2.this, arg3, arg4)
129	elif type == SWFFILTER_TYPE_BEVEL:
130            #shadowColor, highlightColor, blur, shadow, flags
131            if not isinstance(arg3, SWFBlur):
132                raise AttributeError, "4. parameter has to be SWFBlur"
133            if not isinstance(arg4, SWFShadow):
134                raise AttributeError, "5. parameter has to be SWFShadow"
135            self.this = mingc.newBevelFilte(arg1, arg2, arg3.this, arg4.this, arg5)
136	elif type == SWFFILTER_TYPE_GRADIENTGLOW:
137            #gradient, blur, shadow, flags
138            if not isinstance(arg1, SWFGradient):
139                raise AttributeError, "2. parameter has to be SWFGradient"
140            if not isinstance(arg2, SWFBlur):
141                raise AttributeError, "3. parameter has to be SWFBlur"
142            if not isinstance(arg3, SWFShadow):
143                raise AttributeError, "4. parameter has to be SWFShadow"
144            self.this = mingc.newGradienGlowFilter(arg1.this, arg2.this, arg3.this, arg4)
145        elif type == SWFFILTER_TYPE_COLORMATRIX:
146            #colormatrix
147            if not isinstance(arg1, SWFFilterMatrix):
148                raise AttributeError, "2. parameter has to be SWFFilterMatrix"
149            self.this = mingc.newColorMatrixFilter(arg1.this)
150	elif type == SWFFILTER_TYPE_CONVOLUTION:
151            #colormatrix, divisor, bias, color, flags
152            if not isinstance(arg1, SWFFilterMatrix):
153                raise AttributeError, "2. parameter has to be SWFFilterMatrix"
154            self.this = mingc.newConvolutionFilter(arg1.this, arg2, arg3, arg4, arg5)
155        elif type == SWFFILTER_TYPE_GRADIENTBEVEL:
156            #gradient, blur, shadow, flags
157            if not isinstance(arg1, SWFGradient):
158                raise AttributeError, "2. parameter has to be SWFGradient"
159            if not isinstance(arg2, SWFBlur):
160                raise AttributeError, "3. parameter has to be SWFBlur"
161            if not isinstance(arg3, SWFShadow):
162                raise AttributeError, "4. parameter has to be SWFShadow"
163            self.this = mingc.newGradientBevelFilter(arg1.this, arg2.this, arg3.this, arg4)
164	else:
165            raise AttributeError, "bad filter type to SWFFilter::new"
166
167class SWFMatrix(SWFBase):
168
169    def getScaleX(self):
170        return mingc.SWFMatrix_getScaleX(self.this)
171
172    def getScaleY(self):
173        return mingc.SWFMatrix_getScaleY(self.this)
174
175    def getRotate0(self):
176        return mingc.SWFMatrix_getRotate0(self.this)
177
178    def getRotate1(self):
179        return mingc.SWFMatrix_getRotate1(self.this)
180
181    def getTranslateX(self):
182        return mingc.SWFMatrix_getTranslateX(self.this)
183
184    def getTranslateY(self):
185        return mingc.SWFMatrix_getTranslateY(self.this)
186
187SWF_SHAPE3			= mingc.SWF_SHAPE3
188SWF_SHAPE4			= mingc.SWF_SHAPE4
189SWF_SHAPE_USESCALINGSTROKES	= mingc.SWF_SHAPE_USESCALINGSTROKES
190SWF_SHAPE_USENONSCALINGSTROKES	= mingc.SWF_SHAPE_USENONSCALINGSTROKES
191
192class SWFShape(SWFBase):
193
194    def __init__(self, o=None):
195        self.fills = []
196
197        if o is None:
198            self.this = mingc.newSWFShape()
199        else:
200            self.this = o
201
202    def __del__(self):
203        mingc.destroySWFShape(self.this)
204
205    def setLine(self, width, r, g, b, a=0xff):
206        mingc.SWFShape_setLine(self.this, width, r, g, b, a)
207
208    def setLine2(self, width, r, g, b, a, flags, miter):
209        mingc.SWFShape_setLine2(self.this, width, r, g, b, a, flags, miter)
210
211    def setLine2Filled(self, width, fill, flags, miter):
212        mingc.SWFShape_setLine2Filled(self.this, width, mingc.SWFFill_getFillStyle(fill.this), flags, miter)
213
214    # I know there's probably a better way to do this..
215    def addFill(self, arg1, arg2=0, arg3=None, arg4=0xff):
216        if arg3 != None:
217            return SWFFill(mingc.SWFShape_addSolidFill(self.this, arg1, arg2, arg3, arg4))
218        if isinstance(arg1, SWFGradient):
219            # XXX - have to keep reference to gradient so it's not disposed
220            self.fills.append(arg1)
221            return SWFFill(mingc.SWFShape_addGradientFill(self.this, arg1.this, arg2))
222
223        if isinstance(arg1, SWFBitmap):
224            # XXX - have to keep reference to bitmap so it's not disposed
225            self.fills.append(arg1)
226            return SWFFill(mingc.SWFShape_addBitmapFill(self.this, arg1.this, arg2))
227
228        if isinstance(arg1, SWFJpegBitmap):
229            self.fills.append(arg1)
230            return SWFFill(mingc.SWFShape_addBitmapFill(self.this, arg1.this, arg2))
231
232        else:
233            raise AttributeError, "bad argument to SWFShape::addFill"
234
235    def setLeftFill(self, fill):
236        mingc.SWFShape_setLeftFill(self.this, fill)
237
238    def setRightFill(self, fill):
239        mingc.SWFShape_setRightFill(self.this, fill)
240
241    def movePenTo(self, x, y):
242        mingc.SWFShape_movePenTo(self.this, x, y)
243
244    def movePen(self, x, y):
245        mingc.SWFShape_movePen(self.this, x, y)
246
247    def drawLineTo(self, x, y):
248        mingc.SWFShape_drawLineTo(self.this, x, y)
249
250    def drawLine(self, dx, dy):
251        mingc.SWFShape_drawLine(self.this, dx, dy)
252
253    def drawArc(self, x, y, r, startAngle, endAngle):
254        mingc.SWFShape_drawArc(self.this, x, y, r, startAngle, endAngle)
255
256    def drawCircle(self, r):
257        mingc.SWFShape_drawCircle(self.this, r)
258
259    def drawCurveTo(self, bx, by, cx, cy, dx=None, dy=None):
260        if(dx != None):
261            mingc.SWFShape_drawCubicTo(self.this, bx, by, cx, cy, dx, dy)
262        else:
263            mingc.SWFShape_drawCurveTo(self.this, bx, by, cx, cy)
264
265    def drawCurve(self, bx, by, cx, cy, dx=None, dy=None):
266        if(dx != None):
267            mingc.SWFShape_drawCubic(self.this, bx, by, cx, cy, dx, dy)
268        else:
269            mingc.SWFShape_drawCurve(self.this, bx, by, cx, cy)
270
271    def drawCubicTo(self, bx, by, cx, cy, dx, dy):
272        mingc.SWFShape_drawCubicTo(self.this, bx, by, cx, cy, dx, dy)
273
274    def drawCubic(self, bx, by, cx, cy, dx, dy):
275        mingc.SWFShape_drawCubic(self.this, bx, by, cx, cy, dx, dy)
276
277    def drawGlyph(self, font, char, size=0):
278        mingc.SWFShape_drawSizedGlyph(self.this, font.this, ord(char[0]), size)
279
280    def drawCharacterBounds(self, char):
281        mingc.SWFShape_drawCharacterBounds(self.this, char.this)
282
283    def end(self):
284        mingc.SWFShape_end(self.this)
285
286    def useVersion(self, version):
287        mingc.SWFShape_useVersion(self.this, version)
288
289    def getVersion(self):
290        return mingc.SWFShape_getVersion(self.this)
291
292    def addSolidFill(self, r, g, b, a=0xff):
293        return SWFFill(mingc.SWFShape_addSolidFill(self.this, r, g, b, a))
294
295    def addGradientFill(self, gradient, flags):
296        return SWFFill(mingc.SWFShape_addGradientFill(self.this, gradient.this, flags))
297
298    def addBitmapFill(self, bitmap, flags):
299        return SWFFill(mingc.SWFShape_addBitmapFill(self.this, bitmap.this, flags))
300
301    def setRenderHintingFlags(self, flags):
302        mingc.SWFShape_setRenderHintingFlags(self.this, flags)
303
304    def getPenX(self):
305        mingc.SWFShape_getPenX(self.this)
306
307    def getPenY(self):
308        mingc.SWFShape_getPenY(self.this)
309
310    def hideLine(self):
311        mingc.SWFShape_hideLine(self.this)
312
313# addFill flags:
314SWFFILL_SOLID		= mingc.SWFFILL_SOLID
315SWFFILL_GRADIENT	= mingc.SWFFILL_GRADIENT
316SWFFILL_LINEAR_GRADIENT = mingc.SWFFILL_LINEAR_GRADIENT
317SWFFILL_RADIAL_GRADIENT = mingc.SWFFILL_RADIAL_GRADIENT
318SWFFILL_BITMAP		= mingc.SWFFILL_BITMAP
319SWFFILL_TILED_BITMAP	= mingc.SWFFILL_TILED_BITMAP
320SWFFILL_CLIPPED_BITMAP	= mingc.SWFFILL_CLIPPED_BITMAP
321#hinting flags
322SWF_SHAPE_USESCALINGSTROKES    = mingc.SWF_SHAPE_USESCALINGSTROKES
323SWF_SHAPE_USENONSCALINGSTROKES = mingc.SWF_SHAPE_USENONSCALINGSTROKES
324
325class SWFFill(SWFBase):
326
327    def __del__(self):
328        mingc.destroySWFFill(self.this)
329
330    def rotate(self, degrees):
331        mingc.SWFFill_rotate(self.this, degrees)
332
333    def rotateTo(self, degrees):
334        mingc.SWFFill_rotateTo(self.this, degrees)
335
336    def move(self, x, y):
337        mingc.SWFFill_move(self.this, x, y)
338
339    def moveTo(self, x, y):
340        mingc.SWFFill_moveTo(self.this, x, y)
341
342    def scale(self, xScale, yScale=None):
343        if yScale is None:
344            mingc.SWFFill_scaleXY(self.this, xScale, xScale)
345        else:
346            mingc.SWFFill_scaleXY(self.this, xScale, yScale)
347
348    def scaleTo(self, xScale, yScale=None):
349        if yScale is None:
350            mingc.SWFFill_scaleXYTo(self.this, xScale, xScale)
351        else:
352            mingc.SWFFill_scaleXYTo(self.this, xScale, yScale)
353
354    def scaleX(self, xScale):
355        mingc.SWFFill_scaleX(self.this, xScale)
356
357    def scaleXTo(self, xScale):
358        mingc.SWFFill_scaleXTo(self.this, xScale)
359
360    def scaleY(self, yScale):
361        mingc.SWFFill_scaleY(self.this, yScale)
362
363    def scaleYTo(self, yScale):
364        mingc.SWFFill_scaleYTo(self.this, yScale)
365
366    def skewX(self, x):
367        mingc.SWFFill_skewX(self.this, x)
368
369    def skewXTo(self, x):
370        mingc.SWFFill_skewXTo(self.this, x)
371
372    def skewY(self, y):
373        mingc.SWFFill_skewY(self.this, y)
374
375    def skewYTo(self, y):
376        mingc.SWFFill_skewYTo(self.this, y)
377
378    def setMatrix(self, a, b, c, d, x, y):
379        mingc.SWFFill_setMatrix(self.this, a, b, c, d, x, y)
380
381class SWFCharacter(SWFBase):
382
383    def getWidth(self):
384        mingc.SWFCharacter_getWidth(self.this)
385
386    def getHeight(self):
387        mingc.SWFCharacter_getHeight(self.this)
388
389class SWFDisplayItem(SWFBase):
390
391    def rotate(self, degrees):
392        mingc.SWFDisplayItem_rotate(self.this, degrees)
393
394    def rotateTo(self, degrees):
395        mingc.SWFDisplayItem_rotateTo(self.this, degrees)
396
397    def move(self, x, y):
398        mingc.SWFDisplayItem_move(self.this, x, y)
399
400    def moveTo(self, x, y):
401        mingc.SWFDisplayItem_moveTo(self.this, x, y)
402
403    def scale(self, xScale, yScale):
404        mingc.SWFDisplayItem_scale(self.this, xScale, yScale)
405
406    def scaleTo(self, xScale, yScale):
407        mingc.SWFDisplayItem_scaleTo(self.this, xScale, yScale)
408
409    def skewX(self, x):
410        mingc.SWFDisplayItem_skewX(self.this, x)
411
412    def skewXTo(self, x):
413        mingc.SWFDisplayItem_skewXTo(self.this, x);
414
415    def skewY(self, y):
416        mingc.SWFDisplayItem_skewY(self.this, y)
417
418    def skewYTo(self, y):
419        mingc.SWFDisplayItem_skewYTo(self.this, y)
420
421    def setName(self, name):
422        mingc.SWFDisplayItem_setName(self.this, name)
423
424    def setRatio(self, ratio):
425        mingc.SWFDisplayItem_setRatio(self.this, ratio)
426
427    def getDepth(self):
428        return mingc.SWFDisplayItem_getDepth(self.this)
429
430    def setDepth(self, depth):
431        mingc.SWFDisplayItem_setDepth(self.this, depth)
432
433    def addColor(self, r, g, b, a=0):
434        mingc.SWFDisplayItem_setColorAdd(self.this, r, g, b, a)
435
436    def multColor(self, r, g, b, a=1.0):
437        mingc.SWFDisplayItem_setColorMult(self.this, r, g, b, a)
438
439    def remove(self):
440        mingc.SWFDisplayItem_remove(self.this)
441
442    def setMatrix(self, a, b, c, d, x, y):
443        mingc.SWFDisplayItem_setMatrix(self.this, a, b, c, d, x, y)
444
445    def cacheAsBitmap(self, flag):
446        mingc.SWFDisplayItem_cacheAsBitmap(self.this, flag)
447
448    def setBlendMode(self, mode):
449        mingc.SWFDisplayItem_setBlendMode(self.this, flag)
450
451    def addAction(self, actionScript, flags):
452        mingc.SWFDisplayItem_addAction(self.this, actionScript, flags)
453
454    def setMaskLevel(self, level):
455        mingc.SWFDisplayItem_setMaskLevel(self.this, level)
456
457    def getPositionX(self):
458	x = mingc.new_floatp()
459	y = mingc.new_floatp()
460	mingc.SWFDisplayItem_getPosition(self.this, x, y)
461	ret = mingc.floatp_value(x)
462	mingc.delete_floatp(x)
463	mingc.delete_floatp(y)
464	return ret
465
466    def getPositionY(self):
467	x = mingc.new_floatp()
468	y = mingc.new_floatp()
469	mingc.SWFDisplayItem_getPosition(self.this, x, y)
470	ret = mingc.floatp_value(y)
471	mingc.delete_floatp(x)
472	mingc.delete_floatp(y)
473	return ret
474
475    def getRotation(self):
476        rot = mingc.new_floatp()
477	mingc.SWFDisplayItem_getRotation(self.this, rot)
478	ret = mingc.floatp_value(rot)
479	mingc.delete_floatp(rot)
480	return ret
481
482    def getScaleX(self):
483        sx = mingc.new_floatp()
484        sy = mingc.new_floatp()
485        mingc.SWFDisplayItem_getScale(self.this, sx, sy)
486        ret = mingc.floatp_value(sx)
487        mingc.delete_floatp(sx)
488        mingc.delete_floatp(sy)
489        return ret
490
491    def getScaleY(self):
492        sx = mingc.new_floatp()
493        sy = mingc.new_floatp()
494        mingc.SWFDisplayItem_getScale(self.this, sx, sy)
495        ret = mingc.floatp_value(sy)
496        mingc.delete_floatp(sx)
497        mingc.delete_floatp(sy)
498        return ret
499
500    def getSkewX(self):
501        sx = mingc.new_floatp()
502        sy = mingc.new_floatp()
503        mingc.SWFDisplayItem_getSkew(self.this, sx, sy)
504        ret = mingc.floatp_value(sx)
505        mingc.delete_floatp(sx)
506        mingc.delete_floatp(sy)
507        return ret
508
509    def getSkewY(self):
510        sx = mingc.new_floatp()
511        sy = mingc.new_floatp()
512        mingc.SWFDisplayItem_getSkew(self.this, sx, sy)
513        ret = mingc.floatp_value(sy)
514        mingc.delete_floatp(sx)
515        mingc.delete_floatp(sy)
516        return ret
517
518    def flush(self):
519        mingc.SWFDisplayItem_flush(self.this)
520
521    def endMask(self):
522        mingc.SWFDisplayItem_endMask(self.this)
523
524    def getMatrix(self):
525        return SWFMatrix(mingc.SWFDisplayItem_getMatrix(self.this))
526
527    def setCXform(self, cx):
528	mingc.SWFDisplayItem_setCXform(self.this, cx.this);
529
530    def addFilter(self, filter):
531        mingc.SWFDisplayItem_addFilter(self.this, filter.this)
532
533    def getCharacter(self):
534        return SWFCharacter(mingc.SWFDisplayItem_getCharacter(self.this))
535
536SWFACTION_ONLOAD      = mingc.SWFACTION_ONLOAD
537SWFACTION_ENTERFRAME  = mingc.SWFACTION_ENTERFRAME
538SWFACTION_UNLOAD      = mingc.SWFACTION_UNLOAD
539SWFACTION_MOUSEMOVE   = mingc.SWFACTION_MOUSEMOVE
540SWFACTION_MOUSEDOWN   = mingc.SWFACTION_MOUSEDOWN
541SWFACTION_MOUSEUP     = mingc.SWFACTION_MOUSEUP
542SWFACTION_KEYDOWN     = mingc.SWFACTION_KEYDOWN
543SWFACTION_KEYUP       = mingc.SWFACTION_KEYUP
544SWFACTION_DATA        = mingc.SWFACTION_DATA
545
546SWFBLEND_MODE_NULL	= mingc.SWFBLEND_MODE_NULL
547SWFBLEND_MODE_NORMAL	= mingc.SWFBLEND_MODE_NORMAL
548SWFBLEND_MODE_LAYER 	= mingc.SWFBLEND_MODE_LAYER
549SWFBLEND_MODE_MULT	= mingc.SWFBLEND_MODE_MULT
550SWFBLEND_MODE_SCREEN	= mingc.SWFBLEND_MODE_SCREEN
551SWFBLEND_MODE_LIGHTEN	= mingc.SWFBLEND_MODE_LIGHTEN
552SWFBLEND_MODE_DARKEN	= mingc.SWFBLEND_MODE_DARKEN
553SWFBLEND_MODE_DIFF	= mingc.SWFBLEND_MODE_DIFF
554SWFBLEND_MODE_ADD	= mingc.SWFBLEND_MODE_ADD
555SWFBLEND_MODE_SUB	= mingc.SWFBLEND_MODE_SUB
556SWFBLEND_MODE_INV	= mingc.SWFBLEND_MODE_INV
557SWFBLEND_MODE_ALPHA	= mingc.SWFBLEND_MODE_ALPHA
558SWFBLEND_MODE_ERASE	= mingc.SWFBLEND_MODE_ERASE
559SWFBLEND_MODE_OVERLAY	= mingc.SWFBLEND_MODE_OVERLAY
560SWFBLEND_MODE_HARDLIGHT = mingc.SWFBLEND_MODE_HARDLIGHT
561
562
563class SWFMovie(SWFBase):
564
565    def __init__(self):
566        self.this = mingc.newSWFMovie()
567        self.blocks = []
568
569    def __del__(self):
570        mingc.destroySWFMovie(self.this)
571
572    def setRate(self, rate):
573        mingc.SWFMovie_setRate(self.this, rate)
574
575    def getRate(self):
576        return mingc.SWFMovie_getRate(self.this)
577
578    def setDimension(self, x, y):
579        mingc.SWFMovie_setDimension(self.this, x, y)
580
581    def setBackground(self, r, g, b):
582        mingc.SWFMovie_setBackground(self.this, r, g, b)
583
584    def setFrames(self, totalFrames):
585        mingc.SWFMovie_setNumberOfFrames(self.this, totalFrames)
586
587    # or:
588    def setNumberOfFrames(self, totalFrames):
589        mingc.SWFMovie_setNumberOfFrames(self.this, totalFrames)
590
591    def protect(self, passwd=None):
592        if passwd is None:
593            mingc.SWFMovie_protect(self.this, None)
594        else:
595            mingc.SWFMovie_protect(self.this, passwd)
596
597
598    def nextFrame(self):
599        mingc.SWFMovie_nextFrame(self.this)
600
601    def add(self, block):
602        self.blocks.append(block)
603        return SWFDisplayItem(mingc.SWFMovie_add(self.this, block.this))
604
605    def remove(self, item):
606        mingc.SWFMovie_remove(self.this, item.this)
607
608    def replace(self, item, block):
609        self.blocks.append(block)
610        mingc.SWFMovie_replace(self.this, item.this, block.this)
611
612    def streamMp3(self, mp3, skip=0.0):
613        sound = SWFSoundStream(mp3)
614        self.blocks.append(sound)
615        mingc.SWFMovie_setSoundStreamAt(self.this, sound, skip)
616
617    def setSoundStream(self, sound, skip=0.0):
618        self.blocks.append(sound)
619        mingc.SWFMovie_setSoundStreamAt(self.this, sound.this, skip);
620
621    def output(self):
622        return mingc.SWFMovie_simpleOutput(self.this)
623
624    def save(self, filename):
625        mingc.SWFMovie_save(self.this, filename)
626
627    def saveToFile(self, file):
628        mingc.SWFMovie_saveToFileNo(self.this, file.fileno())
629
630    def labelFrame(self, label):
631        mingc.SWFMovie_labelFrame(self.this, label)
632
633    def namedAnchor(self, label):
634        mingc.SWFMovie_namedAnchor(self.this, label)
635
636    # deprecated:
637    def simpleOutput(self):
638        return mingc.SWFMovie_simpleOutput(self.this)
639
640    def addExport(self, clipObj, libName):
641        return mingc.SWFMovie_addExport(self.this, clipObj, libName)
642
643    def writeExports(self):
644        mingc.SWFMovie_writeExports(self.this)
645
646    def assignSymbol(self, character, name):
647	mingc.SWFMovie_assignSymbol(self.this, character.this, name)
648
649    def setNetworkAccess(self, flag):
650        mingc.SWFMovie_setNetworkAccess(self.this, flag)
651
652    def addMetadata(self, xmldata):
653        mingc.SWFMovie_addMetadata(self.this, xmldata)
654
655    def setScriptLimits(self, maxRecursion, timeout):
656        mingc.SWFMovie_setScriptLimits(self.this, maxRecursion, timeout)
657
658    def setTabIndex(self, depth, index):
659        mingc.SWFMovie_setTabIndex(self.this, depth, index)
660
661    def defineScene(self, offset, name):
662        mingc.SWFMovie_defineScene(self.this, offset, index)
663
664    def addFont(self, font):
665        return SWFFontCharacter(mingc.SWFMovie_addFont(self.this, font.this))
666
667    def importFont(self, filename, name):
668        return SWFFontCharacter(mingc.SWFMovie_importFont(self.this, filename, name))
669
670    def startSound(self, sound):
671        return SWFSoundInstance(mingc.SWFMovie_startSound(self.this, sound.this))
672
673    def stopSound(self, sound):
674        mingc.SWFMovie_stopSound(self.this, sound.this)
675
676    def importCharacter(self):
677        SWFCharacter(mingc.SWFMovie_importCharacter(self.this))
678
679
680class SWFSprite(SWFBase):
681
682    def __init__(self):
683        self.this = mingc.newSWFMovieClip()
684        self.blocks = []
685
686    def __del__(self):
687        mingc.destroySWFMovieClip(self.this)
688
689    def setNumberOfFrames(self, frames):
690        mingc.SWFMovieClip_setNumberOfFrames(self.this, frames)
691
692    def add(self, block):
693        self.blocks.append(block)
694        return SWFDisplayItem(mingc.SWFMovieClip_add(self.this, block.this))
695
696    def remove(self, item):
697        mingc.SWFMovieClip_remove(self.this, item.this)
698
699    def nextFrame(self):
700        mingc.SWFMovieClip_nextFrame(self.this)
701
702    def labelFrame(self, label):
703        mingc.SWFMovieClip_labelFrame(self.this, label)
704
705    def setScalingGrid(self, x, y, w, h):
706        mingc.SWFMovieClip_setScalingGrid(self.this, x, y, w, h)
707
708    def removeScalingGrid(self):
709        mingc.SWFMovieClip_removeScalingGrid(self.this)
710
711    def addInitAction(self, action):
712        self.blocks.append(block)
713        mingc.SWFMovieClip_addInitAction(self.this, action.this)
714
715    def startSound(self, sound):
716        return SWFSoundInstance(mingc.SWFMovieClip_startSound(self.this, sound.this))
717
718    def stopSound(self, sound):
719        mingc.SWFMovieClip_stopSound(self.this, sound.this)
720
721    def setSoundStream(self, sound, rate, skip=0.0):
722        self.blocks.append(sound)
723        mingc.SWFMovieClip_setSoundStreamAt(self.this, sound.this, rate, skip);
724
725# deprecated:
726class SWFMovieClip(SWFSprite):
727    pass
728
729
730class SWFMorph(SWFBase):
731
732    def __init__(self):
733        self.this = mingc.newSWFMorphShape()
734
735    def __del__(self):
736        mingc.destroySWFMorph(self.this)
737
738    def getShape1(self):
739        # have to keep a reference so that it doesn't scope out
740        self.shape1 = SWFShape(mingc.SWFMorph_getShape1(self.this))
741        return self.shape1
742
743    def getShape2(self):
744        self.shape2 = SWFShape(mingc.SWFMorph_getShape2(self.this))
745        return self.shape2
746
747# deprecated:
748class SWFMorphShape(SWFMorph):
749    pass
750
751
752class SWFBrowserFont(SWFBase):
753
754    def __init__(self, name):
755       self.this = mingc.newSWFBrowserFont(name)
756       self.name = name
757
758    def __del__(self):
759       	mingc.destroySWFBrowserFont(self.this)
760
761
762class SWFFont(SWFBase):
763
764    def __init__(self, name):
765            self.this = mingc.newSWFFont_fromFile(name)
766            self.name = name
767
768    def __del__(self):
769            mingc.destroySWFFont(self.this)
770
771    def getAscent(self):
772        return mingc.SWFFont_getAscent(self.this)
773
774    def getDescent(self):
775        return mingc.SWFFont_getDescent(self.this)
776
777    def getLeading(self):
778        return mingc.SWFFont_getLeading(self.this)
779
780    def getUTF8StringWidth(self):
781        return mingc.SWFFont_getUTF8StringWidth(self.this, string.encode("utf-8"))
782
783    def getStringWidth(self, string):
784        return mingc.SWFFont_getStringWidth(self.this, string)
785
786    # or: (?)
787    def getWidth(self, string):
788        return mingc.SWFFont_getStringWidth(self.this, string)
789
790    def getName(self):
791        return mingc.SWFFont_getName(self.this)
792
793    def getGlyphCount(self):
794        return mingc.SWFFont_getGlyphCount(self.this)
795
796class SWFFontCharacter(SWFBase):
797
798     def addChars(self, string):
799         mingc.SWFFontCharacter_addChars(self.this, string)
800
801     def addUTF8Chars(self, string):
802         mingc.SWFFontCharacter_addUTF8Chars(self.this, string)
803
804     def addAllChars(self, string):
805         mingc.SWFFontCharacter_addAllChars(self.this)
806
807class SWFBitmap(SWFBase):
808
809    def __init__(self, fname, alpha=None):
810        ext = fname[-4:]
811
812        if alpha is None:
813            self.file = open(fname, "rb")
814            self.this = mingc.newSWFBitmap_fromInput(mingc.newSWFInput_file(self.file))
815
816        elif ext == '.jpg' or ext == '.JPG':
817            self.file = open(fname, "rb")
818            self.this = mingc.newSWFBitmap_fromInput(mingc.newSWFInput_file(self.file))
819
820    def __del__(self):
821        mingc.destroySWFBitmap(self.this)
822
823    def getWidth(self):
824        return mingc.SWFBitmap_getWidth(self.this)
825
826    def getHeight(self):
827        return mingc.SWFBitmap_getHeight(self.this)
828
829
830class SWFFontCollection(SWFBase):
831
832    def __init__(self, filename):
833        self.this = mingc.newSWFFontCollection_fromFile(filename)
834
835    def __del__(self):
836        mingc.destroySWFFontCollection(self.this)
837
838    def getFontCount(self):
839        return mingc.SWFFontCollection_getFontCount(self.this)
840
841    def getFont(self, index):
842        return SWFFont(mingc.SWFFontCollection_getFont(self.this, index))
843
844
845# deprecated:
846class SWFDBLBitmap(SWFBitmap):
847
848    def __init__(self, fname):
849        self.this = mingc.newSWFDBLBitmap(open(fname, "rb"))
850
851
852# deprecated:
853class JpegBitmap(SWFBitmap):
854
855    def __init__(self, fname, alpha=None):
856        if alpha is None:
857            self.this = mingc.newSWFJpegBitmap(open(fname, "rb"))
858        else:
859            self.this = mingc.newSWFJpegWithAlpha(open(fname, "rb"), open(alpha, "rb"))
860
861
862class SWFText(SWFBase):
863
864    def __init__(self, version=2):
865        self.__fonts={} # keep reference
866        if version == 2:
867            self.this = mingc.newSWFText2()
868        else:
869            self.this = mingc.newSWFText()
870
871    def __del__(self):
872        mingc.destroySWFText(self.this)
873
874    def setFont(self, font):
875        self.__fonts[font.name] = font
876        mingc.SWFText_setFont(self.this, font.this)
877
878    def setHeight(self, height):
879        mingc.SWFText_setHeight(self.this, height)
880
881    def moveTo(self, x, y):
882        mingc.SWFText_moveTo(self.this, x, y)
883
884    def setColor(self, r, g, b, a=0xff):
885        mingc.SWFText_setColor(self.this, r, g, b, a)
886
887    def addString(self, s, advance=None):
888        mingc.SWFText_addString(self.this, s, advance)
889
890    def addUTF8String(self, s, advance=None):
891        mingc.SWFText_addUTF8String(self.this, s.encode("utf-8"), advance)
892
893    def setSpacing(self, spacing):
894        mingc.SWFText_setSpacing(self.this, spacing)
895
896    def getAscent(self):
897        return mingc.SWFText_getAscent(self.this)
898
899    def getDescent(self):
900        return mingc.SWFText_getDescent(self.this)
901
902    def getLeading(self):
903        return mingc.SWFText_getLeading(self.this)
904
905    def getWidth(self, string):
906        return mingc.SWFText_getStringWidth(self.this, string)
907
908    def getUTF8Width(self, s):
909        return mingc.SWFText_getUTF8StringWidth(self.this, s.encode("utf-8"))
910
911    # deprecated:
912    def setXY(self, x, y):
913        mingc.SWFText_setXY(self.this, x, y)
914
915
916class SWFText2(SWFText):
917
918    def __init__(self):
919        self.this = mingc.newSWFText2()
920
921
922class SWFTextField(SWFBase):
923
924    def __init__(self, flags=None):
925        self.__fonts={} # keep reference
926        self.this = mingc.newSWFTextField()
927
928        if flags is not None:
929            mingc.SWFTextField_setFlags(self.this, flags)
930
931    def __del__(self):
932        mingc.destroySWFTextField(self.this)
933
934    def setFont(self, font):
935        self.__fonts[font.name] = font
936        mingc.SWFTextField_setFont(self.this, font.this)
937
938    def setBounds(self, width, height):
939        mingc.SWFTextField_setBounds(self.this, width, height)
940
941    def setFlags(self, flags):
942        mingc.SWFTextField_setFlags(self.this, flags)
943
944    def setColor(self, r, g, b, a=0xff):
945        mingc.SWFTextField_setColor(self.this, r, g, b, a)
946
947    def setVariableName(self, name):
948        mingc.SWFTextField_setVariableName(self.this, name)
949
950    def addString(self, string):
951        mingc.SWFTextField_addString(self.this, string)
952
953    def addUTF8String(self, string):
954        mingc.SWFTextField_addUTF8String(self.this, string.encode("utf-8"))
955
956    def setHeight(self,  height):
957        mingc.SWFTextField_setHeight(self.this,  height)
958
959    def setLeftMargin(self, leftMargin):
960        mingc.SWFTextField_setLeftMargin(self.this, leftMargin)
961
962    def setRightMargin(self, rightMargin):
963        mingc.SWFTextField_setRightMargin(self.this, rightMargin)
964
965    def setIndentation(self, indentation):
966        mingc.SWFTextField_setIndentation(self.this, indentation)
967
968    def setLineSpacing(self, lineSpacing):
969        mingc.SWFTextField_setLineSpacing(self.this, lineSpacing)
970
971    def setAlignment(self, alignment):
972        mingc.SWFTextField_setAlignment(self.this,  alignment)
973
974    # or just:
975    def align(self, alignment):
976        mingc.SWFTextField_setAlignment(self.this,  alignment)
977
978    def setLength(self, length):
979        mingc.SWFTextField_setLength(self.this, length)
980
981    def addChars(self, string):
982        mingc.SWFTextField_addChars(self.this, string)
983
984    def setPadding(self, pad):
985        mingc.SWFTextField_setPadding(self.this, pad)
986
987    def setFieldHeight(self, height):
988        mingc.SWFTextField_setFieldHeight(self.this, height)
989
990# textfield alignment flags:
991SWFTEXTFIELD_ALIGN_LEFT    = mingc.SWFTEXTFIELD_ALIGN_LEFT
992SWFTEXTFIELD_ALIGN_RIGHT   = mingc.SWFTEXTFIELD_ALIGN_RIGHT
993SWFTEXTFIELD_ALIGN_CENTER  = mingc.SWFTEXTFIELD_ALIGN_CENTER
994SWFTEXTFIELD_ALIGN_JUSTIFY = mingc.SWFTEXTFIELD_ALIGN_JUSTIFY
995
996# other flags:
997
998SWFTEXTFIELD_ONMASK    = mingc.SWFTEXTFIELD_ONMASK
999SWFTEXTFIELD_OFFMASK   = mingc.SWFTEXTFIELD_OFFMASK
1000SWFTEXTFIELD_HASFONT   = mingc.SWFTEXTFIELD_HASFONT
1001SWFTEXTFIELD_HASLENGTH = mingc.SWFTEXTFIELD_HASLENGTH
1002SWFTEXTFIELD_HASCOLOR  = mingc.SWFTEXTFIELD_HASCOLOR
1003SWFTEXTFIELD_NOEDIT    = mingc.SWFTEXTFIELD_NOEDIT
1004SWFTEXTFIELD_PASSWORD  = mingc.SWFTEXTFIELD_PASSWORD
1005SWFTEXTFIELD_MULTILINE = mingc.SWFTEXTFIELD_MULTILINE
1006SWFTEXTFIELD_WORDWRAP  = mingc.SWFTEXTFIELD_WORDWRAP
1007SWFTEXTFIELD_HASTEXT   = mingc.SWFTEXTFIELD_HASTEXT
1008SWFTEXTFIELD_USEFONT   = mingc.SWFTEXTFIELD_USEFONT
1009SWFTEXTFIELD_HTML      = mingc.SWFTEXTFIELD_HTML
1010SWFTEXTFIELD_DRAWBOX   = mingc.SWFTEXTFIELD_DRAWBOX
1011SWFTEXTFIELD_NOSELECT  = mingc.SWFTEXTFIELD_NOSELECT
1012SWFTEXTFIELD_HASLAYOUT = mingc.SWFTEXTFIELD_HASLAYOUT
1013SWFTEXTFIELD_AUTOSIZE  = mingc.SWFTEXTFIELD_AUTOSIZE
1014
1015class SWFSoundStream(SWFBase):
1016
1017    def __init__(self, fname):
1018        self.file = open(fname, "rb")
1019        self.this = mingc.newSWFSoundStream(self.file)
1020
1021    def getDuration(self):
1022        return mingc.SWFSoundStream_getDuration(self.this)
1023
1024    def setInitialMp3Delay(self, delay):
1025        mingc.SWFSoundStream_setInitialMp3Delay(self.this, delay)
1026
1027class SWFSound(SWFBase):
1028
1029    def __init__(self, arg, flags=0):
1030        self.arg = arg;
1031        if isinstance(arg, SWFSoundStream):
1032            self.this = mingc.newSWFSound_fromSoundStream(arg)
1033        else:
1034            self.file = open(arg, "rb")
1035            self.this = mingc.newSWFSound(self.file, flags)
1036
1037    def setInitialMp3Delay(self, delay):
1038        mingc.SWFSound_setInitialMp3Delay(self.this, delay)
1039
1040    # display list destroys this..
1041
1042SWF_SOUND_COMPRESSION       = mingc.SWF_SOUND_COMPRESSION
1043SWF_SOUND_NOT_COMPRESSED    = mingc.SWF_SOUND_NOT_COMPRESSED
1044SWF_SOUND_ADPCM_COMPRESSED  = mingc.SWF_SOUND_ADPCM_COMPRESSED
1045SWF_SOUND_MP3_COMPRESSED    = mingc.SWF_SOUND_MP3_COMPRESSED
1046SWF_SOUND_NOT_COMPRESSED_LE = mingc.SWF_SOUND_NOT_COMPRESSED_LE
1047SWF_SOUND_NELLY_COMPRESSED  = mingc.SWF_SOUND_NELLY_COMPRESSED
1048SWF_SOUND_RATE              = mingc.SWF_SOUND_RATE
1049SWF_SOUND_5KHZ              = mingc.SWF_SOUND_5KHZ
1050SWF_SOUND_11KHZ             = mingc.SWF_SOUND_11KHZ
1051SWF_SOUND_22KHZ             = mingc.SWF_SOUND_22KHZ
1052SWF_SOUND_44KHZ             = mingc.SWF_SOUND_44KHZ
1053SWF_SOUND_BITS              = mingc.SWF_SOUND_BITS
1054SWF_SOUND_8BITS             = mingc.SWF_SOUND_8BITS
1055SWF_SOUND_16BITS            = mingc.SWF_SOUND_16BITS
1056SWF_SOUND_CHANNELS          = mingc.SWF_SOUND_CHANNELS
1057SWF_SOUND_MONO              = mingc.SWF_SOUND_MONO
1058SWF_SOUND_STEREO            = mingc.SWF_SOUND_STEREO
1059
1060class SWFSoundInstance(SWFBase):
1061
1062    def setNoMultiple(self):
1063        mingc.SWFSoundInstance_setNoMultiple(self.this)
1064
1065    def setLoopInPoint(self, point):
1066        mingc.SWFSoundInstance_setLoopInPoint(self.this, point)
1067
1068    def setLoopOutPoint(self, point):
1069        mingc.SWFSoundInstance_setLoopOutPoint(self.this, point)
1070
1071    def setLoopCount(self, count):
1072        mingc.SWFSoundInstance_setLoopCount(self.this, count)
1073
1074    def addEnvelope(self, mark44, left, right):
1075        mingc.SWFSoundInstance_addEnvelope(self.this, mark44, left, right)
1076
1077class SWFAction(SWFBase):
1078
1079    def __init__(self, script):
1080        self.this = mingc.newSWFAction(script)
1081
1082    def compile(swfVersion):
1083        return mingc.SWFAction_compile(self.this, swfVersion, NULL)
1084
1085class SWFInitAction(SWFBase):
1086
1087   def __init__(self, action):
1088       self.this = mingc.newSWFInitAction(action.this)
1089
1090    # assigned object will destroy this..
1091
1092SWF_GRADIENT_PAD	= mingc.SWF_GRADIENT_PAD
1093SWF_GRADIENT_REFLECT	= mingc.SWF_GRADIENT_REFLECT
1094SWF_GRADIENT_REPEAT	= mingc.SWF_GRADIENT_REPEAT
1095SWF_GRADIENT_NORMAL	= mingc.SWF_GRADIENT_NORMAL
1096SWF_GRADIENT_LINEAR	= mingc.SWF_GRADIENT_LINEAR
1097
1098class SWFGradient(SWFBase):
1099
1100    def __init__(self):
1101        self.this = mingc.newSWFGradient()
1102
1103    def __del__(self):
1104        mingc.destroySWFGradient(self.this)
1105
1106    def addEntry(self, ratio, r, g, b, a=0xff):
1107        mingc.SWFGradient_addEntry(self.this, ratio, r, g, b, a)
1108
1109    def setSpreadMode(self, mode):
1110        mingc.SWFGradient_setSpreadMode(self.this, mode)
1111
1112    def setInterpolationMode(self, mode):
1113        mingc.SWFGradient_setInterpolationMode(self.this, mode)
1114
1115    def SWFGradient_setFocalPoint(self, fp):
1116        mingc.SWFGradient_setFocalPoint(self.this, fp)
1117
1118class SWFButton(SWFBase):
1119
1120    def __init__(self):
1121        self.this = mingc.newSWFButton()
1122        self.shapes = []
1123
1124    def __del__(self):
1125        mingc.destroySWFButton(self.this)
1126
1127    def setUp(self, character):
1128        self.addShape(character, SWFBUTTON_UP)
1129
1130    def setDown(self, character):
1131        self.addShape(character, SWFBUTTON_DOWN)
1132
1133    def setOver(self, character):
1134        self.addShape(character, SWFBUTTON_OVER)
1135
1136    def setHit(self, character):
1137        self.addShape(character, SWFBUTTON_HIT)
1138
1139    def addShape(self, character, flags):
1140        self.shapes.append(character)
1141        mingc.SWFButton_addCharacter(self.this, character, flags)
1142
1143    def addAction(self, action, flags):
1144        mingc.SWFButton_addAction(self.this, action.this, flags)
1145
1146    def addCharacter(self, character, flags):
1147        self.shapes.append(character)
1148        return SWFButtonRecord(mingc.SWFButton_addCharacter(self.this, character, flags))
1149
1150    def addSound(self, sound, flags):
1151        return SWFSoundInstance(mingc.SWFButton_addSound(self.this, sound.this, flags))
1152
1153    def setMenu(self, flag):
1154        mingc.SWFButton_setMenu(self.this, flag)
1155
1156    def setScalingGrid(self, x, y, w, h):
1157        mingc.SWFButton_setScalingGrid(self.this, x, y, w, h)
1158
1159    def removeScalingGrid(self):
1160        mingc.SWFButton_removeScalingGrid(self.this)
1161
1162class SWFButtonRecord(SWFBase):
1163
1164    def setDepth(self, depth):
1165        mingc.SWFButtonRecord_setDepth(self.this, depth)
1166
1167    def setBlendMode(self, mode):
1168        mingc.SWFButtonRecord_setBlendMode(self.this, mode)
1169
1170    def move(self, x, y):
1171        mingc.SWFButtonRecord_move(self.this, x, y)
1172
1173    def moveTo(self, x, y):
1174        mingc.SWFButtonRecord_moveTo(self.this, x, y)
1175
1176    def rotate(self, deg):
1177        mingc.SWFButtonRecord_rotate(self.this, deg)
1178
1179    def rotateTo(self, deg):
1180        mingc.SWFButtonRecord_rotateTo(self.this, deg)
1181
1182    def scale(self, sx, sy):
1183        mingc.SWFButtonRecord_scale(self.this, sx, sy)
1184
1185    def scaleTo(self, sx, sy):
1186        mingc.SWFButtonRecord_scaleTo(self.this, sx, sy)
1187
1188    def skewX(self, sx):
1189        mingc.SWFButtonRecord_skewX(self.this, sx)
1190
1191    def skewXTo(self, sx):
1192        mingc.SWFButtonRecord_skewXTo(self.this, sx)
1193
1194    def skewY(self, sy):
1195        mingc.SWFButtonRecord_skewY(self.this, sy)
1196
1197    def skewYTo(self, sy):
1198        mingc.SWFButtonRecord_skewXTo(self.this, sy)
1199
1200    def addFilter(self, filter):
1201        mingc.SWFButtonRecord_addFilter(self.this, filter.this)
1202
1203SWFVIDEOSTREAM_MODE_AUTO = mingc.SWFVIDEOSTREAM_MODE_AUTO
1204SWFVIDEOSTREAM_MODE_MANUAL = mingc.SWFVIDEOSTREAM_MODE_MANUAL
1205
1206class SWFVideoStream(SWFBase):
1207    def __init__(self, filename=None):
1208	if filename is None:
1209		self.file = 0;
1210        	self.this = mingc.newSWFVideoStream()
1211	else:
1212		self.file = open(filename, "rb");
1213        	self.this = mingc.newSWFVideoStream_fromFile(self.file)
1214    def setDimension(self, w, h):
1215        return mingc.SWFVideoStream_setDimension(self.this, w, h)
1216    def getNumFrames(self):
1217        return mingc.SWFVideoStream_getNumFrames(self.this)
1218    def hasAudio(self):
1219        return mingc.SWFVideoStream_hasAudio(self.this)
1220    def setFrameMode(self, mode):
1221        return mingc.SWFVideoStream_setFrameMode(self.this, mode)
1222    def nextFrame(self):
1223        return mingc.SWFVideoStream_nextFrame(self.this)
1224    def seek(self, frame, whence):
1225        return mingc.SWFVideoStream_seek(self.this, frame, whence)
1226    def __del__(self):
1227        mingc.destroySWFVideoStream(self.this)
1228
1229def SWFBUTTON_KEYPRESS(c):
1230    return mingc.swfButton_keypress(c)
1231
1232# addShape flags:
1233SWFBUTTON_UP             = mingc.SWFBUTTON_UP
1234SWFBUTTON_HIT            = mingc.SWFBUTTON_HIT
1235SWFBUTTON_DOWN           = mingc.SWFBUTTON_DOWN
1236SWFBUTTON_OVER           = mingc.SWFBUTTON_OVER
1237
1238# addAction flags:
1239SWFBUTTON_MOUSEUPOUTSIDE = mingc.SWFBUTTON_MOUSEUPOUTSIDE
1240SWFBUTTON_DRAGOVER       = mingc.SWFBUTTON_DRAGOVER
1241SWFBUTTON_DRAGOUT        = mingc.SWFBUTTON_DRAGOUT
1242SWFBUTTON_MOUSEUP        = mingc.SWFBUTTON_MOUSEUP
1243SWFBUTTON_MOUSEDOWN      = mingc.SWFBUTTON_MOUSEDOWN
1244SWFBUTTON_MOUSEOUT       = mingc.SWFBUTTON_MOUSEOUT
1245SWFBUTTON_MOUSEOVER      = mingc.SWFBUTTON_MOUSEOVER
1246
1247class SWFPrebuiltClip(SWFBase):
1248    def __init__(self, filename):
1249        self.this = mingc.newSWFPrebuiltClip_fromFile(filename)
1250    def __del__(self):
1251        mingc.destroySWFPrebuiltClip(self.this)
1252
1253class SWFBinaryData(SWFBase):
1254    def __init__(self, string, len):
1255        self.this = mingc.newSWFBinaryData(string, len)
1256    def __del__(self):
1257        mingc.destroySWFBinaryData(self.this)
1258