[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r11331: Implemented tabStops and mul
From: |
Sharad Desai |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r11331: Implemented tabStops and multiline property in TextField, and some html tags |
Date: |
Wed, 29 Jul 2009 11:24:10 -0600 |
User-agent: |
Bazaar (1.13.1) |
------------------------------------------------------------
revno: 11331
committer: Sharad Desai <address@hidden>
branch nick: trunk
timestamp: Wed 2009-07-29 11:24:10 -0600
message:
Implemented tabStops and multiline property in TextField, and some html tags
modified:
libcore/TextField.cpp
libcore/TextField.h
libcore/asobj/TextFormat_as.cpp
testsuite/misc-haxe.all/classes.all/text/TextFormat_as.hx
------------------------------------------------------------
revno: 11329.1.1
committer: Sharad Desai <address@hidden>
branch nick: desai_Jul24
timestamp: Wed 2009-07-29 11:19:47 -0600
message:
Implemented tabStops and multiline property in TextField, and some html
tags
modified:
libcore/TextField.cpp
libcore/TextField.h
libcore/asobj/TextFormat_as.cpp
testsuite/misc-haxe.all/classes.all/text/TextFormat_as.hx
=== modified file 'libcore/TextField.cpp'
--- a/libcore/TextField.cpp 2009-07-28 09:23:14 +0000
+++ b/libcore/TextField.cpp 2009-07-29 17:19:47 +0000
@@ -57,6 +57,7 @@
// Text fields have a fixed 2 pixel padding for each side (regardless of
border)
#define PADDING_TWIPS 40
+#define PIXEL_RATIO 20
// Define the following to get detailed log information about
// textfield bounds and HTML tags:
@@ -1009,34 +1010,42 @@
rec.getFont()->name());
);
}
- //~ else
- //~ {
- //~ std::vector<int> tabStops;
- //~ tabStops = _tabStops;
- //~
- //~ std::sort(_tabStops.begin(), _tabStops.end());
-//~
- //~ int tab = 0;
- //~ if ( !_tabStops.empty() )
- //~ {
- //~ tab = _tabStops.back();
- //~
- //~ for (int i = 0; i < tabStops.size(); ++i)
- //~ {
- //~ if (tabStops[i] > x)
- //~ {
- //~ if((tabStops[i] - x) < tab)
- //~ {
- //~ tab = tabStops[i] - x;
- //~ }
- //~ }
- //~ SWF::TextRecord::GlyphEntry ge;
- //~ ge.index = index;
- //~ ge.advance = scale * tab;
- //~ rec.addGlyph(ge);
- //~ x+=ge.advance;
- //~ }
- //~ }
+ else
+ {
+ std::vector<int> tabStops;
+ tabStops = _tabStops;
+
+ std::sort(_tabStops.begin(), _tabStops.end());
+
+ int tab = 0;
+ if ( !_tabStops.empty() )
+ {
+ tab = _tabStops.back()+1;
+
+ for (int i = 0; i < tabStops.size(); ++i)
+ {
+ if (tabStops[i] > x)
+ {
+ if((tabStops[i] - x) < tab)
+ {
+ tab = tabStops[i] - x;
+ }
+ }
+
+ }
+
+ // This is necessary in case the number of tabs in the
text
+ // are more than the actual number of tabStops inside
the
+ // vector
+ if ( !(tab == _tabStops.back()+1) ) {
+ SWF::TextRecord::GlyphEntry ge;
+ ge.index = rec.getFont()->get_glyph_index(32,
_embedFonts);
+ ge.advance = tab;
+ rec.addGlyph(ge);
+ x+=ge.advance;
+ }
+
+ }
else
{
SWF::TextRecord::GlyphEntry ge;
@@ -1044,11 +1053,11 @@
ge.advance = scale * rec.getFont()->get_advance(index,
_embedFonts);
- const int tabstop = 8;
+ const int tabstop = 4;
rec.addGlyph(ge, tabstop);
x += ge.advance * tabstop;
}
- //}
+ }
}
void
@@ -1138,7 +1147,7 @@
SWF::TextRecord::GlyphEntry ge;
ge.index = space;
ge.advance = scale * rec.getFont()->get_advance(space, _embedFonts);
- rec.addGlyph(ge, 10);
+ rec.addGlyph(ge, 5);
// We use an asterisk instead of a bullet
int bullet = rec.getFont()->get_glyph_index(42, _embedFonts);
@@ -1149,7 +1158,7 @@
space = rec.getFont()->get_glyph_index(32, _embedFonts);
ge.index = space;
ge.advance = scale * rec.getFont()->get_advance(space, _embedFonts);
- rec.addGlyph(ge, 9);
+ rec.addGlyph(ge, 4);
}
boost::int32_t x = static_cast<boost::int32_t>(rec.xOffset());
@@ -1278,9 +1287,10 @@
void
TextField::newLine(std::wstring::const_iterator& it, boost::int32_t& x,
boost::int32_t& y, SWF::TextRecord& rec, int& last_space_glyph,
- LineStarts::value_type& last_line_start_record, float div)
+ LineStarts::value_type& last_line_start_record, float div,
+ bool bullet)
{
-
+ _bullet = bullet;
// newline.
LineStarts::iterator linestartit = _line_starts.begin();
LineStarts::const_iterator linestartend = _line_starts.end();
@@ -1340,7 +1350,7 @@
ge.index = space;
ge.advance = scale * rec.getFont()->get_advance(space, _embedFonts);
- rec.addGlyph(ge,10);
+ rec.addGlyph(ge,5);
int bullet = rec.getFont()->get_glyph_index(42, _embedFonts);
ge.index = bullet;
@@ -1350,7 +1360,7 @@
ge.index = space;
ge.advance = scale * rec.getFont()->get_advance(space, _embedFonts);
- rec.addGlyph(ge,9);
+ rec.addGlyph(ge,4);
}
}
@@ -1420,7 +1430,8 @@
case 13:
case 10:
{
-
newLine(it,x,y,rec,last_space_glyph,last_line_start_record,1.0);
+ newLine(it,x,y,rec,last_space_glyph,last_line_start_record,1.0,
+ false);
break;
}
case '<':
@@ -1492,8 +1503,6 @@
} else if (s == "li") {
//list item (bullet)
log_unimpl("<li> html tag in TextField");
- handleChar(it, e, x, y, newrec, last_code,
- last_space_glyph, last_line_start_record);
} else if (s == "span") {
//span
log_unimpl("<span> html tag in TextField");
@@ -1510,12 +1519,12 @@
if (_display == BLOCK)
{
newLine(it, x, y, rec, last_space_glyph,
- last_line_start_record, 1.5);
+ last_line_start_record, 1.5,false);
handleChar(it, e, x, y, newrec, last_code,
last_space_glyph,
last_line_start_record);
newLine(it, x, y, rec, last_space_glyph,
- last_line_start_record, 1.0);
+ last_line_start_record, 1.0,false);
}
else
{
@@ -1525,7 +1534,8 @@
}
} else if (s == "br") {
//line break
- log_unimpl("<br> html tag in TextField");
+ newLine(it, x, y, rec,
last_space_glyph,
+
last_line_start_record, 1.0,false);
} else {
log_debug("<%s> tag is unsupported", s);
// THIS IS DANGEROUS. IF TAG HAS NO CLOSING TAG,
@@ -2168,7 +2178,12 @@
void
TextField::setTabStops(const std::vector<int>& tabStops)
{
- _tabStops = tabStops;
+ _tabStops.resize(tabStops.size());
+ for (int i = 0; i < tabStops.size(); i ++)
+ {
+ _tabStops[i] = PIXEL_RATIO * tabStops[i];
+ }
+
format_text();
set_invalidated();
}
@@ -2928,51 +2943,10 @@
if ( tf->colorDefined() ) text->setTextColor(tf->color());
if ( tf->underlinedDefined() ) text->setUnderlined(tf->underlined());
- LOG_ONCE( log_unimpl("tf->target(): %s ", tf->target()) );
- LOG_ONCE( log_unimpl("tf->display(): %s", tf->display()) );
- LOG_ONCE( log_unimpl("tf->url(): %s", tf->url()) );
-
// ADDED (completed)
if ( tf->bulletDefined() ) text->setBullet(tf->bullet());
if ( tf->displayDefined() ) text->setDisplay(tf->display());
-
- // URL CASE:
- if ( tf->urlDefined() )
- {
- //~ RcInitFile& rc = RcInitFile::getDefaultInstance();
- //~ rc.setURLOpenerFormat("firefox -remote 'openurl(%u)'");
- //~ std::string getUrl = rc.getURLOpenerFormat();
- //~ system("firefox -remote 'openurl(http://www.gnashdev.org)'");
- //~ LOG_ONCE( log_unimpl("getUrl: %s ", getUrl) );
- //~ rgba color = rgba(0, 0, 255, 255);
- //~ text->setTextColor(color);
- //~ text->setUnderlined(true);
-
- // TARGET CASE:
- // gets correct _target...need to implement
- if (tf->targetDefined() )
- {
- //~ if (tf->target()=="_blank")
- //~ system("firefox -remote 'openurl(http://www.blank.org)'");
- //~ else if (tf->target()=="_self") {
- //~ system("firefox -remote 'openurl(http://www.msn.com'");
- //~ }
- //~ else if (tf->target()=="_parent") {
- //~ system("firefox -remote 'openurl(http://www.parent.com'");
- //~ }
- //~ else if (tf->target()=="_top") {
- //~ system("firefox -remote 'openurl(http://www.top.com'");
- //~ }
- }
- }
-
- // TABSTOPS CASE:
- // gets correct _tabStops...need to implement
- if ( tf->tabStopsDefined() )
- {
- text->setTabStops(tf->tabStops());
- }
-
+ if ( tf->tabStopsDefined() ) text->setTabStops(tf->tabStops());
if (isAS3(fn)) {
// TODO: current font finding assumes we have a parent, which isn't
@@ -3003,8 +2977,7 @@
// TODO: add font color and some more
- LOG_ONCE( log_unimpl("TextField.setTextFormat() discards url, target and "
- "tabStops") );
+ LOG_ONCE( log_unimpl("TextField.setTextFormat() discards url and target")
);
return as_value();
@@ -3045,7 +3018,7 @@
{
boost::intrusive_ptr<TextField> text = ensureType<TextField>(fn.this_ptr);
- LOG_ONCE(log_unimpl("TextField.multiline"));
+ //LOG_ONCE(log_unimpl("TextField.multiline"));
if (!fn.nargs) {
// Getter
=== modified file 'libcore/TextField.h'
--- a/libcore/TextField.h 2009-07-28 09:23:14 +0000
+++ b/libcore/TextField.h 2009-07-29 17:19:47 +0000
@@ -549,7 +549,8 @@
/// will hopefully make code cleaner
void newLine(std::wstring::const_iterator& it, boost::int32_t& x,
boost::int32_t& y, SWF::TextRecord& rec, int& last_space_glyph,
- LineStarts::value_type& last_line_start_record, float div);
+ LineStarts::value_type& last_line_start_record, float div,
+ bool bullet);
/// De-reference and do appropriate action for character iterator
void handleChar(std::wstring::const_iterator& it,
=== modified file 'libcore/asobj/TextFormat_as.cpp'
--- a/libcore/asobj/TextFormat_as.cpp 2009-07-29 05:40:20 +0000
+++ b/libcore/asobj/TextFormat_as.cpp 2009-07-29 17:19:47 +0000
@@ -290,76 +290,73 @@
as_value ret;
- //~ std::string strVal = fn.arg(0).to_string();
- //~ std::stringstream ss;
- //~ int countComma = 0;
- //~ int countSpace = 0;
- //~ int countTab = 0;
-
- //~ // Next check is to see whether there is a comma and a space in the
- //~ // array
- //~ for (int i=0; i<strVal.length(); i++)
- //~ {
- //~ if (strVal[i]==(char)44)
- //~ {
- //~ countComma ++;
- //~ }
- //~
- //~ if (strVal[i]==(char)32)
- //~ {
- //~ countSpace ++;
- //~ }
- //~
- //~ if (strVal[i]==(char)9)
- //~ {
- //~ countTab ++;
- //~ }
- //~ }
- //~
- //~ for (int i=0; i<strVal.length(); i++)
- //~ {
- //~ switch(strVal[i])
- //~ {
- //~ case (char)44:
- //~ strVal[i] = (char)44;
- //~ case (char)9:
- //~ strVal[i] = (char)32;
- //~ default:
- //~ break;
- //~ }
- //~ }
-//~
- //~ int numInt = countComma + countSpace + countTab + 1;
- //~ std::vector<int> tabStops(numInt);
- //~
- //~ ss << strVal;
- //~
- //~ int val;
- //~
- //~ for (int i = 0; i < numInt; ++i)
- //~ {
- //~ ss >> val;
- //~ tabStops[i] = val;
- //~ }
- //~
- //~ for (int i = 0; i < numInt; i ++)
- //~ {
- //~ log_unimpl("num: %d", tabStops[i]);
- //~ }
-//~
- //~ if ( fn.nargs == 0) // getter
- //~ {
- //~ LOG_ONCE( log_unimpl("Getter for textformat_tabStops") );
- //~ }
- //~ else // setter
- //~ {
- //~ ptr->tabStopsSet(tabStops);
- //~ }
+ if (!fn.nargs)
+ {
+ return ret;
+ }
+
+ std::string strVal = fn.arg(0).to_string();
+ std::stringstream ss;
+ int countComma = 0;
+ int countSpace = 0;
+ int countTab = 0;
+
+ // Next check is to see whether there is a comma and a space in the
+ // array
+ for (int i=0; i<strVal.length(); i++)
+ {
+ if (strVal[i]==(char)44)
+ {
+ countComma ++;
+ }
+
+ if (strVal[i]==(char)32)
+ {
+ countSpace ++;
+ }
+
+ if (strVal[i]==(char)9)
+ {
+ countTab ++;
+ }
+ }
+
+ for (int i=0; i<strVal.length(); i++)
+ {
+ switch(strVal[i])
+ {
+ case (char)44:
+ strVal[i] = (char)44;
+ case (char)9:
+ strVal[i] = (char)32;
+ default:
+ break;
+ }
+ }
+
+ int numInt = countComma + countSpace + countTab + 1;
+ std::vector<int> tabStops(numInt);
+
+ ss << strVal;
+
+ int val;
+
+ for (int i = 0; i < numInt; ++i)
+ {
+ ss >> val;
+ tabStops[i] = val;
+ }
+
+ if ( fn.nargs == 0) // getter
+ {
+ LOG_ONCE( log_unimpl("Getter for textformat_tabStops") );
+ }
+ else // setter
+ {
+ ptr->tabStopsSet(tabStops);
+ }
return ret;
- //~
- LOG_ONCE( log_unimpl("TextFormat.tabStops") );
- //return as_value();
}
as_value
=== modified file 'testsuite/misc-haxe.all/classes.all/text/TextFormat_as.hx'
--- a/testsuite/misc-haxe.all/classes.all/text/TextFormat_as.hx 2009-07-28
07:49:39 +0000
+++ b/testsuite/misc-haxe.all/classes.all/text/TextFormat_as.hx 2009-07-29
17:19:47 +0000
@@ -287,8 +287,6 @@
}
- DejaGnu.note("typeof(url): " + Type.typeof(x1.url));
-
if (Std.is(x1.url, String)) {
DejaGnu.pass("TextFormat.url property exists");
} else {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r11331: Implemented tabStops and multiline property in TextField, and some html tags,
Sharad Desai <=