Changeset 561 for trunk/src/gui/kernel/qwidget_p.h
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/kernel/qwidget_p.h
r309 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 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 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 58 58 #include "QtCore/qrect.h" 59 59 #include "QtCore/qlocale.h" 60 #include "QtCore/qset.h" 60 61 #include "QtGui/qregion.h" 61 62 #include "QtGui/qsizepolicy.h" 62 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> 63 70 64 71 #ifdef Q_WS_WIN … … 82 89 #include "QtGui/qinputcontext.h" 83 90 #include "QtGui/qscreen_qws.h" 91 #endif 92 93 #if defined(Q_OS_SYMBIAN) 94 class RDrawableWindow; 95 class CCoeControl; 84 96 #endif 85 97 … … 104 116 105 117 struct 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). 106 128 QString caption; // widget caption 107 129 QString iconText; // widget icon text 108 130 QString role; // widget role 109 131 QString filePath; // widget file path 110 QIcon *icon; // widget icon 111 QPixmap *iconPixmap;132 133 // Other variables. 112 134 short incw, inch; // size increments 135 short basew, baseh; // base sizes 113 136 // frame strut, don't use these directly, use QWidgetPrivate::frameStrut() instead. 114 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 **************************** 115 142 uint opacity : 8; 116 143 uint posFromMove : 1; … … 118 145 uint inTopLevelResize : 1; 119 146 uint inRepaint : 1; 120 QWidgetBackingStore *backingStore; 121 #if defined(Q_WS_WIN) 122 ulong savedFlags; // Save window flags while showing fullscreen 123 uint embedded : 1; // window is embedded in another application 124 #else 125 Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen 126 #endif 127 short basew, baseh; // base sizes 128 #if defined(Q_WS_X11) 129 WId parentWinId; // parent window Id (valid after reparenting) 130 uint embedded : 1; // window is embedded in another Qt application 147 uint embedded : 1; 148 149 // *************************** Platform specific values (bit fields first) ********** 150 #if defined(Q_WS_X11) // <----------------------------------------------------------- X11 131 151 uint spont_unmapped: 1; // window was spontaneously unmapped 132 152 uint dnd : 1; // DND properties installed 133 153 uint validWMState : 1; // is WM_STATE valid? 134 154 uint waitingForMapNotify : 1; // show() has been called, haven't got the MapNotify yet 155 WId parentWinId; // parent window Id (valid after reparenting) 135 156 WId userTimeWindow; // window id that contains user-time timestamp when WM supports a _NET_WM_USER_TIME_WINDOW atom 136 157 QPoint fullScreenOffset; 137 #endif 138 #if defined(Q_WS_MAC) 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; 139 171 quint32 wattr; 140 172 quint32 wclass; … … 142 174 IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys. 143 175 quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys() 144 uint resizer : 4; 145 uint isSetGeometry : 1; 146 uint isMove : 1; 147 uint embedded : 1; 148 #endif 149 #if defined(Q_WS_QWS) && !defined (QT_NO_QWS_MANAGER) 176 #elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS 177 #ifndef QT_NO_QWS_MANAGER 150 178 QWSManager *qwsManager; 151 179 #endif 152 #if defined(Q_WS_WIN) 153 HICON winIconBig; // internal big Windows icon 154 HICON winIconSmall; // internal small Windows icon 155 #endif 156 #if defined(Q_WS_PM) 180 #elif defined(Q_WS_PM) 157 181 HWND fId; 158 182 HSWITCH swEntry; 159 183 HPOINTER iconPointer; 160 184 #endif 161 QRect normalGeometry; // used by showMin/maximized/FullScreen162 QWindowSurface *windowSurface;163 QPainter *sharedPainter;164 185 }; 165 186 166 187 struct QWExtra { 167 qint32 minw, minh; // minimum size 168 qint32 maxw, maxh; // maximum size 169 QPointer<QWidget> focus_proxy; 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 170 196 #ifndef QT_NO_CURSOR 171 197 QCursor *curs; 172 198 #endif 173 QTLWExtra *topextra; // only useful for TLWs 174 QGraphicsProxyWidget *proxyWidget; // if the widget is embedded 175 void *glContext; // if the widget is hijacked by QGLWindowSurface 176 #if defined(Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP) 177 QOleDropTarget *dropTarget; // drop target 178 QList<QPointer<QWidget> > oleDropWidgets; 179 #endif 180 #if defined(Q_WS_X11) 181 WId xDndProxy; // XDND forwarding to embedded windows 182 #endif 199 QPointer<QStyle> style; 200 QPointer<QWidget> focus_proxy; 201 202 // Implicit pointers (shared_empty/shared_null). 183 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; 184 213 QSize staticContentsSize; 185 214 186 //bit flags at the end to improve packing 187 #if defined(Q_WS_WIN) 188 uint shown_mode : 8; // widget show mode 189 #ifndef QT_NO_DIRECT3D 190 uint had_paint_on_screen : 1; 191 uint had_no_system_bg : 1; 192 uint had_auto_fill_bg : 1; 193 #endif 194 #endif 195 #if defined(Q_WS_X11) 196 uint compress_events : 1; 197 #endif 215 // *************************** Cross-platform bit fields **************************** 198 216 uint explicitMinSize : 2; 199 217 uint explicitMaxSize : 2; … … 203 221 uint hasMask : 1; 204 222 205 QPointer<QStyle> style; 206 QString styleSheet; 207 208 quint16 customDpiX; 209 quint16 customDpiY; 210 #if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) 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 211 234 // Cocoa Mask stuff 212 235 QImage maskBits; 213 236 CGImageRef imageMask; 214 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 215 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 */ 288 static 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 } 216 297 217 298 class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate … … 220 301 221 302 public: 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. 222 328 explicit QWidgetPrivate(int version = QObjectPrivateVersion); 223 329 ~QWidgetPrivate(); … … 229 335 void setSharedPainter(QPainter *painter); 230 336 QWidgetBackingStore *maybeBackingStore() const; 231 #ifdef Q_WS_QWS232 void setMaxWindowState_helper();233 void setFullScreenSize_helper();234 #endif235 337 void init(QWidget *desktopWidget, Qt::WindowFlags f); 236 338 void create_sys(WId window, bool initializeWindow, bool destroyOldWindow); … … 253 355 254 356 void setMask_sys(const QRegion &); 255 #ifdef Q_WS_WIN 256 bool shouldShowMaximizeButton(); 257 void winUpdateIsOpaque(); 258 #endif 259 260 #ifdef Q_WS_MAC 261 void macUpdateSizeAttribute(); 262 void macUpdateHideOnSuspend(); 263 void macUpdateOpaqueSizeGrip(); 264 void macUpdateIgnoreMouseEvents(); 265 void macUpdateMetalAttribute(); 266 void macUpdateIsOpaque(); 267 void setEnabled_helper_sys(bool enable); 268 bool isRealWindow() const; 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); 269 361 #endif 270 362 … … 293 385 void inheritStyle(); 294 386 295 bool isBackgroundInherited() const;296 297 387 void setUpdatesEnabled_helper(bool ); 298 388 299 void paintBackground(QPainter *, const QRegion &, const QPoint & = QPoint(), int flags = DrawAsRoot) const; 300 enum DrawWidgetFlags { 301 DrawAsRoot = 0x01, 302 DrawPaintOnScreen = 0x02, 303 DrawRecursive = 0x04, 304 DrawInvisible = 0x08, 305 DontSubtractOpaqueChildren = 0x10, 306 DontSetCompositionMode = 0x20, 307 DontDrawOpaqueChildren = 0x40 308 }; 389 void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const; 309 390 bool isAboutToShow() const; 310 391 QRegion prepareToRender(const QRegion ®ion, QWidget::RenderFlags renderFlags); … … 325 406 QPainter *beginSharedPainter(); 326 407 bool endSharedPainter(); 327 static QGraphicsProxyWidget * nearestGraphicsProxyWidget(QWidget *origin); 408 #ifndef QT_NO_GRAPHICSVIEW 409 static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin); 410 #endif 328 411 QWindowSurface *createDefaultWindowSurface(); 329 412 QWindowSurface *createDefaultWindowSurface_sys(); 330 413 void repaint_sys(const QRegion &rgn); 331 #ifdef Q_WS_MAC332 void update_sys(const QRect &rect);333 void update_sys(const QRegion &rgn);334 #endif335 414 336 415 QRect clipRect() const; … … 343 422 void setOpaque(bool opaque); 344 423 void updateIsTranslucent(); 345 bool hasBackground() const;346 424 bool paintOnScreen() const; 347 348 QRegion getOpaqueRegion() const; 425 #ifndef QT_NO_GRAPHICSEFFECT 426 void invalidateGraphicsEffectsRecursively(); 427 #endif //QT_NO_GRAPHICSEFFECT 428 349 429 const QRegion &getOpaqueChildren() const; 350 430 void setDirtyOpaqueRegion(); 351 431 352 QRegion opaqueChildren;353 354 enum CloseMode {355 CloseNoEvent,356 CloseWithEvent,357 CloseWithSpontaneousEvent358 };359 432 bool close_helper(CloseMode mode); 360 433 361 bool compositeEvent(QEvent *e);362 434 void setWindowIcon_helper(); 363 435 void setWindowIcon_sys(bool forceReset = false); 364 436 void setWindowOpacity_sys(qreal opacity); 365 366 437 void adjustQuitOnCloseAttribute(); 367 438 368 #if defined(Q_WS_X11)369 void setWindowRole();370 void sendStartupMessage(const char *message) const;371 void setNetWmWindowTypes();372 void x11UpdateIsOpaque();373 #endif374 375 #if defined(Q_WS_WIN) || defined(Q_WS_PM)376 void reparentChildren();377 #endif378 379 439 void scrollChildren(int dx, int dy); 380 381 440 void moveRect(const QRect &, int dx, int dy); 382 441 void scrollRect(const QRect &, int dx, int dy); … … 392 451 393 452 static int pointToRect(const QPoint &p, const QRect &r); 394 QRect fromOrToLayoutItemRect(const QRect &rect, int sign) const;395 453 396 454 void setWinId(WId); … … 402 460 void deactivateWidgetCleanup(); 403 461 void setGeometry_sys(int, int, int, int, bool); 404 #ifdef Q_WS_MAC405 void setGeometry_sys_helper(int, int, int, int, bool);406 #endif407 462 void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false); 408 463 void activateChildLayoutsRecursively(); … … 416 471 void setEnabled_helper(bool); 417 472 void registerDropSite(bool); 418 #if defined(Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)419 QOleDropTarget *registerOleDnd(QWidget *widget);420 void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);421 #endif422 473 static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0); 423 474 424 475 void updateFrameStrut(); 425 476 QRect frameStrut() const; 477 478 #ifdef QT_KEYPAD_NAVIGATION 479 static bool navigateToDirection(Direction direction); 480 static QWidget *widgetInNavigationDirection(Direction direction); 481 #endif 426 482 427 483 void setWindowIconText_sys(const QString &cap); … … 429 485 void setWindowTitle_sys(const QString &cap); 430 486 431 #ifdef Q_OS_WIN432 void grabMouseWhileInWindow();433 #endif434 435 487 #ifndef QT_NO_CURSOR 436 488 void setCursor_sys(const QCursor &cursor); … … 438 490 #endif 439 491 440 #ifdef Q_WS_MAC 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 #elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN 715 uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine() 716 uint nativeGesturePanEnabled : 1; 717 718 bool shouldShowMaximizeButton(); 719 void winUpdateIsOpaque(); 720 void reparentChildren(); 721 #ifndef QT_NO_DRAGANDDROP 722 QOleDropTarget *registerOleDnd(QWidget *widget); 723 void unregisterOleDnd(QWidget *widget, QOleDropTarget *target); 724 #endif 725 void grabMouseWhileInWindow(); 726 void registerTouchWindow(); 727 void winSetupGestures(); 728 #elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC 729 // This is new stuff 730 uint needWindowChange : 1; 731 uint isGLWidget : 1; 732 733 // Each wiget keeps a list of all its child and grandchild OpenGL widgets. 734 // This list is used to update the gl context whenever a parent and a granparent 735 // moves, and also to check for intersections with gl widgets within the window 736 // when a widget moves. 737 struct GlWidgetInfo 738 { 739 GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { } 740 bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); } 741 QWidget * widget; 742 QWidget * lastUpdateWidget; 743 }; 744 745 // dirtyOnWidget contains the areas in the widget that needs to be repained, 746 // in the same way as dirtyOnScreen does for the window. Areas are added in 747 // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use 748 // this information repaint invalid areas when widgets are scrolled. 749 QRegion dirtyOnWidget; 750 EventHandlerRef window_event; 751 QList<GlWidgetInfo> glWidgets; 752 753 //these are here just for code compat (HIViews) 754 Qt::HANDLE qd_hd; 755 756 void macUpdateSizeAttribute(); 757 void macUpdateHideOnSuspend(); 758 void macUpdateOpaqueSizeGrip(); 759 void macUpdateIgnoreMouseEvents(); 760 void macUpdateMetalAttribute(); 761 void macUpdateIsOpaque(); 762 void setEnabled_helper_sys(bool enable); 763 bool isRealWindow() const; 764 void adjustWithinMaxAndMinSize(int &w, int &h); 765 void applyMaxAndMinSizeOnWindow(); 766 void update_sys(const QRect &rect); 767 void update_sys(const QRegion &rgn); 768 void setGeometry_sys_helper(int, int, int, int, bool); 441 769 void setWindowModified_sys(bool b); 442 770 void updateMaximizeButton_sys(); … … 454 782 void determineWindowClass(); 455 783 void transferChildren(); 456 #endif457 void setWindowTitle_helper(const QString &cap);458 void setWindowFilePath_helper(const QString &filePath);459 460 bool setMinimumSize_helper(int &minw, int &minh);461 bool setMaximumSize_helper(int &maxw, int &maxh);462 void setConstraints_sys();463 QWidget *childAt_helper(const QPoint &, bool) const;464 void updateGeometry_helper(bool forceUpdate);465 466 void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;467 void setLayoutItemMargins(int left, int top, int right, int bottom);468 void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);469 470 QInputContext *inputContext() const;471 472 #if defined(Q_WS_PM)473 HWND frameWinId() const474 { return maybeTopData() && maybeTopData()->fId != NULLHANDLE ?475 maybeTopData()->fId : data.winid; }476 HWND effectiveFrameWinId() const;477 #endif478 479 #if defined(Q_WS_QWS)480 void moveSurface(QWindowSurface *surface, const QPoint &offset);481 482 QRegion localRequestedRegion() const;483 QRegion localAllocatedRegion() const;484 485 void blitToScreen(const QRegion &globalrgn);486 #ifndef QT_NO_CURSOR487 void updateCursor() const;488 #endif489 490 QScreen* getScreen() const;491 492 friend class QWSManager;493 friend class QWSManagerPrivate;494 friend class QDecoration;495 #endif496 497 static int instanceCounter; // Current number of widget instances498 static int maxInstances; // Maximum number of widget instances499 500 #ifdef QT_KEYPAD_NAVIGATION501 static QPointer<QWidget> editingWidget;502 #endif503 504 QWidgetData data;505 506 QWExtra *extra;507 QWidget *focus_next;508 QWidget *focus_prev;509 QWidget *focus_child;510 #ifndef QT_NO_ACTION511 QList<QAction*> actions;512 #endif513 QLayout *layout;514 QWidgetItemV2 *widgetItem;515 #if !defined(QT_NO_IM)516 QPointer<QInputContext> ic;517 #endif518 // All widgets are initially added into the uncreatedWidgets set. Once519 // they receive a window id they are removed and added to the mapper520 static QWidgetMapper *mapper;521 static QWidgetSet *uncreatedWidgets;522 523 short leftmargin, topmargin, rightmargin, bottommargin;524 525 signed char leftLayoutItemMargin;526 signed char topLayoutItemMargin;527 signed char rightLayoutItemMargin;528 signed char bottomLayoutItemMargin;529 530 // ### TODO: reorganize private/extra/topextra to save memory531 QPointer<QWidget> compositeChildGrab;532 #ifndef QT_NO_TOOLTIP533 QString toolTip;534 #endif535 #ifndef QT_NO_STATUSTIP536 QString statusTip;537 #endif538 #ifndef QT_NO_WHATSTHIS539 QString whatsThis;540 #endif541 QString accessibleName, accessibleDescription;542 543 QPalette::ColorRole fg_role : 8;544 QPalette::ColorRole bg_role : 8;545 uint high_attributes[3]; // the low ones are in QWidget::widget_attributes546 Qt::HANDLE hd;547 QRegion dirty;548 QRegion *needsFlush;549 uint dirtyOpaqueChildren : 1;550 uint isOpaque : 1;551 uint inDirtyList : 1;552 uint isScrolled : 1;553 uint isMoved : 1;554 555 #if defined(Q_WS_WIN) || defined(Q_WS_PM)556 uint noPaintOnScreen : 1; // see qwidget_[win|pm].cpp ::paintEngine()557 #endif558 559 uint inheritedFontResolveMask;560 uint inheritedPaletteResolveMask;561 #if defined(Q_WS_X11)562 QX11Info xinfo;563 Qt::HANDLE picture;564 #endif565 #if defined(Q_WS_MAC)566 enum PaintChildrenOPs {567 PC_None = 0x00,568 PC_Now = 0x01,569 PC_NoPaint = 0x04,570 PC_Later = 0x10571 };572 EventHandlerRef window_event;573 784 bool qt_mac_dnd_event(uint, DragRef); 574 785 void toggleDrawers(bool); … … 576 787 static bool qt_create_root_win(); 577 788 static void qt_clean_root_win(); 578 static bool qt_recreate_root_win();579 789 static bool qt_mac_update_sizer(QWidget *, int up = 0); 580 790 static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *); 581 791 static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *); 582 792 static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool); 583 static bool qt_widget_shape(QWidget *, short, HIMutableShapeRef, bool); 584 585 // Each wiget keeps a list of all its child and grandchild OpenGL widgets. 586 // This list is used to update the gl context whenever a parent and a granparent 587 // moves, and also to check for intersections with gl widgets within the window 588 // when a widget moves. 589 struct GlWidgetInfo 590 { 591 GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { } 592 bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); } 593 QWidget * widget; 594 QWidget * lastUpdateWidget; 595 }; 596 QList<GlWidgetInfo> glWidgets; 597 598 // dirtyOnWidget contains the areas in the widget that needs to be repained, 599 // in the same way as dirtyOnScreen does for the window. Areas are added in 600 // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use 601 // this information repaint invalid areas when widgets are scrolled. 602 QRegion dirtyOnWidget; 603 604 //these are here just for code compat (HIViews) 605 Qt::HANDLE qd_hd; 606 607 // This is new stuff 608 uint needWindowChange : 1; 609 uint isGLWidget : 1; 610 #endif 611 612 #if defined(Q_WS_X11) || defined (Q_WS_WIN) || defined (Q_WS_PM) || defined(Q_WS_MAC) 613 #ifdef Q_WS_MAC 614 void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect()); 615 #else 616 void setWSGeometry(bool dontShow=false); 617 #endif 618 619 inline QPoint mapToWS(const QPoint &p) const 620 { return p - data.wrect.topLeft(); } 621 622 inline QPoint mapFromWS(const QPoint &p) const 623 { return p + data.wrect.topLeft(); } 624 625 inline QRect mapToWS(const QRect &r) const 626 { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; } 627 628 inline QRect mapFromWS(const QRect &r) const 629 { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; } 630 #endif 631 632 QPaintEngine *extraPaintEngine; 633 634 mutable const QMetaObject *polished; 635 636 void setModal_sys(); 637 638 #ifdef Q_WS_PM 639 void validateObstacles(); 640 #endif 641 642 QSizePolicy size_policy; 643 QLocale locale; 644 645 #ifdef Q_WS_X11 793 void registerTouchWindow(); 794 #elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS 795 void setMaxWindowState_helper(); 796 void setFullScreenSize_helper(); 797 void moveSurface(QWindowSurface *surface, const QPoint &offset); 798 QRegion localRequestedRegion() const; 799 QRegion localAllocatedRegion() const; 800 801 friend class QWSManager; 802 friend class QWSManagerPrivate; 803 friend class QDecoration; 804 #ifndef QT_NO_CURSOR 805 void updateCursor() const; 806 #endif 807 QScreen* getScreen() const; 808 #elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN 646 809 static QWidget *mouseGrabber; 647 810 static QWidget *keyboardGrabber; 648 #endif 649 QPaintDevice *redirectDev; 650 QPoint redirectOffset; 651 652 inline void setRedirected(QPaintDevice *replacement, const QPoint &offset) 811 void s60UpdateIsOpaque(); 812 void reparentChildren(); 813 void registerTouchWindow(); 814 #endif 815 816 }; 817 818 struct QWidgetPaintContext 819 { 820 inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f, 821 QPainter *p, QWidgetBackingStore *b) 822 : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(0) {} 823 824 QPaintDevice *pdev; 825 QRegion rgn; 826 QPoint offset; 827 int flags; 828 QPainter *sharedPainter; 829 QWidgetBackingStore *backingStore; 830 QPainter *painter; 831 }; 832 833 #ifndef QT_NO_GRAPHICSEFFECT 834 class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate 835 { 836 public: 837 QWidgetEffectSourcePrivate(QWidget *widget) 838 : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false) 839 {} 840 841 inline void detach() 842 { m_widget->d_func()->graphicsEffect = 0; } 843 844 inline const QGraphicsItem *graphicsItem() const 845 { return 0; } 846 847 inline const QWidget *widget() const 848 { return m_widget; } 849 850 inline void update() 653 851 { 654 Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent)); 655 redirectDev = replacement; 656 redirectOffset = offset; 657 } 658 659 inline QPaintDevice *redirected(QPoint *offset) const 852 updateDueToGraphicsEffect = true; 853 m_widget->update(); 854 updateDueToGraphicsEffect = false; 855 } 856 857 inline bool isPixmap() const 858 { return false; } 859 860 inline void effectBoundingRectChanged() 660 861 { 661 if (offset) 662 *offset = redirectDev ? redirectOffset : QPoint(); 663 return redirectDev; 664 } 665 666 inline void restoreRedirected() 667 { redirectDev = 0; } 668 669 inline void enforceNativeChildren() 670 { 671 if (!extra) 672 createExtra(); 673 674 if (extra->nativeChildrenForced) 675 return; 676 extra->nativeChildrenForced = 1; 677 678 for (int i = 0; i < children.size(); ++i) { 679 if (QWidget *child = qobject_cast<QWidget *>(children.at(i))) 680 child->setAttribute(Qt::WA_NativeWindow); 681 } 682 } 683 684 inline bool nativeChildrenForced() const 685 { 686 return extra ? extra->nativeChildrenForced : false; 687 } 688 689 QSize adjustedSize() const; 862 // ### This function should take a rect parameter; then we can avoid 863 // updating too much on the parent widget. 864 if (QWidget *parent = m_widget->parentWidget()) 865 parent->update(); 866 else 867 update(); 868 } 869 870 inline const QStyleOption *styleOption() const 871 { return 0; } 872 873 inline QRect deviceRect() const 874 { return m_widget->window()->rect(); } 875 876 QRectF boundingRect(Qt::CoordinateSystem system) const; 877 void draw(QPainter *p); 878 QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset, 879 QGraphicsEffect::PixmapPadMode mode) const; 880 881 QWidget *m_widget; 882 QWidgetPaintContext *context; 883 QTransform lastEffectTransform; 884 bool updateDueToGraphicsEffect; 690 885 }; 886 #endif //QT_NO_GRAPHICSEFFECT 691 887 692 888 inline QWExtra *QWidgetPrivate::extraData() const
Note:
See TracChangeset
for help on using the changeset viewer.