Scribus
Open source desktop publishing at your fingertips
textlayout.h
1 /*
2  For general Scribus (>=1.3.2) copyright and licensing information please refer
3  to the COPYING file provided with the program. Following this notice may exist
4  a copyright and/or license notice that predates the release of Scribus 1.3.2
5  for which a new license (GPL+exception) is in place.
6  */
7 /***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15 
16 #ifndef TEXTLAYOUT_H
17 #define TEXTLAYOUT_H
18 
19 #include <QList>
20 
21 #include "scribusapi.h"
22 
23 #include "fpoint.h"
24 #include "frect.h"
25 #include "scpainter.h"
26 #include "sctextstruct.h"
27 
28 class StoryText;
29 
30 struct LineSpec
31 {
32  qreal x;
33  qreal y;
34  qreal width;
35  qreal ascent;
36  qreal descent;
37  qreal colLeft;
38 
39  int firstItem;
40  int lastItem;
41  qreal naturalWidth;
42 };
43 
44 struct PathData
45 {
46  float PtransX;
47  float PtransY;
48  float PRot;
49  float PDx;
50 };
51 
52 
58 class SCRIBUS_API TextLayout
59 {
60 public:
61  TextLayout(StoryText* text, PageItem* frame);
62 
63  bool overflows() const;
64 
65  StoryText* story() { return m_story; }
66  const StoryText* story() const { return m_story; }
67  void setStory(StoryText* story);
68 
69  int startOfLine(int pos) const;
70  int endOfLine(int pos) const;
71  int prevLine(int pos) const;
72  int nextLine(int pos) const;
73  int startOfFrame() const;
74  int endOfFrame() const;
75 
76  int screenToPosition(FPoint coord) const;
77  FRect boundingBox(int pos, uint len = 1) const;
78 
79  uint lines() const;
80 
81  const LineSpec& line(uint i) const;
82  const PathData& point(int pos) const;
83  PathData& point(int pos);
84 
85  void appendLine(const LineSpec& ls);
86  void removeLastLine ();
87 
88  void clear();
89 
90 protected:
91  friend class FrameControl;
92 
93  StoryText* m_story;
94  PageItem* m_frame;
95 
96  int m_firstInFrame;
97  int m_lastInFrame;
98  QList<LineSpec> m_lines;
99  QVector<PathData> m_path;
100  bool m_validLayout;
101  mutable qreal m_magicX;
102  mutable int m_lastMagicPos;
103 
104 };
105 
106 #endif
Definition: storytext.h:71
Definition: textlayout.h:58
A point with floating point precision.
Definition: fpoint.h:43
Definition: textlayout.h:30
Definition: pageitem.h:92
Definition: textlayout.h:44
The FRect class defines a rectangle in the plane.
Definition: frect.h:50