24 #include "KDChartAbstractAreaBase_p.h" 28 #include "KDChartPainterSaver_p.h" 32 #include <KDABLibFakes> 37 AbstractAreaBase::Private::Private() :
44 AbstractAreaBase::Private::~Private() {}
47 void AbstractAreaBase::Private::init()
63 void AbstractAreaBase::init()
72 if ( other ==
this )
return true;
84 qWarning(
"Sorry, not implemented: void AbstractAreaBase::alignToReferencePoint( const RelativePosition& position )" );
89 if (
d->frameAttributes == a )
92 d->frameAttributes = a;
98 return d->frameAttributes;
103 if (
d->backgroundAttributes == a )
106 d->backgroundAttributes = a;
112 return d->backgroundAttributes;
123 if ( Qt::NoBrush != attributes.
brush().style() ) {
124 KDChart::PainterSaver painterSaver( &painter );
125 painter.setPen( Qt::NoPen );
126 const QPointF newTopLeft( painter.deviceMatrix().map( rect.topLeft() ) );
127 painter.setBrushOrigin( newTopLeft );
128 painter.setBrush( attributes.
brush() );
129 painter.drawRect( rect.adjusted( 0, 0, -1, -1 ) );
132 if ( !attributes.
pixmap().isNull() &&
134 QPointF ol = rect.topLeft();
137 ol.setX( rect.center().x() - attributes.
pixmap().width() / 2 );
138 ol.setY( rect.center().y() - attributes.
pixmap().height()/ 2 );
139 painter.drawPixmap( ol, attributes.
pixmap() );
142 qreal zW = (qreal)rect.width() / (qreal)attributes.
pixmap().width();
143 qreal zH = (qreal)rect.height() / (qreal)attributes.
pixmap().height();
158 QPixmap pm = attributes.
pixmap().transformed( m );
159 ol.setX( rect.center().x() - pm.width() / 2 );
160 ol.setY( rect.center().y() - pm.height()/ 2 );
161 painter.drawPixmap( ol, pm );
177 const QPen oldPen( painter.pen() );
178 const QBrush oldBrush( painter.brush() );
181 painter.setBrush( Qt::NoBrush );
184 painter.setBrush( oldBrush );
185 painter.setPen( oldPen );
190 Q_ASSERT_X (
d != 0,
"AbstractAreaBase::paintBackground()",
191 "Private class was not initialized!" );
193 PainterSaver painterSaver( &painter );
195 const qreal radius =
d->frameAttributes.cornerRadius();
197 path.addRoundedRect( rect.adjusted( 0, 0, -1, -1 ), radius, radius );
198 painter.setClipPath(path);
206 Q_ASSERT_X (
d != 0,
"AbstractAreaBase::paintFrame()",
207 "Private class was not initialized!" );
215 if (
d &&
d->frameAttributes.isVisible() ) {
216 padding = qMax(
d->frameAttributes.padding(), 0 );
231 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)