24 #include "KDChartAbstractAreaBase_p.h" 28 #include "KDChartPainterSaver_p.h" 32 #include <KDABLibFakes> 33 #include <QPainterPath> 38 AbstractAreaBase::Private::Private() :
45 AbstractAreaBase::Private::~Private() {}
48 void AbstractAreaBase::Private::init()
64 void AbstractAreaBase::init()
73 if ( other ==
this )
return true;
85 qWarning(
"Sorry, not implemented: void AbstractAreaBase::alignToReferencePoint( const RelativePosition& position )" );
90 if (
d->frameAttributes == a )
93 d->frameAttributes = a;
99 return d->frameAttributes;
104 if (
d->backgroundAttributes == a )
107 d->backgroundAttributes = a;
113 return d->backgroundAttributes;
124 if ( Qt::NoBrush != attributes.
brush().style() ) {
125 KDChart::PainterSaver painterSaver( &painter );
126 painter.setPen( Qt::NoPen );
127 const QPointF newTopLeft( painter.deviceMatrix().map( rect.topLeft() ) );
128 painter.setBrushOrigin( newTopLeft );
129 painter.setBrush( attributes.
brush() );
130 painter.drawRect( rect.adjusted( 0, 0, -1, -1 ) );
133 if ( !attributes.
pixmap().isNull() &&
135 QPointF ol = rect.topLeft();
138 ol.setX( rect.center().x() - attributes.
pixmap().width() / 2 );
139 ol.setY( rect.center().y() - attributes.
pixmap().height()/ 2 );
140 painter.drawPixmap( ol, attributes.
pixmap() );
143 qreal zW = (qreal)rect.width() / (qreal)attributes.
pixmap().width();
144 qreal zH = (qreal)rect.height() / (qreal)attributes.
pixmap().height();
159 QPixmap pm = attributes.
pixmap().transformed( m );
160 ol.setX( rect.center().x() - pm.width() / 2 );
161 ol.setY( rect.center().y() - pm.height()/ 2 );
162 painter.drawPixmap( ol, pm );
178 const QPen oldPen( painter.pen() );
179 const QBrush oldBrush( painter.brush() );
182 painter.setBrush( Qt::NoBrush );
185 painter.setBrush( oldBrush );
186 painter.setPen( oldPen );
191 Q_ASSERT_X (
d != 0,
"AbstractAreaBase::paintBackground()",
192 "Private class was not initialized!" );
194 PainterSaver painterSaver( &painter );
196 const qreal radius =
d->frameAttributes.cornerRadius();
198 path.addRoundedRect( rect.adjusted( 0, 0, -1, -1 ), radius, radius );
199 painter.setClipPath(path);
207 Q_ASSERT_X (
d != 0,
"AbstractAreaBase::paintFrame()",
208 "Private class was not initialized!" );
216 if (
d &&
d->frameAttributes.isVisible() ) {
217 padding = qMax(
d->frameAttributes.padding(), 0 );
232 return QRect ( QPoint( 0, 0 ),
areaGeometry().size() ).adjusted( left, top, -right, -bottom );
static void paintFrameAttributes(QPainter &painter, const QRect &rectangle, const KDChart::FrameAttributes &attributes)
static void paintBackgroundAttributes(QPainter &painter, const QRect &rectangle, const KDChart::BackgroundAttributes &attributes)
BackgroundAttributes backgroundAttributes() const
virtual void paintFrame(QPainter &painter, const QRect &rectangle)
A set of attributes for frames around items.
Base class for AbstractArea and AbstractAreaWidget: An area in the chart with a background, a frame, etc.
void getFrameLeadings(int &left, int &top, int &right, int &bottom) const
virtual void paintBackground(QPainter &painter, const QRect &rectangle)
virtual ~AbstractAreaBase()
qreal cornerRadius() const
bool compare(const AbstractAreaBase *other) const
Returns true if both areas have the same settings.
virtual QRect areaGeometry() const =0
virtual void positionHasChanged()
Defines relative position information: reference area, position in this area (reference position)...
static QPen scalePen(const QPen &pen)
void setBackgroundAttributes(const BackgroundAttributes &a)
FrameAttributes frameAttributes() const
BackgroundPixmapMode pixmapMode() const
void setFrameAttributes(const FrameAttributes &a)
Set of attributes usable for background pixmaps.
void alignToReferencePoint(const RelativePosition &position)