2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
9 ** $QT_BEGIN_LICENSE:LGPL$ |
9 ** $QT_BEGIN_LICENSE:LGPL$ |
10 ** No Commercial Usage |
10 ** No Commercial Usage |
11 ** This file contains pre-release code and may not be distributed. |
11 ** This file contains pre-release code and may not be distributed. |
12 ** You may use this file in accordance with the terms and conditions |
12 ** You may use this file in accordance with the terms and conditions |
71 #include <aknutils.h> // AknLayoutUtils |
71 #include <aknutils.h> // AknLayoutUtils |
72 #include <avkon.hrh> // EEikStatusPaneUidTitle |
72 #include <avkon.hrh> // EEikStatusPaneUidTitle |
73 #include <akntitle.h> // CAknTitlePane |
73 #include <akntitle.h> // CAknTitlePane |
74 #include <akncontext.h> // CAknContextPane |
74 #include <akncontext.h> // CAknContextPane |
75 #include <eikspane.h> // CEikStatusPane |
75 #include <eikspane.h> // CEikStatusPane |
|
76 #include <aknpopupfader.h> // MAknFadedComponent and TAknPopupFader |
76 #endif |
77 #endif |
77 |
78 |
78 QT_BEGIN_NAMESPACE |
79 QT_BEGIN_NAMESPACE |
79 |
80 |
80 // Application internal HandleResourceChangeL events, |
81 // Application internal HandleResourceChangeL events, |
100 int screenHeightInTwips; |
101 int screenHeightInTwips; |
101 int defaultDpiX; |
102 int defaultDpiX; |
102 int defaultDpiY; |
103 int defaultDpiY; |
103 WId curWin; |
104 WId curWin; |
104 int virtualMouseLastKey; |
105 int virtualMouseLastKey; |
|
106 enum PressedKeys { |
|
107 Select = 0x1, |
|
108 Right = 0x2, |
|
109 Down = 0x4, |
|
110 Left = 0x8, |
|
111 Up = 0x10 |
|
112 }; |
|
113 int virtualMousePressedKeys; // of the above type, but avoids casting problems |
105 int virtualMouseAccel; |
114 int virtualMouseAccel; |
106 int virtualMouseMaxAccel; |
115 int virtualMouseMaxAccel; |
107 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
116 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
108 int brokenPointerCursors : 1; |
117 int brokenPointerCursors : 1; |
109 #endif |
118 #endif |
112 int virtualMouseRequired : 1; |
121 int virtualMouseRequired : 1; |
113 int qtOwnsS60Environment : 1; |
122 int qtOwnsS60Environment : 1; |
114 int supportsPremultipliedAlpha : 1; |
123 int supportsPremultipliedAlpha : 1; |
115 QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type |
124 QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type |
116 static inline void updateScreenSize(); |
125 static inline void updateScreenSize(); |
117 static inline RWsSession& wsSession(); |
126 static inline RWsSession& wsSession(); |
118 static inline RWindowGroup& windowGroup(); |
127 static inline RWindowGroup& windowGroup(); |
119 static inline CWsScreenDevice* screenDevice(); |
128 static inline CWsScreenDevice* screenDevice(); |
120 static inline CCoeAppUi* appUi(); |
129 static inline CCoeAppUi* appUi(); |
121 #ifdef Q_WS_S60 |
130 #ifdef Q_WS_S60 |
122 static inline CEikStatusPane* statusPane(); |
131 static inline CEikStatusPane* statusPane(); |
138 virtual void HandleLongTapEventL( const TPoint& aPenEventLocation, |
147 virtual void HandleLongTapEventL( const TPoint& aPenEventLocation, |
139 const TPoint& aPenEventScreenLocation ) = 0; |
148 const TPoint& aPenEventScreenLocation ) = 0; |
140 }; |
149 }; |
141 class QLongTapTimer; |
150 class QLongTapTimer; |
142 |
151 |
|
152 |
143 class QSymbianControl : public CCoeControl, public QAbstractLongTapObserver |
153 class QSymbianControl : public CCoeControl, public QAbstractLongTapObserver |
|
154 #ifdef Q_WS_S60 |
|
155 , public MAknFadedComponent |
|
156 #endif |
144 { |
157 { |
145 public: |
158 public: |
146 DECLARE_TYPE_ID(0x51740000) // Fun fact: the two first values are "Qt" in ASCII. |
159 DECLARE_TYPE_ID(0x51740000) // Fun fact: the two first values are "Qt" in ASCII. |
147 |
160 |
148 public: |
161 public: |
163 void setIgnoreFocusChanged(bool enabled) { m_ignoreFocusChanged = enabled; } |
176 void setIgnoreFocusChanged(bool enabled) { m_ignoreFocusChanged = enabled; } |
164 void CancelLongTapTimer(); |
177 void CancelLongTapTimer(); |
165 |
178 |
166 void setFocusSafely(bool focus); |
179 void setFocusSafely(bool focus); |
167 |
180 |
|
181 #ifdef Q_WS_S60 |
|
182 void FadeBehindPopup(bool fade){ popupFader.FadeBehindPopup( this, this, fade); } |
|
183 |
|
184 protected: // from MAknFadedComponent |
|
185 TInt CountFadedComponents() {return 1;} |
|
186 CCoeControl* FadedComponent(TInt /*aIndex*/) {return this;} |
|
187 #else |
|
188 #warning No fallback implementation for QSymbianControl::FadeBehindPopup |
|
189 void FadeBehindPopup(bool /*fade*/){ } |
|
190 #endif |
|
191 |
168 protected: |
192 protected: |
169 void Draw(const TRect& aRect) const; |
193 void Draw(const TRect& aRect) const; |
170 void SizeChanged(); |
194 void SizeChanged(); |
171 void PositionChanged(); |
195 void PositionChanged(); |
172 void FocusChanged(TDrawNow aDrawNow); |
196 void FocusChanged(TDrawNow aDrawNow); |
174 private: |
198 private: |
175 void HandlePointerEvent(const TPointerEvent& aPointerEvent); |
199 void HandlePointerEvent(const TPointerEvent& aPointerEvent); |
176 TKeyResponse OfferKeyEvent(const TKeyEvent& aKeyEvent,TEventCode aType); |
200 TKeyResponse OfferKeyEvent(const TKeyEvent& aKeyEvent,TEventCode aType); |
177 TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent); |
201 TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent); |
178 bool sendMouseEvent(QWidget *widget, QMouseEvent *mEvent); |
202 bool sendMouseEvent(QWidget *widget, QMouseEvent *mEvent); |
|
203 void sendMouseEvent( |
|
204 QWidget *receiver, |
|
205 QEvent::Type type, |
|
206 const QPoint &globalPos, |
|
207 Qt::MouseButton button, |
|
208 Qt::KeyboardModifiers modifiers); |
179 void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ); |
209 void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ); |
180 #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER |
210 #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER |
181 void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event); |
211 void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event); |
182 #endif |
212 #endif |
183 |
213 |
184 private: |
214 private: |
185 static QSymbianControl *lastFocusedControl; |
215 static QSymbianControl *lastFocusedControl; |
186 |
216 |
187 private: |
217 private: |
188 QWidget *qwidget; |
218 QWidget *qwidget; |
189 bool m_ignoreFocusChanged; |
|
190 QLongTapTimer* m_longTapDetector; |
219 QLongTapTimer* m_longTapDetector; |
191 bool m_previousEventLongTap; |
220 bool m_ignoreFocusChanged : 1; |
|
221 bool m_symbianPopupIsOpen : 1; |
|
222 |
|
223 #ifdef Q_WS_S60 |
|
224 // Fader object used to fade everything except this menu and the CBA. |
|
225 TAknPopupFader popupFader; |
|
226 #endif |
192 }; |
227 }; |
193 |
228 |
194 inline QS60Data::QS60Data() |
229 inline QS60Data::QS60Data() |
195 { |
230 { |
196 memclr(this, sizeof(QS60Data)); //zero init data |
231 memclr(this, sizeof(QS60Data)); //zero init data |