r15886 by pierremarc - Fixed update of Boxes geometry when adding a box to a boxgroup, then it allowed to implement GlyphBox::screenToPosition
scribus-commit
scribus-commit at lists.scribus.net
Tue Nov 16 19:12:37 CET 2010
Author: pierremarc
Date: Tue Nov 16 18:12:37 2010
New Revision: 15886
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15886
Log:
Fixed update of Boxes geometry when adding a box to a boxgroup, then it allowed to implement GlyphBox::screenToPosition
Modified:
branches/ScribusOIF/scribus/text/boxes.cpp
branches/ScribusOIF/scribus/text/boxes.h
Modified: branches/ScribusOIF/scribus/text/boxes.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15886&path=/branches/ScribusOIF/scribus/text/boxes.cpp
==============================================================================
--- branches/ScribusOIF/scribus/text/boxes.cpp (original)
+++ branches/ScribusOIF/scribus/text/boxes.cpp Tue Nov 16 18:12:37 2010
@@ -33,11 +33,13 @@
{
m_boxes.append(b);
FRect newRect = bbox().unite(b->bbox());
- m_y = newRect.y();
+ if(0 == m_ascent)
+ m_ascent = b->ascent();
+ m_y = newRect.y() + m_ascent;
m_x = newRect.x();
- m_ascent = qMax(b->ascent(), m_ascent);
+ m_width = newRect.width();
m_descent = newRect.height() - m_ascent;
- qDebug()<<"BoxGroup::addBox"<< b->toString()<<toString();
+ qDebug()<<"BoxGroup::addBox"<< b->toString()<< "\n\t->" <<toString();
}
void BoxGroup::render(ScPainter* p, const RenderOptions& renderOptions) const
@@ -535,7 +537,28 @@
int GlyphBox::screenToPosition(FPoint coord) const
{
- return m_charStart; // FIXME!
+ Cluster c(m_glyphs->itemStart(m_item));
+ double stack(m_x);
+ double clusterWidth(0);
+ double cx(coord.x());
+ while(c.textPosition() <= m_charEnd)
+ {
+ if(c.textPosition() < m_charStart)
+ {
+ if(m_glyphs->haveNext(c))
+ {
+ c = m_glyphs->next(c);
+ continue;
+ }
+ else
+ break;
+ }
+ clusterWidth = m_glyphs->clusterWidth(c);
+ if((cx > stack) && (cx < (stack + clusterWidth)))
+ return c.textPosition();
+ stack += clusterWidth;
+ }
+ return m_charStart;
}
FRect GlyphBox::boundingBox(int pos, uint len) const
Modified: branches/ScribusOIF/scribus/text/boxes.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15886&path=/branches/ScribusOIF/scribus/text/boxes.h
==============================================================================
--- branches/ScribusOIF/scribus/text/boxes.h (original)
+++ branches/ScribusOIF/scribus/text/boxes.h Tue Nov 16 18:12:37 2010
@@ -69,7 +69,7 @@
qreal descent() const { return m_descent; }
void setAscent(double a) { m_ascent = a; }
void setDescent(double d) { m_descent = d; }
- FRect bbox() const { return FRect(m_x, m_y - m_descent, m_width, height()); }
+ FRect bbox() const { return FRect(m_x, m_y - m_ascent, m_width, height()); }
virtual void render(ScPainter* p, const RenderOptions& renderOptions) const = 0;
virtual int screenToPosition(FPoint coord) const = 0;
More information about the scribus-commit
mailing list