summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/FontControl.h
authorgroucho <groucho>2003-05-07 09:01:39 (UTC)
committer groucho <groucho>2003-05-07 09:01:39 (UTC)
commit118d03d815a7615b9c53363218a7ac45b3f4c514 (patch) (unidiff)
tree356953e2413cddcec0f35bd47bb6439767da7051 /noncore/apps/opie-reader/FontControl.h
parent00894537decf01c5a5cdc565b2740b5e67a2e90f (diff)
downloadopie-118d03d815a7615b9c53363218a7ac45b3f4c514.zip
opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.gz
opie-118d03d815a7615b9c53363218a7ac45b3f4c514.tar.bz2
Incorporated TimWs current source tree and make it compile
Diffstat (limited to 'noncore/apps/opie-reader/FontControl.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-reader/FontControl.h63
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
@@ -8,14 +8,20 @@
8class FontControl 8class 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);
21 } 27 }
@@ -23,11 +29,16 @@ class FontControl
23 { 29 {
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();
33 if (tgt < 0) 44 if (tgt < 0)
@@ -46,7 +57,7 @@ class FontControl
46 QFontMetrics fm(f); 57 QFontMetrics fm(f);
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));
52 QFontMetrics fm(f); 63 QFontMetrics fm(f);
@@ -58,7 +69,7 @@ class FontControl
58 QFontMetrics fm(f); 69 QFontMetrics fm(f);
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));
64 QFontMetrics fm(f); 75 QFontMetrics fm(f);
@@ -70,7 +81,7 @@ class FontControl
70 QFontMetrics fm(f); 81 QFontMetrics fm(f);
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));
76 QFontMetrics fm(f); 87 QFontMetrics fm(f);
@@ -78,27 +89,65 @@ class FontControl
78 } 89 }
79 bool decreasesize() 90 bool decreasesize()
80 { 91 {
92/*
81 if (--m_size < 0) 93 if (--m_size < 0)
82 { 94 {
83 m_size = 0; 95 m_size = 0;
84 return false; 96 return false;
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 {
92 m_size = m_maxsize - 1; 115 m_size = m_maxsize - 1;
93 return false; 116 return false;
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)
98 { 131 {
99 return ChangeFont(n, currentsize()); 132 return ChangeFont(n, currentsize());
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
104#endif 153#endif