##// END OF EJS Templates
minor.
Michal Klocek -
r59:ae8f836b608d
parent child
Show More
@@ -1,50 +1,50
1 1 #include "bar.h"
2 2 #include <QDebug>
3 #include <Qpainter>
3 #include <QPainter>
4 4
5 5 QTCOMMERCIALCHART_BEGIN_NAMESPACE
6 6
7 7 Bar::Bar(QGraphicsItem *parent)
8 8 : QGraphicsItem(parent)
9 9 {
10 10 }
11 11
12 12 void Bar::resize( int w, int h )
13 13 {
14 14 mWidth = w;
15 15 mHeight = h;
16 16 }
17 17
18 18 void Bar::setColor( QColor col )
19 19 {
20 20 mColor = col;
21 21 }
22 22 void Bar::setPos(qreal x, qreal y)
23 23 {
24 24 mXpos = x;
25 25 mYpos = y;
26 26 }
27 27
28 28 void Bar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
29 29 {
30 30 // Set color for bar. TODO: gradients, textures etc
31 31 QPen pen = painter->pen();
32 32 pen.setColor( mColor );
33 33 pen.setWidth( mWidth );
34 34 painter->setPen(pen);
35 35
36 36 // Draw bar
37 37 // TODO: Pen width affects bar height for now. This should be rect
38 38 painter->drawLine(scenePos().x() + mXpos, scenePos().y() + mYpos + parentItem()->boundingRect().height() - mHeight - mWidth,
39 39 scenePos().x() + mXpos, scenePos().y() + mYpos + parentItem()->boundingRect().height() - mWidth);
40 40 }
41 41
42 42 QRectF Bar::boundingRect() const
43 43 {
44 44 // TODO: check validity of this (I suppose there is easier way, and currently this bit incorrect :)
45 45 // QRectF r(scenePos().x()+mXpos, scenePos().y()+mYpos, scenePos().x() + mWidth, scenePos().y() + mHeight );
46 46 QRectF r(mXpos, mYpos, mXpos + mWidth, mYpos + mHeight);
47 47 return r;
48 48 }
49 49
50 50 QTCOMMERCIALCHART_END_NAMESPACE
General Comments 0
You need to be logged in to leave comments. Login now