gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/edit_text_character.cpp ...
Date: Thu, 10 Apr 2008 08:44:14 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  08/04/10 08:44:14

Modified files:
        .              : ChangeLog 
        server         : edit_text_character.cpp font.cpp font.h 
        server/asobj   : TextFormat.cpp TextFormat.h 
        testsuite/misc-ming.all: DefineEditTextTest.c 

Log message:
        * server/edit_text_character.cpp: add bold,italic and indent support
          in getTextFormat and setTextFormat; proxy setNewTextFormat to
          setTextFormat (still unimplemneted but at least would do something)
        * server/font.{cpp,h}: allow specifying bold and italic modifiers
          in the device-font constructor; add getters for them.
        * server/asobj/TextFormat.{cpp,h}: implement getter-setter for
          bold, italic and indent; make properties enumerable.
        * testsuite/misc-ming.all/DefineEditTextTest.c: test bold, italic
          and indent values from TextField.getTextFormat.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6234&r2=1.6235
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.165&r2=1.166
http://cvs.savannah.gnu.org/viewcvs/gnash/server/font.cpp?cvsroot=gnash&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/gnash/server/font.h?cvsroot=gnash&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/TextFormat.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/TextFormat.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DefineEditTextTest.c?cvsroot=gnash&r1=1.30&r2=1.31

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6234
retrieving revision 1.6235
diff -u -b -r1.6234 -r1.6235
--- ChangeLog   10 Apr 2008 07:24:01 -0000      1.6234
+++ ChangeLog   10 Apr 2008 08:44:12 -0000      1.6235
@@ -1,3 +1,15 @@
+2008-04-10 Sandro Santilli <address@hidden>
+
+       * server/edit_text_character.cpp: add bold,italic and indent support
+         in getTextFormat and setTextFormat; proxy setNewTextFormat to 
+         setTextFormat (still unimplemneted but at least would do something)
+       * server/font.{cpp,h}: allow specifying bold and italic modifiers
+         in the device-font constructor; add getters for them.
+       * server/asobj/TextFormat.{cpp,h}: implement getter-setter for
+         bold, italic and indent; make properties enumerable.
+       * testsuite/misc-ming.all/DefineEditTextTest.c: test bold, italic
+         and indent values from TextField.getTextFormat.
+
 2008-04-10 Benjamin Wolsey <address@hidden>
 
        * libbase/log.{cpp,h}: allow registering callback to receive

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -b -r1.165 -r1.166
--- server/edit_text_character.cpp      10 Apr 2008 00:41:07 -0000      1.165
+++ server/edit_text_character.cpp      10 Apr 2008 08:44:13 -0000      1.166
@@ -120,21 +120,6 @@
 }
 
 static as_value
-textfield_setNewTextFormat(const fn_call& fn)
-{
-       boost::intrusive_ptr<edit_text_character> text = 
ensureType<edit_text_character>(fn.this_ptr);
-       UNUSED(text);
-
-       static bool warned = false;
-       if ( ! warned ) {
-               log_unimpl("TextField.setNewTextFormat()");
-               warned = true;
-       }
-
-       return as_value();
-}
-
-static as_value
 textfield_getDepth(const fn_call& fn)
 {
        // TODO: make this a character::getDepth_method function...
@@ -193,11 +178,13 @@
        if (font)
        {
                tf->fontSet(font->get_name());
+               tf->italicedSet(font->isItalic());
+               tf->boldSet(font->isBold());
        }
 
-       // TODO: add font name, color and some more
+       // TODO: add font color and some more
 
-       ONCE( log_unimpl("TextField.getTextFormat() INCOMPLETE") );
+       ONCE( log_unimpl("TextField.getTextFormat() discards color, url, 
target, underline, blockIndent, tabStops, bullet and display") );
 
        return as_value(tf.get());
 }
@@ -253,21 +240,35 @@
        const std::string& fontName = tf->font();
        if ( ! fontName.empty() )
        {
+               bool bold = tf->bold();
+               bool italic = tf->italiced();
+
                // TODO: reuse an existing font with this name if known !
                //       Would need cleanups in the fontlib package
                //       for proper thread-safety
-               boost::intrusive_ptr<font> f ( new font(fontName) );
+               boost::intrusive_ptr<font> f ( new font(fontName, bold, italic) 
);
                text->setFont( f );
        }
 
-       // TODO: add font name, color and some more
+       // TODO: add font color and some more
 
-       ONCE( log_unimpl("TextField.setTextFormat() TESTING") );
+       ONCE( log_unimpl("TextField.setTextFormat() discards color, url, 
target, underline, blockIndent, tabStops, bullet and display") );
 
        return as_value();
 
 }
 
+static as_value
+textfield_setNewTextFormat(const fn_call& fn)
+{
+       //boost::intrusive_ptr<edit_text_character> text = 
ensureType<edit_text_character>(fn.this_ptr);
+       //UNUSED(text);
+
+       ONCE( log_unimpl("TextField.setNewTextFormat(), we'll delegate to 
setTextFormat") );
+       return textfield_setTextFormat(fn);
+
+       //return as_value();
+}
 
 static as_value
 textfield_replaceSel(const fn_call& fn)

Index: server/font.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/font.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- server/font.cpp     24 Mar 2008 00:53:51 -0000      1.61
+++ server/font.cpp     10 Apr 2008 08:44:13 -0000      1.62
@@ -78,7 +78,7 @@
        {
        }
 
-       font::font(const std::string& name)
+       font::font(const std::string& name, bool bold, bool italic)
                :
                m_name(name),
                 m_display_name(),
@@ -87,8 +87,8 @@
                m_unicode_chars(false),
                m_shift_jis_chars(false),
                m_ansi_chars(true),
-               m_is_italic(false),
-               m_is_bold(false),
+               m_is_italic(italic),
+               m_is_bold(bold),
                m_wide_codes(false),
                m_subpixel_font(false),
                m_ascent(0.0f),
@@ -101,6 +101,10 @@
                {
                        log_error(_("Could not initialize device font face 
'%s'"), m_name.c_str());
                }
+               else
+               {
+                       log_debug("Initialized device font face '%s'%s%s", 
m_name, bold ? " bold" : "", italic ? " italic" : "");
+               }
        }
 
        font::~font()

Index: server/font.h
===================================================================
RCS file: /sources/gnash/gnash/server/font.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- server/font.h       27 Mar 2008 10:50:14 -0000      1.36
+++ server/font.h       10 Apr 2008 08:44:14 -0000      1.37
@@ -111,8 +111,18 @@
 public:
        font();
 
-       // Create a device-font only font, using the given name to find it
-       font(const std::string& name);
+       /// Create a device-font only font, using the given name to find it
+       //
+       /// @param name
+       ///     Name of the font face to look for.
+       ///
+       /// @param bold
+       ///     Whether to use the bold variant of the font.
+       ///
+       /// @param italic
+       ///     Whether to use the italic variant of the font.
+       ///
+       font(const std::string& name, bool bold=false, bool italic=false);
 
        ~font();
 
@@ -232,6 +242,9 @@
 
        bool    is_subpixel_font() const { return m_subpixel_font; }
        void    set_subpixel_font(bool isit) { m_subpixel_font = isit; }
+
+       bool    isBold() const { return m_is_bold; }
+       bool    isItalic() const { return m_is_italic; }
 private:
 
        /// Read the table that maps from glyph indices to character codes.

Index: server/asobj/TextFormat.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/TextFormat.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/TextFormat.cpp 10 Apr 2008 00:41:08 -0000      1.4
+++ server/asobj/TextFormat.cpp 10 Apr 2008 08:44:14 -0000      1.5
@@ -51,7 +51,7 @@
        _right_margin(-1),
        _point_size(-1),
        _tab_stops(-1),
-       _target(-1)
+       _target()
 {
        //log_debug("%s:", __FUNCTION__);
        init_member("getTextExtent", new 
builtin_function(TextFormat::getTextExtent_method));
@@ -59,15 +59,27 @@
 
 /// new TextFormat([font, [size, [color, [bold, [italic, [underline, [url, 
[target, [align,[leftMargin, [rightMargin, [indent, [leading]]]]]]]]]]]]])
 static as_value
-textformat_new(const fn_call& /* fn */)
+textformat_new(const fn_call& fn)
 {
   //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..
+       boost::intrusive_ptr<TextFormat> tf = new TextFormat;
+       if ( fn.nargs > 0  ) {  tf->fontSet(fn.arg(0).to_string());
+       if ( fn.nargs > 1  ) {  tf->sizeSet(fn.arg(1).to_int());
+       if ( fn.nargs > 2  ) {  tf->colorSet(fn.arg(2).to_int()); // TODO: 
check this...
+       if ( fn.nargs > 3  ) {  tf->boldSet(fn.arg(3).to_bool()); 
+       if ( fn.nargs > 4  ) {  tf->italicedSet(fn.arg(4).to_bool()); 
+       if ( fn.nargs > 5  ) {  tf->underlinedSet(fn.arg(5).to_bool()); 
+       if ( fn.nargs > 6  ) {  tf->urlSet(fn.arg(6).to_string()); 
+       if ( fn.nargs > 7  ) {  tf->targetSet(fn.arg(7).to_string()); 
+       if ( fn.nargs > 8  ) {  ONCE(log_unimpl("align parameter in TextFormat 
constructor")); // ltf->alignSet(fn.arg(8).to_string()); 
+       if ( fn.nargs > 9  ) {  tf->leftMarginSet(fn.arg(9).to_int());
+       if ( fn.nargs > 10 ) {  tf->rightMarginSet(fn.arg(10).to_int());
+       if ( fn.nargs > 11 ) {  tf->indentSet(fn.arg(11).to_int());
+       if ( fn.nargs > 12 ) {  tf->leadingSet(fn.arg(12).to_int());
+       }}}}}}}}}}}}}
   
-  return as_value(text_obj.get());
+       return as_value(tf.get());
 }
 
 as_value
@@ -106,9 +118,19 @@
 }
 
 as_value
-TextFormat::indent_getset(const fn_call& /*fn*/)
+TextFormat::indent_getset(const fn_call& fn)
 {
-       ONCE( log_unimpl("TextField.indent") );
+       boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
+
+       if ( fn.nargs == 0 ) // getter
+       {
+               return as_value(TWIPS_TO_PIXELS(ptr->indent()));
+       }
+       else // setter
+       {
+               ptr->indentSet(PIXELS_TO_TWIPS(fn.arg(0).to_int()));
+       }
+
        return as_value();
 }
 
@@ -141,16 +163,36 @@
 }
 
 as_value
-TextFormat::italic_getset(const fn_call& /*fn*/)
+TextFormat::italic_getset(const fn_call& fn)
 {
-       ONCE( log_unimpl("TextField.italic") );
+       boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
+
+       if ( fn.nargs == 0 ) // getter
+       {
+               return as_value(ptr->italiced());
+       }
+       else // setter
+       {
+               ptr->italicedSet(fn.arg(0).to_bool());
+       }
+
        return as_value();
 }
 
 as_value
-TextFormat::bold_getset(const fn_call& /*fn*/)
+TextFormat::bold_getset(const fn_call& fn)
 {
-       ONCE( log_unimpl("TextField.bold") );
+       boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
+
+       if ( fn.nargs == 0 ) // getter
+       {
+               return as_value(ptr->bold());
+       }
+       else // setter
+       {
+               ptr->boldSet(fn.arg(0).to_bool());
+       }
+
        return as_value();
 }
 
@@ -221,25 +263,25 @@
 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_property("size", &TextFormat::size_getset, 
&TextFormat::size_getset);
+       int flags = 0; // for sure we want to enum, dunno about deleting yet
 
-       o.init_property("font", &TextFormat::font_getset, 
&TextFormat::font_getset);
+       o.init_property("display", &TextFormat::display_getset, 
&TextFormat::display_getset, flags);
+       o.init_property("bullet", &TextFormat::bullet_getset, 
&TextFormat::bullet_getset, flags);
+       o.init_property("tabStops", &TextFormat::tabStops_getset, 
&TextFormat::tabStops_getset, flags);
+       o.init_property("blockIndent", &TextFormat::blockIndent_getset, 
&TextFormat::blockIndent_getset, flags);
+       o.init_property("leading", &TextFormat::leading_getset, 
&TextFormat::leading_getset, flags);
+       o.init_property("indent", &TextFormat::indent_getset, 
&TextFormat::indent_getset, flags);
+       o.init_property("rightMargin", &TextFormat::rightMargin_getset, 
&TextFormat::rightMargin_getset, flags);
+       o.init_property("leftMargin", &TextFormat::leftMargin_getset, 
&TextFormat::leftMargin_getset, flags);
+       o.init_property("align", &TextFormat::align_getset, 
&TextFormat::align_getset, flags);
+       o.init_property("underline", &TextFormat::underline_getset, 
&TextFormat::underline_getset, flags);
+       o.init_property("italic", &TextFormat::italic_getset, 
&TextFormat::italic_getset, flags);
+       o.init_property("bold", &TextFormat::bold_getset, 
&TextFormat::bold_getset, flags);
+       o.init_property("target", &TextFormat::target_getset, 
&TextFormat::target_getset, flags);
+       o.init_property("url", &TextFormat::url_getset, 
&TextFormat::url_getset, flags);
+       o.init_property("color", &TextFormat::color_getset, 
&TextFormat::color_getset, flags);
+       o.init_property("size", &TextFormat::size_getset, 
&TextFormat::size_getset, flags);
+       o.init_property("font", &TextFormat::font_getset, 
&TextFormat::font_getset, flags);
 }
 
 static as_object*

Index: server/asobj/TextFormat.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/TextFormat.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- server/asobj/TextFormat.h   10 Apr 2008 00:41:08 -0000      1.4
+++ server/asobj/TextFormat.h   10 Apr 2008 08:44:14 -0000      1.5
@@ -75,6 +75,18 @@
        /// Return the name of a font for text as a string.
        const std::string& font() const { return _font; }
 
+       // See doc for _target member
+       const std::string& target() const { return _target; }
+
+       // See doc for _target member
+       void targetSet(const std::string& s) { _target=s; }
+
+       // See doc for _url member
+       const std::string& url() const { return _url; }
+
+       // See doc for _url member
+       void urlSet(const std::string& s) { _url=s; }
+
        ///
        boost::uint16_t blockIndent() { return _block_indent; }
 
@@ -189,7 +201,7 @@
         /// 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;
+       std::string     _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

Index: testsuite/misc-ming.all/DefineEditTextTest.c
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/DefineEditTextTest.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- testsuite/misc-ming.all/DefineEditTextTest.c        10 Apr 2008 00:41:08 
-0000      1.30
+++ testsuite/misc-ming.all/DefineEditTextTest.c        10 Apr 2008 08:44:14 
-0000      1.31
@@ -252,12 +252,28 @@
                   "dtext2.text += ' world';" );
 
   // TextFormat objects are created on the fly
-  check_equals(mo, "typeof(etext1.getTextFormat())", "'object'"); 
-  check_equals(mo, "typeof(dtext2.getTextFormat())", "'object'"); 
-  check_equals(mo, "etext1.getTextFormat().size", "12"); 
-  check_equals(mo, "dtext2.getTextFormat().size", "12"); 
-  check_equals(mo, "etext1.getTextFormat().font", "'Bitstream Vera Sans'");
-  check_equals(mo, "dtext2.getTextFormat().font", "'times'"); 
+  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", "0");
+  check_equals(mo, "dtext2.tf.indent", "0"); 
 
   check_equals(mo, "dtext1.text", "'Hello world'");
   check_equals(mo, "etext1.text", "'Hello world'");




reply via email to

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