[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
klfrelativefont.h
Go to the documentation of this file.
1 /***************************************************************************
2  * file klfrelativefont.h
3  * This file is part of the KLatexFormula Project.
4  * Copyright (C) 2011 by Philippe Faist
5  * philippe.faist at bluewin.ch
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 /* $Id: klfrelativefont.h 660 2011-07-07 22:19:41Z phfaist $ */
23 
24 #ifndef KLFRELATIVEFONT_H
25 #define KLFRELATIVEFONT_H
26 
27 #include <QObject>
28 #include <QWidget>
29 #include <QFont>
30 
31 #include <klfdefs.h>
32 
33 
35 {
36  Q_OBJECT
37 public:
38  KLFRelativeFontBase(QWidget *parent);
39  KLFRelativeFontBase(QWidget *reference, QWidget *target);
40  virtual ~KLFRelativeFontBase();
41 
42  bool eventFilter(QObject *object, QEvent *event);
43 
44  void setThorough(bool thorough);
45 
46 protected:
47  virtual QFont calculateRelativeFont(const QFont& baseFont) = 0;
48 
49  inline QWidget * referenceWidget() { return pReference; }
50  inline QWidget * targetWidget() { return pTarget; }
51 
52 private:
53  void calculateAndApplyNewFont();
54 
55 private:
56  QWidget *pReference;
57  QWidget *pTarget;
58 
59  bool pInhibitFontChangeRecursion;
60  bool pHasAppliedFont;
61 
62  bool pThorough;
63 };
64 
65 
66 // ----
67 
68 
70 {
71  Q_OBJECT
72 public:
73  KLFRelativeFont(QWidget *parent);
74  KLFRelativeFont(QWidget *reference, QWidget *target);
75 
76  virtual ~KLFRelativeFont();
77 
78  inline QString forceFamily() const { return pForceFamily; }
79  inline int relPointSize() const { return pRelPointSize; }
80 
81  void setRelPointSize(int relps);
82 
83  void setForceFamily(const QString& family);
84  void releaseForceFamily() { setForceFamily(QString()); }
85 
86  void setForceBold(bool bold) { setForceWeight(bold ? QFont::Bold : QFont::Normal); }
87  void setForceWeight(int weight);
88  void releaseForceWeight() { setForceWeight(-1); }
89 
90  void setForceItalic(bool it) { setForceStyle(it ? QFont::StyleItalic : QFont::StyleNormal); }
91  void setForceStyle(int style);
92  void releaseForceStyle() { setForceStyle(-1); }
93 
94 protected:
95  virtual QFont calculateRelativeFont(const QFont& baseFont);
96 
97 private:
98  QString pForceFamily;
99  int pRelPointSize;
100  int pForceWeight;
101  int pForceStyle;
102 
103  void rfinit();
104 };
105 
106 
107 #endif
const char * style
Definition: klfdatautil.cpp:56
void releaseForceWeight()
Base declarations for klatexformula and some utilities.
void releaseForceStyle()
void setForceBold(bool bold)
void releaseForceFamily()
virtual QFont calculateRelativeFont(const QFont &baseFont)=0
QWidget * referenceWidget()
#define KLF_EXPORT
Definition: klfdefs.h:41
virtual bool eventFilter(QObject *watched, QEvent *event)
int relPointSize() const
QString forceFamily() const
void setForceItalic(bool it)
QWidget * targetWidget()

Generated by doxygen 1.8.13