KD Chart API Documentation 3.1
Loading...
Searching...
No Matches
KDChartAbstractArea.cpp
Go to the documentation of this file.
1/****************************************************************************
2**
3** This file is part of the KD Chart library.
4**
5** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: MIT
8**
9****************************************************************************/
10
11#include "KDChartAbstractArea.h"
12#include "KDChartAbstractArea_p.h"
13
14#include <qglobal.h>
15
16#include <QPainter>
17#include <QRect>
18
19#include <KDABLibFakes>
20
21using namespace KDChart;
22
23#define d (d_func())
24
25AbstractArea::Private::Private()
26 : AbstractAreaBase::Private()
27{
28 // this block left empty intentionally
29}
30
31AbstractArea::Private::~Private()
32{
33 // this block left empty intentionally
34}
35
43
45{
46 // this block left empty intentionally
47}
48
49void AbstractArea::init()
50{
51 d->amountOfLeftOverlap = 0;
52 d->amountOfRightOverlap = 0;
53 d->amountOfTopOverlap = 0;
54 d->amountOfBottomOverlap = 0;
55}
56
57int AbstractArea::leftOverlap(bool doNotRecalculate) const
58{
59 // Re-calculate the sizes,
60 // so we also get the amountOf..Overlap members set newly:
62 sizeHint();
63 return d->amountOfLeftOverlap;
64}
65int AbstractArea::rightOverlap(bool doNotRecalculate) const
66{
67 // Re-calculate the sizes,
68 // so we also get the amountOf..Overlap members set newly:
70 sizeHint();
71 return d->amountOfRightOverlap;
72}
73int AbstractArea::topOverlap(bool doNotRecalculate) const
74{
75 // Re-calculate the sizes,
76 // so we also get the amountOf..Overlap members set newly:
78 sizeHint();
79 return d->amountOfTopOverlap;
80}
81int AbstractArea::bottomOverlap(bool doNotRecalculate) const
82{
83 // Re-calculate the sizes,
84 // so we also get the amountOf..Overlap members set newly:
86 sizeHint();
87 return d->amountOfBottomOverlap;
88}
89
90void AbstractArea::paintIntoRect(QPainter &painter, const QRect &rect)
91{
92 const QRect oldGeometry(geometry());
93 if (oldGeometry != rect)
94 setGeometry(rect);
95 painter.translate(rect.left(), rect.top());
96 paintAll(painter);
97 painter.translate(-rect.left(), -rect.top());
98 if (oldGeometry != rect)
100}
101
103{
104 // Paint the background and frame
105 const QRect overlappingArea(geometry().adjusted(-d->amountOfLeftOverlap, -d->amountOfTopOverlap,
106 d->amountOfRightOverlap, d->amountOfBottomOverlap));
108 paintFrame(painter, overlappingArea);
109
110 // temporarily adjust the widget size, to be sure all content gets calculated
111 // to fit into the inner rectangle
114 inner.moveTo(oldGeometry.left() + inner.left(), oldGeometry.top() + inner.top());
115 const bool needAdjustGeometry = oldGeometry != inner;
116 if (needAdjustGeometry) {
117 // don't notify others of this change for internal purposes
119 blockSignals(true);
122 }
123 paint(&painter);
124 if (needAdjustGeometry) {
126 blockSignals(true);
129 }
130 // qDebug() << "AbstractAreaWidget::paintAll() done.";
131}
132
134{
135 return geometry();
136}
137
Base class for AbstractArea and AbstractAreaWidget: An area in the chart with a background,...
virtual void paintFrame(QPainter &painter, const QRect &rectangle)
virtual void paintBackground(QPainter &painter, const QRect &rectangle)
virtual int bottomOverlap(bool doNotRecalculate=false) const
virtual int rightOverlap(bool doNotRecalculate=false) const
void paintAll(QPainter &painter) override
virtual int topOverlap(bool doNotRecalculate=false) const
virtual int leftOverlap(bool doNotRecalculate=false) const
void positionChanged(AbstractArea *)
QRect areaGeometry() const override
virtual void paintIntoRect(QPainter &painter, const QRect &rect)
Draws the background and frame, then calls paint().
virtual void paint(QPainter *)=0
virtual QRect geometry() const const=0
virtual void setGeometry(const QRect &r)=0
virtual QSize sizeHint() const const=0
Q_EMITQ_EMIT
bool blockSignals(bool block)
T qobject_cast(QObject *object)
bool signalsBlocked() const const
void translate(const QPointF &offset)
int left() const const
int top() const const

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated on Wed May 1 2024 00:01:10 for KD Chart API Documentation by doxygen 1.9.8