summaryrefslogtreecommitdiffstats
path: root/examples/animation/piemenu/qgraphicspiemenusection_p.h
blob: 328f74256e1de1a94dc9efda27fb7a580d5b8bde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/****************************************************************************
**
** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the $MODULE$ of the Qt Toolkit.
**
** $TROLLTECH_DUAL_LICENSE$
**
****************************************************************************/

#ifndef QGRAPHICSPIEMENUSECTION_H
#define QGRAPHICSPIEMENUSECTION_H

#include <QtGui/qgraphicswidget.h>
#include <QtGui/qpainter.h>

class QGraphicsPieMenuSection : public QGraphicsWidget
{
    Q_OBJECT
    Q_PROPERTY(qreal rotation READ rotation WRITE setRotation)
public:
    QGraphicsPieMenuSection(QGraphicsItem *parent = 0)
        : QGraphicsWidget(parent), rot(0)
    { }

    qreal rotation() const
    {
        return rot;
    }
    void setRotation(qreal rotation)
    {
        rot = rotation;
        setTransform(QTransform().rotate(rot));
    }

    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
    {
        Q_UNUSED(option);
        Q_UNUSED(widget);
        painter->setPen(QPen(Qt::black, 1));
        painter->setBrush(QBrush(Qt::gray));
        painter->drawPie(QRectF(-100, -100, 200, 200), 0, -30 * 16);
    }

protected:
    QSizeF sizeHint(Qt::SizeHint which, const QSizeF &size = QSizeF()) const
    {
        Q_UNUSED(which);
        Q_UNUSED(size);
        return QSizeF(100, 30);
    }

private:
    qreal rot;
};

#endif