Diffstat (limited to 'noncore/apps/opie-reader/StyleConsts.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/StyleConsts.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/StyleConsts.h b/noncore/apps/opie-reader/StyleConsts.h index 8e23c6f..4b7ff4b 100644 --- a/noncore/apps/opie-reader/StyleConsts.h +++ b/noncore/apps/opie-reader/StyleConsts.h | |||
@@ -9,90 +9,93 @@ typedef unsigned short StyleType; | |||
9 | #include <string.h> | 9 | #include <string.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <qglobal.h> | 11 | #include <qglobal.h> |
12 | class QImage; | 12 | class QImage; |
13 | 13 | ||
14 | struct GraphicLink | 14 | struct GraphicLink |
15 | { | 15 | { |
16 | QImage* graphic; | 16 | QImage* graphic; |
17 | bool isLink; | 17 | bool isLink; |
18 | unsigned long link; | 18 | unsigned long link; |
19 | GraphicLink(QImage* p, bool isLnk, unsigned long tgt) : | 19 | GraphicLink(QImage* p, bool isLnk, unsigned long tgt) : |
20 | graphic(p), isLink(isLnk), link(tgt) {} | 20 | graphic(p), isLink(isLnk), link(tgt) {} |
21 | ~GraphicLink(); | 21 | ~GraphicLink(); |
22 | }; | 22 | }; |
23 | 23 | ||
24 | struct pmstore | 24 | struct pmstore |
25 | { | 25 | { |
26 | unsigned int count; | 26 | unsigned int count; |
27 | bool m_isScaleable; | 27 | bool m_isScaleable; |
28 | GraphicLink* graphic; | 28 | GraphicLink* graphic; |
29 | pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale) | 29 | pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale) |
30 | { | 30 | { |
31 | graphic = new GraphicLink(p, isLnk, tgt); | 31 | graphic = new GraphicLink(p, isLnk, tgt); |
32 | } | 32 | } |
33 | ~pmstore(); | 33 | ~pmstore(); |
34 | }; | 34 | }; |
35 | 35 | ||
36 | enum EalignmentType | 36 | enum EalignmentType |
37 | { | 37 | { |
38 | m_AlignLeft, | 38 | m_AlignLeft, |
39 | m_AlignRight, | 39 | m_AlignRight, |
40 | m_AlignCentre, | 40 | m_AlignCentre, |
41 | m_AlignJustify | 41 | m_AlignJustify, |
42 | m_AlignNone | ||
42 | }; | 43 | }; |
43 | 44 | ||
44 | class CBasicStyle | 45 | class CBasicStyle |
45 | { | 46 | { |
46 | friend class CStyle; | 47 | friend class CStyle; |
47 | bool m_bold, | 48 | bool m_bold, |
48 | m_italic; | 49 | m_italic; |
50 | unsigned long m_table; | ||
49 | int m_fontsize; | 51 | int m_fontsize; |
50 | EalignmentType m_align; | 52 | EalignmentType m_align; |
51 | unsigned char red, green, blue; | 53 | unsigned char red, green, blue; |
52 | unsigned char bred, bgreen, bblue; | 54 | unsigned char bred, bgreen, bblue; |
53 | unsigned char pred, pgreen, pblue; | 55 | unsigned char pred, pgreen, pblue; |
54 | unsigned long data; | 56 | unsigned long data; |
55 | unsigned long offset; | 57 | unsigned long offset; |
56 | bool isLink; | 58 | bool isLink; |
57 | // bool isVisited; | 59 | // bool isVisited; |
58 | bool m_underline; | 60 | bool m_underline; |
59 | bool m_strikethru; | 61 | bool m_strikethru; |
60 | bool m_monospaced; | 62 | bool m_monospaced; |
61 | unsigned char m_leftmargin, m_rightmargin; | 63 | unsigned char m_leftmargin, m_rightmargin; |
62 | signed char m_extraspace; | 64 | signed char m_extraspace; |
63 | signed char m_voffset; | 65 | signed char m_voffset; |
64 | CBasicStyle() | 66 | CBasicStyle() |
65 | { | 67 | { |
66 | unset(); | 68 | unset(); |
69 | m_table = 0xffffffff; | ||
67 | } | 70 | } |
68 | bool operator!=(const CBasicStyle& rhs) | 71 | bool operator!=(const CBasicStyle& rhs) |
69 | { | 72 | { |
70 | return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0); | 73 | return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0); |
71 | } | 74 | } |
72 | void unset() | 75 | void unset() |
73 | { | 76 | { |
74 | m_bold = false; | 77 | m_bold = false; |
75 | m_italic = false; | 78 | m_italic = false; |
76 | m_fontsize = 0; | 79 | m_fontsize = 0; |
77 | m_align = m_AlignLeft; | 80 | m_align = m_AlignLeft; |
78 | red = green = blue = 0; | 81 | red = green = blue = 0; |
79 | bred = bgreen = bblue = 255; | 82 | bred = bgreen = bblue = 255; |
80 | pred = pgreen = pblue = 255; | 83 | pred = pgreen = pblue = 255; |
81 | data = 0; | 84 | data = 0; |
82 | offset = 0; | 85 | offset = 0; |
83 | isLink = false; | 86 | isLink = false; |
84 | // isVisited = false; | 87 | // isVisited = false; |
85 | m_underline = false; | 88 | m_underline = false; |
86 | m_strikethru = false; | 89 | m_strikethru = false; |
87 | m_leftmargin = 0; | 90 | m_leftmargin = 0; |
88 | m_rightmargin = 0; | 91 | m_rightmargin = 0; |
89 | m_monospaced = false; | 92 | m_monospaced = false; |
90 | m_extraspace = 0; | 93 | m_extraspace = 0; |
91 | m_voffset = 0; | 94 | m_voffset = 0; |
92 | } | 95 | } |
93 | }; | 96 | }; |
94 | 97 | ||
95 | class CStyle | 98 | class CStyle |
96 | { | 99 | { |
97 | CBasicStyle sty; | 100 | CBasicStyle sty; |
98 | pmstore* graphic; | 101 | pmstore* graphic; |
@@ -117,105 +120,112 @@ class CStyle | |||
117 | unsigned char Green() { return sty.green; } | 120 | unsigned char Green() { return sty.green; } |
118 | unsigned char Blue() { return sty.blue; } | 121 | unsigned char Blue() { return sty.blue; } |
119 | void setColour(unsigned char r, unsigned char g, unsigned char b) | 122 | void setColour(unsigned char r, unsigned char g, unsigned char b) |
120 | { | 123 | { |
121 | sty.red = r; | 124 | sty.red = r; |
122 | sty.green = g; | 125 | sty.green = g; |
123 | sty.blue = b; | 126 | sty.blue = b; |
124 | } | 127 | } |
125 | unsigned char bRed() { return sty.bred; } | 128 | unsigned char bRed() { return sty.bred; } |
126 | unsigned char bGreen() { return sty.bgreen; } | 129 | unsigned char bGreen() { return sty.bgreen; } |
127 | unsigned char bBlue() { return sty.bblue; } | 130 | unsigned char bBlue() { return sty.bblue; } |
128 | unsigned char pRed() { return sty.pred; } | 131 | unsigned char pRed() { return sty.pred; } |
129 | unsigned char pGreen() { return sty.pgreen; } | 132 | unsigned char pGreen() { return sty.pgreen; } |
130 | unsigned char pBlue() { return sty.pblue; } | 133 | unsigned char pBlue() { return sty.pblue; } |
131 | void setPaper(unsigned char r, unsigned char g, unsigned char b) | 134 | void setPaper(unsigned char r, unsigned char g, unsigned char b) |
132 | { | 135 | { |
133 | sty.pred = r; | 136 | sty.pred = r; |
134 | sty.pgreen = g; | 137 | sty.pgreen = g; |
135 | sty.pblue = b; | 138 | sty.pblue = b; |
136 | } | 139 | } |
137 | void setBackground(unsigned char r, unsigned char g, unsigned char b) | 140 | void setBackground(unsigned char r, unsigned char g, unsigned char b) |
138 | { | 141 | { |
139 | sty.bred = r; | 142 | sty.bred = r; |
140 | sty.bgreen = g; | 143 | sty.bgreen = g; |
141 | sty.bblue = b; | 144 | sty.bblue = b; |
142 | } | 145 | } |
143 | CStyle() : graphic(NULL) {} | 146 | CStyle() : graphic(NULL) {} |
144 | ~CStyle(); | 147 | ~CStyle(); |
145 | // CStyle(CStyle&); | 148 | // CStyle(CStyle&); |
146 | CStyle(const CStyle&); | 149 | CStyle(const CStyle&); |
147 | CStyle& operator=(const CStyle&); | 150 | CStyle& operator=(const CStyle&); |
148 | void unset(); | 151 | void unset(); |
152 | bool isTable() const { return (sty.m_table != 0xffffffff); } | ||
153 | void setTable(unsigned long _b) { sty.m_table = _b; } | ||
154 | unsigned long getTable() { return sty.m_table; } | ||
149 | bool isPicture() const { return (graphic != NULL); } | 155 | bool isPicture() const { return (graphic != NULL); } |
150 | bool canScale() const { return graphic->m_isScaleable; } | 156 | bool canScale() const { return graphic->m_isScaleable; } |
151 | void clearPicture(); | 157 | void clearPicture(); |
152 | void setPicture(bool canScale, QImage* _g, bool il=false, unsigned long tgt=0); | 158 | void setPicture(bool canScale, QImage* _g, bool il=false, unsigned long tgt=0); |
153 | QImage* getPicture() | 159 | QImage* getPicture() |
154 | { | 160 | { |
155 | QImage* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL); | 161 | QImage* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL); |
156 | return pm; | 162 | return pm; |
157 | } | 163 | } |
158 | void setUnderline() { sty.m_underline = true; } | 164 | void setUnderline() { sty.m_underline = true; } |
159 | void unsetUnderline() { sty.m_underline = false; } | 165 | void unsetUnderline() { sty.m_underline = false; } |
160 | bool isUnderline() { return sty.m_underline; } | 166 | bool isUnderline() { return sty.m_underline; } |
161 | void setStrikethru() { sty.m_strikethru = true; } | 167 | void setStrikethru() { sty.m_strikethru = true; } |
162 | void unsetStrikethru() { sty.m_strikethru = false; } | 168 | void unsetStrikethru() { sty.m_strikethru = false; } |
163 | bool isStrikethru() { return sty.m_strikethru; } | 169 | bool isStrikethru() { return sty.m_strikethru; } |
164 | void setBold() { sty.m_bold = true; } | 170 | void setBold() { sty.m_bold = true; } |
165 | void unsetBold() { sty.m_bold = false; } | 171 | void unsetBold() { sty.m_bold = false; } |
166 | bool isBold() { return sty.m_bold; } | 172 | bool isBold() { return sty.m_bold; } |
167 | void setItalic() { sty.m_italic = true; } | 173 | void setItalic() { sty.m_italic = true; } |
168 | void unsetItalic() { sty.m_italic = false; } | 174 | void unsetItalic() { sty.m_italic = false; } |
169 | bool isItalic() { return sty.m_italic; } | 175 | bool isItalic() { return sty.m_italic; } |
170 | void setMono() { sty.m_monospaced = true; } | 176 | void setMono() { sty.m_monospaced = true; } |
171 | void unsetMono() { sty.m_monospaced = false; } | 177 | void unsetMono() { sty.m_monospaced = false; } |
172 | bool isMono() { return sty.m_monospaced; } | 178 | bool isMono() { return sty.m_monospaced; } |
173 | 179 | ||
174 | void setLeftJustify() | 180 | void setLeftJustify() |
175 | { | 181 | { |
176 | sty.m_align = m_AlignLeft; | 182 | sty.m_align = m_AlignLeft; |
177 | } | 183 | } |
178 | void setRightJustify() | 184 | void setRightJustify() |
179 | { | 185 | { |
180 | sty.m_align = m_AlignRight; | 186 | sty.m_align = m_AlignRight; |
181 | } | 187 | } |
182 | void setCentreJustify() | 188 | void setCentreJustify() |
183 | { | 189 | { |
184 | sty.m_align = m_AlignCentre; | 190 | sty.m_align = m_AlignCentre; |
185 | } | 191 | } |
186 | void setFullJustify() | 192 | void setFullJustify() |
187 | { | 193 | { |
188 | sty.m_align = m_AlignJustify; | 194 | sty.m_align = m_AlignJustify; |
189 | } | 195 | } |
196 | void setNoJustify() | ||
197 | { | ||
198 | sty.m_align = m_AlignNone; | ||
199 | } | ||
190 | StyleType getJustify() | 200 | StyleType getJustify() |
191 | { | 201 | { |
192 | return sty.m_align; | 202 | return sty.m_align; |
193 | } | 203 | } |
194 | 204 | ||
195 | void setFontSize(int _fs) | 205 | void setFontSize(int _fs) |
196 | { | 206 | { |
197 | sty.m_fontsize = _fs; | 207 | sty.m_fontsize = _fs; |
198 | } | 208 | } |
199 | int getFontSize() const | 209 | int getFontSize() const |
200 | { | 210 | { |
201 | return sty.m_fontsize; | 211 | return sty.m_fontsize; |
202 | } | 212 | } |
203 | bool operator!=(const CStyle& rhs) | 213 | bool operator!=(const CStyle& rhs) |
204 | { | 214 | { |
205 | return | 215 | return |
206 | ( | 216 | ( |
207 | (sty != rhs.sty) || | 217 | (sty != rhs.sty) || |
208 | (graphic != rhs.graphic) | 218 | (graphic != rhs.graphic) |
209 | ); | 219 | ); |
210 | } | 220 | } |
211 | void setLink(bool _l) { sty.isLink = _l; } | 221 | void setLink(bool _l) { sty.isLink = _l; } |
212 | bool getLink() { return sty.isLink; } | 222 | bool getLink() { return sty.isLink; } |
213 | // void setVisited(bool _l) { sty.isVisited = _l; } | 223 | // void setVisited(bool _l) { sty.isVisited = _l; } |
214 | // bool getVisited() { return sty.isVisited; } | 224 | // bool getVisited() { return sty.isVisited; } |
215 | void setData(unsigned long _d) { sty.data = _d; } | 225 | void setData(unsigned long _d) { sty.data = _d; } |
216 | unsigned long getData() { return sty.data; } | 226 | unsigned long getData() { return sty.data; } |
217 | void setOffset(unsigned long _d) { sty.offset = _d; } | 227 | void setOffset(unsigned long _d) { sty.offset = _d; } |
218 | unsigned long getOffset() { return sty.offset; } | 228 | unsigned long getOffset() { return sty.offset; } |
219 | void invert(); | 229 | void invert(); |
220 | }; | 230 | }; |
221 | 231 | ||