gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ChangeLog server/asobj/TextFormat.cpp ser...


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/asobj/TextFormat.cpp ser...
Date: Thu, 10 Apr 2008 09:35:34 +0000

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

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

Log message:
        * server/asobj/TextFormat.{cpp,h}: implement align getter-setter
        * testsuite/misc-ming.all/DefineEditTextTest.c: test align.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6236&r2=1.6237
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/TextFormat.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/TextFormat.h?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/misc-ming.all/DefineEditTextTest.c?cvsroot=gnash&r1=1.32&r2=1.33

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6236
retrieving revision 1.6237
diff -u -b -r1.6236 -r1.6237
--- ChangeLog   10 Apr 2008 09:04:32 -0000      1.6236
+++ ChangeLog   10 Apr 2008 09:35:33 -0000      1.6237
@@ -1,5 +1,10 @@
 2008-04-10 Sandro Santilli <address@hidden>
 
+       * server/asobj/TextFormat.{cpp,h}: implement align getter-setter
+       * testsuite/misc-ming.all/DefineEditTextTest.c: test align.
+
+2008-04-10 Sandro Santilli <address@hidden>
+
        * server/asobj/TextFormat.cpp: implement leftMargin and rightMargin
          getter-setters.
        * testsuite/misc-ming.all/DefineEditTextTest.c: test leftMargin and

Index: server/asobj/TextFormat.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/TextFormat.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/asobj/TextFormat.cpp 10 Apr 2008 09:04:32 -0000      1.6
+++ server/asobj/TextFormat.cpp 10 Apr 2008 09:35:34 -0000      1.7
@@ -26,6 +26,7 @@
 #include "namedStrings.h"
 #include "VM.h"
 #include "server/types.h" // for PIXELS_TO_TWIPS
+#include "StringPredicates.h" // for parseAlignString
 
 #define ONCE(x) { static bool warned=false; if (!warned) { warned=true; x; } }
 
@@ -72,7 +73,7 @@
        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 > 8  ) {  tf->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());
@@ -169,9 +170,19 @@
 }
 
 as_value
-TextFormat::align_getset(const fn_call& /*fn*/)
+TextFormat::align_getset(const fn_call& fn)
 {
-       ONCE( log_unimpl("TextField.align") );
+       boost::intrusive_ptr<TextFormat> ptr = 
ensureType<TextFormat>(fn.this_ptr);
+
+       if ( fn.nargs == 0 ) // getter
+       {
+               return as_value(ptr->getAlignString(ptr->align()));
+       }
+       else // setter
+       {
+               ptr->alignSet(fn.arg(0).to_string());
+       }
+
        return as_value();
 }
 
@@ -332,4 +343,39 @@
 
 }
 
+edit_text_character_def::alignment
+TextFormat::parseAlignString(const std::string& align)
+{
+       StringNoCaseEqual cmp;
+       if ( cmp(align, "right") ) return edit_text_character_def::ALIGN_RIGHT;
+       else if ( cmp(align, "center") ) return 
edit_text_character_def::ALIGN_CENTER;
+       else if ( cmp(align, "right") ) return 
edit_text_character_def::ALIGN_RIGHT;
+       else if ( cmp(align, "justify") ) return 
edit_text_character_def::ALIGN_JUSTIFY;
+       else
+       {
+               log_debug("Invalid align string %s, take as left", align);
+               return edit_text_character_def::ALIGN_JUSTIFY;
+       }
+}
+
+const char* 
+TextFormat::getAlignString(edit_text_character_def::alignment a)
+{
+       switch (a)
+       {
+               case edit_text_character_def::ALIGN_LEFT:
+                       return "left";
+               case edit_text_character_def::ALIGN_CENTER:
+                       return "center";
+               case edit_text_character_def::ALIGN_RIGHT:
+                       return "right";
+               case edit_text_character_def::ALIGN_JUSTIFY:
+                       return "justify";
+               default:
+                       log_error("Uknown alignment value: %d, take as left", 
a);
+                       return "left";
+       }
+}
+
+
 } // end of gnash namespace

Index: server/asobj/TextFormat.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/TextFormat.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/asobj/TextFormat.h   10 Apr 2008 08:44:14 -0000      1.5
+++ server/asobj/TextFormat.h   10 Apr 2008 09:35:34 -0000      1.6
@@ -113,6 +113,12 @@
 
        void alignSet(edit_text_character_def::alignment x)  { _align = x; }
 
+       static edit_text_character_def::alignment parseAlignString(const 
std::string& align);
+
+       static const char* getAlignString(edit_text_character_def::alignment a);
+
+       void alignSet(const std::string& align) { 
alignSet(parseAlignString(align)); }
+
        void blockIndentSet(boost::uint16_t x)   { _block_indent = x; }
        void leadingSet(boost::uint16_t x)     { _leading = x; }
        void leftMarginSet(boost::uint16_t x)  { _left_margin = x; }

Index: testsuite/misc-ming.all/DefineEditTextTest.c
===================================================================
RCS file: /sources/gnash/gnash/testsuite/misc-ming.all/DefineEditTextTest.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- testsuite/misc-ming.all/DefineEditTextTest.c        10 Apr 2008 09:04:33 
-0000      1.32
+++ testsuite/misc-ming.all/DefineEditTextTest.c        10 Apr 2008 09:35:34 
-0000      1.33
@@ -38,10 +38,10 @@
 #define OUTPUT_VERSION 7
 #define OUTPUT_FILENAME "DefineEditTextTest.swf"
 
-SWFDisplayItem add_text_field(SWFMovie mo, SWFBlock font, const char* text, 
float indent, float leftMargin, float rightMargin);
+SWFDisplayItem add_text_field(SWFMovie mo, SWFBlock font, const char* text, 
float indent, float leftMargin, float rightMargin, SWFTextFieldAlignment align);
 
 SWFDisplayItem
-add_text_field(SWFMovie mo, SWFBlock font, const char* text, float indent, 
float leftMargin, float rightMargin)
+add_text_field(SWFMovie mo, SWFBlock font, const char* text, float indent, 
float leftMargin, float rightMargin, SWFTextFieldAlignment align)
 {
   SWFTextField tf;
 
@@ -51,6 +51,7 @@
   SWFTextField_setIndentation(tf, indent);
   SWFTextField_setLeftMargin(tf, leftMargin);
   SWFTextField_setRightMargin(tf, rightMargin);
+  SWFTextField_setAlignment(tf, align);
 
   /* setting flags seem unneeded */
   /*SWFTextField_setFlags(tf, SWFTEXTFIELD_USEFONT|SWFTEXTFIELD_NOEDIT);*/
@@ -146,15 +147,15 @@
     SWFBrowserFont bfont = newSWFBrowserFont("_sans");
     SWFFont efont = loadSWFFontFromFile(font_file);
 
-    it = add_text_field(mo, (SWFBlock)bfont, "Hello", 1, 2, 3);
+    it = add_text_field(mo, (SWFBlock)bfont, "Hello", 1, 2, 3, 
SWFTEXTFIELD_ALIGN_LEFT);
     SWFDisplayItem_setName(it, "dtext1");
     SWFDisplayItem_moveTo(it, 0, 200);
-    it = add_text_field(mo, (SWFBlock)efont, "Hello", 4, 5, 6);
+    it = add_text_field(mo, (SWFBlock)efont, "Hello", 4, 5, 6, 
SWFTEXTFIELD_ALIGN_CENTER);
     SWFDisplayItem_setName(it, "etext1");
     SWFDisplayItem_moveTo(it, 0, 300);
 
     SWFBrowserFont bfont2 = newSWFBrowserFont("times");
-    it = add_text_field(mo, (SWFBlock)bfont2, "Hello", 7, 8, 9);
+    it = add_text_field(mo, (SWFBlock)bfont2, "Hello", 7, 8, 9, 
SWFTEXTFIELD_ALIGN_RIGHT);
     SWFDisplayItem_setName(it, "dtext2");
     SWFDisplayItem_moveTo(it, 0, 400);
   }
@@ -285,6 +286,10 @@
   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, "dtext1.text", "'Hello world'");
   check_equals(mo, "etext1.text", "'Hello world'");




reply via email to

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