LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
colorroundrectbutton.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2011-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef COLORROUNDRECTBUTTON_H_
23 #define COLORROUNDRECTBUTTON_H_
24 
25 #include "labeledbutton.h"
26 #include <QColor>
27 #include <QStateMachine>
28 #include <QState>
29 
30 class QGraphicsSceneMouseEvent;
31 class QGesture;
32 class QGestureEvent;
33 class QTouchEvent;
34 class QPanGesture;
35 class QSwipeGesture;
36 class QPinchGesture;
37 class QTapAndHoldGesture;
38 class QTapGesture;
39 class FlickGesture;
40 class PixmapObject;
41 
43 {
44  Q_OBJECT
46 
47 public:
48  ColorRoundRectButton(const QSize& encompassingRectSize,const QString& label,QColor normalColor);
49  ColorRoundRectButton(const QSize& encompassingRectSize,const QString& label,QColor normalColor,QColor activeColor);
50  virtual ~ColorRoundRectButton();
51  virtual void commonCtor(QSize requestedSize);
52 
53  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option=0,QWidget *widget=0);
54  virtual void paintOffscreen(QPainter * painter);
55  //TODO: need other paintOffscreen flavors, e.g. PixmapHugeObject
56 
57  virtual bool valid();
58 
59  virtual bool stateActive() const;
60  virtual void setStateActive(bool v);
61 
62 Q_SIGNALS:
63 
64  void signalFirstContact();
65  void signalContact();
66  void signalRelease();
67  void signalLastRelease();
68  void signalActivated();
69 
71  void signalFSMActivate();
72  void signalFSMDeactivate();
73 
74 protected:
75 
76  virtual bool touchStartEvent(QTouchEvent *event);
77  virtual bool touchUpdateEvent(QTouchEvent *event);
78  virtual bool touchEndEvent(QTouchEvent *event);
79 
80  virtual bool sceneEvent(QEvent * event);
81 
82  //overriding these to suppress them from generating signals
83  virtual bool tapAndHoldGesture(QTapAndHoldGesture *tapHoldEvent);
84  virtual bool tapGesture(QTapGesture *tapEvent);
85  virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
86  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
87  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
88 
89  virtual void setupFSM();
90 
91 protected:
92 
93  QColor m_normalColor;
94  QColor m_activeColor;
96 
99 
102  qint32 m_touchCount;
105  bool m_valid;
106 };
107 
108 #endif /* COLORROUNDRECTBUTTON_H_ */