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

Last change on this file since 603 was 569, checked in by Dmitry A. Kuminov, 15 years ago

gui: Adopted to 4.6.1 changes.

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