Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Public Member Functions | Public Attributes | Private Attributes
LineControl Struct Reference

fields which describe how the current line is placed into the frame More...

Collaboration diagram for LineControl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void init (double w, double h, const MarginStruct &extra, double lCorr)
 remember frame dimensions and offsets
void initColumns (double width, double gap)
 start at column 0
void nextColumn (double asce)
 move position to next column
bool isEndOfCol (double morespace=0)
void startLine (int first)
 init fields for a new line at current position
void rememberShrinkStretch (QChar ch, double wide, const ParagraphStyle &style)
 called when glyphs are placed on the line
void rememberBreak (int index, double pos)
 called when a possible break is passed
void breakLine (const StoryText &itemText, int last)
 called when a mandatory break is found
void finishLine (double endX)
 use the last remembered break to set line width and itemrange
bool isEndOfLine (double moreSpace=0)
double startOfLine (const QRegion &shape, const QPainter &pf2, double ascent, double descent, double morespace)
 find x position to start current line
double endOfLine (const QRegion &shape, const QPainter &pf2, double ascent, double descent, double morespace=0)
 find x position where this line must end
double getLineAscent (const StoryText &itemText)
double getLineHeight (const StoryText &itemText)

Public Attributes

LineSpec line
int itemsInLine
int hyphenCount
double colWidth
double colGap
double colLeft
double colRight
int column
bool startOfCol
double ascend
double descend
double width
double xPos
double yPos
int breakIndex
double breakXPos
double maxShrink
double maxStretch

Private Attributes

double frameWidth
double frameHeight
MarginStruct insets
double lineCorr

Detailed Description

fields which describe how the current line is placed into the frame

Definition at line 295 of file pageitem_textframe.cpp.


Member Function Documentation

void LineControl::breakLine ( const StoryText &  itemText,
int  last 
) [inline]

called when a mandatory break is found

Definition at line 408 of file pageitem_textframe.cpp.

       {
              breakIndex = last;
              breakXPos  = line.x;
              for (int j = line.firstItem; j <= last; ++j)
                     if ( (itemText.item(j)->effects() & ScStyle_SuppressSpace) == 0)
                            breakXPos += itemText.item(j)->glyph.wide();            
       }
double LineControl::endOfLine ( const QRegion &  shape,
const QPainter &  pf2,
double  ascent,
double  descent,
double  morespace = 0 
) [inline]

find x position where this line must end

Definition at line 458 of file pageitem_textframe.cpp.

       {
              double EndX = floor(QMAX(line.x, QMIN(colRight,breakXPos) - 1));
              QPoint pt1, pt2;
              //     qDebug(QString("endx start=%1, hl is '%2'").arg(EndX).arg(hl->ch));
              do {
                     EndX += 0.125;
                     pt1 = QPoint(qRound(ceil(EndX + insets.Right)), static_cast<int>(yPos+descent));
                     pt2 = QPoint(qRound(ceil(EndX + insets.Right)), static_cast<int>(ceil(yPos-ascent)));
              } while 
                     (   (EndX + (legacy? lineCorr + insets.Right : 0) < colRight - morespace)
                       && shape.contains(pf2.xForm(pt1))
                       && shape.contains(pf2.xForm(pt2)) 
                       );
              
              return EndX;
       }
void LineControl::finishLine ( double  endX) [inline]

use the last remembered break to set line width and itemrange

Definition at line 418 of file pageitem_textframe.cpp.

       {
              line.lastItem = breakIndex;
              line.naturalWidth = breakXPos - line.x;
              line.width = endX - line.x;
              maxShrink = maxStretch = 0;
//            qDebug(QString("finishLine ..%1: %2___%3 %4->%5").arg(breakIndex).arg(line.x).arg(endX).arg(line.naturalWidth).arg(line.width));
       }
double LineControl::getLineAscent ( const StoryText &  itemText) [inline]

Definition at line 477 of file pageitem_textframe.cpp.

       {
              double result = 0;
              if ((itemText.text(line.firstItem) == SpecialChars::PARSEP) || (itemText.text(line.firstItem) == SpecialChars::LINEBREAK))
                     result = itemText.charStyle(line.firstItem).font().ascent(itemText.charStyle(line.firstItem).fontSize() / 10.0);
              else if (itemText.object(line.firstItem) != 0)
                     result = QMAX(result, (itemText.object(line.firstItem)->gHeight + itemText.object(line.firstItem)->lineWidth()) * (itemText.charStyle(line.firstItem).scaleV() / 1000.0));
              else //if (itemText.charStyle(current.line.firstItem).effects() & ScStyle_DropCap == 0)
                     result = itemText.charStyle(line.firstItem).font().realCharAscent(itemText.text(line.firstItem), itemText.charStyle(line.firstItem).fontSize() / 10.0);
              for (int zc = 0; zc < itemsInLine; ++zc)
              {
                     QChar ch = itemText.text(line.firstItem + zc);
                     if (ch == SpecialChars::PAGENUMBER)
                            ch = '8'; // should have highest ascender even in oldstyle
                     const CharStyle& cStyle(itemText.charStyle(line.firstItem + zc));
                     if ((ch == SpecialChars::TAB) || (ch == QChar(10))
                            || (ch == SpecialChars::PARSEP) || (ch == SpecialChars::NBHYPHEN)
                            || (ch == SpecialChars::COLBREAK) || (ch == SpecialChars::LINEBREAK)
                            || (ch == SpecialChars::FRAMEBREAK) || (ch.isSpace()))
                            continue;
                     double asce;
                     if (itemText.object(line.firstItem + zc) != 0)
                            asce = itemText.object(line.firstItem + zc)->gHeight + itemText.object(line.firstItem + zc)->lineWidth() * (cStyle.scaleV() / 1000.0);
                     else //if (itemText.charStyle(current.line.firstItem + zc).effects() & ScStyle_DropCap == 0)
                            asce = cStyle.font().realCharAscent(ch, cStyle.fontSize() / 10.0);
//                   qDebug(QString("checking char 'x%2' with ascender %1 > %3").arg(asce).arg(ch.unicode()).arg(result));
                     result = QMAX(result, asce);
              }
              return result;
       }
double LineControl::getLineHeight ( const StoryText &  itemText) [inline]

Definition at line 508 of file pageitem_textframe.cpp.

       {
              double result = 0;
              if (itemText.object(line.firstItem) != 0)
                     result = QMAX(result, (itemText.object(line.firstItem)->gHeight + itemText.object(line.firstItem)->lineWidth()) * (itemText.charStyle(line.firstItem).scaleV() / 1000.0));
              else //if (itemText.charStyle(current.line.firstItem).effects() & ScStyle_DropCap == 0)
                     result = itemText.charStyle(line.firstItem).font().height(itemText.charStyle(line.firstItem).fontSize() / 10.0);
              for (int zc = 0; zc < itemsInLine; ++zc)
              {
                     QChar ch = itemText.text(line.firstItem+zc);
                     if ((ch == SpecialChars::TAB) || (ch == QChar(10))
                            || (ch == SpecialChars::PARSEP) || (ch == SpecialChars::NBHYPHEN)
                            || (ch == SpecialChars::COLBREAK) || (ch == SpecialChars::FRAMEBREAK)
                            || (ch == SpecialChars::LINEBREAK) || (ch.isSpace()))
                            continue;
                     double asce;
                     if (itemText.object(line.firstItem+zc) != 0)
                            asce = (itemText.object(line.firstItem+zc)->gHeight + itemText.object(line.firstItem+zc)->lineWidth()) * (itemText.charStyle(line.firstItem+zc).scaleV() / 1000.0);
                     else //if (itemText.charStyle(current.line.firstItem+zc).effects() & ScStyle_DropCap == 0)
                            asce = itemText.charStyle(line.firstItem+zc).font().height(itemText.charStyle(line.firstItem+zc).fontSize() / 10.0);
                     //                                 qDebug(QString("checking char 'x%2' with ascender %1 > %3").arg(asce).arg(ch.unicode()).arg(result));
                     result = QMAX(result, asce);
              }
              return result;
       }
void LineControl::init ( double  w,
double  h,
const MarginStruct extra,
double  lCorr 
) [inline]

remember frame dimensions and offsets

Definition at line 316 of file pageitem_textframe.cpp.

       {
              insets = extra;
              lineCorr = lCorr;
              frameWidth = w;
              frameHeight = h;
       }
void LineControl::initColumns ( double  width,
double  gap 
) [inline]

start at column 0

Definition at line 325 of file pageitem_textframe.cpp.

       {
              column = 0;
              colWidth = width;
              colGap = gap;
       }
bool LineControl::isEndOfCol ( double  morespace = 0) [inline]

Definition at line 344 of file pageitem_textframe.cpp.

       {
              return yPos + morespace + insets.Bottom + lineCorr > frameHeight;
       }
bool LineControl::isEndOfLine ( double  moreSpace = 0) [inline]

Definition at line 428 of file pageitem_textframe.cpp.

       {
              if (legacy)
                     return xPos + insets.Right + lineCorr + moreSpace - maxShrink >= colRight;
              else
                     return xPos + moreSpace - maxShrink >= colRight;
       }
void LineControl::nextColumn ( double  asce) [inline]

move position to next column

Definition at line 333 of file pageitem_textframe.cpp.

void LineControl::rememberBreak ( int  index,
double  pos 
) [inline]

called when a possible break is passed

Definition at line 383 of file pageitem_textframe.cpp.

       {
              if (pos > colRight)
              {
                     // only look for the first break behind the right edge
                     maxShrink = 0;
              
                     // check if we already have a better break
                     if (breakIndex >= 0)
                     {
                            double oldLooseness = QABS(colRight - breakXPos);
                            double newLooseness = pos - colRight;
                            if (newLooseness >= oldLooseness)
                                   return;
                     }
                     breakXPos = colRight;
              }
              else
              {
                     breakXPos = pos;
              }
              breakIndex = index;
       }
void LineControl::rememberShrinkStretch ( QChar  ch,
double  wide,
const ParagraphStyle &  style 
) [inline]

called when glyphs are placed on the line

Definition at line 370 of file pageitem_textframe.cpp.

       {
              if (SpecialChars::isExpandingSpace(ch))
                     maxShrink += (1 - style.minWordTracking()) * wide;
              else
              {
                     maxShrink += (1 - style.minGlyphExtension()) * wide;
              }
              maxStretch += (style.maxGlyphExtension() - 1) * wide;
       }
void LineControl::startLine ( int  first) [inline]

init fields for a new line at current position

Definition at line 352 of file pageitem_textframe.cpp.

       {             
              itemsInLine = 0;
              line.x = xPos;
              line.y = yPos;
              line.firstItem = first;
              line.ascent = 10;
              line.descent = 0;
              line.width = 0;
              line.naturalWidth = 0;
              breakIndex = -1;
              breakXPos = 0;
              maxShrink = 0;
              maxStretch = 0;
       }
double LineControl::startOfLine ( const QRegion &  shape,
const QPainter &  pf2,
double  ascent,
double  descent,
double  morespace 
) [inline]

find x position to start current line

Definition at line 437 of file pageitem_textframe.cpp.

       {
              QPoint pt1, pt2;
              double tmpX = xPos;
              pt1 = QPoint(static_cast<int>(ceil(tmpX)), static_cast<int>(yPos + descent));
              pt2 = QPoint(static_cast<int>(ceil(tmpX)), static_cast<int>(ceil(yPos - ascent)));
              // increase pt1/pt2 until i-beam reaches end of line
              while ((!shape.contains(pf2.xForm(pt1))) || (!shape.contains(pf2.xForm(pt2))))
              {
                     tmpX++;
                     if (xPos + (legacy? lineCorr + insets.Right : 0) + lineCorr + morespace >= colRight)
                     {
                            return tmpX;
                     }
                     pt1 = QPoint(static_cast<int>(ceil(tmpX)), static_cast<int>(yPos + descent));
                     pt2 = QPoint(static_cast<int>(ceil(tmpX)), static_cast<int>(ceil(yPos - ascent)));
              }
              return tmpX;
       }

Member Data Documentation

Definition at line 305 of file pageitem_textframe.cpp.

Definition at line 310 of file pageitem_textframe.cpp.

Definition at line 311 of file pageitem_textframe.cpp.

Definition at line 300 of file pageitem_textframe.cpp.

Definition at line 301 of file pageitem_textframe.cpp.

Definition at line 302 of file pageitem_textframe.cpp.

Definition at line 303 of file pageitem_textframe.cpp.

Definition at line 299 of file pageitem_textframe.cpp.

Definition at line 306 of file pageitem_textframe.cpp.

double LineControl::frameHeight [private]

Definition at line 537 of file pageitem_textframe.cpp.

double LineControl::frameWidth [private]

Definition at line 536 of file pageitem_textframe.cpp.

Definition at line 298 of file pageitem_textframe.cpp.

Definition at line 538 of file pageitem_textframe.cpp.

Definition at line 297 of file pageitem_textframe.cpp.

Definition at line 296 of file pageitem_textframe.cpp.

double LineControl::lineCorr [private]

Definition at line 539 of file pageitem_textframe.cpp.

Definition at line 312 of file pageitem_textframe.cpp.

Definition at line 313 of file pageitem_textframe.cpp.

Definition at line 304 of file pageitem_textframe.cpp.

Definition at line 307 of file pageitem_textframe.cpp.

Definition at line 308 of file pageitem_textframe.cpp.

Definition at line 309 of file pageitem_textframe.cpp.


The documentation for this struct was generated from the following file: