void add_text_field(SWFMovie mo, const char* name, const char* varname, const char* initial_label, int depth, int x, int y) { SWFDisplayItem it; SWFTextField tf = newSWFTextField(); SWFTextField_setFont(tf, (void*)font); SWFTextField_addChars(tf, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345689:.,/\\#@?!"); SWFTextField_setVariableName(tf, varname); SWFTextField_addString(tf, "Idle"); SWFTextField_setBounds(tf, 120, 12); SWFTextField_setFlags(tf, SWFTEXTFIELD_DRAWBOX|SWFTEXTFIELD_NOEDIT); it = SWFMovie_add(mo, (SWFBlock)tf); SWFDisplayItem_moveTo(it, x, y+2); SWFDisplayItem_setDepth(it, depth); SWFDisplayItem_setName(it, name); // "textfield"); // Label tf = newSWFTextField(); SWFTextField_setFont(tf, (void*)font); SWFTextField_addString(tf, initial_label); SWFTextField_setFlags(tf, SWFTEXTFIELD_DRAWBOX|SWFTEXTFIELD_NOEDIT); it = SWFMovie_add(mo, (SWFBlock)tf); SWFDisplayItem_scale(it, 0.3, 0.3); SWFDisplayItem_setDepth(it, depth*10); SWFDisplayItem_moveTo(it, x, y); }
static void do_movie (int version) { char name[100]; SWFMovie movie; SWFTextField text; SWFDisplayItem display; movie = newSWFMovieWithVersion (version); movie = newSWFMovie(); SWFMovie_setRate (movie, 1); SWFMovie_setDimension (movie, 200, 150); text = newSWFTextField (); SWFTextField_setVariableName (text, "/:foo"); display = SWFMovie_add (movie, (SWFBlock) text); SWFMovie_nextFrame (movie); SWFMovie_add (movie, (SWFBlock) newSWFAction ( "loadMovie (\"FSCommand:quit\", \"\");" )); SWFMovie_nextFrame (movie); sprintf (name, "crash-0.5.3-text-field-root-variable-%d.swf", version); SWFMovie_save (movie, name); }
int main() { SWFMovie m = newSWFMovie(); SWFText text = newSWFText(); SWFTextField textfield = newSWFTextField(); SWFDisplayItem it; SWFFont font = newSWFFont_fromFile(MEDIADIR "/font01.fdb"); if(font == NULL) { perror(MEDIADIR "/font01.fdb"); exit(EXIT_FAILURE); } SWFText_setFont(text, font); SWFText_setColor(text, 0, 0, 0xff, 0xff); SWFText_setHeight(text, 20); SWFText_moveTo(text, 100, 100); SWFText_addString(text, "1234567890", NULL); SWFTextField_setFont(textfield, font); SWFTextField_addString(textfield, "1234567890"); SWFTextField_setColor(textfield, 0xff, 0, 0, 0xff); SWFTextField_setHeight(textfield, 20); SWFMovie_add(m, text); it = SWFMovie_add(m, textfield); SWFDisplayItem_moveTo(it, 100, 120); SWFMovie_nextFrame(m); SWFMovie_save(m, "test04.swf"); return 0; }
SWFDisplayItem add_text_field(SWFMovie mo, SWFBlock font, const char* text, float indent, float leftMargin, float rightMargin, SWFTextFieldAlignment align, float lineSpacing, unsigned int textR, unsigned int textG, unsigned int textB, unsigned int textA) { SWFTextField tf; tf = newSWFTextField(); SWFTextField_setFont(tf, font); SWFTextField_setIndentation(tf, indent); SWFTextField_setLeftMargin(tf, leftMargin); SWFTextField_setRightMargin(tf, rightMargin); SWFTextField_setAlignment(tf, align); SWFTextField_setLineSpacing(tf, lineSpacing); SWFTextField_setColor(tf, textR, textG, textB, textA); SWFTextField_setFlags(tf, SWFTEXTFIELD_DRAWBOX); SWFTextField_addChars(tf, text); SWFTextField_addString(tf, text); SWFTextField_setBounds(tf, 80, 16); return SWFMovie_add(mo, (SWFBlock)tf); }
static void do_movie (int version) { char name[100]; SWFMovie movie; SWFTextField text; SWFDisplayItem display; movie = newSWFMovieWithVersion (version); movie = newSWFMovie(); SWFMovie_setRate (movie, 1); SWFMovie_setDimension (movie, 200, 150); text = newSWFTextField (); display = SWFMovie_add (movie, (SWFBlock) text); SWFMovie_add (movie, (SWFBlock) newSWFAction ("" "trace ('Test whether native properties of TextField are initialized if the movie contains an EditText tag');" "_global.TextField.prototype.hasOwnProperty = ASnative (101, 5);" "trace (_global.TextField.prototype.hasOwnProperty ('text'));" "_global.TextField.prototype = new Object ();" "loadMovie (\"FSCommand:quit\", \"\");" "")); SWFMovie_nextFrame (movie); sprintf (name, "text-field-init-native-%d.swf", version); SWFMovie_save (movie, name); }
SWFTextField get_label(const char* label, SWFFont font) { SWFTextField tf = newSWFTextField(); SWFTextField_setFont(tf, (void*)font); SWFTextField_addChars(tf, " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345689:.,/\\#@?!"); SWFTextField_addString(tf, label); return tf; }
void add_xtrace_function_clip(SWFMovieClip mc, SWFBlock font, int depth, int x, int y, int width, int height) { SWFTextField tf; SWFDisplayItem it; int flags; tf = newSWFTextField(); SWFTextField_setFont(tf, font); /* setting flags seem unneeded */ flags = 0; //flags |= SWFTEXTFIELD_USEFONT; flags |= SWFTEXTFIELD_WORDWRAP; //flags |= SWFTEXTFIELD_NOEDIT; SWFTextField_setFlags(tf, flags); /* Add all ascii chars */ SWFTextField_addChars(tf, asciichars); SWFTextField_addString(tf, " - xtrace enabled -\n"); SWFTextField_setBounds(tf, width, height); /* * Hopefully we have a *single* _root. */ SWFTextField_setVariableName(tf, "_root._trace_text"); /* * Set flags explicitly so that the field is selectable * and you can cut&paste results. * (the default seems to include SWFTEXTFIELD_NOSELECT) */ SWFTextField_setFlags(tf, SWFTEXTFIELD_NOEDIT); /*SWFTextField_setHeight(tf, 240);*/ /*SWFTextField_setColor(tf, 0x00, 0x00, 0x00, 0xff);*/ /*SWFTextField_setAlignment(tf, SWFTEXTFIELD_ALIGN_LEFT);*/ /*SWFTextField_setLeftMargin(tf, 0);*/ /*SWFTextField_setRightMargin(tf, 0);*/ /*SWFTextField_setIndentation(tf, 0);*/ /*SWFTextField_setLineSpacing(tf, 40);*/ /*SWFTextField_setLineSpacing(tf, 40);*/ it = SWFMovieClip_add(mc, (SWFBlock)tf); SWFDisplayItem_moveTo(it, x, y); SWFDisplayItem_setDepth(it, depth); SWFDisplayItem_setName(it, "_xtrace_win"); add_clip_actions(mc, " _root.xtrace = function (msg) { " " _root._trace_text += msg + '\n'; " "};"); }
EXPORT BOOL WINAPI mhsp_SWFTextField(SWFTextField *p1, int flags, int p3, int p4) { lstrcpy(funcname, "SWFTextField"); *p1 = newSWFTextField(); SWFTextField_setFlags(*p1, flags); if (!mhsp_field) { mhsp_field = *p1; } return 0; }
static void ming_textpara(GVJ_t * job, pointf p, textpara_t * para) { SWFMovie movie = (SWFMovie)(job->context); SWFTextField textfield; SWFDisplayItem item; obj_state_t *obj = job->obj; gvcolor_t pencolor = obj->pencolor; pointf offset; char *font_file_name; char *libdir; static SWFFont font; /* FIXME - hardcoded to a Times-like font */ if (font == NULL) { libdir=gvconfig_libdir(); font_file_name = malloc(strlen(libdir)+strlen(FONT)+2); strcpy(font_file_name, libdir); strcat(font_file_name, "/"); strcat(font_file_name, FONT); font = newSWFFont_fromFile(font_file_name); free(font_file_name); } textfield = newSWFTextField(); SWFTextField_setFont(textfield, (SWFBlock)font); SWFTextField_addChars(textfield, para->str); SWFTextField_addUTF8String(textfield, para->str); SWFTextField_setColor(textfield, pencolor.u.rgba[0], pencolor.u.rgba[1], pencolor.u.rgba[2], pencolor.u.rgba[3]); SWFTextField_setHeight(textfield, para->fontsize); switch (para->just) { case 'r': offset.x = 0.; break; case 'l': offset.x = -para->width; break; case 'n': default: offset.x = -para->width/2.; break; } /* offset to baseline */ offset.y = -para->height + para->fontsize*.4; /* empirically determined */ item = SWFMovie_add(movie, (SWFBlock)textfield); SWFDisplayItem_moveTo(item, p.x + offset.x, p.y + offset.y); }
SWFDisplayItem add_text_field(SWFMovie mo, SWFBlock font, const char* text, float indent, float leftMargin, float rightMargin, SWFTextFieldAlignment align, float lineSpacing, unsigned int textR, unsigned int textG, unsigned int textB, unsigned int textA) { SWFTextField tf; tf = newSWFTextField(); SWFTextField_setFont(tf, font); SWFTextField_setIndentation(tf, indent); SWFTextField_setLeftMargin(tf, leftMargin); SWFTextField_setRightMargin(tf, rightMargin); SWFTextField_setAlignment(tf, align); SWFTextField_setLineSpacing(tf, lineSpacing); SWFTextField_setColor(tf, textR, textG, textB, textA); /* setting flags seem unneeded */ /*SWFTextField_setFlags(tf, SWFTEXTFIELD_USEFONT|SWFTEXTFIELD_NOEDIT);*/ SWFTextField_addChars(tf, text); SWFTextField_addString(tf, text); /* * Bounds computed by Ming (if we omit the setBounds call) * are 2640, 240. This means that we're shrinking the available * space with this explicit setting. Gnash chokes in this case. * * Ref: https://savannah.gnu.org/bugs/?func=detailitem&item_id=16637. */ SWFTextField_setBounds(tf, 100, 100); //SWFTextField_setBounds(tf, 60000, 338); /* * The following settings (found in the reported SWF) * are not needed to exploit the bug. */ /*SWFTextField_setHeight(tf, 240);*/ /*SWFTextField_setColor(tf, 0x00, 0x00, 0x00, 0xff);*/ /*SWFTextField_setAlignment(tf, SWFTEXTFIELD_ALIGN_LEFT);*/ /*SWFTextField_setLeftMargin(tf, 0);*/ /*SWFTextField_setRightMargin(tf, 0);*/ /*SWFTextField_setIndentation(tf, 0);*/ /*SWFTextField_setLineSpacing(tf, 40);*/ /*SWFTextField_setLineSpacing(tf, 40);*/ return SWFMovie_add(mo, (SWFBlock)tf); }
void add_xtrace_function(SWFMovie mo, SWFBlock font, int depth, int x, int y, int width, int height) { SWFTextField tf; SWFDisplayItem it; tf = newSWFTextField(); SWFTextField_setFont(tf, font); /* setting flags seem unneeded */ /*SWFTextField_setFlags(tf, SWFTEXTFIELD_USEFONT|SWFTEXTFIELD_NOEDIT);*/ /* Add all ascii chars */ SWFTextField_addChars(tf, asciichars); SWFTextField_addString(tf, " - xtrace enabled -\n"); SWFTextField_setBounds(tf, width, height); /* * Hopefully we have a *single* _root. */ SWFTextField_setVariableName(tf, "_root._trace_text"); /*SWFTextField_setHeight(tf, 240);*/ /*SWFTextField_setColor(tf, 0x00, 0x00, 0x00, 0xff);*/ /*SWFTextField_setAlignment(tf, SWFTEXTFIELD_ALIGN_LEFT);*/ /*SWFTextField_setLeftMargin(tf, 0);*/ /*SWFTextField_setRightMargin(tf, 0);*/ /*SWFTextField_setIndentation(tf, 0);*/ /*SWFTextField_setLineSpacing(tf, 40);*/ /*SWFTextField_setLineSpacing(tf, 40);*/ it = SWFMovie_add(mo, (SWFBlock)tf); SWFDisplayItem_moveTo(it, x, y); SWFDisplayItem_setDepth(it, depth); SWFDisplayItem_setName(it, "_xtrace_win"); add_actions(mo, " _root.xtrace = function (msg) { " " trace (msg); " " _root._trace_text += msg + '\n'; " "};"); }
int main() { SWFMovie m = newSWFMovie(); SWFTextField text = newSWFTextField(); SWFFont font = newSWFFont_fromFile(MEDIADIR "/test.ttf"); if(font == NULL) { perror(MEDIADIR "/test.tff"); exit(EXIT_FAILURE); } SWFTextField_setFont(text, font); SWFTextField_setColor(text, 0, 0, 0, 0xff); SWFTextField_setHeight(text, 20); SWFMovie_add(m, text); SWFMovie_nextFrame(m); SWFMovie_save(m, "test02.swf"); return 0; }
int main() { SWFMovie m = newSWFMovie(); SWFTextField text = newSWFTextField(); SWFFont font = newSWFFont_fromFile(MEDIADIR "/test.ttf"); if(font == NULL) { perror(MEDIADIR "/test.tff"); exit(EXIT_FAILURE); } SWFTextField_setFont(text, font); SWFTextField_setColor(text, 0, 0, 0, 0xff); SWFTextField_setHeight(text, 20); SWFTextField_setFlags(text, SWFTEXTFIELD_NOEDIT); SWFTextField_addString(text, "The quick brown fox jumps over the lazy dog. 1234567890"); SWFMovie_add(m, text); SWFMovie_nextFrame(m); SWFMovie_save(m, "test01.swf"); return 0; }
static VALUE allocate(VALUE klass) { SWFTextField tf = newSWFTextField(); return Data_Wrap_Struct(klass, NULL, deallocate, tf); }