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

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

trunk: Merged in qt 4.6.2 sources.

File size: 30.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef 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 "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>
70
71#ifdef Q_WS_WIN
72#include "QtCore/qt_windows.h"
73#include <private/qdnd_p.h>
74#endif // Q_WS_WIN
75
76#ifdef Q_WS_PM
77#include "QtCore/qt_os2.h"
78#endif
79
80#ifdef Q_WS_X11
81#include "QtGui/qx11info_x11.h"
82#endif
83
84#ifdef Q_WS_MAC
85#include <private/qt_mac_p.h>
86#endif
87
88#if defined(Q_WS_QWS)
89#include "QtGui/qinputcontext.h"
90#include "QtGui/qscreen_qws.h"
91#endif
92
93#if defined(Q_OS_SYMBIAN)
94class RDrawableWindow;
95class CCoeControl;
96#endif
97
98QT_BEGIN_NAMESPACE
99
100// Extra QWidget data
101// - to minimize memory usage for members that are seldom used.
102// - top-level widgets have extra extra data to reduce cost further
103#if defined(Q_WS_QWS)
104class QWSManager;
105#endif
106#if defined(Q_WS_MAC)
107class QCoreGraphicsPaintEnginePrivate;
108#endif
109class QPaintEngine;
110class QPixmap;
111class QWidgetBackingStore;
112class QGraphicsProxyWidget;
113class QWidgetItemV2;
114
115class QStyle;
116
117struct QTLWExtra {
118 // *************************** Cross-platform variables *****************************
119
120 // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
121 QIcon *icon; // widget icon
122 QPixmap *iconPixmap;
123 QWidgetBackingStore *backingStore;
124 QWindowSurface *windowSurface;
125 QPainter *sharedPainter;
126
127 // Implicit pointers (shared_null).
128 QString caption; // widget caption
129 QString iconText; // widget icon text
130 QString role; // widget role
131 QString filePath; // widget file path
132
133 // Other variables.
134 short incw, inch; // size increments
135 short basew, baseh; // base sizes
136 // frame strut, don't use these directly, use QWidgetPrivate::frameStrut() instead.
137 QRect frameStrut;
138 QRect normalGeometry; // used by showMin/maximized/FullScreen
139 Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
140
141 // *************************** Cross-platform bit fields ****************************
142 uint opacity : 8;
143 uint posFromMove : 1;
144 uint sizeAdjusted : 1;
145 uint inTopLevelResize : 1;
146 uint inRepaint : 1;
147 uint embedded : 1;
148
149 // *************************** Platform specific values (bit fields first) **********
150#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
151 uint spont_unmapped: 1; // window was spontaneously unmapped
152 uint dnd : 1; // DND properties installed
153 uint validWMState : 1; // is WM_STATE valid?
154 uint waitingForMapNotify : 1; // show() has been called, haven't got the MapNotify yet
155 WId parentWinId; // parent window Id (valid after reparenting)
156 WId userTimeWindow; // window id that contains user-time timestamp when WM supports a _NET_WM_USER_TIME_WINDOW atom
157 QPoint fullScreenOffset;
158#ifndef QT_NO_XSYNC
159 WId syncUpdateCounter;
160 ulong syncRequestTimestamp;
161 qint32 newCounterValueHi;
162 quint32 newCounterValueLo;
163#endif
164#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
165 HICON winIconBig; // internal big Windows icon
166 HICON winIconSmall; // internal small Windows icon
167#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
168 uint resizer : 4;
169 uint isSetGeometry : 1;
170 uint isMove : 1;
171 quint32 wattr;
172 quint32 wclass;
173 WindowGroupRef group;
174 IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
175 quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys()
176#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
177#ifndef QT_NO_QWS_MANAGER
178 QWSManager *qwsManager;
179#endif
180#elif defined(Q_OS_SYMBIAN)
181 uint inExpose : 1; // Prevents drawing recursion
182#elif defined(Q_WS_PM)
183 HWND fId;
184 HSWITCH swEntry;
185 HPOINTER iconPointer;
186#endif
187};
188
189struct QWExtra {
190 // *************************** Cross-platform variables *****************************
191
192 // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
193 void *glContext; // if the widget is hijacked by QGLWindowSurface
194 QTLWExtra *topextra; // only useful for TLWs
195#ifndef QT_NO_GRAPHICSVIEW
196 QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
197#endif
198#ifndef QT_NO_CURSOR
199 QCursor *curs;
200#endif
201 QPointer<QStyle> style;
202 QPointer<QWidget> focus_proxy;
203
204 // Implicit pointers (shared_empty/shared_null).
205 QRegion mask; // widget mask
206 QString styleSheet;
207
208 // Other variables.
209 qint32 minw;
210 qint32 minh; // minimum size
211 qint32 maxw;
212 qint32 maxh; // maximum size
213 quint16 customDpiX;
214 quint16 customDpiY;
215 QSize staticContentsSize;
216
217 // *************************** Cross-platform bit fields ****************************
218 uint explicitMinSize : 2;
219 uint explicitMaxSize : 2;
220 uint autoFillBackground : 1;
221 uint nativeChildrenForced : 1;
222 uint inRenderWithPainter : 1;
223 uint hasMask : 1;
224
225 // *************************** Platform specific values (bit fields first) **********
226#if defined(Q_WS_WIN) // <----------------------------------------------------------- WIN
227#ifndef QT_NO_DRAGANDDROP
228 QOleDropTarget *dropTarget; // drop target
229 QList<QPointer<QWidget> > oleDropWidgets;
230#endif
231#elif defined(Q_WS_X11) // <--------------------------------------------------------- X11
232 uint compress_events : 1;
233 WId xDndProxy; // XDND forwarding to embedded windows
234#elif defined(Q_WS_MAC) // <------------------------------------------------------ MAC
235#ifdef QT_MAC_USE_COCOA
236 // Cocoa Mask stuff
237 QImage maskBits;
238 CGImageRef imageMask;
239#endif
240#elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian
241 uint activated : 1; // RWindowBase::Activated has been called
242
243 /**
244 * Defines the behaviour of QSymbianControl::Draw.
245 */
246 enum NativePaintMode {
247 /**
248 * Normal drawing mode: blits the required region of the backing store
249 * via WSERV.
250 */
251 Blit,
252
253 /**
254 * Disable drawing for this widget.
255 */
256 Disable,
257
258 /**
259 * Paint zeros into the WSERV framebuffer, using BitGDI APIs. For windows
260 * with an EColor16MU display mode, zero is written only into the R, G and B
261 * channels of the pixel.
262 */
263 ZeroFill,
264
265 Default = Blit
266 };
267
268 NativePaintMode nativePaintMode : 2;
269
270 /**
271 * If this bit is set, each native widget receives the signals from the
272 * Symbian control immediately before and immediately after draw ops are
273 * sent to the window server for this control:
274 * void beginNativePaintEvent(const QRect &paintRect);
275 * void endNativePaintEvent(const QRect &paintRect);
276 */
277 uint receiveNativePaintEvents : 1;
278
279#endif
280};
281
282/*!
283 \internal
284
285 Returns true if \a p or any of its parents enable the
286 Qt::BypassGraphicsProxyWidget window flag. Used in QWidget::show() and
287 QWidget::setParent() to determine whether it's necessary to embed the
288 widget into a QGraphicsProxyWidget or not.
289*/
290static inline bool bypassGraphicsProxyWidget(const QWidget *p)
291{
292 while (p) {
293 if (p->windowFlags() & Qt::BypassGraphicsProxyWidget)
294 return true;
295 p = p->parentWidget();
296 }
297 return false;
298}
299
300class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
301{
302 Q_DECLARE_PUBLIC(QWidget)
303
304public:
305 // *************************** Cross-platform ***************************************
306 enum DrawWidgetFlags {
307 DrawAsRoot = 0x01,
308 DrawPaintOnScreen = 0x02,
309 DrawRecursive = 0x04,
310 DrawInvisible = 0x08,
311 DontSubtractOpaqueChildren = 0x10,
312 DontSetCompositionMode = 0x20,
313 DontDrawOpaqueChildren = 0x40
314 };
315
316 enum CloseMode {
317 CloseNoEvent,
318 CloseWithEvent,
319 CloseWithSpontaneousEvent
320 };
321
322 enum Direction {
323 DirectionNorth = 0x01,
324 DirectionEast = 0x10,
325 DirectionSouth = 0x02,
326 DirectionWest = 0x20
327 };
328
329 // Functions.
330 explicit QWidgetPrivate(int version = QObjectPrivateVersion);
331 ~QWidgetPrivate();
332
333 QWExtra *extraData() const;
334 QTLWExtra *topData() const;
335 QTLWExtra *maybeTopData() const;
336 QPainter *sharedPainter() const;
337 void setSharedPainter(QPainter *painter);
338 QWidgetBackingStore *maybeBackingStore() const;
339 void init(QWidget *desktopWidget, Qt::WindowFlags f);
340 void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
341 void createRecursively();
342 void createWinId(WId id = 0);
343
344 void createTLExtra();
345 void createExtra();
346 void deleteExtra();
347 void createSysExtra();
348 void deleteSysExtra();
349 void createTLSysExtra();
350 void deleteTLSysExtra();
351 void updateSystemBackground();
352 void propagatePaletteChange();
353
354 void setPalette_helper(const QPalette &);
355 void resolvePalette();
356 QPalette naturalWidgetPalette(uint inheritedMask) const;
357
358 void setMask_sys(const QRegion &);
359#ifdef Q_OS_SYMBIAN
360 void setSoftKeys_sys(const QList<QAction*> &softkeys);
361 void activateSymbianWindow(WId wid = 0);
362 void _q_delayedDestroy(WId winId);
363#endif
364
365 void raise_sys();
366 void lower_sys();
367 void stackUnder_sys(QWidget *);
368
369 void setFocus_sys();
370
371 void updateFont(const QFont &);
372 inline void setFont_helper(const QFont &font) {
373 if (data.fnt == font && data.fnt.resolve() == font.resolve())
374 return;
375 updateFont(font);
376 }
377 void resolveFont();
378 QFont naturalWidgetFont(uint inheritedMask) const;
379
380 void setLayoutDirection_helper(Qt::LayoutDirection);
381 void resolveLayoutDirection();
382
383 void setLocale_helper(const QLocale &l, bool forceUpdate = false);
384 void resolveLocale();
385
386 void setStyle_helper(QStyle *newStyle, bool propagate, bool metalHack = false);
387 void inheritStyle();
388
389 void setUpdatesEnabled_helper(bool );
390
391 void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const;
392 bool isAboutToShow() const;
393 QRegion prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags);
394 void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
395 QWidget::RenderFlags renderFlags);
396 void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
397 QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0);
398
399
400 void paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& children, int index,
401 const QRegion &rgn, const QPoint &offset, int flags
402#ifdef Q_BACKINGSTORE_SUBSURFACES
403 , const QWindowSurface *currentSurface
404#endif
405 , QPainter *sharedPainter, QWidgetBackingStore *backingStore);
406
407
408 QPainter *beginSharedPainter();
409 bool endSharedPainter();
410#ifndef QT_NO_GRAPHICSVIEW
411 static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin);
412#endif
413 QWindowSurface *createDefaultWindowSurface();
414 QWindowSurface *createDefaultWindowSurface_sys();
415 void repaint_sys(const QRegion &rgn);
416
417 QRect clipRect() const;
418 QRegion clipRegion() const;
419 void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const;
420 void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0,
421 bool alsoNonOpaque = false) const;
422 void clipToEffectiveMask(QRegion &region) const;
423 void updateIsOpaque();
424 void setOpaque(bool opaque);
425 void updateIsTranslucent();
426 bool paintOnScreen() const;
427#ifndef QT_NO_GRAPHICSEFFECT
428 void invalidateGraphicsEffectsRecursively();
429#endif //QT_NO_GRAPHICSEFFECT
430
431 const QRegion &getOpaqueChildren() const;
432 void setDirtyOpaqueRegion();
433
434 bool close_helper(CloseMode mode);
435
436 void setWindowIcon_helper();
437 void setWindowIcon_sys(bool forceReset = false);
438 void setWindowOpacity_sys(qreal opacity);
439 void adjustQuitOnCloseAttribute();
440
441 void scrollChildren(int dx, int dy);
442 void moveRect(const QRect &, int dx, int dy);
443 void scrollRect(const QRect &, int dx, int dy);
444 void invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize);
445 // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
446 void invalidateBuffer(const QRegion &);
447 void invalidateBuffer(const QRect &);
448 bool isOverlapped(const QRect&) const;
449 void syncBackingStore();
450 void syncBackingStore(const QRegion &region);
451
452 void reparentFocusWidgets(QWidget *oldtlw);
453
454 static int pointToRect(const QPoint &p, const QRect &r);
455
456 void setWinId(WId);
457 void showChildren(bool spontaneous);
458 void hideChildren(bool spontaneous);
459 void setParent_sys(QWidget *parent, Qt::WindowFlags);
460 void scroll_sys(int dx, int dy);
461 void scroll_sys(int dx, int dy, const QRect &r);
462 void deactivateWidgetCleanup();
463 void setGeometry_sys(int, int, int, int, bool);
464 void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
465 void activateChildLayoutsRecursively();
466 void show_recursive();
467 void show_helper();
468 void show_sys();
469 void hide_sys();
470 void hide_helper();
471 void _q_showIfNotHidden();
472
473 void setEnabled_helper(bool);
474 void registerDropSite(bool);
475 static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
476
477 void updateFrameStrut();
478 QRect frameStrut() const;
479
480#ifdef QT_KEYPAD_NAVIGATION
481 static bool navigateToDirection(Direction direction);
482 static QWidget *widgetInNavigationDirection(Direction direction);
483#endif
484
485 void setWindowIconText_sys(const QString &cap);
486 void setWindowIconText_helper(const QString &cap);
487 void setWindowTitle_sys(const QString &cap);
488
489#ifndef QT_NO_CURSOR
490 void setCursor_sys(const QCursor &cursor);
491 void unsetCursor_sys();
492#endif
493
494 void setWindowTitle_helper(const QString &cap);
495 void setWindowFilePath_helper(const QString &filePath);
496
497 bool setMinimumSize_helper(int &minw, int &minh);
498 bool setMaximumSize_helper(int &maxw, int &maxh);
499 void setConstraints_sys();
500 QWidget *childAt_helper(const QPoint &, bool) const;
501 void updateGeometry_helper(bool forceUpdate);
502
503 void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
504 void setLayoutItemMargins(int left, int top, int right, int bottom);
505 void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);
506
507 QInputContext *inputContext() const;
508 inline QWidget *effectiveFocusWidget() {
509 QWidget *w = q_func();
510 while (w->focusProxy())
511 w = w->focusProxy();
512 return w;
513 }
514
515 void setModal_sys();
516
517 // This is an helper function that return the available geometry for
518 // a widget and takes care is this one is in QGraphicsView.
519 // If the widget is not embed in a scene then the geometry available is
520 // null, we let QDesktopWidget decide for us.
521 static QRect screenGeometry(const QWidget *widget)
522 {
523 QRect screen;
524#ifndef QT_NO_GRAPHICSVIEW
525 QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget);
526 //It's embedded if it has an ancestor
527 if (ancestorProxy) {
528 if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != 0) {
529 // One view, let be smart and return the viewport rect then the popup is aligned
530 if (ancestorProxy->scene()->views().size() == 1) {
531 QGraphicsView *view = ancestorProxy->scene()->views().at(0);
532 screen = view->mapToScene(view->viewport()->rect()).boundingRect().toRect();
533 } else {
534 screen = ancestorProxy->scene()->sceneRect().toRect();
535 }
536 }
537 }
538#endif
539 return screen;
540 }
541
542 inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
543 {
544 Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
545 redirectDev = replacement;
546 redirectOffset = offset;
547 }
548
549 inline QPaintDevice *redirected(QPoint *offset) const
550 {
551 if (offset)
552 *offset = redirectDev ? redirectOffset : QPoint();
553 return redirectDev;
554 }
555
556 inline void restoreRedirected()
557 { redirectDev = 0; }
558
559 inline void enforceNativeChildren()
560 {
561 if (!extra)
562 createExtra();
563
564 if (extra->nativeChildrenForced)
565 return;
566 extra->nativeChildrenForced = 1;
567
568 for (int i = 0; i < children.size(); ++i) {
569 if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
570 child->setAttribute(Qt::WA_NativeWindow);
571 }
572 }
573
574 inline bool nativeChildrenForced() const
575 {
576 return extra ? extra->nativeChildrenForced : false;
577 }
578
579 inline QRect effectiveRectFor(const QRect &rect) const
580 {
581#ifndef QT_NO_GRAPHICSEFFECT
582 if (graphicsEffect && graphicsEffect->isEnabled())
583 return graphicsEffect->boundingRectFor(rect).toAlignedRect();
584#endif //QT_NO_GRAPHICSEFFECT
585 return rect;
586 }
587
588 QSize adjustedSize() const;
589
590 inline void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
591 {
592 Q_Q(QWidget);
593 if (button == Qt::LeftButton && qApp->autoSipEnabled()) {
594 QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
595 q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
596 if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
597 QEvent event(QEvent::RequestSoftwareInputPanel);
598 QApplication::sendEvent(q, &event);
599 }
600 }
601 }
602
603#ifndef Q_WS_QWS // Almost cross-platform :-)
604 void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
605
606 inline QPoint mapToWS(const QPoint &p) const
607 { return p - data.wrect.topLeft(); }
608
609 inline QPoint mapFromWS(const QPoint &p) const
610 { return p + data.wrect.topLeft(); }
611
612 inline QRect mapToWS(const QRect &r) const
613 { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
614
615 inline QRect mapFromWS(const QRect &r) const
616 { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
617#endif
618
619 // Variables.
620 // Regular pointers (keep them together to avoid gaps on 64 bit architectures).
621 QWExtra *extra;
622 QWidget *focus_next;
623 QWidget *focus_prev;
624 QWidget *focus_child;
625 QLayout *layout;
626 QRegion *needsFlush;
627 QPaintDevice *redirectDev;
628 QWidgetItemV2 *widgetItem;
629 QPaintEngine *extraPaintEngine;
630 mutable const QMetaObject *polished;
631 QGraphicsEffect *graphicsEffect;
632 // All widgets are added into the allWidgets set. Once
633 // they receive a window id they are also added to the mapper.
634 // This should just ensure that all widgets are deleted by QApplication
635 static QWidgetMapper *mapper;
636 static QWidgetSet *allWidgets;
637#if !defined(QT_NO_IM)
638 QPointer<QInputContext> ic;
639 Qt::InputMethodHints imHints;
640#endif
641#ifdef QT_KEYPAD_NAVIGATION
642 static QPointer<QWidget> editingWidget;
643#endif
644
645 // Implicit pointers (shared_null/shared_empty).
646 QRegion opaqueChildren;
647 QRegion dirty;
648#ifndef QT_NO_TOOLTIP
649 QString toolTip;
650#endif
651#ifndef QT_NO_STATUSTIP
652 QString statusTip;
653#endif
654#ifndef QT_NO_WHATSTHIS
655 QString whatsThis;
656#endif
657#ifndef QT_NO_ACCESSIBILITY
658 QString accessibleName;
659 QString accessibleDescription;
660#endif
661
662 // Other variables.
663 uint inheritedFontResolveMask;
664 uint inheritedPaletteResolveMask;
665 short leftmargin;
666 short topmargin;
667 short rightmargin;
668 short bottommargin;
669 signed char leftLayoutItemMargin;
670 signed char topLayoutItemMargin;
671 signed char rightLayoutItemMargin;
672 signed char bottomLayoutItemMargin;
673 static int instanceCounter; // Current number of widget instances
674 static int maxInstances; // Maximum number of widget instances
675 Qt::HANDLE hd;
676 QWidgetData data;
677 QSizePolicy size_policy;
678 QLocale locale;
679 QPoint redirectOffset;
680#ifndef QT_NO_ACTION
681 QList<QAction*> actions;
682#endif
683 QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
684
685 // Bit fields.
686 uint high_attributes[3]; // the low ones are in QWidget::widget_attributes
687 QPalette::ColorRole fg_role : 8;
688 QPalette::ColorRole bg_role : 8;
689 uint dirtyOpaqueChildren : 1;
690 uint isOpaque : 1;
691 uint inDirtyList : 1;
692 uint isScrolled : 1;
693 uint isMoved : 1;
694 uint usesDoubleBufferedGLContext : 1;
695
696 // *************************** Platform specific ************************************
697#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
698 QX11Info xinfo;
699 Qt::HANDLE picture;
700 static QWidget *mouseGrabber;
701 static QWidget *keyboardGrabber;
702
703 void setWindowRole();
704 void sendStartupMessage(const char *message) const;
705 void setNetWmWindowTypes();
706 void x11UpdateIsOpaque();
707 bool isBackgroundInherited() const;
708#elif defined(Q_WS_PM) // <----------------------------------------------------------- PM
709 uint noPaintOnScreen : 1; // see qwidget_pm.cpp ::paintEngine()
710
711 HWND frameWinId() const
712 { return maybeTopData() && maybeTopData()->fId != NULLHANDLE ?
713 maybeTopData()->fId : data.winid; }
714 HWND effectiveFrameWinId() const;
715 void validateObstacles();
716 void reparentChildren();
717#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
718 uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
719 uint nativeGesturePanEnabled : 1;
720
721 bool shouldShowMaximizeButton();
722 void winUpdateIsOpaque();
723 void reparentChildren();
724#ifndef QT_NO_DRAGANDDROP
725 QOleDropTarget *registerOleDnd(QWidget *widget);
726 void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
727#endif
728 void grabMouseWhileInWindow();
729 void registerTouchWindow();
730 void winSetupGestures();
731#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
732 // This is new stuff
733 uint needWindowChange : 1;
734 uint isGLWidget : 1;
735
736 // Each wiget keeps a list of all its child and grandchild OpenGL widgets.
737 // This list is used to update the gl context whenever a parent and a granparent
738 // moves, and also to check for intersections with gl widgets within the window
739 // when a widget moves.
740 struct GlWidgetInfo
741 {
742 GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { }
743 bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); }
744 QWidget * widget;
745 QWidget * lastUpdateWidget;
746 };
747
748 // dirtyOnWidget contains the areas in the widget that needs to be repained,
749 // in the same way as dirtyOnScreen does for the window. Areas are added in
750 // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
751 // this information repaint invalid areas when widgets are scrolled.
752 QRegion dirtyOnWidget;
753 EventHandlerRef window_event;
754 QList<GlWidgetInfo> glWidgets;
755
756 //these are here just for code compat (HIViews)
757 Qt::HANDLE qd_hd;
758
759 void macUpdateSizeAttribute();
760 void macUpdateHideOnSuspend();
761 void macUpdateOpaqueSizeGrip();
762 void macUpdateIgnoreMouseEvents();
763 void macUpdateMetalAttribute();
764 void macUpdateIsOpaque();
765 void setEnabled_helper_sys(bool enable);
766 bool isRealWindow() const;
767 void adjustWithinMaxAndMinSize(int &w, int &h);
768 void applyMaxAndMinSizeOnWindow();
769 void update_sys(const QRect &rect);
770 void update_sys(const QRegion &rgn);
771 void setGeometry_sys_helper(int, int, int, int, bool);
772 void setWindowModified_sys(bool b);
773 void updateMaximizeButton_sys();
774 void setWindowFilePath_sys(const QString &filePath);
775 void createWindow_sys();
776 void recreateMacWindow();
777#ifndef QT_MAC_USE_COCOA
778 void initWindowPtr();
779 void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
780#else
781 void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
782 void syncCocoaMask();
783 void finishCocoaMaskSetup();
784#endif
785 void determineWindowClass();
786 void transferChildren();
787 bool qt_mac_dnd_event(uint, DragRef);
788 void toggleDrawers(bool);
789 //mac event functions
790 static bool qt_create_root_win();
791 static void qt_clean_root_win();
792 static bool qt_mac_update_sizer(QWidget *, int up = 0);
793 static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
794 static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
795 static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
796 void registerTouchWindow();
797#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
798 void setMaxWindowState_helper();
799 void setFullScreenSize_helper();
800 void moveSurface(QWindowSurface *surface, const QPoint &offset);
801 QRegion localRequestedRegion() const;
802 QRegion localAllocatedRegion() const;
803
804 friend class QWSManager;
805 friend class QWSManagerPrivate;
806 friend class QDecoration;
807#ifndef QT_NO_CURSOR
808 void updateCursor() const;
809#endif
810 QScreen* getScreen() const;
811#elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN
812 static QWidget *mouseGrabber;
813 static QWidget *keyboardGrabber;
814 void s60UpdateIsOpaque();
815 void reparentChildren();
816 void registerTouchWindow();
817#endif
818
819};
820
821struct QWidgetPaintContext
822{
823 inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f,
824 QPainter *p, QWidgetBackingStore *b)
825 : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(0) {}
826
827 QPaintDevice *pdev;
828 QRegion rgn;
829 QPoint offset;
830 int flags;
831 QPainter *sharedPainter;
832 QWidgetBackingStore *backingStore;
833 QPainter *painter;
834};
835
836#ifndef QT_NO_GRAPHICSEFFECT
837class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate
838{
839public:
840 QWidgetEffectSourcePrivate(QWidget *widget)
841 : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false)
842 {}
843
844 inline void detach()
845 { m_widget->d_func()->graphicsEffect = 0; }
846
847 inline const QGraphicsItem *graphicsItem() const
848 { return 0; }
849
850 inline const QWidget *widget() const
851 { return m_widget; }
852
853 inline void update()
854 {
855 updateDueToGraphicsEffect = true;
856 m_widget->update();
857 updateDueToGraphicsEffect = false;
858 }
859
860 inline bool isPixmap() const
861 { return false; }
862
863 inline void effectBoundingRectChanged()
864 {
865 // ### This function should take a rect parameter; then we can avoid
866 // updating too much on the parent widget.
867 if (QWidget *parent = m_widget->parentWidget())
868 parent->update();
869 else
870 update();
871 }
872
873 inline const QStyleOption *styleOption() const
874 { return 0; }
875
876 inline QRect deviceRect() const
877 { return m_widget->window()->rect(); }
878
879 QRectF boundingRect(Qt::CoordinateSystem system) const;
880 void draw(QPainter *p);
881 QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset,
882 QGraphicsEffect::PixmapPadMode mode) const;
883
884 QWidget *m_widget;
885 QWidgetPaintContext *context;
886 QTransform lastEffectTransform;
887 bool updateDueToGraphicsEffect;
888};
889#endif //QT_NO_GRAPHICSEFFECT
890
891inline QWExtra *QWidgetPrivate::extraData() const
892{
893 return extra;
894}
895
896inline QTLWExtra *QWidgetPrivate::topData() const
897{
898 const_cast<QWidgetPrivate *>(this)->createTLExtra();
899 return extra->topextra;
900}
901
902inline QTLWExtra *QWidgetPrivate::maybeTopData() const
903{
904 return extra ? extra->topextra : 0;
905}
906
907inline QPainter *QWidgetPrivate::sharedPainter() const
908{
909 Q_Q(const QWidget);
910 QTLWExtra *x = q->window()->d_func()->maybeTopData();
911 return x ? x->sharedPainter : 0;
912}
913
914inline void QWidgetPrivate::setSharedPainter(QPainter *painter)
915{
916 Q_Q(QWidget);
917 QTLWExtra *x = q->window()->d_func()->topData();
918 x->sharedPainter = painter;
919}
920
921inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
922{
923 Q_Q(const QWidget);
924 QTLWExtra *x = q->window()->d_func()->maybeTopData();
925 return x ? x->backingStore : 0;
926}
927
928QT_END_NAMESPACE
929
930#endif // QWIDGET_P_H
Note: See TracBrowser for help on using the repository browser.