|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtGui of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
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 |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QT_S60_P_H |
|
43 #define QT_S60_P_H |
|
44 |
|
45 // |
|
46 // W A R N I N G |
|
47 // ------------- |
|
48 // |
|
49 // This file is not part of the Qt API. It exists purely as an |
|
50 // implementation detail. This header file may change from version to |
|
51 // version without notice, or even be removed. |
|
52 // |
|
53 // We mean it. |
|
54 // |
|
55 |
|
56 #include "QtGui/qwindowdefs.h" |
|
57 #include "private/qcore_symbian_p.h" |
|
58 #include "qhash.h" |
|
59 #include "qpoint.h" |
|
60 #include "QtGui/qfont.h" |
|
61 #include "QtGui/qimage.h" |
|
62 #include "QtGui/qevent.h" |
|
63 #include "qpointer.h" |
|
64 #include "qapplication.h" |
|
65 #include <w32std.h> |
|
66 #include <coecntrl.h> |
|
67 #include <eikenv.h> |
|
68 #include <eikappui.h> |
|
69 |
|
70 #ifdef Q_WS_S60 |
|
71 #include <aknutils.h> // AknLayoutUtils |
|
72 #include <avkon.hrh> // EEikStatusPaneUidTitle |
|
73 #include <akntitle.h> // CAknTitlePane |
|
74 #include <akncontext.h> // CAknContextPane |
|
75 #include <eikspane.h> // CEikStatusPane |
|
76 #endif |
|
77 |
|
78 QT_BEGIN_NAMESPACE |
|
79 |
|
80 // Application internal HandleResourceChangeL events, |
|
81 // system events seems to start with 0x10 |
|
82 const TInt KInternalStatusPaneChange = 0x50000000; |
|
83 |
|
84 //this macro exists because EColor16MAP enum value doesn't exist in Symbian OS 9.2 |
|
85 #define Q_SYMBIAN_ECOLOR16MAP TDisplayMode(13) |
|
86 |
|
87 class QS60Data |
|
88 { |
|
89 public: |
|
90 QS60Data(); |
|
91 TUid uid; |
|
92 int screenDepth; |
|
93 QPoint lastCursorPos; |
|
94 QPoint lastPointerEventPos; |
|
95 QPointer<QWidget> lastPointerEventTarget; |
|
96 QPointer<QWidget> mousePressTarget; |
|
97 int screenWidthInPixels; |
|
98 int screenHeightInPixels; |
|
99 int screenWidthInTwips; |
|
100 int screenHeightInTwips; |
|
101 int defaultDpiX; |
|
102 int defaultDpiY; |
|
103 WId curWin; |
|
104 int virtualMouseLastKey; |
|
105 int virtualMouseAccel; |
|
106 int virtualMouseMaxAccel; |
|
107 #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS |
|
108 int brokenPointerCursors : 1; |
|
109 #endif |
|
110 int hasTouchscreen : 1; |
|
111 int mouseInteractionEnabled : 1; |
|
112 int virtualMouseRequired : 1; |
|
113 int qtOwnsS60Environment : 1; |
|
114 int supportsPremultipliedAlpha : 1; |
|
115 QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type |
|
116 static inline void updateScreenSize(); |
|
117 static inline RWsSession& wsSession(); |
|
118 static inline RWindowGroup& windowGroup(); |
|
119 static inline CWsScreenDevice* screenDevice(); |
|
120 static inline CCoeAppUi* appUi(); |
|
121 #ifdef Q_WS_S60 |
|
122 static inline CEikStatusPane* statusPane(); |
|
123 static inline CCoeControl* statusPaneSubPane(TInt aPaneId); |
|
124 static inline CAknTitlePane* titlePane(); |
|
125 static inline CAknContextPane* contextPane(); |
|
126 static inline CEikButtonGroupContainer* buttonGroupContainer(); |
|
127 |
|
128 TTrapHandler *s60InstalledTrapHandler; |
|
129 #endif |
|
130 }; |
|
131 |
|
132 QS60Data* qGlobalS60Data(); |
|
133 #define S60 qGlobalS60Data() |
|
134 |
|
135 class QAbstractLongTapObserver |
|
136 { |
|
137 public: |
|
138 virtual void HandleLongTapEventL( const TPoint& aPenEventLocation, |
|
139 const TPoint& aPenEventScreenLocation ) = 0; |
|
140 }; |
|
141 class QLongTapTimer; |
|
142 |
|
143 class QSymbianControl : public CCoeControl, public QAbstractLongTapObserver |
|
144 { |
|
145 public: |
|
146 DECLARE_TYPE_ID(0x51740000) // Fun fact: the two first values are "Qt" in ASCII. |
|
147 |
|
148 public: |
|
149 QSymbianControl(QWidget *w); |
|
150 void ConstructL(bool isWindowOwning = false, bool desktop = false); |
|
151 ~QSymbianControl(); |
|
152 void HandleResourceChange(int resourceType); |
|
153 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
154 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
155 #if !defined(QT_NO_IM) && defined(Q_WS_S60) |
|
156 TCoeInputCapabilities InputCapabilities() const; |
|
157 #endif |
|
158 TTypeUid::Ptr MopSupplyObject(TTypeUid id); |
|
159 |
|
160 inline QWidget* widget() const { return qwidget; } |
|
161 void setWidget(QWidget *w); |
|
162 void sendInputEvent(QWidget *widget, QInputEvent *inputEvent); |
|
163 void setIgnoreFocusChanged(bool enabled) { m_ignoreFocusChanged = enabled; } |
|
164 void CancelLongTapTimer(); |
|
165 |
|
166 void setFocusSafely(bool focus); |
|
167 |
|
168 protected: |
|
169 void Draw(const TRect& aRect) const; |
|
170 void SizeChanged(); |
|
171 void PositionChanged(); |
|
172 void FocusChanged(TDrawNow aDrawNow); |
|
173 |
|
174 private: |
|
175 void HandlePointerEvent(const TPointerEvent& aPointerEvent); |
|
176 TKeyResponse OfferKeyEvent(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
177 TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent); |
|
178 bool sendMouseEvent(QWidget *widget, QMouseEvent *mEvent); |
|
179 void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation ); |
|
180 #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER |
|
181 void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event); |
|
182 #endif |
|
183 |
|
184 private: |
|
185 static QSymbianControl *lastFocusedControl; |
|
186 |
|
187 private: |
|
188 QWidget *qwidget; |
|
189 bool m_ignoreFocusChanged; |
|
190 QLongTapTimer* m_longTapDetector; |
|
191 bool m_previousEventLongTap; |
|
192 }; |
|
193 |
|
194 inline QS60Data::QS60Data() |
|
195 { |
|
196 memclr(this, sizeof(QS60Data)); //zero init data |
|
197 } |
|
198 |
|
199 inline void QS60Data::updateScreenSize() |
|
200 { |
|
201 TPixelsTwipsAndRotation params; |
|
202 int mode = S60->screenDevice()->CurrentScreenMode(); |
|
203 S60->screenDevice()->GetScreenModeSizeAndRotation(mode, params); |
|
204 S60->screenWidthInPixels = params.iPixelSize.iWidth; |
|
205 S60->screenHeightInPixels = params.iPixelSize.iHeight; |
|
206 S60->screenWidthInTwips = params.iTwipsSize.iWidth; |
|
207 S60->screenHeightInTwips = params.iTwipsSize.iHeight; |
|
208 |
|
209 S60->virtualMouseMaxAccel = qMax(S60->screenHeightInPixels, S60->screenWidthInPixels) / 20; |
|
210 |
|
211 TReal inches = S60->screenHeightInTwips / (TReal)KTwipsPerInch; |
|
212 S60->defaultDpiY = S60->screenHeightInPixels / inches; |
|
213 inches = S60->screenWidthInTwips / (TReal)KTwipsPerInch; |
|
214 S60->defaultDpiX = S60->screenWidthInPixels / inches; |
|
215 } |
|
216 |
|
217 inline RWsSession& QS60Data::wsSession() |
|
218 { |
|
219 return CCoeEnv::Static()->WsSession(); |
|
220 } |
|
221 |
|
222 inline RWindowGroup& QS60Data::windowGroup() |
|
223 { |
|
224 return CCoeEnv::Static()->RootWin(); |
|
225 } |
|
226 |
|
227 inline CWsScreenDevice* QS60Data::screenDevice() |
|
228 { |
|
229 return CCoeEnv::Static()->ScreenDevice(); |
|
230 } |
|
231 |
|
232 inline CCoeAppUi* QS60Data::appUi() |
|
233 { |
|
234 return CCoeEnv::Static()-> AppUi(); |
|
235 } |
|
236 |
|
237 #ifdef Q_WS_S60 |
|
238 inline CEikStatusPane* QS60Data::statusPane() |
|
239 { |
|
240 return CEikonEnv::Static()->AppUiFactory()->StatusPane(); |
|
241 } |
|
242 |
|
243 // Returns the application's status pane control, if not present returns NULL. |
|
244 inline CCoeControl* QS60Data::statusPaneSubPane( TInt aPaneId ) |
|
245 { |
|
246 const TUid paneUid = { aPaneId }; |
|
247 CEikStatusPane* statusPane = S60->statusPane(); |
|
248 if (statusPane && statusPane->PaneCapabilities(paneUid).IsPresent()) { |
|
249 CCoeControl* control = NULL; |
|
250 // ControlL shouldn't leave because the pane is present |
|
251 TRAPD(err, control = statusPane->ControlL(paneUid)); |
|
252 return err != KErrNone ? NULL : control; |
|
253 } |
|
254 return NULL; |
|
255 } |
|
256 |
|
257 // Returns the application's title pane, if not present returns NULL. |
|
258 inline CAknTitlePane* QS60Data::titlePane() |
|
259 { |
|
260 return static_cast<CAknTitlePane*>(S60->statusPaneSubPane(EEikStatusPaneUidTitle)); |
|
261 } |
|
262 |
|
263 // Returns the application's title pane, if not present returns NULL. |
|
264 inline CAknContextPane* QS60Data::contextPane() |
|
265 { |
|
266 return static_cast<CAknContextPane*>(S60->statusPaneSubPane(EEikStatusPaneUidContext)); |
|
267 } |
|
268 |
|
269 inline CEikButtonGroupContainer* QS60Data::buttonGroupContainer() |
|
270 { |
|
271 return CEikonEnv::Static()->AppUiFactory()->Cba(); |
|
272 } |
|
273 #endif // Q_WS_S60 |
|
274 |
|
275 static inline QFont qt_TFontSpec2QFontL(const TFontSpec &fontSpec) |
|
276 { |
|
277 return QFont( |
|
278 qt_TDesC2QString(fontSpec.iTypeface.iName), |
|
279 fontSpec.iHeight / KTwipsPerPoint, |
|
280 fontSpec.iFontStyle.StrokeWeight() == EStrokeWeightNormal ? QFont::Normal : QFont::Bold, |
|
281 fontSpec.iFontStyle.Posture() == EPostureItalic |
|
282 ); |
|
283 } |
|
284 |
|
285 static inline QImage::Format qt_TDisplayMode2Format(TDisplayMode mode) |
|
286 { |
|
287 QImage::Format format; |
|
288 switch(mode) { |
|
289 case EGray2: |
|
290 format = QImage::Format_MonoLSB; |
|
291 break; |
|
292 case EColor256: |
|
293 case EGray256: |
|
294 format = QImage::Format_Indexed8; |
|
295 break; |
|
296 case EColor4K: |
|
297 format = QImage::Format_RGB444; |
|
298 break; |
|
299 case EColor64K: |
|
300 format = QImage::Format_RGB16; |
|
301 break; |
|
302 case EColor16M: |
|
303 format = QImage::Format_RGB888; |
|
304 break; |
|
305 case EColor16MU: |
|
306 format = QImage::Format_RGB32; |
|
307 break; |
|
308 case EColor16MA: |
|
309 format = QImage::Format_ARGB32; |
|
310 break; |
|
311 case Q_SYMBIAN_ECOLOR16MAP: |
|
312 format = QImage::Format_ARGB32_Premultiplied; |
|
313 break; |
|
314 default: |
|
315 format = QImage::Format_Invalid; |
|
316 break; |
|
317 } |
|
318 return format; |
|
319 } |
|
320 |
|
321 #ifndef QT_NO_CURSOR |
|
322 void qt_symbian_setWindowCursor(const QCursor &cursor, const CCoeControl* wid); |
|
323 void qt_symbian_setWindowGroupCursor(const QCursor &cursor, RWindowTreeNode &node); |
|
324 void qt_symbian_setGlobalCursor(const QCursor &cursor); |
|
325 void qt_symbian_set_cursor_visible(bool visible); |
|
326 bool qt_symbian_is_cursor_visible(); |
|
327 #endif |
|
328 |
|
329 QT_END_NAMESPACE |
|
330 |
|
331 #endif // QT_S60_P_H |