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

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

gui: Added QWidget::addPmEventFilter()/removPmEventFilter() (OS/2 specific).

File size: 30.5 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#elif defined(Q_WS_PM) // <----------------------------------------------------- PM
280 QList<QWidget::PmEventFilter*> pmEventFilters;
281#endif
282};
283
284/*!
285 \internal
286
287 Returns true if \a p or any of its parents enable the
288 Qt::BypassGraphicsProxyWidget window flag. Used in QWidget::show() and
289 QWidget::setParent() to determine whether it's necessary to embed the
290 widget into a QGraphicsProxyWidget or not.
291*/
292static inline bool bypassGraphicsProxyWidget(const QWidget *p)
293{
294 while (p) {
295 if (p->windowFlags() & Qt::BypassGraphicsProxyWidget)
296 return true;
297 p = p->parentWidget();
298 }
299 return false;
300}
301
302class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
303{
304 Q_DECLARE_PUBLIC(QWidget)
305
306public:
307 // *************************** Cross-platform ***************************************
308 enum DrawWidgetFlags {
309 DrawAsRoot = 0x01,
310 DrawPaintOnScreen = 0x02,
311 DrawRecursive = 0x04,
312 DrawInvisible = 0x08,
313 DontSubtractOpaqueChildren = 0x10,
314 DontSetCompositionMode = 0x20,
315 DontDrawOpaqueChildren = 0x40
316 };
317
318 enum CloseMode {
319 CloseNoEvent,
320 CloseWithEvent,
321 CloseWithSpontaneousEvent
322 };
323
324 enum Direction {
325 DirectionNorth = 0x01,
326 DirectionEast = 0x10,
327 DirectionSouth = 0x02,
328 DirectionWest = 0x20
329 };
330
331 // Functions.
332 explicit QWidgetPrivate(int version = QObjectPrivateVersion);
333 ~QWidgetPrivate();
334
335 QWExtra *extraData() const;
336 QTLWExtra *topData() const;
337 QTLWExtra *maybeTopData() const;
338 QPainter *sharedPainter() const;
339 void setSharedPainter(QPainter *painter);
340 QWidgetBackingStore *maybeBackingStore() const;
341 void init(QWidget *desktopWidget, Qt::WindowFlags f);
342 void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
343 void createRecursively();
344 void createWinId(WId id = 0);
345
346 void createTLExtra();
347 void createExtra();
348 void deleteExtra();
349 void createSysExtra();
350 void deleteSysExtra();
351 void createTLSysExtra();
352 void deleteTLSysExtra();
353 void updateSystemBackground();
354 void propagatePaletteChange();
355
356 void setPalette_helper(const QPalette &);
357 void resolvePalette();
358 QPalette naturalWidgetPalette(uint inheritedMask) const;
359
360 void setMask_sys(const QRegion &);
361#ifdef Q_OS_SYMBIAN
362 void setSoftKeys_sys(const QList<QAction*> &softkeys);
363 void activateSymbianWindow(WId wid = 0);
364 void _q_delayedDestroy(WId winId);
365#endif
366
367 void raise_sys();
368 void lower_sys();
369 void stackUnder_sys(QWidget *);
370
371 void setFocus_sys();
372
373 void updateFont(const QFont &);
374 inline void setFont_helper(const QFont &font) {
375 if (data.fnt == font && data.fnt.resolve() == font.resolve())
376 return;
377 updateFont(font);
378 }
379 void resolveFont();
380 QFont naturalWidgetFont(uint inheritedMask) const;
381
382 void setLayoutDirection_helper(Qt::LayoutDirection);
383 void resolveLayoutDirection();
384
385 void setLocale_helper(const QLocale &l, bool forceUpdate = false);
386 void resolveLocale();
387
388 void setStyle_helper(QStyle *newStyle, bool propagate, bool metalHack = false);
389 void inheritStyle();
390
391 void setUpdatesEnabled_helper(bool );
392
393 void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const;
394 bool isAboutToShow() const;
395 QRegion prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags);
396 void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
397 QWidget::RenderFlags renderFlags);
398 void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
399 QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0);
400
401
402 void paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& children, int index,
403 const QRegion &rgn, const QPoint &offset, int flags
404#ifdef Q_BACKINGSTORE_SUBSURFACES
405 , const QWindowSurface *currentSurface
406#endif
407 , QPainter *sharedPainter, QWidgetBackingStore *backingStore);
408
409
410 QPainter *beginSharedPainter();
411 bool endSharedPainter();
412#ifndef QT_NO_GRAPHICSVIEW
413 static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin);
414#endif
415 QWindowSurface *createDefaultWindowSurface();
416 QWindowSurface *createDefaultWindowSurface_sys();
417 void repaint_sys(const QRegion &rgn);
418
419 QRect clipRect() const;
420 QRegion clipRegion() const;
421 void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const;
422 void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0,
423 bool alsoNonOpaque = false) const;
424 void clipToEffectiveMask(QRegion &region) const;
425 void updateIsOpaque();
426 void setOpaque(bool opaque);
427 void updateIsTranslucent();
428 bool paintOnScreen() const;
429#ifndef QT_NO_GRAPHICSEFFECT
430 void invalidateGraphicsEffectsRecursively();
431#endif //QT_NO_GRAPHICSEFFECT
432
433 const QRegion &getOpaqueChildren() const;
434 void setDirtyOpaqueRegion();
435
436 bool close_helper(CloseMode mode);
437
438 void setWindowIcon_helper();
439 void setWindowIcon_sys(bool forceReset = false);
440 void setWindowOpacity_sys(qreal opacity);
441 void adjustQuitOnCloseAttribute();
442
443 void scrollChildren(int dx, int dy);
444 void moveRect(const QRect &, int dx, int dy);
445 void scrollRect(const QRect &, int dx, int dy);
446 void invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize);
447 // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
448 void invalidateBuffer(const QRegion &);
449 void invalidateBuffer(const QRect &);
450 bool isOverlapped(const QRect&) const;
451 void syncBackingStore();
452 void syncBackingStore(const QRegion &region);
453
454 void reparentFocusWidgets(QWidget *oldtlw);
455
456 static int pointToRect(const QPoint &p, const QRect &r);
457
458 void setWinId(WId);
459 void showChildren(bool spontaneous);
460 void hideChildren(bool spontaneous);
461 void setParent_sys(QWidget *parent, Qt::WindowFlags);
462 void scroll_sys(int dx, int dy);
463 void scroll_sys(int dx, int dy, const QRect &r);
464 void deactivateWidgetCleanup();
465 void setGeometry_sys(int, int, int, int, bool);
466 void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
467 void activateChildLayoutsRecursively();
468 void show_recursive();
469 void show_helper();
470 void show_sys();
471 void hide_sys();
472 void hide_helper();
473 void _q_showIfNotHidden();
474
475 void setEnabled_helper(bool);
476 void registerDropSite(bool);
477 static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
478
479 void updateFrameStrut();
480 QRect frameStrut() const;
481
482#ifdef QT_KEYPAD_NAVIGATION
483 static bool navigateToDirection(Direction direction);
484 static QWidget *widgetInNavigationDirection(Direction direction);
485#endif
486
487 void setWindowIconText_sys(const QString &cap);
488 void setWindowIconText_helper(const QString &cap);
489 void setWindowTitle_sys(const QString &cap);
490
491#ifndef QT_NO_CURSOR
492 void setCursor_sys(const QCursor &cursor);
493 void unsetCursor_sys();
494#endif
495
496 void setWindowTitle_helper(const QString &cap);
497 void setWindowFilePath_helper(const QString &filePath);
498
499 bool setMinimumSize_helper(int &minw, int &minh);
500 bool setMaximumSize_helper(int &maxw, int &maxh);
501 void setConstraints_sys();
502 QWidget *childAt_helper(const QPoint &, bool) const;
503 void updateGeometry_helper(bool forceUpdate);
504
505 void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
506 void setLayoutItemMargins(int left, int top, int right, int bottom);
507 void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);
508
509 QInputContext *inputContext() const;
510 inline QWidget *effectiveFocusWidget() {
511 QWidget *w = q_func();
512 while (w->focusProxy())
513 w = w->focusProxy();
514 return w;
515 }
516
517 void setModal_sys();
518
519 // This is an helper function that return the available geometry for
520 // a widget and takes care is this one is in QGraphicsView.
521 // If the widget is not embed in a scene then the geometry available is
522 // null, we let QDesktopWidget decide for us.
523 static QRect screenGeometry(const QWidget *widget)
524 {
525 QRect screen;
526#ifndef QT_NO_GRAPHICSVIEW
527 QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget);
528 //It's embedded if it has an ancestor
529 if (ancestorProxy) {
530 if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != 0) {
531 // One view, let be smart and return the viewport rect then the popup is aligned
532 if (ancestorProxy->scene()->views().size() == 1) {
533 QGraphicsView *view = ancestorProxy->scene()->views().at(0);
534 screen = view->mapToScene(view->viewport()->rect()).boundingRect().toRect();
535 } else {
536 screen = ancestorProxy->scene()->sceneRect().toRect();
537 }
538 }
539 }
540#endif
541 return screen;
542 }
543
544 inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
545 {
546 Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
547 redirectDev = replacement;
548 redirectOffset = offset;
549 }
550
551 inline QPaintDevice *redirected(QPoint *offset) const
552 {
553 if (offset)
554 *offset = redirectDev ? redirectOffset : QPoint();
555 return redirectDev;
556 }
557
558 inline void restoreRedirected()
559 { redirectDev = 0; }
560
561 inline void enforceNativeChildren()
562 {
563 if (!extra)
564 createExtra();
565
566 if (extra->nativeChildrenForced)
567 return;
568 extra->nativeChildrenForced = 1;
569
570 for (int i = 0; i < children.size(); ++i) {
571 if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
572 child->setAttribute(Qt::WA_NativeWindow);
573 }
574 }
575
576 inline bool nativeChildrenForced() const
577 {
578 return extra ? extra->nativeChildrenForced : false;
579 }
580
581 inline QRect effectiveRectFor(const QRect &rect) const
582 {
583#ifndef QT_NO_GRAPHICSEFFECT
584 if (graphicsEffect && graphicsEffect->isEnabled())
585 return graphicsEffect->boundingRectFor(rect).toAlignedRect();
586#endif //QT_NO_GRAPHICSEFFECT
587 return rect;
588 }
589
590 QSize adjustedSize() const;
591
592 inline void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
593 {
594 Q_Q(QWidget);
595 if (button == Qt::LeftButton && qApp->autoSipEnabled()) {
596 QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
597 q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
598 if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
599 QEvent event(QEvent::RequestSoftwareInputPanel);
600 QApplication::sendEvent(q, &event);
601 }
602 }
603 }
604
605#ifndef Q_WS_QWS // Almost cross-platform :-)
606 void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
607
608 inline QPoint mapToWS(const QPoint &p) const
609 { return p - data.wrect.topLeft(); }
610
611 inline QPoint mapFromWS(const QPoint &p) const
612 { return p + data.wrect.topLeft(); }
613
614 inline QRect mapToWS(const QRect &r) const
615 { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
616
617 inline QRect mapFromWS(const QRect &r) const
618 { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
619#endif
620
621 // Variables.
622 // Regular pointers (keep them together to avoid gaps on 64 bit architectures).
623 QWExtra *extra;
624 QWidget *focus_next;
625 QWidget *focus_prev;
626 QWidget *focus_child;
627 QLayout *layout;
628 QRegion *needsFlush;
629 QPaintDevice *redirectDev;
630 QWidgetItemV2 *widgetItem;
631 QPaintEngine *extraPaintEngine;
632 mutable const QMetaObject *polished;
633 QGraphicsEffect *graphicsEffect;
634 // All widgets are added into the allWidgets set. Once
635 // they receive a window id they are also added to the mapper.
636 // This should just ensure that all widgets are deleted by QApplication
637 static QWidgetMapper *mapper;
638 static QWidgetSet *allWidgets;
639#if !defined(QT_NO_IM)
640 QPointer<QInputContext> ic;
641 Qt::InputMethodHints imHints;
642#endif
643#ifdef QT_KEYPAD_NAVIGATION
644 static QPointer<QWidget> editingWidget;
645#endif
646
647 // Implicit pointers (shared_null/shared_empty).
648 QRegion opaqueChildren;
649 QRegion dirty;
650#ifndef QT_NO_TOOLTIP
651 QString toolTip;
652#endif
653#ifndef QT_NO_STATUSTIP
654 QString statusTip;
655#endif
656#ifndef QT_NO_WHATSTHIS
657 QString whatsThis;
658#endif
659#ifndef QT_NO_ACCESSIBILITY
660 QString accessibleName;
661 QString accessibleDescription;
662#endif
663
664 // Other variables.
665 uint inheritedFontResolveMask;
666 uint inheritedPaletteResolveMask;
667 short leftmargin;
668 short topmargin;
669 short rightmargin;
670 short bottommargin;
671 signed char leftLayoutItemMargin;
672 signed char topLayoutItemMargin;
673 signed char rightLayoutItemMargin;
674 signed char bottomLayoutItemMargin;
675 static int instanceCounter; // Current number of widget instances
676 static int maxInstances; // Maximum number of widget instances
677 Qt::HANDLE hd;
678 QWidgetData data;
679 QSizePolicy size_policy;
680 QLocale locale;
681 QPoint redirectOffset;
682#ifndef QT_NO_ACTION
683 QList<QAction*> actions;
684#endif
685 QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
686
687 // Bit fields.
688 uint high_attributes[3]; // the low ones are in QWidget::widget_attributes
689 QPalette::ColorRole fg_role : 8;
690 QPalette::ColorRole bg_role : 8;
691 uint dirtyOpaqueChildren : 1;
692 uint isOpaque : 1;
693 uint inDirtyList : 1;
694 uint isScrolled : 1;
695 uint isMoved : 1;
696 uint usesDoubleBufferedGLContext : 1;
697
698 // *************************** Platform specific ************************************
699#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
700 QX11Info xinfo;
701 Qt::HANDLE picture;
702 static QWidget *mouseGrabber;
703 static QWidget *keyboardGrabber;
704
705 void setWindowRole();
706 void sendStartupMessage(const char *message) const;
707 void setNetWmWindowTypes();
708 void x11UpdateIsOpaque();
709 bool isBackgroundInherited() const;
710#elif defined(Q_WS_PM) // <----------------------------------------------------------- PM
711 uint noPaintOnScreen : 1; // see qwidget_pm.cpp ::paintEngine()
712
713 HWND frameWinId() const
714 { return maybeTopData() && maybeTopData()->fId != NULLHANDLE ?
715 maybeTopData()->fId : data.winid; }
716 HWND effectiveFrameWinId() const;
717 void validateObstacles();
718 void reparentChildren();
719#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
720 uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
721 uint nativeGesturePanEnabled : 1;
722
723 bool shouldShowMaximizeButton();
724 void winUpdateIsOpaque();
725 void reparentChildren();
726#ifndef QT_NO_DRAGANDDROP
727 QOleDropTarget *registerOleDnd(QWidget *widget);
728 void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
729#endif
730 void grabMouseWhileInWindow();
731 void registerTouchWindow();
732 void winSetupGestures();
733#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
734 // This is new stuff
735 uint needWindowChange : 1;
736 uint isGLWidget : 1;
737
738 // Each wiget keeps a list of all its child and grandchild OpenGL widgets.
739 // This list is used to update the gl context whenever a parent and a granparent
740 // moves, and also to check for intersections with gl widgets within the window
741 // when a widget moves.
742 struct GlWidgetInfo
743 {
744 GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { }
745 bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); }
746 QWidget * widget;
747 QWidget * lastUpdateWidget;
748 };
749
750 // dirtyOnWidget contains the areas in the widget that needs to be repained,
751 // in the same way as dirtyOnScreen does for the window. Areas are added in
752 // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
753 // this information repaint invalid areas when widgets are scrolled.
754 QRegion dirtyOnWidget;
755 EventHandlerRef window_event;
756 QList<GlWidgetInfo> glWidgets;
757
758 //these are here just for code compat (HIViews)
759 Qt::HANDLE qd_hd;
760
761 void macUpdateSizeAttribute();
762 void macUpdateHideOnSuspend();
763 void macUpdateOpaqueSizeGrip();
764 void macUpdateIgnoreMouseEvents();
765 void macUpdateMetalAttribute();
766 void macUpdateIsOpaque();
767 void setEnabled_helper_sys(bool enable);
768 bool isRealWindow() const;
769 void adjustWithinMaxAndMinSize(int &w, int &h);
770 void applyMaxAndMinSizeOnWindow();
771 void update_sys(const QRect &rect);
772 void update_sys(const QRegion &rgn);
773 void setGeometry_sys_helper(int, int, int, int, bool);
774 void setWindowModified_sys(bool b);
775 void updateMaximizeButton_sys();
776 void setWindowFilePath_sys(const QString &filePath);
777 void createWindow_sys();
778 void recreateMacWindow();
779#ifndef QT_MAC_USE_COCOA
780 void initWindowPtr();
781 void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
782#else
783 void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
784 void syncCocoaMask();
785 void finishCocoaMaskSetup();
786#endif
787 void determineWindowClass();
788 void transferChildren();
789 bool qt_mac_dnd_event(uint, DragRef);
790 void toggleDrawers(bool);
791 //mac event functions
792 static bool qt_create_root_win();
793 static void qt_clean_root_win();
794 static bool qt_mac_update_sizer(QWidget *, int up = 0);
795 static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
796 static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
797 static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
798 void registerTouchWindow();
799#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
800 void setMaxWindowState_helper();
801 void setFullScreenSize_helper();
802 void moveSurface(QWindowSurface *surface, const QPoint &offset);
803 QRegion localRequestedRegion() const;
804 QRegion localAllocatedRegion() const;
805
806 friend class QWSManager;
807 friend class QWSManagerPrivate;
808 friend class QDecoration;
809#ifndef QT_NO_CURSOR
810 void updateCursor() const;
811#endif
812 QScreen* getScreen() const;
813#elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN
814 static QWidget *mouseGrabber;
815 static QWidget *keyboardGrabber;
816 void s60UpdateIsOpaque();
817 void reparentChildren();
818 void registerTouchWindow();
819#endif
820
821};
822
823struct QWidgetPaintContext
824{
825 inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f,
826 QPainter *p, QWidgetBackingStore *b)
827 : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(0) {}
828
829 QPaintDevice *pdev;
830 QRegion rgn;
831 QPoint offset;
832 int flags;
833 QPainter *sharedPainter;
834 QWidgetBackingStore *backingStore;
835 QPainter *painter;
836};
837
838#ifndef QT_NO_GRAPHICSEFFECT
839class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate
840{
841public:
842 QWidgetEffectSourcePrivate(QWidget *widget)
843 : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false)
844 {}
845
846 inline void detach()
847 { m_widget->d_func()->graphicsEffect = 0; }
848
849 inline const QGraphicsItem *graphicsItem() const
850 { return 0; }
851
852 inline const QWidget *widget() const
853 { return m_widget; }
854
855 inline void update()
856 {
857 updateDueToGraphicsEffect = true;
858 m_widget->update();
859 updateDueToGraphicsEffect = false;
860 }
861
862 inline bool isPixmap() const
863 { return false; }
864
865 inline void effectBoundingRectChanged()
866 {
867 // ### This function should take a rect parameter; then we can avoid
868 // updating too much on the parent widget.
869 if (QWidget *parent = m_widget->parentWidget())
870 parent->update();
871 else
872 update();
873 }
874
875 inline const QStyleOption *styleOption() const
876 { return 0; }
877
878 inline QRect deviceRect() const
879 { return m_widget->window()->rect(); }
880
881 QRectF boundingRect(Qt::CoordinateSystem system) const;
882 void draw(QPainter *p);
883 QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset,
884 QGraphicsEffect::PixmapPadMode mode) const;
885
886 QWidget *m_widget;
887 QWidgetPaintContext *context;
888 QTransform lastEffectTransform;
889 bool updateDueToGraphicsEffect;
890};
891#endif //QT_NO_GRAPHICSEFFECT
892
893inline QWExtra *QWidgetPrivate::extraData() const
894{
895 return extra;
896}
897
898inline QTLWExtra *QWidgetPrivate::topData() const
899{
900 const_cast<QWidgetPrivate *>(this)->createTLExtra();
901 return extra->topextra;
902}
903
904inline QTLWExtra *QWidgetPrivate::maybeTopData() const
905{
906 return extra ? extra->topextra : 0;
907}
908
909inline QPainter *QWidgetPrivate::sharedPainter() const
910{
911 Q_Q(const QWidget);
912 QTLWExtra *x = q->window()->d_func()->maybeTopData();
913 return x ? x->sharedPainter : 0;
914}
915
916inline void QWidgetPrivate::setSharedPainter(QPainter *painter)
917{
918 Q_Q(QWidget);
919 QTLWExtra *x = q->window()->d_func()->topData();
920 x->sharedPainter = painter;
921}
922
923inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
924{
925 Q_Q(const QWidget);
926 QTLWExtra *x = q->window()->d_func()->maybeTopData();
927 return x ? x->backingStore : 0;
928}
929
930QT_END_NAMESPACE
931
932#endif // QWIDGET_P_H
Note: See TracBrowser for help on using the repository browser.