X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fexample%2Fedittext.c;h=19b04a46ef8f5039d0fb86a9561e7e0a34791a55;hb=879d0eec420fe0fd5ddcd56c8fe62b82a6744edd;hp=65c124eab24bbdcc82c8d61cc6152439693baada;hpb=0720ce023d5ae1913d6f53627d4705b7a7856c40;p=swftools.git diff --git a/lib/example/edittext.c b/lib/example/edittext.c index 65c124e..19b04a4 100644 --- a/lib/example/edittext.c +++ b/lib/example/edittext.c @@ -4,7 +4,7 @@ Part of the swftools package. - Copyright (c) 2000, 2001 Matthias Kramm + Copyright (c) 2000, 2001 Matthias Kramm This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,20 +25,16 @@ #include #include "../rfxswf.h" -TAG* tag; - /* defined below: */ extern char * longtext; extern SWFFONT * Font_Courier(U16 id); -/* Notice: It seems Flash Players 5 and below always use their - built-in font for edittext, even if some other font is given */ - int main (int argc,char ** argv) { SWF swf; RGBA rgb; SRECT r; MATRIX m; + TAG* tag; EditTextLayout layout; SWFFONT*font; S32 width=640,height = 480; @@ -63,7 +59,6 @@ int main (int argc,char ** argv) swf_GetMatrix(0, &m); tag = swf_InsertTag(tag,ST_DEFINEFONT2); - //font = Font_Dingbats(76); font = Font_Courier(76); swf_FontSetDefine2(tag, font); @@ -91,22 +86,22 @@ int main (int argc,char ** argv) /* this is the standard edit field, upper left corner */ swf_SetEditText(tag, ET_USEOUTLINES|ET_MULTILINE|ET_BORDER, r, "everything you\ntype in the\nleft box\nalso appears\nin the right\nbox", - &rgb, 0, /*font id*/76, 30*20, &layout, "/:variable1"); + &rgb, 0, /*font id*/76, 10*20, &layout, "/:variable1"); } if (t==1) { /* this field (upper right corner) mirrors the first field, without being editable */ swf_SetEditText(tag, ET_NOSELECT|ET_MULTILINE|ET_BORDER|ET_READONLY, r, 0, &rgb, 0, - /*font id*/76, 20*20, &layout, "/:variable1"); + /*font id*/0, 20*20, &layout, "/:variable1"); } if (t==2) { /* another edit field, in brown (lower left corner) */ rgb.r = 80; rgb.g = 80; swf_SetEditText(tag, ET_WORDWRAP|ET_MULTILINE|ET_BORDER, r, longtext, &rgb, 0, - /*font id*/76, 10*20, &layout, "/:variable2"); + /*font id*/0, 10*20, &layout, "/:variable2"); } if (t==3) { m.ty += 40*20; /* password edit field , lower right corner*/ swf_SetEditText(tag, ET_PASSWORD, r, 0, &rgb, 0, - /*font id*/76, 24*20, &layout, "/:variable3"); + /*font id*/0, 24*20, &layout, "/:variable3"); } tag = swf_InsertTag(tag,ST_PLACEOBJECT2); @@ -126,11 +121,11 @@ int main (int argc,char ** argv) tag = swf_InsertTag(tag,ST_SHOWFRAME); tag = swf_InsertTag(tag,ST_END); - f = open("edittext.swf",O_WRONLY|O_CREAT|O_TRUNC, 0644); - if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n"); + f = open("edittext.swf",O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644); + if(swf_WriteSWF(f,&swf)<0) fprintf(stderr,"WriteSWF() failed.\n"); close(f); - swf_FreeTags(&swf); // cleanup + swf_FreeTags(&swf); return 0; } @@ -228,7 +223,7 @@ void fn5b6e(SWFFONT * f,int i,U16 ascii,U16 advance,U8 * data,U32 bitlen,int xmi } U8 Glyphs_Courier[] = { - 0x0a, 0x0b, 0x0a, 0x92, 0xe6, 0xa0, 0x22, 0x90, + 0x00, 0x00, 0x00, 0x92, 0xe6, 0xa0, 0x22, 0x90, 0x2a, 0xc0, 0xe6, 0x6f, 0xab, 0x8b, 0x8f, 0xa9, 0xad, 0x41, 0xbe, 0xd2, 0x24, 0xfc, 0xc0, 0xd4, 0xe6, 0x09, 0x14, 0x64, 0xa0, 0x9c, 0xa6, 0xff, @@ -1961,7 +1956,7 @@ SWFFONT * Font_Courier(U16 id) memset(f->ascii2glyph, -1, sizeof(int)*256); f->layout = (SWFLAYOUT*)malloc(sizeof(SWFLAYOUT)); - f->layout->ascent = 137; + f->layout->ascent = 1037; f->layout->descent = 911; f->layout->leading = 274; f->layout->kerningcount = 0; @@ -1969,7 +1964,7 @@ SWFFONT * Font_Courier(U16 id) f->layout->bounds = (SRECT*)malloc(sizeof(SRECT)*148); memset(f->layout->bounds, 0, sizeof(SRECT)*148); - addGlyph(f, 0, 0x021, 36*20, &Glyphs_Courier[0x0000], 547, 480, -1236, 720, 30); // ! + addGlyph(f, 0, 0x020, 36*20, &Glyphs_Courier[0x0000], 14, 480, -1236, 720, 30); // ' ' addGlyph(f, 1, 0x022, 45*20, &Glyphs_Courier[0x0045], 393, 292, -1208, 908, -628); // " addGlyph(f, 2, 0x023, 50*20, &Glyphs_Courier[0x0077], 1376, 184, -1294, 1016, 125); // # addGlyph(f, 3, 0x024, 49*20, &Glyphs_Courier[0x0123], 1393, 219, -1320, 980, 180); // $ @@ -2117,6 +2112,7 @@ SWFFONT * Font_Courier(U16 id) addGlyph(f,145, 0x0f9, 54*20, &Glyphs_Courier[0x33e6], 1040, 104, -916, 1088, 86); // ù addGlyph(f,146, 0x0fa, 57*20, &Glyphs_Courier[0x3468], 1193, 20, -868, 1159, 32); // ú addGlyph(f,147, 0x0fb, 50*20, &Glyphs_Courier[0x34fe], 1063, 86, -1220, 1000, 31); // û + return f; }