Diffstat (limited to 'noncore/apps/opie-reader/FontControl.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/FontControl.h | 63 |
1 files changed, 56 insertions, 7 deletions
diff --git a/noncore/apps/opie-reader/FontControl.h b/noncore/apps/opie-reader/FontControl.h index 02049d0..5681496 100644 --- a/noncore/apps/opie-reader/FontControl.h +++ b/noncore/apps/opie-reader/FontControl.h | |||
@@ -9,12 +9,18 @@ class FontControl | |||
9 | { | 9 | { |
10 | int * m_fontsizes; | 10 | int * m_fontsizes; |
11 | int m_size; | 11 | int m_size, g_size; |
12 | QString m_fontname; | 12 | QString m_fontname; |
13 | QString m_fixedfontname; | ||
13 | int m_maxsize; | 14 | int m_maxsize; |
14 | bool m_hasCourier; | 15 | bool m_hasCourier; |
16 | int m_leading, m_extraspace; | ||
17 | unsigned char m_basesize; | ||
15 | public: | 18 | public: |
19 | void setBaseSize(unsigned char _s) { m_basesize = _s; } | ||
20 | unsigned char getBaseSize() { return m_basesize; } | ||
21 | int gzoom(); | ||
16 | FontControl(QString n = "helvetica", int size = 10) | 22 | FontControl(QString n = "helvetica", int size = 10) |
17 | : | 23 | : |
18 | m_fontsizes(NULL), m_hasCourier(false) | 24 | m_fontsizes(NULL), m_hasCourier(false), m_leading(0), m_extraspace(0) |
19 | { | 25 | { |
20 | ChangeFont(n, size); | 26 | ChangeFont(n, size); |
@@ -24,9 +30,14 @@ class FontControl | |||
24 | if (m_fontsizes != NULL) delete [] m_fontsizes; | 30 | if (m_fontsizes != NULL) delete [] m_fontsizes; |
25 | } | 31 | } |
26 | void hasCourier(bool _b) { m_hasCourier = _b; } | 32 | void hasCourier(bool _b, const QString& _nm) |
33 | { | ||
34 | m_hasCourier = _b; | ||
35 | m_fixedfontname = _nm; | ||
36 | } | ||
37 | QString& fixedfontname() { return m_fixedfontname; } | ||
27 | bool hasCourier() { return m_hasCourier; } | 38 | bool hasCourier() { return m_hasCourier; } |
28 | QString name() { return m_fontname; } | 39 | QString name() { return m_fontname; } |
29 | int currentsize() { return m_fontsizes[m_size]; } | 40 | int currentsize() { return m_fontsizes[m_size]; } |
30 | int getsize(CStyle size) | 41 | int getsize(const CStyle& size) |
31 | { | 42 | { |
32 | int tgt = m_size+size.getFontSize(); | 43 | int tgt = m_size+size.getFontSize(); |
@@ -47,5 +58,5 @@ class FontControl | |||
47 | return fm.ascent(); | 58 | return fm.ascent(); |
48 | } | 59 | } |
49 | int ascent(CStyle ch) | 60 | int ascent(const CStyle& ch) |
50 | { | 61 | { |
51 | QFont f(name(), getsize(ch)); | 62 | QFont f(name(), getsize(ch)); |
@@ -59,5 +70,5 @@ class FontControl | |||
59 | return fm.descent(); | 70 | return fm.descent(); |
60 | } | 71 | } |
61 | int descent(CStyle ch) | 72 | int descent(const CStyle& ch) |
62 | { | 73 | { |
63 | QFont f(name(), getsize(ch)); | 74 | QFont f(name(), getsize(ch)); |
@@ -71,5 +82,5 @@ class FontControl | |||
71 | return fm.lineSpacing(); | 82 | return fm.lineSpacing(); |
72 | } | 83 | } |
73 | int lineSpacing(CStyle ch) | 84 | int lineSpacing(const CStyle& ch) |
74 | { | 85 | { |
75 | QFont f(name(), getsize(ch)); | 86 | QFont f(name(), getsize(ch)); |
@@ -79,4 +90,5 @@ class FontControl | |||
79 | bool decreasesize() | 90 | bool decreasesize() |
80 | { | 91 | { |
92 | /* | ||
81 | if (--m_size < 0) | 93 | if (--m_size < 0) |
82 | { | 94 | { |
@@ -85,7 +97,18 @@ class FontControl | |||
85 | } | 97 | } |
86 | else return true; | 98 | else return true; |
99 | */ | ||
100 | if (g_size-- == m_size) | ||
101 | { | ||
102 | if (--m_size < 0) | ||
103 | { | ||
104 | m_size = 0; | ||
105 | } | ||
106 | } | ||
107 | // qDebug("Font:%d Graphics:%d", m_size, g_size); | ||
108 | return true; | ||
87 | } | 109 | } |
88 | bool increasesize() | 110 | bool increasesize() |
89 | { | 111 | { |
112 | /* | ||
90 | if (++m_size >= m_maxsize) | 113 | if (++m_size >= m_maxsize) |
91 | { | 114 | { |
@@ -94,4 +117,14 @@ class FontControl | |||
94 | } | 117 | } |
95 | else return true; | 118 | else return true; |
119 | */ | ||
120 | if (g_size++ == m_size) | ||
121 | { | ||
122 | if (++m_size >= m_maxsize) | ||
123 | { | ||
124 | m_size = m_maxsize - 1; | ||
125 | } | ||
126 | } | ||
127 | // qDebug("Font:%d Graphics:%d", m_size, g_size); | ||
128 | return true; | ||
96 | } | 129 | } |
97 | bool ChangeFont(QString& n) | 130 | bool ChangeFont(QString& n) |
@@ -100,4 +133,20 @@ class FontControl | |||
100 | } | 133 | } |
101 | bool ChangeFont(QString& n, int tgt); | 134 | bool ChangeFont(QString& n, int tgt); |
135 | void setlead(int _lead) | ||
136 | { | ||
137 | m_leading = _lead; | ||
138 | } | ||
139 | int getlead() | ||
140 | { | ||
141 | return m_leading; | ||
142 | } | ||
143 | void setextraspace(int _lead) | ||
144 | { | ||
145 | m_extraspace = _lead; | ||
146 | } | ||
147 | int getextraspace() | ||
148 | { | ||
149 | return m_extraspace; | ||
150 | } | ||
102 | }; | 151 | }; |
103 | 152 | ||