Subversion Repositories Scribus

Rev

Rev 20632 | Rev 21563 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18988 avox 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
 
18989 jghali 21
#include "scribusapi.h"
22
 
18988 avox 23
#include "fpoint.h"
24
#include "frect.h"
25
#include "scpainter.h"
26
#include "sctextstruct.h"
27
 
28
class StoryText;
21107 craig 29
class Box;
30
class GroupBox;
31
class LineBox;
32
class TextLayoutPainter;
18988 avox 33
 
34
struct PathData
35
{
36
        float PtransX;
37
        float PtransY;
38
        float PRot;
39
        float PDx;
40
};
41
 
42
 
43
/**
44
        This class manages the physical layout of a textframe, ie. its line
45
        structure and the lines' glyph layouts. It will use some of the layouters above to create a Box.
46
    It listens to change events from the StoryText and the PageItem and will update the layout accordingly.
47
 */
18989 jghali 48
class SCRIBUS_API TextLayout
18988 avox 49
{
50
public:
51
        TextLayout(StoryText* text, PageItem* frame);
21107 craig 52
        ~TextLayout();
18988 avox 53
 
54
        bool overflows() const;
55
 
56
        StoryText* story() { return m_story; }
57
        const StoryText* story() const { return m_story; }
58
        void setStory(StoryText* story);
21107 craig 59
        void render(TextLayoutPainter *p, PageItem *item);
60
        void render(TextLayoutPainter *p);
61
        void renderBackground(TextLayoutPainter *p);
18988 avox 62
        int startOfLine(int pos) const;
63
        int endOfLine(int pos) const;
64
        int prevLine(int pos) const;
65
        int nextLine(int pos) const;
66
        int startOfFrame() const;
67
        int endOfFrame() const;
68
 
21107 craig 69
        int pointToPosition(QPointF coord) const;
70
        QLineF positionToPoint(int pos) const;
18988 avox 71
 
72
        uint lines() const;
73
 
21107 craig 74
        const LineBox*  line(uint i) const;
75
        const Box* box() const;
76
        Box* box();
18988 avox 77
        const PathData& point(int pos) const;
78
        PathData& point(int pos);
79
 
21107 craig 80
        void appendLine(LineBox* ls);
18988 avox 81
        void removeLastLine ();
21107 craig 82
        void addColumn(double colLeft, double colWidth);
18988 avox 83
 
84
        void clear();
85
 
86
protected:
87
        friend class FrameControl;
88
 
89
        StoryText* m_story;
90
    PageItem* m_frame;
21107 craig 91
        GroupBox* m_box;
18988 avox 92
 
93
        QVector<PathData> m_path;
94
        bool m_validLayout;
95
        mutable qreal m_magicX;
96
        mutable int m_lastMagicPos;
97
 
98
};
99
 
100
#endif