From 9742bfe3f470d04e85c76c5366c9dd2b21a5dde9 2012-03-19 08:27:49 From: Michal Klocek Date: 2012-03-19 08:27:49 Subject: [PATCH] Add missing files from last commit --- diff --git a/src/chartbackground.cpp b/src/chartbackground.cpp new file mode 100644 index 0000000..1b09a54 --- /dev/null +++ b/src/chartbackground.cpp @@ -0,0 +1,43 @@ +#include "chartbackground_p.h" +#include +#include +#include + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +ChartBackground::ChartBackground(QGraphicsItem* parent):QGraphicsRectItem(parent), +m_diameter(15) +{ + +} + +ChartBackground::~ChartBackground() +{ + +} + +void ChartBackground::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(option); + Q_UNUSED(widget); + painter->setPen(pen()); + painter->setBrush(brush()); + painter->drawRoundRect(rect(),roundness(rect().width()),roundness(rect().height())); +} + +int ChartBackground::roundness(qreal size) const +{ + return 100*m_diameter/int(size); +} + +int ChartBackground::diameter() const +{ + return m_diameter; +} + +void ChartBackground::setDimeter(int dimater) +{ + m_diameter=dimater; +} + +QTCOMMERCIALCHART_END_NAMESPACE diff --git a/src/chartbackground_p.h b/src/chartbackground_p.h new file mode 100644 index 0000000..00549ee --- /dev/null +++ b/src/chartbackground_p.h @@ -0,0 +1,33 @@ +#ifndef CHARTBACKGROUND_H_ +#define CHARTBACKGROUND_H_ + +#include "qchartglobal.h" +#include + +QTCOMMERCIALCHART_BEGIN_NAMESPACE + +class ChartBackground: public QGraphicsRectItem +{ +public: + ChartBackground(QGraphicsItem *parent =0); + ~ChartBackground(); + + void setDimeter(int dimater); + int diameter() const; + + +protected: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + + +private: + int roundness(qreal size) const; + +private: + int m_diameter; + +}; + +#endif /* CHARTBACKGROUND_H_ */ + +QTCOMMERCIALCHART_END_NAMESPACE