00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef QWIDGET_H
00043 #define QWIDGET_H
00044
00045 #include <QtGui/qwindowdefs.h>
00046 #include <QtCore/qobject.h>
00047 #include <QtCore/qmargins.h>
00048 #include <QtGui/qpaintdevice.h>
00049 #include <QtGui/qpalette.h>
00050 #include <QtGui/qfont.h>
00051 #include <QtGui/qfontmetrics.h>
00052 #include <QtGui/qfontinfo.h>
00053 #include <QtGui/qsizepolicy.h>
00054 #include <QtGui/qregion.h>
00055 #include <QtGui/qbrush.h>
00056 #include <QtGui/qcursor.h>
00057 #include <QtGui/qkeysequence.h>
00058
00059 #ifdef QT_INCLUDE_COMPAT
00060 #include <QtGui/qevent.h>
00061 #endif
00062
00063 QT_BEGIN_HEADER
00064
00065 QT_BEGIN_NAMESPACE
00066
00067 QT_MODULE(Gui)
00068
00069 class QLayout;
00070 class QWSRegionManager;
00071 class QStyle;
00072 class QAction;
00073 class QVariant;
00074
00075 class QActionEvent;
00076 class QMouseEvent;
00077 class QWheelEvent;
00078 class QHoverEvent;
00079 class QKeyEvent;
00080 class QFocusEvent;
00081 class QPaintEvent;
00082 class QMoveEvent;
00083 class QResizeEvent;
00084 class QCloseEvent;
00085 class QContextMenuEvent;
00086 class QInputMethodEvent;
00087 class QTabletEvent;
00088 class QDragEnterEvent;
00089 class QDragMoveEvent;
00090 class QDragLeaveEvent;
00091 class QDropEvent;
00092 class QShowEvent;
00093 class QHideEvent;
00094 class QInputContext;
00095 class QIcon;
00096 class QWindowSurface;
00097 class QLocale;
00098 class QGraphicsProxyWidget;
00099 class QGraphicsEffect;
00100 #if defined(Q_WS_X11)
00101 class QX11Info;
00102 #endif
00103
00104 class QWidgetData
00105 {
00106 public:
00107 WId winid;
00108 uint widget_attributes;
00109 Qt::WindowFlags window_flags;
00110 uint window_state : 4;
00111 uint focus_policy : 4;
00112 uint sizehint_forced :1;
00113 uint is_closing :1;
00114 uint in_show : 1;
00115 uint in_set_window_state : 1;
00116 mutable uint fstrut_dirty : 1;
00117 uint context_menu_policy : 3;
00118 uint window_modality : 2;
00119 uint in_destructor : 1;
00120 uint unused : 13;
00121 QRect crect;
00122 mutable QPalette pal;
00123 QFont fnt;
00124 #if defined(Q_WS_QWS)
00125
00126
00127
00128
00129
00130
00131
00132 int alloc_region_index;
00133
00134 #endif
00135 QRect wrect;
00136 };
00137
00138 class QWidgetPrivate;
00139
00140 class Q_GUI_EXPORT QWidget : public QObject, public QPaintDevice
00141 {
00142 Q_OBJECT
00143 Q_DECLARE_PRIVATE(QWidget)
00144
00145 Q_PROPERTY(bool modal READ isModal)
00146 Q_PROPERTY(Qt::WindowModality windowModality READ windowModality WRITE setWindowModality)
00147 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
00148 Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
00149 Q_PROPERTY(QRect frameGeometry READ frameGeometry)
00150 Q_PROPERTY(QRect normalGeometry READ normalGeometry)
00151 Q_PROPERTY(int x READ x)
00152 Q_PROPERTY(int y READ y)
00153 Q_PROPERTY(QPoint pos READ pos WRITE move DESIGNABLE false STORED false)
00154 Q_PROPERTY(QSize frameSize READ frameSize)
00155 Q_PROPERTY(QSize size READ size WRITE resize DESIGNABLE false STORED false)
00156 Q_PROPERTY(int width READ width)
00157 Q_PROPERTY(int height READ height)
00158 Q_PROPERTY(QRect rect READ rect)
00159 Q_PROPERTY(QRect childrenRect READ childrenRect)
00160 Q_PROPERTY(QRegion childrenRegion READ childrenRegion)
00161 Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy)
00162 Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)
00163 Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)
00164 Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false DESIGNABLE false)
00165 Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false DESIGNABLE false)
00166 Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false DESIGNABLE false)
00167 Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false DESIGNABLE false)
00168 Q_PROPERTY(QSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement)
00169 Q_PROPERTY(QSize baseSize READ baseSize WRITE setBaseSize)
00170 Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
00171 Q_PROPERTY(QFont font READ font WRITE setFont)
00172 #ifndef QT_NO_CURSOR
00173 Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor)
00174 #endif
00175 Q_PROPERTY(bool mouseTracking READ hasMouseTracking WRITE setMouseTracking)
00176 Q_PROPERTY(bool isActiveWindow READ isActiveWindow)
00177 Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy)
00178 Q_PROPERTY(bool focus READ hasFocus)
00179 Q_PROPERTY(Qt::ContextMenuPolicy contextMenuPolicy READ contextMenuPolicy WRITE setContextMenuPolicy)
00180 Q_PROPERTY(bool updatesEnabled READ updatesEnabled WRITE setUpdatesEnabled DESIGNABLE false)
00181 Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
00182 Q_PROPERTY(bool minimized READ isMinimized)
00183 Q_PROPERTY(bool maximized READ isMaximized)
00184 Q_PROPERTY(bool fullScreen READ isFullScreen)
00185 Q_PROPERTY(QSize sizeHint READ sizeHint)
00186 Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint)
00187 Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops)
00188 Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE isWindow)
00189 Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon DESIGNABLE isWindow)
00190 Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText DESIGNABLE isWindow)
00191 Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow)
00192 Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow)
00193 #ifndef QT_NO_TOOLTIP
00194 Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
00195 #endif
00196 #ifndef QT_NO_STATUSTIP
00197 Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip)
00198 #endif
00199 #ifndef QT_NO_WHATSTHIS
00200 Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)
00201 #endif
00202 #ifndef QT_NO_ACCESSIBILITY
00203 Q_PROPERTY(QString accessibleName READ accessibleName WRITE setAccessibleName)
00204 Q_PROPERTY(QString accessibleDescription READ accessibleDescription WRITE setAccessibleDescription)
00205 #endif
00206 Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection)
00207 QDOC_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)
00208 Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground)
00209 #ifndef QT_NO_STYLE_STYLESHEET
00210 Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
00211 #endif
00212 Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET unsetLocale)
00213 Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath DESIGNABLE isWindow)
00214 Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
00215
00216 public:
00217 enum RenderFlag {
00218 DrawWindowBackground = 0x1,
00219 DrawChildren = 0x2,
00220 IgnoreMask = 0x4
00221 };
00222 Q_DECLARE_FLAGS(RenderFlags, RenderFlag)
00223
00224 explicit QWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
00225 #ifdef QT3_SUPPORT
00226 QT3_SUPPORT_CONSTRUCTOR QWidget(QWidget* parent, const char *name, Qt::WindowFlags f = 0);
00227 #endif
00228 ~QWidget();
00229
00230 int devType() const;
00231
00232 WId winId() const;
00233 void createWinId();
00234 inline WId internalWinId() const { return data->winid; }
00235 WId effectiveWinId() const;
00236
00237
00238 QStyle *style() const;
00239 void setStyle(QStyle *);
00240
00241
00242 bool isTopLevel() const;
00243 bool isWindow() const;
00244
00245 bool isModal() const;
00246 Qt::WindowModality windowModality() const;
00247 void setWindowModality(Qt::WindowModality windowModality);
00248
00249 bool isEnabled() const;
00250 bool isEnabledTo(QWidget*) const;
00251 bool isEnabledToTLW() const;
00252
00253 public Q_SLOTS:
00254 void setEnabled(bool);
00255 void setDisabled(bool);
00256 void setWindowModified(bool);
00257
00258
00259
00260 public:
00261 QRect frameGeometry() const;
00262 const QRect &geometry() const;
00263 QRect normalGeometry() const;
00264
00265 int x() const;
00266 int y() const;
00267 QPoint pos() const;
00268 QSize frameSize() const;
00269 QSize size() const;
00270 inline int width() const;
00271 inline int height() const;
00272 inline QRect rect() const;
00273 QRect childrenRect() const;
00274 QRegion childrenRegion() const;
00275
00276 QSize minimumSize() const;
00277 QSize maximumSize() const;
00278 int minimumWidth() const;
00279 int minimumHeight() const;
00280 int maximumWidth() const;
00281 int maximumHeight() const;
00282 void setMinimumSize(const QSize &);
00283 void setMinimumSize(int minw, int minh);
00284 void setMaximumSize(const QSize &);
00285 void setMaximumSize(int maxw, int maxh);
00286 void setMinimumWidth(int minw);
00287 void setMinimumHeight(int minh);
00288 void setMaximumWidth(int maxw);
00289 void setMaximumHeight(int maxh);
00290
00291 #ifdef Q_QDOC
00292 void setupUi(QWidget *widget);
00293 #endif
00294
00295 QSize sizeIncrement() const;
00296 void setSizeIncrement(const QSize &);
00297 void setSizeIncrement(int w, int h);
00298 QSize baseSize() const;
00299 void setBaseSize(const QSize &);
00300 void setBaseSize(int basew, int baseh);
00301
00302 void setFixedSize(const QSize &);
00303 void setFixedSize(int w, int h);
00304 void setFixedWidth(int w);
00305 void setFixedHeight(int h);
00306
00307
00308
00309 QPoint mapToGlobal(const QPoint &) const;
00310 QPoint mapFromGlobal(const QPoint &) const;
00311 QPoint mapToParent(const QPoint &) const;
00312 QPoint mapFromParent(const QPoint &) const;
00313 QPoint mapTo(QWidget *, const QPoint &) const;
00314 QPoint mapFrom(QWidget *, const QPoint &) const;
00315
00316 QWidget *window() const;
00317 QWidget *nativeParentWidget() const;
00318 inline QWidget *topLevelWidget() const { return window(); }
00319
00320
00321 const QPalette &palette() const;
00322 void setPalette(const QPalette &);
00323
00324 void setBackgroundRole(QPalette::ColorRole);
00325 QPalette::ColorRole backgroundRole() const;
00326
00327 void setForegroundRole(QPalette::ColorRole);
00328 QPalette::ColorRole foregroundRole() const;
00329
00330 const QFont &font() const;
00331 void setFont(const QFont &);
00332 QFontMetrics fontMetrics() const;
00333 QFontInfo fontInfo() const;
00334
00335 #ifndef QT_NO_CURSOR
00336 QCursor cursor() const;
00337 void setCursor(const QCursor &);
00338 void unsetCursor();
00339 #endif
00340
00341 void setMouseTracking(bool enable);
00342 bool hasMouseTracking() const;
00343 bool underMouse() const;
00344
00345 void setMask(const QBitmap &);
00346 void setMask(const QRegion &);
00347 QRegion mask() const;
00348 void clearMask();
00349
00350 void render(QPaintDevice *target, const QPoint &targetOffset = QPoint(),
00351 const QRegion &sourceRegion = QRegion(),
00352 RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren));
00353
00354 void render(QPainter *painter, const QPoint &targetOffset = QPoint(),
00355 const QRegion &sourceRegion = QRegion(),
00356 RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren));
00357
00358 #ifndef QT_NO_GRAPHICSEFFECT
00359 QGraphicsEffect *graphicsEffect() const;
00360 void setGraphicsEffect(QGraphicsEffect *effect);
00361 #endif //QT_NO_GRAPHICSEFFECT
00362
00363 #ifndef QT_NO_GESTURES
00364 void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags());
00365 void ungrabGesture(Qt::GestureType type);
00366 #endif
00367
00368 public Q_SLOTS:
00369 void setWindowTitle(const QString &);
00370 #ifndef QT_NO_STYLE_STYLESHEET
00371 void setStyleSheet(const QString& styleSheet);
00372 #endif
00373 public:
00374 #ifndef QT_NO_STYLE_STYLESHEET
00375 QString styleSheet() const;
00376 #endif
00377 QString windowTitle() const;
00378 void setWindowIcon(const QIcon &icon);
00379 QIcon windowIcon() const;
00380 void setWindowIconText(const QString &);
00381 QString windowIconText() const;
00382 void setWindowRole(const QString &);
00383 QString windowRole() const;
00384 void setWindowFilePath(const QString &filePath);
00385 QString windowFilePath() const;
00386
00387 void setWindowOpacity(qreal level);
00388 qreal windowOpacity() const;
00389
00390 bool isWindowModified() const;
00391 #ifndef QT_NO_TOOLTIP
00392 void setToolTip(const QString &);
00393 QString toolTip() const;
00394 #endif
00395 #ifndef QT_NO_STATUSTIP
00396 void setStatusTip(const QString &);
00397 QString statusTip() const;
00398 #endif
00399 #ifndef QT_NO_WHATSTHIS
00400 void setWhatsThis(const QString &);
00401 QString whatsThis() const;
00402 #endif
00403 #ifndef QT_NO_ACCESSIBILITY
00404 QString accessibleName() const;
00405 void setAccessibleName(const QString &name);
00406 QString accessibleDescription() const;
00407 void setAccessibleDescription(const QString &description);
00408 #endif
00409
00410 void setLayoutDirection(Qt::LayoutDirection direction);
00411 Qt::LayoutDirection layoutDirection() const;
00412 void unsetLayoutDirection();
00413
00414 void setLocale(const QLocale &locale);
00415 QLocale locale() const;
00416 void unsetLocale();
00417
00418 inline bool isRightToLeft() const { return layoutDirection() == Qt::RightToLeft; }
00419 inline bool isLeftToRight() const { return layoutDirection() == Qt::LeftToRight; }
00420
00421 public Q_SLOTS:
00422 inline void setFocus() { setFocus(Qt::OtherFocusReason); }
00423
00424 public:
00425 bool isActiveWindow() const;
00426 void activateWindow();
00427 void clearFocus();
00428
00429 void setFocus(Qt::FocusReason reason);
00430 Qt::FocusPolicy focusPolicy() const;
00431 void setFocusPolicy(Qt::FocusPolicy policy);
00432 bool hasFocus() const;
00433 static void setTabOrder(QWidget *, QWidget *);
00434 void setFocusProxy(QWidget *);
00435 QWidget *focusProxy() const;
00436 Qt::ContextMenuPolicy contextMenuPolicy() const;
00437 void setContextMenuPolicy(Qt::ContextMenuPolicy policy);
00438
00439
00440 void grabMouse();
00441 #ifndef QT_NO_CURSOR
00442 void grabMouse(const QCursor &);
00443 #endif
00444 void releaseMouse();
00445 void grabKeyboard();
00446 void releaseKeyboard();
00447 #ifndef QT_NO_SHORTCUT
00448 int grabShortcut(const QKeySequence &key, Qt::ShortcutContext context = Qt::WindowShortcut);
00449 void releaseShortcut(int id);
00450 void setShortcutEnabled(int id, bool enable = true);
00451 void setShortcutAutoRepeat(int id, bool enable = true);
00452 #endif
00453 static QWidget *mouseGrabber();
00454 static QWidget *keyboardGrabber();
00455
00456
00457 inline bool updatesEnabled() const;
00458 void setUpdatesEnabled(bool enable);
00459
00460 #if 0 //def Q_WS_QWS
00461 void repaintUnclipped(const QRegion &, bool erase = true);
00462 #endif
00463
00464 #ifndef QT_NO_GRAPHICSVIEW
00465 QGraphicsProxyWidget *graphicsProxyWidget() const;
00466 #endif
00467
00468 public Q_SLOTS:
00469 void update();
00470 void repaint();
00471
00472 public:
00473 inline void update(int x, int y, int w, int h);
00474 void update(const QRect&);
00475 void update(const QRegion&);
00476
00477 void repaint(int x, int y, int w, int h);
00478 void repaint(const QRect &);
00479 void repaint(const QRegion &);
00480
00481 public Q_SLOTS:
00482
00483
00484 virtual void setVisible(bool visible);
00485 inline void setHidden(bool hidden) { setVisible(!hidden); }
00486 #ifndef Q_WS_WINCE
00487 inline void show() { setVisible(true); }
00488 #else
00489 void show();
00490 #endif
00491 inline void hide() { setVisible(false); }
00492 inline QT_MOC_COMPAT void setShown(bool shown) { setVisible(shown); }
00493
00494 void showMinimized();
00495 void showMaximized();
00496 void showFullScreen();
00497 void showNormal();
00498
00499 bool close();
00500 void raise();
00501 void lower();
00502
00503 public:
00504 void stackUnder(QWidget*);
00505 void move(int x, int y);
00506 void move(const QPoint &);
00507 void resize(int w, int h);
00508 void resize(const QSize &);
00509 inline void setGeometry(int x, int y, int w, int h);
00510 void setGeometry(const QRect &);
00511 QByteArray saveGeometry() const;
00512 bool restoreGeometry(const QByteArray &geometry);
00513 void adjustSize();
00514 bool isVisible() const;
00515 bool isVisibleTo(QWidget*) const;
00516
00517 inline bool isHidden() const;
00518
00519 bool isMinimized() const;
00520 bool isMaximized() const;
00521 bool isFullScreen() const;
00522
00523 Qt::WindowStates windowState() const;
00524 void setWindowState(Qt::WindowStates state);
00525 void overrideWindowState(Qt::WindowStates state);
00526
00527 virtual QSize sizeHint() const;
00528 virtual QSize minimumSizeHint() const;
00529
00530 QSizePolicy sizePolicy() const;
00531 void setSizePolicy(QSizePolicy);
00532 inline void setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical);
00533 virtual int heightForWidth(int) const;
00534
00535 QRegion visibleRegion() const;
00536
00537 void setContentsMargins(int left, int top, int right, int bottom);
00538 void setContentsMargins(const QMargins &margins);
00539 void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
00540 QMargins contentsMargins() const;
00541
00542 QRect contentsRect() const;
00543
00544 public:
00545 QLayout *layout() const;
00546 void setLayout(QLayout *);
00547 void updateGeometry();
00548
00549 void setParent(QWidget *parent);
00550 void setParent(QWidget *parent, Qt::WindowFlags f);
00551
00552 void scroll(int dx, int dy);
00553 void scroll(int dx, int dy, const QRect&);
00554
00555
00556
00557 QWidget *focusWidget() const;
00558 QWidget *nextInFocusChain() const;
00559 QWidget *previousInFocusChain() const;
00560
00561
00562 bool acceptDrops() const;
00563 void setAcceptDrops(bool on);
00564
00565 #ifndef QT_NO_ACTION
00566
00567 void addAction(QAction *action);
00568 void addActions(QList<QAction*> actions);
00569 void insertAction(QAction *before, QAction *action);
00570 void insertActions(QAction *before, QList<QAction*> actions);
00571 void removeAction(QAction *action);
00572 QList<QAction*> actions() const;
00573 #endif
00574
00575 QWidget *parentWidget() const;
00576
00577 void setWindowFlags(Qt::WindowFlags type);
00578 inline Qt::WindowFlags windowFlags() const;
00579 void overrideWindowFlags(Qt::WindowFlags type);
00580
00581 inline Qt::WindowType windowType() const;
00582
00583 static QWidget *find(WId);
00584 #ifdef QT3_SUPPORT
00585 static QT3_SUPPORT QWidgetMapper *wmapper();
00586 #endif
00587 inline QWidget *childAt(int x, int y) const;
00588 QWidget *childAt(const QPoint &p) const;
00589
00590 #if defined(Q_WS_X11)
00591 const QX11Info &x11Info() const;
00592 Qt::HANDLE x11PictureHandle() const;
00593 #endif
00594
00595 #if defined(Q_WS_MAC)
00596 Qt::HANDLE macQDHandle() const;
00597 Qt::HANDLE macCGHandle() const;
00598 #endif
00599
00600 #if defined(Q_WS_WIN)
00601 HDC getDC() const;
00602 void releaseDC(HDC) const;
00603 #else
00604 Qt::HANDLE handle() const;
00605 #endif
00606
00607 void setAttribute(Qt::WidgetAttribute, bool on = true);
00608 inline bool testAttribute(Qt::WidgetAttribute) const;
00609
00610 QPaintEngine *paintEngine() const;
00611
00612 void ensurePolished() const;
00613
00614 QInputContext *inputContext();
00615 void setInputContext(QInputContext *);
00616
00617 bool isAncestorOf(const QWidget *child) const;
00618
00619 #ifdef QT_KEYPAD_NAVIGATION
00620 bool hasEditFocus() const;
00621 void setEditFocus(bool on);
00622 #endif
00623
00624 bool autoFillBackground() const;
00625 void setAutoFillBackground(bool enabled);
00626
00627 void setWindowSurface(QWindowSurface *surface);
00628 QWindowSurface *windowSurface() const;
00629
00630 Q_SIGNALS:
00631 void customContextMenuRequested(const QPoint &pos);
00632
00633 protected:
00634
00635 bool event(QEvent *);
00636 virtual void mousePressEvent(QMouseEvent *);
00637 virtual void mouseReleaseEvent(QMouseEvent *);
00638 virtual void mouseDoubleClickEvent(QMouseEvent *);
00639 virtual void mouseMoveEvent(QMouseEvent *);
00640 #ifndef QT_NO_WHEELEVENT
00641 virtual void wheelEvent(QWheelEvent *);
00642 #endif
00643 virtual void keyPressEvent(QKeyEvent *);
00644 virtual void keyReleaseEvent(QKeyEvent *);
00645 virtual void focusInEvent(QFocusEvent *);
00646 virtual void focusOutEvent(QFocusEvent *);
00647 virtual void enterEvent(QEvent *);
00648 virtual void leaveEvent(QEvent *);
00649 virtual void paintEvent(QPaintEvent *);
00650 virtual void moveEvent(QMoveEvent *);
00651 virtual void resizeEvent(QResizeEvent *);
00652 virtual void closeEvent(QCloseEvent *);
00653 #ifndef QT_NO_CONTEXTMENU
00654 virtual void contextMenuEvent(QContextMenuEvent *);
00655 #endif
00656 #ifndef QT_NO_TABLETEVENT
00657 virtual void tabletEvent(QTabletEvent *);
00658 #endif
00659 #ifndef QT_NO_ACTION
00660 virtual void actionEvent(QActionEvent *);
00661 #endif
00662
00663 #ifndef QT_NO_DRAGANDDROP
00664 virtual void dragEnterEvent(QDragEnterEvent *);
00665 virtual void dragMoveEvent(QDragMoveEvent *);
00666 virtual void dragLeaveEvent(QDragLeaveEvent *);
00667 virtual void dropEvent(QDropEvent *);
00668 #endif
00669
00670 virtual void showEvent(QShowEvent *);
00671 virtual void hideEvent(QHideEvent *);
00672
00673 #if defined(Q_WS_MAC)
00674 virtual bool macEvent(EventHandlerCallRef, EventRef);
00675 #endif
00676 #if defined(Q_WS_WIN)
00677 virtual bool winEvent(MSG *message, long *result);
00678 #endif
00679 #if defined(Q_WS_X11)
00680 virtual bool x11Event(XEvent *);
00681 #endif
00682 #if defined(Q_WS_QWS)
00683 virtual bool qwsEvent(QWSEvent *);
00684 #endif
00685
00686
00687 virtual void changeEvent(QEvent *);
00688
00689 int metric(PaintDeviceMetric) const;
00690
00691 virtual void inputMethodEvent(QInputMethodEvent *);
00692 public:
00693 virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const;
00694
00695 Qt::InputMethodHints inputMethodHints() const;
00696 void setInputMethodHints(Qt::InputMethodHints hints);
00697
00698 protected:
00699 void resetInputContext();
00700 protected Q_SLOTS:
00701 void updateMicroFocus();
00702 protected:
00703
00704 void create(WId = 0, bool initializeWindow = true,
00705 bool destroyOldWindow = true);
00706 void destroy(bool destroyWindow = true,
00707 bool destroySubWindows = true);
00708
00709 virtual bool focusNextPrevChild(bool next);
00710 inline bool focusNextChild() { return focusNextPrevChild(true); }
00711 inline bool focusPreviousChild() { return focusNextPrevChild(false); }
00712
00713 protected:
00714 QWidget(QWidgetPrivate &d, QWidget* parent, Qt::WindowFlags f);
00715 private:
00716
00717 bool testAttribute_helper(Qt::WidgetAttribute) const;
00718
00719 QLayout *takeLayout();
00720
00721 friend class QBackingStoreDevice;
00722 friend class QWidgetBackingStore;
00723 friend class QApplication;
00724 friend class QApplicationPrivate;
00725 friend class QBaseApplication;
00726 friend class QPainter;
00727 friend class QPainterPrivate;
00728 friend class QPixmap;
00729 friend class QFontMetrics;
00730 friend class QFontInfo;
00731 friend class QETWidget;
00732 friend class QLayout;
00733 friend class QWidgetItem;
00734 friend class QWidgetItemV2;
00735 friend class QGLContext;
00736 friend class QGLWidget;
00737 friend class QGLWindowSurface;
00738 friend class QX11PaintEngine;
00739 friend class QWin32PaintEngine;
00740 friend class QShortcutPrivate;
00741 friend class QShortcutMap;
00742 friend class QWindowSurface;
00743 friend class QGraphicsProxyWidget;
00744 friend class QGraphicsProxyWidgetPrivate;
00745 friend class QStyleSheetStyle;
00746 friend struct QWidgetExceptionCleaner;
00747 #ifndef QT_NO_GESTURES
00748 friend class QGestureManager;
00749 friend class QWinNativePanGestureRecognizer;
00750 #endif // QT_NO_GESTURES
00751 friend class QWidgetEffectSourcePrivate;
00752
00753 #ifdef Q_WS_MAC
00754 friend class QCoreGraphicsPaintEnginePrivate;
00755 friend QPoint qt_mac_posInWindow(const QWidget *w);
00756 friend OSWindowRef qt_mac_window_for(const QWidget *w);
00757 friend bool qt_mac_is_metal(const QWidget *w);
00758 friend OSViewRef qt_mac_nativeview_for(const QWidget *w);
00759 friend void qt_event_request_window_change(QWidget *widget);
00760 friend bool qt_mac_sendMacEventToWidget(QWidget *widget, EventRef ref);
00761 #endif
00762 #ifdef Q_WS_QWS
00763 friend class QWSBackingStore;
00764 friend class QWSManager;
00765 friend class QWSManagerPrivate;
00766 friend class QDecoration;
00767 friend class QWSWindowSurface;
00768 friend class QScreen;
00769 friend class QVNCScreen;
00770 friend bool isWidgetOpaque(const QWidget *);
00771 friend class QGLWidgetPrivate;
00772 #endif
00773 #ifdef Q_OS_SYMBIAN
00774 friend class QSymbianControl;
00775 friend class QS60WindowSurface;
00776 #endif
00777 #ifdef Q_WS_X11
00778 friend void qt_net_update_user_time(QWidget *tlw, unsigned long timestamp);
00779 friend void qt_net_remove_user_time(QWidget *tlw);
00780 friend void qt_set_winid_on_widget(QWidget*, Qt::HANDLE);
00781 #endif
00782
00783 friend Q_GUI_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget);
00784 friend Q_GUI_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget);
00785
00786 private:
00787 Q_DISABLE_COPY(QWidget)
00788 Q_PRIVATE_SLOT(d_func(), void _q_showIfNotHidden())
00789 #ifdef Q_OS_SYMBIAN
00790 Q_PRIVATE_SLOT(d_func(), void _q_delayedDestroy(WId winId))
00791 #endif
00792
00793 QWidgetData *data;
00794
00795 #ifdef QT3_SUPPORT
00796 public:
00797 inline QT3_SUPPORT bool isUpdatesEnabled() const { return updatesEnabled(); }
00798 QT3_SUPPORT QStyle *setStyle(const QString&);
00799 inline QT3_SUPPORT bool isVisibleToTLW() const;
00800 QT3_SUPPORT QRect visibleRect() const;
00801 inline QT3_SUPPORT void iconify() { showMinimized(); }
00802 inline QT3_SUPPORT void constPolish() const { ensurePolished(); }
00803 inline QT3_SUPPORT void polish() { ensurePolished(); }
00804 inline QT3_SUPPORT void reparent(QWidget *parent, Qt::WindowFlags f, const QPoint &p, bool showIt=false)
00805 { setParent(parent, f); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
00806 inline QT3_SUPPORT void reparent(QWidget *parent, const QPoint &p, bool showIt=false)
00807 { setParent(parent, windowFlags() & ~Qt::WindowType_Mask); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
00808 inline QT3_SUPPORT void recreate(QWidget *parent, Qt::WindowFlags f, const QPoint & p, bool showIt=false)
00809 { setParent(parent, f); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
00810 inline QT3_SUPPORT void setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw)
00811 { QSizePolicy sp(hor, ver); sp.setHeightForWidth(hfw); setSizePolicy(sp);}
00812 inline QT3_SUPPORT bool hasMouse() const { return testAttribute(Qt::WA_UnderMouse); }
00813 #ifndef QT_NO_CURSOR
00814 inline QT3_SUPPORT bool ownCursor() const { return testAttribute(Qt::WA_SetCursor); }
00815 #endif
00816 inline QT3_SUPPORT bool ownFont() const { return testAttribute(Qt::WA_SetFont); }
00817 inline QT3_SUPPORT void unsetFont() { setFont(QFont()); }
00818 inline QT3_SUPPORT bool ownPalette() const { return testAttribute(Qt::WA_SetPalette); }
00819 inline QT3_SUPPORT void unsetPalette() { setPalette(QPalette()); }
00820 Qt::BackgroundMode QT3_SUPPORT backgroundMode() const;
00821 void QT3_SUPPORT setBackgroundMode(Qt::BackgroundMode, Qt::BackgroundMode = Qt::PaletteBackground);
00822 const QT3_SUPPORT QColor &eraseColor() const;
00823 void QT3_SUPPORT setEraseColor(const QColor &);
00824 const QT3_SUPPORT QColor &foregroundColor() const;
00825 const QT3_SUPPORT QPixmap *erasePixmap() const;
00826 void QT3_SUPPORT setErasePixmap(const QPixmap &);
00827 const QT3_SUPPORT QColor &paletteForegroundColor() const;
00828 void QT3_SUPPORT setPaletteForegroundColor(const QColor &);
00829 const QT3_SUPPORT QColor &paletteBackgroundColor() const;
00830 void QT3_SUPPORT setPaletteBackgroundColor(const QColor &);
00831 const QT3_SUPPORT QPixmap *paletteBackgroundPixmap() const;
00832 void QT3_SUPPORT setPaletteBackgroundPixmap(const QPixmap &);
00833 const QT3_SUPPORT QBrush& backgroundBrush() const;
00834 const QT3_SUPPORT QColor &backgroundColor() const;
00835 const QT3_SUPPORT QPixmap *backgroundPixmap() const;
00836 void QT3_SUPPORT setBackgroundPixmap(const QPixmap &);
00837 QT3_SUPPORT void setBackgroundColor(const QColor &);
00838 QT3_SUPPORT QColorGroup colorGroup() const;
00839 QT3_SUPPORT QWidget *parentWidget(bool sameWindow) const;
00840 inline QT3_SUPPORT void setKeyCompression(bool b) { setAttribute(Qt::WA_KeyCompression, b); }
00841 inline QT3_SUPPORT void setFont(const QFont &f, bool) { setFont(f); }
00842 inline QT3_SUPPORT void setPalette(const QPalette &p, bool) { setPalette(p); }
00843 enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin };
00844 inline QT3_SUPPORT void setBackgroundOrigin(BackgroundOrigin) {}
00845 inline QT3_SUPPORT BackgroundOrigin backgroundOrigin() const { return WindowOrigin; }
00846 inline QT3_SUPPORT QPoint backgroundOffset() const { return QPoint(); }
00847 inline QT3_SUPPORT void repaint(bool) { repaint(); }
00848 inline QT3_SUPPORT void repaint(int x, int y, int w, int h, bool) { repaint(x,y,w,h); }
00849 inline QT3_SUPPORT void repaint(const QRect &r, bool) { repaint(r); }
00850 inline QT3_SUPPORT void repaint(const QRegion &rgn, bool) { repaint(rgn); }
00851 QT3_SUPPORT void erase();
00852 inline QT3_SUPPORT void erase(int x, int y, int w, int h) { erase_helper(x, y, w, h); }
00853 QT3_SUPPORT void erase(const QRect &);
00854 QT3_SUPPORT void erase(const QRegion &);
00855 QT3_SUPPORT void drawText(const QPoint &p, const QString &s)
00856 { drawText_helper(p.x(), p.y(), s); }
00857 inline QT3_SUPPORT void drawText(int x, int y, const QString &s)
00858 { drawText_helper(x, y, s); }
00859 QT3_SUPPORT bool close(bool);
00860 inline QT3_SUPPORT QWidget *childAt(int x, int y, bool includeThis) const
00861 {
00862 QWidget *w = childAt(x, y);
00863 return w ? w : ((includeThis && rect().contains(x,y))?const_cast<QWidget*>(this):0);
00864 }
00865 inline QT3_SUPPORT QWidget *childAt(const QPoint &p, bool includeThis) const
00866 {
00867 QWidget *w = childAt(p);
00868 return w ? w : ((includeThis && rect().contains(p))?const_cast<QWidget*>(this):0);
00869 }
00870 inline QT3_SUPPORT void setCaption(const QString &c) { setWindowTitle(c); }
00871 QT3_SUPPORT void setIcon(const QPixmap &i);
00872 inline QT3_SUPPORT void setIconText(const QString &it) { setWindowIconText(it); }
00873 inline QT3_SUPPORT QString caption() const { return windowTitle(); }
00874 QT3_SUPPORT const QPixmap *icon() const;
00875 inline QT3_SUPPORT QString iconText() const { return windowIconText(); }
00876 inline QT3_SUPPORT void setInputMethodEnabled(bool b) { setAttribute(Qt::WA_InputMethodEnabled, b); }
00877 inline QT3_SUPPORT bool isInputMethodEnabled() const { return testAttribute(Qt::WA_InputMethodEnabled); }
00878 inline QT3_SUPPORT void setActiveWindow() { activateWindow(); }
00879 inline QT3_SUPPORT bool isShown() const { return !isHidden(); }
00880 inline QT3_SUPPORT bool isDialog() const { return windowType() == Qt::Dialog; }
00881 inline QT3_SUPPORT bool isPopup() const { return windowType() == Qt::Popup; }
00882 inline QT3_SUPPORT bool isDesktop() const { return windowType() == Qt::Desktop; }
00883
00884
00885 private:
00886 void drawText_helper(int x, int y, const QString &);
00887 void erase_helper(int x, int y, int w, int h);
00888 #endif // QT3_SUPPORT
00889
00890 protected:
00891 virtual void styleChange(QStyle&);
00892 virtual void enabledChange(bool);
00893 virtual void paletteChange(const QPalette &);
00894 virtual void fontChange(const QFont &);
00895 virtual void windowActivationChange(bool);
00896 virtual void languageChange();
00897 };
00898
00899 Q_DECLARE_OPERATORS_FOR_FLAGS(QWidget::RenderFlags)
00900
00901 #if defined Q_CC_MSVC && _MSC_VER < 1300
00902 template <> inline QWidget *qobject_cast_helper<QWidget*>(QObject *o, QWidget *)
00903 {
00904 if (!o || !o->isWidgetType()) return 0;
00905 return (QWidget*)(o);
00906 }
00907 #else
00908 template <> inline QWidget *qobject_cast<QWidget*>(QObject *o)
00909 {
00910 if (!o || !o->isWidgetType()) return 0;
00911 return static_cast<QWidget*>(o);
00912 }
00913 template <> inline const QWidget *qobject_cast<const QWidget*>(const QObject *o)
00914 {
00915 if (!o || !o->isWidgetType()) return 0;
00916 return static_cast<const QWidget*>(o);
00917 }
00918 #endif
00919
00920 inline QWidget *QWidget::childAt(int ax, int ay) const
00921 { return childAt(QPoint(ax, ay)); }
00922
00923 inline Qt::WindowType QWidget::windowType() const
00924 { return static_cast<Qt::WindowType>(int(data->window_flags & Qt::WindowType_Mask)); }
00925 inline Qt::WindowFlags QWidget::windowFlags() const
00926 { return data->window_flags; }
00927
00928 inline bool QWidget::isTopLevel() const
00929 { return (windowType() & Qt::Window); }
00930
00931 inline bool QWidget::isWindow() const
00932 { return (windowType() & Qt::Window); }
00933
00934 inline bool QWidget::isEnabled() const
00935 { return !testAttribute(Qt::WA_Disabled); }
00936
00937 inline bool QWidget::isModal() const
00938 { return data->window_modality != Qt::NonModal; }
00939
00940 inline bool QWidget::isEnabledToTLW() const
00941 { return isEnabled(); }
00942
00943 inline int QWidget::minimumWidth() const
00944 { return minimumSize().width(); }
00945
00946 inline int QWidget::minimumHeight() const
00947 { return minimumSize().height(); }
00948
00949 inline int QWidget::maximumWidth() const
00950 { return maximumSize().width(); }
00951
00952 inline int QWidget::maximumHeight() const
00953 { return maximumSize().height(); }
00954
00955 inline void QWidget::setMinimumSize(const QSize &s)
00956 { setMinimumSize(s.width(),s.height()); }
00957
00958 inline void QWidget::setMaximumSize(const QSize &s)
00959 { setMaximumSize(s.width(),s.height()); }
00960
00961 inline void QWidget::setSizeIncrement(const QSize &s)
00962 { setSizeIncrement(s.width(),s.height()); }
00963
00964 inline void QWidget::setBaseSize(const QSize &s)
00965 { setBaseSize(s.width(),s.height()); }
00966
00967 inline const QFont &QWidget::font() const
00968 { return data->fnt; }
00969
00970 inline QFontMetrics QWidget::fontMetrics() const
00971 { return QFontMetrics(data->fnt); }
00972
00973 inline QFontInfo QWidget::fontInfo() const
00974 { return QFontInfo(data->fnt); }
00975
00976 inline void QWidget::setMouseTracking(bool enable)
00977 { setAttribute(Qt::WA_MouseTracking, enable); }
00978
00979 inline bool QWidget::hasMouseTracking() const
00980 { return testAttribute(Qt::WA_MouseTracking); }
00981
00982 inline bool QWidget::underMouse() const
00983 { return testAttribute(Qt::WA_UnderMouse); }
00984
00985 inline bool QWidget::updatesEnabled() const
00986 { return !testAttribute(Qt::WA_UpdatesDisabled); }
00987
00988 inline void QWidget::update(int ax, int ay, int aw, int ah)
00989 { update(QRect(ax, ay, aw, ah)); }
00990
00991 inline bool QWidget::isVisible() const
00992 { return testAttribute(Qt::WA_WState_Visible); }
00993
00994 inline bool QWidget::isHidden() const
00995 { return testAttribute(Qt::WA_WState_Hidden); }
00996
00997 inline void QWidget::move(int ax, int ay)
00998 { move(QPoint(ax, ay)); }
00999
01000 inline void QWidget::resize(int w, int h)
01001 { resize(QSize(w, h)); }
01002
01003 inline void QWidget::setGeometry(int ax, int ay, int aw, int ah)
01004 { setGeometry(QRect(ax, ay, aw, ah)); }
01005
01006 inline QRect QWidget::rect() const
01007 { return QRect(0,0,data->crect.width(),data->crect.height()); }
01008
01009 inline const QRect &QWidget::geometry() const
01010 { return data->crect; }
01011
01012 inline QSize QWidget::size() const
01013 { return data->crect.size(); }
01014
01015 inline int QWidget::width() const
01016 { return data->crect.width(); }
01017
01018 inline int QWidget::height() const
01019 { return data->crect.height(); }
01020
01021 inline QWidget *QWidget::parentWidget() const
01022 { return static_cast<QWidget *>(QObject::parent()); }
01023
01024 inline void QWidget::setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver)
01025 { setSizePolicy(QSizePolicy(hor, ver)); }
01026
01027 inline bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const
01028 {
01029 if (attribute < int(8*sizeof(uint)))
01030 return data->widget_attributes & (1<<attribute);
01031 return testAttribute_helper(attribute);
01032 }
01033
01034 #ifdef QT3_SUPPORT
01035 inline bool QWidget::isVisibleToTLW() const
01036 { return isVisible(); }
01037 inline QWidget *QWidget::parentWidget(bool sameWindow) const
01038 {
01039 if (sameWindow && isWindow())
01040 return 0;
01041 return static_cast<QWidget *>(QObject::parent());
01042 }
01043 inline QColorGroup QWidget::colorGroup() const
01044 { return QColorGroup(palette()); }
01045 inline void QWidget::setPaletteForegroundColor(const QColor &c)
01046 { QPalette p = palette(); p.setColor(foregroundRole(), c); setPalette(p); }
01047 inline const QBrush& QWidget::backgroundBrush() const { return palette().brush(backgroundRole()); }
01048 inline void QWidget::setBackgroundPixmap(const QPixmap &pm)
01049 { QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
01050 inline const QPixmap *QWidget::backgroundPixmap() const { return 0; }
01051 inline void QWidget::setBackgroundColor(const QColor &c)
01052 { QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
01053 inline const QColor & QWidget::backgroundColor() const { return palette().color(backgroundRole()); }
01054 inline const QColor &QWidget::foregroundColor() const { return palette().color(foregroundRole());}
01055 inline const QColor &QWidget::eraseColor() const { return palette().color(backgroundRole()); }
01056 inline void QWidget::setEraseColor(const QColor &c)
01057 { QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
01058 inline const QPixmap *QWidget::erasePixmap() const { return 0; }
01059 inline void QWidget::setErasePixmap(const QPixmap &pm)
01060 { QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
01061 inline const QColor &QWidget::paletteForegroundColor() const { return palette().color(foregroundRole());}
01062 inline const QColor &QWidget::paletteBackgroundColor() const { return palette().color(backgroundRole()); }
01063 inline void QWidget::setPaletteBackgroundColor(const QColor &c)
01064 { QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
01065 inline const QPixmap *QWidget::paletteBackgroundPixmap() const
01066 { return 0; }
01067 inline void QWidget::setPaletteBackgroundPixmap(const QPixmap &pm)
01068 { QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
01069 inline QT3_SUPPORT void QWidget::erase() { erase_helper(0, 0, data->crect.width(), data->crect.height()); }
01070 inline QT3_SUPPORT void QWidget::erase(const QRect &r) { erase_helper(r.x(), r.y(), r.width(), r.height()); }
01071 #endif
01072
01073 #define QWIDGETSIZE_MAX ((1<<24)-1)
01074
01075 QT_END_NAMESPACE
01076
01077 QT_END_HEADER
01078
01079 #endif // QWIDGET_H