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 ABSTRACTCHARTLAYOUT_H
14#define ABSTRACTCHARTLAYOUT_H
15
16#include <QtWidgets/QGraphicsLayout>
17#include <QtCore/QMargins>
18#include <QtCharts/QChartGlobal>
19#include <QtCharts/private/qchartglobal_p.h>
20
21QT_BEGIN_NAMESPACE
22
23class ChartTitle;
24class ChartAxisElement;
25class ChartPresenter;
26class QLegend;
27class ChartBackground;
28
29class Q_CHARTS_PRIVATE_EXPORT AbstractChartLayout : public QGraphicsLayout
30{
31public:
32 AbstractChartLayout(ChartPresenter *presenter);
33 virtual ~AbstractChartLayout();
34
35 virtual void setMargins(const QMargins &margins);
36 virtual QMargins margins() const;
37 void setGeometry(const QRectF &rect) override;
38
39protected:
40 virtual QRectF calculateBackgroundGeometry(const QRectF &geometry, ChartBackground *background,
41 bool update = true) const;
42 virtual QRectF calculateBackgroundMinimum(const QRectF &minimum) const;
43 virtual QRectF calculateContentGeometry(const QRectF &geometry) const;
44 virtual QRectF calculateContentMinimum(const QRectF &minimum) const;
45 virtual QRectF calculateTitleGeometry(const QRectF &geometry, ChartTitle *title,
46 bool update = true) const;
47 virtual QRectF calculateTitleMinimum(const QRectF &minimum, ChartTitle *title) const;
48 virtual QRectF calculateLegendGeometry(const QRectF &geometry, QLegend *legend,
49 bool update = true) const;
50 virtual QRectF calculateLegendMinimum(const QRectF &minimum, QLegend *legend) const;
51
52 virtual QRectF calculateAxisGeometry(const QRectF &geometry,
53 const QList<ChartAxisElement *>& axes,
54 bool update = true) const = 0;
55 virtual QRectF calculateAxisMinimum(const QRectF &minimum,
56 const QList<ChartAxisElement *>& axes) const = 0;
57
58 // from QGraphicsLayout
59 QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
60 int count() const override { return 0; }
61 QGraphicsLayoutItem *itemAt(int) const override { return 0; };
62 void removeAt(int) override {};
63
64 ChartPresenter *m_presenter;
65 QMargins m_margins;
66 QRectF m_minAxisRect;
67};
68
69QT_END_NAMESPACE
70
71#endif // ABSTRACTCHARTLAYOUT_H
72

source code of qtcharts/src/charts/layout/abstractchartlayout_p.h