12 #include "KDChartAbstractAreaBase_p.h"
13 #include "KDChartPainterSaver_p.h"
20 #include <KDABLibFakes>
21 #include <QPainterPath>
25 AbstractAreaBase::Private::Private()
30 AbstractAreaBase::Private::~Private()
34 void AbstractAreaBase::Private::init()
49 void AbstractAreaBase::init()
69 qWarning(
"Sorry, not implemented: void AbstractAreaBase::alignToReferencePoint( const RelativePosition& position )");
74 if (
d->frameAttributes == a)
77 d->frameAttributes = a;
83 return d->frameAttributes;
88 if (
d->backgroundAttributes == a)
91 d->backgroundAttributes = a;
97 return d->backgroundAttributes;
108 if (Qt::NoBrush != attributes.
brush().style()) {
109 KDChart::PainterSaver painterSaver(&painter);
110 painter.setPen(Qt::NoPen);
111 const QPointF newTopLeft(painter.deviceTransform().map(rect.topLeft()));
112 painter.setBrushOrigin(newTopLeft);
113 painter.setBrush(attributes.
brush());
114 painter.drawRect(rect.adjusted(0, 0, -1, -1));
118 QPointF ol = rect.topLeft();
120 ol.setX(rect.center().x() - attributes.
pixmap().width() / 2);
121 ol.setY(rect.center().y() - attributes.
pixmap().height() / 2);
122 painter.drawPixmap(ol, attributes.
pixmap());
125 qreal zW = ( qreal )rect.width() / ( qreal )attributes.
pixmap().width();
126 qreal zH = ( qreal )rect.height() / ( qreal )attributes.
pixmap().height();
138 QPixmap pm = attributes.
pixmap().transformed(m);
139 ol.setX(rect.center().x() - pm.width() / 2);
140 ol.setY(rect.center().y() - pm.height() / 2);
141 painter.drawPixmap(ol, pm);
157 const QPen oldPen(painter.pen());
158 const QBrush oldBrush(painter.brush());
161 painter.setBrush(Qt::NoBrush);
164 painter.setBrush(oldBrush);
165 painter.setPen(oldPen);
170 Q_ASSERT_X(
d !=
nullptr,
"AbstractAreaBase::paintBackground()",
171 "Private class was not initialized!");
173 PainterSaver painterSaver(&painter);
175 const qreal radius =
d->frameAttributes.cornerRadius();
177 path.addRoundedRect(rect.adjusted(0, 0, -1, -1), radius, radius);
178 painter.setClipPath(path);
185 Q_ASSERT_X(
d !=
nullptr,
"AbstractAreaBase::paintFrame()",
186 "Private class was not initialized!");
193 if (
d &&
d->frameAttributes.isVisible()) {
194 padding = qMax(
d->frameAttributes.padding(), 0);
209 return QRect(QPoint(0, 0),
areaGeometry().size()).adjusted(left, top, -right, -bottom);
Base class for AbstractArea and AbstractAreaWidget: An area in the chart with a background,...
void setFrameAttributes(const FrameAttributes &a)
void getFrameLeadings(int &left, int &top, int &right, int &bottom) const
BackgroundAttributes backgroundAttributes() const
void alignToReferencePoint(const RelativePosition &position)
void setBackgroundAttributes(const BackgroundAttributes &a)
static void paintFrameAttributes(QPainter &painter, const QRect &rectangle, const KDChart::FrameAttributes &attributes)
virtual void positionHasChanged()
virtual void paintFrame(QPainter &painter, const QRect &rectangle)
virtual void paintBackground(QPainter &painter, const QRect &rectangle)
bool compare(const AbstractAreaBase *other) const
static void paintBackgroundAttributes(QPainter &painter, const QRect &rectangle, const KDChart::BackgroundAttributes &attributes)
virtual ~AbstractAreaBase()
virtual QRect areaGeometry() const =0
FrameAttributes frameAttributes() const
BackgroundPixmapMode pixmapMode() const
@ BackgroundPixmapModeNone
@ BackgroundPixmapModeStretched
@ BackgroundPixmapModeScaled
@ BackgroundPixmapModeCentered
A set of attributes for frames around items.
qreal cornerRadius() const
static QPen scalePen(const QPen &pen)
Defines relative position information: reference area, position in this area (reference position),...