src/layoutelements/layoutelement-plottitle.h Source File

· · ·
layoutelement-plottitle.h
1 /***************************************************************************
2 ** **
3 ** QCustomPlot, an easy to use, modern plotting widget for Qt **
4 ** Copyright (C) 2011, 2012, 2013 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: 04.11.13 **
23 ** Version: 1.1.0 **
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)
46 Q_PROPERTY(bool selected READ selected WRITE setSelected)
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 void setSelectable(bool selectable);
68 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
76 protected:
77 // property members:
78 QString mText;
79 QFont mFont;
80 QColor mTextColor;
81 QFont mSelectedFont;
82 QColor mSelectedTextColor;
83 QRect mTextBoundingRect;
84 bool mSelectable, mSelected;
85
86 // reimplemented virtual methods:
87 virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const;
88 virtual void draw(QCPPainter *painter);
89 virtual QSize minimumSizeHint() const;
90 virtual QSize maximumSizeHint() const;
91 // events:
92 virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged);
93 virtual void deselectEvent(bool *selectionStateChanged);
94
95 // non-virtual methods:
96 QFont mainFont() const;
97 QColor mainTextColor() const;
98
99 private:
100 Q_DISABLE_COPY(QCPPlotTitle)
101 };
102
103
104
105 #endif // QCP_LAYOUTELEMENT_PLOTTITLE_H
Generated with Doxygen 1.8.1.2