X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpython%2Ftags.c;h=7235e1ee0afc555d9538e885af4f95383945d355;hb=e069f3af1280183fa6e3d219ace624c31aef0080;hp=1f8e658e75002af6e6512a0de74c1bbdab985979;hpb=ec2e9a68ca39bb6d8c8dd685a67b697a4a65652f;p=swftools.git diff --git a/lib/python/tags.c b/lib/python/tags.c index 1f8e658..7235e1e 100644 --- a/lib/python/tags.c +++ b/lib/python/tags.c @@ -288,6 +288,32 @@ static tag_internals_t showframe_tag = datasize: 0, }; //---------------------------------------------------------------------------- +staticforward tag_internals_t removeobject_tag; +static PyObject* f_RemoveObject(PyObject* self, PyObject* args, PyObject* kwargs) +{ + static char *kwlist[] = {"depth", NULL}; + int depth; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &depth)) + return NULL; + + PyObject*tag = tag_new(&removeobject_tag); + tag_internals_t*itag = tag_getinternals(tag); + itag->tag = swf_InsertTag(0, ST_REMOVEOBJECT); + swf_SetU16(itag->tag, depth); + mylog("+%08x(%d) f_RemoveObject", (int)tag, tag->ob_refcnt); + return (PyObject*)tag; +} +static tag_internals_t removeobject_tag = +{ + parse: 0, + fillTAG: 0, + dealloc: 0, + getattr: 0, + setattr: 0, + tagfunctions: 0, + datasize: 0, +}; +//---------------------------------------------------------------------------- staticforward tag_internals_t sprite_tag; typedef struct _sprite_internal { @@ -391,6 +417,7 @@ typedef struct _text_internal SWFFONT* swffont; RGBA rgba; int size; + SRECT bbox; } text_internal_t; staticforward tag_internals_t placeobject_tag; @@ -399,9 +426,17 @@ static int text_fillTAG(tag_internals_t*self) text_internal_t*ti = (text_internal_t*)self->data; self->tag= swf_InsertTag(0, ST_DEFINETEXT2); swf_SetU16(self->tag, /*ID*/0); - SRECT r = swf_SetDefineText(self->tag, ti->swffont, &ti->rgba, ti->text, ti->size); + ti->bbox = swf_SetDefineText(self->tag, ti->swffont, &ti->rgba, ti->text, ti->size); return 1; } +static PyObject* text_getattr(tag_internals_t*self,char*a) +{ + text_internal_t*si = (text_internal_t*)self->data; + if(!strcmp(a, "bbox")) { + return f_BBox2(si->bbox); + } + return 0; +} static PyObject* f_DefineText(PyObject* self, PyObject* args, PyObject* kwargs) { static char *kwlist[] = {"font", "text", "size", "color", NULL}; @@ -415,7 +450,11 @@ static PyObject* f_DefineText(PyObject* self, PyObject* args, PyObject* kwargs) if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!Oi|O!", kwlist, &TagClass, &font, &otext, &size, &ColorClass, &color)) return NULL; - text = PyString_AS_STRING(PyUnicode_AsUTF8String(otext)); + if(PyUnicode_Check(otext)) { + text = PyString_AS_STRING(PyUnicode_AsUTF8String(otext)); + } else if(PyString_Check(otext)) { + text = PyString_AS_STRING(otext); + } if(color) rgba = color_getRGBA(color); @@ -440,7 +479,7 @@ static tag_internals_t text_tag = parse: 0, fillTAG: text_fillTAG, dealloc: 0, - getattr: 0, + getattr: text_getattr, setattr: 0, tagfunctions: 0, datasize: sizeof(text_internal_t), @@ -817,6 +856,7 @@ static PyMethodDef TagMethods[] = {"Font", (PyCFunction)f_DefineFont, METH_KEYWORDS, "Create a DefineFont Tag."}, {"Text", (PyCFunction)f_DefineText, METH_KEYWORDS, "Create a DefineText Tag."}, {"PlaceObject", (PyCFunction)f_PlaceObject, METH_KEYWORDS, "Create a PlaceObject Tag."}, + {"RemoveObject", (PyCFunction)f_RemoveObject, METH_KEYWORDS, "Create a RemoveObject Tag."}, {"MoveObject", (PyCFunction)f_MoveObject, METH_KEYWORDS, "Create a PlaceObject Move Tag."}, {"VideoStream", (PyCFunction)f_DefineVideoStream, METH_KEYWORDS, "Create a Videostream."}, {"Image", (PyCFunction)f_DefineImage, METH_KEYWORDS, "Create an SWF Image Tag."}, @@ -831,6 +871,8 @@ PyMethodDef* tags_getMethods() register_tag(ST_PLACEOBJECT,&placeobject_tag); register_tag(ST_PLACEOBJECT2,&placeobject_tag); + register_tag(ST_REMOVEOBJECT,&removeobject_tag); + register_tag(ST_REMOVEOBJECT2,&removeobject_tag); register_tag(ST_SETBACKGROUNDCOLOR,&bgcolor_tag); register_tag(ST_DEFINEFONT,&font_tag); register_tag(ST_PROTECT,&protect_tag);