more fiddling with edgestyles
[swftools.git] / lib / python / tag.c
index 5d55fb3..f495499 100644 (file)
@@ -83,7 +83,7 @@ static void tag_dealloc(PyObject * self)
        tag->internals.data = 0;
     }
     if(tag->internals.tag) {
-       swf_DeleteTag(tag->internals.tag);
+       swf_DeleteTag(0, tag->internals.tag);
        tag->internals.tag = 0;
     }
     Py_DECREF(tag->internals.tagmap);
@@ -117,6 +117,17 @@ static PyObject* tag_isShape(PyObject * _self, PyObject*args)
     if(!fillTAG((PyObject*)self))   return NULL;
     return PyInt_FromLong(swf_isShapeTag(self->internals.tag));
 }
+static PyObject* tag_isFont(PyObject * _self, PyObject*args)
+{
+    TagObject*self = (TagObject*)_self;
+    if(!PyArg_ParseTuple(args, "")) return NULL;
+    if(!fillTAG((PyObject*)self))   return NULL;
+    int id = self->internals.tag->id;
+    int isfont=0;
+    if(id == ST_DEFINEFONT || id == ST_DEFINEFONT2)
+       isfont = 1;
+    return PyInt_FromLong(isfont);
+}
 static PyObject* tag_isImage(PyObject * _self, PyObject*args)
 {
     TagObject*self = (TagObject*)_self;
@@ -131,6 +142,14 @@ static PyObject* tag_isDefiningTag(PyObject * _self, PyObject*args)
     if(!fillTAG((PyObject*)self))   return NULL;
     return PyInt_FromLong(swf_isDefiningTag(self->internals.tag));
 }
+static PyObject* tag_isPlacement(PyObject * _self, PyObject*args)
+{
+    TagObject*self = (TagObject*)_self;
+    if(!PyArg_ParseTuple(args, "")) return NULL;
+    if(!fillTAG((PyObject*)self))   return NULL;
+    return PyInt_FromLong((self->internals.tag->id == ST_PLACEOBJECT ||
+                          self->internals.tag->id == ST_PLACEOBJECT2));
+}
 static PyObject* tag_getBBox(PyObject * _self, PyObject*args)
 {
     TagObject*self = (TagObject*)_self;
@@ -138,12 +157,24 @@ static PyObject* tag_getBBox(PyObject * _self, PyObject*args)
     if(!fillTAG((PyObject*)self))   return NULL;
     return f_BBox2(swf_GetDefineBBox(self->internals.tag));
 }
+static PyObject* tag_setBBox(PyObject * _self, PyObject*args)
+{
+    TagObject*self = (TagObject*)_self;
+    PyObject*bbox = 0;
+    if(!PyArg_ParseTuple(args, "O!", &BBoxClass, &bbox)) return NULL;
+    if(!fillTAG((PyObject*)self))   return NULL;
+    swf_SetDefineBBox(self->internals.tag, bbox_getSRECT(bbox));
+    return PY_NONE;
+}
 //----------------------------------------------------------------------------
 static PyMethodDef common_tagfunctions[] =
 {{"isShape", tag_isShape, METH_VARARGS, "tests whether the tag is a shape tag"},
  {"isImage", tag_isImage, METH_VARARGS, "tests whether the tag is an image"},
+ {"isFont", tag_isFont, METH_VARARGS, "tests whether the tag is a font"},
  {"isDefiningTag", tag_isDefiningTag, METH_VARARGS, "tests whether the tag is a defining tag"},
+ {"isPlacement", tag_isPlacement, METH_VARARGS, "tests whether the tag is a placement"},
  {"getBBox", tag_getBBox, METH_VARARGS, "get's the tags bounding box"},
+ {"setBBox", tag_setBBox, METH_VARARGS, "set's the tags bounding box"},
  {NULL, NULL, 0, NULL}
 };
 
@@ -165,6 +196,11 @@ static PyObject* tag_getattr(PyObject * self, char* a)
        char* name = swf_TagGetName(tag->internals.tag);
        return Py_BuildValue("s", name);
     }
+    if(!strcmp(a, "data")) {
+       if(!fillTAG(self))
+           return 0;
+       return Py_BuildValue("s#", tag->internals.tag->data, tag->internals.tag->len);
+    }
     if(tag->internals.getattr) {
        PyObject* ret = tag->internals.getattr(&tag->internals, a);
        if(ret) return ret;
@@ -193,7 +229,7 @@ static int tag_setattr(PyObject * _self, char* a, PyObject * o)
     /* a setattr will almost certainly change the tag data,
        so delete the tag */
     if(self->internals.tag) {
-       swf_DeleteTag(self->internals.tag);
+       swf_DeleteTag(0, self->internals.tag);
        self->internals.tag = 0;
     }
     if(self->internals.setattr) {