/branches/ScribusOIF/scribus/canvasmode_edit.cpp |
---|
176,7 → 176,7 |
{ |
if(textframe->lastInFrame() < 0) |
return; |
if ( m_blinkTime.elapsed() > qApp->cursorFlashTime() / 2 ) |
if ( m_blinkTime.elapsed() > qApp->cursorFlashTime() / 2) |
{ |
m_cursorVisible = !m_cursorVisible; |
m_blinkTime.restart(); |
299,9 → 299,9 |
{ |
bbox = textframe->textLayout->boundingBox ( textCursorPos ); |
cursorDirection = !textframe->itemText.charAttributes(textCursorPos).testFlag(TextFlag_RightToLeft); |
dx = cursorDirection ? bbox.x() :bbox.right() ; |
dx = cursorDirection ? bbox.right() : bbox.x(); |
dy = bbox.y(); |
dx += bbox.width(); |
// dx += bbox.width(); |
if ( bbox.height() <= 2 ) |
dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0; |
else |
317,10 → 317,10 |
bbox = textframe->textLayout->boundingBox ( textCursorPos ); |
dx = cursorDirection ? bbox.x() :bbox.right(); |
dy = bbox.y(); |
// if ( bbox.height() <= 2 ) |
// dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0; |
// else |
dy1 = bbox.y() + bbox.height(); |
if ( bbox.height() <= 2 ) |
dy1 = bbox.y() + textframe->itemText.charStyle ( textCursorPos ).fontSize() / 30.0; |
else |
dy1 = bbox.y() + textframe->textLayout->boxAscent(textCursorPos); |
cPen.setColor ( ScColorEngine::getRGBColor ( m_doc->PageColors[textframe->itemText.charStyle ( textCursorPos ).fillColor() ], m_doc ) ); |
} |
/branches/ScribusOIF/scribus/sctextstruct.h |
---|
56,7 → 56,8 |
TextFlag_StartOfLine = 16, |
TextFlag_ClusterStart = 32, |
TextFlag_WordBoundary = 64, |
TextFlag_RightToLeft = 128 |
TextFlag_RightToLeft = 128, |
TextFlag_TextSelected = 256 |
}; |
Q_DECLARE_FLAGS(TextFlags, TextFlag) |
/branches/ScribusOIF/scribus/scribusview.cpp |
---|
1687,8 → 1687,9 |
else |
{ |
FPoint point(pf.x() - currItem->xPos(), pf.y() - currItem->yPos()); |
int screenToPos(currItem->textLayout->screenToPosition(point)); |
currItem->CPos = currItem->itemText.length() == 0 ? 0 : |
/*currItem->itemText.screenToPosition(point)*/ currItem->textLayout->screenToPosition(point); |
(screenToPos < 0 ? currItem->itemText.length() : screenToPos); |
} |
if (currItem->itemText.length() > 0) |
/branches/ScribusOIF/scribus/pageitem_textframe.cpp |
---|
378,10 → 378,10 |
assert( lastInFrame() < itemText.length() ); |
RenderOptions options; |
options.markSelection = itemText.lengthOfSelection() > 0; |
options.markSelection = (itemText.lengthOfSelection() > 0) && (m_Doc->appMode == modeEdit); |
options.showControls = (m_Doc->guidesPrefs().showControls); |
options.controlCharColor = PrefsManager::instance()->appPrefs.displayPrefs.controlCharColor; |
options.reverse = Reverse; // hope we have bidi soon... |
options.reverse = Reverse; // hope we have bidi soon... // we have, but it's not frame based :) |
options.layerOutline = (m_Doc->layerOutline(LayerID)); |
options.layerMarker = m_Doc->layerMarker(LayerID); |
textLayout->render(p, options); |
/branches/ScribusOIF/scribus/text/boxes.cpp |
---|
13,8 → 13,11 |
#include "specialchars.h" |
#include "storytext.h" |
#include "scpainterexbase.h" |
#include "text/storytext.h" |
#include <QDebug> |
#include <QApplication> |
#include <QPalette> |
BoxGroup::BoxGroup(BoxType type): |
88,8 → 91,13 |
for (int i=0; i < m_boxes.count(); ++i) |
{ |
Box* b = m_boxes[i]; |
// FIXME_OIF - we should return a bb running towards many glyphboxes |
if (b->containsPos(pos)) |
result = result.unite(b->boundingBox(pos, len)); |
{ |
result = b->boundingBox(pos, len); |
// qDebug()<<"R1"<<result.x()<<result.y(); |
break; |
} |
} |
return result; |
} |
445,6 → 453,7 |
p->drawLine(FPoint(x(), y()), FPoint(x() + width(), y())); |
p->restore(); |
// Position the painter |
p->save(); |
p->setAntialiasing(true); |
if(rtl) |
451,7 → 460,48 |
p->translate(x() + width(), y()); |
else |
p->translate(x(), y()); |
// Paint the selection rectangle |
if(renderOptions.markSelection) |
{ |
int selStart(-1); |
int selEnd(-1); |
for(int si(m_charStart); si <= m_charEnd; ++si) |
{ |
if(m_glyphs->story()->charAttributes(si).testFlag(TextFlag_TextSelected)) |
{ |
if(selStart < 0) |
{ |
selEnd = selStart = si; |
} |
else |
selEnd = si; |
} |
} |
double selX(0); |
double selWidth(m_glyphs->itemWidth(m_item, selStart, selEnd - selStart + 1)); |
if(rtl) |
selX = m_width - selWidth; |
if(selStart != m_charStart) |
{ |
if(rtl) |
selX -= m_glyphs->itemWidth(m_item, m_charStart, selStart - m_charStart ); |
else |
selX += m_glyphs->itemWidth(m_item, m_charStart, selStart - m_charStart ); |
} |
if(selStart >= 0) |
{ |
p->save(); |
p->setPen(qApp->palette().color(QPalette::Active, QPalette::Highlight), 0.0, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin); |
p->setFillMode(ScPainter::Solid); |
p->setBrush(qApp->palette().color(QPalette::Active, QPalette::Highlight)); |
p->drawRect(selX, -m_ascent, selWidth, m_ascent + m_descent); |
p->restore(); |
} |
} |
QString color = style.fillColor(); |
QColor fillColor(Qt::transparent); |
double shade = style.fillShade(); |
545,8 → 595,17 |
// p->setFillMode(ScPainter::None); |
// p->drawRect(0, -m_ascent, layout->xadvance , height()); |
// p->restore(); |
layout->renderOutlines(p, renderOptions, style); |
if(renderOptions.markSelection && m_glyphs->story()->charAttributes(cluster.textPosition()).testFlag(TextFlag_TextSelected)) |
{ |
p->setBrush(qApp->palette().color(QPalette::Active, QPalette::HighlightedText)); |
layout->renderOutlines(p, renderOptions, style); |
p->setBrush(fillColor); |
} |
else |
layout->renderOutlines(p, renderOptions, style); |
if ((style.effects() & ScStyle_Strikethrough) && (style.strokeColor() != CommonStrings::None)) |
{ |
layout->renderStrikeThrough(p, renderOptions, style); |
665,10 → 724,12 |
FRect ret; |
if (!containsPos(pos)) |
return ret; |
ret.setTop(y() - m_ascent); |
ret.setHeight(height()); |
bool rtl(m_glyphs->story()->charAttributes(m_glyphs->itemTextPosition(m_item)).testFlag(TextFlag_RightToLeft)); |
uint clen(len); |
if(pos + len > m_charEnd) |
clen = m_charEnd - pos; |
if(pos + len > m_charEnd + 1) |
clen = (m_charEnd - pos) + 1; |
double width(m_glyphs->itemWidth(m_item, pos, clen)); |
double poffset(0); |
if(pos != m_charStart) |
675,16 → 736,13 |
{ |
poffset = m_glyphs->itemWidth(m_item, m_charStart , pos - m_charStart); |
} |
ret.setTop(y() - m_ascent); |
if(rtl) |
ret.setLeft(x() + m_width - (width + poffset)); |
else |
ret.setLeft(x() + poffset); |
ret.setWidth(width); |
ret.setHeight(height()); |
qDebug()<<"GS::bb"<<"text:"<<m_glyphs->story()->text(pos, len)<<"width"<<ret.width()<<"x"<<x()<<"offset"<<poffset<<"px"<<ret.x(); |
// qDebug()<<"GS::bb"<<"text:"<<m_glyphs->story()->text(pos, len)<<"width"<<ret.width()<<"x"<<x()<<"offset"<<poffset<<"px"<<ret.x(); |
return ret; |
// return FRect(8*pos,0,8*len,10); // FIXME! |
/branches/ScribusOIF/scribus/text/storytext.h |
---|
174,6 → 174,8 |
int startOfSelection() const; |
int endOfSelection() const; |
int lengthOfSelection() const; |
// to be called after any change on selection to update text attributes |
void attrSelection(); |
// when physical view doesn't match logical view any more: |
/branches/ScribusOIF/scribus/text/storytext.cpp |
---|
839,6 → 839,19 |
return selFirst <= selLast? selLast - selFirst + 1 : 0; |
} |
void StoryText::attrSelection() |
{ |
if(selLast >= 0) |
{ |
for(int i(0); i < length() ; ++i) |
{ |
if(selected(i)) |
data->charAttributes(i) |= TextFlag_TextSelected; |
else |
data->charAttributes(i) &= ~TextFlag_TextSelected; |
} |
} |
} |
bool StoryText::selected(int pos) const |
{ |
910,7 → 923,7 |
// Grr, deselection splits selection |
selLast = pos - 1; |
} |
attrSelection(); |
// qDebug("new selection: %d - %d", selFirst, selLast); |
} |
922,11 → 935,13 |
if (selLast == oldPos - 1) |
{ |
selLast = newPos - 1; |
attrSelection(); |
return; |
} |
else if (selFirst == oldPos) |
{ |
selFirst = newPos; |
attrSelection(); |
return; |
} |
// can't extend, fall through |
942,6 → 957,7 |
selFirst = newPos; |
selLast = oldPos - 1; |
} |
attrSelection(); |
} |
void StoryText::selectAll() |
955,6 → 971,7 |
*/ |
selFirst = 0; |
selLast = length() - 1; |
attrSelection(); |
} |
void StoryText::deselectAll() |
968,6 → 985,7 |
*/ |
selFirst = 0; |
selLast = -1; |
attrSelection(); |
} |
void StoryText::removeSelection() |