1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | // W A R N I N G |
5 | // ------------- |
6 | // |
7 | // This file is not part of the Qt Chart API. It exists purely as an |
8 | // implementation detail. This header file may change from version to |
9 | // version without notice, or even be removed. |
10 | // |
11 | // We mean it. |
12 | |
13 | #ifndef CANDLESTICK_P_H |
14 | #define CANDLESTICK_P_H |
15 | |
16 | #include <QtGui/QBrush> |
17 | #include <QtGui/QPainterPath> |
18 | #include <QtGui/QPen> |
19 | #include <QtWidgets/QGraphicsObject> |
20 | #include <private/candlestickdata_p.h> |
21 | #include <QtCharts/private/qchartglobal_p.h> |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class AbstractDomain; |
26 | class QCandlestickSet; |
27 | |
28 | class Q_CHARTS_PRIVATE_EXPORT Candlestick : public QGraphicsObject |
29 | { |
30 | Q_OBJECT |
31 | |
32 | public: |
33 | Candlestick(QCandlestickSet *set, AbstractDomain *domain, QGraphicsObject *parent); |
34 | ~Candlestick(); |
35 | |
36 | void setTimePeriod(qreal timePeriod); |
37 | void setMaximumColumnWidth(qreal maximumColumnWidth); |
38 | void setMinimumColumnWidth(qreal minimumColumnWidth); |
39 | void setBodyWidth(qreal bodyWidth); |
40 | void setBodyOutlineVisible(bool bodyOutlineVisible); |
41 | void setCapsWidth(qreal capsWidth); |
42 | void setCapsVisible(bool capsVisible); |
43 | void setIncreasingColor(const QColor &color); |
44 | void setDecreasingColor(const QColor &color); |
45 | void setBrush(const QBrush &brush); |
46 | void setPen(const QPen &pen); |
47 | void setLayout(const CandlestickData &data); |
48 | |
49 | void mousePressEvent(QGraphicsSceneMouseEvent *event) override; |
50 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; |
51 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; |
52 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; |
53 | void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; |
54 | |
55 | QRectF boundingRect() const override; |
56 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,QWidget *widget = nullptr) override; |
57 | |
58 | Q_SIGNALS: |
59 | void clicked(QCandlestickSet *set); |
60 | void hovered(bool status, QCandlestickSet *set); |
61 | void pressed(QCandlestickSet *set); |
62 | void released(QCandlestickSet *set); |
63 | void doubleClicked(QCandlestickSet *set); |
64 | |
65 | private: |
66 | void updateGeometry(AbstractDomain *domain); |
67 | |
68 | private: |
69 | QCandlestickSet *m_set; |
70 | AbstractDomain *m_domain; |
71 | qreal m_timePeriod; |
72 | qreal m_maximumColumnWidth; |
73 | qreal m_minimumColumnWidth; |
74 | qreal m_bodyWidth; |
75 | bool m_bodyOutlineVisible; |
76 | qreal m_capsWidth; |
77 | bool m_capsVisible; |
78 | QColor m_increasingColor; |
79 | QColor m_decreasingColor; |
80 | QBrush m_brush; |
81 | QPen m_pen; |
82 | CandlestickData m_data; |
83 | bool m_hovering; |
84 | bool m_mousePressed; |
85 | QRectF m_boundingRect; |
86 | QRectF m_bodyRect; |
87 | QPainterPath m_wicksPath; |
88 | QPainterPath m_capsPath; |
89 | |
90 | friend class CandlestickAnimation; |
91 | friend class CandlestickChartItem; |
92 | }; |
93 | |
94 | QT_END_NAMESPACE |
95 | |
96 | #endif // CANDLESTICK_P_H |
97 |