1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt Charts module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:GPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU |
19 | ** General Public License version 3 or (at your option) any later version |
20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
22 | ** included in the packaging of this file. Please review the following |
23 | ** information to ensure the GNU General Public License requirements will |
24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
25 | ** |
26 | ** $QT_END_LICENSE$ |
27 | ** |
28 | ****************************************************************************/ |
29 | |
30 | #ifndef QLEGENDMARKER_H |
31 | #define QLEGENDMARKER_H |
32 | |
33 | #include <QtCharts/QChartGlobal> |
34 | #include <QtCharts/QLegend> |
35 | #include <QtCore/QObject> |
36 | #include <QtGui/QPen> |
37 | #include <QtGui/QBrush> |
38 | #include <QtGui/QFont> |
39 | |
40 | QT_CHARTS_BEGIN_NAMESPACE |
41 | |
42 | class QLegendMarkerPrivate; |
43 | class QAbstractSeries; |
44 | class QLegend; |
45 | |
46 | class Q_CHARTS_EXPORT QLegendMarker : public QObject |
47 | { |
48 | Q_OBJECT |
49 | |
50 | public: |
51 | enum LegendMarkerType { |
52 | LegendMarkerTypeArea, |
53 | LegendMarkerTypeBar, |
54 | LegendMarkerTypePie, |
55 | LegendMarkerTypeXY, |
56 | LegendMarkerTypeBoxPlot, |
57 | LegendMarkerTypeCandlestick |
58 | }; |
59 | |
60 | Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY labelChanged) |
61 | Q_PROPERTY(QBrush labelBrush READ labelBrush WRITE setLabelBrush NOTIFY labelBrushChanged) |
62 | Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged) |
63 | Q_PROPERTY(QPen pen READ pen WRITE setPen NOTIFY penChanged) |
64 | Q_PROPERTY(QBrush brush READ brush WRITE setBrush NOTIFY brushChanged) |
65 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) |
66 | Q_PROPERTY(QtCharts::QLegend::MarkerShape shape READ shape WRITE setShape NOTIFY shapeChanged) |
67 | Q_ENUMS(LegendMarkerType) |
68 | |
69 | public: |
70 | virtual ~QLegendMarker(); |
71 | virtual LegendMarkerType type() = 0; |
72 | |
73 | QString label() const; |
74 | void setLabel(const QString &label); |
75 | |
76 | QBrush labelBrush() const; |
77 | void setLabelBrush(const QBrush &brush); |
78 | |
79 | QFont font() const; |
80 | void setFont(const QFont &font); |
81 | |
82 | QPen pen() const; |
83 | void setPen(const QPen &pen); |
84 | |
85 | QBrush brush() const; |
86 | void setBrush(const QBrush &brush); |
87 | |
88 | bool isVisible() const; |
89 | void setVisible(bool visible); |
90 | |
91 | QLegend::MarkerShape shape() const; |
92 | void setShape(QLegend::MarkerShape shape); |
93 | |
94 | virtual QAbstractSeries* series() = 0; |
95 | |
96 | Q_SIGNALS: |
97 | void clicked(); |
98 | void hovered(bool status); |
99 | void labelChanged(); |
100 | void labelBrushChanged(); |
101 | void fontChanged(); |
102 | void penChanged(); |
103 | void brushChanged(); |
104 | void visibleChanged(); |
105 | void shapeChanged(); |
106 | |
107 | protected: |
108 | explicit QLegendMarker(QLegendMarkerPrivate &d, QObject *parent = nullptr); |
109 | |
110 | QScopedPointer<QLegendMarkerPrivate> d_ptr; |
111 | friend class QLegendPrivate; |
112 | friend class QLegendMarkerPrivate; |
113 | friend class LegendMarkerItem; |
114 | friend class LegendLayout; |
115 | friend class LegendScroller; |
116 | |
117 | private: |
118 | Q_DISABLE_COPY(QLegendMarker) |
119 | }; |
120 | |
121 | QT_CHARTS_END_NAMESPACE |
122 | |
123 | #endif // QLEGENDMARKER_H |
124 | |