summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/FontControl.h
authorpohly <pohly>2004-08-24 20:52:45 (UTC)
committer pohly <pohly>2004-08-24 20:52:45 (UTC)
commit73253e93327cf4ef0932de1b4afb56af22a0f37e (patch) (side-by-side diff)
tree1c9a7a6dd3341e036a894d348a3372525d29acec /noncore/apps/opie-reader/FontControl.h
parente90847c784c48bd21bf8768cb38edb853b832697 (diff)
downloadopie-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) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/FontControl.h209
1 files changed, 114 insertions, 95 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,7 +1,6 @@
#ifndef __FONTCONTROL_H
#define __FONTCONTROL_H
-#include <qfontdatabase.h>
#include <qfontmetrics.h>
#include "StyleConsts.h"
@@ -15,139 +14,159 @@ class FontControl
bool m_hasCourier;
int m_leading, m_extraspace;
unsigned char m_basesize;
+ bool m_fixgraphics;
public:
+ void FixGraphics(bool _b)
+ {
+ m_fixgraphics = _b;
+ }
+ bool FixGraphics()
+ {
+ return m_fixgraphics;
+ }
void setBaseSize(unsigned char _s) { m_basesize = _s; }
unsigned char getBaseSize() { return m_basesize; }
int gzoom();
FontControl(QString n = "helvetica", int size = 10)
- :
- m_fontsizes(NULL), m_hasCourier(false), m_leading(0), m_extraspace(0)
+ :
+ m_fontsizes(NULL), m_hasCourier(false), m_leading(0), m_extraspace(0), m_fixgraphics(true)
{
- ChangeFont(n, size);
+ ChangeFont(n, size);
}
~FontControl()
- {
- if (m_fontsizes != NULL) delete [] m_fontsizes;
- }
+ {
+ if (m_fontsizes != NULL) delete [] m_fontsizes;
+ }
void hasCourier(bool _b, const QString& _nm)
- {
- m_hasCourier = _b;
- m_fixedfontname = _nm;
- }
+ {
+ m_hasCourier = _b;
+ m_fixedfontname = _nm;
+ }
QString& fixedfontname() { return m_fixedfontname; }
bool hasCourier() { return m_hasCourier; }
QString name() { return m_fontname; }
- int currentsize() { return m_fontsizes[m_size]; }
+ int currentsize() { return (m_fontsizes == NULL) ? 0 : m_fontsizes[m_size]; }
int getsize(const CStyle& size)
- {
- int tgt = m_size+size.getFontSize();
- if (tgt < 0)
- {
- tgt = 0;
- }
- if (tgt >= m_maxsize)
- {
- tgt = m_maxsize - 1;
- }
- return m_fontsizes[tgt];
- }
+ {
+ return getsize(size.getFontSize());
+ }
+ int getsize(int _offset)
+ {
+ int tgt = m_size+_offset;
+ if (tgt < 0)
+ {
+ tgt = 0;
+ }
+ if (tgt >= m_maxsize)
+ {
+ tgt = m_maxsize - 1;
+ }
+ return m_fontsizes[tgt];
+ }
int ascent()
{
- QFont f(name(), currentsize());
- QFontMetrics fm(f);
- return fm.ascent();
+ QFont f(name(), currentsize());
+ QFontMetrics fm(f);
+ return fm.ascent();
}
int ascent(const CStyle& ch)
{
- QFont f(name(), getsize(ch));
- QFontMetrics fm(f);
- return fm.ascent();
+ QFont f(name(), getsize(ch));
+ QFontMetrics fm(f);
+ return fm.ascent();
}
int descent()
{
- QFont f(name(), currentsize());
- QFontMetrics fm(f);
- return fm.descent();
+ QFont f(name(), currentsize());
+ QFontMetrics fm(f);
+ return fm.descent();
}
int descent(const CStyle& ch)
{
- QFont f(name(), getsize(ch));
- QFontMetrics fm(f);
- return fm.descent();
+ QFont f(name(), getsize(ch));
+ QFontMetrics fm(f);
+ return fm.descent();
}
int lineSpacing()
{
- QFont f(name(), currentsize());
- QFontMetrics fm(f);
- return fm.lineSpacing();
+ QFont f(name(), currentsize());
+ QFontMetrics fm(f);
+ return fm.lineSpacing();
}
int lineSpacing(const CStyle& ch)
{
- QFont f(name(), getsize(ch));
- QFontMetrics fm(f);
- return fm.lineSpacing();
+ QFont f(name(), getsize(ch));
+ QFontMetrics fm(f);
+ return fm.lineSpacing();
}
bool decreasesize()
- {
-/*
- if (--m_size < 0)
- {
- m_size = 0;
- return false;
- }
- else return true;
-*/
- if (g_size-- == m_size)
- {
- if (--m_size < 0)
- {
- m_size = 0;
- }
- }
-// odebug << "Font:" << m_size << " Graphics:" << g_size << oendl;
- return true;
- }
+ {
+ if (m_fixgraphics)
+ {
+ if (--m_size < 0)
+ {
+ m_size = 0;
+ return false;
+ }
+ g_size = m_size;
+ }
+ else
+ {
+ if (g_size-- == m_size)
+ {
+ if (--m_size < 0)
+ {
+ m_size = 0;
+ }
+ }
+ }
+// qDebug("Font:%d Graphics:%d", m_size, g_size);
+ return true;
+ }
bool increasesize()
- {
-/*
- if (++m_size >= m_maxsize)
- {
- m_size = m_maxsize - 1;
- return false;
- }
- else return true;
-*/
- if (g_size++ == m_size)
- {
- if (++m_size >= m_maxsize)
- {
- m_size = m_maxsize - 1;
- }
- }
-// odebug << "Font:" << m_size << " Graphics:" << g_size << oendl;
- return true;
- }
+ {
+ if (m_fixgraphics)
+ {
+ if (++m_size >= m_maxsize)
+ {
+ m_size = m_maxsize - 1;
+ return false;
+ }
+ g_size = m_size;
+ }
+ else
+ {
+ if (g_size++ == m_size)
+ {
+ if (++m_size >= m_maxsize)
+ {
+ m_size = m_maxsize - 1;
+ }
+ }
+ }
+ return true;
+ }
bool ChangeFont(QString& n)
- {
- return ChangeFont(n, currentsize());
- }
+ {
+ return ChangeFont(n, currentsize());
+ }
bool ChangeFont(QString& n, int tgt);
void setlead(int _lead)
- {
- m_leading = _lead;
- }
+ {
+ m_leading = _lead;
+ }
int getlead()
- {
- return m_leading;
- }
+ {
+ return m_leading;
+ }
void setextraspace(int _lead)
- {
- m_extraspace = _lead;
- }
+ {
+ m_extraspace = _lead;
+ }
int getextraspace()
- {
- return m_extraspace;
- }
+ {
+ return m_extraspace;
+ }
};
#endif