[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11358: framework for htmlText/text
From: |
Bob Naugle |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11358: framework for htmlText/text separation |
Date: |
Fri, 31 Jul 2009 14:59:28 -0600 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11358
committer: Bob Naugle <address@hidden>
branch nick: trunk
timestamp: Fri 2009-07-31 14:59:28 -0600
message:
framework for htmlText/text separation
modified:
libcore/TextField.cpp
libcore/TextField.h
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp 2009-07-31 19:46:51 +0000
+++ b/libcore/TextField.cpp 2009-07-31 20:59:28 +0000
@@ -122,6 +122,7 @@
InteractiveObject(parent, id),
_tag(&def),
_textDefined(def.hasText()),
+ _htmlTextDefined(def.hasText()),
_restrictDefined(false),
_underlined(false),
_bullet(false),
@@ -176,6 +177,7 @@
if (_textDefined)
{
setTextValue(utf8::decodeCanonicalString(def.defaultText(), version));
+ setHtmlTextValue(utf8::decodeCanonicalString(def.defaultText(),
version));
}
init();
@@ -187,6 +189,7 @@
// the id trick is to fool assertions in DisplayObject ctor
InteractiveObject(parent, parent ? 0 : -1),
_textDefined(false),
+ _htmlTextDefined(false),
_restrictDefined(false),
_underlined(false),
_bullet(false),
@@ -366,7 +369,7 @@
SWF::TextRecord::displayRecords(renderer, m, get_world_cxform(),
_displayRecords, _embedFonts);
- if (m_has_focus) show_cursor(renderer, wmat);
+ if (m_has_focus && !isReadOnly()) show_cursor(renderer, wmat);
clear_invalidated();
}
@@ -771,9 +774,69 @@
}
void
+TextField::updateHtmlText(const std::string& str)
+{
+ int version = getSWFVersion(*this);
+ const std::wstring& wstr = utf8::decodeCanonicalString(str, version);
+ updateHtmlText(wstr);
+}
+
+void
+TextField::updateHtmlText(const std::wstring& wstr)
+{
+ _htmlTextDefined = true;
+
+ if (_htmlText == wstr) return;
+
+ set_invalidated();
+
+ _htmlText = wstr;
+ format_text();
+}
+
+void
+TextField::setHtmlTextValue(const std::wstring& wstr)
+{
+ if (!doHtml()) {
+ updateText(wstr);
+ } else {
+ //updateText with no HTML tags
+ //for now, it is better to make the display correct
+ updateText(wstr);
+ }
+ updateHtmlText(wstr);
+
+ if ( ! _variable_name.empty() && _text_variable_registered )
+ {
+ // TODO: notify MovieClip if we have a variable name !
+ VariableRef ref = parseTextVariableRef(_variable_name);
+ as_object* tgt = ref.first;
+ if ( tgt )
+ {
+ int version = getSWFVersion(*this);
+ // we shouldn't truncate, right?
+ tgt->set_member(ref.second, utf8::encodeCanonicalString(wstr,
+ version));
+ }
+ else
+ {
+ // nothing to do (too early ?)
+ log_debug("setHtmlTextValue: variable name %s points to a
non-existent"
+ " target, I guess we would not be registered if this was "
+ "true, or the sprite we've registered our variable name "
+ "has been unloaded", _variable_name);
+ }
+ }
+}
+
+void
TextField::setTextValue(const std::wstring& wstr)
{
-
+ if (!doHtml()) {
+ updateHtmlText(wstr);
+ } else {
+ //updateHtmlText and insert necessary html tags
+ }
updateText(wstr);
if ( ! _variable_name.empty() && _text_variable_registered )
@@ -815,6 +878,14 @@
return utf8::encodeCanonicalString(_text, version);
}
+std::string
+TextField::get_htmltext_value() const
+{
+ const_cast<TextField*>(this)->registerTextVariable();
+ int version = getSWFVersion(*this);
+ return utf8::encodeCanonicalString(_htmlText, version);
+}
+
void
TextField::setTextFormat(TextFormat_as& tf)
{
@@ -3466,13 +3537,13 @@
if (!fn.nargs)
{
// Getter
- return as_value(ptr->get_text_value());
+ return as_value(ptr->get_htmltext_value());
}
// Setter
const int version = getSWFVersion(*ptr);
- ptr->setTextValue(
+ ptr->setHtmlTextValue(
utf8::decodeCanonicalString(fn.arg(0).to_string(), version));
return as_value();
=== modified file 'libcore/TextField.h'
--- a/libcore/TextField.h 2009-07-31 19:46:51 +0000
+++ b/libcore/TextField.h 2009-07-31 20:59:28 +0000
@@ -154,9 +154,14 @@
/// updated.
void updateText(const std::string& s);
+ void updateHtmlText(const std::string& s);
+
/// Return value of our text.
std::string get_text_value() const;
+ /// Return value of our htmlText.
+ std::string get_htmltext_value() const;
+
/// Return true if text is defined
bool getTextDefined() const { return _textDefined; }
@@ -537,6 +542,10 @@
///
void setTextValue(const std::wstring& wstr);
+ /// Set our htmlText to the given string.
+ //
+ void setHtmlTextValue(const std::wstring& wstr);
+
protected:
/// Mark reachable reosurces (for GC)
@@ -560,6 +569,8 @@
/// updated.
void updateText(const std::wstring& s);
+ void updateHtmlText(const std::wstring& s);
+
void insertTab(SWF::TextRecord& rec, boost::int32_t& x, float scale);
/// What happens when setFocus() is called on this TextField.
@@ -661,12 +672,18 @@
/// easier.
std::wstring _text;
+ /// The html representation of our text
+ //
+ std::wstring _htmlText;
+
/// This flag will be true as soon as the TextField
/// is assigned a text value. Only way to be false is
/// when definition has the hasText flag set to false
/// and no actionscript added text.
bool _textDefined;
+ bool _htmlTextDefined;
+
bool _restrictDefined;
/// bounds of dynamic text, as laid out
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11358: framework for htmlText/text separation,
Bob Naugle <=