activityfw/testapplications/newtestappset/acttestfigure/circlewidget.cpp
changeset 117 c63ee96dbe5f
equal deleted inserted replaced
115:3ab5c078b490 117:c63ee96dbe5f
       
     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, 1, 0, 1, 1);
       
    28     mGridLayout->addItem(mSqure, 1, 1, 1, 1);
       
    29 
       
    30     mColor = "blue";
       
    31     mNameCombo->addItem("Circle");
       
    32     
       
    33     delete mCircle;
       
    34     mCircle = NULL;
       
    35 }
       
    36 
       
    37 circlewidget::~circlewidget()
       
    38 {
       
    39 }
       
    40 
       
    41 void circlewidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
       
    42 {
       
    43     QRect rect(10, 10, 300, 300);
       
    44     QPainterPath painterpath;
       
    45     painterpath.addEllipse(rect);
       
    46     painterpath.setFillRule(Qt::WindingFill);
       
    47 
       
    48     painter->setPen(Qt::black);
       
    49     if (mColor == "red") {
       
    50         painter->setBrush(Qt::red);
       
    51     } else if (mColor == "green") {
       
    52         painter->setBrush(Qt::green);
       
    53     } else if (mColor == "blue") {
       
    54         painter->setBrush(Qt::blue);
       
    55     } else {
       
    56         Q_ASSERT(false);
       
    57     }
       
    58     painter->drawPath(painterpath);
       
    59     
       
    60     figurewidget::paint(painter, option, widget);
       
    61 }