author | pohly <pohly> | 2004-08-24 20:52:45 (UTC) |
---|---|---|
committer | pohly <pohly> | 2004-08-24 20:52:45 (UTC) |
commit | 73253e93327cf4ef0932de1b4afb56af22a0f37e (patch) (unidiff) | |
tree | 1c9a7a6dd3341e036a894d348a3372525d29acec /noncore/apps/opie-reader/FontControl.h | |
parent | e90847c784c48bd21bf8768cb38edb853b832697 (diff) | |
download | opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.zip opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.gz opie-73253e93327cf4ef0932de1b4afb56af22a0f37e.tar.bz2 |
updated source to opie-reader 0.7g
Diffstat (limited to 'noncore/apps/opie-reader/FontControl.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/FontControl.h | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/noncore/apps/opie-reader/FontControl.h b/noncore/apps/opie-reader/FontControl.h index e56b619..90d39b2 100644 --- a/noncore/apps/opie-reader/FontControl.h +++ b/noncore/apps/opie-reader/FontControl.h | |||
@@ -1,10 +1,9 @@ | |||
1 | #ifndef __FONTCONTROL_H | 1 | #ifndef __FONTCONTROL_H |
2 | #define __FONTCONTROL_H | 2 | #define __FONTCONTROL_H |
3 | 3 | ||
4 | #include <qfontdatabase.h> | ||
5 | #include <qfontmetrics.h> | 4 | #include <qfontmetrics.h> |
6 | #include "StyleConsts.h" | 5 | #include "StyleConsts.h" |
7 | 6 | ||
8 | class FontControl | 7 | class FontControl |
9 | { | 8 | { |
10 | int * m_fontsizes; | 9 | int * m_fontsizes; |
@@ -12,19 +11,28 @@ class FontControl | |||
12 | QString m_fontname; | 11 | QString m_fontname; |
13 | QString m_fixedfontname; | 12 | QString m_fixedfontname; |
14 | int m_maxsize; | 13 | int m_maxsize; |
15 | bool m_hasCourier; | 14 | bool m_hasCourier; |
16 | int m_leading, m_extraspace; | 15 | int m_leading, m_extraspace; |
17 | unsigned char m_basesize; | 16 | unsigned char m_basesize; |
17 | bool m_fixgraphics; | ||
18 | public: | 18 | public: |
19 | void FixGraphics(bool _b) | ||
20 | { | ||
21 | m_fixgraphics = _b; | ||
22 | } | ||
23 | bool FixGraphics() | ||
24 | { | ||
25 | return m_fixgraphics; | ||
26 | } | ||
19 | void setBaseSize(unsigned char _s) { m_basesize = _s; } | 27 | void setBaseSize(unsigned char _s) { m_basesize = _s; } |
20 | unsigned char getBaseSize() { return m_basesize; } | 28 | unsigned char getBaseSize() { return m_basesize; } |
21 | int gzoom(); | 29 | int gzoom(); |
22 | FontControl(QString n = "helvetica", int size = 10) | 30 | FontControl(QString n = "helvetica", int size = 10) |
23 | : | 31 | : |
24 | m_fontsizes(NULL), m_hasCourier(false), m_leading(0), m_extraspace(0) | 32 | m_fontsizes(NULL), m_hasCourier(false), m_leading(0), m_extraspace(0), m_fixgraphics(true) |
25 | { | 33 | { |
26 | ChangeFont(n, size); | 34 | ChangeFont(n, size); |
27 | } | 35 | } |
28 | ~FontControl() | 36 | ~FontControl() |
29 | { | 37 | { |
30 | if (m_fontsizes != NULL) delete [] m_fontsizes; | 38 | if (m_fontsizes != NULL) delete [] m_fontsizes; |
@@ -34,16 +42,20 @@ class FontControl | |||
34 | m_hasCourier = _b; | 42 | m_hasCourier = _b; |
35 | m_fixedfontname = _nm; | 43 | m_fixedfontname = _nm; |
36 | } | 44 | } |
37 | QString& fixedfontname() { return m_fixedfontname; } | 45 | QString& fixedfontname() { return m_fixedfontname; } |
38 | bool hasCourier() { return m_hasCourier; } | 46 | bool hasCourier() { return m_hasCourier; } |
39 | QString name() { return m_fontname; } | 47 | QString name() { return m_fontname; } |
40 | int currentsize() { return m_fontsizes[m_size]; } | 48 | int currentsize() { return (m_fontsizes == NULL) ? 0 : m_fontsizes[m_size]; } |
41 | int getsize(const CStyle& size) | 49 | int getsize(const CStyle& size) |
42 | { | 50 | { |
43 | int tgt = m_size+size.getFontSize(); | 51 | return getsize(size.getFontSize()); |
52 | } | ||
53 | int getsize(int _offset) | ||
54 | { | ||
55 | int tgt = m_size+_offset; | ||
44 | if (tgt < 0) | 56 | if (tgt < 0) |
45 | { | 57 | { |
46 | tgt = 0; | 58 | tgt = 0; |
47 | } | 59 | } |
48 | if (tgt >= m_maxsize) | 60 | if (tgt >= m_maxsize) |
49 | { | 61 | { |
@@ -86,48 +98,55 @@ class FontControl | |||
86 | QFont f(name(), getsize(ch)); | 98 | QFont f(name(), getsize(ch)); |
87 | QFontMetrics fm(f); | 99 | QFontMetrics fm(f); |
88 | return fm.lineSpacing(); | 100 | return fm.lineSpacing(); |
89 | } | 101 | } |
90 | bool decreasesize() | 102 | bool decreasesize() |
91 | { | 103 | { |
92 | /* | 104 | if (m_fixgraphics) |
105 | { | ||
93 | if (--m_size < 0) | 106 | if (--m_size < 0) |
94 | { | 107 | { |
95 | m_size = 0; | 108 | m_size = 0; |
96 | return false; | 109 | return false; |
97 | } | 110 | } |
98 | else return true; | 111 | g_size = m_size; |
99 | */ | 112 | } |
113 | else | ||
114 | { | ||
100 | if (g_size-- == m_size) | 115 | if (g_size-- == m_size) |
101 | { | 116 | { |
102 | if (--m_size < 0) | 117 | if (--m_size < 0) |
103 | { | 118 | { |
104 | m_size = 0; | 119 | m_size = 0; |
105 | } | 120 | } |
106 | } | 121 | } |
107 | // odebug << "Font:" << m_size << " Graphics:" << g_size << oendl; | 122 | } |
123 | // qDebug("Font:%d Graphics:%d", m_size, g_size); | ||
108 | return true; | 124 | return true; |
109 | } | 125 | } |
110 | bool increasesize() | 126 | bool increasesize() |
111 | { | 127 | { |
112 | /* | 128 | if (m_fixgraphics) |
129 | { | ||
113 | if (++m_size >= m_maxsize) | 130 | if (++m_size >= m_maxsize) |
114 | { | 131 | { |
115 | m_size = m_maxsize - 1; | 132 | m_size = m_maxsize - 1; |
116 | return false; | 133 | return false; |
117 | } | 134 | } |
118 | else return true; | 135 | g_size = m_size; |
119 | */ | 136 | } |
137 | else | ||
138 | { | ||
120 | if (g_size++ == m_size) | 139 | if (g_size++ == m_size) |
121 | { | 140 | { |
122 | if (++m_size >= m_maxsize) | 141 | if (++m_size >= m_maxsize) |
123 | { | 142 | { |
124 | m_size = m_maxsize - 1; | 143 | m_size = m_maxsize - 1; |
125 | } | 144 | } |
126 | } | 145 | } |
127 | // odebug << "Font:" << m_size << " Graphics:" << g_size << oendl; | 146 | } |
128 | return true; | 147 | return true; |
129 | } | 148 | } |
130 | bool ChangeFont(QString& n) | 149 | bool ChangeFont(QString& n) |
131 | { | 150 | { |
132 | return ChangeFont(n, currentsize()); | 151 | return ChangeFont(n, currentsize()); |
133 | } | 152 | } |