· · ·
layoutelement-plottitle.h
1 /***************************************************************************
2 ** **
3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
4 ** Copyright (C) 2011, 2012, 2013, 2014 Emanuel Eichhammer **
5 ** **
6 ** This program is free software: you can redistribute it and/or modify **
7 ** it under the terms of the GNU General Public License as published by **
8 ** the Free Software Foundation, either version 3 of the License, or **
9 ** (at your option) any later version. **
10 ** **
11 ** This program is distributed in the hope that it will be useful, **
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
14 ** GNU General Public License for more details. **
15 ** **
16 ** You should have received a copy of the GNU General Public License **
17 ** along with this program. If not, see http://www.gnu.org/licenses/. **
18 ** **
19 ****************************************************************************
20 ** Author: Emanuel Eichhammer **
21 ** Website/Contact: http://www.qcustomplot.com/ **
22 ** Date: 07.04.14 **
23 ** Version: 1.2.1 **
24 ****************************************************************************/
25
26 #ifndef QCP_LAYOUTELEMENT_PLOTTITLE_H
27 #define QCP_LAYOUTELEMENT_PLOTTITLE_H
28
29 #include "../global.h"
30 #include "../layer.h"
31 #include "../layout.h"
32
33 class QCPPainter;
34 class QCustomPlot;
35
36 class QCP_LIB_DECL QCPPlotTitle : public QCPLayoutElement
37 {
38 Q_OBJECT
40 Q_PROPERTY(QString text READ text WRITE setText)
41 Q_PROPERTY(QFont font READ font WRITE setFont)
42 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor)
43 Q_PROPERTY(QFont selectedFont READ selectedFont WRITE setSelectedFont)
44 Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor)
45 Q_PROPERTY(bool selectable READ selectable WRITE setSelectable NOTIFY selectableChanged)
46 Q_PROPERTY(bool selected READ selected WRITE setSelected NOTIFY selectionChanged)
48 public:
49 explicit QCPPlotTitle(QCustomPlot *parentPlot);
50 explicit QCPPlotTitle(QCustomPlot *parentPlot, const QString &text);
51
52 // getters:
53 QString text() const { return mText; }
54 QFont font() const { return mFont; }
55 QColor textColor() const { return mTextColor; }
56 QFont selectedFont() const { return mSelectedFont; }
57 QColor selectedTextColor() const { return mSelectedTextColor; }
58 bool selectable() const { return mSelectable; }
59 bool selected() const { return mSelected; }
60
61 // setters:
62 void setText(const QString &text);
63 void setFont(const QFont &font);
64 void setTextColor(const QColor &color);
65 void setSelectedFont(const QFont &font);
66 void setSelectedTextColor(const QColor &color);
67 Q_SLOT void setSelectable(bool selectable);
68 Q_SLOT void setSelected(bool selected);
69
70 // reimplemented virtual methods:
71 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const;
72
73 signals:
74 void selectionChanged(bool selected);
75 void selectableChanged(bool selectable);
76
77 protected:
78 // property members:
79 QString mText;
80 QFont mFont;
81 QColor mTextColor;
82 QFont mSelectedFont;
83 QColor mSelectedTextColor;
84 QRect mTextBoundingRect;
85 bool mSelectable, mSelected;
86
87 // reimplemented virtual methods:
88 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
89 virtual void draw(QCPPainter *painter);
90 virtual QSize minimumSizeHint() const;
91 virtual QSize maximumSizeHint() const;
92 // events:
93 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
94 virtual void deselectEvent(bool *selectionStateChanged);
95
96 // non-virtual methods:
97 QFont mainFont() const;
98 QColor mainTextColor() const;
99
100 private:
101 Q_DISABLE_COPY(QCPPlotTitle)
102 };
103
104
105
106 #endif // QCP_LAYOUTELEMENT_PLOTTITLE_H
Generated with Doxygen 1.8.1.2