summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/StyleConsts.h
Unidiff
Diffstat (limited to 'noncore/apps/opie-reader/StyleConsts.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/StyleConsts.h192
1 files changed, 128 insertions, 64 deletions
diff --git a/noncore/apps/opie-reader/StyleConsts.h b/noncore/apps/opie-reader/StyleConsts.h
index b6dd861..5aacdf0 100644
--- a/noncore/apps/opie-reader/StyleConsts.h
+++ b/noncore/apps/opie-reader/StyleConsts.h
@@ -3,111 +3,175 @@
3 3
4typedef unsigned short StyleType; 4typedef unsigned short StyleType;
5 5
6class CStyle 6#include <stdlib.h>
7#include <qglobal.h>
8class QPixmap;
9
10struct GraphicLink
7{ 11{
8// 15 14 13-5 4 3 2 1 0 12 QPixmap* graphic;
9//bold italic spare align align fs fs fs 13 bool isLink;
10 static const StyleType m_Bold = 1 << 15; 14 unsigned long link;
11 static const StyleType m_Italic = 1 << 14; 15 GraphicLink(QPixmap* p, bool isLnk, unsigned long tgt) :
12 static const StyleType m_FontMask = 7; 16 graphic(p), isLink(isLnk), link(tgt) {}
13 static const StyleType m_FontBase = 3; 17 ~GraphicLink();
14 18};
15 static const StyleType m_AlignShift = 3;
16 static const StyleType m_AlignMask = 3 << m_AlignShift;
17 static const StyleType m_EveryBit = 0xffff;
18 19
20struct pmstore
21{
22 unsigned int count;
23 GraphicLink* graphic;
24 pmstore(QPixmap* p, bool isLnk, unsigned long tgt) : count(1)
25 {
26 graphic = new GraphicLink(p, isLnk, tgt);
27 }
28 ~pmstore();
29};
19 30
20 StyleType sty; 31enum EalignmentType
32{
33 m_AlignLeft,
34 m_AlignRight,
35 m_AlignCentre,
36 m_AlignJustify
37};
21 38
22 void unjustify() { sty &= m_EveryBit ^ m_AlignMask; } 39class CBasicStyle
40{
41 friend class CStyle;
42 bool m_bold,
43 m_italic;
44 int m_fontsize;
45 EalignmentType m_align;
23 unsigned char red, green, blue; 46 unsigned char red, green, blue;
24 unsigned long data; 47 unsigned long data;
25 bool isLink; 48 bool isLink;
26 public: 49 bool m_underline;
27 unsigned char Red() { return red; } 50 bool m_strikethru;
28 unsigned char Green() { return green; } 51 bool m_monospaced;
29 unsigned char Blue() { return blue; } 52 unsigned char m_leftmargin, m_rightmargin;
30 void setColour(unsigned char r, unsigned char g, unsigned char b) 53 CBasicStyle()
31 { 54 {
32 red = r; 55 unset();
33 green = g; 56 }
34 blue = b; 57 bool operator!=(const CBasicStyle& rhs)
35 } 58 {
36 static const StyleType m_AlignLeft = 0; 59 return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0);
37 static const StyleType m_AlignRight = 1 << m_AlignShift; 60 }
38 static const StyleType m_AlignCentre = 2 << m_AlignShift;
39 static const StyleType m_AlignJustify = 3 << m_AlignShift;
40 CStyle()
41 :
42 sty(m_FontBase),
43 red(0), green(0), blue(0),
44 data(0), isLink(false)
45 {}
46// CStyle(const int _fs) : sty(m_FontBase+_fs) {}
47
48 void unset() 61 void unset()
49 { 62 {
50 sty = m_FontBase; 63 m_bold = false;
64 m_italic = false;
65 m_fontsize = 0;
66 m_align = m_AlignLeft;
51 red = green = blue = 0; 67 red = green = blue = 0;
52 data = 0; 68 data = 0;
53 isLink = false; 69 isLink = false;
70 m_underline = false;
71 m_strikethru = false;
72 m_leftmargin = 0;
73 m_rightmargin = 0;
74 m_monospaced = false;
54 } 75 }
76};
55 77
56 void setBold() { sty |= m_Bold; } 78class CStyle
57 void setItalic() { sty |= m_Italic; } 79{
58 void unsetBold() { sty &= m_EveryBit ^ m_Bold; } 80 CBasicStyle sty;
59 void unsetItalic() { sty &= m_EveryBit ^ m_Italic; } 81 pmstore* graphic;
60 bool isBold() { return ((sty & m_Bold) != 0); } 82 public:
61 bool isItalic() { return ((sty & m_Italic) != 0); } 83 bool getPictureLink()
84 {
85 return (graphic != NULL && graphic->graphic->isLink);
86 }
87 unsigned long getPictureLinkData()
88 {
89 return graphic->graphic->link;
90 }
91 void setLeftMargin(unsigned char m) { sty.m_leftmargin = m; }
92 unsigned char getLeftMargin() { return sty.m_leftmargin; }
93 void setRightMargin(unsigned char m) { sty.m_rightmargin = m; }
94 unsigned char getRightMargin() { return sty.m_rightmargin; }
95 unsigned char Red() { return sty.red; }
96 unsigned char Green() { return sty.green; }
97 unsigned char Blue() { return sty.blue; }
98 void setColour(unsigned char r, unsigned char g, unsigned char b)
99 {
100 sty.red = r;
101 sty.green = g;
102 sty.blue = b;
103 }
104 CStyle() : graphic(NULL) {}
105 ~CStyle();
106 CStyle(CStyle&);
107 CStyle(const CStyle&);
108 CStyle& operator=(const CStyle&);
109 void unset();
110 bool isPicture() { return (graphic != NULL); }
111 void clearPicture();
112 void setPicture(QPixmap* _g, bool il=false, unsigned long tgt=0);
113 QPixmap* getPicture()
114 {
115 QPixmap* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL);
116 return pm;
117 }
118 void setUnderline() { sty.m_underline = true; }
119 void unsetUnderline() { sty.m_underline = false; }
120 bool isUnderline() { return sty.m_underline; }
121 void setStrikethru() { sty.m_strikethru = true; }
122 void unsetStrikethru() { sty.m_strikethru = false; }
123 bool isStrikethru() { return sty.m_strikethru; }
124 void setBold() { sty.m_bold = true; }
125 void unsetBold() { sty.m_bold = false; }
126 bool isBold() { return sty.m_bold; }
127 void setItalic() { sty.m_italic = true; }
128 void unsetItalic() { sty.m_italic = false; }
129 bool isItalic() { return sty.m_italic; }
130 void setMono() { sty.m_monospaced = true; }
131 void unsetMono() { sty.m_monospaced = false; }
132 bool isMono() { return sty.m_monospaced; }
62 133
63 void setLeftJustify() 134 void setLeftJustify()
64 { 135 {
65 unjustify(); 136 sty.m_align = m_AlignLeft;
66 sty |= m_AlignLeft;
67 } 137 }
68 void setRightJustify() 138 void setRightJustify()
69 { 139 {
70 unjustify(); 140 sty.m_align = m_AlignRight;
71 sty |= m_AlignRight;
72 } 141 }
73 void setCentreJustify() 142 void setCentreJustify()
74 { 143 {
75 unjustify(); 144 sty.m_align = m_AlignCentre;
76 sty |= m_AlignCentre;
77 } 145 }
78 void setFullJustify() 146 void setFullJustify()
79 { 147 {
80 unjustify(); 148 sty.m_align = m_AlignJustify;
81 sty |= m_AlignJustify;
82 } 149 }
83 StyleType getJustify() 150 StyleType getJustify()
84 { 151 {
85 return sty & m_AlignMask; 152 return sty.m_align;
86 } 153 }
87 154
88 void setFontSize(int _fs) 155 void setFontSize(int _fs)
89 { 156 {
90 sty &= m_EveryBit ^ m_FontMask; 157 sty.m_fontsize = _fs;
91 sty |= m_FontBase + _fs;
92 } 158 }
93 int getFontSize() 159 int getFontSize()
94 { 160 {
95 return (sty & m_FontMask) - m_FontBase; 161 return sty.m_fontsize;
96 } 162 }
97 bool operator!=(const CStyle& rhs) 163 bool operator!=(const CStyle& rhs)
98 { 164 {
99 return 165 return
100 ( 166 (
101 (sty != rhs.sty) || (red != rhs.red) || (green != rhs.green) || 167 (sty != rhs.sty) ||
102 (blue != rhs.blue) || 168 (graphic != rhs.graphic)
103 (data != rhs.data) || 169 );
104 (isLink != rhs.isLink) 170 }
105 ); 171 void setLink(bool _l) { sty.isLink = _l; }
106 } 172 bool getLink() { return sty.isLink; }
107 void setLink(bool _l) { isLink = _l; } 173 void setData(unsigned long _d) { sty.data = _d; }
108 bool getLink() { return isLink; } 174 unsigned long getData() { return sty.data; }
109 void setData(unsigned long _d) { data = _d; }
110 unsigned long getData() { return data; }
111}; 175};
112 176
113#endif 177#endif