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 class Box; 30 class GroupBox; 31 class LineBox; 32 class TextLayoutPainter; 33 class ScreenPainter; 34 class ITextContext; 35 /** 36 This class manages the physical layout of a textframe, ie. its line 37 structure and the lines' glyph layouts. It will use some of the layouters above to create a Box. 38 It listens to change events from the StoryText and the PageItem and will update the layout accordingly. 39 */ 40 class SCRIBUS_API TextLayout 41 { 42 public: 43 TextLayout(StoryText* text, ITextContext* frame); 44 ~TextLayout(); 45 46 bool overflows() const; 47 story()48 StoryText* story() { return m_story; } frame()49 ITextContext* frame() { return m_frame; } story()50 const StoryText* story() const { return m_story; } 51 void setStory(StoryText* story); 52 void render(ScreenPainter *p, ITextContext *ctx) const; 53 void render(TextLayoutPainter *p) const; 54 void renderBackground(TextLayoutPainter *p) const; 55 int startOfLine(int pos) const; 56 int endOfLine(int pos) const; 57 int prevLine(int pos) const; 58 int nextLine(int pos) const; 59 int startOfFrame() const; 60 int endOfFrame() const; 61 62 int pointToPosition(QPointF coord) const; 63 QLineF positionToPoint(int pos) const; 64 65 uint lines() const; 66 67 const LineBox* line(uint i) const; 68 const Box* box() const; 69 Box* box(); 70 71 void appendLine(LineBox* ls); 72 void removeLastLine (); 73 void addColumn(double colLeft, double colWidth); 74 75 void clear(); 76 77 protected: 78 friend class FrameControl; 79 80 StoryText* m_story; 81 ITextContext* m_frame; 82 GroupBox* m_box; 83 84 bool m_validLayout; 85 mutable qreal m_magicX; 86 mutable int m_lastMagicPos; 87 88 }; 89 90 #endif 91