summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/StyleConsts.h
blob: 5817b540435b5aaf26ead9946540a0ab8c2a3176 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#ifndef __STYLECONSTS_H
#define __STYLECONSTS_H

typedef unsigned short StyleType;

#include <string.h>
#include <stdlib.h>
#include <qglobal.h>
class QImage;

struct GraphicLink
{
    QImage* graphic;
    bool isLink;
    unsigned long link;
    GraphicLink(QImage* p, bool isLnk, unsigned long tgt) :
	graphic(p), isLink(isLnk), link(tgt) {}
    ~GraphicLink();
};

struct pmstore
{
    unsigned int count;
    bool m_isScaleable;
    GraphicLink*     graphic;
    pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale)
	{
	    graphic = new GraphicLink(p, isLnk, tgt);
	}
    ~pmstore();
};

enum EalignmentType
{
    m_AlignLeft,
    m_AlignRight,
    m_AlignCentre,
    m_AlignJustify
};

class CBasicStyle
{
    friend class CStyle;
    bool m_bold,
	m_italic;
    int m_fontsize;
    EalignmentType m_align;
    unsigned char red, green, blue;
    unsigned long data;
    bool isLink;
    bool m_underline;
    bool m_strikethru;
    bool m_monospaced;
    unsigned char m_leftmargin, m_rightmargin;
    signed char m_extraspace;
    signed char m_voffset;
    CBasicStyle()
	{
	    unset();
	}
    bool operator!=(const CBasicStyle& rhs)
	{
	    return (memcmp(this, &rhs, sizeof(CBasicStyle)) != 0);
	}
    void unset()
	{
	    m_bold = false;
	    m_italic = false;
	    m_fontsize = 0;
	    m_align = m_AlignLeft;
	    red = green = blue = 0;
	    data = 0;
	    isLink = false;
	    m_underline = false;
	    m_strikethru = false;
	    m_leftmargin = 0;
	    m_rightmargin = 0;
	    m_monospaced = false;
	    m_extraspace = 0;
	    m_voffset = 0;
	}
};

class CStyle
{
    CBasicStyle sty;
    pmstore* graphic;
 public:
    signed char getVOffset() { return sty.m_voffset; }
    void setVOffset(signed char sp) { sty.m_voffset = sp; }
    signed char getExtraSpace() { return sty.m_extraspace; }
    void setExtraSpace(signed char sp) { sty.m_extraspace = sp; }
    bool getPictureLink()
	{
	    return (graphic != NULL && graphic->graphic->isLink);
	}
    unsigned long getPictureLinkData()
	{
	    return graphic->graphic->link;
	}
    void setLeftMargin(unsigned char m) { sty.m_leftmargin = m; }
    unsigned char getLeftMargin() { return sty.m_leftmargin; }
    void setRightMargin(unsigned char m) { sty.m_rightmargin = m; }
    unsigned char getRightMargin() { return sty.m_rightmargin; }
    unsigned char Red() { return sty.red; }
    unsigned char Green() { return sty.green; }
    unsigned char Blue() { return sty.blue; }
    void setColour(unsigned char r, unsigned char g, unsigned char b)
	{
	    sty.red = r;
	    sty.green = g;
	    sty.blue = b;
	}
    CStyle() : graphic(NULL) {}
    ~CStyle();
//    CStyle(CStyle&);
    CStyle(const CStyle&);
    CStyle& operator=(const CStyle&);
    void unset();
    bool isPicture() { return (graphic != NULL); }
    bool canScale() { return graphic->m_isScaleable; }
    void clearPicture();
    void setPicture(bool canScale, QImage* _g, bool il=false, unsigned long tgt=0);
    QImage* getPicture()
	{ 
	    QImage* pm = ((graphic != NULL) ? graphic->graphic->graphic : NULL);
	    return pm;
	}
    void setUnderline() { sty.m_underline = true; }
    void unsetUnderline() { sty.m_underline = false; }
    bool isUnderline() { return sty.m_underline; }
    void setStrikethru() { sty.m_strikethru = true; }
    void unsetStrikethru() { sty.m_strikethru = false; }
    bool isStrikethru() { return sty.m_strikethru; }
    void setBold() { sty.m_bold = true; }
    void unsetBold() { sty.m_bold = false; }
    bool isBold() { return sty.m_bold; }
    void setItalic() { sty.m_italic = true; }
    void unsetItalic() { sty.m_italic = false; }
    bool isItalic() { return sty.m_italic; }
    void setMono() { sty.m_monospaced = true; }
    void unsetMono() { sty.m_monospaced = false; }
    bool isMono() { return sty.m_monospaced; }

    void setLeftJustify()
	{
	    sty.m_align = m_AlignLeft;
	}
    void setRightJustify()
	{
	    sty.m_align = m_AlignRight;
	}
    void setCentreJustify()
	{
	    sty.m_align = m_AlignCentre;
	}
    void setFullJustify()
	{
	    sty.m_align = m_AlignJustify;
	}
    StyleType getJustify()
	{
	    return sty.m_align;
	}

    void setFontSize(int _fs)
	{
	    sty.m_fontsize = _fs;
	}
    int getFontSize() const
	{
	    return sty.m_fontsize;
	}
    bool operator!=(const CStyle& rhs)
	{
	    return
		(
		    (sty != rhs.sty) ||
		    (graphic != rhs.graphic)
		    );
	}
    void setLink(bool _l) { sty.isLink = _l; }
    bool getLink() { return sty.isLink; }
    void setData(unsigned long _d) { sty.data = _d; }
    unsigned long getData() { return sty.data; }
};

#endif