[Top][All Lists]
[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: |
Sun, 24 Sep 2006 20:17:04 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 06/09/24 20:17:04
Modified files:
. : ChangeLog
server : edit_text_character.cpp edit_text_character.h
Log message:
* server/edit_text_character.{h,cpp}: added private
registerTextVariable() method to handle variablenames.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.910&r2=1.911
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.cpp?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/server/edit_text_character.h?cvsroot=gnash&r1=1.10&r2=1.11
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.910
retrieving revision 1.911
diff -u -b -r1.910 -r1.911
--- ChangeLog 24 Sep 2006 18:57:03 -0000 1.910
+++ ChangeLog 24 Sep 2006 20:17:03 -0000 1.911
@@ -1,3 +1,8 @@
+2006-09-24 Sandro Santilli <address@hidden>
+
+ * server/edit_text_character.{h,cpp}: added private
+ registerTextVariable() method to handle variablenames.
+
2006-09-24 Markus Gothe <address@hidden>
* libbase/ogl.cpp: Removed unsed TU-file.
Index: server/edit_text_character.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/edit_text_character.cpp 21 Sep 2006 14:22:49 -0000 1.14
+++ server/edit_text_character.cpp 24 Sep 2006 20:17:04 -0000 1.15
@@ -35,6 +35,9 @@
// WARNING! remember to set the font *before* setting text value!
set_font( m_def->get_font() );
+ // set default text *before* calling registerTextVariable
+ // (if the textvariable already exist and has a value
+ // the text will be replaced with it)
set_text_value(m_def->get_default_text().c_str());
m_dummy_style.push_back(fill_style());
@@ -44,51 +47,12 @@
// member, handle it by adding the textfield_variable
// to the appropriate sprite
//
- const char* varname = m_def->get_variable_name().c_str();
- if ( *varname )
+ const std::string& varname = m_def->get_variable_name();
+ if ( ! varname.empty() )
{
- // add a text variable to the sprite
-
- assert(dynamic_cast<sprite_instance*>(parent));
- sprite_instance* sprite = static_cast<sprite_instance*>(parent);
-
- // If the variable name can contain path information,
- // in which case
- tu_string path, var;
- if ( as_environment::parse_path(varname, path, var) )
- {
- // contains path info
- character* tgt_char =
sprite->get_environment().find_target(path);
- assert(dynamic_cast<sprite_instance*>(tgt_char));
- sprite = static_cast<sprite_instance*>(tgt_char);
- varname = var.c_str();
+ registerTextVariable(varname);
}
- // check if the VariableName already has a value,
- // in that case update text value
- as_value val;
- if ( sprite->get_member(tu_stringi(varname), &val) )
- {
-#ifdef DEBUG_DYNTEXT_VARIABLES
-log_msg("target sprite (%p) does have a member named %s", (void*)sprite,
varname);
-#endif
- set_text_value(val.to_string());
- }
-#ifdef DEBUG_DYNTEXT_VARIABLES
- else
- {
-log_msg("target sprite (%p) does NOT have a member named %s", (void*)sprite,
varname);
- }
-#endif
-
- // add this text variable to the target sprite
- sprite->set_textfield_variable(varname, this);
-
- //log_warning("EditTextCharacter VariableName support TESTING");
-
- }
-
-
reset_bounding_box(0, 0);
}
@@ -824,6 +788,57 @@
}
+void
+edit_text_character::registerTextVariable(const std::string& var_str)
+{
+ assert ( ! var_str.empty() );
+
+ const char* varname = var_str.c_str();
+
+ // Default target is our parent
+ character* parent = get_parent();
+ assert(dynamic_cast<sprite_instance*>(parent));
+ sprite_instance* sprite = static_cast<sprite_instance*>(parent);
+
+ // If the variable string contains a path, we extract
+ // the appropriate target from it.
+
+ tu_string path, var;
+ if ( as_environment::parse_path(varname, path, var) )
+ {
+ // find target for the path component
+ // we use our parent's environment for this
+ character* tgt_char =
sprite->get_environment().find_target(path);
+ assert(dynamic_cast<sprite_instance*>(tgt_char));
+ sprite = static_cast<sprite_instance*>(tgt_char);
+
+ // update varname (with path component stripped)
+ varname = var.c_str();
+ }
+
+
+ // check if the VariableName already has a value,
+ // in that case update text value
+ as_value val;
+ if ( sprite->get_member(tu_stringi(varname), &val) )
+ {
+#ifdef DEBUG_DYNTEXT_VARIABLES
+log_msg("target sprite (%p) does have a member named %s", (void*)sprite,
varname);
+#endif
+ set_text_value(val.to_string());
+ }
+#ifdef DEBUG_DYNTEXT_VARIABLES
+ else
+ {
+log_msg("target sprite (%p) does NOT have a member named %s", (void*)sprite,
varname);
+ }
+#endif
+
+ // add the textfield variable to the target sprite
+ sprite->set_textfield_variable(varname, this);
+
+}
+
} // namespace gnash
Index: server/edit_text_character.h
===================================================================
RCS file: /sources/gnash/gnash/server/edit_text_character.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/edit_text_character.h 21 Sep 2006 10:18:37 -0000 1.10
+++ server/edit_text_character.h 24 Sep 2006 20:17:04 -0000 1.11
@@ -147,6 +147,22 @@
float m_xcursor;
float m_ycursor;
+ /// Associate a variable to the text of this character
+ //
+ /// Setting the associated variable actually changes the
+ /// displayed text. Getting the variable would return the
+ /// displayed text.
+ ///
+ /// If the given variable already exist use it to set
+ /// current text before overriding it.
+ ///
+ /// @param varname
+ /// Name of the variable. Can contain path information,
+ /// in that case the path is resolved relative to this
+ /// character's parent.
+ ///
+ void registerTextVariable(const std::string& varname);
+
};
} // namespace gnash