Esempio n. 1
0
int
main(int argc, char **argv)
{
	SWFMovie mo;
	SWFDisplayItem it;
	const char *srcdir=".";
	char fdbfont[256];
	SWFMovieClip dejagnuclip;

	/*********************************************
	 *
	 * Initialization
	 *
	 *********************************************/

	puts("Setting things up");

	Ming_init();
        Ming_useSWFVersion (OUTPUT_VERSION);
	Ming_setScale(20.0); 
 
	mo = newSWFMovie();
	SWFMovie_setDimension(mo, 800, 600);
	SWFMovie_setRate(mo, 1);

	if ( argc>1 ) srcdir=argv[1];
	else
	{
		fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
		return 1;
	}

	sprintf(fdbfont, "%s/Bitstream-Vera-Sans.fdb", srcdir);
	FILE *font_file = fopen(fdbfont, "r");
	if ( font_file == NULL )
	{
		perror(fdbfont);
		exit(1);
	}
	/*SWFBrowserFont bfont = newSWFBrowserFont("_sans");*/
	font = loadSWFFontFromFile(font_file);

	/* Dejagnu equipment */
	dejagnuclip = get_dejagnu_clip((SWFBlock)font, 10, 0, 0, 800, 600);
	it = SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  	SWFDisplayItem_setDepth(it, 200); 
  	SWFDisplayItem_move(it, 200, 0); 

	add_text_field(mo, "textfield", "_root.msg", "Button events", 10, 0, 5);
	add_text_field(mo, "textfield2", "_root.msg2", "Mouse events", 11, 0, 100);
	add_text_field(mo, "textfield3", "_root.msg3", "Key events", 12, 0, 80);

	SWFMovie_nextFrame(mo);

	/*****************************************************
	 *
	 * Add button
	 *
	 *****************************************************/

	it = add_button(mo);
	SWFDisplayItem_moveTo(it, 40, 30);
	SWFDisplayItem_setName(it, "square1");
	SWFDisplayItem_setDepth(it, 2);

	// Mouse pointer events
	//add_actions(mo, "square1.button.onRollOver = function() { _root.msg2 = 'RollOver'; };");
	//add_actions(mo, "square1.button.onRollOut = function() { _root.msg2 = 'RollOut'; };");

	// Mouse buttons events
	//add_actions(mo, "square1.button.onPress = function() { _root.msg2 = 'Press'; };");
	//add_actions(mo, "square1.button.onRelease = function() { _root.msg2 = 'Release'; gotoAndStop(1); };");
	//add_actions(mo, "square1.button.onReleaseOutside = function() { _root.msg2 = 'ReleaseOutside'; };");

	// Focus events
	add_actions(mo, "square1.button.onSetFocus = function() { _root.msg3 = 'SetFocus'; };");

	// Key events - button needs focus for these to work
	add_actions(mo, "square1.button.onKeyDown = function() { _root.msg3 = 'KeyDown'; };");
	add_actions(mo, "square1.button.onKeyUp = function() { _root.msg3 = 'KeyUp'; };");


	SWFMovie_nextFrame(mo); /* showFrame */

	/*****************************************************
	 *
	 * On second frame, add a shape at lower depth 
	 *
	 *****************************************************/

	{
		SWFShape sh = make_fill_square(0, 0, 120, 120, 0, 0, 0, 0, 255, 0);
		SWFDisplayItem itsh = SWFMovie_add(mo, (SWFBlock)sh);
		SWFDisplayItem_setDepth(itsh, 1);

		SWFMovie_nextFrame(mo); /* showFrame */
	}

	/*****************************************************
	 *
	 * On third frame, add a shape at higher depth 
	 *
	 *****************************************************/

	{
		SWFShape sh = make_fill_square(0, 0, 120, 120, 0, 0, 0, 0, 255, 0);
		SWFDisplayItem itsh = SWFMovie_add(mo, (SWFBlock)sh);
		SWFDisplayItem_setDepth(itsh, 3);
		SWFDisplayItem_setColorAdd(itsh, 0, 0, 0, -128);

		SWFMovie_nextFrame(mo); /* showFrame */
	}

	/*****************************************************
	 *
	 * On third frame, add a shape at higher depth 
	 *
	 *****************************************************/

	{

		add_actions(mo,
			"square1.button.enabled = false;"
			//"_root.msg = _root.msg2 = _root.msg3 = 'Idle';"
			"stop();"
			"totals();"
		);
		SWFMovie_nextFrame(mo); /* showFrame */
	}

	/*****************************************************
	 *
	 * Save it...
	 *
	 *****************************************************/

	puts("Saving " OUTPUT_FILENAME );

	SWFMovie_save(mo, OUTPUT_FILENAME);

	return 0;
}
Esempio n. 2
0
File: gicon.c Progetto: S010/test
int
main(int argc, char **argv)
{
	GtkWidget *window, *main_vbox, *hbox, *lbl, *txt, *get, *set;
	uint id;

	gtk_init(&argc, &argv);

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	g_signal_connect(G_OBJECT(window), "destroy",
	    G_CALLBACK(on_window_destroy), NULL);
	gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);

	main_vbox = gtk_vbox_new(FALSE, 0);

	status_icon = gtk_status_icon_new_from_stock(GTK_STOCK_OPEN);

	add_id_label(main_vbox, status_icon);

	/* Window id */

	txt = add_text_field(main_vbox, "Window id");
	add_getset_buttons(main_vbox, txt, on_winid_get_clicked, NULL);

	/* Name */

	txt = add_text_field(main_vbox, "Name");
	add_getset_buttons(main_vbox, txt, NULL,
	    on_name_set_clicked);

	/* Title */

	txt = add_text_field(main_vbox, "Title");
	add_getset_buttons(main_vbox, txt, on_title_get_clicked,
	    on_title_set_clicked);

	/* Tooltip text */

	txt = add_text_field(main_vbox, "Tooltip text");
	add_getset_buttons(main_vbox, txt, on_tt_text_get_clicked,
	    on_tt_text_set_clicked);

	/* Tooltip markup */

	txt = add_text_field(main_vbox, "Tooltip markup");
	add_getset_buttons(main_vbox, txt, on_tt_markup_get_clicked,
	    on_tt_markup_set_clicked);

	/* Has tooltip? */

	txt = add_text_field(main_vbox, "Has tooltip?");
	add_getset_buttons(main_vbox, txt, on_has_tooltip_get_clicked,
	    on_has_tooltip_get_clicked);

	/* Visible */

	txt = add_text_field(main_vbox, "Visible");
	add_getset_buttons(main_vbox, txt, on_visible_get_clicked,
	    on_visible_set_clicked);

	/* Is embedded */

	txt = add_text_field(main_vbox, "Is embedded");
	add_getset_buttons(main_vbox, txt, on_isembed_get_clicked, NULL);


	gtk_container_add(GTK_CONTAINER(window), main_vbox);
	gtk_widget_show_all(window);



	gtk_main();

	return 0;
}
Esempio n. 3
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  const char *srcdir=".";
  char fdbfont[256];
  SWFMovieClip  dejagnuclip;
  
  /*********************************************
   *
   * Initialization
   *
   *********************************************/

  if ( argc>1 ) srcdir=argv[1];
  else
  {
    fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
    return 1;
  }

  sprintf(fdbfont, "%s/Bitstream-Vera-Sans.fdb", srcdir);

  puts("Setting things up");

  Ming_init();
  Ming_useSWFVersion (OUTPUT_VERSION);
  //Ming_setScale(20.0); /* so we talk twips */
 
  mo = newSWFMovie();
  SWFMovie_setRate(mo, 1.0);
  SWFMovie_setDimension(mo, 800, 600);
  
  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  SWFMovie_nextFrame(mo); // 1st frame 


  /*********************************************
   *
   * Add some textfields
   *
   *********************************************/
  {
    SWFDisplayItem it;
    FILE *font_file = fopen(fdbfont, "r");
    if ( font_file == NULL )
    {
      perror(fdbfont);
      exit(1);
    }
    SWFFont efont = loadSWFFontFromFile(font_file);

    it = add_text_field(mo, efont, "First text");
    SWFDisplayItem_setName(it, "dtext1");
    SWFDisplayItem_moveTo(it, 0, 200);
    it = add_text_field(mo, efont, "Zweites Textfeld");
    SWFDisplayItem_setName(it, "etext1");
    SWFDisplayItem_moveTo(it, 0, 300);

    it = add_text_field(mo, efont, "Some more static text here... abcdefgh");
    SWFDisplayItem_setName(it, "dtext2");
    SWFDisplayItem_moveTo(it, 0, 400);
  }
  SWFMovie_nextFrame(mo); 

  add_actions(mo, "createTextField('dynamictext1', 99, 10, 10, 10, 10);"
		  "this.dynamictext1.text = 'Dynamic Text';");
  
  add_actions(mo, "ts = this.getTextSnapshot();");
  check(mo, "ts instanceof TextSnapshot");
  check_equals(mo, "ts.getCount()", "64");

  check_equals(mo, "ts.getText(0, 1)", "'F'");
  check_equals(mo, "ts.getText(3, 3)", "'s'");
  check_equals(mo, "ts.getText(-5, 5)", "'First'");
  check_equals(mo, "ts.getText(10, 6)", "'Z'");
  check_equals(mo, "ts.getText(0, 100)", "'First textZweites TextfeldSome more "
		  "static text here... abcdefgh'");
  add_actions(mo, "ss = ts.getText(100, 110);");
  check_equals(mo, "typeof(ss)", "'string'");
  check_equals(mo, "ss", "'h'");
  check_equals(mo, "ss.length", "1");
  
  check_equals(mo, "ts.getText(0, 100, true)", 
          "'First text\nZweites Textfeld\nSome more "
		  "static text here... abcdefgh'");
  
  check_equals(mo, "ts.getText(0, 14, true)", "'First text\nZwei'");

  check_equals(mo, "ts.findText(0, '', false)", "-1");
  check_equals(mo, "ts.findText(0, 'f', false)", "0");
  check_equals(mo, "ts.findText(0, 'f', true)", "22");
  check_equals(mo, "ts.findText(1, 'Rst', false)", "2");
  check_equals(mo, "ts.findText(3, 'RSt', false)", "-1");
  check_equals(mo, "ts.findText(100, 'h', false)", "-1");
  check_equals(mo, "ts.findText(64, 'h', false)", "-1");
  check_equals(mo, "ts.findText(-5, 'Zwei', true)", "-1");
  check_equals(mo, "ts.findText(-5, 'gh', true)", "-1");

  add_actions(mo, "ts.setSelected(5, 30, true);");
  check_equals(mo, "ts.getSelectedText()", "' textZweites TextfeldSome'");
  check_equals(mo, "ts.getSelectedText(true)", "' text\nZweites "
          "Textfeld\nSome'");
  check_equals(mo, "ts.getSelectedText(false)", "' textZweites TextfeldSome'");
  check_equals(mo, "ts.getSelected(0, 4)", "false");
  check_equals(mo, "ts.getSelected(1, 9)", "true");
  check_equals(mo, "ts.getSelected(-4, 10)", "true");
  check_equals(mo, "ts.getSelected(-4, 6)", "true");
  check_equals(mo, "ts.getSelected(28, 23)", "true");
  check_equals(mo, "ts.getSelected(20, 20)", "true");
  check_equals(mo, "ts.getSelected(20, 27)", "true");
  check_equals(mo, "ts.getSelected(-3, -1)", "false");
  check_equals(mo, "ts.getSelected(30, 31)", "false");
  check_equals(mo, "ts.getSelected(0, 5)", "false");
  check_equals(mo, "ts.getSelected(40, 45)", "false");
  check_equals(mo, "ts.getSelected(31, 34)", "false");

  check_equals(mo, "ts.getSelected(0)", "undefined");
  check_equals(mo, "ts.getSelected(1)", "undefined");
  check_equals(mo, "ts.getSelected(-4)", "undefined");
  check_equals(mo, "ts.getSelected(-4)", "undefined");
  check_equals(mo, "ts.getSelected(28)", "undefined");
  check_equals(mo, "ts.getSelected(20)", "undefined");

  // Selected text is stored in the textfield and reset when a new
  // snapshot is taken.
  add_actions(mo, "ts2 = new TextSnapshot(this);");
  check_equals(mo, "ts.getSelectedText(false)", "''");
  check_equals(mo, "ts2.getCount()", "64");
  check_equals(mo, "ts2.getSelectedText()", "''");
  add_actions(mo, "ts2 = this.getTextSnapshot();");
  check_equals(mo, "ts2.getCount()", "64");
  check_equals(mo, "ts2.getSelectedText()", "''");

  add_actions(mo, "ts2.setSelected(3, 10, true);");
  check_equals(mo, "ts2.getSelectedText(false).length", "7");
  check_equals(mo, "ts.getSelectedText(false).length", "7");

  add_actions(mo, "ts.setSelectedColor(0xffff00);");
  add_actions(mo, "ts2.setSelectedColor(0x0000ff);");

  check_equals(mo, "ts.getSelectedText(false)", "'st text'");
  add_actions(mo, "ri = ts.getTextRunInfo(4, 10);");
  check_equals(mo, "typeof(ri)", "'object'");
  check(mo, "ri instanceof Array");
  check_equals(mo, "ri.length", "7");

  add_actions(mo, "el = ri[1];");
  check_equals(mo, "typeof(el)", "'object'");
  check(mo, "!el.hasOwnProperty('indexInRun')");
  check_equals(mo, "el.indexInRun", "5");
  check_equals(mo, "el.selected", "true");
  check_equals(mo, "el.font", "'Bitstream Vera Sans'");
  check_equals(mo, "el.color", "0");
  check_equals(mo, "el.height", "12");
  check_equals(mo, "el.matrix_a", "1");
  check_equals(mo, "el.matrix_b", "0");
  check_equals(mo, "el.matrix_c", "0");
  check_equals(mo, "el.matrix_d", "1");
  check_equals(mo, "el.matrix_tx", "25.95");
  check_equals(mo, "el.matrix_ty", "200");
  xcheck_equals(mo, "el.corner0x", "25.95");
  xcheck_equals(mo, "el.corner0y", "202.8");
  xcheck_equals(mo, "el.corner1x", "29.75");
  xcheck_equals(mo, "el.corner1y", "202.8");
  xcheck_equals(mo, "el.corner2x", "29.75");
  xcheck_equals(mo, "el.corner2y", "188.85");
  xcheck_equals(mo, "el.corner3x", "25.95");
  xcheck_equals(mo, "el.corner3y", "188.85");

  // Check properties individually
  check_equals(mo, "ri[2].height", "12");
  check_equals(mo, "ri[3].height", "12");
  check_equals(mo, "ri[4].height", "12");
  check_equals(mo, "ri[5].height", "12");
  check_equals(mo, "ri[6].height", "12");

  check_equals(mo, "ri[2].selected", "true");
  check_equals(mo, "ri[3].selected", "true");
  check_equals(mo, "ri[4].selected", "true");
  check_equals(mo, "ri[5].selected", "true");
  check_equals(mo, "ri[6].selected", "false");

  check_equals(mo, "ri[2].matrix_tx", "29.75");
  check_equals(mo, "ri[2].matrix_ty", "200");
  check_equals(mo, "ri[3].matrix_tx", "34.4");
  check_equals(mo, "ri[3].matrix_ty", "200");
  check_equals(mo, "ri[4].matrix_tx", "41.75");
  check_equals(mo, "ri[4].matrix_ty", "200");

  xcheck_equals(mo, "ri[2].corner0x", "29.75");
  xcheck_equals(mo, "ri[2].corner0y", "202.8");
  xcheck_equals(mo, "ri[3].corner0x", "34.4");
  xcheck_equals(mo, "ri[3].corner0y", "202.8");
  xcheck_equals(mo, "ri[4].corner0x", "41.75");
  xcheck_equals(mo, "ri[4].corner0y", "202.8");
  
  xcheck_equals(mo, "ri[2].corner2y", "188.85");
  xcheck_equals(mo, "ri[3].corner2y", "188.85");
  xcheck_equals(mo, "ri[4].corner2y", "188.85");

  add_actions(mo, "ts.setSelected(0, 10, true);");
  add_actions(mo, "ts.setSelected(15, 20, false);");
  check_equals(mo, "ts2.getSelectedText().length", "10");

  add_actions(mo, "ri2 = ts.getTextRunInfo(0, 100);");

  check_equals(mo, "ri2[0].selected", "true");
  check_equals(mo, "ri2[1].selected", "true");
  check_equals(mo, "ri2[2].selected", "true");
  check_equals(mo, "ri2[3].selected", "true");
  check_equals(mo, "ri2[4].selected", "true");
  check_equals(mo, "ri2[5].selected", "true");
  check_equals(mo, "ri2[6].selected", "true");
  check_equals(mo, "ri2[15].selected", "false");
  check_equals(mo, "ri2[16].selected", "false");
  check_equals(mo, "ri2[17].selected", "false");
  check_equals(mo, "ri2[18].selected", "false");

  xcheck_equals(mo, "ri2[50].corner2y", "388.85");
  xcheck_equals(mo, "ri2[50].corner2x", "156.6");
  xcheck_equals(mo, "ri2[51].corner2y", "388.85");
  xcheck_equals(mo, "ri2[51].corner2x", "163.95");

  check_equals(mo, "ri2[50].matrix_tx", "151.65");
  check_equals(mo, "ri2[51].matrix_tx", "156.55");

  add_actions(mo, "ts = this.getTextSnapshot();");
  check_equals(mo, "typeof(ts)", "'object'");
  add_actions(mo, "backup = TextSnapshot;");
  add_actions(mo, "TextSnapshot = undefined;");
  add_actions(mo, "t = new TextSnapshot();");
  check_equals(mo, "typeof(t)", "'undefined'");

  check_equals(mo, "typeof(TextSnapshot)", "'undefined'");
  add_actions(mo, "ts = this.getTextSnapshot();");
  xcheck_equals(mo, "typeof(ts)", "'undefined'");
  add_actions(mo, "TextSnapshot = backup;");
  add_actions(mo, "ts = this.getTextSnapshot();");
  check_equals(mo, "typeof(ts)", "'object'");
  
  add_actions(mo, "backup = TextSnapshot.prototype;");
  add_actions(mo, "TextSnapshot.prototype = undefined;");
  add_actions(mo, "ts = this.getTextSnapshot();");
  check_equals(mo, "typeof(ts)", "'object'");
  add_actions(mo, "TextSnapshot.prototype = backup;");
  add_actions(mo, "ts = this.getTextSnapshot();");
  check_equals(mo, "typeof(ts)", "'object'");
  
  add_actions(mo, "totals(); stop();");
  
  SWFMovie_nextFrame(mo); 

  /*****************************************************
   *
   * Output movie
   *
   *****************************************************/
  puts("Saving " OUTPUT_FILENAME );

  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
Esempio n. 4
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  const char *srcdir=".";
  char fdbfont[256];
  SWFMovieClip  dejagnuclip;
  
  /*********************************************
   *
   * Initialization
   *
   *********************************************/

  if ( argc>1 ) srcdir=argv[1];
  else
  {
    fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
    return 1;
  }

  sprintf(fdbfont, "%s/Bitstream-Vera-Sans.fdb", srcdir);

  puts("Setting things up");

  Ming_init();
  Ming_useSWFVersion (OUTPUT_VERSION);
  //Ming_setScale(20.0); /* so we talk twips */
 
  mo = newSWFMovie();
  SWFMovie_setRate(mo, 1.0);
  SWFMovie_setDimension(mo, 800, 600);
  
  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10, 0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  SWFMovie_nextFrame(mo); // 1st frame 

  // Check that the dejagnu clip is really a TextField.
  check_equals(mo, "_root.getInstanceAtDepth(-16383)",
          "_level0.instance1");
  check(mo, "_level0.instance1._xtrace_win "
          "instanceof TextField");

  // Note: the dejagnuclip already placed some texts, so the following
  // should be true.
  check(mo, "TextField.prototype.hasOwnProperty('background')");
  check(mo, "TextField.prototype.hasOwnProperty('backgroundColor')");
  check(mo, "TextField.prototype.hasOwnProperty('text')");
  check(mo, "TextField.prototype.hasOwnProperty('textColor')");

  /*********************************************
   *
   * Add some textfields
   *
   *********************************************/
  {
    SWFDisplayItem it;
    FILE *font_file = fopen(fdbfont, "r");
    if ( font_file == NULL )
    {
      perror(fdbfont);
      exit(1);
    }
    SWFBrowserFont bfont = newSWFBrowserFont("_sans");
    SWFFont efont = loadSWFFontFromFile(font_file);

    it = add_text_field(mo, (SWFBlock)bfont, "Hello", 1, 2, 3, SWFTEXTFIELD_ALIGN_LEFT, 10, 100, 101, 102, 50);
    SWFDisplayItem_setName(it, "dtext1");
    SWFDisplayItem_moveTo(it, 0, 200);
    it = add_text_field(mo, (SWFBlock)efont, "Hello", 4, 5, 6, SWFTEXTFIELD_ALIGN_CENTER, 11, 110, 111, 112, 51);
    SWFDisplayItem_setName(it, "etext1");
    SWFDisplayItem_moveTo(it, 0, 300);

    SWFBrowserFont bfont2 = newSWFBrowserFont("times");
    it = add_text_field(mo, (SWFBlock)bfont2, "Hello", 7, 8, 9, SWFTEXTFIELD_ALIGN_RIGHT, 12, 120, 121, 122, 52);
    SWFDisplayItem_setName(it, "dtext2");
    SWFDisplayItem_moveTo(it, 0, 400);
  }
  SWFMovie_nextFrame(mo); 

  check_equals(mo, "dtext1.embedFonts", "false");
  check_equals(mo, "etext1.embedFonts", "true");
  check_equals(mo, "etext1.hasOwnProperty('embedFonts')", "false");

  add_actions(mo, "ret = Selection.setFocus(dtext1);"
                  "check_equals(ret, false);"
                  "check_equals(Selection.getFocus(), '_level0.dtext1');");
  add_actions(mo, "ret = Selection.setFocus(etext1);"
                  "check_equals(ret, false);"
                  "check_equals(Selection.getFocus(), '_level0.etext1');");

  add_actions(mo, "createTextField('dynamictext1', 99, 10, 10, 10, 10);");

  add_actions(mo, "ret = Selection.setFocus(dynamictext1);"
               "check_equals(ret, false);"
               "check_equals(Selection.getFocus(), '_level0.dynamictext1');");

  check_equals(mo, "dtext1.__proto__", "TextField.prototype");
  check_equals(mo, "etext1.__proto__", "TextField.prototype");
  check_equals(mo, "etext1.__proto__", "dynamictext1.__proto__");

  // checks after placing some swf defined TextField
  check(mo, "TextField.prototype.hasOwnProperty('background')");
  check(mo, "TextField.prototype.hasOwnProperty('backgroundColor')");
  check(mo, "TextField.prototype.hasOwnProperty('text')");
  check(mo, "TextField.prototype.hasOwnProperty('textColor')");
  check(mo, "!TextField.prototype.hasOwnProperty('_parent')");
  check(mo, "!TextField.prototype.hasOwnProperty('_xmouse')");
  check(mo, "!TextField.prototype.hasOwnProperty('_ymouse')");
  check(mo, "!TextField.prototype.hasOwnProperty('_xscale')");
  check(mo, "!TextField.prototype.hasOwnProperty('_yscale')");
  
  check_equals(mo, "typeof(dtext1)", "'object'");
  check_equals(mo, "typeof(dtext1.text)", "'string'");
  check_equals(mo, "typeof(dtext1.background)", "'boolean'");
  check_equals(mo, "typeof(dtext1.backgroundColor)", "'number'");
  check_equals(mo, "typeof(dtext1.textColor)", "'number'");
  check_equals(mo, "typeof(dtext1._alpha)", "'number'");
  check_equals(mo, "typeof(dtext1.type)", "'string'");
  check_equals(mo, "dtext1.type", "'input'");
  
  check_equals(mo, "typeof(dtext1.__proto__.text)", "'undefined'");
  check_equals(mo, "typeof(dtext1.__proto__.background)", "'undefined'");
  check_equals(mo, "typeof(dtext1.__proto__.backgroundColor)", "'undefined'");
  check_equals(mo, "typeof(dtext1.__proto__.textColor)", "'undefined'");
  check_equals(mo, "typeof(dtext1.__proto__._alpha)", "'undefined'");

  check_equals(mo, "dtext1.hasOwnProperty('text')", "false");
  check_equals(mo, "dtext1.hasOwnProperty('background')", "false");
  check_equals(mo, "dtext1.hasOwnProperty('backgroundColor')", "false");
  check_equals(mo, "dtext1.hasOwnProperty('textColor')", "false");
  check_equals(mo, "dtext1.hasOwnProperty('_alpha')", "false");
  check(mo, "!dtext1.hasOwnProperty('_parent')");
  check(mo, "!dtext1.hasOwnProperty('_xmouse')");
  check(mo, "!dtext1.hasOwnProperty('_ymouse')");
  check(mo, "!dtext1.hasOwnProperty('_xscale')");
  check(mo, "!dtext1.hasOwnProperty('_yscale')");
  check(mo, "!etext1.hasOwnProperty('_parent')");
  check(mo, "!etext1.hasOwnProperty('_xmouse')");
  check(mo, "!etext1.hasOwnProperty('_ymouse')");
  check(mo, "!etext1.hasOwnProperty('_xscale')");
  check(mo, "!etext1.hasOwnProperty('_yscale')");
  
  check(mo, "dtext1.__proto__.hasOwnProperty('text')");
  check_equals(mo, "dtext1.__proto__.hasOwnProperty('background')", "true");
  check_equals(mo, "dtext1.__proto__.hasOwnProperty('backgroundColor')", "true");
  check_equals(mo, "dtext1.__proto__.hasOwnProperty('textColor')", "true");
  // Why _alpha is special???
  check_equals(mo, "dtext1.__proto__.hasOwnProperty('_alpha')", "false");
  
  check_equals(mo, "dtext1.text", "'Hello'");
  check_equals(mo, "etext1.text", "'Hello'");
  check_equals(mo, "dtext2.text", "'Hello'");
  check_equals(mo, "dtext1.background", "false");
  check_equals(mo, "etext1.background", "false");
  check_equals(mo, "dtext2.background", "false");
  check_equals(mo, "dtext1.backgroundColor", "0xffffff");
  check_equals(mo, "etext1.backgroundColor", "0xffffff");
  check_equals(mo, "dtext2.backgroundColor", "0xffffff");
  check_equals(mo, "dtext1.textColor", "6579558");
  check_equals(mo, "etext1.textColor", "7237488");
  check_equals(mo, "dtext2.textColor", "7895418");
  check_equals(mo, "dtext1._alpha", "100");
  check_equals(mo, "etext1._alpha", "100");
  check_equals(mo, "dtext2._alpha", "100");
  check_equals(mo, "etext1._parent", "_root");
  check_equals(mo, "dtext2._parent", "_root");
  check_equals(mo, "etext1._xscale", "100");
  check_equals(mo, "dtext2._xscale", "100");
  check_equals(mo, "etext1._yscale", "100");
  check_equals(mo, "dtext2._yscale", "100");
  check_equals(mo, "typeof(etext1._xmouse)", "'number'");
  check_equals(mo, "typeof(dtext2._xmouse)", "'number'");
  check_equals(mo, "typeof(etext1._ymouse)", "'number'"); 
  check_equals(mo, "typeof(dtext2._ymouse)", "'number'"); 

  // TextFormat objects are created on the fly
  add_actions(mo,
	"etext1.tf = etext1.getTextFormat();"
	"dtext2.tf = dtext2.getTextFormat();"
	);
  check_equals(mo, "typeof(etext1.tf)", "'object'"); 
  check_equals(mo, "typeof(dtext2.tf)", "'object'"); 
  check_equals(mo, "etext1.tf.size", "12"); 
  check_equals(mo, "dtext2.tf.size", "12"); 
  check_equals(mo, "etext1.tf.font", "'Bitstream Vera Sans'");
  check_equals(mo, "dtext2.tf.font", "'times'"); 
  check_equals(mo, "typeof(etext1.tf.bold)", "'boolean'");
  check_equals(mo, "typeof(dtext2.tf.bold)", "'boolean'");
  check_equals(mo, "etext1.tf.bold", "false");
  check_equals(mo, "dtext2.tf.bold", "false"); 
  check_equals(mo, "typeof(etext1.tf.italic)", "'boolean'");
  check_equals(mo, "typeof(dtext2.tf.italic)", "'boolean'");
  check_equals(mo, "etext1.tf.italic", "false");
  check_equals(mo, "dtext2.tf.italic", "false"); 
  check_equals(mo, "typeof(etext1.tf.indent)", "'number'");
  check_equals(mo, "typeof(dtext2.tf.indent)", "'number'");
  check_equals(mo, "etext1.tf.indent", "4");
  check_equals(mo, "dtext2.tf.indent", "7"); 
  check_equals(mo, "typeof(etext1.tf.leftMargin)", "'number'");
  check_equals(mo, "typeof(dtext2.tf.leftMargin)", "'number'");
  check_equals(mo, "etext1.tf.leftMargin", "5");
  check_equals(mo, "dtext2.tf.leftMargin", "8"); 
  check_equals(mo, "typeof(etext1.tf.rightMargin)", "'number'");
  check_equals(mo, "typeof(dtext2.tf.rightMargin)", "'number'");
  check_equals(mo, "etext1.tf.rightMargin", "6");
  check_equals(mo, "dtext2.tf.rightMargin", "9"); 
  check_equals(mo, "typeof(etext1.tf.align)", "'string'");
  check_equals(mo, "typeof(dtext2.tf.align)", "'string'");
  check_equals(mo, "etext1.tf.align", "'center'");
  check_equals(mo, "dtext2.tf.align", "'right'"); 
  check_equals(mo, "typeof(etext1.tf.leading)", "'number'");
  check_equals(mo, "typeof(dtext2.tf.leading)", "'number'");
  check_equals(mo, "etext1.tf.leading", "11");
  check_equals(mo, "dtext2.tf.leading", "12"); 
  check_equals(mo, "typeof(etext1.tf.color)", "'number'");
  check_equals(mo, "typeof(dtext2.tf.color)", "'number'");
  check_equals(mo, "etext1.tf.color", "7237488");
  check_equals(mo, "dtext2.tf.color", "7895418");
  check_equals(mo, "typeof(etext1.tf.blockIndent)", "'number'");
  check_equals(mo, "typeof(dtext2.tf.blockIndent)", "'number'");
  check_equals(mo, "etext1.tf.blockIndent", "0");
  check_equals(mo, "dtext2.tf.blockIndent", "0");
  check_equals(mo, "typeof(etext1.tf.underline)", "'boolean'");
  check_equals(mo, "typeof(dtext2.tf.underline)", "'boolean'");
  check_equals(mo, "etext1.tf.underline", "false");
  check_equals(mo, "dtext2.tf.underline", "false");

  add_actions(mo, "dtext1.background = true;"
                  "etext1.background = true;"
                  "dtext2.background = true;"
                  "dtext1.backgroundColor = 0xff0000;"
                  "etext1.backgroundColor = 0x00ff00;"
                  "dtext2.backgroundColor = 0x0000ff;"
                  "dtext1.textColor = 0x00ffff;"
                  "etext1.textColor = 0xff00ff;"
                  "dtext2.textColor = 0xffff00;"
                  "dtext1.text += ' world';"
                  "etext1.text += ' world';"
                  "dtext2.text += ' world';" );

  check_equals(mo, "etext1.getTextFormat().color", "0xff00ff");
  check_equals(mo, "dtext2.getTextFormat().color", "0xffff00"); 

  check_equals(mo, "dtext1.text", "'Hello world'");
  check_equals(mo, "etext1.text", "'Hello world'");
  check_equals(mo, "dtext2.text", "'Hello world'");
  check_equals(mo, "dtext1.background", "true");
  check_equals(mo, "etext1.background", "true");
  check_equals(mo, "dtext2.background", "true");
  check_equals(mo, "dtext1.backgroundColor", "0xff0000");
  check_equals(mo, "etext1.backgroundColor", "0x00ff00");
  check_equals(mo, "dtext2.backgroundColor", "0x0000ff");
  check_equals(mo, "dtext1.textColor", "0x00ffff");
  check_equals(mo, "etext1.textColor", "0xff00ff");
  check_equals(mo, "dtext2.textColor", "0xffff00");
  SWFMovie_nextFrame(mo); 
  
  add_actions(mo, "dtext1._alpha = 0;"
                  "etext1._alpha = 0;"
                  "dtext2._alpha = 0;" );
  check_equals(mo, "dtext1._alpha", "0");
  check_equals(mo, "etext1._alpha", "0");
  check_equals(mo, "dtext2._alpha", "0");
  SWFMovie_nextFrame(mo); 

  add_actions(mo, "dtext1._alpha = 100; dtext1.embedFonts=true; dtext1.text = 'embedFonts';"
                  "etext1._alpha = 100; etext1.embedFonts=false; etext1.text = '!embedFonts';"
                  "dtext2._alpha = 100;" );

  check_equals(mo, "dtext1.embedFonts", "true");
  check_equals(mo, "etext1.embedFonts", "false");

  add_actions(mo, "totals(); stop();");
  SWFMovie_nextFrame(mo); 

  /*****************************************************
   *
   * Output movie
   *
   *****************************************************/
  puts("Saving " OUTPUT_FILENAME );

  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
Esempio n. 5
0
int
main(int argc, char **argv)
{
	SWFMovie mo;
	SWFDisplayItem it;
	const char *srcdir=".";
	SWFMovieClip dejagnuclip;

	/*********************************************
	 *
	 * Initialization
	 *
	 *********************************************/

	puts("Setting things up");

	Ming_init();
        Ming_useSWFVersion (OUTPUT_VERSION);
	Ming_setScale(20.0); 
 
	mo = newSWFMovie();
	SWFMovie_setDimension(mo, 800, 600);
	SWFMovie_setRate(mo, 12);

	if ( argc>1 ) srcdir=argv[1];
	else
	{
		fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
		return 1;
	}

	font = get_default_font(srcdir); 

	/* Dejagnu equipment */
	dejagnuclip = get_dejagnu_clip((SWFBlock)font, 10, 0, 0, 800, 600);
	it = SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  	SWFDisplayItem_setDepth(it, 200); 
  	SWFDisplayItem_move(it, 200, 0); 

	add_text_field(mo, "textfield", "_root.msg", "Button events", 10, 0, 5);
	add_text_field(mo, "textfield2", "_root.msg2", "Mouse events", 11, 0, 100);
	add_text_field(mo, "textfield3", "_root.msg3", "Key events", 12, 0, 80);

	SWFMovie_nextFrame(mo); /* showFrame */

	/*****************************************************
	 *
	 * Add button
	 *
	 *****************************************************/

	it = add_button(mo);
	SWFDisplayItem_moveTo(it, 40, 30);
	SWFDisplayItem_setName(it, "square1");
	SWFDisplayItem_setDepth(it, 2);

	add_actions(mo,
		"function printBounds(b) {"
		"   return ''+Math.round(b.xMin*100)/100+','+Math.round(b.yMin*100)/100+' '+Math.round(b.xMax*100)/100+','+Math.round(b.yMax*100)/100;"
		"}"
	);

	//
	// Mouse pointer events
	//

	add_actions(mo,
		"square1.button.onRollOver = function() { "
		"	_root.msg2 = 'RollOver'; "
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	add_actions(mo,
		"square1.button.onRollOut = function() {"
		"	_root.msg2 = 'RollOut'; "
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	//
	// Mouse buttons events
	//

	add_actions(mo,
		"square1.button.onPress = function() {"
		"	_root.msg2 = 'Press'; "
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	add_actions(mo,
		"square1.button.onRelease = function() {"
		"	_root.msg2 = 'Release'; "
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	add_actions(mo,
		"square1.button.onReleaseOutside = function() {"
		"	_root.msg2 = 'ReleaseOutside'; "
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	//
	// Focus events
	//

	add_actions(mo,
		"square1.button.onSetFocus = function() {"
		"	_root.msg3 = 'SetFocus';"
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	//
	// Key events - button needs focus for these to work
	//

	add_actions(mo,
		"square1.button.onKeyDown = function() {"
		"	_root.msg3 = 'KeyDown';"
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	add_actions(mo, 
		"square1.button.onKeyUp = function() {"
		"	_root.msg3 = 'KeyUp';"
		// Target is the one this function was defined in
		"	check_equals(_target, '/');"
		"};"
		);

	SWFMovie_nextFrame(mo); /* showFrame */

	/*****************************************************
	 *
	 * On second frame, check construction of the button
	 * DisplayObject states and give instructions to proceed
	 *
	 *
	 *****************************************************/

	add_actions(mo, "Array.prototype.realLength = function() {"
		" var l=0; for (var i in this) { "
		"	if (Number(i) == i) l++;" /* count only numbers */
		" };"
		" return l;"
		"};");

	/* buttonChild was initialized with 2 elements */
	check_equals(mo, "typeof(_root.buttonChild)", "'object'");
	check(mo, "_root.buttonChild instanceof Array");
	check_equals(mo, "_root.buttonChild.realLength()", "2"); /* UP and ALL states */

	/* sprite for ALL states */
	check_equals(mo, "typeof(_root.buttonChild[10])", "'object'");
	check_equals(mo, "(_root.buttonChild[10].nam)", "'_level0.square1.button.instance5'"); 
	check_equals(mo, "(_root.buttonChild[10].exe)", "1");
	check_equals(mo, "(_root.buttonChild[10].uld)", "0");

	/* sprite for UP state */
	check_equals(mo, "typeof(_root.buttonChild[12])", "'object'");
	check_equals(mo, "(_root.buttonChild[12].nam)", "'_level0.square1.button.instance6'"); 
	check_equals(mo, "(_root.buttonChild[12].exe)", "1");
	check_equals(mo, "(_root.buttonChild[12].uld)", "0");
	check_equals(mo, "_level0.square1.button.instance6._name", "'instance6'");
	check_equals(mo, "_level0.square1.button.instance6.getDepth()", "-16371");

	/* sprite for HIT state not constructed */
	check_equals(mo, "typeof(_root.buttonChild[11])", "'undefined'");

	/* sprite for DOWN state not constructed */
	check_equals(mo, "typeof(_root.buttonChild[13])", "'undefined'"); 

	add_actions(mo,
		"stop();"
		/*"_root.note('buttonChild is '+dumpObj(_root.buttonChild));"*/
		"_root.testno=0;"
		"_root.square1.onRollOut = function() { _root.testno++; delete _root.square1.onRollOut; nextFrame(); };"
		"_root.note('"
		"0. Roll over and out the red square, not touching the small dark-red square in it."
		"');");

	/* hitTest should work on every child, not just first added */
	check(mo, "_level0.square1.hitTest(60,60,true)");

	SWFMovie_nextFrame(mo); /* showFrame */

	/*****************************************************
	 *
	 * On third frame, start the button event test
	 *
	 *****************************************************/

	add_actions(mo,
		"stop();"
		/*"_root.note('buttonChild is '+dumpObj(_root.buttonChild));"*/
		"_root.testno=1;"
		"_root.note('"
		"1. Roll over the red square."
		"');");

	SWFMovie_nextFrame(mo); /* showFrame */

	/*****************************************************
	 *
	 * On fourth frame, add a shape at lower depth,
	 * and check bounds of square1
	 *
	 *
	 *****************************************************/

	{
		SWFShape sh = make_fill_square(0, 0, 120, 120, 0, 0, 0, 0, 255, 0);
		SWFDisplayItem itsh = SWFMovie_add(mo, (SWFBlock)sh);
		SWFDisplayItem_setDepth(itsh, 1);

		check_equals(mo, "printBounds(square1.getBounds())", "'-0.05,-0.05 40.05,40.05'");

		/* buttonChild should now have a total of 4 elements (UP,DOWN, OVER and ALL states) */
		check_equals(mo, "typeof(_root.buttonChild)", "'object'");
		check(mo, "_root.buttonChild instanceof Array");
		check_equals(mo, "_root.buttonChild.realLength()", "4"); 

		/* sprite for ALL states */
		check_equals(mo, "typeof(_root.buttonChild[10])", "'object'");
		check_equals(mo, "(_root.buttonChild[10].nam)", "'_level0.square1.button.instance5'"); 
		check_equals(mo, "(_root.buttonChild[10].exe)", "1");
		check_equals(mo, "(_root.buttonChild[10].uld)", "0");

		/* sprite for UP state */
		check_equals(mo, "typeof(_root.buttonChild[12])", "'object'");
		check_equals(mo, "(_root.buttonChild[12].nam)", "'_level0.square1.button.instance6'"); 
		check_equals(mo, "(_root.buttonChild[12].exe)", "3"); 
		check_equals(mo, "(_root.buttonChild[12].uld)", "2");

		/* sprite for OVER state */
		check_equals(mo, "typeof(_root.buttonChild[13])", "'object'");
		check_equals(mo, "(_root.buttonChild[13].nam)", "'_level0.square1.button.instance7'"); 
		check_equals(mo, "(_root.buttonChild[13].exe)", "4");
		check_equals(mo, "(_root.buttonChild[13].uld)", "4");

		/* sprite for DOWN state */
		check_equals(mo, "typeof(_root.buttonChild[14])", "'object'");
		check_equals(mo, "(_root.buttonChild[14].nam)", "'_level0.square1.button.instance8'"); 
		check_equals(mo, "(_root.buttonChild[14].exe)", "2");
		check_equals(mo, "(_root.buttonChild[14].uld)", "2");

		/* sprite for HIT state never constructed */
		check_equals(mo, "typeof(_root.buttonChild[11])", "'undefined'"); 



		add_actions(mo,
			"stop();"
			"_root.note('-- Added shape at lower depth --');"
			"_root.testno++;"
			"_root.note(_root.testno+'. Roll over the square.');"
		);

		SWFMovie_nextFrame(mo); /* showFrame */
	}

	/*****************************************************
	 *
	 * On fifth frame, add a shape at higher depth 
	 *
	 *****************************************************/

	{
		SWFShape sh = make_fill_square(0, 0, 120, 120, 0, 0, 0, 0, 255, 0);
		SWFDisplayItem itsh = SWFMovie_add(mo, (SWFBlock)sh);
		SWFDisplayItem_setDepth(itsh, 3);
		SWFDisplayItem_setColorAdd(itsh, 0, 0, 0, -128);

		/* buttonChild should now have a total of 4 elements (UP,DOWN, OVER and ALL states) */
		check_equals(mo, "typeof(_root.buttonChild)", "'object'");
		check(mo, "_root.buttonChild instanceof Array");
		check_equals(mo, "_root.buttonChild.realLength()", "4"); 

		/* sprite for ALL states */
		check_equals(mo, "typeof(_root.buttonChild[10])", "'object'");
		check_equals(mo, "(_root.buttonChild[10].nam)", "'_level0.square1.button.instance5'"); 
		check_equals(mo, "(_root.buttonChild[10].exe)", "1");
		check_equals(mo, "(_root.buttonChild[10].uld)", "0");

		/* sprite for UP state */
		check_equals(mo, "typeof(_root.buttonChild[12])", "'object'");
		check_equals(mo, "(_root.buttonChild[12].nam)", "'_level0.square1.button.instance6'"); 
		check_equals(mo, "(_root.buttonChild[12].exe)", "5"); 
		check_equals(mo, "(_root.buttonChild[12].uld)", "4");

		/* sprite for OVER state */
		check_equals(mo, "typeof(_root.buttonChild[13])", "'object'");
		check_equals(mo, "(_root.buttonChild[13].nam)", "'_level0.square1.button.instance7'"); 
		check_equals(mo, "(_root.buttonChild[13].exe)", "8");
		check_equals(mo, "(_root.buttonChild[13].uld)", "8");

		/* sprite for DOWN state */
		check_equals(mo, "typeof(_root.buttonChild[14])", "'object'");
		check_equals(mo, "(_root.buttonChild[14].nam)", "'_level0.square1.button.instance8'"); 
		check_equals(mo, "(_root.buttonChild[14].exe)", "4");
		check_equals(mo, "(_root.buttonChild[14].uld)", "4");

		/* sprite for HIT state never constructed */
		check_equals(mo, "typeof(_root.buttonChild[11])", "'undefined'"); 

		add_actions(mo,
			"stop();"
			"_root.note('-- Added shape at higher depth --');"
			"_root.testno++;"
			"_root.note(_root.testno+'. Roll over the square.');"
		);

		SWFMovie_nextFrame(mo); /* showFrame */
	}

	/*****************************************************
	 *
	 * On sixth frame, disable the button
	 * and check total tests so far
	 *
	 *****************************************************/

	{

		add_actions(mo,
            "check_equals(square1.button.enabled, true);"
			"square1.button.enabled = 6;"
            "check_equals(square1.button.enabled, 6);"
			"square1.button.enabled = 'string';"
            "check_equals(square1.button.enabled, 'string');"
            "square1.button._visible = false;"
            "check_equals(square1.button.enabled, 'string');"
            "square1.button._visible = true;"
			"square1.button.enabled = false;"
			"stop();"
			"_root.totals(160);"
			"_root.note('-- Button disabled, try playing with it, nothing should happen --');"
		);
		SWFMovie_nextFrame(mo); /* showFrame */
	}

	/*****************************************************
	 *
	 * Save it...
	 *
	 *****************************************************/

	puts("Saving " OUTPUT_FILENAME );

	SWFMovie_save(mo, OUTPUT_FILENAME);

	return 0;
}
Esempio n. 6
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  const char *srcdir=".";
  char fdefont[256];
  SWFMovieClip  dejagnuclip;
  
  SWFDisplayItem it;

  /*********************************************
   *
   * Initialization
   *
   *********************************************/

  if ( argc>1 ) srcdir=argv[1];
  else
  {
    fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
    return 1;
  }

  sprintf(fdefont, "%s/Bitstream-Vera-Sans.fdb", srcdir);
  FILE *font_file = fopen(fdefont, "r");
  if ( font_file == NULL )
  {
    perror(fdefont);
    exit(1);
  }
  SWFFont efont = loadSWFFontFromFile(font_file);

  puts("Setting things up");

  Ming_init();
  Ming_useSWFVersion (OUTPUT_VERSION);
 
  mo = newSWFMovie();
  SWFMovie_setRate(mo, 1.0);
  SWFMovie_setDimension(mo, 800, 600);
  
  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10,
          0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  SWFMovie_nextFrame(mo); // 1st frame 

  /*********************************************
   *
   * Add some textfields
   *
   *********************************************/

  int y = 30;
  int inc = 30;

  it = add_text_field(mo, (SWFBlock)efont, "Normal", 1, 2, 3,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_setName(it, "tf1");
  
  y += inc;

  it = add_text_field(mo, (SWFBlock)efont, "Transparent", 1, 2, 3,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 0);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_setName(it, "tf2");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, no indent or "
          "margin", 0, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf3");

  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, indent 4",
          4, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf4");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, left margin 4",
          0, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf5");
  
  y += inc;
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, right margin 4",
          0, 0, 4, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf6");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 16, left margin 4, "
          "indent 4", 4, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf7");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 8, no indent or margin",
          0, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 8, 1);
  SWFDisplayItem_setName(it, "tf8");

  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 8, indent 4", 4, 0, 0,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 8, 1);
  SWFDisplayItem_setName(it, "tf9");
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "X scaled by 0.2", 8, 8, 8,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 0.2, 1);
  SWFDisplayItem_setName(it, "tf10");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)efont, "Y scaled by 4", 4, 4, 0,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 1, 4);
  SWFDisplayItem_setName(it, "tf11");
  
  y += inc * 3;
  
  it = add_text_field(mo, (SWFBlock)efont, "Y scaled by 8", 4, 4, 0,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 1, 8);
  SWFDisplayItem_setName(it, "tf12");


  // It's not clear how consistent the textWidth or textHeight
  // values are. As they are embedded, it may be possible to reproduce
  // exactly, in which case the test can be made more precise.

  check_equals(mo, "tf1._width", "84");
  check_equals(mo, "tf1._height", "20");
  xcheck_equals(mo, "tf1._x", "48");
  xcheck_equals(mo, "tf1._y", "28");
  xcheck_equals(mo, "tf1.textHeight", "23");
  // Approx 46
  add_actions(mo, "trace(tf1.textWidth);");
  xcheck(mo, "tf1.textWidth >= 44 && tf1.textWidth <= 48");

  check_equals(mo, "tf2._width", "84");
  check_equals(mo, "tf2._height", "20");
  xcheck_equals(mo, "tf2._x", "48");
  xcheck_equals(mo, "tf2._y", "58");
  xcheck_equals(mo, "tf2.textHeight", "23");
  // Approx 78
  add_actions(mo, "trace(tf2.textWidth);");
  xcheck(mo, "tf2.textWidth >= 76 && tf2.textWidth <= 80");

  check_equals(mo, "tf3._width", "1344");
  check_equals(mo, "tf3._height", "20");
  xcheck_equals(mo, "tf3._x", "18");
  xcheck_equals(mo, "tf3._y", "88");
  xcheck_equals(mo, "tf3.textHeight", "23");
  // Approx 230
  add_actions(mo, "trace(tf3.textWidth);");
  xcheck(mo, "tf3.textWidth >= 225 && tf3.textWidth <= 235");

  check_equals(mo, "tf4._width", "1344");
  check_equals(mo, "tf4._height", "20");
  xcheck_equals(mo, "tf4._x", "18");
  xcheck_equals(mo, "tf4._y", "118");
  xcheck_equals(mo, "tf4.textHeight", "23");
  // Approx 156
  add_actions(mo, "trace(tf4.textWidth);");
  xcheck(mo, "tf4.textWidth >= 153 && tf4.textWidth <= 159");

  check_equals(mo, "tf5._width", "1344");
  check_equals(mo, "tf5._height", "20");
  xcheck_equals(mo, "tf5._x", "18");
  xcheck_equals(mo, "tf5._y", "148");
  xcheck_equals(mo, "tf5.textHeight", "23");
  // Approx 186
  add_actions(mo, "trace(tf5.textWidth);");
  xcheck(mo, "tf5.textWidth >= 183 && tf5.textWidth <= 189");

  check_equals(mo, "tf6._width", "1344");
  check_equals(mo, "tf6._height", "20");
  xcheck_equals(mo, "tf6._x", "18");
  xcheck_equals(mo, "tf6._y", "178");
  xcheck_equals(mo, "tf6.textHeight", "23");
  // Approx 194
  add_actions(mo, "trace(tf6.textWidth);");
  xcheck(mo, "tf6.textWidth >= 189 && tf6.textWidth <= 199");

  check_equals(mo, "tf7._width", "1344");
  check_equals(mo, "tf7._height", "20");
  xcheck_equals(mo, "tf7._x", "18");
  xcheck_equals(mo, "tf7._y", "208");
  xcheck_equals(mo, "tf7.textHeight", "23");
  // Approx 247
  add_actions(mo, "trace(tf7.textWidth);");
  xcheck(mo, "tf7.textWidth >= 240 && tf7.textWidth <= 254");

  check_equals(mo, "tf8._width", "672");
  check_equals(mo, "tf8._height", "20");
  xcheck_equals(mo, "tf8._x", "34");
  xcheck_equals(mo, "tf8._y", "238");
  xcheck_equals(mo, "tf8.textHeight", "23");
  // Approx 222
  add_actions(mo, "trace(tf8.textWidth);");
  xcheck(mo, "tf8.textWidth >= 217 && tf8.textWidth <= 227");

  check_equals(mo, "tf9._width", "672");
  check_equals(mo, "tf9._height", "20");
  xcheck_equals(mo, "tf9._x", "34");
  xcheck_equals(mo, "tf9._y", "268");
  xcheck_equals(mo, "tf9.textHeight", "23");
  // Approx 148
  add_actions(mo, "trace(tf9.textWidth);");
  xcheck(mo, "tf9.textWidth >= 144 && tf9.textWidth <= 152");

  check_equals(mo, "tf10._width", "16.8");
  check_equals(mo, "tf10._height", "20");
  xcheck_equals(mo, "tf10._x", "49.6");
  xcheck_equals(mo, "tf10._y", "298");
  xcheck_equals(mo, "tf10.textHeight", "23");
  // Approx 99
  add_actions(mo, "trace(tf10.textWidth);");
  xcheck(mo, "tf10.textWidth >= 95 && tf10.textWidth <= 103");

  // The textHeight for the following two fields varies.
  check_equals(mo, "tf11._width", "84");
  check_equals(mo, "tf11._height", "80");
  xcheck_equals(mo, "tf11._x", "48");
  xcheck_equals(mo, "tf11._y", "322");
  xcheck_equals(mo, "tf11.textHeight", "23");
  // Approx 86
  add_actions(mo, "trace(tf11.textWidth);");
  xcheck(mo, "tf11.textWidth >= 84 && tf11.textWidth <= 88");

  check_equals(mo, "tf12._width", "84");
  check_equals(mo, "tf12._height", "160");
  xcheck_equals(mo, "tf12._x", "48");
  xcheck_equals(mo, "tf12._y", "404");
  xcheck_equals(mo, "tf12.textHeight", "23");
  // Approx 86
  add_actions(mo, "trace(tf12.textWidth);");
  xcheck(mo, "tf12.textWidth >= 84 && tf12.textWidth <= 88");

  add_actions(mo, "totals(); stop();");

  SWFMovie_nextFrame(mo); 

  /*****************************************************
   *
   * Output movie
   *
   *****************************************************/
  puts("Saving " OUTPUT_FILENAME );

  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}
Esempio n. 7
0
int
main(int argc, char** argv)
{
  SWFMovie mo;
  const char *srcdir=".";
  char fdbfont[256];
  SWFMovieClip  dejagnuclip;
  
  SWFDisplayItem it;

  /*********************************************
   *
   * Initialization
   *
   *********************************************/

  if ( argc>1 ) srcdir=argv[1];
  else
  {
    fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
    return 1;
  }

  sprintf(fdbfont, "%s/Bitstream-Vera-Sans.fdb", srcdir);

  puts("Setting things up");

  Ming_init();
  Ming_useSWFVersion (OUTPUT_VERSION);
 
  mo = newSWFMovie();
  SWFMovie_setRate(mo, 1.0);
  SWFMovie_setDimension(mo, 800, 600);
  
  dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10,
          0, 0, 800, 600);
  SWFMovie_add(mo, (SWFBlock)dejagnuclip);
  SWFMovie_nextFrame(mo); // 1st frame 

  /*********************************************
   *
   * Add some textfields
   *
   *********************************************/
  SWFBrowserFont bfont = newSWFBrowserFont("_sans");

  int y = 30;
  int inc = 30;

  it = add_text_field(mo, (SWFBlock)bfont, "Normal", 1, 2, 3,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_setName(it, "tf1");
  
  y += inc;

  it = add_text_field(mo, (SWFBlock)bfont, "Transparent", 1, 2, 3,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 0);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_setName(it, "tf2");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 16, no indent or "
          "margin", 0, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf3");

  y += inc;
  
  it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 16, indent 4",
          4, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf4");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 16, left margin 4",
          0, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf5");
  
  y += inc;
  it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 16, right margin 4",
          0, 0, 4, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf6");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 16, left margin 4, "
          "indent 4", 4, 4, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 16, 1);
  SWFDisplayItem_setName(it, "tf7");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 8, no indent or margin",
          0, 0, 0, SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 8, 1);
  SWFDisplayItem_setName(it, "tf8");

  y += inc;
  
  it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 8, indent 4", 4, 0, 0,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 8, 1);
  SWFDisplayItem_setName(it, "tf9");
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)bfont, "X scaled by 0.2", 8, 8, 8,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 0.2, 1);
  SWFDisplayItem_setName(it, "tf10");
  
  y += inc;
  
  it = add_text_field(mo, (SWFBlock)bfont, "Y scaled by 4", 4, 4, 0,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 1, 4);
  SWFDisplayItem_setName(it, "tf11");
  
  y += inc * 3;
  
  it = add_text_field(mo, (SWFBlock)bfont, "Y scaled by 8", 4, 4, 0,
          SWFTEXTFIELD_ALIGN_LEFT, 10, 0, 0, 0, 255);
  SWFDisplayItem_moveTo(it, 50, y);
  SWFDisplayItem_scale(it, 1, 8);
  SWFDisplayItem_setName(it, "tf12");


  // As these are device fonts, it's not clear how consistent the textWidth
  // value will be. It's not even clear that it's worth testing it.

  check_equals(mo, "tf1._width", "84");
  check_equals(mo, "tf1._height", "20");
  xcheck_equals(mo, "tf1._x", "48");
  xcheck_equals(mo, "tf1._y", "28");
  xcheck_equals(mo, "tf1.textHeight", "24");
  // Approx 42
  xcheck(mo, "tf1.textWidth >= 40 && tf1.textWidth <= 45");

  check_equals(mo, "tf2._width", "84");
  check_equals(mo, "tf2._height", "20");
  xcheck_equals(mo, "tf2._x", "48");
  xcheck_equals(mo, "tf2._y", "58");
  xcheck_equals(mo, "tf2.textHeight", "24");
  // Approx 69
  xcheck(mo, "tf2.textWidth >= 66 && tf2.textWidth <= 72");

  check_equals(mo, "tf3._width", "1344");
  check_equals(mo, "tf3._height", "20");
  xcheck_equals(mo, "tf3._x", "18");
  xcheck_equals(mo, "tf3._y", "88");
  xcheck_equals(mo, "tf3.textHeight", "24");
  // Approx 13
  xcheck(mo, "tf3.textWidth >= 11 && tf3.textWidth <= 15");

  check_equals(mo, "tf4._width", "1344");
  check_equals(mo, "tf4._height", "20");
  xcheck_equals(mo, "tf4._x", "18");
  xcheck_equals(mo, "tf4._y", "118");
  xcheck_equals(mo, "tf4.textHeight", "24");
  // Approx 9
  xcheck(mo, "tf4.textWidth >= 7 && tf4.textWidth <= 11");

  check_equals(mo, "tf5._width", "1344");
  check_equals(mo, "tf5._height", "20");
  xcheck_equals(mo, "tf5._x", "18");
  xcheck_equals(mo, "tf5._y", "148");
  xcheck_equals(mo, "tf5.textHeight", "24");
  // Approx 10
  xcheck(mo, "tf5.textWidth >= 8 && tf5.textWidth <= 12");

  check_equals(mo, "tf6._width", "1344");
  check_equals(mo, "tf6._height", "20");
  xcheck_equals(mo, "tf6._x", "18");
  xcheck_equals(mo, "tf6._y", "178");
  xcheck_equals(mo, "tf6.textHeight", "24");
  // Approx 11
  xcheck(mo, "tf6.textWidth >= 9 && tf6.textWidth <= 13");

  check_equals(mo, "tf7._width", "1344");
  check_equals(mo, "tf7._height", "20");
  xcheck_equals(mo, "tf7._x", "18");
  xcheck_equals(mo, "tf7._y", "208");
  xcheck_equals(mo, "tf7.textHeight", "24");
  // Approx 14
  xcheck(mo, "tf7.textWidth >= 14 && tf7.textWidth <= 16");

  check_equals(mo, "tf8._width", "672");
  check_equals(mo, "tf8._height", "20");
  xcheck_equals(mo, "tf8._x", "34");
  xcheck_equals(mo, "tf8._y", "238");
  xcheck_equals(mo, "tf8.textHeight", "24");
  // Approx 25
  xcheck(mo, "tf8.textWidth >= 21 && tf8.textWidth <= 27");

  check_equals(mo, "tf9._width", "672");
  check_equals(mo, "tf9._height", "20");
  xcheck_equals(mo, "tf9._x", "34");
  xcheck_equals(mo, "tf9._y", "268");
  xcheck_equals(mo, "tf9.textHeight", "24");
  // Approx 16
  xcheck(mo, "tf9.textWidth >= 14 && tf9.textWidth <= 18");

  check_equals(mo, "tf10._width", "16.8");
  check_equals(mo, "tf10._height", "20");
  xcheck_equals(mo, "tf10._x", "49.6");
  xcheck_equals(mo, "tf10._y", "298");
  xcheck_equals(mo, "tf10.textHeight", "24");
  // Approx 452
  xcheck(mo, "tf10.textWidth >= 440 && tf10.textWidth <= 460");

  // The textHeight for the following two fields varies.
  check_equals(mo, "tf11._width", "84");
  check_equals(mo, "tf11._height", "80");
  xcheck_equals(mo, "tf11._x", "48");
  xcheck_equals(mo, "tf11._y", "322");
  add_actions(mo, "trace(tf11.textWidth);");
  xcheck(mo, "tf11.textHeight >= 23 && tf11.textHeight <= 24");
  // Approx 315
  xcheck(mo, "tf11.textWidth >= 305 && tf11.textWidth <= 325");

  check_equals(mo, "tf12._width", "84");
  check_equals(mo, "tf12._height", "160");
  xcheck_equals(mo, "tf12._x", "48");
  xcheck_equals(mo, "tf12._y", "404");
  add_actions(mo, "trace(tf12.textWidth);");
  xcheck(mo, "tf12.textHeight >= 23 && tf12.textHeight <= 24");
  // Approx 640
  xcheck(mo, "tf12.textWidth >= 625 && tf12.textWidth <= 655");

  add_actions(mo, "totals(); stop();");

  SWFMovie_nextFrame(mo); 

  /*****************************************************
   *
   * Output movie
   *
   *****************************************************/
  puts("Saving " OUTPUT_FILENAME );

  SWFMovie_save(mo, OUTPUT_FILENAME);

  return 0;
}