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: Wed, 29 Nov 2006 10:48:34 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  06/11/29 10:48:34

Modified files:
        .              : ChangeLog 
        server         : edit_text_character.cpp edit_text_character.h 

Log message:
                * server/edit_text_character.{cpp,h}:
                  Allow programmatically setting a TextField's
                  variable name.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.1815&r2=1.1816
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.18&r2=1.19

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.1815
retrieving revision 1.1816
diff -u -b -r1.1815 -r1.1816
--- ChangeLog   29 Nov 2006 09:44:31 -0000      1.1815
+++ ChangeLog   29 Nov 2006 10:48:33 -0000      1.1816
@@ -1,5 +1,11 @@
 2006-11-29 Sandro Santilli <address@hidden>
 
+       * server/edit_text_character.{cpp,h}:
+         Allow programmatically setting a TextField's
+         variable name.
+
+2006-11-29 Sandro Santilli <address@hidden>
+
        * server/edit_text_character.cpp: properly set
          TextField interface (to finish); implement 'variable'
          propery.

Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- server/edit_text_character.cpp      29 Nov 2006 10:15:44 -0000      1.35
+++ server/edit_text_character.cpp      29 Nov 2006 10:48:33 -0000      1.36
@@ -15,7 +15,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 
-/* $Id: edit_text_character.cpp,v 1.35 2006/11/29 10:15:44 strk Exp $ */
+/* $Id: edit_text_character.cpp,v 1.36 2006/11/29 10:48:33 strk Exp $ */
 
 #include "utf8.h"
 #include "log.h"
@@ -51,10 +51,16 @@
 }
 
 static void
-textfield_set_variable(const fn_call& /*fn*/)
+textfield_set_variable(const fn_call& fn)
 {
-       log_warning("TextField.variable property is read-only "
-               " (might be a Gnash bug really)");
+       assert( dynamic_cast<edit_text_character*>(fn.this_ptr) );
+       edit_text_character* text = 
static_cast<edit_text_character*>(fn.this_ptr);
+
+       assert ( fn.nargs > 0 );
+       std::string newname = fn.arg(0).to_std_string();
+
+       text->set_variable_name(newname);
+
        return;
 }
 
@@ -120,7 +126,8 @@
        m_cursor(0),
        m_xcursor(0.0f),
        m_ycursor(0.0f),
-       _text_variable_registered(false)
+       _text_variable_registered(false),
+       _variable_name(m_def->get_variable_name())
 {
        assert(parent);
        assert(m_def);
@@ -952,7 +959,7 @@
                return;
        }
 
-       const std::string& var_str = m_def->get_variable_name();
+       const std::string& var_str = _variable_name;
 
        if ( var_str.empty() )
        {
@@ -1051,6 +1058,16 @@
        return 0;
 }
 
+void
+edit_text_character::set_variable_name(const std::string& newname)
+{
+       if ( newname != _variable_name )
+       {
+               _variable_name = newname;
+               _text_variable_registered = false;
+       }
+}
+
 } // namespace gnash
 
 

Index: server/edit_text_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- server/edit_text_character.h        21 Nov 2006 00:25:46 -0000      1.18
+++ server/edit_text_character.h        29 Nov 2006 10:48:33 -0000      1.19
@@ -54,11 +54,19 @@
        virtual character* get_topmost_mouse_entity(float x, float y);  
        virtual bool on_event(const event_id& id);      
 
-       virtual const char* get_variable_name() const
+       const char* get_variable_name() const
        {
-               return m_def->get_variable_name().c_str();
+               return _variable_name.c_str();
        }
 
+       /// Set the name of a variable associated to this
+       /// TextField's displayed text.
+       //
+       /// Calling this function will override any previous
+       /// setting for the variable name.
+       /// 
+       void set_variable_name(const std::string& newname);
+
        /// Set our text to the given string.
        virtual void    set_text_value(const char* new_text);
 
@@ -154,6 +162,13 @@
        ///
        bool _text_variable_registered;
 
+       /// The text variable name
+       //
+       /// This is stored here, and not just in the definition,
+       /// because it can be changed programmatically, by setting
+       /// 'TextFields.variable'
+       std::string _variable_name;
+
 };
 
 } // namespace gnash




reply via email to

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