|
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 HBPUSHBUTTON_H |
|
27 #define HBPUSHBUTTON_H |
|
28 |
|
29 #include <hbabstractbutton.h> |
|
30 |
|
31 #define HB_PUSHBUTTON_TYPE "HB_PUSHBUTTON" |
|
32 |
|
33 class HbPushButtonPrivate; |
|
34 class HbStyleOptionPushButton; |
|
35 class HbFrameDrawer; |
|
36 |
|
37 class HB_WIDGETS_EXPORT HbPushButton : public HbAbstractButton |
|
38 { |
|
39 Q_OBJECT |
|
40 Q_PROPERTY( HbIcon background READ background WRITE setBackground ) |
|
41 Q_PROPERTY( QString text READ text WRITE setText ) |
|
42 Q_PROPERTY( QString additionalText READ additionalText WRITE setAdditionalText ) |
|
43 Q_PROPERTY( HbIcon icon READ icon WRITE setIcon ) |
|
44 Q_PROPERTY( Qt::Orientation orientation READ orientation WRITE setOrientation ) |
|
45 Q_PROPERTY( Qt::Alignment textAlignment READ textAlignment WRITE setTextAlignment ) |
|
46 Q_PROPERTY( Qt::Alignment additionalTextAlignment READ additionalTextAlignment WRITE setAdditionalTextAlignment ) |
|
47 Q_PROPERTY( bool stretched READ isStretched WRITE setStretched ) |
|
48 |
|
49 public: |
|
50 explicit HbPushButton( QGraphicsItem *parent = 0 ); |
|
51 explicit HbPushButton( const QString &text, QGraphicsItem *parent = 0 ); |
|
52 HbPushButton( const HbIcon &icon, const QString &text, QGraphicsItem *parent = 0 ); |
|
53 HbPushButton( const HbIcon &icon, const QString &text, Qt::Orientation orientation, |
|
54 QGraphicsItem *parent = 0 ); |
|
55 virtual ~HbPushButton( ); |
|
56 |
|
57 void setBackground( const HbIcon &background ); |
|
58 HbIcon background( ) const; |
|
59 |
|
60 void setFrameBackground( HbFrameDrawer *backgroundFrameDrawer ); |
|
61 HbFrameDrawer* frameBackground( ) const; |
|
62 |
|
63 QString text( ) const; |
|
64 QString additionalText( ) const; |
|
65 |
|
66 void setIcon( const HbIcon &icon ); |
|
67 HbIcon icon( ) const; |
|
68 |
|
69 void setOrientation( Qt::Orientation orientation ); |
|
70 Qt::Orientation orientation( ) const; |
|
71 |
|
72 void setTextAlignment( Qt::Alignment alignment ); |
|
73 Qt::Alignment textAlignment ( ) const; |
|
74 |
|
75 void setAdditionalTextAlignment( Qt::Alignment alignment ); |
|
76 Qt::Alignment additionalTextAlignment ( ) const; |
|
77 |
|
78 |
|
79 void setStretched( bool stretched = true ); |
|
80 bool isStretched( ) const; |
|
81 |
|
82 QGraphicsItem* primitive( HbStyle::Primitive primitive ) const; |
|
83 |
|
84 enum { Type = Hb::ItemType_PushButton }; |
|
85 int type() const { return Type; } |
|
86 |
|
87 public slots: |
|
88 void setText( const QString &text ); |
|
89 void setAdditionalText( const QString &additionalText ); |
|
90 void recreatePrimitives(); |
|
91 void updatePrimitives(); |
|
92 |
|
93 signals: |
|
94 void longPress( QPointF ); |
|
95 |
|
96 protected: |
|
97 HbPushButton( HbPushButtonPrivate &dd, QGraphicsItem *parent ); |
|
98 void initStyleOption( HbStyleOptionPushButton *option ) const; |
|
99 |
|
100 void keyPressEvent( QKeyEvent *event ); |
|
101 void keyReleaseEvent( QKeyEvent *event ); |
|
102 |
|
103 void mousePressEvent( QGraphicsSceneMouseEvent *event ); |
|
104 void mouseReleaseEvent( QGraphicsSceneMouseEvent *event ); |
|
105 void mouseMoveEvent(QGraphicsSceneMouseEvent *event); |
|
106 void resizeEvent( QGraphicsSceneResizeEvent *event ); |
|
107 virtual void polish( HbStyleParameters& params ); |
|
108 |
|
109 void focusInEvent( QFocusEvent *event ); |
|
110 void focusOutEvent( QFocusEvent *event ); |
|
111 QVariant itemChange( GraphicsItemChange change, const QVariant &value ); |
|
112 |
|
113 bool hitButton( const QPointF &pos ) const; |
|
114 |
|
115 private: |
|
116 Q_DECLARE_PRIVATE_D( d_ptr, HbPushButton ) |
|
117 Q_DISABLE_COPY( HbPushButton ) |
|
118 Q_PRIVATE_SLOT( d_func(),void _q_handleLongPress(QPointF) ) |
|
119 Q_PRIVATE_SLOT( d_func(),void _q_handleLongKeyPress( ) ) |
|
120 |
|
121 }; |
|
122 |
|
123 #endif // HBPUSHBUTTON_H |