1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
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 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
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 | #include <aknpopupfader.h> // MAknFadedComponent and TAknPopupFader
|
---|
77 | #endif
|
---|
78 |
|
---|
79 | QT_BEGIN_NAMESPACE
|
---|
80 |
|
---|
81 | // Application internal HandleResourceChangeL events,
|
---|
82 | // system events seems to start with 0x10
|
---|
83 | const TInt KInternalStatusPaneChange = 0x50000000;
|
---|
84 |
|
---|
85 | //this macro exists because EColor16MAP enum value doesn't exist in Symbian OS 9.2
|
---|
86 | #define Q_SYMBIAN_ECOLOR16MAP TDisplayMode(13)
|
---|
87 |
|
---|
88 | class QS60Data
|
---|
89 | {
|
---|
90 | public:
|
---|
91 | QS60Data();
|
---|
92 | TUid uid;
|
---|
93 | int screenDepth;
|
---|
94 | QPoint lastCursorPos;
|
---|
95 | QPoint lastPointerEventPos;
|
---|
96 | QPointer<QWidget> lastPointerEventTarget;
|
---|
97 | QPointer<QWidget> mousePressTarget;
|
---|
98 | int screenWidthInPixels;
|
---|
99 | int screenHeightInPixels;
|
---|
100 | int screenWidthInTwips;
|
---|
101 | int screenHeightInTwips;
|
---|
102 | int defaultDpiX;
|
---|
103 | int defaultDpiY;
|
---|
104 | WId curWin;
|
---|
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
|
---|
114 | int virtualMouseAccel;
|
---|
115 | int virtualMouseMaxAccel;
|
---|
116 | #ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS
|
---|
117 | int brokenPointerCursors : 1;
|
---|
118 | #endif
|
---|
119 | int hasTouchscreen : 1;
|
---|
120 | int mouseInteractionEnabled : 1;
|
---|
121 | int virtualMouseRequired : 1;
|
---|
122 | int qtOwnsS60Environment : 1;
|
---|
123 | int supportsPremultipliedAlpha : 1;
|
---|
124 | QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type
|
---|
125 | static inline void updateScreenSize();
|
---|
126 | static inline RWsSession& wsSession();
|
---|
127 | static inline RWindowGroup& windowGroup();
|
---|
128 | static inline CWsScreenDevice* screenDevice();
|
---|
129 | static inline CCoeAppUi* appUi();
|
---|
130 | #ifdef Q_WS_S60
|
---|
131 | static inline CEikStatusPane* statusPane();
|
---|
132 | static inline CCoeControl* statusPaneSubPane(TInt aPaneId);
|
---|
133 | static inline CAknTitlePane* titlePane();
|
---|
134 | static inline CAknContextPane* contextPane();
|
---|
135 | static inline CEikButtonGroupContainer* buttonGroupContainer();
|
---|
136 |
|
---|
137 | TTrapHandler *s60InstalledTrapHandler;
|
---|
138 | #endif
|
---|
139 | };
|
---|
140 |
|
---|
141 | QS60Data* qGlobalS60Data();
|
---|
142 | #define S60 qGlobalS60Data()
|
---|
143 |
|
---|
144 | class QAbstractLongTapObserver
|
---|
145 | {
|
---|
146 | public:
|
---|
147 | virtual void HandleLongTapEventL( const TPoint& aPenEventLocation,
|
---|
148 | const TPoint& aPenEventScreenLocation ) = 0;
|
---|
149 | };
|
---|
150 | class QLongTapTimer;
|
---|
151 |
|
---|
152 |
|
---|
153 | class QSymbianControl : public CCoeControl, public QAbstractLongTapObserver
|
---|
154 | #ifdef Q_WS_S60
|
---|
155 | , public MAknFadedComponent
|
---|
156 | #endif
|
---|
157 | {
|
---|
158 | public:
|
---|
159 | DECLARE_TYPE_ID(0x51740000) // Fun fact: the two first values are "Qt" in ASCII.
|
---|
160 |
|
---|
161 | public:
|
---|
162 | QSymbianControl(QWidget *w);
|
---|
163 | void ConstructL(bool isWindowOwning = false, bool desktop = false);
|
---|
164 | ~QSymbianControl();
|
---|
165 | void HandleResourceChange(int resourceType);
|
---|
166 | void HandlePointerEventL(const TPointerEvent& aPointerEvent);
|
---|
167 | TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
|
---|
168 | #if !defined(QT_NO_IM) && defined(Q_WS_S60)
|
---|
169 | TCoeInputCapabilities InputCapabilities() const;
|
---|
170 | #endif
|
---|
171 | TTypeUid::Ptr MopSupplyObject(TTypeUid id);
|
---|
172 |
|
---|
173 | inline QWidget* widget() const { return qwidget; }
|
---|
174 | void setWidget(QWidget *w);
|
---|
175 | void sendInputEvent(QWidget *widget, QInputEvent *inputEvent);
|
---|
176 | void setIgnoreFocusChanged(bool enabled) { m_ignoreFocusChanged = enabled; }
|
---|
177 | void CancelLongTapTimer();
|
---|
178 |
|
---|
179 | void setFocusSafely(bool focus);
|
---|
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 |
|
---|
192 | protected:
|
---|
193 | void Draw(const TRect& aRect) const;
|
---|
194 | void SizeChanged();
|
---|
195 | void PositionChanged();
|
---|
196 | void FocusChanged(TDrawNow aDrawNow);
|
---|
197 |
|
---|
198 | private:
|
---|
199 | void HandlePointerEvent(const TPointerEvent& aPointerEvent);
|
---|
200 | TKeyResponse OfferKeyEvent(const TKeyEvent& aKeyEvent,TEventCode aType);
|
---|
201 | TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent);
|
---|
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);
|
---|
209 | void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation );
|
---|
210 | #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
|
---|
211 | void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event);
|
---|
212 | #endif
|
---|
213 |
|
---|
214 | private:
|
---|
215 | static QSymbianControl *lastFocusedControl;
|
---|
216 |
|
---|
217 | private:
|
---|
218 | QWidget *qwidget;
|
---|
219 | QLongTapTimer* m_longTapDetector;
|
---|
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
|
---|
227 | };
|
---|
228 |
|
---|
229 | inline QS60Data::QS60Data()
|
---|
230 | {
|
---|
231 | memclr(this, sizeof(QS60Data)); //zero init data
|
---|
232 | }
|
---|
233 |
|
---|
234 | inline void QS60Data::updateScreenSize()
|
---|
235 | {
|
---|
236 | TPixelsTwipsAndRotation params;
|
---|
237 | int mode = S60->screenDevice()->CurrentScreenMode();
|
---|
238 | S60->screenDevice()->GetScreenModeSizeAndRotation(mode, params);
|
---|
239 | S60->screenWidthInPixels = params.iPixelSize.iWidth;
|
---|
240 | S60->screenHeightInPixels = params.iPixelSize.iHeight;
|
---|
241 | S60->screenWidthInTwips = params.iTwipsSize.iWidth;
|
---|
242 | S60->screenHeightInTwips = params.iTwipsSize.iHeight;
|
---|
243 |
|
---|
244 | S60->virtualMouseMaxAccel = qMax(S60->screenHeightInPixels, S60->screenWidthInPixels) / 20;
|
---|
245 |
|
---|
246 | TReal inches = S60->screenHeightInTwips / (TReal)KTwipsPerInch;
|
---|
247 | S60->defaultDpiY = S60->screenHeightInPixels / inches;
|
---|
248 | inches = S60->screenWidthInTwips / (TReal)KTwipsPerInch;
|
---|
249 | S60->defaultDpiX = S60->screenWidthInPixels / inches;
|
---|
250 | }
|
---|
251 |
|
---|
252 | inline RWsSession& QS60Data::wsSession()
|
---|
253 | {
|
---|
254 | return CCoeEnv::Static()->WsSession();
|
---|
255 | }
|
---|
256 |
|
---|
257 | inline RWindowGroup& QS60Data::windowGroup()
|
---|
258 | {
|
---|
259 | return CCoeEnv::Static()->RootWin();
|
---|
260 | }
|
---|
261 |
|
---|
262 | inline CWsScreenDevice* QS60Data::screenDevice()
|
---|
263 | {
|
---|
264 | return CCoeEnv::Static()->ScreenDevice();
|
---|
265 | }
|
---|
266 |
|
---|
267 | inline CCoeAppUi* QS60Data::appUi()
|
---|
268 | {
|
---|
269 | return CCoeEnv::Static()-> AppUi();
|
---|
270 | }
|
---|
271 |
|
---|
272 | #ifdef Q_WS_S60
|
---|
273 | inline CEikStatusPane* QS60Data::statusPane()
|
---|
274 | {
|
---|
275 | return CEikonEnv::Static()->AppUiFactory()->StatusPane();
|
---|
276 | }
|
---|
277 |
|
---|
278 | // Returns the application's status pane control, if not present returns NULL.
|
---|
279 | inline CCoeControl* QS60Data::statusPaneSubPane( TInt aPaneId )
|
---|
280 | {
|
---|
281 | const TUid paneUid = { aPaneId };
|
---|
282 | CEikStatusPane* statusPane = S60->statusPane();
|
---|
283 | if (statusPane && statusPane->PaneCapabilities(paneUid).IsPresent()) {
|
---|
284 | CCoeControl* control = NULL;
|
---|
285 | // ControlL shouldn't leave because the pane is present
|
---|
286 | TRAPD(err, control = statusPane->ControlL(paneUid));
|
---|
287 | return err != KErrNone ? NULL : control;
|
---|
288 | }
|
---|
289 | return NULL;
|
---|
290 | }
|
---|
291 |
|
---|
292 | // Returns the application's title pane, if not present returns NULL.
|
---|
293 | inline CAknTitlePane* QS60Data::titlePane()
|
---|
294 | {
|
---|
295 | return static_cast<CAknTitlePane*>(S60->statusPaneSubPane(EEikStatusPaneUidTitle));
|
---|
296 | }
|
---|
297 |
|
---|
298 | // Returns the application's title pane, if not present returns NULL.
|
---|
299 | inline CAknContextPane* QS60Data::contextPane()
|
---|
300 | {
|
---|
301 | return static_cast<CAknContextPane*>(S60->statusPaneSubPane(EEikStatusPaneUidContext));
|
---|
302 | }
|
---|
303 |
|
---|
304 | inline CEikButtonGroupContainer* QS60Data::buttonGroupContainer()
|
---|
305 | {
|
---|
306 | return CEikonEnv::Static()->AppUiFactory()->Cba();
|
---|
307 | }
|
---|
308 | #endif // Q_WS_S60
|
---|
309 |
|
---|
310 | static inline QFont qt_TFontSpec2QFontL(const TFontSpec &fontSpec)
|
---|
311 | {
|
---|
312 | return QFont(
|
---|
313 | qt_TDesC2QString(fontSpec.iTypeface.iName),
|
---|
314 | fontSpec.iHeight / KTwipsPerPoint,
|
---|
315 | fontSpec.iFontStyle.StrokeWeight() == EStrokeWeightNormal ? QFont::Normal : QFont::Bold,
|
---|
316 | fontSpec.iFontStyle.Posture() == EPostureItalic
|
---|
317 | );
|
---|
318 | }
|
---|
319 |
|
---|
320 | static inline QImage::Format qt_TDisplayMode2Format(TDisplayMode mode)
|
---|
321 | {
|
---|
322 | QImage::Format format;
|
---|
323 | switch(mode) {
|
---|
324 | case EGray2:
|
---|
325 | format = QImage::Format_MonoLSB;
|
---|
326 | break;
|
---|
327 | case EColor256:
|
---|
328 | case EGray256:
|
---|
329 | format = QImage::Format_Indexed8;
|
---|
330 | break;
|
---|
331 | case EColor4K:
|
---|
332 | format = QImage::Format_RGB444;
|
---|
333 | break;
|
---|
334 | case EColor64K:
|
---|
335 | format = QImage::Format_RGB16;
|
---|
336 | break;
|
---|
337 | case EColor16M:
|
---|
338 | format = QImage::Format_RGB888;
|
---|
339 | break;
|
---|
340 | case EColor16MU:
|
---|
341 | format = QImage::Format_RGB32;
|
---|
342 | break;
|
---|
343 | case EColor16MA:
|
---|
344 | format = QImage::Format_ARGB32;
|
---|
345 | break;
|
---|
346 | case Q_SYMBIAN_ECOLOR16MAP:
|
---|
347 | format = QImage::Format_ARGB32_Premultiplied;
|
---|
348 | break;
|
---|
349 | default:
|
---|
350 | format = QImage::Format_Invalid;
|
---|
351 | break;
|
---|
352 | }
|
---|
353 | return format;
|
---|
354 | }
|
---|
355 |
|
---|
356 | #ifndef QT_NO_CURSOR
|
---|
357 | void qt_symbian_setWindowCursor(const QCursor &cursor, const CCoeControl* wid);
|
---|
358 | void qt_symbian_setWindowGroupCursor(const QCursor &cursor, RWindowTreeNode &node);
|
---|
359 | void qt_symbian_setGlobalCursor(const QCursor &cursor);
|
---|
360 | void qt_symbian_set_cursor_visible(bool visible);
|
---|
361 | bool qt_symbian_is_cursor_visible();
|
---|
362 | #endif
|
---|
363 |
|
---|
364 | QT_END_NAMESPACE
|
---|
365 |
|
---|
366 | #endif // QT_S60_P_H
|
---|