|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 #include "circlewidget.h" |
|
18 #include <QRect> |
|
19 #include <QPainter> |
|
20 #include <QPainterPath> |
|
21 #include <QPolygon> |
|
22 |
|
23 |
|
24 circlewidget::circlewidget(QGraphicsItem *parent) |
|
25 : figurewidget(parent) |
|
26 { |
|
27 mGridLayout->addItem(mTriangle, 2, 0, 1, 1); |
|
28 mGridLayout->addItem(mSqure, 2, 1, 1, 1); |
|
29 |
|
30 mColor = "blue"; |
|
31 |
|
32 delete mCircle; |
|
33 mCircle = NULL; |
|
34 } |
|
35 |
|
36 circlewidget::~circlewidget() |
|
37 { |
|
38 } |
|
39 |
|
40 void circlewidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) |
|
41 { |
|
42 QRect rect(10, 10, 300, 300); |
|
43 QPainterPath painterpath; |
|
44 painterpath.addEllipse(rect); |
|
45 painterpath.setFillRule(Qt::WindingFill); |
|
46 |
|
47 painter->setPen(Qt::black); |
|
48 if (mColor == "red") { |
|
49 painter->setBrush(Qt::red); |
|
50 } else if (mColor == "green") { |
|
51 painter->setBrush(Qt::green); |
|
52 } else if (mColor == "blue") { |
|
53 painter->setBrush(Qt::blue); |
|
54 } else { |
|
55 Q_ASSERT(false); |
|
56 } |
|
57 painter->drawPath(painterpath); |
|
58 |
|
59 figurewidget::paint(painter, option, widget); |
|
60 } |