1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** Contact: Qt Software Information ([email protected])
|
---|
5 | **
|
---|
6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
7 | **
|
---|
8 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
9 | ** Commercial Usage
|
---|
10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
11 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
12 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
13 | ** a written agreement between you and Nokia.
|
---|
14 | **
|
---|
15 | ** GNU Lesser General Public License Usage
|
---|
16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
17 | ** General Public License version 2.1 as published by the Free Software
|
---|
18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
19 | ** packaging of this file. Please review the following information to
|
---|
20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
22 | **
|
---|
23 | ** In addition, as a special exception, Nokia gives you certain
|
---|
24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
---|
25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
---|
26 | ** 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 are unsure which license is appropriate for your use, please
|
---|
37 | ** contact the sales department at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef QWIDGET_P_H
|
---|
43 | #define QWIDGET_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 and qfiledialog.cpp. This header
|
---|
51 | // file may change from version to version without notice, or even be removed.
|
---|
52 | //
|
---|
53 | // We mean it.
|
---|
54 | //
|
---|
55 |
|
---|
56 | #include "QtGui/qwidget.h"
|
---|
57 | #include "private/qobject_p.h"
|
---|
58 | #include "QtCore/qrect.h"
|
---|
59 | #include "QtCore/qlocale.h"
|
---|
60 | #include "QtGui/qregion.h"
|
---|
61 | #include "QtGui/qsizepolicy.h"
|
---|
62 | #include "QtGui/qstyle.h"
|
---|
63 |
|
---|
64 | #ifdef Q_WS_WIN
|
---|
65 | #include "QtCore/qt_windows.h"
|
---|
66 | #include <private/qdnd_p.h>
|
---|
67 | #endif // Q_WS_WIN
|
---|
68 |
|
---|
69 | #ifdef Q_WS_PM
|
---|
70 | #include "QtCore/qt_os2.h"
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | #ifdef Q_WS_X11
|
---|
74 | #include "QtGui/qx11info_x11.h"
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | #ifdef Q_WS_MAC
|
---|
78 | #include <private/qt_mac_p.h>
|
---|
79 | #endif
|
---|
80 |
|
---|
81 | #if defined(Q_WS_QWS)
|
---|
82 | #include "QtGui/qinputcontext.h"
|
---|
83 | #include "QtGui/qscreen_qws.h"
|
---|
84 | #endif
|
---|
85 |
|
---|
86 | QT_BEGIN_NAMESPACE
|
---|
87 |
|
---|
88 | // Extra QWidget data
|
---|
89 | // - to minimize memory usage for members that are seldom used.
|
---|
90 | // - top-level widgets have extra extra data to reduce cost further
|
---|
91 | #if defined(Q_WS_QWS)
|
---|
92 | class QWSManager;
|
---|
93 | #endif
|
---|
94 | #if defined(Q_WS_MAC)
|
---|
95 | class QCoreGraphicsPaintEnginePrivate;
|
---|
96 | #endif
|
---|
97 | class QPaintEngine;
|
---|
98 | class QPixmap;
|
---|
99 | class QWidgetBackingStore;
|
---|
100 | class QGraphicsProxyWidget;
|
---|
101 | class QWidgetItemV2;
|
---|
102 |
|
---|
103 | class QStyle;
|
---|
104 |
|
---|
105 | struct QTLWExtra {
|
---|
106 | QString caption; // widget caption
|
---|
107 | QString iconText; // widget icon text
|
---|
108 | QString role; // widget role
|
---|
109 | QString filePath; // widget file path
|
---|
110 | QIcon *icon; // widget icon
|
---|
111 | QPixmap *iconPixmap;
|
---|
112 | short incw, inch; // size increments
|
---|
113 | // frame strut, don't use these directly, use QWidgetPrivate::frameStrut() instead.
|
---|
114 | QRect frameStrut;
|
---|
115 | uint opacity : 8;
|
---|
116 | uint posFromMove : 1;
|
---|
117 | uint sizeAdjusted : 1;
|
---|
118 | uint inTopLevelResize : 1;
|
---|
119 | uint inRepaint : 1;
|
---|
120 | QWidgetBackingStore *backingStore;
|
---|
121 | #if defined(Q_WS_WIN)
|
---|
122 | ulong savedFlags; // Save window flags while showing fullscreen
|
---|
123 | uint embedded : 1; // window is embedded in another application
|
---|
124 | #else
|
---|
125 | Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
|
---|
126 | #endif
|
---|
127 | short basew, baseh; // base sizes
|
---|
128 | #if defined(Q_WS_X11)
|
---|
129 | WId parentWinId; // parent window Id (valid after reparenting)
|
---|
130 | uint embedded : 1; // window is embedded in another Qt application
|
---|
131 | uint spont_unmapped: 1; // window was spontaneously unmapped
|
---|
132 | uint dnd : 1; // DND properties installed
|
---|
133 | uint validWMState : 1; // is WM_STATE valid?
|
---|
134 | uint waitingForMapNotify : 1; // show() has been called, haven't got the MapNotify yet
|
---|
135 | WId userTimeWindow; // window id that contains user-time timestamp when WM supports a _NET_WM_USER_TIME_WINDOW atom
|
---|
136 | QPoint fullScreenOffset;
|
---|
137 | #endif
|
---|
138 | #if defined(Q_WS_MAC)
|
---|
139 | quint32 wattr;
|
---|
140 | quint32 wclass;
|
---|
141 | WindowGroupRef group;
|
---|
142 | IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
|
---|
143 | quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys()
|
---|
144 | uint resizer : 4;
|
---|
145 | uint isSetGeometry : 1;
|
---|
146 | uint isMove : 1;
|
---|
147 | uint embedded : 1;
|
---|
148 | #endif
|
---|
149 | #if defined(Q_WS_QWS) && !defined (QT_NO_QWS_MANAGER)
|
---|
150 | QWSManager *qwsManager;
|
---|
151 | #endif
|
---|
152 | #if defined(Q_WS_WIN)
|
---|
153 | HICON winIconBig; // internal big Windows icon
|
---|
154 | HICON winIconSmall; // internal small Windows icon
|
---|
155 | #endif
|
---|
156 | #if defined(Q_WS_PM)
|
---|
157 | HWND fId;
|
---|
158 | HSWITCH swEntry;
|
---|
159 | HPOINTER iconPointer;
|
---|
160 | #endif
|
---|
161 | QRect normalGeometry; // used by showMin/maximized/FullScreen
|
---|
162 | QWindowSurface *windowSurface;
|
---|
163 | QPainter *sharedPainter;
|
---|
164 | };
|
---|
165 |
|
---|
166 | struct QWExtra {
|
---|
167 | qint32 minw, minh; // minimum size
|
---|
168 | qint32 maxw, maxh; // maximum size
|
---|
169 | QPointer<QWidget> focus_proxy;
|
---|
170 | #ifndef QT_NO_CURSOR
|
---|
171 | QCursor *curs;
|
---|
172 | #endif
|
---|
173 | QTLWExtra *topextra; // only useful for TLWs
|
---|
174 | QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
|
---|
175 | void *glContext; // if the widget is hijacked by QGLWindowSurface
|
---|
176 | #if defined(Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
|
---|
177 | QOleDropTarget *dropTarget; // drop target
|
---|
178 | QList<QPointer<QWidget> > oleDropWidgets;
|
---|
179 | #endif
|
---|
180 | #if defined(Q_WS_X11)
|
---|
181 | WId xDndProxy; // XDND forwarding to embedded windows
|
---|
182 | #endif
|
---|
183 | QRegion mask; // widget mask
|
---|
184 | QSize staticContentsSize;
|
---|
185 |
|
---|
186 | //bit flags at the end to improve packing
|
---|
187 | #if defined(Q_WS_WIN)
|
---|
188 | uint shown_mode : 8; // widget show mode
|
---|
189 | #ifndef QT_NO_DIRECT3D
|
---|
190 | uint had_paint_on_screen : 1;
|
---|
191 | uint had_no_system_bg : 1;
|
---|
192 | uint had_auto_fill_bg : 1;
|
---|
193 | #endif
|
---|
194 | #endif
|
---|
195 | #if defined(Q_WS_X11)
|
---|
196 | uint compress_events : 1;
|
---|
197 | #endif
|
---|
198 | uint explicitMinSize : 2;
|
---|
199 | uint explicitMaxSize : 2;
|
---|
200 | uint autoFillBackground : 1;
|
---|
201 | uint nativeChildrenForced : 1;
|
---|
202 | uint inRenderWithPainter : 1;
|
---|
203 | uint hasMask : 1;
|
---|
204 |
|
---|
205 | QPointer<QStyle> style;
|
---|
206 | QString styleSheet;
|
---|
207 |
|
---|
208 | quint16 customDpiX;
|
---|
209 | quint16 customDpiY;
|
---|
210 | #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
|
---|
211 | // Cocoa Mask stuff
|
---|
212 | QImage maskBits;
|
---|
213 | CGImageRef imageMask;
|
---|
214 | #endif
|
---|
215 | };
|
---|
216 |
|
---|
217 | class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
|
---|
218 | {
|
---|
219 | Q_DECLARE_PUBLIC(QWidget)
|
---|
220 |
|
---|
221 | public:
|
---|
222 | explicit QWidgetPrivate(int version = QObjectPrivateVersion);
|
---|
223 | ~QWidgetPrivate();
|
---|
224 |
|
---|
225 | QWExtra *extraData() const;
|
---|
226 | QTLWExtra *topData() const;
|
---|
227 | QTLWExtra *maybeTopData() const;
|
---|
228 | QPainter *sharedPainter() const;
|
---|
229 | void setSharedPainter(QPainter *painter);
|
---|
230 | QWidgetBackingStore *maybeBackingStore() const;
|
---|
231 | #ifdef Q_WS_QWS
|
---|
232 | void setMaxWindowState_helper();
|
---|
233 | void setFullScreenSize_helper();
|
---|
234 | #endif
|
---|
235 | void init(QWidget *desktopWidget, Qt::WindowFlags f);
|
---|
236 | void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
|
---|
237 | void createRecursively();
|
---|
238 | void createWinId(WId id = 0);
|
---|
239 |
|
---|
240 | void createTLExtra();
|
---|
241 | void createExtra();
|
---|
242 | void deleteExtra();
|
---|
243 | void createSysExtra();
|
---|
244 | void deleteSysExtra();
|
---|
245 | void createTLSysExtra();
|
---|
246 | void deleteTLSysExtra();
|
---|
247 | void updateSystemBackground();
|
---|
248 | void propagatePaletteChange();
|
---|
249 |
|
---|
250 | void setPalette_helper(const QPalette &);
|
---|
251 | void resolvePalette();
|
---|
252 | QPalette naturalWidgetPalette(uint inheritedMask) const;
|
---|
253 |
|
---|
254 | void setMask_sys(const QRegion &);
|
---|
255 | #ifdef Q_WS_WIN
|
---|
256 | bool shouldShowMaximizeButton();
|
---|
257 | void winUpdateIsOpaque();
|
---|
258 | #endif
|
---|
259 |
|
---|
260 | #ifdef Q_WS_MAC
|
---|
261 | void macUpdateSizeAttribute();
|
---|
262 | void macUpdateHideOnSuspend();
|
---|
263 | void macUpdateOpaqueSizeGrip();
|
---|
264 | void macUpdateIgnoreMouseEvents();
|
---|
265 | void macUpdateMetalAttribute();
|
---|
266 | void macUpdateIsOpaque();
|
---|
267 | void setEnabled_helper_sys(bool enable);
|
---|
268 | bool isRealWindow() const;
|
---|
269 | #endif
|
---|
270 |
|
---|
271 | void raise_sys();
|
---|
272 | void lower_sys();
|
---|
273 | void stackUnder_sys(QWidget *);
|
---|
274 |
|
---|
275 | void setFocus_sys();
|
---|
276 |
|
---|
277 | void updateFont(const QFont &);
|
---|
278 | inline void setFont_helper(const QFont &font) {
|
---|
279 | if (data.fnt == font && data.fnt.resolve() == font.resolve())
|
---|
280 | return;
|
---|
281 | updateFont(font);
|
---|
282 | }
|
---|
283 | void resolveFont();
|
---|
284 | QFont naturalWidgetFont(uint inheritedMask) const;
|
---|
285 |
|
---|
286 | void setLayoutDirection_helper(Qt::LayoutDirection);
|
---|
287 | void resolveLayoutDirection();
|
---|
288 |
|
---|
289 | void setLocale_helper(const QLocale &l, bool forceUpdate = false);
|
---|
290 | void resolveLocale();
|
---|
291 |
|
---|
292 | void setStyle_helper(QStyle *newStyle, bool propagate, bool metalHack = false);
|
---|
293 | void inheritStyle();
|
---|
294 |
|
---|
295 | bool isBackgroundInherited() const;
|
---|
296 |
|
---|
297 | void setUpdatesEnabled_helper(bool );
|
---|
298 |
|
---|
299 | void paintBackground(QPainter *, const QRegion &, const QPoint & = QPoint(), int flags = DrawAsRoot) const;
|
---|
300 | enum DrawWidgetFlags {
|
---|
301 | DrawAsRoot = 0x01,
|
---|
302 | DrawPaintOnScreen = 0x02,
|
---|
303 | DrawRecursive = 0x04,
|
---|
304 | DrawInvisible = 0x08,
|
---|
305 | DontSubtractOpaqueChildren = 0x10,
|
---|
306 | DontSetCompositionMode = 0x20,
|
---|
307 | DontDrawOpaqueChildren = 0x40
|
---|
308 | };
|
---|
309 | bool isAboutToShow() const;
|
---|
310 | QRegion prepareToRender(const QRegion ®ion, QWidget::RenderFlags renderFlags);
|
---|
311 | void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
|
---|
312 | QWidget::RenderFlags renderFlags);
|
---|
313 | void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
|
---|
314 | QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0);
|
---|
315 |
|
---|
316 |
|
---|
317 | void paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& children, int index,
|
---|
318 | const QRegion &rgn, const QPoint &offset, int flags
|
---|
319 | #ifdef Q_BACKINGSTORE_SUBSURFACES
|
---|
320 | , const QWindowSurface *currentSurface
|
---|
321 | #endif
|
---|
322 | , QPainter *sharedPainter, QWidgetBackingStore *backingStore);
|
---|
323 |
|
---|
324 |
|
---|
325 | QPainter *beginSharedPainter();
|
---|
326 | bool endSharedPainter();
|
---|
327 | static QGraphicsProxyWidget * nearestGraphicsProxyWidget(QWidget *origin);
|
---|
328 | QWindowSurface *createDefaultWindowSurface();
|
---|
329 | QWindowSurface *createDefaultWindowSurface_sys();
|
---|
330 | void repaint_sys(const QRegion &rgn);
|
---|
331 | #ifdef Q_WS_MAC
|
---|
332 | void update_sys(const QRect &rect);
|
---|
333 | void update_sys(const QRegion &rgn);
|
---|
334 | #endif
|
---|
335 |
|
---|
336 | QRect clipRect() const;
|
---|
337 | QRegion clipRegion() const;
|
---|
338 | void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const;
|
---|
339 | void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0,
|
---|
340 | bool alsoNonOpaque = false) const;
|
---|
341 | void clipToEffectiveMask(QRegion ®ion) const;
|
---|
342 | void updateIsOpaque();
|
---|
343 | void setOpaque(bool opaque);
|
---|
344 | void updateIsTranslucent();
|
---|
345 | bool hasBackground() const;
|
---|
346 | bool paintOnScreen() const;
|
---|
347 |
|
---|
348 | QRegion getOpaqueRegion() const;
|
---|
349 | const QRegion &getOpaqueChildren() const;
|
---|
350 | void setDirtyOpaqueRegion();
|
---|
351 |
|
---|
352 | QRegion opaqueChildren;
|
---|
353 |
|
---|
354 | enum CloseMode {
|
---|
355 | CloseNoEvent,
|
---|
356 | CloseWithEvent,
|
---|
357 | CloseWithSpontaneousEvent
|
---|
358 | };
|
---|
359 | bool close_helper(CloseMode mode);
|
---|
360 |
|
---|
361 | bool compositeEvent(QEvent *e);
|
---|
362 | void setWindowIcon_helper();
|
---|
363 | void setWindowIcon_sys(bool forceReset = false);
|
---|
364 | void setWindowOpacity_sys(qreal opacity);
|
---|
365 |
|
---|
366 | void adjustQuitOnCloseAttribute();
|
---|
367 |
|
---|
368 | #if defined(Q_WS_X11)
|
---|
369 | void setWindowRole();
|
---|
370 | void sendStartupMessage(const char *message) const;
|
---|
371 | void setNetWmWindowTypes();
|
---|
372 | void x11UpdateIsOpaque();
|
---|
373 | #endif
|
---|
374 |
|
---|
375 | #if defined(Q_WS_WIN) || defined(Q_WS_PM)
|
---|
376 | void reparentChildren();
|
---|
377 | #endif
|
---|
378 |
|
---|
379 | void scrollChildren(int dx, int dy);
|
---|
380 |
|
---|
381 | void moveRect(const QRect &, int dx, int dy);
|
---|
382 | void scrollRect(const QRect &, int dx, int dy);
|
---|
383 | void invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize);
|
---|
384 | // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
|
---|
385 | void invalidateBuffer(const QRegion &);
|
---|
386 | void invalidateBuffer(const QRect &);
|
---|
387 | bool isOverlapped(const QRect&) const;
|
---|
388 | void syncBackingStore();
|
---|
389 | void syncBackingStore(const QRegion ®ion);
|
---|
390 |
|
---|
391 | void reparentFocusWidgets(QWidget *oldtlw);
|
---|
392 |
|
---|
393 | static int pointToRect(const QPoint &p, const QRect &r);
|
---|
394 | QRect fromOrToLayoutItemRect(const QRect &rect, int sign) const;
|
---|
395 |
|
---|
396 | void setWinId(WId);
|
---|
397 | void showChildren(bool spontaneous);
|
---|
398 | void hideChildren(bool spontaneous);
|
---|
399 | void setParent_sys(QWidget *parent, Qt::WindowFlags);
|
---|
400 | void scroll_sys(int dx, int dy);
|
---|
401 | void scroll_sys(int dx, int dy, const QRect &r);
|
---|
402 | void deactivateWidgetCleanup();
|
---|
403 | void setGeometry_sys(int, int, int, int, bool);
|
---|
404 | #ifdef Q_WS_MAC
|
---|
405 | void setGeometry_sys_helper(int, int, int, int, bool);
|
---|
406 | #endif
|
---|
407 | void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
|
---|
408 | void activateChildLayoutsRecursively();
|
---|
409 | void show_recursive();
|
---|
410 | void show_helper();
|
---|
411 | void show_sys();
|
---|
412 | void hide_sys();
|
---|
413 | void hide_helper();
|
---|
414 | void _q_showIfNotHidden();
|
---|
415 |
|
---|
416 | void setEnabled_helper(bool);
|
---|
417 | void registerDropSite(bool);
|
---|
418 | #if defined(Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
|
---|
419 | QOleDropTarget *registerOleDnd(QWidget *widget);
|
---|
420 | void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
|
---|
421 | #endif
|
---|
422 | static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
|
---|
423 |
|
---|
424 | void updateFrameStrut();
|
---|
425 | QRect frameStrut() const;
|
---|
426 |
|
---|
427 | void setWindowIconText_sys(const QString &cap);
|
---|
428 | void setWindowIconText_helper(const QString &cap);
|
---|
429 | void setWindowTitle_sys(const QString &cap);
|
---|
430 |
|
---|
431 | #ifdef Q_OS_WIN
|
---|
432 | void grabMouseWhileInWindow();
|
---|
433 | #endif
|
---|
434 |
|
---|
435 | #ifndef QT_NO_CURSOR
|
---|
436 | void setCursor_sys(const QCursor &cursor);
|
---|
437 | void unsetCursor_sys();
|
---|
438 | #endif
|
---|
439 |
|
---|
440 | #ifdef Q_WS_MAC
|
---|
441 | void setWindowModified_sys(bool b);
|
---|
442 | void updateMaximizeButton_sys();
|
---|
443 | void setWindowFilePath_sys(const QString &filePath);
|
---|
444 | void createWindow_sys();
|
---|
445 | void recreateMacWindow();
|
---|
446 | #ifndef QT_MAC_USE_COCOA
|
---|
447 | void initWindowPtr();
|
---|
448 | void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
|
---|
449 | #else
|
---|
450 | void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
|
---|
451 | void syncCocoaMask();
|
---|
452 | void finishCocoaMaskSetup();
|
---|
453 | #endif
|
---|
454 | void determineWindowClass();
|
---|
455 | void transferChildren();
|
---|
456 | #endif
|
---|
457 | void setWindowTitle_helper(const QString &cap);
|
---|
458 | void setWindowFilePath_helper(const QString &filePath);
|
---|
459 |
|
---|
460 | bool setMinimumSize_helper(int &minw, int &minh);
|
---|
461 | bool setMaximumSize_helper(int &maxw, int &maxh);
|
---|
462 | void setConstraints_sys();
|
---|
463 | QWidget *childAt_helper(const QPoint &, bool) const;
|
---|
464 | void updateGeometry_helper(bool forceUpdate);
|
---|
465 |
|
---|
466 | void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
|
---|
467 | void setLayoutItemMargins(int left, int top, int right, int bottom);
|
---|
468 | void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);
|
---|
469 |
|
---|
470 | QInputContext *inputContext() const;
|
---|
471 |
|
---|
472 | #if defined(Q_WS_PM)
|
---|
473 | HWND frameWinId() const
|
---|
474 | { return maybeTopData() && maybeTopData()->fId != NULLHANDLE ?
|
---|
475 | maybeTopData()->fId : data.winid; }
|
---|
476 | HWND effectiveFrameWinId() const;
|
---|
477 | #endif
|
---|
478 |
|
---|
479 | #if defined(Q_WS_QWS)
|
---|
480 | void moveSurface(QWindowSurface *surface, const QPoint &offset);
|
---|
481 |
|
---|
482 | QRegion localRequestedRegion() const;
|
---|
483 | QRegion localAllocatedRegion() const;
|
---|
484 |
|
---|
485 | void blitToScreen(const QRegion &globalrgn);
|
---|
486 | #ifndef QT_NO_CURSOR
|
---|
487 | void updateCursor() const;
|
---|
488 | #endif
|
---|
489 |
|
---|
490 | QScreen* getScreen() const;
|
---|
491 |
|
---|
492 | friend class QWSManager;
|
---|
493 | friend class QWSManagerPrivate;
|
---|
494 | friend class QDecoration;
|
---|
495 | #endif
|
---|
496 |
|
---|
497 | static int instanceCounter; // Current number of widget instances
|
---|
498 | static int maxInstances; // Maximum number of widget instances
|
---|
499 |
|
---|
500 | #ifdef QT_KEYPAD_NAVIGATION
|
---|
501 | static QPointer<QWidget> editingWidget;
|
---|
502 | #endif
|
---|
503 |
|
---|
504 | QWidgetData data;
|
---|
505 |
|
---|
506 | QWExtra *extra;
|
---|
507 | QWidget *focus_next;
|
---|
508 | QWidget *focus_prev;
|
---|
509 | QWidget *focus_child;
|
---|
510 | #ifndef QT_NO_ACTION
|
---|
511 | QList<QAction*> actions;
|
---|
512 | #endif
|
---|
513 | QLayout *layout;
|
---|
514 | QWidgetItemV2 *widgetItem;
|
---|
515 | #if !defined(QT_NO_IM)
|
---|
516 | QPointer<QInputContext> ic;
|
---|
517 | #endif
|
---|
518 | // All widgets are initially added into the uncreatedWidgets set. Once
|
---|
519 | // they receive a window id they are removed and added to the mapper
|
---|
520 | static QWidgetMapper *mapper;
|
---|
521 | static QWidgetSet *uncreatedWidgets;
|
---|
522 |
|
---|
523 | short leftmargin, topmargin, rightmargin, bottommargin;
|
---|
524 |
|
---|
525 | signed char leftLayoutItemMargin;
|
---|
526 | signed char topLayoutItemMargin;
|
---|
527 | signed char rightLayoutItemMargin;
|
---|
528 | signed char bottomLayoutItemMargin;
|
---|
529 |
|
---|
530 | // ### TODO: reorganize private/extra/topextra to save memory
|
---|
531 | QPointer<QWidget> compositeChildGrab;
|
---|
532 | #ifndef QT_NO_TOOLTIP
|
---|
533 | QString toolTip;
|
---|
534 | #endif
|
---|
535 | #ifndef QT_NO_STATUSTIP
|
---|
536 | QString statusTip;
|
---|
537 | #endif
|
---|
538 | #ifndef QT_NO_WHATSTHIS
|
---|
539 | QString whatsThis;
|
---|
540 | #endif
|
---|
541 | QString accessibleName, accessibleDescription;
|
---|
542 |
|
---|
543 | QPalette::ColorRole fg_role : 8;
|
---|
544 | QPalette::ColorRole bg_role : 8;
|
---|
545 | uint high_attributes[3]; // the low ones are in QWidget::widget_attributes
|
---|
546 | Qt::HANDLE hd;
|
---|
547 | QRegion dirty;
|
---|
548 | QRegion *needsFlush;
|
---|
549 | uint dirtyOpaqueChildren : 1;
|
---|
550 | uint isOpaque : 1;
|
---|
551 | uint inDirtyList : 1;
|
---|
552 | uint isScrolled : 1;
|
---|
553 | uint isMoved : 1;
|
---|
554 |
|
---|
555 | #if defined(Q_WS_WIN) || defined(Q_WS_PM)
|
---|
556 | uint noPaintOnScreen : 1; // see qwidget_[win|pm].cpp ::paintEngine()
|
---|
557 | #endif
|
---|
558 |
|
---|
559 | uint inheritedFontResolveMask;
|
---|
560 | uint inheritedPaletteResolveMask;
|
---|
561 | #if defined(Q_WS_X11)
|
---|
562 | QX11Info xinfo;
|
---|
563 | Qt::HANDLE picture;
|
---|
564 | #endif
|
---|
565 | #if defined(Q_WS_MAC)
|
---|
566 | enum PaintChildrenOPs {
|
---|
567 | PC_None = 0x00,
|
---|
568 | PC_Now = 0x01,
|
---|
569 | PC_NoPaint = 0x04,
|
---|
570 | PC_Later = 0x10
|
---|
571 | };
|
---|
572 | EventHandlerRef window_event;
|
---|
573 | bool qt_mac_dnd_event(uint, DragRef);
|
---|
574 | void toggleDrawers(bool);
|
---|
575 | //mac event functions
|
---|
576 | static bool qt_create_root_win();
|
---|
577 | static void qt_clean_root_win();
|
---|
578 | static bool qt_recreate_root_win();
|
---|
579 | static bool qt_mac_update_sizer(QWidget *, int up = 0);
|
---|
580 | static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
|
---|
581 | static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
|
---|
582 | static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
|
---|
583 | static bool qt_widget_shape(QWidget *, short, HIMutableShapeRef, bool);
|
---|
584 |
|
---|
585 | // Each wiget keeps a list of all its child and grandchild OpenGL widgets.
|
---|
586 | // This list is used to update the gl context whenever a parent and a granparent
|
---|
587 | // moves, and also to check for intersections with gl widgets within the window
|
---|
588 | // when a widget moves.
|
---|
589 | struct GlWidgetInfo
|
---|
590 | {
|
---|
591 | GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { }
|
---|
592 | bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); }
|
---|
593 | QWidget * widget;
|
---|
594 | QWidget * lastUpdateWidget;
|
---|
595 | };
|
---|
596 | QList<GlWidgetInfo> glWidgets;
|
---|
597 |
|
---|
598 | // dirtyOnWidget contains the areas in the widget that needs to be repained,
|
---|
599 | // in the same way as dirtyOnScreen does for the window. Areas are added in
|
---|
600 | // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
|
---|
601 | // this information repaint invalid areas when widgets are scrolled.
|
---|
602 | QRegion dirtyOnWidget;
|
---|
603 |
|
---|
604 | //these are here just for code compat (HIViews)
|
---|
605 | Qt::HANDLE qd_hd;
|
---|
606 |
|
---|
607 | // This is new stuff
|
---|
608 | uint needWindowChange : 1;
|
---|
609 | uint isGLWidget : 1;
|
---|
610 | #endif
|
---|
611 |
|
---|
612 | #if defined(Q_WS_X11) || defined (Q_WS_WIN) || defined (Q_WS_PM) || defined(Q_WS_MAC)
|
---|
613 | #ifdef Q_WS_MAC
|
---|
614 | void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
|
---|
615 | #else
|
---|
616 | void setWSGeometry(bool dontShow=false);
|
---|
617 | #endif
|
---|
618 |
|
---|
619 | inline QPoint mapToWS(const QPoint &p) const
|
---|
620 | { return p - data.wrect.topLeft(); }
|
---|
621 |
|
---|
622 | inline QPoint mapFromWS(const QPoint &p) const
|
---|
623 | { return p + data.wrect.topLeft(); }
|
---|
624 |
|
---|
625 | inline QRect mapToWS(const QRect &r) const
|
---|
626 | { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
|
---|
627 |
|
---|
628 | inline QRect mapFromWS(const QRect &r) const
|
---|
629 | { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
|
---|
630 | #endif
|
---|
631 |
|
---|
632 | QPaintEngine *extraPaintEngine;
|
---|
633 |
|
---|
634 | mutable const QMetaObject *polished;
|
---|
635 |
|
---|
636 | void setModal_sys();
|
---|
637 |
|
---|
638 | #ifdef Q_WS_PM
|
---|
639 | void validateObstacles();
|
---|
640 | #endif
|
---|
641 |
|
---|
642 | QSizePolicy size_policy;
|
---|
643 | QLocale locale;
|
---|
644 |
|
---|
645 | #ifdef Q_WS_X11
|
---|
646 | static QWidget *mouseGrabber;
|
---|
647 | static QWidget *keyboardGrabber;
|
---|
648 | #endif
|
---|
649 | QPaintDevice *redirectDev;
|
---|
650 | QPoint redirectOffset;
|
---|
651 |
|
---|
652 | inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
|
---|
653 | {
|
---|
654 | Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
|
---|
655 | redirectDev = replacement;
|
---|
656 | redirectOffset = offset;
|
---|
657 | }
|
---|
658 |
|
---|
659 | inline QPaintDevice *redirected(QPoint *offset) const
|
---|
660 | {
|
---|
661 | if (offset)
|
---|
662 | *offset = redirectDev ? redirectOffset : QPoint();
|
---|
663 | return redirectDev;
|
---|
664 | }
|
---|
665 |
|
---|
666 | inline void restoreRedirected()
|
---|
667 | { redirectDev = 0; }
|
---|
668 |
|
---|
669 | inline void enforceNativeChildren()
|
---|
670 | {
|
---|
671 | if (!extra)
|
---|
672 | createExtra();
|
---|
673 |
|
---|
674 | if (extra->nativeChildrenForced)
|
---|
675 | return;
|
---|
676 | extra->nativeChildrenForced = 1;
|
---|
677 |
|
---|
678 | for (int i = 0; i < children.size(); ++i) {
|
---|
679 | if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
|
---|
680 | child->setAttribute(Qt::WA_NativeWindow);
|
---|
681 | }
|
---|
682 | }
|
---|
683 |
|
---|
684 | inline bool nativeChildrenForced() const
|
---|
685 | {
|
---|
686 | return extra ? extra->nativeChildrenForced : false;
|
---|
687 | }
|
---|
688 |
|
---|
689 | QSize adjustedSize() const;
|
---|
690 | };
|
---|
691 |
|
---|
692 | inline QWExtra *QWidgetPrivate::extraData() const
|
---|
693 | {
|
---|
694 | return extra;
|
---|
695 | }
|
---|
696 |
|
---|
697 | inline QTLWExtra *QWidgetPrivate::topData() const
|
---|
698 | {
|
---|
699 | const_cast<QWidgetPrivate *>(this)->createTLExtra();
|
---|
700 | return extra->topextra;
|
---|
701 | }
|
---|
702 |
|
---|
703 | inline QTLWExtra *QWidgetPrivate::maybeTopData() const
|
---|
704 | {
|
---|
705 | return extra ? extra->topextra : 0;
|
---|
706 | }
|
---|
707 |
|
---|
708 | inline QPainter *QWidgetPrivate::sharedPainter() const
|
---|
709 | {
|
---|
710 | Q_Q(const QWidget);
|
---|
711 | QTLWExtra *x = q->window()->d_func()->maybeTopData();
|
---|
712 | return x ? x->sharedPainter : 0;
|
---|
713 | }
|
---|
714 |
|
---|
715 | inline void QWidgetPrivate::setSharedPainter(QPainter *painter)
|
---|
716 | {
|
---|
717 | Q_Q(QWidget);
|
---|
718 | QTLWExtra *x = q->window()->d_func()->topData();
|
---|
719 | x->sharedPainter = painter;
|
---|
720 | }
|
---|
721 |
|
---|
722 | inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
|
---|
723 | {
|
---|
724 | Q_Q(const QWidget);
|
---|
725 | QTLWExtra *x = q->window()->d_func()->maybeTopData();
|
---|
726 | return x ? x->backingStore : 0;
|
---|
727 | }
|
---|
728 |
|
---|
729 | QT_END_NAMESPACE
|
---|
730 |
|
---|
731 | #endif // QWIDGET_P_H
|
---|