gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/textformat.cpp server/te...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/textformat.cpp server/te...
Date: Wed, 09 Apr 2008 20:34:55 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/04/09 20:34:54

Modified files:
        .              : ChangeLog 
        server         : textformat.cpp textformat.h 
        server/asobj   : ClassHierarchy.cpp Global.cpp 
        server/parser  : edit_text_character_def.h 
        testsuite/actionscript.all: Makefile.am 
        testsuite/misc-ming.all: DefineEditTextTest.c 
Added files:
        testsuite/actionscript.all: TextFormat.as 

Log message:
        * server/textformat.{cpp,h}: stub TextFormat in the up-to-date way
        * server/asobj/ClassHierarchy.cpp: don't include textformat.h
        * server/asobj/Global.cpp: initialize TextFormat object in the
          proper way (and from swf5 up).
        * server/parser/edit_text_character_def.h: drop unused functions
          referencing textformat.
        * testsuite/actionscript.all/: Makefile.am, TextFormat.as: initial
          simple test for TextFormat object
        * testsuite/misc-ming.all/DefineEditTextTest.c: test that a TextFormat
          is constructed on demand (TextField.getTextFormat).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6229&r2=1.6230
http://cvs.savannah.gnu.org/viewcvs/gnash/server/textformat.cpp?cvsroot=gnash&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/gnash/server/textformat.h?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/ClassHierarchy.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Global.cpp?cvsroot=gnash&r1=1.106&r2=1.107
http://cvs.savannah.gnu.org/viewcvs/gnash/server/parser/edit_text_character_def.h?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Makefile.am?cvsroot=gnash&r1=1.86&r2=1.87
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/TextFormat.as?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DefineEditTextTest.c?cvsroot=gnash&r1=1.28&r2=1.29

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6229
retrieving revision 1.6230
diff -u -b -r1.6229 -r1.6230
--- ChangeLog   9 Apr 2008 20:32:36 -0000       1.6229
+++ ChangeLog   9 Apr 2008 20:34:50 -0000       1.6230
@@ -1,5 +1,18 @@
 2008-04-09 Sandro Santilli <address@hidden>
 
+       * server/textformat.{cpp,h}: stub TextFormat in the up-to-date way
+       * server/asobj/ClassHierarchy.cpp: don't include textformat.h
+       * server/asobj/Global.cpp: initialize TextFormat object in the 
+         proper way (and from swf5 up).
+       * server/parser/edit_text_character_def.h: drop unused functions
+         referencing textformat.
+       * testsuite/actionscript.all/: Makefile.am, TextFormat.as: initial
+         simple test for TextFormat object
+       * testsuite/misc-ming.all/DefineEditTextTest.c: test that a TextFormat
+         is constructed on demand (TextField.getTextFormat).
+
+2008-04-09 Sandro Santilli <address@hidden>
+
        * server/text.{cpp,h}: don't include textformat.h
        * server/vm/action.cpp: reduce header inclusion, drop obsoleted
          comments and code.

Index: server/textformat.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/textformat.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- server/textformat.cpp       14 Mar 2008 20:21:49 -0000      1.36
+++ server/textformat.cpp       9 Apr 2008 20:34:51 -0000       1.37
@@ -19,6 +19,7 @@
 
 
 #include "log.h"
+#include "Object.h" // for getObjectInterface
 #include "textformat.h"
 #include "fn_call.h"
 #include "builtin_function.h" // for getter/setter properties
@@ -29,7 +30,188 @@
 
 namespace gnash {  
 
-  text_format::text_format() :
+static as_value textformat_new(const fn_call& fn);
+static as_object* getTextFormatInterface();
+static void attachTextFormatInterface(as_object& o);
+
+class DSOEXPORT TextFormat : public as_object
+{
+public:
+  
+       TextFormat();
+       ~TextFormat() {}
+
+       /// Return a Boolean value that indicates whether the text is 
underlined.
+       bool underlined()  { return _underline; }
+
+       /// Return a Boolean value that indicates whether the text is 
italicized.
+       bool italiced()    { return _italic; }
+
+       /// Return a Boolean value that indicates whether the text is boldface.
+       bool bold()        { return _bold; }
+
+       bool bullet()      { return _bullet; }
+
+       /// Return the color of text using this text format.
+       //
+       /// A number containing three 8-bit RGB components; for example,
+        /// 0xFF0000 is red, 0x00FF00 is green.
+       boost::uint32_t color() const { return _color; }
+
+       /// \brief
+       /// Return ann integer that indicates the indentation from the left
+        /// margin to the first character in the paragraph
+       float indent() const { return _indent; }
+
+       /// Return the alignment of the paragraph, represented as a string.
+       //
+       /// If "left", the paragraph is left-aligned. If "center", the
+       /// paragraph is centered. If "right", the paragraph is
+       /// right-aligned.
+       ///
+       /// FIXME: use an enum !
+       ///
+       const std::string& align() const { return _align; }
+
+       /// Return the name of a font for text as a string.
+       const std::string& font() const { return _font; }
+
+       ///
+       float blockIndent() { return _block_indent; }
+
+       /// Return a number that indicates the amount of leading vertical
+       /// space between lines.
+       float leading()     { return _leading; }
+
+       /// Indicates the left margin of the paragraph, in points.
+       float leftMargin()  { return _left_margin; }
+
+       /// Indicates the right margin of the paragraph, in points.
+       float RightMargin() { return _right_margin; }
+
+       /// Return a float that indicates the point size.
+       float size()        { return _point_size; }
+
+       void underlinedSet(bool x)   { _underline = x; }
+       void italicedSet(bool x)     { _italic = x; }
+       void boldSet(bool x)         { _bold = x; }
+       void bulletSet(bool x)       { _bullet = x; }
+       void colorSet(boost::uint32_t x)      { _color = x; }
+       void indentSet(float x)      { _indent = x; }
+
+       void alignSet(const std::string& x)  { _align = x; }
+
+       void blockIndentSet(float x)   { _block_indent = x; }
+       void leadingSet(float x)     { _leading = x; }
+       void leftMarginSet(float x)  { _left_margin = x; }
+       void rightMarginSet(float x) { _right_margin = x; }
+       void sizeSet(float x)        { _point_size = x; }
+
+       // In a paragraph, change the format of a range of characters.
+       void setTextFormat (TextFormat &format);
+       void setTextFormat (int index, TextFormat &format);
+       void setTextFormat (int start, int end, TextFormat &format);
+
+       TextFormat &getTextFormat ();
+       TextFormat &getTextFormat (int index);
+       TextFormat &getTextFormat (int start, int end);
+
+       int getTextExtant();
+
+       static as_value display_getset(const fn_call& fn);
+       static as_value bullet_getset(const fn_call& fn);
+       static as_value tabStops_getset(const fn_call& fn);
+       static as_value blockIndent_getset(const fn_call& fn);
+       static as_value leading_getset(const fn_call& fn);
+       static as_value indent_getset(const fn_call& fn);
+       static as_value rightMargin_getset(const fn_call& fn);
+       static as_value leftMargin_getset(const fn_call& fn);
+       static as_value align_getset(const fn_call& fn);
+       static as_value underline_getset(const fn_call& fn);
+       static as_value italic_getset(const fn_call& fn);
+       static as_value bold_getset(const fn_call& fn);
+       static as_value target_getset(const fn_call& fn);
+       static as_value url_getset(const fn_call& fn);
+       static as_value color_getset(const fn_call& fn);
+       static as_value size_getset(const fn_call& fn);
+       static as_value font_getset(const fn_call& fn);
+       static as_value getTextExtent_method(const fn_call& fn);
+
+  
+private:
+
+
+       /// A Boolean value that indicates whether the text is underlined.
+       bool          _underline;
+
+       /// A Boolean value that indicates whether the text is boldface.
+       bool          _bold;    
+
+       /// A Boolean value that indicates whether the text is italicized.
+       bool          _italic;
+
+       // 
+       bool          _bullet;
+  
+       /// The alignment of the paragraph, represented as a string.
+       //
+       /// If "left", the paragraph is left-aligned. If "center", the
+       /// paragraph is centered. If "right", the paragraph is
+       /// right-aligned.
+       ///
+       /// FIXME: use an enum !
+       ///
+       std::string _align;
+
+       // 
+       float           _block_indent;
+
+       /// The color of text using this text format.
+       //
+       /// A number containing three 8-bit RGB components; for example,
+        /// 0xFF0000 is red, 0x00FF00 is green.
+       boost::uint32_t _color; 
+
+       // The name of a font for text as a string.
+       std::string _font;      
+
+       /// An integer that indicates the indentation from the left
+        /// margin to the first character in the paragraph
+       float           _indent;
+
+       /// A number that indicates the amount of leading vertical
+       /// space between lines.
+       float           _leading;
+
+       /// Indicates the left margin of the paragraph, in points.
+       float           _left_margin;
+
+       /// Indicates the right margin of the paragraph, in points.
+       float           _right_margin;
+
+       /// An float that indicates the point size.
+       float           _point_size;
+
+       ///
+       int             _tab_stops;
+
+       /// The target window where the hyperlink is displayed. 
+        /// If the target window is an empty string, the text is displayed in
+        /// the default target window _self. If the url parameter is
+        /// set to an empty string or to the value null, you can get
+        /// or set this property, but the property will have no effect.
+       int             _target;
+
+       /// The URL to which the text in this text format hyperlinks.
+       /// If url is an empty string, the text does not have a hyperlink
+       std::string      _url;  
+
+};
+ 
+
+TextFormat::TextFormat()
+       :
+       as_object(getTextFormatInterface()),
       _underline(false),
       _bold(false),
       _italic(false),
@@ -45,214 +227,215 @@
       _target(-1)
 {
   //log_debug("%s:", __FUNCTION__);
-}
-
-text_format::~text_format()
-{
-  // don't need to clean up anything
-}
-
-// Copy one text_format object to another.
-text_format *
-text_format::operator = (text_format &format)
-{
-  GNASH_REPORT_FUNCTION;
-
-  _underline = format._underline;
-  _bold = format._bold;
-  _italic = format._italic;
-  _bullet = format._bullet;
-  
-  _align = format._align;
-  _block_indent = format._block_indent;
-  _color = format._color;
-  _font = format._font;
-  _indent = format._indent;
-  _leading = format._leading;
-  _left_margin = format._left_margin;
-  _right_margin = format._right_margin;
-  _point_size = format._point_size;
-  _tab_stops = format._tab_stops;
-  _target = format._target;
-  _url = format._url;
-  
-  return this;
+       init_member("getTextExtent", new 
builtin_function(TextFormat::getTextExtent_method));
 }
 
 // In a paragraph, change the format of a range of characters.
 void
-text_format::setTextFormat (text_format& /*format*/)
+TextFormat::setTextFormat (TextFormat& /*format*/)
 {
   //GNASH_REPORT_FUNCTION;
 }
 
 void
-text_format::setTextFormat (int /*index*/, text_format& /*format*/)
+TextFormat::setTextFormat (int /*index*/, TextFormat& /*format*/)
 {
   //GNASH_REPORT_FUNCTION;
 }
 
 void
-text_format::setTextFormat (int /*start*/, int /*end*/, text_format& 
/*format*/)
+TextFormat::setTextFormat (int /*start*/, int /*end*/, TextFormat& /*format*/)
 {
   //GNASH_REPORT_FUNCTION;
 }
 
-#if 0
-text_format &
-text_format::getTextFormat ()
+/// new TextFormat([font, [size, [color, [bold, [italic, [underline, [url, 
[target, [align,[leftMargin, [rightMargin, [indent, [leading]]]]]]]]]]]]])
+static as_value
+textformat_new(const fn_call& /* fn */)
 {
-  GNASH_REPORT_FUNCTION;
+  //GNASH_REPORT_FUNCTION;
+  //log_debug(_("%s: args=%d"), __FUNCTION__, nargs);
+
+  boost::intrusive_ptr<TextFormat> text_obj = new TextFormat;
+  ONCE(log_unimpl("TextFormat")); // need to handle args too..
+  
+  return as_value(text_obj.get());
 }
 
-text_format &
-text_format::getTextFormat (int index)
+as_value
+TextFormat::display_getset(const fn_call& /*fn*/)
 {
-  GNASH_REPORT_FUNCTION;
+       ONCE( log_unimpl("TextField.display") );
+       return as_value();
 }
 
-text_format &
-text_format::getTextFormat (int start, int end)
+as_value
+TextFormat::bullet_getset(const fn_call& /*fn*/)
 {
-  GNASH_REPORT_FUNCTION;
+       ONCE( log_unimpl("TextField.bullet") );
+       return as_value();
 }
-#endif
 
-as_value textformat_new(const fn_call& /* fn */)
+as_value
+TextFormat::tabStops_getset(const fn_call& /*fn*/)
 {
-  //GNASH_REPORT_FUNCTION;
-  //log_debug(_("%s: args=%d"), __FUNCTION__, nargs);
-
-  boost::intrusive_ptr<textformat_as_object> text_obj = new 
textformat_as_object;
-  ONCE(log_unimpl("TextFormat"));
-  
-  // tulrich: this looks like it's inserting a method into our
-  // caller's env.  setTextFormat is a method on TextField.  So here
-  // we're hoping our caller is a text field... scary.
-  //
-  // TODO we should handle setTextFormat as a method on TextField,
-  // instead of doing this.
-  //fn.env().set_variable("setTextFormat", new 
builtin_function(textformat_setformat));
+       ONCE( log_unimpl("TextField.tabStops") );
+       return as_value();
+}
   
-  return as_value(text_obj.get());
+as_value
+TextFormat::blockIndent_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.blockIndent") );
+       return as_value();
 }
 
+as_value
+TextFormat::leading_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.leading") );
+       return as_value();
+}
 
-as_value textformat_setformat(const fn_call& fn)
+as_value
+TextFormat::indent_getset(const fn_call& /*fn*/)
 {
-  as_value     method;
-  //log_debug(_("%s: args=%d at %p"), __FUNCTION__, nargs, this_ptr);
+       ONCE( log_unimpl("TextField.indent") );
+       return as_value();
+}
 
-  boost::intrusive_ptr<textformat_as_object> ptr = 
ensureType<textformat_as_object>(fn.this_ptr);
-  //double start = fn.arg(0).to_number();
-  //double end = fn.arg(1).to_number();
-  VM& vm = ptr->getVM();
-  string_table& st = vm.getStringTable();
+as_value
+TextFormat::rightMargin_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.rightMargin") );
+       return as_value();
+}
 
-  if ( fn.nargs < 3 )
-  {
-    IF_VERBOSE_ASCODING_ERRORS(
-    log_aserror(_("TextFormat.setFormat() needs at least 3 arguments - ...me 
thinks"));
-    );
+as_value
+TextFormat::leftMargin_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.leftMargin") );
     return as_value();
-  }
+}
 
-  boost::intrusive_ptr<textformat_as_object> obj = 
boost::dynamic_pointer_cast<textformat_as_object>(fn.arg(2).to_object());
-  if ( ! obj )
-  {
-    IF_VERBOSE_ASCODING_ERRORS(
-    log_aserror(_("Argument 3 given to TextFormat.setFormat() is not a 
TextFormat object - ... should it be?"));
-    );
+as_value
+TextFormat::align_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.align") );
     return as_value();
-  }
-  assert(obj);
+}
 
-  //log_debug(_("Change from %f for %f characters for object at %p"), start, 
end, obj);
+as_value
+TextFormat::underline_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.underline") );
+       return as_value();
+}
 
-  // Check for the flags that could be set
-  if (obj->get_member(NSV::PROP_UNDERLINE, &method)) {
-    //log_debug(_("Underline exists and is set to %d"), method.to_bool());
-    obj->obj.underlinedSet(method.to_bool());
-  }
+as_value
+TextFormat::italic_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.italic") );
+       return as_value();
+}
   
-  if (obj->get_member(NSV::PROP_ITALIC, &method)) {
-    //log_debug(_("Italic exists and is set to %d"), method.to_bool());
-    obj->obj.italicedSet(method.to_bool());
-  }
+as_value
+TextFormat::bold_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.bold") );
+       return as_value();
+}
   
-  if (obj->get_member(NSV::PROP_BOLD, &method)) {
-    //log_debug(_("Bold exists and is set to %d"), method.to_bool());
-    obj->obj.boldSet(method.to_bool());
-  }
+as_value
+TextFormat::target_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.target") );
+       return as_value();
+}
   
-  if (obj->get_member(NSV::PROP_BULLET, &method)) {
-    //log_debug(_("Bullet exists and is set to %d"), method.to_bool());
-    obj->obj.bulletSet(method.to_bool());
-  }
+as_value
+TextFormat::url_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.url") );
+       return as_value();
+}
 
-  // Can't use a named string here with current model, as a "color"
-  // named string would clash with the "Color" class in SWF6 and below
-  // (but not in SWF7 and above)
-  if (obj->get_member(st.find("color"), &method)) {
-    //log_debug(_("Color exists and is set to %f", method.to_number());
-    obj->obj.colorSet((boost::uint32_t)method.to_number());
-  }
+as_value
+TextFormat::color_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.color") );
+       return as_value();
+}
 
-  if (obj->get_member(NSV::PROP_INDENT, &method)) {
-    //log_debug(_("Indent exists and is set to %f"), method.to_number());
-    obj->obj.indentSet(float(method.to_number()));
-  }
+as_value
+TextFormat::size_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.size") );
+       return as_value();
+}
 
-  if (obj->get_member(NSV::PROP_ALIGN, &method)) {
-    //log_debug(_("Align exists and is set to %s"), method.to_string());
-    const char* align = method.to_string().c_str();
-    if ( align ) obj->obj.alignSet(align);
-  }
+as_value
+TextFormat::font_getset(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.font") );
+       return as_value();
+}
 
-  if (obj->get_member(NSV::PROP_BLOCK_INDENT, &method)) {
-    //log_debug(_("BlockIndent exists and is set to %f"), method.to_number());
-    obj->obj.blockIndentSet(float(method.to_number()));
-  }
+as_value
+TextFormat::getTextExtent_method(const fn_call& /*fn*/)
+{
+       ONCE( log_unimpl("TextField.getTextExtent") );
+       return as_value();
+}
   
-  if (obj->get_member(NSV::PROP_LEADING, &method)) {
-    //log_debug(_("Leading exists and is set to %f"), method.to_number());
-    obj->obj.leadingSet(float(method.to_number()));
-  }
+static void
+attachTextFormatInterface(as_object& o)
+{
+       o.init_readonly_property("display", &TextFormat::display_getset);
+       o.init_readonly_property("bullet", &TextFormat::bullet_getset);
+       o.init_readonly_property("tabStops", &TextFormat::tabStops_getset);
+       o.init_readonly_property("blockIndent", 
&TextFormat::blockIndent_getset);
+       o.init_readonly_property("leading", &TextFormat::leading_getset);
+       o.init_readonly_property("indent", &TextFormat::indent_getset);
+       o.init_readonly_property("rightMargin", 
&TextFormat::rightMargin_getset);
+       o.init_readonly_property("leftMargin", &TextFormat::leftMargin_getset);
+       o.init_readonly_property("align", &TextFormat::align_getset);
+       o.init_readonly_property("underline", &TextFormat::underline_getset);
+       o.init_readonly_property("italic", &TextFormat::italic_getset);
+       o.init_readonly_property("bold", &TextFormat::bold_getset);
+       o.init_readonly_property("target", &TextFormat::target_getset);
+       o.init_readonly_property("url", &TextFormat::url_getset);
+       o.init_readonly_property("color", &TextFormat::color_getset);
+       o.init_readonly_property("size", &TextFormat::size_getset);
+       o.init_readonly_property("font", &TextFormat::font_getset);
+}
   
-  if (obj->get_member(NSV::PROP_LEFT_MARGIN, &method)) {
-    //log_debug(_("LeftMargin exists and is set to %f"), method.to_number());
-    obj->obj.leftMarginSet(float(method.to_number()));
+static as_object*
+getTextFormatInterface()
+{
+       static boost::intrusive_ptr<as_object> o;
+       if ( ! o )
+       {
+               o = new as_object(getObjectInterface());
+               attachTextFormatInterface(*o);
   }
+       return o.get();
+}
   
-  if (obj->get_member(NSV::PROP_RIGHT_MARGIN, &method)) {
-    //log_debug(_("RightMargin exists and is set to %f"), method.to_number());
-    obj->obj.rightMarginSet(float(method.to_number()));
-  }
+// extern (used by Global.cpp)
+void textformat_class_init(as_object& global)
+{
+       // This is going to be the global Color "class"/"function"
+       static boost::intrusive_ptr<builtin_function> cl;
   
-  if (obj->get_member(NSV::PROP_SIZE, &method)) {
-    //log_debug(_("Size exists and is set to %f"), method.to_number());
-    obj->obj.sizeSet(float(method.to_number()));
+       if ( cl == NULL )
+       {
+               cl=new builtin_function(&textformat_new, 
getTextFormatInterface());
   }
   
-  //ptr->obj.setTextFormat(start, end, obj->obj);
-  //result->set_bool(true);
-  return as_value();
-}
-#if 0
-  void
-  textformat_getformat(gnash::as_value* result, gnash::as_object_interface* 
this_ptr, gnash::as_environment* env, int nargs, int first_arg)
-{
-  log_unimpl(_("%s: args=%d unfinished implementation"), __FUNCTION__, nargs);
-  textformat_as_object*        ptr = (textformat_as_object*)this_ptr;
-  assert(ptr);
-  double start = env->bottom(first_arg).to_number();
-  double end = env->bottom(first_arg-1).to_number();
-  textformat_as_object *obj = (textformat_as_object 
*)env->bottom(first_arg-2).to_object();
-  assert(obj);
+       // Register _global.Color
+       global.init_member("TextFormat", cl.get());
     
-  ptr->obj = ptr->obj.getTextFormat();
-  result->set_bool(true);
 }
-#endif
 
 } // end of gnash namespace

Index: server/textformat.h
===================================================================
RCS file: /sources/gnash/gnash/server/textformat.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- server/textformat.h 27 Mar 2008 10:50:15 -0000      1.23
+++ server/textformat.h 9 Apr 2008 20:34:52 -0000       1.24
@@ -21,183 +21,15 @@
 #ifndef __TEXTFORMAT_H__
 #define __TEXTFORMAT_H__
 
-#include "dsodefs.h"
-#include "as_object.h" // for textformat_as_object inheritance
-
-
 // Forward declarations
 namespace gnash {  
-       class fn_call;
+       class as_object;
 }
 
 namespace gnash {  
 
-/// new text_format([font, [size, [color, [bold, [italic, [underline, [url, 
[target, [align,[leftMargin, [rightMargin, [indent, [leading]]]]]]]]]]]]])
-class DSOEXPORT text_format
-{
-public:
-  
-       text_format();
-       text_format(const std::string& font);
-       text_format(const std::string& font, int size);
-       text_format(const std::string& font, int size, int color);
-       ~text_format();
-  
-       /// Return a Boolean value that indicates whether the text is 
underlined.
-       bool underlined()  { return _underline; }
-
-       /// Return a Boolean value that indicates whether the text is 
italicized.
-       bool italiced()    { return _italic; }
-
-       /// Return a Boolean value that indicates whether the text is boldface.
-       bool bold()        { return _bold; }
-
-       bool bullet()      { return _bullet; }
-
-       /// Return the color of text using this text format.
-       //
-       /// A number containing three 8-bit RGB components; for example,
-        /// 0xFF0000 is red, 0x00FF00 is green.
-       boost::uint32_t color() const { return _color; }
-
-       /// \brief
-       /// Return ann integer that indicates the indentation from the left
-        /// margin to the first character in the paragraph
-       float indent() const { return _indent; }
-
-       /// Return the alignment of the paragraph, represented as a string.
-       //
-       /// If "left", the paragraph is left-aligned. If "center", the
-       /// paragraph is centered. If "right", the paragraph is
-       /// right-aligned.
-       ///
-       /// FIXME: use an enum !
-       ///
-       const std::string& align() const { return _align; }
-
-       /// Return the name of a font for text as a string.
-       const std::string& font() const { return _font; }
-
-       ///
-       float blockIndent() { return _block_indent; }
-
-       /// Return a number that indicates the amount of leading vertical
-       /// space between lines.
-       float leading()     { return _leading; }
-
-       /// Indicates the left margin of the paragraph, in points.
-       float leftMargin()  { return _left_margin; }
-
-       /// Indicates the right margin of the paragraph, in points.
-       float RightMargin() { return _right_margin; }
-
-       /// Return a float that indicates the point size.
-       float size()        { return _point_size; }
-
-       void underlinedSet(bool x)   { _underline = x; }
-       void italicedSet(bool x)     { _italic = x; }
-       void boldSet(bool x)         { _bold = x; }
-       void bulletSet(bool x)       { _bullet = x; }
-       void colorSet(boost::uint32_t x)      { _color = x; }
-       void indentSet(float x)      { _indent = x; }
-
-       void alignSet(const std::string& x)  { _align = x; }
-
-       void blockIndentSet(float x)   { _block_indent = x; }
-       void leadingSet(float x)     { _leading = x; }
-       void leftMarginSet(float x)  { _left_margin = x; }
-       void rightMarginSet(float x) { _right_margin = x; }
-       void sizeSet(float x)        { _point_size = x; }
-
-       // In a paragraph, change the format of a range of characters.
-       void setTextFormat (text_format &format);
-       void setTextFormat (int index, text_format &format);
-       void setTextFormat (int start, int end, text_format &format);
-
-       text_format &getTextFormat ();
-       text_format &getTextFormat (int index);
-       text_format &getTextFormat (int start, int end);
-
-       int getTextExtant();
-       text_format *operator = (text_format &format);
-  
- private:
-       /// A Boolean value that indicates whether the text is underlined.
-       bool          _underline;
-
-       /// A Boolean value that indicates whether the text is boldface.
-       bool          _bold;    
-
-       /// A Boolean value that indicates whether the text is italicized.
-       bool          _italic;
-
-       // 
-       bool          _bullet;
-  
-       /// The alignment of the paragraph, represented as a string.
-       //
-       /// If "left", the paragraph is left-aligned. If "center", the
-       /// paragraph is centered. If "right", the paragraph is
-       /// right-aligned.
-       ///
-       /// FIXME: use an enum !
-       ///
-       std::string _align;
-
-       // 
-       float           _block_indent;
-
-       /// The color of text using this text format.
-       //
-       /// A number containing three 8-bit RGB components; for example,
-        /// 0xFF0000 is red, 0x00FF00 is green.
-       boost::uint32_t _color; 
-
-       // The name of a font for text as a string.
-       std::string _font;      
-
-       /// An integer that indicates the indentation from the left
-        /// margin to the first character in the paragraph
-       float           _indent;
-
-       /// A number that indicates the amount of leading vertical
-       /// space between lines.
-       float           _leading;
-
-       /// Indicates the left margin of the paragraph, in points.
-       float           _left_margin;
-
-       /// Indicates the right margin of the paragraph, in points.
-       float           _right_margin;
-
-       /// An float that indicates the point size.
-       float           _point_size;
-
-       ///
-       int             _tab_stops;
-
-       /// The target window where the hyperlink is displayed. 
-        /// If the target window is an empty string, the text is displayed in
-        /// the default target window _self. If the url parameter is
-        /// set to an empty string or to the value null, you can get
-        /// or set this property, but the property will have no effect.
-       int             _target;
-
-       /// The URL to which the text in this text format hyperlinks.
-       /// If url is an empty string, the text does not have a hyperlink
-       std::string      _url;  
-
-};
- 
-class DSOLOCAL textformat_as_object : public gnash::as_object
-{
-public:
-       text_format obj;
-};
-
-DSOEXPORT as_value textformat_new(const fn_call& fn);
-DSOEXPORT as_value textformat_setformat(const fn_call& fn);
-DSOEXPORT as_value textformat_getformat(const fn_call& fn);
+/// Initialize the global Color class
+void textformat_class_init(as_object& global);
 
 } // end of gnash namespace
 

Index: server/asobj/ClassHierarchy.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/ClassHierarchy.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- server/asobj/ClassHierarchy.cpp     31 Mar 2008 23:48:32 -0000      1.12
+++ server/asobj/ClassHierarchy.cpp     9 Apr 2008 20:34:52 -0000       1.13
@@ -49,7 +49,6 @@
 #include "Sound.h"
 #include "Stage.h"
 #include "System.h"
-#include "textformat.h"
 #include "TextSnapshot.h"
 #include "video_stream_instance.h"
 #include "extension.h"

Index: server/asobj/Global.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Global.cpp,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -b -r1.106 -r1.107
--- server/asobj/Global.cpp     31 Mar 2008 18:53:35 -0000      1.106
+++ server/asobj/Global.cpp     9 Apr 2008 20:34:53 -0000       1.107
@@ -604,13 +604,13 @@
        init_member("Infinity", as_value(INFINITY));
 
        color_class_init(*this);
+       textformat_class_init(*this);
 
        if ( vm.getSWFVersion() < 6 ) goto extscan;
        //-----------------------
        // SWF6
        //-----------------------
        init_member("LocalConnection", new 
builtin_function(localconnection_new));
-       init_member("TextFormat", new builtin_function(textformat_new));
 
        if ( vm.getSWFVersion() < 7 ) goto extscan;
        //-----------------------

Index: server/parser/edit_text_character_def.h
===================================================================
RCS file: /sources/gnash/gnash/server/parser/edit_text_character_def.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- server/parser/edit_text_character_def.h     1 Apr 2008 18:36:22 -0000       
1.25
+++ server/parser/edit_text_character_def.h     9 Apr 2008 20:34:53 -0000       
1.26
@@ -50,7 +50,6 @@
        edit_text_character_def(movie_definition* root_def)
                :
                m_root_def(root_def),
-               m_format(),
 
                m_has_text(true), // For an SWF-defined textfield we'll read
                                  // this from the tag. Dynamic textfields 
should
@@ -84,12 +83,6 @@
                m_color.set(0, 0, 0, 255);
        }
 
-       /// Set the format of the text
-       void    set_format(text_format &format)
-       {
-               m_format = format;
-       }
-       
        ~edit_text_character_def()
        {
        }
@@ -277,7 +270,6 @@
 
        rect                    m_rect;
        std::string             m_variable_name;
-       text_format             m_format;
        bool                    m_has_text;
        bool                    m_word_wrap;
        bool                    m_multiline;

Index: testsuite/actionscript.all/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Makefile.am,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -b -r1.86 -r1.87
--- testsuite/actionscript.all/Makefile.am      5 Mar 2008 03:56:05 -0000       
1.86
+++ testsuite/actionscript.all/Makefile.am      9 Apr 2008 20:34:54 -0000       
1.87
@@ -102,6 +102,7 @@
        String.as               \
        System.as               \
        TextField.as            \
+       TextFormat.as           \
        TextSnapshot.as         \
        Video.as                \
        Object.as               \

Index: testsuite/misc-ming.all/DefineEditTextTest.c
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/DefineEditTextTest.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- testsuite/misc-ming.all/DefineEditTextTest.c        8 Apr 2008 20:33:31 
-0000       1.28
+++ testsuite/misc-ming.all/DefineEditTextTest.c        9 Apr 2008 20:34:54 
-0000       1.29
@@ -237,6 +237,9 @@
   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
+  xcheck_equals(mo, "typeof(etext1.getTextFormat())", "'object'"); 
+  xcheck_equals(mo, "typeof(dtext2.getTextFormat())", "'object'"); 
   
   add_actions(mo, "dtext1.background = true;"
                   "etext1.background = true;"

Index: testsuite/actionscript.all/TextFormat.as
===================================================================
RCS file: testsuite/actionscript.all/TextFormat.as
diff -N testsuite/actionscript.all/TextFormat.as
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/actionscript.all/TextFormat.as    9 Apr 2008 20:34:54 -0000       
1.1
@@ -0,0 +1,58 @@
+// 
+//   Copyright (C) 2008 Free Software Foundation, Inc.
+//
+// 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
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+//
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+// Test case for TextFormat ActionScript class
+// compile this test case with Ming makeswf, and then
+// execute it like this gnash -1 -r 0 -v out.swf
+
+rcsid="$Id: TextFormat.as,v 1.1 2008/04/09 20:34:54 strk Exp $";
+
+#include "check.as"
+
+Object.prototype.hasOwnProperty = ASnative(101, 5);
+
+check_equals(typeof(TextFormat), 'function');
+check_equals(typeof(TextFormat.prototype), 'object');
+tfObj = new TextFormat();
+check_equals(typeof(tfObj), 'object');
+check(tfObj instanceof TextFormat);
+
+// The members below would not exist before
+// the construction of first TextFormat object
+check(TextFormat.prototype.hasOwnProperty('display'));
+check(TextFormat.prototype.hasOwnProperty('bullet'));
+check(TextFormat.prototype.hasOwnProperty('tabStops'));
+check(TextFormat.prototype.hasOwnProperty('blockIndent'));
+check(TextFormat.prototype.hasOwnProperty('leading'));
+check(TextFormat.prototype.hasOwnProperty('indent'));
+check(TextFormat.prototype.hasOwnProperty('rightMargin'));
+check(TextFormat.prototype.hasOwnProperty('leftMargin'));
+check(TextFormat.prototype.hasOwnProperty('align'));
+check(TextFormat.prototype.hasOwnProperty('underline'));
+check(TextFormat.prototype.hasOwnProperty('italic'));
+check(TextFormat.prototype.hasOwnProperty('bold'));
+check(TextFormat.prototype.hasOwnProperty('target'));
+check(TextFormat.prototype.hasOwnProperty('url'));
+check(TextFormat.prototype.hasOwnProperty('color'));
+check(TextFormat.prototype.hasOwnProperty('size'));
+check(TextFormat.prototype.hasOwnProperty('font'));
+check(!TextFormat.prototype.hasOwnProperty('getTextExtent'));
+check(tfObj.hasOwnProperty('getTextExtent'));
+
+
+check_totals(23);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]