1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
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.
56 #include "QtGui/qwidget.h"
57 #include "private/qobject_p.h"
58 #include "QtCore/qrect.h"
59 #include "QtCore/qlocale.h"
60 #include "QtCore/qset.h"
61 #include "QtGui/qregion.h"
62 #include "QtGui/qsizepolicy.h"
63 #include "QtGui/qstyle.h"
64 #include "QtGui/qapplication.h"
65 #include <private/qgraphicseffect_p.h>
66 #include "QtGui/qgraphicsproxywidget.h"
67 #include "QtGui/qgraphicsscene.h"
68 #include "QtGui/qgraphicsview.h"
69 #include <private/qgesture_p.h>
72 #include "QtCore/qt_windows.h"
73 #include <private/qdnd_p.h>
77 #include "QtGui/qx11info_x11.h"
81 #include <private/qt_mac_p.h>
85 #include "QtGui/qinputcontext.h"
86 #include "QtGui/qscreen_qws.h"
89 #if defined(Q_OS_SYMBIAN)
90 class RDrawableWindow;
97 // - to minimize memory usage for members that are seldom used.
98 // - top-level widgets have extra extra data to reduce cost further
102 #if defined(Q_WS_MAC)
103 class QCoreGraphicsPaintEnginePrivate;
105 #if defined(Q_WS_QPA)
106 class QPlatformWindow;
110 class QWidgetBackingStore;
111 class QGraphicsProxyWidget;
116 class QUnifiedToolbarSurface;
118 class Q_AUTOTEST_EXPORT QWidgetBackingStoreTracker
122 QWidgetBackingStoreTracker();
123 ~QWidgetBackingStoreTracker();
125 void create(QWidget *tlw);
128 void registerWidget(QWidget *w);
129 void unregisterWidget(QWidget *w);
130 void unregisterWidgetSubtree(QWidget *w);
132 inline QWidgetBackingStore* data()
137 inline QWidgetBackingStore* operator->()
142 inline QWidgetBackingStore& operator*()
147 inline operator bool() const
153 Q_DISABLE_COPY(QWidgetBackingStoreTracker)
156 QWidgetBackingStore* m_ptr;
157 QSet<QWidget *> m_widgets;
161 // *************************** Cross-platform variables *****************************
163 // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
164 QIcon *icon; // widget icon
166 QWidgetBackingStoreTracker backingStore;
167 QWindowSurface *windowSurface;
168 QPainter *sharedPainter;
170 // Implicit pointers (shared_null).
171 QString caption; // widget caption
172 QString iconText; // widget icon text
173 QString role; // widget role
174 QString filePath; // widget file path
177 short incw, inch; // size increments
178 short basew, baseh; // base sizes
179 // frame strut, don't use these directly, use QWidgetPrivate::frameStrut() instead.
181 QRect normalGeometry; // used by showMin/maximized/FullScreen
182 Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
184 // *************************** Cross-platform bit fields ****************************
186 uint posFromMove : 1;
187 uint sizeAdjusted : 1;
188 uint inTopLevelResize : 1;
192 // *************************** Platform specific values (bit fields first) **********
193 #if defined(Q_WS_X11) // <----------------------------------------------------------- X11
194 uint spont_unmapped: 1; // window was spontaneously unmapped
195 uint dnd : 1; // DND properties installed
196 uint validWMState : 1; // is WM_STATE valid?
197 uint waitingForMapNotify : 1; // show() has been called, haven't got the MapNotify yet
198 WId parentWinId; // parent window Id (valid after reparenting)
199 WId userTimeWindow; // window id that contains user-time timestamp when WM supports a _NET_WM_USER_TIME_WINDOW atom
200 QPoint fullScreenOffset;
202 WId syncUpdateCounter;
203 ulong syncRequestTimestamp;
204 qint32 newCounterValueHi;
205 quint32 newCounterValueLo;
207 #elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
208 uint hotkeyRegistered: 1; // Hot key from the STARTUPINFO has been registered.
209 HICON winIconBig; // internal big Windows icon
210 HICON winIconSmall; // internal small Windows icon
211 #elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
213 uint isSetGeometry : 1;
217 WindowGroupRef group;
218 IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
219 quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys()
220 #ifdef QT_MAC_USE_COCOA
221 // This value is just to make sure we maximize and restore to the right location, yet we allow apps to be maximized and
223 // The name is misleading, since this is set when maximizing the window. It is a hint to saveGeometry(..) to record the
224 // starting position as 0,0 instead of the normal starting position.
226 #endif // QT_MAC_USE_COCOA
228 #elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
229 #ifndef QT_NO_QWS_MANAGER
230 QWSManager *qwsManager;
232 #elif defined(Q_OS_SYMBIAN)
233 uint inExpose : 1; // Prevents drawing recursion
234 uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency
235 uint forcedToRaster : 1;
236 #elif defined(Q_WS_QPA)
237 QPlatformWindow *platformWindow;
238 QPlatformWindowFormat platformWindowFormat;
239 quint32 screenIndex; // index in qplatformscreenlist
244 // *************************** Cross-platform variables *****************************
246 // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
247 void *glContext; // if the widget is hijacked by QGLWindowSurface
248 QTLWExtra *topextra; // only useful for TLWs
249 #ifndef QT_NO_GRAPHICSVIEW
250 QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
255 QPointer<QStyle> style;
256 QPointer<QWidget> focus_proxy;
258 // Implicit pointers (shared_empty/shared_null).
259 QRegion mask; // widget mask
264 qint32 minh; // minimum size
266 qint32 maxh; // maximum size
269 QSize staticContentsSize;
271 // *************************** Cross-platform bit fields ****************************
272 uint explicitMinSize : 2;
273 uint explicitMaxSize : 2;
274 uint autoFillBackground : 1;
275 uint nativeChildrenForced : 1;
276 uint inRenderWithPainter : 1;
279 // *************************** Platform specific values (bit fields first) **********
280 #if defined(Q_WS_WIN) // <----------------------------------------------------------- WIN
281 #ifndef QT_NO_DRAGANDDROP
282 QOleDropTarget *dropTarget; // drop target
283 QList<QPointer<QWidget> > oleDropWidgets;
285 #elif defined(Q_WS_X11) // <--------------------------------------------------------- X11
286 uint compress_events : 1;
287 WId xDndProxy; // XDND forwarding to embedded windows
288 #elif defined(Q_WS_MAC) // <------------------------------------------------------ MAC
289 #ifdef QT_MAC_USE_COCOA
292 CGImageRef imageMask;
294 #elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian
295 uint activated : 1; // RWindowBase::Activated has been called
298 * If this bit is set, each native widget receives the signals from the
299 * Symbian control immediately before and immediately after draw ops are
300 * sent to the window server for this control:
301 * void beginNativePaintEvent(const QRect &paintRect);
302 * void endNativePaintEvent(const QRect &paintRect);
304 uint receiveNativePaintEvents : 1;
307 * Defines the behaviour of QSymbianControl::Draw.
309 enum NativePaintMode {
311 * Normal drawing mode: blits the required region of the backing store
317 * Disable drawing for this widget.
322 * Paint zeros into the WSERV framebuffer, using BitGDI APIs. For windows
323 * with an EColor16MU display mode, zero is written only into the R, G and B
324 * channels of the pixel.
329 * Blit backing store, propagating alpha channel into the framebuffer.
336 NativePaintMode nativePaintMode;
344 Returns true if \a p or any of its parents enable the
345 Qt::BypassGraphicsProxyWidget window flag. Used in QWidget::show() and
346 QWidget::setParent() to determine whether it's necessary to embed the
347 widget into a QGraphicsProxyWidget or not.
349 static inline bool bypassGraphicsProxyWidget(const QWidget *p)
352 if (p->windowFlags() & Qt::BypassGraphicsProxyWidget)
354 p = p->parentWidget();
359 class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
361 Q_DECLARE_PUBLIC(QWidget)
364 // *************************** Cross-platform ***************************************
365 enum DrawWidgetFlags {
367 DrawPaintOnScreen = 0x02,
368 DrawRecursive = 0x04,
369 DrawInvisible = 0x08,
370 DontSubtractOpaqueChildren = 0x10,
371 DontSetCompositionMode = 0x20,
372 DontDrawOpaqueChildren = 0x40,
373 DontDrawNativeChildren = 0x80
379 CloseWithSpontaneousEvent
383 DirectionNorth = 0x01,
384 DirectionEast = 0x10,
385 DirectionSouth = 0x02,
390 explicit QWidgetPrivate(int version = QObjectPrivateVersion);
393 QWExtra *extraData() const;
394 QTLWExtra *topData() const;
395 QTLWExtra *maybeTopData() const;
396 QPainter *sharedPainter() const;
397 void setSharedPainter(QPainter *painter);
398 QWidgetBackingStore *maybeBackingStore() const;
399 void init(QWidget *desktopWidget, Qt::WindowFlags f);
400 void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
401 void createRecursively();
402 void createWinId(WId id = 0);
404 void createTLExtra();
407 void createSysExtra();
408 void deleteSysExtra();
409 void createTLSysExtra();
410 void deleteTLSysExtra();
411 void updateSystemBackground();
412 void propagatePaletteChange();
414 void setPalette_helper(const QPalette &);
415 void resolvePalette();
416 QPalette naturalWidgetPalette(uint inheritedMask) const;
418 void setMask_sys(const QRegion &);
420 void setSoftKeys_sys(const QList<QAction*> &softkeys);
421 void activateSymbianWindow(WId wid = 0);
422 void _q_cleanupWinIds();
427 void stackUnder_sys(QWidget *);
431 void updateFont(const QFont &);
432 inline void setFont_helper(const QFont &font) {
433 if (data.fnt == font && data.fnt.resolve() == font.resolve())
438 QFont naturalWidgetFont(uint inheritedMask) const;
440 void setLayoutDirection_helper(Qt::LayoutDirection);
441 void resolveLayoutDirection();
443 void setLocale_helper(const QLocale &l, bool forceUpdate = false);
444 void resolveLocale();
446 void setStyle_helper(QStyle *newStyle, bool propagate, bool metalHack = false);
449 void setUpdatesEnabled_helper(bool );
451 void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const;
452 bool isAboutToShow() const;
453 QRegion prepareToRender(const QRegion ®ion, QWidget::RenderFlags renderFlags);
454 void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
455 QWidget::RenderFlags renderFlags);
456 void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion,
457 QWidget::RenderFlags renderFlags, bool readyToRender);
458 void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
459 QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0);
462 void paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& children, int index,
463 const QRegion &rgn, const QPoint &offset, int flags
464 #ifdef Q_BACKINGSTORE_SUBSURFACES
465 , const QWindowSurface *currentSurface
467 , QPainter *sharedPainter, QWidgetBackingStore *backingStore);
470 QPainter *beginSharedPainter();
471 bool endSharedPainter();
472 #ifndef QT_NO_GRAPHICSVIEW
473 static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin);
475 QWindowSurface *createDefaultWindowSurface();
476 QWindowSurface *createDefaultWindowSurface_sys();
477 void repaint_sys(const QRegion &rgn);
479 QRect clipRect() const;
480 QRegion clipRegion() const;
481 void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const;
482 void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0,
483 bool alsoNonOpaque = false) const;
484 void clipToEffectiveMask(QRegion ®ion) const;
485 void updateIsOpaque();
486 void setOpaque(bool opaque);
487 void updateIsTranslucent();
488 bool paintOnScreen() const;
489 #ifndef QT_NO_GRAPHICSEFFECT
490 void invalidateGraphicsEffectsRecursively();
491 #endif //QT_NO_GRAPHICSEFFECT
493 const QRegion &getOpaqueChildren() const;
494 void setDirtyOpaqueRegion();
496 bool close_helper(CloseMode mode);
498 void setWindowIcon_helper();
499 void setWindowIcon_sys(bool forceReset = false);
500 void setWindowOpacity_sys(qreal opacity);
501 void adjustQuitOnCloseAttribute();
503 void scrollChildren(int dx, int dy);
504 void moveRect(const QRect &, int dx, int dy);
505 void scrollRect(const QRect &, int dx, int dy);
506 void invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize);
507 // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
508 void invalidateBuffer(const QRegion &);
509 void invalidateBuffer(const QRect &);
510 bool isOverlapped(const QRect&) const;
511 void syncBackingStore();
512 void syncBackingStore(const QRegion ®ion);
514 void reparentFocusWidgets(QWidget *oldtlw);
516 static int pointToRect(const QPoint &p, const QRect &r);
519 void showChildren(bool spontaneous);
520 void hideChildren(bool spontaneous);
521 void setParent_sys(QWidget *parent, Qt::WindowFlags);
522 void scroll_sys(int dx, int dy);
523 void scroll_sys(int dx, int dy, const QRect &r);
524 void deactivateWidgetCleanup();
525 void setGeometry_sys(int, int, int, int, bool);
526 void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
527 void activateChildLayoutsRecursively();
528 void show_recursive();
533 void _q_showIfNotHidden();
535 void setEnabled_helper(bool);
536 void registerDropSite(bool);
537 static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
539 void updateFrameStrut();
540 QRect frameStrut() const;
542 #ifdef QT_KEYPAD_NAVIGATION
543 static bool navigateToDirection(Direction direction);
544 static QWidget *widgetInNavigationDirection(Direction direction);
545 static bool canKeypadNavigate(Qt::Orientation orientation);
546 static bool inTabWidget(QWidget *widget);
549 void setWindowIconText_sys(const QString &cap);
550 void setWindowIconText_helper(const QString &cap);
551 void setWindowTitle_sys(const QString &cap);
554 void setCursor_sys(const QCursor &cursor);
555 void unsetCursor_sys();
558 void setWindowTitle_helper(const QString &cap);
559 void setWindowFilePath_helper(const QString &filePath);
561 bool setMinimumSize_helper(int &minw, int &minh);
562 bool setMaximumSize_helper(int &maxw, int &maxh);
563 virtual bool hasHeightForWidth() const;
564 void setConstraints_sys();
565 bool pointInsideRectAndMask(const QPoint &) const;
566 QWidget *childAt_helper(const QPoint &, bool) const;
567 QWidget *childAtRecursiveHelper(const QPoint &p, bool, bool includeFrame = false) const;
568 void updateGeometry_helper(bool forceUpdate);
570 void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
571 void setLayoutItemMargins(int left, int top, int right, int bottom);
572 void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);
574 // aboutToDestroy() is called just before the contents of
575 // QWidget::destroy() is executed. It's used to signal QWidget
576 // sub-classes that their internals are about to be released.
577 virtual void aboutToDestroy() {}
579 QInputContext *assignedInputContext() const;
580 QInputContext *inputContext() const;
581 inline QWidget *effectiveFocusWidget() {
582 QWidget *w = q_func();
583 while (w->focusProxy())
590 // This is an helper function that return the available geometry for
591 // a widget and takes care is this one is in QGraphicsView.
592 // If the widget is not embed in a scene then the geometry available is
593 // null, we let QDesktopWidget decide for us.
594 static QRect screenGeometry(const QWidget *widget)
597 #ifndef QT_NO_GRAPHICSVIEW
598 QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget);
599 //It's embedded if it has an ancestor
601 if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != 0) {
602 // One view, let be smart and return the viewport rect then the popup is aligned
603 if (ancestorProxy->scene()->views().size() == 1) {
604 QGraphicsView *view = ancestorProxy->scene()->views().at(0);
605 screen = view->mapToScene(view->viewport()->rect()).boundingRect().toRect();
607 screen = ancestorProxy->scene()->sceneRect().toRect();
615 inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
617 Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
618 redirectDev = replacement;
619 redirectOffset = offset;
622 inline QPaintDevice *redirected(QPoint *offset) const
625 *offset = redirectDev ? redirectOffset : QPoint();
629 inline void restoreRedirected()
632 inline void enforceNativeChildren()
637 if (extra->nativeChildrenForced)
639 extra->nativeChildrenForced = 1;
641 for (int i = 0; i < children.size(); ++i) {
642 if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
643 child->setAttribute(Qt::WA_NativeWindow);
647 inline bool nativeChildrenForced() const
649 return extra ? extra->nativeChildrenForced : false;
652 inline QRect effectiveRectFor(const QRect &rect) const
654 #ifndef QT_NO_GRAPHICSEFFECT
655 if (graphicsEffect && graphicsEffect->isEnabled())
656 return graphicsEffect->boundingRectFor(rect).toAlignedRect();
657 #endif //QT_NO_GRAPHICSEFFECT
661 QSize adjustedSize() const;
663 inline void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
666 if (button == Qt::LeftButton && qApp->autoSipEnabled()) {
667 QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
668 q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
669 if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
670 QEvent event(QEvent::RequestSoftwareInputPanel);
671 QApplication::sendEvent(q, &event);
676 #ifndef Q_WS_QWS // Almost cross-platform :-)
677 void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
679 inline QPoint mapToWS(const QPoint &p) const
680 { return p - data.wrect.topLeft(); }
682 inline QPoint mapFromWS(const QPoint &p) const
683 { return p + data.wrect.topLeft(); }
685 inline QRect mapToWS(const QRect &r) const
686 { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
688 inline QRect mapFromWS(const QRect &r) const
689 { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
693 // Regular pointers (keep them together to avoid gaps on 64 bit architectures).
697 QWidget *focus_child;
700 QPaintDevice *redirectDev;
701 QWidgetItemV2 *widgetItem;
702 QPaintEngine *extraPaintEngine;
703 mutable const QMetaObject *polished;
704 QGraphicsEffect *graphicsEffect;
705 // All widgets are added into the allWidgets set. Once
706 // they receive a window id they are also added to the mapper.
707 // This should just ensure that all widgets are deleted by QApplication
708 static QWidgetMapper *mapper;
709 static QWidgetSet *allWidgets;
710 #if !defined(QT_NO_IM)
711 QPointer<QInputContext> ic;
712 Qt::InputMethodHints imHints;
714 #ifdef QT_KEYPAD_NAVIGATION
715 static QPointer<QWidget> editingWidget;
718 // Implicit pointers (shared_null/shared_empty).
719 QRegion opaqueChildren;
721 #ifndef QT_NO_TOOLTIP
724 #ifndef QT_NO_STATUSTIP
727 #ifndef QT_NO_WHATSTHIS
730 #ifndef QT_NO_ACCESSIBILITY
731 QString accessibleName;
732 QString accessibleDescription;
736 uint inheritedFontResolveMask;
737 uint inheritedPaletteResolveMask;
742 signed char leftLayoutItemMargin;
743 signed char topLayoutItemMargin;
744 signed char rightLayoutItemMargin;
745 signed char bottomLayoutItemMargin;
746 static int instanceCounter; // Current number of widget instances
747 static int maxInstances; // Maximum number of widget instances
750 QSizePolicy size_policy;
752 QPoint redirectOffset;
754 QList<QAction*> actions;
756 #ifndef QT_NO_GESTURES
757 QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
761 uint high_attributes[4]; // the low ones are in QWidget::widget_attributes
762 QPalette::ColorRole fg_role : 8;
763 QPalette::ColorRole bg_role : 8;
764 uint dirtyOpaqueChildren : 1;
766 uint inDirtyList : 1;
770 uint usesDoubleBufferedGLContext : 1;
772 uint inheritsInputMethodHints : 1;
774 uint inSetParent : 1;
776 // *************************** Platform specific ************************************
777 #if defined(Q_WS_X11) // <----------------------------------------------------------- X11
780 static QWidget *mouseGrabber;
781 static QWidget *keyboardGrabber;
783 void setWindowRole();
784 void sendStartupMessage(const char *message) const;
785 void setNetWmWindowTypes();
786 void x11UpdateIsOpaque();
787 bool isBackgroundInherited() const;
788 void updateX11AcceptFocus();
789 QPoint mapToGlobal(const QPoint &pos) const;
790 QPoint mapFromGlobal(const QPoint &pos) const;
791 #elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
792 uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
793 #ifndef QT_NO_GESTURES
794 uint nativeGesturePanEnabled : 1;
796 bool shouldShowMaximizeButton();
797 void winUpdateIsOpaque();
798 void reparentChildren();
799 #ifndef QT_NO_DRAGANDDROP
800 QOleDropTarget *registerOleDnd(QWidget *widget);
801 void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
803 void grabMouseWhileInWindow();
804 void registerTouchWindow();
805 void winSetupGestures();
806 #elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
808 uint needWindowChange : 1;
810 // Each wiget keeps a list of all its child and grandchild OpenGL widgets.
811 // This list is used to update the gl context whenever a parent and a granparent
812 // moves, and also to check for intersections with gl widgets within the window
813 // when a widget moves.
816 GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { }
817 bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); }
819 QWidget * lastUpdateWidget;
822 // dirtyOnWidget contains the areas in the widget that needs to be repained,
823 // in the same way as dirtyOnScreen does for the window. Areas are added in
824 // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
825 // this information repaint invalid areas when widgets are scrolled.
826 QRegion dirtyOnWidget;
827 EventHandlerRef window_event;
828 QList<GlWidgetInfo> glWidgets;
830 //these are here just for code compat (HIViews)
833 void macUpdateSizeAttribute();
834 void macUpdateHideOnSuspend();
835 void macUpdateOpaqueSizeGrip();
836 void macUpdateIgnoreMouseEvents();
837 void macUpdateMetalAttribute();
838 void macUpdateIsOpaque();
839 void macSetNeedsDisplay(QRegion region);
840 void setEnabled_helper_sys(bool enable);
841 bool isRealWindow() const;
842 void adjustWithinMaxAndMinSize(int &w, int &h);
843 void applyMaxAndMinSizeOnWindow();
844 void update_sys(const QRect &rect);
845 void update_sys(const QRegion &rgn);
846 void setGeometry_sys_helper(int, int, int, int, bool);
847 void setWindowModified_sys(bool b);
848 void updateMaximizeButton_sys();
849 void setWindowFilePath_sys(const QString &filePath);
850 void createWindow_sys();
851 void recreateMacWindow();
852 #ifndef QT_MAC_USE_COCOA
853 void initWindowPtr();
854 void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
856 void setSubWindowStacking(bool set);
857 void setWindowLevel();
858 void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
859 void syncCocoaMask();
860 void finishCocoaMaskSetup();
861 void syncUnifiedMode();
862 // Did we add the drawRectOriginal method?
863 bool drawRectOriginalAdded;
864 // Is the original drawRect method available?
865 bool originalDrawMethod;
866 // Do we need to change the methods?
869 // Unified toolbar variables
870 bool isInUnifiedToolbar;
871 QUnifiedToolbarSurface *unifiedSurface;
872 QPoint toolbar_offset;
873 QWidget *toolbar_ancestor;
875 bool touchEventsEnabled;
876 #endif // QT_MAC_USE_COCOA
877 void determineWindowClass();
878 void transferChildren();
879 bool qt_mac_dnd_event(uint, DragRef);
880 void toggleDrawers(bool);
881 //mac event functions
882 static bool qt_create_root_win();
883 static void qt_clean_root_win();
884 static bool qt_mac_update_sizer(QWidget *, int up = 0);
885 static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
886 static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
887 static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
888 void registerTouchWindow(bool enable = true);
889 #elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
890 void setMaxWindowState_helper();
891 void setFullScreenSize_helper();
892 void moveSurface(QWindowSurface *surface, const QPoint &offset);
893 QRegion localRequestedRegion() const;
894 QRegion localAllocatedRegion() const;
896 friend class QWSManager;
897 friend class QWSManagerPrivate;
898 friend class QDecoration;
900 void updateCursor() const;
902 QScreen* getScreen() const;
903 #elif defined(Q_WS_QPA) // <--------------------------------------------------------- QPA
904 void setMaxWindowState_helper();
905 void setFullScreenSize_helper();
907 void updateCursor() const;
909 #elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN
910 static QWidget *mouseGrabber;
911 static QWidget *keyboardGrabber;
912 int symbianScreenNumber; // only valid for desktop widget and top-levels
913 bool fixNativeOrientationCalled;
914 void s60UpdateIsOpaque();
915 void reparentChildren();
916 void registerTouchWindow();
917 QList<WId> widCleanupList;
922 struct QWidgetPaintContext
924 inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f,
925 QPainter *p, QWidgetBackingStore *b)
926 : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(0) {}
932 QPainter *sharedPainter;
933 QWidgetBackingStore *backingStore;
937 #ifndef QT_NO_GRAPHICSEFFECT
938 class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate
941 QWidgetEffectSourcePrivate(QWidget *widget)
942 : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false)
946 { m_widget->d_func()->graphicsEffect = 0; }
948 inline const QGraphicsItem *graphicsItem() const
951 inline const QWidget *widget() const
956 updateDueToGraphicsEffect = true;
958 updateDueToGraphicsEffect = false;
961 inline bool isPixmap() const
964 inline void effectBoundingRectChanged()
966 // ### This function should take a rect parameter; then we can avoid
967 // updating too much on the parent widget.
968 if (QWidget *parent = m_widget->parentWidget())
974 inline const QStyleOption *styleOption() const
977 inline QRect deviceRect() const
978 { return m_widget->window()->rect(); }
980 QRectF boundingRect(Qt::CoordinateSystem system) const;
981 void draw(QPainter *p);
982 QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset,
983 QGraphicsEffect::PixmapPadMode mode) const;
986 QWidgetPaintContext *context;
987 QTransform lastEffectTransform;
988 bool updateDueToGraphicsEffect;
990 #endif //QT_NO_GRAPHICSEFFECT
992 inline QWExtra *QWidgetPrivate::extraData() const
997 inline QTLWExtra *QWidgetPrivate::topData() const
999 const_cast<QWidgetPrivate *>(this)->createTLExtra();
1000 return extra->topextra;
1003 inline QTLWExtra *QWidgetPrivate::maybeTopData() const
1005 return extra ? extra->topextra : 0;
1008 inline QPainter *QWidgetPrivate::sharedPainter() const
1011 QTLWExtra *x = q->window()->d_func()->maybeTopData();
1012 return x ? x->sharedPainter : 0;
1015 inline void QWidgetPrivate::setSharedPainter(QPainter *painter)
1018 QTLWExtra *x = q->window()->d_func()->topData();
1019 x->sharedPainter = painter;
1022 inline bool QWidgetPrivate::pointInsideRectAndMask(const QPoint &p) const
1025 return q->rect().contains(p) && (!extra || !extra->hasMask || q->testAttribute(Qt::WA_MouseNoMask)
1026 || extra->mask.contains(p));
1029 inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
1032 QTLWExtra *x = q->window()->d_func()->maybeTopData();
1033 return x ? x->backingStore.data() : 0;
1038 #endif // QWIDGET_P_H