1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtGui module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
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 "QtWidgets/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/qinputmethod.h"
63
#include "QtWidgets/qsizepolicy.h"
64
#include "QtWidgets/qstyle.h"
65
#include "QtWidgets/qapplication.h"
66
#include <private/qgraphicseffect_p.h>
67
#include "QtWidgets/qgraphicsproxywidget.h"
68
#include "QtWidgets/qgraphicsscene.h"
69
#include "QtWidgets/qgraphicsview.h"
70
#include <private/qgesture_p.h>
75
// - to minimize memory usage for members that are seldom used.
76
// - top-level widgets have extra extra data to reduce cost further
80
class QWidgetBackingStore;
81
class QGraphicsProxyWidget;
86
class QUnifiedToolbarSurface;
88
// implemented in qshortcut.cpp
89
bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context);
91
class QUpdateLaterEvent : public QEvent
94
explicit QUpdateLaterEvent(const QRegion& paintRegion)
95
: QEvent(UpdateLater), m_region(paintRegion)
103
inline const QRegion ®ion() const { return m_region; }
111
class Q_AUTOTEST_EXPORT QWidgetBackingStoreTracker
115
QWidgetBackingStoreTracker();
116
~QWidgetBackingStoreTracker();
118
void create(QWidget *tlw);
121
void registerWidget(QWidget *w);
122
void unregisterWidget(QWidget *w);
123
void unregisterWidgetSubtree(QWidget *w);
125
inline QWidgetBackingStore* data()
130
inline QWidgetBackingStore* operator->()
135
inline QWidgetBackingStore& operator*()
140
inline operator bool() const
146
Q_DISABLE_COPY(QWidgetBackingStoreTracker)
149
QWidgetBackingStore* m_ptr;
150
QSet<QWidget *> m_widgets;
154
// *************************** Cross-platform variables *****************************
156
// Regular pointers (keep them together to avoid gaps on 64 bits architectures).
157
QIcon *icon; // widget icon
158
QWidgetBackingStoreTracker backingStoreTracker;
159
QBackingStore *backingStore;
160
QPainter *sharedPainter;
162
// Implicit pointers (shared_null).
163
QString caption; // widget caption
164
QString iconText; // widget icon text
165
QString role; // widget role
166
QString filePath; // widget file path
169
short incw, inch; // size increments
170
short basew, baseh; // base sizes
171
// frame strut, don't use these directly, use QWidgetPrivate::frameStrut() instead.
173
QRect normalGeometry; // used by showMin/maximized/FullScreen
174
Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
176
// *************************** Cross-platform bit fields ****************************
178
uint posIncludesFrame : 1;
179
uint sizeAdjusted : 1;
180
uint inTopLevelResize : 1;
184
// *************************** Platform specific values (bit fields first) **********
185
#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
186
uint spont_unmapped: 1; // window was spontaneously unmapped
187
uint dnd : 1; // DND properties installed
188
uint validWMState : 1; // is WM_STATE valid?
189
uint waitingForMapNotify : 1; // show() has been called, haven't got the MapNotify yet
190
WId parentWinId; // parent window Id (valid after reparenting)
191
WId userTimeWindow; // window id that contains user-time timestamp when WM supports a _NET_WM_USER_TIME_WINDOW atom
192
QPoint fullScreenOffset;
194
WId syncUpdateCounter;
195
ulong syncRequestTimestamp;
196
qint32 newCounterValueHi;
197
quint32 newCounterValueLo;
199
#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
200
uint hotkeyRegistered: 1; // Hot key from the STARTUPINFO has been registered.
201
HICON winIconBig; // internal big Windows icon
202
HICON winIconSmall; // internal small Windows icon
203
#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
205
uint isSetGeometry : 1;
209
WindowGroupRef group;
210
IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
211
quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys()
212
// This value is just to make sure we maximize and restore to the right location, yet we allow apps to be maximized and
214
// The name is misleading, since this is set when maximizing the window. It is a hint to saveGeometry(..) to record the
215
// starting position as 0,0 instead of the normal starting position.
218
QWidgetWindow *window;
219
quint32 screenIndex; // index in qplatformscreenlist
223
// *************************** Cross-platform variables *****************************
225
// Regular pointers (keep them together to avoid gaps on 64 bits architectures).
226
void *glContext; // if the widget is hijacked by QGLWindowSurface
227
QTLWExtra *topextra; // only useful for TLWs
228
#ifndef QT_NO_GRAPHICSVIEW
229
QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
234
QPointer<QStyle> style;
235
QPointer<QWidget> focus_proxy;
237
// Implicit pointers (shared_empty/shared_null).
238
QRegion mask; // widget mask
243
qint32 minh; // minimum size
245
qint32 maxh; // maximum size
248
QSize staticContentsSize;
250
// *************************** Cross-platform bit fields ****************************
251
uint explicitMinSize : 2;
252
uint explicitMaxSize : 2;
253
uint autoFillBackground : 1;
254
uint nativeChildrenForced : 1;
255
uint inRenderWithPainter : 1;
258
// *************************** Platform specific values (bit fields first) **********
259
#if defined(Q_WS_WIN) // <----------------------------------------------------------- WIN
260
#ifndef QT_NO_DRAGANDDROP
261
QOleDropTarget *dropTarget; // drop target
262
QList<QPointer<QWidget> > oleDropWidgets;
264
#elif defined(Q_WS_X11) // <--------------------------------------------------------- X11
265
uint compress_events : 1;
266
WId xDndProxy; // XDND forwarding to embedded windows
267
#elif defined(Q_WS_MAC) // <------------------------------------------------------ MAC
270
CGImageRef imageMask;
277
Returns true if \a p or any of its parents enable the
278
Qt::BypassGraphicsProxyWidget window flag. Used in QWidget::show() and
279
QWidget::setParent() to determine whether it's necessary to embed the
280
widget into a QGraphicsProxyWidget or not.
282
static inline bool bypassGraphicsProxyWidget(const QWidget *p)
285
if (p->windowFlags() & Qt::BypassGraphicsProxyWidget)
287
p = p->parentWidget();
292
class Q_WIDGETS_EXPORT QWidgetPrivate : public QObjectPrivate
294
Q_DECLARE_PUBLIC(QWidget)
297
// *************************** Cross-platform ***************************************
298
enum DrawWidgetFlags {
300
DrawPaintOnScreen = 0x02,
301
DrawRecursive = 0x04,
302
DrawInvisible = 0x08,
303
DontSubtractOpaqueChildren = 0x10,
304
DontDrawOpaqueChildren = 0x20,
305
DontDrawNativeChildren = 0x40,
306
DontSetCompositionMode = 0x80
312
CloseWithSpontaneousEvent
316
DirectionNorth = 0x01,
317
DirectionEast = 0x10,
318
DirectionSouth = 0x02,
323
explicit QWidgetPrivate(int version = QObjectPrivateVersion);
326
QWExtra *extraData() const;
327
QTLWExtra *topData() const;
328
QTLWExtra *maybeTopData() const;
329
QPainter *sharedPainter() const;
330
void setSharedPainter(QPainter *painter);
331
QWidgetBackingStore *maybeBackingStore() const;
332
void init(QWidget *desktopWidget, Qt::WindowFlags f);
333
void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
334
void createRecursively();
335
void createWinId(WId id = 0);
337
void createTLExtra();
340
void createSysExtra();
341
void deleteSysExtra();
342
void createTLSysExtra();
343
void deleteTLSysExtra();
344
void updateSystemBackground();
345
void propagatePaletteChange();
347
void setPalette_helper(const QPalette &);
348
void resolvePalette();
349
QPalette naturalWidgetPalette(uint inheritedMask) const;
351
void setMask_sys(const QRegion &);
355
void stackUnder_sys(QWidget *);
358
void updateFocusChild();
360
void updateFont(const QFont &);
361
inline void setFont_helper(const QFont &font) {
362
if (data.fnt == font && data.fnt.resolve() == font.resolve())
367
QFont naturalWidgetFont(uint inheritedMask) const;
369
void setLayoutDirection_helper(Qt::LayoutDirection);
370
void resolveLayoutDirection();
372
void setLocale_helper(const QLocale &l, bool forceUpdate = false);
373
void resolveLocale();
375
void setStyle_helper(QStyle *newStyle, bool propagate, bool metalHack = false);
378
void setUpdatesEnabled_helper(bool );
380
void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const;
381
bool isAboutToShow() const;
382
QRegion prepareToRender(const QRegion ®ion, QWidget::RenderFlags renderFlags);
383
void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
384
QWidget::RenderFlags renderFlags);
385
void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion,
386
QWidget::RenderFlags renderFlags, bool readyToRender);
387
void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
388
QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0);
391
void paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& children, int index,
392
const QRegion &rgn, const QPoint &offset, int flags,
393
QPainter *sharedPainter, QWidgetBackingStore *backingStore);
396
QPainter *beginSharedPainter();
397
bool endSharedPainter();
398
#ifndef QT_NO_GRAPHICSVIEW
399
static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin);
401
void repaint_sys(const QRegion &rgn);
403
QRect clipRect() const;
404
QRegion clipRegion() const;
405
void setSystemClip(QPaintDevice *paintDevice, const QRegion ®ion);
406
void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const;
407
void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0,
408
bool alsoNonOpaque = false) const;
409
void clipToEffectiveMask(QRegion ®ion) const;
410
void updateIsOpaque();
411
void setOpaque(bool opaque);
412
void updateIsTranslucent();
413
bool paintOnScreen() const;
414
#ifndef QT_NO_GRAPHICSEFFECT
415
void invalidateGraphicsEffectsRecursively();
416
#endif //QT_NO_GRAPHICSEFFECT
418
const QRegion &getOpaqueChildren() const;
419
void setDirtyOpaqueRegion();
421
bool close_helper(CloseMode mode);
423
void setWindowIcon_helper();
424
void setWindowIcon_sys();
425
void setWindowOpacity_sys(qreal opacity);
426
void adjustQuitOnCloseAttribute();
428
void scrollChildren(int dx, int dy);
429
void moveRect(const QRect &, int dx, int dy);
430
void scrollRect(const QRect &, int dx, int dy);
431
void invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize);
432
// ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
433
void invalidateBuffer(const QRegion &);
434
void invalidateBuffer(const QRect &);
435
bool isOverlapped(const QRect&) const;
436
void syncBackingStore();
437
void syncBackingStore(const QRegion ®ion);
439
// tells the input method about the widgets transform
440
void updateWidgetTransform();
442
void reparentFocusWidgets(QWidget *oldtlw);
444
static int pointToRect(const QPoint &p, const QRect &r);
447
void showChildren(bool spontaneous);
448
void hideChildren(bool spontaneous);
449
void setParent_sys(QWidget *parent, Qt::WindowFlags);
450
void scroll_sys(int dx, int dy);
451
void scroll_sys(int dx, int dy, const QRect &r);
452
void deactivateWidgetCleanup();
453
void setGeometry_sys(int, int, int, int, bool);
454
void fixPosIncludesFrame();
455
void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
456
void activateChildLayoutsRecursively();
457
void show_recursive();
462
void _q_showIfNotHidden();
464
void setEnabled_helper(bool);
465
void registerDropSite(bool);
466
static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
468
void updateFrameStrut();
469
QRect frameStrut() const;
471
#ifdef QT_KEYPAD_NAVIGATION
472
static bool navigateToDirection(Direction direction);
473
static QWidget *widgetInNavigationDirection(Direction direction);
474
static bool canKeypadNavigate(Qt::Orientation orientation);
475
static bool inTabWidget(QWidget *widget);
478
void setWindowIconText_sys(const QString &cap);
479
void setWindowIconText_helper(const QString &cap);
480
void setWindowTitle_sys(const QString &cap);
481
void setWindowFilePath_sys(const QString &filePath);
484
void setCursor_sys(const QCursor &cursor);
485
void unsetCursor_sys();
488
void setWindowTitle_helper(const QString &cap);
489
void setWindowFilePath_helper(const QString &filePath);
490
void setWindowModified_helper();
492
bool setMinimumSize_helper(int &minw, int &minh);
493
bool setMaximumSize_helper(int &maxw, int &maxh);
494
void setConstraints_sys();
495
bool pointInsideRectAndMask(const QPoint &) const;
496
QWidget *childAt_helper(const QPoint &, bool) const;
497
QWidget *childAtRecursiveHelper(const QPoint &p, bool, bool includeFrame = false) const;
498
void updateGeometry_helper(bool forceUpdate);
500
void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
501
void setLayoutItemMargins(int left, int top, int right, int bottom);
502
void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);
504
// aboutToDestroy() is called just before the contents of
505
// QWidget::destroy() is executed. It's used to signal QWidget
506
// sub-classes that their internals are about to be released.
507
virtual void aboutToDestroy() {}
509
inline QWidget *effectiveFocusWidget() {
510
QWidget *w = q_func();
511
while (w->focusProxy())
518
// This is an helper function that return the available geometry for
519
// a widget and takes care is this one is in QGraphicsView.
520
// If the widget is not embed in a scene then the geometry available is
521
// null, we let QDesktopWidget decide for us.
522
static QRect screenGeometry(const QWidget *widget)
525
#ifndef QT_NO_GRAPHICSVIEW
526
QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget);
527
//It's embedded if it has an ancestor
529
if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != 0) {
530
// One view, let be smart and return the viewport rect then the popup is aligned
531
if (ancestorProxy->scene()->views().size() == 1) {
532
QGraphicsView *view = ancestorProxy->scene()->views().at(0);
533
screen = view->mapToScene(view->viewport()->rect()).boundingRect().toRect();
535
screen = ancestorProxy->scene()->sceneRect().toRect();
543
inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
545
Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
546
redirectDev = replacement;
547
redirectOffset = offset;
550
inline QPaintDevice *redirected(QPoint *offset) const
553
*offset = redirectDev ? redirectOffset : QPoint();
557
inline void restoreRedirected()
560
inline void enforceNativeChildren()
565
if (extra->nativeChildrenForced)
567
extra->nativeChildrenForced = 1;
569
for (int i = 0; i < children.size(); ++i) {
570
if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
571
child->setAttribute(Qt::WA_NativeWindow);
575
inline bool nativeChildrenForced() const
577
return extra ? extra->nativeChildrenForced : false;
580
inline QRect effectiveRectFor(const QRect &rect) const
582
#ifndef QT_NO_GRAPHICSEFFECT
583
if (graphicsEffect && graphicsEffect->isEnabled())
584
return graphicsEffect->boundingRectFor(rect).toAlignedRect();
585
#endif //QT_NO_GRAPHICSEFFECT
589
QSize adjustedSize() const;
591
inline void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
594
if (button == Qt::LeftButton && qApp->autoSipEnabled()) {
595
QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
596
q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
597
if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
598
qApp->inputMethod()->show();
603
void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
605
inline QPoint mapToWS(const QPoint &p) const
606
{ return p - data.wrect.topLeft(); }
608
inline QPoint mapFromWS(const QPoint &p) const
609
{ return p + data.wrect.topLeft(); }
611
inline QRect mapToWS(const QRect &r) const
612
{ QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
614
inline QRect mapFromWS(const QRect &r) const
615
{ QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
618
// Regular pointers (keep them together to avoid gaps on 64 bit architectures).
622
QWidget *focus_child;
625
QPaintDevice *redirectDev;
626
QWidgetItemV2 *widgetItem;
627
QPaintEngine *extraPaintEngine;
628
mutable const QMetaObject *polished;
629
QGraphicsEffect *graphicsEffect;
630
// All widgets are added into the allWidgets set. Once
631
// they receive a window id they are also added to the mapper.
632
// This should just ensure that all widgets are deleted by QApplication
633
static QWidgetMapper *mapper;
634
static QWidgetSet *allWidgets;
635
#if !defined(QT_NO_IM)
636
Qt::InputMethodHints imHints;
638
#ifdef QT_KEYPAD_NAVIGATION
639
static QPointer<QWidget> editingWidget;
642
// Implicit pointers (shared_null/shared_empty).
643
QRegion opaqueChildren;
645
#ifndef QT_NO_TOOLTIP
648
#ifndef QT_NO_STATUSTIP
651
#ifndef QT_NO_WHATSTHIS
654
#ifndef QT_NO_ACCESSIBILITY
655
QString accessibleName;
656
QString accessibleDescription;
660
uint inheritedFontResolveMask;
661
uint inheritedPaletteResolveMask;
666
signed char leftLayoutItemMargin;
667
signed char topLayoutItemMargin;
668
signed char rightLayoutItemMargin;
669
signed char bottomLayoutItemMargin;
670
static int instanceCounter; // Current number of widget instances
671
static int maxInstances; // Maximum number of widget instances
674
QSizePolicy size_policy;
676
QPoint redirectOffset;
678
QList<QAction*> actions;
680
#ifndef QT_NO_GESTURES
681
QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
685
uint high_attributes[4]; // the low ones are in QWidget::widget_attributes
686
QPalette::ColorRole fg_role : 8;
687
QPalette::ColorRole bg_role : 8;
688
uint dirtyOpaqueChildren : 1;
690
uint inDirtyList : 1;
693
uint usesDoubleBufferedGLContext : 1;
695
uint inheritsInputMethodHints : 1;
698
// *************************** Platform specific ************************************
699
#if defined(Q_OS_WIN)
700
uint noPaintOnScreen : 1; // see qwidget_qpa.cpp ::paintEngine()
702
#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
704
static QWidget *mouseGrabber;
705
static QWidget *keyboardGrabber;
707
void setWindowRole();
708
void sendStartupMessage(const char *message) const;
709
void setNetWmWindowTypes();
710
void x11UpdateIsOpaque();
711
bool isBackgroundInherited() const;
712
void updateX11AcceptFocus();
713
QPoint mapToGlobal(const QPoint &pos) const;
714
QPoint mapFromGlobal(const QPoint &pos) const;
715
#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
716
#ifndef QT_NO_GESTURES
717
uint nativeGesturePanEnabled : 1;
719
bool shouldShowMaximizeButton();
720
void winUpdateIsOpaque();
721
void reparentChildren();
722
#ifndef QT_NO_DRAGANDDROP
723
QOleDropTarget *registerOleDnd(QWidget *widget);
724
void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
726
void grabMouseWhileInWindow();
727
void registerTouchWindow();
728
void winSetupGestures();
729
#elif defined(Q_OS_MAC) // <--------------------------------------------------------- MAC
730
void macUpdateSizeAttribute();
731
#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC (old stuff)
733
uint needWindowChange : 1;
735
// Each wiget keeps a list of all its child and grandchild OpenGL widgets.
736
// This list is used to update the gl context whenever a parent and a granparent
737
// moves, and also to check for intersections with gl widgets within the window
738
// when a widget moves.
741
GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { }
742
bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); }
744
QWidget * lastUpdateWidget;
747
// dirtyOnWidget contains the areas in the widget that needs to be repained,
748
// in the same way as dirtyOnScreen does for the window. Areas are added in
749
// dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
750
// this information repaint invalid areas when widgets are scrolled.
751
QRegion dirtyOnWidget;
752
EventHandlerRef window_event;
753
QList<GlWidgetInfo> glWidgets;
755
//these are here just for code compat (HIViews)
758
void macUpdateHideOnSuspend();
759
void macUpdateOpaqueSizeGrip();
760
void macUpdateIgnoreMouseEvents();
761
void macUpdateMetalAttribute();
762
void macUpdateIsOpaque();
763
void macSetNeedsDisplay(QRegion region);
764
void setEnabled_helper_sys(bool enable);
765
bool isRealWindow() const;
766
void adjustWithinMaxAndMinSize(int &w, int &h);
767
void applyMaxAndMinSizeOnWindow();
768
void update_sys(const QRect &rect);
769
void update_sys(const QRegion &rgn);
770
void setGeometry_sys_helper(int, int, int, int, bool);
771
void updateMaximizeButton_sys();
772
void createWindow_sys();
773
void recreateMacWindow();
774
void setSubWindowStacking(bool set);
775
void setWindowLevel();
776
void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
777
void syncCocoaMask();
778
void finishCocoaMaskSetup();
779
void syncUnifiedMode();
780
// Did we add the drawRectOriginal method?
781
bool drawRectOriginalAdded;
782
// Is the original drawRect method available?
783
bool originalDrawMethod;
784
// Do we need to change the methods?
787
// Unified toolbar variables
788
bool isInUnifiedToolbar;
789
QUnifiedToolbarSurface *unifiedSurface;
790
QPoint toolbar_offset;
791
QWidget *toolbar_ancestor;
793
bool touchEventsEnabled;
794
void determineWindowClass();
795
void transferChildren();
796
bool qt_mac_dnd_event(uint, DragRef);
797
void toggleDrawers(bool);
798
//mac event functions
799
static bool qt_create_root_win();
800
static void qt_clean_root_win();
801
static bool qt_mac_update_sizer(QWidget *, int up = 0);
802
static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
803
static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
804
static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
805
void registerTouchWindow(bool enable = true);
807
bool stealKeyboardGrab(bool grab);
808
bool stealMouseGrab(bool grab);
811
struct QWidgetPaintContext
813
inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f,
814
QPainter *p, QWidgetBackingStore *b)
815
: pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(0) {}
821
QPainter *sharedPainter;
822
QWidgetBackingStore *backingStore;
826
#ifndef QT_NO_GRAPHICSEFFECT
827
class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate
830
QWidgetEffectSourcePrivate(QWidget *widget)
831
: QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false)
835
{ m_widget->d_func()->graphicsEffect = 0; }
837
inline const QGraphicsItem *graphicsItem() const
840
inline const QWidget *widget() const
845
updateDueToGraphicsEffect = true;
847
updateDueToGraphicsEffect = false;
850
inline bool isPixmap() const
853
inline void effectBoundingRectChanged()
855
// ### This function should take a rect parameter; then we can avoid
856
// updating too much on the parent widget.
857
if (QWidget *parent = m_widget->parentWidget())
863
inline const QStyleOption *styleOption() const
866
inline QRect deviceRect() const
867
{ return m_widget->window()->rect(); }
869
QRectF boundingRect(Qt::CoordinateSystem system) const;
870
void draw(QPainter *p);
871
QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset,
872
QGraphicsEffect::PixmapPadMode mode) const;
875
QWidgetPaintContext *context;
876
QTransform lastEffectTransform;
877
bool updateDueToGraphicsEffect;
879
#endif //QT_NO_GRAPHICSEFFECT
881
inline QWExtra *QWidgetPrivate::extraData() const
886
inline QTLWExtra *QWidgetPrivate::topData() const
888
const_cast<QWidgetPrivate *>(this)->createTLExtra();
889
return extra->topextra;
892
inline QTLWExtra *QWidgetPrivate::maybeTopData() const
894
return extra ? extra->topextra : 0;
897
inline QPainter *QWidgetPrivate::sharedPainter() const
900
QTLWExtra *x = q->window()->d_func()->maybeTopData();
901
return x ? x->sharedPainter : 0;
904
inline void QWidgetPrivate::setSharedPainter(QPainter *painter)
907
QTLWExtra *x = q->window()->d_func()->topData();
908
x->sharedPainter = painter;
911
inline bool QWidgetPrivate::pointInsideRectAndMask(const QPoint &p) const
914
return q->rect().contains(p) && (!extra || !extra->hasMask || q->testAttribute(Qt::WA_MouseNoMask)
915
|| extra->mask.contains(p));
918
inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
921
QTLWExtra *x = q->window()->d_func()->maybeTopData();
922
return x ? x->backingStoreTracker.data() : 0;
927
#endif // QWIDGET_P_H