|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbWidgets module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #ifndef HBCHECKBOX_H |
|
27 #define HBCHECKBOX_H |
|
28 |
|
29 #include <hbabstractbutton.h> |
|
30 #define HB_CHECKBOX_TYPE "HB_CHECKBOX" |
|
31 |
|
32 class HbCheckBoxPrivate; |
|
33 class HbStyleOptionCheckBox; |
|
34 |
|
35 class HB_WIDGETS_EXPORT HbCheckBox : public HbAbstractButton |
|
36 { |
|
37 Q_OBJECT |
|
38 Q_PROPERTY( QString text READ text WRITE setText ) |
|
39 Q_PROPERTY(bool tristate READ isTristate WRITE setTristate) |
|
40 Q_PROPERTY(Qt::CheckState checkState READ checkState WRITE setCheckState) |
|
41 |
|
42 public: |
|
43 |
|
44 explicit HbCheckBox( QGraphicsItem *parent = 0 ); |
|
45 explicit HbCheckBox( const QString &text, QGraphicsItem *parent = 0 ); |
|
46 virtual ~HbCheckBox(); |
|
47 |
|
48 enum { Type = Hb::ItemType_CheckBox }; |
|
49 int type() const { return Type; } |
|
50 |
|
51 void setText( const QString &text ); |
|
52 QString text( ) const; |
|
53 |
|
54 void setTristate( bool isTristate = true ); |
|
55 bool isTristate( ) const; |
|
56 |
|
57 Qt::CheckState checkState( ) const; |
|
58 |
|
59 virtual QGraphicsItem *primitive(HbStyle::Primitive primitive) const; |
|
60 |
|
61 public slots: |
|
62 |
|
63 void setCheckState( Qt::CheckState state ); |
|
64 virtual void updatePrimitives(); |
|
65 |
|
66 protected: |
|
67 void initStyleOption( HbStyleOptionCheckBox *option ) const; |
|
68 void resizeEvent(QGraphicsSceneResizeEvent *event); |
|
69 |
|
70 virtual bool hitButton( const QPointF &pos ) const; |
|
71 virtual void checkStateSet( ); |
|
72 virtual void nextCheckState( ); |
|
73 |
|
74 void mouseReleaseEvent( QGraphicsSceneMouseEvent *event ); |
|
75 void mouseMoveEvent(QGraphicsSceneMouseEvent *event); |
|
76 void keyPressEvent(QKeyEvent *keyEvent); |
|
77 QVariant itemChange( GraphicsItemChange change, const QVariant &value ); |
|
78 |
|
79 signals: |
|
80 void stateChanged ( int state ); |
|
81 |
|
82 private: |
|
83 Q_DECLARE_PRIVATE_D(d_ptr, HbCheckBox) |
|
84 Q_DISABLE_COPY(HbCheckBox) |
|
85 |
|
86 }; |
|
87 |
|
88 #endif //HBCHECKBOX_H |
|
89 |