X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fswfc.c;h=40f011f5b4cc7b5e30ff025872f5f239b0b279ab;hb=207ff1e0876ef04db4ab3e3cc34e49150aa33093;hp=b1f42cb32ec5b6a0a9a43414c6d7e71d6d69bf95;hpb=0b3da0905e9d8bc4cf725b23bcb0be95d99879e9;p=swftools.git diff --git a/src/swfc.c b/src/swfc.c index b1f42cb..40f011f 100644 --- a/src/swfc.c +++ b/src/swfc.c @@ -805,16 +805,18 @@ void s_box(char*name, int width, int height, RGBA color, int linewidth, char*tex r2.ymax = height; tag = swf_InsertTag(tag, ST_DEFINESHAPE3); swf_ShapeNew(&s); - if(linewidth) - ls1 = swf_ShapeAddLineStyle(s,linewidth>=20?linewidth-20:0,&color); + if(linewidth) { + linewidth = linewidth>=20?linewidth-20:0; + ls1 = swf_ShapeAddLineStyle(s,linewidth,&color); + } if(texture) fs1 = addFillStyle(s, &r2, texture); swf_SetU16(tag,id); - r.xmin = r2.xmin-linewidth-linewidth/2; - r.ymin = r2.ymin-linewidth-linewidth/2; - r.xmax = r2.xmax+linewidth+linewidth/2; - r.ymax = r2.ymax+linewidth+linewidth/2; + r.xmin = r2.xmin-linewidth/2; + r.ymin = r2.ymin-linewidth/2; + r.xmax = r2.xmax+linewidth/2; + r.ymax = r2.ymax+linewidth/2; swf_SetRect(tag,&r); swf_SetShapeHeader(tag,s); swf_ShapeSetAll(tag,s,0,0,ls1,fs1,0); @@ -843,22 +845,24 @@ void s_filled(char*name, char*outlinename, RGBA color, int linewidth, char*textu tag = swf_InsertTag(tag, ST_DEFINESHAPE3); swf_ShapeNew(&s); - if(linewidth) - ls1 = swf_ShapeAddLineStyle(s,linewidth>=20?linewidth-20:0,&color); + if(linewidth) { + linewidth = linewidth>=20?linewidth-20:0; + ls1 = swf_ShapeAddLineStyle(s,linewidth,&color); + } if(texture) fs1 = addFillStyle(s, &r2, texture); swf_SetU16(tag,id); - rect.xmin = r2.xmin-linewidth-linewidth/2; - rect.ymin = r2.ymin-linewidth-linewidth/2; - rect.xmax = r2.xmax+linewidth+linewidth/2; - rect.ymax = r2.ymax+linewidth+linewidth/2; + rect.xmin = r2.xmin-linewidth/2; + rect.ymin = r2.ymin-linewidth/2; + rect.xmax = r2.xmax+linewidth/2; + rect.ymax = r2.ymax+linewidth/2; swf_SetRect(tag,&rect); swf_SetShapeStyles(tag, s); swf_ShapeCountBits(s,0,0); - swf_RecodeShapeData(outline->shape->data, outline->shape->bitlen, 1, 1, - &s->data, &s->bitlen, s->bits.fill, s->bits.line); + swf_RecodeShapeData(outline->shape->data, outline->shape->bitlen, outline->shape->bits.fill, outline->shape->bits.line, + &s->data, &s->bitlen, s->bits.fill, s->bits.line); swf_SetShapeBits(tag, s); swf_SetBlock(tag, s->data, (s->bitlen+7)/8); swf_ShapeFree(s); @@ -878,15 +882,17 @@ void s_circle(char*name, int r, RGBA color, int linewidth, char*texture) tag = swf_InsertTag(tag, ST_DEFINESHAPE3); swf_ShapeNew(&s); - if(linewidth) - ls1 = swf_ShapeAddLineStyle(s,linewidth>=20?linewidth-20:0,&color); + if(linewidth) { + linewidth = linewidth>=20?linewidth-20:0; + ls1 = swf_ShapeAddLineStyle(s,linewidth,&color); + } if(texture) fs1 = addFillStyle(s, &r2, texture); swf_SetU16(tag,id); - rect.xmin = r2.xmin-linewidth-linewidth/2; - rect.ymin = r2.ymin-linewidth-linewidth/2; - rect.xmax = r2.xmax+linewidth+linewidth/2; - rect.ymax = r2.ymax+linewidth+linewidth/2; + rect.xmin = r2.xmin-linewidth/2; + rect.ymin = r2.ymin-linewidth/2; + rect.xmax = r2.xmax+linewidth/2; + rect.ymax = r2.ymax+linewidth/2; swf_SetRect(tag,&rect); swf_SetShapeHeader(tag,s); @@ -973,7 +979,7 @@ void s_quicktime(char*name, char*url) incrementid(); } -void s_edittext(char*name, char*fontname, int size, int width, int height, char*text, RGBA*color, int maxlength, char*variable, int flags) +void s_edittext(char*name, char*fontname, int size, int width, int height, char*text, RGBA*color, int maxlength, char*variable, int flags, int align) { SWFFONT*font = 0; EditTextLayout layout; @@ -987,7 +993,7 @@ void s_edittext(char*name, char*fontname, int size, int width, int height, char* } tag = swf_InsertTag(tag, ST_DEFINEEDITTEXT); swf_SetU16(tag, id); - layout.align = 0; + layout.align = align; layout.leftmargin = 0; layout.rightmargin = 0; layout.indent = 0; @@ -1341,7 +1347,9 @@ void s_outline(char*name, char*format, char*source) SHAPE2* shape2; SRECT bounds; + //swf_Shape10DrawerInit(&draw, 0); swf_Shape11DrawerInit(&draw, 0); + draw_string(&draw, source); draw.finish(&draw); shape = swf_ShapeDrawerToShape(&draw); @@ -2700,7 +2708,7 @@ static int c_on_key(map_t*args) static int c_edittext(map_t*args) { - //"name font size width height text="" color=black maxlength=0 variable="" @password=0 @wordwrap=0 @multiline=0 @html=0 @noselect=0 @readonly=0"}, + //"name font size width height text="" color=black maxlength=0 variable="" @password=0 @wordwrap=0 @multiline=0 @html=0 @noselect=0 @readonly=0 @autosize=0"}, char*name = lu(args, "name"); char*font = lu(args, "font"); int size = (int)(1024*parsePxOrPercent(font, lu(args, "size"))); @@ -2717,6 +2725,9 @@ static int c_edittext(map_t*args) char*noselectstr = lu(args, "noselect"); char*readonlystr = lu(args, "readonly"); char*borderstr = lu(args, "border"); + char*autosizestr = lu(args, "autosize"); + char*alignstr = lu(args, "align"); + int align = -1; int flags = 0; if(!strcmp(passwordstr, "password")) flags |= ET_PASSWORD; @@ -2726,8 +2737,14 @@ static int c_edittext(map_t*args) if(!strcmp(htmlstr, "html")) flags |= ET_HTML; if(!strcmp(noselectstr, "noselect")) flags |= ET_NOSELECT; if(!strcmp(borderstr, "border")) flags |= ET_BORDER; - - s_edittext(name, font, size, width, height, text, &color, maxlength, variable, flags); + if(!strcmp(autosizestr, "autosize")) flags |= ET_AUTOSIZE; + if(!strcmp(alignstr, "left") || !*alignstr) align = ET_ALIGN_LEFT; + else if(!strcmp(alignstr, "right")) align = ET_ALIGN_RIGHT; + else if(!strcmp(alignstr, "center")) align = ET_ALIGN_CENTER; + else if(!strcmp(alignstr, "justify")) align = ET_ALIGN_JUSTIFY; + else syntaxerror("Unknown alignment: %s", alignstr); + + s_edittext(name, font, size, width, height, text, &color, maxlength, variable, flags, align); return 0; } @@ -2816,7 +2833,7 @@ static struct { {"egon", c_egon, "name vertices color=white line=1 @fill=none"}, {"text", c_text, "name text font size=100% color=white"}, - {"edittext", c_edittext, "name font= size=100% width height text="" color=white maxlength=0 variable="" @password=0 @wordwrap=0 @multiline=0 @html=0 @noselect=0 @readonly=0 @border=0"}, + {"edittext", c_edittext, "name font= size=100% width height text="" color=white maxlength=0 variable="" @password=0 @wordwrap=0 @multiline=0 @html=0 @noselect=0 @readonly=0 @border=0 @autosize=0 align="}, {"morphshape", c_morphshape, "name start end"}, {"button", c_button, "name"}, {"show", c_show, "name x=0 y=0 red=+0 green=+0 blue=+0 alpha=+0 luminance= scale= scalex= scaley= pivot= pin= shear= rotate= ratio= above= below= as="},