source: trunk/src/gui/kernel/qwidget_p.h@ 187

Last change on this file since 187 was 130, checked in by Dmitry A. Kuminov, 16 years ago

gui: Implemented QWidget::grabMouse/Keyboard(), releaseMouse/Keyboard(), activateWindow().

File size: 22.2 KB
Line 
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
86QT_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)
92class QWSManager;
93#endif
94#if defined(Q_WS_MAC)
95class QCoreGraphicsPaintEnginePrivate;
96#endif
97class QPaintEngine;
98class QPixmap;
99class QWidgetBackingStore;
100class QGraphicsProxyWidget;
101class QWidgetItemV2;
102
103class QStyle;
104
105struct 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#endif
160 QRect normalGeometry; // used by showMin/maximized/FullScreen
161 QWindowSurface *windowSurface;
162 QPainter *sharedPainter;
163};
164
165struct QWExtra {
166 qint32 minw, minh; // minimum size
167 qint32 maxw, maxh; // maximum size
168 QPointer<QWidget> focus_proxy;
169#ifndef QT_NO_CURSOR
170 QCursor *curs;
171#endif
172 QTLWExtra *topextra; // only useful for TLWs
173 QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
174 void *glContext; // if the widget is hijacked by QGLWindowSurface
175#if defined(Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
176 QOleDropTarget *dropTarget; // drop target
177 QList<QPointer<QWidget> > oleDropWidgets;
178#endif
179#if defined(Q_WS_X11)
180 WId xDndProxy; // XDND forwarding to embedded windows
181#endif
182 QRegion mask; // widget mask
183 QSize staticContentsSize;
184
185//bit flags at the end to improve packing
186#if defined(Q_WS_WIN)
187 uint shown_mode : 8; // widget show mode
188#ifndef QT_NO_DIRECT3D
189 uint had_paint_on_screen : 1;
190 uint had_no_system_bg : 1;
191 uint had_auto_fill_bg : 1;
192#endif
193#endif
194#if defined(Q_WS_X11)
195 uint compress_events : 1;
196#endif
197 uint explicitMinSize : 2;
198 uint explicitMaxSize : 2;
199 uint autoFillBackground : 1;
200 uint nativeChildrenForced : 1;
201 uint inRenderWithPainter : 1;
202 uint hasMask : 1;
203
204 QPointer<QStyle> style;
205 QString styleSheet;
206
207 quint16 customDpiX;
208 quint16 customDpiY;
209#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
210 // Cocoa Mask stuff
211 QImage maskBits;
212 CGImageRef imageMask;
213#endif
214};
215
216class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
217{
218 Q_DECLARE_PUBLIC(QWidget)
219
220public:
221 explicit QWidgetPrivate(int version = QObjectPrivateVersion);
222 ~QWidgetPrivate();
223
224 QWExtra *extraData() const;
225 QTLWExtra *topData() const;
226 QTLWExtra *maybeTopData() const;
227 QPainter *sharedPainter() const;
228 void setSharedPainter(QPainter *painter);
229 QWidgetBackingStore *maybeBackingStore() const;
230#ifdef Q_WS_QWS
231 void setMaxWindowState_helper();
232 void setFullScreenSize_helper();
233#endif
234 void init(QWidget *desktopWidget, Qt::WindowFlags f);
235 void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
236 void createRecursively();
237 void createWinId(WId id = 0);
238
239 void createTLExtra();
240 void createExtra();
241 void deleteExtra();
242 void createSysExtra();
243 void deleteSysExtra();
244 void createTLSysExtra();
245 void deleteTLSysExtra();
246 void updateSystemBackground();
247 void propagatePaletteChange();
248
249 void setPalette_helper(const QPalette &);
250 void resolvePalette();
251 QPalette naturalWidgetPalette(uint inheritedMask) const;
252
253 void setMask_sys(const QRegion &);
254#ifdef Q_WS_WIN
255 bool shouldShowMaximizeButton();
256 void winUpdateIsOpaque();
257#endif
258
259#ifdef Q_WS_MAC
260 void macUpdateSizeAttribute();
261 void macUpdateHideOnSuspend();
262 void macUpdateOpaqueSizeGrip();
263 void macUpdateIgnoreMouseEvents();
264 void macUpdateMetalAttribute();
265 void macUpdateIsOpaque();
266 void setEnabled_helper_sys(bool enable);
267 bool isRealWindow() const;
268#endif
269
270 void raise_sys();
271 void lower_sys();
272 void stackUnder_sys(QWidget *);
273
274 void setFocus_sys();
275
276 void updateFont(const QFont &);
277 inline void setFont_helper(const QFont &font) {
278 if (data.fnt == font && data.fnt.resolve() == font.resolve())
279 return;
280 updateFont(font);
281 }
282 void resolveFont();
283 QFont naturalWidgetFont(uint inheritedMask) const;
284
285 void setLayoutDirection_helper(Qt::LayoutDirection);
286 void resolveLayoutDirection();
287
288 void setLocale_helper(const QLocale &l, bool forceUpdate = false);
289 void resolveLocale();
290
291 void setStyle_helper(QStyle *newStyle, bool propagate, bool metalHack = false);
292 void inheritStyle();
293
294 bool isBackgroundInherited() const;
295
296 void setUpdatesEnabled_helper(bool );
297
298 void paintBackground(QPainter *, const QRegion &, const QPoint & = QPoint(), int flags = DrawAsRoot) const;
299 enum DrawWidgetFlags {
300 DrawAsRoot = 0x01,
301 DrawPaintOnScreen = 0x02,
302 DrawRecursive = 0x04,
303 DrawInvisible = 0x08,
304 DontSubtractOpaqueChildren = 0x10,
305 DontSetCompositionMode = 0x20,
306 DontDrawOpaqueChildren = 0x40
307 };
308 bool isAboutToShow() const;
309 QRegion prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags);
310 void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
311 QWidget::RenderFlags renderFlags);
312 void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
313 QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0);
314
315
316 void paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& children, int index,
317 const QRegion &rgn, const QPoint &offset, int flags
318#ifdef Q_BACKINGSTORE_SUBSURFACES
319 , const QWindowSurface *currentSurface
320#endif
321 , QPainter *sharedPainter, QWidgetBackingStore *backingStore);
322
323
324 QPainter *beginSharedPainter();
325 bool endSharedPainter();
326 static QGraphicsProxyWidget * nearestGraphicsProxyWidget(QWidget *origin);
327 QWindowSurface *createDefaultWindowSurface();
328 QWindowSurface *createDefaultWindowSurface_sys();
329 void repaint_sys(const QRegion &rgn);
330#ifdef Q_WS_MAC
331 void update_sys(const QRect &rect);
332 void update_sys(const QRegion &rgn);
333#endif
334
335 QRect clipRect() const;
336 QRegion clipRegion() const;
337 void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const;
338 void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0,
339 bool alsoNonOpaque = false) const;
340 void clipToEffectiveMask(QRegion &region) const;
341 void updateIsOpaque();
342 void setOpaque(bool opaque);
343 void updateIsTranslucent();
344 bool hasBackground() const;
345 bool paintOnScreen() const;
346
347 QRegion getOpaqueRegion() const;
348 const QRegion &getOpaqueChildren() const;
349 void setDirtyOpaqueRegion();
350
351 QRegion opaqueChildren;
352
353 enum CloseMode {
354 CloseNoEvent,
355 CloseWithEvent,
356 CloseWithSpontaneousEvent
357 };
358 bool close_helper(CloseMode mode);
359
360 bool compositeEvent(QEvent *e);
361 void setWindowIcon_helper();
362 void setWindowIcon_sys(bool forceReset = false);
363 void setWindowOpacity_sys(qreal opacity);
364
365 void adjustQuitOnCloseAttribute();
366
367#if defined(Q_WS_X11)
368 void setWindowRole();
369 void sendStartupMessage(const char *message) const;
370 void setNetWmWindowTypes();
371 void x11UpdateIsOpaque();
372#endif
373
374#if defined(Q_WS_WIN) || defined(Q_WS_PM)
375 void reparentChildren();
376#endif
377
378 void scrollChildren(int dx, int dy);
379
380 void moveRect(const QRect &, int dx, int dy);
381 void scrollRect(const QRect &, int dx, int dy);
382 void invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize);
383 // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
384 void invalidateBuffer(const QRegion &);
385 void invalidateBuffer(const QRect &);
386 bool isOverlapped(const QRect&) const;
387 void syncBackingStore();
388 void syncBackingStore(const QRegion &region);
389
390 void reparentFocusWidgets(QWidget *oldtlw);
391
392 static int pointToRect(const QPoint &p, const QRect &r);
393 QRect fromOrToLayoutItemRect(const QRect &rect, int sign) const;
394
395 void setWinId(WId);
396 void showChildren(bool spontaneous);
397 void hideChildren(bool spontaneous);
398 void setParent_sys(QWidget *parent, Qt::WindowFlags);
399 void scroll_sys(int dx, int dy);
400 void scroll_sys(int dx, int dy, const QRect &r);
401 void deactivateWidgetCleanup();
402 void setGeometry_sys(int, int, int, int, bool);
403#ifdef Q_WS_MAC
404 void setGeometry_sys_helper(int, int, int, int, bool);
405#endif
406 void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
407 void activateChildLayoutsRecursively();
408 void show_recursive();
409 void show_helper();
410 void show_sys();
411 void hide_sys();
412 void hide_helper();
413 void _q_showIfNotHidden();
414
415 void setEnabled_helper(bool);
416 void registerDropSite(bool);
417#if defined(Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
418 QOleDropTarget *registerOleDnd(QWidget *widget);
419 void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
420#endif
421 static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
422
423 void updateFrameStrut();
424 QRect frameStrut() const;
425
426 void setWindowIconText_sys(const QString &cap);
427 void setWindowIconText_helper(const QString &cap);
428 void setWindowTitle_sys(const QString &cap);
429
430#ifdef Q_OS_WIN
431 void grabMouseWhileInWindow();
432#endif
433
434#ifndef QT_NO_CURSOR
435 void setCursor_sys(const QCursor &cursor);
436 void unsetCursor_sys();
437#endif
438
439#ifdef Q_WS_MAC
440 void setWindowModified_sys(bool b);
441 void updateMaximizeButton_sys();
442 void setWindowFilePath_sys(const QString &filePath);
443 void createWindow_sys();
444 void recreateMacWindow();
445#ifndef QT_MAC_USE_COCOA
446 void initWindowPtr();
447 void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
448#else
449 void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
450 void syncCocoaMask();
451 void finishCocoaMaskSetup();
452#endif
453 void determineWindowClass();
454 void transferChildren();
455#endif
456 void setWindowTitle_helper(const QString &cap);
457 void setWindowFilePath_helper(const QString &filePath);
458
459 bool setMinimumSize_helper(int &minw, int &minh);
460 bool setMaximumSize_helper(int &maxw, int &maxh);
461 void setConstraints_sys();
462 QWidget *childAt_helper(const QPoint &, bool) const;
463 void updateGeometry_helper(bool forceUpdate);
464
465 void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
466 void setLayoutItemMargins(int left, int top, int right, int bottom);
467 void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);
468
469 QInputContext *inputContext() const;
470
471#if defined(Q_WS_PM)
472 HWND frameWinId() const
473 { return maybeTopData() && maybeTopData()->fId != NULLHANDLE ?
474 maybeTopData()->fId : data.winid; }
475 HWND effectiveFrameWinId() const;
476#endif
477
478#if defined(Q_WS_QWS)
479 void moveSurface(QWindowSurface *surface, const QPoint &offset);
480
481 QRegion localRequestedRegion() const;
482 QRegion localAllocatedRegion() const;
483
484 void blitToScreen(const QRegion &globalrgn);
485#ifndef QT_NO_CURSOR
486 void updateCursor() const;
487#endif
488
489 QScreen* getScreen() const;
490
491 friend class QWSManager;
492 friend class QWSManagerPrivate;
493 friend class QDecoration;
494#endif
495
496 static int instanceCounter; // Current number of widget instances
497 static int maxInstances; // Maximum number of widget instances
498
499#ifdef QT_KEYPAD_NAVIGATION
500 static QPointer<QWidget> editingWidget;
501#endif
502
503 QWidgetData data;
504
505 QWExtra *extra;
506 QWidget *focus_next;
507 QWidget *focus_prev;
508 QWidget *focus_child;
509#ifndef QT_NO_ACTION
510 QList<QAction*> actions;
511#endif
512 QLayout *layout;
513 QWidgetItemV2 *widgetItem;
514#if !defined(QT_NO_IM)
515 QPointer<QInputContext> ic;
516#endif
517 // All widgets are initially added into the uncreatedWidgets set. Once
518 // they receive a window id they are removed and added to the mapper
519 static QWidgetMapper *mapper;
520 static QWidgetSet *uncreatedWidgets;
521
522 short leftmargin, topmargin, rightmargin, bottommargin;
523
524 signed char leftLayoutItemMargin;
525 signed char topLayoutItemMargin;
526 signed char rightLayoutItemMargin;
527 signed char bottomLayoutItemMargin;
528
529 // ### TODO: reorganize private/extra/topextra to save memory
530 QPointer<QWidget> compositeChildGrab;
531#ifndef QT_NO_TOOLTIP
532 QString toolTip;
533#endif
534#ifndef QT_NO_STATUSTIP
535 QString statusTip;
536#endif
537#ifndef QT_NO_WHATSTHIS
538 QString whatsThis;
539#endif
540 QString accessibleName, accessibleDescription;
541
542 QPalette::ColorRole fg_role : 8;
543 QPalette::ColorRole bg_role : 8;
544 uint high_attributes[3]; // the low ones are in QWidget::widget_attributes
545 Qt::HANDLE hd;
546 QRegion dirty;
547 QRegion *needsFlush;
548 uint dirtyOpaqueChildren : 1;
549 uint isOpaque : 1;
550 uint inDirtyList : 1;
551 uint isScrolled : 1;
552 uint isMoved : 1;
553
554#if defined(Q_WS_WIN) || defined(Q_WS_PM)
555 uint noPaintOnScreen : 1; // see qwidget_[win|pm].cpp ::paintEngine()
556#endif
557
558 uint inheritedFontResolveMask;
559 uint inheritedPaletteResolveMask;
560#if defined(Q_WS_X11)
561 QX11Info xinfo;
562 Qt::HANDLE picture;
563#endif
564#if defined(Q_WS_MAC)
565 enum PaintChildrenOPs {
566 PC_None = 0x00,
567 PC_Now = 0x01,
568 PC_NoPaint = 0x04,
569 PC_Later = 0x10
570 };
571 EventHandlerRef window_event;
572 bool qt_mac_dnd_event(uint, DragRef);
573 void toggleDrawers(bool);
574 //mac event functions
575 static bool qt_create_root_win();
576 static void qt_clean_root_win();
577 static bool qt_recreate_root_win();
578 static bool qt_mac_update_sizer(QWidget *, int up = 0);
579 static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
580 static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
581 static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
582 static bool qt_widget_shape(QWidget *, short, HIMutableShapeRef, bool);
583
584 // Each wiget keeps a list of all its child and grandchild OpenGL widgets.
585 // This list is used to update the gl context whenever a parent and a granparent
586 // moves, and also to check for intersections with gl widgets within the window
587 // when a widget moves.
588 struct GlWidgetInfo
589 {
590 GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { }
591 bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); }
592 QWidget * widget;
593 QWidget * lastUpdateWidget;
594 };
595 QList<GlWidgetInfo> glWidgets;
596
597 // dirtyOnWidget contains the areas in the widget that needs to be repained,
598 // in the same way as dirtyOnScreen does for the window. Areas are added in
599 // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
600 // this information repaint invalid areas when widgets are scrolled.
601 QRegion dirtyOnWidget;
602
603 //these are here just for code compat (HIViews)
604 Qt::HANDLE qd_hd;
605
606 // This is new stuff
607 uint needWindowChange : 1;
608 uint isGLWidget : 1;
609#endif
610
611#if defined(Q_WS_X11) || defined (Q_WS_WIN) || defined (Q_WS_PM) || defined(Q_WS_MAC)
612#ifdef Q_WS_MAC
613 void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
614#else
615 void setWSGeometry(bool dontShow=false);
616#endif
617
618 inline QPoint mapToWS(const QPoint &p) const
619 { return p - data.wrect.topLeft(); }
620
621 inline QPoint mapFromWS(const QPoint &p) const
622 { return p + data.wrect.topLeft(); }
623
624 inline QRect mapToWS(const QRect &r) const
625 { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
626
627 inline QRect mapFromWS(const QRect &r) const
628 { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
629#endif
630
631 QPaintEngine *extraPaintEngine;
632
633 mutable const QMetaObject *polished;
634
635 void setModal_sys();
636
637#ifdef Q_WS_PM
638 void validateObstacles();
639#endif
640
641 QSizePolicy size_policy;
642 QLocale locale;
643
644#ifdef Q_WS_X11
645 static QWidget *mouseGrabber;
646 static QWidget *keyboardGrabber;
647#endif
648 QPaintDevice *redirectDev;
649 QPoint redirectOffset;
650
651 inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
652 {
653 Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
654 redirectDev = replacement;
655 redirectOffset = offset;
656 }
657
658 inline QPaintDevice *redirected(QPoint *offset) const
659 {
660 if (offset)
661 *offset = redirectDev ? redirectOffset : QPoint();
662 return redirectDev;
663 }
664
665 inline void restoreRedirected()
666 { redirectDev = 0; }
667
668 inline void enforceNativeChildren()
669 {
670 if (!extra)
671 createExtra();
672
673 if (extra->nativeChildrenForced)
674 return;
675 extra->nativeChildrenForced = 1;
676
677 for (int i = 0; i < children.size(); ++i) {
678 if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
679 child->setAttribute(Qt::WA_NativeWindow);
680 }
681 }
682
683 inline bool nativeChildrenForced() const
684 {
685 return extra ? extra->nativeChildrenForced : false;
686 }
687
688 QSize adjustedSize() const;
689};
690
691inline QWExtra *QWidgetPrivate::extraData() const
692{
693 return extra;
694}
695
696inline QTLWExtra *QWidgetPrivate::topData() const
697{
698 const_cast<QWidgetPrivate *>(this)->createTLExtra();
699 return extra->topextra;
700}
701
702inline QTLWExtra *QWidgetPrivate::maybeTopData() const
703{
704 return extra ? extra->topextra : 0;
705}
706
707inline QPainter *QWidgetPrivate::sharedPainter() const
708{
709 Q_Q(const QWidget);
710 QTLWExtra *x = q->window()->d_func()->maybeTopData();
711 return x ? x->sharedPainter : 0;
712}
713
714inline void QWidgetPrivate::setSharedPainter(QPainter *painter)
715{
716 Q_Q(QWidget);
717 QTLWExtra *x = q->window()->d_func()->topData();
718 x->sharedPainter = painter;
719}
720
721inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
722{
723 Q_Q(const QWidget);
724 QTLWExtra *x = q->window()->d_func()->maybeTopData();
725 return x ? x->backingStore : 0;
726}
727
728QT_END_NAMESPACE
729
730#endif // QWIDGET_P_H
Note: See TracBrowser for help on using the repository browser.