1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2010 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 | int avkonComponentsSupportTransparency : 1;
|
---|
125 | QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type
|
---|
126 | static inline void updateScreenSize();
|
---|
127 | static inline RWsSession& wsSession();
|
---|
128 | static inline RWindowGroup& windowGroup();
|
---|
129 | static inline CWsScreenDevice* screenDevice();
|
---|
130 | static inline CCoeAppUi* appUi();
|
---|
131 | static inline CEikMenuBar* menuBar();
|
---|
132 | #ifdef Q_WS_S60
|
---|
133 | static inline CEikStatusPane* statusPane();
|
---|
134 | static inline CCoeControl* statusPaneSubPane(TInt aPaneId);
|
---|
135 | static inline CAknTitlePane* titlePane();
|
---|
136 | static inline CAknContextPane* contextPane();
|
---|
137 | static inline CEikButtonGroupContainer* buttonGroupContainer();
|
---|
138 |
|
---|
139 | TTrapHandler *s60InstalledTrapHandler;
|
---|
140 | #endif
|
---|
141 | };
|
---|
142 |
|
---|
143 | QS60Data* qGlobalS60Data();
|
---|
144 | #define S60 qGlobalS60Data()
|
---|
145 |
|
---|
146 | class QAbstractLongTapObserver
|
---|
147 | {
|
---|
148 | public:
|
---|
149 | virtual void HandleLongTapEventL( const TPoint& aPenEventLocation,
|
---|
150 | const TPoint& aPenEventScreenLocation ) = 0;
|
---|
151 | };
|
---|
152 | class QLongTapTimer;
|
---|
153 |
|
---|
154 |
|
---|
155 | class QSymbianControl : public CCoeControl, public QAbstractLongTapObserver
|
---|
156 | #ifdef Q_WS_S60
|
---|
157 | , public MAknFadedComponent
|
---|
158 | #endif
|
---|
159 | {
|
---|
160 | public:
|
---|
161 | DECLARE_TYPE_ID(0x51740000) // Fun fact: the two first values are "Qt" in ASCII.
|
---|
162 |
|
---|
163 | public:
|
---|
164 | QSymbianControl(QWidget *w);
|
---|
165 | void ConstructL(bool isWindowOwning = false, bool desktop = false);
|
---|
166 | ~QSymbianControl();
|
---|
167 | void HandleResourceChange(int resourceType);
|
---|
168 | void HandlePointerEventL(const TPointerEvent& aPointerEvent);
|
---|
169 | TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
|
---|
170 | #if !defined(QT_NO_IM) && defined(Q_WS_S60)
|
---|
171 | TCoeInputCapabilities InputCapabilities() const;
|
---|
172 | #endif
|
---|
173 | TTypeUid::Ptr MopSupplyObject(TTypeUid id);
|
---|
174 |
|
---|
175 | inline QWidget* widget() const { return qwidget; }
|
---|
176 | void setWidget(QWidget *w);
|
---|
177 | void sendInputEvent(QWidget *widget, QInputEvent *inputEvent);
|
---|
178 | void setIgnoreFocusChanged(bool enabled) { m_ignoreFocusChanged = enabled; }
|
---|
179 | void CancelLongTapTimer();
|
---|
180 |
|
---|
181 | void setFocusSafely(bool focus);
|
---|
182 |
|
---|
183 | #ifdef Q_WS_S60
|
---|
184 | void FadeBehindPopup(bool fade){ popupFader.FadeBehindPopup( this, this, fade); }
|
---|
185 |
|
---|
186 | protected: // from MAknFadedComponent
|
---|
187 | TInt CountFadedComponents() {return 1;}
|
---|
188 | CCoeControl* FadedComponent(TInt /*aIndex*/) {return this;}
|
---|
189 | #else
|
---|
190 | #warning No fallback implementation for QSymbianControl::FadeBehindPopup
|
---|
191 | void FadeBehindPopup(bool /*fade*/){ }
|
---|
192 | #endif
|
---|
193 |
|
---|
194 | protected:
|
---|
195 | void Draw(const TRect& aRect) const;
|
---|
196 | void SizeChanged();
|
---|
197 | void PositionChanged();
|
---|
198 | void FocusChanged(TDrawNow aDrawNow);
|
---|
199 |
|
---|
200 | private:
|
---|
201 | void HandlePointerEvent(const TPointerEvent& aPointerEvent);
|
---|
202 | TKeyResponse OfferKeyEvent(const TKeyEvent& aKeyEvent,TEventCode aType);
|
---|
203 | TKeyResponse sendKeyEvent(QWidget *widget, QKeyEvent *keyEvent);
|
---|
204 | bool sendMouseEvent(QWidget *widget, QMouseEvent *mEvent);
|
---|
205 | void sendMouseEvent(
|
---|
206 | QWidget *receiver,
|
---|
207 | QEvent::Type type,
|
---|
208 | const QPoint &globalPos,
|
---|
209 | Qt::MouseButton button,
|
---|
210 | Qt::KeyboardModifiers modifiers);
|
---|
211 | void HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation );
|
---|
212 | #ifdef QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER
|
---|
213 | void translateAdvancedPointerEvent(const TAdvancedPointerEvent *event);
|
---|
214 | #endif
|
---|
215 |
|
---|
216 | private:
|
---|
217 | static QSymbianControl *lastFocusedControl;
|
---|
218 |
|
---|
219 | private:
|
---|
220 | QWidget *qwidget;
|
---|
221 | QLongTapTimer* m_longTapDetector;
|
---|
222 | bool m_ignoreFocusChanged : 1;
|
---|
223 | bool m_symbianPopupIsOpen : 1;
|
---|
224 |
|
---|
225 | #ifdef Q_WS_S60
|
---|
226 | // Fader object used to fade everything except this menu and the CBA.
|
---|
227 | TAknPopupFader popupFader;
|
---|
228 | #endif
|
---|
229 | };
|
---|
230 |
|
---|
231 | inline QS60Data::QS60Data()
|
---|
232 | {
|
---|
233 | memclr(this, sizeof(QS60Data)); //zero init data
|
---|
234 | }
|
---|
235 |
|
---|
236 | inline void QS60Data::updateScreenSize()
|
---|
237 | {
|
---|
238 | TPixelsTwipsAndRotation params;
|
---|
239 | int mode = S60->screenDevice()->CurrentScreenMode();
|
---|
240 | S60->screenDevice()->GetScreenModeSizeAndRotation(mode, params);
|
---|
241 | S60->screenWidthInPixels = params.iPixelSize.iWidth;
|
---|
242 | S60->screenHeightInPixels = params.iPixelSize.iHeight;
|
---|
243 | S60->screenWidthInTwips = params.iTwipsSize.iWidth;
|
---|
244 | S60->screenHeightInTwips = params.iTwipsSize.iHeight;
|
---|
245 |
|
---|
246 | S60->virtualMouseMaxAccel = qMax(S60->screenHeightInPixels, S60->screenWidthInPixels) / 20;
|
---|
247 |
|
---|
248 | TReal inches = S60->screenHeightInTwips / (TReal)KTwipsPerInch;
|
---|
249 | S60->defaultDpiY = S60->screenHeightInPixels / inches;
|
---|
250 | inches = S60->screenWidthInTwips / (TReal)KTwipsPerInch;
|
---|
251 | S60->defaultDpiX = S60->screenWidthInPixels / inches;
|
---|
252 | }
|
---|
253 |
|
---|
254 | inline RWsSession& QS60Data::wsSession()
|
---|
255 | {
|
---|
256 | return CCoeEnv::Static()->WsSession();
|
---|
257 | }
|
---|
258 |
|
---|
259 | inline RWindowGroup& QS60Data::windowGroup()
|
---|
260 | {
|
---|
261 | return CCoeEnv::Static()->RootWin();
|
---|
262 | }
|
---|
263 |
|
---|
264 | inline CWsScreenDevice* QS60Data::screenDevice()
|
---|
265 | {
|
---|
266 | return CCoeEnv::Static()->ScreenDevice();
|
---|
267 | }
|
---|
268 |
|
---|
269 | inline CCoeAppUi* QS60Data::appUi()
|
---|
270 | {
|
---|
271 | return CCoeEnv::Static()-> AppUi();
|
---|
272 | }
|
---|
273 |
|
---|
274 | inline CEikMenuBar* QS60Data::menuBar()
|
---|
275 | {
|
---|
276 | return CEikonEnv::Static()->AppUiFactory()->MenuBar();
|
---|
277 | }
|
---|
278 |
|
---|
279 | #ifdef Q_WS_S60
|
---|
280 | inline CEikStatusPane* QS60Data::statusPane()
|
---|
281 | {
|
---|
282 | return CEikonEnv::Static()->AppUiFactory()->StatusPane();
|
---|
283 | }
|
---|
284 |
|
---|
285 | // Returns the application's status pane control, if not present returns NULL.
|
---|
286 | inline CCoeControl* QS60Data::statusPaneSubPane( TInt aPaneId )
|
---|
287 | {
|
---|
288 | const TUid paneUid = { aPaneId };
|
---|
289 | CEikStatusPane* statusPane = S60->statusPane();
|
---|
290 | if (statusPane && statusPane->PaneCapabilities(paneUid).IsPresent()) {
|
---|
291 | CCoeControl* control = NULL;
|
---|
292 | // ControlL shouldn't leave because the pane is present
|
---|
293 | TRAPD(err, control = statusPane->ControlL(paneUid));
|
---|
294 | return err != KErrNone ? NULL : control;
|
---|
295 | }
|
---|
296 | return NULL;
|
---|
297 | }
|
---|
298 |
|
---|
299 | // Returns the application's title pane, if not present returns NULL.
|
---|
300 | inline CAknTitlePane* QS60Data::titlePane()
|
---|
301 | {
|
---|
302 | return static_cast<CAknTitlePane*>(S60->statusPaneSubPane(EEikStatusPaneUidTitle));
|
---|
303 | }
|
---|
304 |
|
---|
305 | // Returns the application's title pane, if not present returns NULL.
|
---|
306 | inline CAknContextPane* QS60Data::contextPane()
|
---|
307 | {
|
---|
308 | return static_cast<CAknContextPane*>(S60->statusPaneSubPane(EEikStatusPaneUidContext));
|
---|
309 | }
|
---|
310 |
|
---|
311 | inline CEikButtonGroupContainer* QS60Data::buttonGroupContainer()
|
---|
312 | {
|
---|
313 | return CEikonEnv::Static()->AppUiFactory()->Cba();
|
---|
314 | }
|
---|
315 | #endif // Q_WS_S60
|
---|
316 |
|
---|
317 | static inline QFont qt_TFontSpec2QFontL(const TFontSpec &fontSpec)
|
---|
318 | {
|
---|
319 | return QFont(
|
---|
320 | qt_TDesC2QString(fontSpec.iTypeface.iName),
|
---|
321 | fontSpec.iHeight / KTwipsPerPoint,
|
---|
322 | fontSpec.iFontStyle.StrokeWeight() == EStrokeWeightNormal ? QFont::Normal : QFont::Bold,
|
---|
323 | fontSpec.iFontStyle.Posture() == EPostureItalic
|
---|
324 | );
|
---|
325 | }
|
---|
326 |
|
---|
327 | static inline QImage::Format qt_TDisplayMode2Format(TDisplayMode mode)
|
---|
328 | {
|
---|
329 | QImage::Format format;
|
---|
330 | switch(mode) {
|
---|
331 | case EGray2:
|
---|
332 | format = QImage::Format_MonoLSB;
|
---|
333 | break;
|
---|
334 | case EColor256:
|
---|
335 | case EGray256:
|
---|
336 | format = QImage::Format_Indexed8;
|
---|
337 | break;
|
---|
338 | case EColor4K:
|
---|
339 | format = QImage::Format_RGB444;
|
---|
340 | break;
|
---|
341 | case EColor64K:
|
---|
342 | format = QImage::Format_RGB16;
|
---|
343 | break;
|
---|
344 | case EColor16M:
|
---|
345 | format = QImage::Format_RGB888;
|
---|
346 | break;
|
---|
347 | case EColor16MU:
|
---|
348 | format = QImage::Format_RGB32;
|
---|
349 | break;
|
---|
350 | case EColor16MA:
|
---|
351 | format = QImage::Format_ARGB32;
|
---|
352 | break;
|
---|
353 | case Q_SYMBIAN_ECOLOR16MAP:
|
---|
354 | format = QImage::Format_ARGB32_Premultiplied;
|
---|
355 | break;
|
---|
356 | default:
|
---|
357 | format = QImage::Format_Invalid;
|
---|
358 | break;
|
---|
359 | }
|
---|
360 | return format;
|
---|
361 | }
|
---|
362 |
|
---|
363 | #ifndef QT_NO_CURSOR
|
---|
364 | void qt_symbian_setWindowCursor(const QCursor &cursor, const CCoeControl* wid);
|
---|
365 | void qt_symbian_setWindowGroupCursor(const QCursor &cursor, RWindowTreeNode &node);
|
---|
366 | void qt_symbian_setGlobalCursor(const QCursor &cursor);
|
---|
367 | void qt_symbian_set_cursor_visible(bool visible);
|
---|
368 | bool qt_symbian_is_cursor_visible();
|
---|
369 | #endif
|
---|
370 |
|
---|
371 | QT_END_NAMESPACE
|
---|
372 |
|
---|
373 | #endif // QT_S60_P_H
|
---|