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 QAPPLICATION_P_H
|
---|
43 | #define QAPPLICATION_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 for the convenience
|
---|
50 | // of qapplication_*.cpp, qwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp
|
---|
51 | // and many other. This header file may change from version to version
|
---|
52 | // without notice, or even be removed.
|
---|
53 | //
|
---|
54 | // We mean it.
|
---|
55 | //
|
---|
56 |
|
---|
57 | #include "QtGui/qapplication.h"
|
---|
58 | #include "QtGui/qevent.h"
|
---|
59 | #include "QtGui/qfont.h"
|
---|
60 | #include "QtGui/qcursor.h"
|
---|
61 | #include "QtGui/qregion.h"
|
---|
62 | #include "QtCore/qmutex.h"
|
---|
63 | #include "QtCore/qtranslator.h"
|
---|
64 | #include "QtCore/qbasictimer.h"
|
---|
65 | #include "QtCore/qhash.h"
|
---|
66 | #include "QtCore/qpointer.h"
|
---|
67 | #include "private/qcoreapplication_p.h"
|
---|
68 | #include "private/qshortcutmap_p.h"
|
---|
69 | #include <private/qthread_p.h>
|
---|
70 | #ifdef Q_WS_QWS
|
---|
71 | #include "QtGui/qscreen_qws.h"
|
---|
72 | #include <private/qgraphicssystem_qws_p.h>
|
---|
73 | #endif
|
---|
74 | #ifdef Q_OS_SYMBIAN
|
---|
75 | #include <w32std.h>
|
---|
76 | #endif
|
---|
77 |
|
---|
78 | QT_BEGIN_NAMESPACE
|
---|
79 |
|
---|
80 | class QClipboard;
|
---|
81 | class QGraphicsScene;
|
---|
82 | class QGraphicsSystem;
|
---|
83 | class QInputContext;
|
---|
84 | class QObject;
|
---|
85 | class QWidget;
|
---|
86 | class QSocketNotifier;
|
---|
87 | class QGestureManager;
|
---|
88 |
|
---|
89 | extern bool qt_is_gui_used;
|
---|
90 | #ifndef QT_NO_CLIPBOARD
|
---|
91 | extern QClipboard *qt_clipboard;
|
---|
92 | #endif
|
---|
93 |
|
---|
94 | #if defined (Q_OS_WIN32) || defined (Q_OS_CYGWIN) || defined(Q_OS_WINCE)
|
---|
95 | extern QSysInfo::WinVersion qt_winver;
|
---|
96 | enum { QT_TABLET_NPACKETQSIZE = 128 };
|
---|
97 | # ifdef Q_OS_WINCE
|
---|
98 | extern DWORD qt_cever;
|
---|
99 | # endif
|
---|
100 | #elif defined (Q_OS_MAC)
|
---|
101 | extern QSysInfo::MacVersion qt_macver;
|
---|
102 | #endif
|
---|
103 | #if defined(Q_WS_QWS)
|
---|
104 | class QWSManager;
|
---|
105 | class QDirectPainter;
|
---|
106 | struct QWSServerCleaner { ~QWSServerCleaner(); };
|
---|
107 | #endif
|
---|
108 |
|
---|
109 | #ifndef QT_NO_TABLET
|
---|
110 | struct QTabletDeviceData
|
---|
111 | {
|
---|
112 | #ifndef Q_WS_MAC
|
---|
113 | int minPressure;
|
---|
114 | int maxPressure;
|
---|
115 | int minTanPressure;
|
---|
116 | int maxTanPressure;
|
---|
117 | int minX, maxX, minY, maxY, minZ, maxZ;
|
---|
118 | inline QPointF scaleCoord(int coordX, int coordY, int outOriginX, int outExtentX,
|
---|
119 | int outOriginY, int outExtentY) const;
|
---|
120 | #endif
|
---|
121 |
|
---|
122 | #if defined(Q_WS_X11) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA))
|
---|
123 | QPointer<QWidget> widgetToGetPress;
|
---|
124 | #endif
|
---|
125 |
|
---|
126 | #ifdef Q_WS_X11
|
---|
127 | int deviceType;
|
---|
128 | enum {
|
---|
129 | TOTAL_XINPUT_EVENTS = 64
|
---|
130 | };
|
---|
131 | void *device;
|
---|
132 | int eventCount;
|
---|
133 | long unsigned int eventList[TOTAL_XINPUT_EVENTS]; // XEventClass is in fact a long unsigned int
|
---|
134 |
|
---|
135 | int xinput_motion;
|
---|
136 | int xinput_key_press;
|
---|
137 | int xinput_key_release;
|
---|
138 | int xinput_button_press;
|
---|
139 | int xinput_button_release;
|
---|
140 | int xinput_proximity_in;
|
---|
141 | int xinput_proximity_out;
|
---|
142 | #elif defined(Q_WS_WIN)
|
---|
143 | qint64 llId;
|
---|
144 | int currentDevice;
|
---|
145 | int currentPointerType;
|
---|
146 | #elif defined(Q_WS_MAC)
|
---|
147 | quint64 tabletUniqueID;
|
---|
148 | int tabletDeviceType;
|
---|
149 | int tabletPointerType;
|
---|
150 | int capabilityMask;
|
---|
151 | #endif
|
---|
152 | };
|
---|
153 |
|
---|
154 | static inline int sign(int x)
|
---|
155 | {
|
---|
156 | return x >= 0 ? 1 : -1;
|
---|
157 | }
|
---|
158 |
|
---|
159 | #ifndef Q_WS_MAC
|
---|
160 | inline QPointF QTabletDeviceData::scaleCoord(int coordX, int coordY,
|
---|
161 | int outOriginX, int outExtentX,
|
---|
162 | int outOriginY, int outExtentY) const
|
---|
163 | {
|
---|
164 | QPointF ret;
|
---|
165 |
|
---|
166 | if (sign(outExtentX) == sign(maxX))
|
---|
167 | ret.setX(((coordX - minX) * qAbs(outExtentX) / qAbs(qreal(maxX - minX))) + outOriginX);
|
---|
168 | else
|
---|
169 | ret.setX(((qAbs(maxX) - (coordX - minX)) * qAbs(outExtentX) / qAbs(qreal(maxX - minX)))
|
---|
170 | + outOriginX);
|
---|
171 |
|
---|
172 | if (sign(outExtentY) == sign(maxY))
|
---|
173 | ret.setY(((coordY - minY) * qAbs(outExtentY) / qAbs(qreal(maxY - minY))) + outOriginY);
|
---|
174 | else
|
---|
175 | ret.setY(((qAbs(maxY) - (coordY - minY)) * qAbs(outExtentY) / qAbs(qreal(maxY - minY)))
|
---|
176 | + outOriginY);
|
---|
177 |
|
---|
178 | return ret;
|
---|
179 | }
|
---|
180 | #endif
|
---|
181 |
|
---|
182 | typedef QList<QTabletDeviceData> QTabletDeviceDataList;
|
---|
183 | QTabletDeviceDataList *qt_tablet_devices();
|
---|
184 | # if defined(Q_WS_MAC)
|
---|
185 | typedef QHash<int, QTabletDeviceData> QMacTabletHash;
|
---|
186 | QMacTabletHash *qt_mac_tablet_hash();
|
---|
187 | # endif
|
---|
188 | #endif
|
---|
189 |
|
---|
190 | #ifdef QT3_SUPPORT
|
---|
191 | extern "C" {
|
---|
192 | typedef bool (*Ptrqt_tryAccelEvent)(QWidget *w, QKeyEvent *e);
|
---|
193 | typedef bool (*Ptrqt_tryComposeUnicode)(QWidget *w, QKeyEvent *e);
|
---|
194 | typedef bool (*Ptrqt_dispatchAccelEvent)(QWidget *w, QKeyEvent *e);
|
---|
195 | }
|
---|
196 | #endif
|
---|
197 |
|
---|
198 | #if defined(Q_WS_WIN)
|
---|
199 | typedef BOOL (WINAPI *PtrRegisterTouchWindow)(HWND, ULONG);
|
---|
200 | typedef BOOL (WINAPI *PtrGetTouchInputInfo)(HANDLE, UINT, PVOID, int);
|
---|
201 | typedef BOOL (WINAPI *PtrCloseTouchInputHandle)(HANDLE);
|
---|
202 |
|
---|
203 | typedef BOOL (WINAPI *PtrGetGestureInfo)(HANDLE, PVOID);
|
---|
204 | typedef BOOL (WINAPI *PtrGetGestureExtraArgs)(HANDLE, UINT, PBYTE);
|
---|
205 | typedef BOOL (WINAPI *PtrCloseGestureInfoHandle)(HANDLE);
|
---|
206 | typedef BOOL (WINAPI *PtrSetGestureConfig)(HWND, DWORD, UINT, PVOID, UINT);
|
---|
207 | typedef BOOL (WINAPI *PtrGetGestureConfig)(HWND, DWORD, DWORD, PUINT, PVOID, UINT);
|
---|
208 |
|
---|
209 | typedef BOOL (WINAPI *PtrBeginPanningFeedback)(HWND);
|
---|
210 | typedef BOOL (WINAPI *PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL);
|
---|
211 | typedef BOOL (WINAPI *PtrEndPanningFeedback)(HWND, BOOL);
|
---|
212 |
|
---|
213 | #ifndef WM_GESTURE
|
---|
214 | # define WM_GESTURE 0x0119
|
---|
215 |
|
---|
216 | # define GID_BEGIN 1
|
---|
217 | # define GID_END 2
|
---|
218 | # define GID_ZOOM 3
|
---|
219 | # define GID_PAN 4
|
---|
220 | # define GID_ROTATE 5
|
---|
221 | # define GID_TWOFINGERTAP 6
|
---|
222 | # define GID_ROLLOVER 7
|
---|
223 |
|
---|
224 | typedef struct tagGESTUREINFO
|
---|
225 | {
|
---|
226 | UINT cbSize;
|
---|
227 | DWORD dwFlags;
|
---|
228 | DWORD dwID;
|
---|
229 | HWND hwndTarget;
|
---|
230 | POINTS ptsLocation;
|
---|
231 | DWORD dwInstanceID;
|
---|
232 | DWORD dwSequenceID;
|
---|
233 | ULONGLONG ullArguments;
|
---|
234 | UINT cbExtraArgs;
|
---|
235 | } GESTUREINFO;
|
---|
236 |
|
---|
237 | # define GC_PAN 0x00000001
|
---|
238 | # define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
|
---|
239 | # define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
|
---|
240 |
|
---|
241 | # define GC_ZOOM 0x00000001
|
---|
242 | # define GC_ROTATE 0x00000001
|
---|
243 |
|
---|
244 | typedef struct tagGESTURECONFIG
|
---|
245 | {
|
---|
246 | DWORD dwID;
|
---|
247 | DWORD dwWant;
|
---|
248 | DWORD dwBlock;
|
---|
249 | } GESTURECONFIG;
|
---|
250 |
|
---|
251 | # define GID_ROTATE_ANGLE_FROM_ARGUMENT(arg) ((((double)(arg) / 65535.0) * 4.0 * 3.14159265) - 2.0*3.14159265)
|
---|
252 |
|
---|
253 | #endif // WM_GESTURE
|
---|
254 |
|
---|
255 | #if defined(Q_WS_WINCE_WM) && defined(QT_WINCE_GESTURES)
|
---|
256 | #undef GID_ZOOM
|
---|
257 | #define GID_ZOOM 0xf000
|
---|
258 | #undef GID_ROTATE
|
---|
259 | #define GID_ROTATE 0xf001
|
---|
260 | #undef GID_TWOFINGERTAP
|
---|
261 | #define GID_TWOFINGERTAP 0xf002
|
---|
262 | #undef GID_ROLLOVER
|
---|
263 | #define GID_ROLLOVER 0xf003
|
---|
264 | #endif
|
---|
265 |
|
---|
266 | #endif // Q_WS_WIN
|
---|
267 |
|
---|
268 | class QScopedLoopLevelCounter
|
---|
269 | {
|
---|
270 | QThreadData *threadData;
|
---|
271 | public:
|
---|
272 | QScopedLoopLevelCounter(QThreadData *threadData)
|
---|
273 | : threadData(threadData)
|
---|
274 | { ++threadData->loopLevel; }
|
---|
275 | ~QScopedLoopLevelCounter()
|
---|
276 | { --threadData->loopLevel; }
|
---|
277 | };
|
---|
278 |
|
---|
279 | typedef QHash<QByteArray, QFont> FontHash;
|
---|
280 | FontHash *qt_app_fonts_hash();
|
---|
281 |
|
---|
282 | typedef QHash<QByteArray, QPalette> PaletteHash;
|
---|
283 | PaletteHash *qt_app_palettes_hash();
|
---|
284 |
|
---|
285 | class Q_GUI_EXPORT QApplicationPrivate : public QCoreApplicationPrivate
|
---|
286 | {
|
---|
287 | Q_DECLARE_PUBLIC(QApplication)
|
---|
288 | public:
|
---|
289 | QApplicationPrivate(int &argc, char **argv, QApplication::Type type);
|
---|
290 | ~QApplicationPrivate();
|
---|
291 |
|
---|
292 | #if defined(Q_WS_X11)
|
---|
293 | #ifndef QT_NO_SETTINGS
|
---|
294 | static bool x11_apply_settings();
|
---|
295 | #endif
|
---|
296 | static void reset_instance_pointer();
|
---|
297 | #elif defined(Q_WS_QWS)
|
---|
298 | static bool qws_apply_settings();
|
---|
299 | static QWidget *findWidget(const QObjectList&, const QPoint &, bool rec);
|
---|
300 | #endif
|
---|
301 | static bool quitOnLastWindowClosed;
|
---|
302 | static void emitLastWindowClosed();
|
---|
303 | #ifdef Q_WS_WINCE
|
---|
304 | static int autoMaximizeThreshold;
|
---|
305 | #endif
|
---|
306 | static bool autoSipEnabled;
|
---|
307 | static QString desktopStyleKey();
|
---|
308 |
|
---|
309 | static QGraphicsSystem *graphicsSystem()
|
---|
310 | #if !defined(Q_WS_QWS)
|
---|
311 | { return graphics_system; }
|
---|
312 | #else
|
---|
313 | { return QScreen::instance()->graphicsSystem(); }
|
---|
314 | #endif
|
---|
315 |
|
---|
316 | void createEventDispatcher();
|
---|
317 | QString appName() const;
|
---|
318 | static void dispatchEnterLeave(QWidget *enter, QWidget *leave);
|
---|
319 |
|
---|
320 | //modality
|
---|
321 | static void enterModal(QWidget*);
|
---|
322 | static void leaveModal(QWidget*);
|
---|
323 | static void enterModal_sys(QWidget*);
|
---|
324 | static void leaveModal_sys(QWidget*);
|
---|
325 | static bool isBlockedByModal(QWidget *widget);
|
---|
326 | static bool modalState();
|
---|
327 | static bool tryModalHelper(QWidget *widget, QWidget **rettop = 0);
|
---|
328 | #ifdef Q_WS_MAC
|
---|
329 | static QWidget *tryModalHelper_sys(QWidget *top);
|
---|
330 | bool canQuit();
|
---|
331 | #endif
|
---|
332 |
|
---|
333 | bool notify_helper(QObject *receiver, QEvent * e);
|
---|
334 |
|
---|
335 | void construct(
|
---|
336 | #ifdef Q_WS_X11
|
---|
337 | Display *dpy = 0, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0
|
---|
338 | #endif
|
---|
339 | );
|
---|
340 | void initialize();
|
---|
341 | void process_cmdline();
|
---|
342 |
|
---|
343 | #if defined(Q_WS_X11)
|
---|
344 | static void x11_initialize_style();
|
---|
345 | #endif
|
---|
346 |
|
---|
347 | enum KeyPlatform {
|
---|
348 | KB_Win = 1,
|
---|
349 | KB_Mac = 2,
|
---|
350 | KB_X11 = 4,
|
---|
351 | KB_KDE = 8,
|
---|
352 | KB_Gnome = 16,
|
---|
353 | KB_CDE = 32,
|
---|
354 | KB_S60 = 64,
|
---|
355 | KB_All = 0xffff
|
---|
356 | };
|
---|
357 |
|
---|
358 | static uint currentPlatform();
|
---|
359 | bool inPopupMode() const;
|
---|
360 | void closePopup(QWidget *popup);
|
---|
361 | void openPopup(QWidget *popup);
|
---|
362 | static void setFocusWidget(QWidget *focus, Qt::FocusReason reason);
|
---|
363 | static QWidget *focusNextPrevChild_helper(QWidget *toplevel, bool next);
|
---|
364 |
|
---|
|
---|