rfxswf cleanups: added prefixes and altered structure name conventions
[swftools.git] / lib / modules / swfobject.c
1 /* swfobject.c
2
3    Object place and move routines
4       
5    Extension module for the rfxswf library.
6    Part of the swftools package.
7
8    Copyright (c) 2001 Rainer Böhme <rfxswf@reflex-studio.de>
9  
10    This file is distributed under the GPL, see file COPYING for details 
11
12 */
13
14 #define PF_MOVE         0x01
15 #define PF_CHAR         0x02
16 #define PF_MATRIX       0x04
17 #define PF_CXFORM       0x08
18 #define PF_RATIO        0x10
19 #define PF_NAME         0x20
20 #define PF_CLIPACTION   0x40
21
22 int swf_ObjectPlace(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name)
23 { U8 flags;
24   if (!t) return -1;
25
26   flags = (id?PF_CHAR:0)|(m?PF_MATRIX:0)|(cx?PF_CXFORM:0)|(name?PF_NAME:0)|((m||cx)&&(!id)?PF_MOVE:0);
27
28   swf_SetU8(t,flags);
29   swf_SetU16(t,depth);
30   if (flags&PF_CHAR) swf_SetU16(t,id);
31   if (flags&PF_MATRIX) swf_SetMatrix(t,m);
32   if (flags&PF_CXFORM) swf_SetCXForm(t,cx,(cx->a0!=256)||(cx->a1));
33   if (flags&PF_RATIO) swf_SetU16(t,0);
34   if (flags&PF_NAME) swf_SetString(t,name);
35   
36   return 0; 
37 }
38
39 int swf_ObjectPlaceClip(TAG * t,U16 id,U16 depth,MATRIX * m,CXFORM * cx,U8 * name, U16 clipaction)
40 { U8 flags;
41   if (!t) return -1;
42
43   flags = (id?PF_CHAR:0)|(m?PF_MATRIX:0)|(cx?PF_CXFORM:0)|(name?PF_NAME:0)|
44           ((m||cx)&&(!id)?PF_MOVE:0)|(clipaction?PF_CLIPACTION:0);
45
46   swf_SetU8(t,flags);
47   swf_SetU16(t,depth);
48   if (flags&PF_CHAR) swf_SetU16(t,id);
49   if (flags&PF_MATRIX) swf_SetMatrix(t,m);
50   if (flags&PF_CXFORM) swf_SetCXForm(t,cx,(cx->a0!=256)||(cx->a1));
51   if (flags&PF_RATIO) swf_SetU16(t,0);
52   if (flags&PF_NAME) swf_SetString(t,name);
53   if (flags&PF_CLIPACTION) swf_SetU16(t, clipaction);
54   return 0; 
55 }
56
57 int swf_ObjectMove(TAG * t,U16 depth,MATRIX * m,CXFORM * cx)
58 { return swf_ObjectPlace(t,0,depth,m,cx,NULL);
59 }