Rev 21155 | Rev 21563 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | cbradney | 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 | */ |
||
3878 | cbradney | 7 | #ifndef SCTEXTSTRUCT_H |
8 | #define SCTEXTSTRUCT_H |
||
9 | |||
10 | #ifdef HAVE_CONFIG_H |
||
11 | #include "scconfig.h" |
||
12 | #endif |
||
13 | |||
4689 | mrdocs | 14 | #include "scribusapi.h" |
15 | |||
10028 | cbradney | 16 | #include <QString> |
3878 | cbradney | 17 | |
5559 | avox | 18 | #include "scfonts.h" |
5691 | avox | 19 | #include "style.h" |
8337 | avox | 20 | #include "styles/charstyle.h" |
21 | #include "styles/paragraphstyle.h" |
||
5559 | avox | 22 | |
3878 | cbradney | 23 | class PageItem; |
17826 | craig | 24 | class Mark; |
17407 | fschmid | 25 | class ScribusDoc; |
3878 | cbradney | 26 | |
27 | /* Struktur fuer Pageitem Text */ |
||
4670 | avox | 28 | |
29 | |||
30 | /* |
||
31 | * sctext.h |
||
32 | * Scribus |
||
33 | * |
||
34 | * Created by Andreas Vox on 29.07.05. |
||
35 | * Copyright 2005 under GPL2. All rights reserved. |
||
36 | * |
||
37 | */ |
||
38 | |||
18524 | avox | 39 | // from charstlye.h ScStyleFlags |
40 | enum LayoutFlags { |
||
41 | ScLayout_None = 0, |
||
21107 | craig | 42 | ScLayout_BulletNum = 1, // new: marks list layout glyphs |
43 | ScLayout_FixedSpace = 2, // new: marks a fixed space |
||
44 | ScLayout_ExpandingSpace= 4, // new: marks an expanding space |
||
45 | ScLayout_ImplicitSpace = 8, // new: marks an implicit space |
||
46 | ScLayout_TabLeaders = 16, // new: marks a tab with fillchar |
||
21237 | jghali | 47 | ScLayout_HyphenationPossible=128, // Hyphenation possible here (Soft Hyphen) |
18524 | avox | 48 | ScLayout_DropCap = 2048, |
21237 | jghali | 49 | ScLayout_SuppressSpace = 4096, // internal use in PageItem (Suppresses spaces when in Block alignment) |
50 | ScLayout_SoftHyphenVisible=8192, // Soft Hyphen visible at line end |
||
51 | ScLayout_StartOfLine = 16384, // set for start of line |
||
52 | ScLayout_Underlined = 32768 // chararcter should be underlined |
||
18524 | avox | 53 | }; |
4670 | avox | 54 | |
55 | |||
5691 | avox | 56 | /** |
57 | * This struct stores a positioned glyph. This is the result of the layout process. |
||
58 | */ |
||
59 | struct SCRIBUS_API GlyphLayout { |
||
60 | float xadvance; |
||
61 | float yadvance; |
||
62 | float xoffset; |
||
63 | float yoffset; |
||
64 | double scaleV; |
||
65 | double scaleH; |
||
66 | uint glyph; |
||
6144 | avox | 67 | |
5691 | avox | 68 | GlyphLayout() : xadvance(0.0f), yadvance(0.0f), xoffset(0.0f), yoffset(0.0f), |
21107 | craig | 69 | scaleV(1.0), scaleH(1.0), glyph(0) //, more(NULL) |
6144 | avox | 70 | { } |
4670 | avox | 71 | }; |
72 | |||
21107 | craig | 73 | |
74 | class GlyphRun |
||
13946 | jghali | 75 | { |
21107 | craig | 76 | const CharStyle* m_style; |
77 | LayoutFlags m_flags; |
||
78 | QList<GlyphLayout> m_glyphs; |
||
21155 | jghali | 79 | |
21107 | craig | 80 | int m_firstChar; |
81 | int m_lastChar; |
||
82 | PageItem* m_object; |
||
83 | |||
84 | public: |
||
85 | GlyphRun(const CharStyle* style, LayoutFlags flags, int first, int last, PageItem* o) |
||
86 | : m_style(style) |
||
87 | , m_flags(flags) |
||
88 | , m_firstChar(first) |
||
89 | , m_lastChar(last) |
||
90 | , m_object(o) |
||
91 | {} |
||
92 | |||
93 | const CharStyle& style() const { return *m_style; } |
||
94 | bool hasFlag(LayoutFlags f) const { return (m_flags & f) == f; } |
||
95 | void setFlag(LayoutFlags f) { m_flags = static_cast<LayoutFlags>(m_flags | f); } |
||
96 | void clearFlag(LayoutFlags f) { m_flags = static_cast<LayoutFlags>(m_flags & ~f); } |
||
21155 | jghali | 97 | void clearGlyphs() { m_glyphs.clear(); } |
21107 | craig | 98 | |
21131 | jghali | 99 | QList<GlyphLayout>& glyphs() { return m_glyphs; } |
100 | const QList<GlyphLayout>& glyphs() const { return m_glyphs; } |
||
21155 | jghali | 101 | int glyphCount() const { return m_glyphs.count(); } |
21107 | craig | 102 | int firstChar() const { return m_firstChar; } |
103 | int lastChar() const { return m_lastChar; } |
||
104 | qreal width() const; |
||
105 | PageItem* object() const { return m_object; } |
||
13946 | jghali | 106 | }; |
107 | |||
18524 | avox | 108 | |
4689 | mrdocs | 109 | class SCRIBUS_API ScText : public CharStyle |
4670 | avox | 110 | { |
111 | public: |
||
5691 | avox | 112 | ParagraphStyle* parstyle; // only for parseps |
17407 | fschmid | 113 | int embedded; |
17826 | craig | 114 | Mark* mark; |
9737 | jghali | 115 | QChar ch; |
21107 | craig | 116 | ScText() : |
8775 | cbradney | 117 | CharStyle(), |
21107 | craig | 118 | parstyle(NULL), |
18987 | avox | 119 | embedded(0), mark(NULL), ch() {} |
21107 | craig | 120 | ScText(const ScText& other) : |
7005 | avox | 121 | CharStyle(other), |
21107 | craig | 122 | parstyle(NULL), |
17826 | craig | 123 | embedded(other.embedded), mark(NULL), ch(other.ch) |
6144 | avox | 124 | { |
125 | if (other.parstyle) |
||
126 | parstyle = new ParagraphStyle(*other.parstyle); |
||
17826 | craig | 127 | if (other.mark) |
128 | setNewMark(other.mark); |
||
6144 | avox | 129 | } |
5691 | avox | 130 | ~ScText(); |
16600 | jghali | 131 | |
17407 | fschmid | 132 | bool hasObject(ScribusDoc *doc) const; |
17826 | craig | 133 | //returns true if given MRK is found, if MRK is NULL then any mark returns true |
134 | bool hasMark(Mark * MRK = NULL) const; |
||
17407 | fschmid | 135 | QList<PageItem*> getGroupedItems(ScribusDoc *doc); |
136 | PageItem* getItem(ScribusDoc *doc); |
||
17826 | craig | 137 | private: |
138 | void setNewMark(Mark* mrk); |
||
3878 | cbradney | 139 | }; |
5184 | avox | 140 | |
12269 | cbradney | 141 | |
142 | /** @brief First Line Offset Policy |
||
143 | * Set wether the first line offset is based on max glyph height |
||
144 | * or some of predefined height. |
||
145 | * I put a prefix because it could easily conflict |
||
146 | */ |
||
147 | enum FirstLineOffsetPolicy |
||
148 | { |
||
149 | FLOPRealGlyphHeight = 0, // Historical |
||
17760 | jghali | 150 | FLOPFontAscent = 1, |
151 | FLOPLineSpacing = 2, |
||
152 | FLOPBaselineGrid = 3 |
||
12269 | cbradney | 153 | }; |
154 | |||
155 | |||
3878 | cbradney | 156 | #endif // SCTEXTSTRUCT_H |
157 |