Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef KLFRELATIVEFONT_H
00025 #define KLFRELATIVEFONT_H
00026
00027 #include <QObject>
00028 #include <QWidget>
00029 #include <QFont>
00030
00031 #include <klfdefs.h>
00032
00033
00034 class KLF_EXPORT KLFRelativeFontBase : public QObject
00035 {
00036 Q_OBJECT
00037 public:
00038 KLFRelativeFontBase(QWidget *parent);
00039 KLFRelativeFontBase(QWidget *reference, QWidget *target);
00040 virtual ~KLFRelativeFontBase();
00041
00042 bool eventFilter(QObject *object, QEvent *event);
00043
00044 void setThorough(bool thorough);
00045
00046 protected:
00047 virtual QFont calculateRelativeFont(const QFont& baseFont) = 0;
00048
00049 inline QWidget * referenceWidget() { return pReference; }
00050 inline QWidget * targetWidget() { return pTarget; }
00051
00052 private:
00053 void calculateAndApplyNewFont();
00054
00055 private:
00056 QWidget *pReference;
00057 QWidget *pTarget;
00058
00059 bool pInhibitFontChangeRecursion;
00060 bool pHasAppliedFont;
00061
00062 bool pThorough;
00063 };
00064
00065
00066
00067
00068
00069 class KLF_EXPORT KLFRelativeFont : public KLFRelativeFontBase
00070 {
00071 Q_OBJECT
00072 public:
00073 KLFRelativeFont(QWidget *parent);
00074 KLFRelativeFont(QWidget *reference, QWidget *target);
00075
00076 virtual ~KLFRelativeFont();
00077
00078 inline QString forceFamily() const { return pForceFamily; }
00079 inline int relPointSize() const { return pRelPointSize; }
00080
00081 void setRelPointSize(int relps);
00082
00083 void setForceFamily(const QString& family);
00084 void releaseForceFamily() { setForceFamily(QString()); }
00085
00086 void setForceBold(bool bold) { setForceWeight(bold ? QFont::Bold : QFont::Normal); }
00087 void setForceWeight(int weight);
00088 void releaseForceWeight() { setForceWeight(-1); }
00089
00090 void setForceItalic(bool it) { setForceStyle(it ? QFont::StyleItalic : QFont::StyleNormal); }
00091 void setForceStyle(int style);
00092 void releaseForceStyle() { setForceStyle(-1); }
00093
00094 protected:
00095 virtual QFont calculateRelativeFont(const QFont& baseFont);
00096
00097 private:
00098 QString pForceFamily;
00099 int pRelPointSize;
00100 int pForceWeight;
00101 int pForceStyle;
00102
00103 void rfinit();
00104 };
00105
00106
00107 #endif