1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the gui module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
32
#include "QtGui/qwindowdefs.h"
33
#include "QtCore/qobject.h"
34
#include "QtGui/qpaintdevice.h"
35
#include "QtGui/qpalette.h"
36
#include "QtGui/qfont.h"
37
#include "QtGui/qfontmetrics.h"
38
#include "QtGui/qfontinfo.h"
39
#include "QtGui/qsizepolicy.h"
40
#include "QtGui/qregion.h"
41
#include "QtGui/qbrush.h"
42
#include "QtGui/qcursor.h"
43
#include "QtGui/qkeysequence.h"
45
#ifdef QT_INCLUDE_COMPAT
46
#include "QtGui/qevent.h"
50
class QWSRegionManager;
65
class QContextMenuEvent;
66
class QInputMethodEvent;
68
class QDragEnterEvent;
70
class QDragLeaveEvent;
84
uint widget_attributes;
85
Qt::WindowFlags window_flags;
86
uint window_state : 4;
87
uint focus_policy : 4;
88
uint sizehint_forced :1;
91
uint in_set_window_state : 1;
92
mutable uint fstrut_dirty : 1;
93
uint context_menu_policy : 3;
99
// QRegion req_region; // Requested region
100
// mutable QRegion paintable_region; // Paintable region
101
// mutable bool paintable_region_dirty;// needs to be recalculated
102
// mutable QRegion alloc_region; // Allocated region
103
// mutable bool alloc_region_dirty; // needs to be recalculated
104
// mutable int overlapping_children; // Handle overlapping children
106
int alloc_region_index;
107
// int alloc_region_revision;
112
class QWidgetPrivate;
114
class Q_GUI_EXPORT QWidget : public QObject, public QPaintDevice
117
Q_DECLARE_PRIVATE(QWidget)
119
Q_PROPERTY(bool modal READ isModal)
120
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
121
Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
122
Q_PROPERTY(QRect frameGeometry READ frameGeometry)
123
Q_PROPERTY(QRect normalGeometry READ normalGeometry)
124
Q_PROPERTY(int x READ x)
125
Q_PROPERTY(int y READ y)
126
Q_PROPERTY(QPoint pos READ pos WRITE move DESIGNABLE false STORED false)
127
Q_PROPERTY(QSize frameSize READ frameSize)
128
Q_PROPERTY(QSize size READ size WRITE resize DESIGNABLE false STORED false)
129
Q_PROPERTY(int width READ width)
130
Q_PROPERTY(int height READ height)
131
Q_PROPERTY(QRect rect READ rect)
132
Q_PROPERTY(QRect childrenRect READ childrenRect)
133
Q_PROPERTY(QRegion childrenRegion READ childrenRegion)
134
Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy)
135
Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)
136
Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)
137
Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false DESIGNABLE false)
138
Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false DESIGNABLE false)
139
Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false DESIGNABLE false)
140
Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false DESIGNABLE false)
141
Q_PROPERTY(QSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement)
142
Q_PROPERTY(QSize baseSize READ baseSize WRITE setBaseSize)
143
Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
144
Q_PROPERTY(QFont font READ font WRITE setFont)
146
Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor)
148
Q_PROPERTY(bool mouseTracking READ hasMouseTracking WRITE setMouseTracking)
149
Q_PROPERTY(bool isActiveWindow READ isActiveWindow)
150
Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy)
151
Q_PROPERTY(bool focus READ hasFocus)
152
Q_PROPERTY(Qt::ContextMenuPolicy contextMenuPolicy READ contextMenuPolicy WRITE setContextMenuPolicy)
153
Q_PROPERTY(bool updatesEnabled READ updatesEnabled WRITE setUpdatesEnabled DESIGNABLE false)
154
Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
155
Q_PROPERTY(bool minimized READ isMinimized)
156
Q_PROPERTY(bool maximized READ isMaximized)
157
Q_PROPERTY(bool fullScreen READ isFullScreen)
158
Q_PROPERTY(QSize sizeHint READ sizeHint)
159
Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint)
160
Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops)
161
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE isWindow)
162
Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon DESIGNABLE isWindow)
163
Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText DESIGNABLE isWindow)
164
Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE false)
165
Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow)
166
Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
167
Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip)
168
Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)
169
#ifndef QT_NO_ACCESSIBILITY
170
Q_PROPERTY(QString accessibleName READ accessibleName WRITE setAccessibleName)
171
Q_PROPERTY(QString accessibleDescription READ accessibleDescription WRITE setAccessibleDescription)
173
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection)
174
QDOC_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)
178
explicit QWidget(QWidget* parent = 0, Qt::WFlags f = 0);
180
QT3_SUPPORT_CONSTRUCTOR QWidget(QWidget* parent, const char *name, Qt::WFlags f = 0);
189
QStyle *style() const;
190
void setStyle(QStyle *);
192
// Widget types and states
194
bool isTopLevel() const;
195
bool isWindow() const;
197
bool isModal() const;
199
bool isEnabled() const;
200
bool isEnabledTo(QWidget*) const;
201
bool isEnabledToTLW() const;
204
void setEnabled(bool);
205
void setDisabled(bool);
206
void setWindowModified(bool);
208
// Widget coordinates
211
QRect frameGeometry() const;
212
const QRect &geometry() const;
213
QRect normalGeometry() const;
218
QSize frameSize() const;
220
inline int width() const;
221
inline int height() const;
222
inline QRect rect() const;
223
QRect childrenRect() const;
224
QRegion childrenRegion() const;
226
QSize minimumSize() const;
227
QSize maximumSize() const;
228
int minimumWidth() const;
229
int minimumHeight() const;
230
int maximumWidth() const;
231
int maximumHeight() const;
232
void setMinimumSize(const QSize &);
233
void setMinimumSize(int minw, int minh);
234
void setMaximumSize(const QSize &);
235
void setMaximumSize(int maxw, int maxh);
236
void setMinimumWidth(int minw);
237
void setMinimumHeight(int minh);
238
void setMaximumWidth(int maxw);
239
void setMaximumHeight(int maxh);
241
QSize sizeIncrement() const;
242
void setSizeIncrement(const QSize &);
243
void setSizeIncrement(int w, int h);
244
QSize baseSize() const;
245
void setBaseSize(const QSize &);
246
void setBaseSize(int basew, int baseh);
248
void setFixedSize(const QSize &);
249
void setFixedSize(int w, int h);
250
void setFixedWidth(int w);
251
void setFixedHeight(int h);
253
// Widget coordinate mapping
255
QPoint mapToGlobal(const QPoint &) const;
256
QPoint mapFromGlobal(const QPoint &) const;
257
QPoint mapToParent(const QPoint &) const;
258
QPoint mapFromParent(const QPoint &) const;
259
QPoint mapTo(QWidget *, const QPoint &) const;
260
QPoint mapFrom(QWidget *, const QPoint &) const;
262
QWidget *window() const;
263
inline QWidget *topLevelWidget() const { return window(); }
265
// Widget appearance functions
266
const QPalette &palette() const;
267
void setPalette(const QPalette &);
269
void setBackgroundRole(QPalette::ColorRole);
270
QPalette::ColorRole backgroundRole() const;
272
void setForegroundRole(QPalette::ColorRole);
273
QPalette::ColorRole foregroundRole() const;
275
const QFont &font() const;
276
void setFont(const QFont &);
277
QFontMetrics fontMetrics() const;
278
QFontInfo fontInfo() const;
281
QCursor cursor() const;
282
void setCursor(const QCursor &);
286
void setMouseTracking(bool enable);
287
bool hasMouseTracking() const;
288
bool underMouse() const;
290
void setMask(const QBitmap &);
291
void setMask(const QRegion &);
292
QRegion mask() const;
295
void setWindowTitle(const QString &);
296
QString windowTitle() const;
297
void setWindowIcon(const QIcon &icon);
298
QIcon windowIcon() const;
299
void setWindowIconText(const QString &);
300
QString windowIconText() const;
301
void setWindowRole(const QString &);
302
QString windowRole() const;
304
void setWindowOpacity(qreal level);
305
qreal windowOpacity() const;
307
bool isWindowModified() const;
309
void setToolTip(const QString &);
310
QString toolTip() const;
312
void setStatusTip(const QString &);
313
QString statusTip() const;
315
void setWhatsThis(const QString &);
316
QString whatsThis() const;
318
#ifndef QT_NO_ACCESSIBILITY
319
QString accessibleName() const;
320
void setAccessibleName(const QString &name);
321
QString accessibleDescription() const;
322
void setAccessibleDescription(const QString &description);
325
void setLayoutDirection(Qt::LayoutDirection direction);
326
Qt::LayoutDirection layoutDirection() const;
327
void unsetLayoutDirection();
329
inline bool isRightToLeft() const { return layoutDirection() == Qt::RightToLeft; }
330
inline bool isLeftToRight() const { return layoutDirection() == Qt::LeftToRight; }
333
inline void setFocus() { setFocus(Qt::OtherFocusReason); }
336
bool isActiveWindow() const;
337
void activateWindow();
340
void setFocus(Qt::FocusReason reason);
341
Qt::FocusPolicy focusPolicy() const;
342
void setFocusPolicy(Qt::FocusPolicy policy);
343
bool hasFocus() const;
344
static void setTabOrder(QWidget *, QWidget *);
345
void setFocusProxy(QWidget *);
346
QWidget *focusProxy() const;
347
Qt::ContextMenuPolicy contextMenuPolicy() const;
348
void setContextMenuPolicy(Qt::ContextMenuPolicy policy);
353
void grabMouse(const QCursor &);
357
void releaseKeyboard();
358
int grabShortcut(const QKeySequence &key, Qt::ShortcutContext context = Qt::WindowShortcut);
359
void releaseShortcut(int id);
360
void setShortcutEnabled(int id, bool enable = true);
361
static QWidget *mouseGrabber();
362
static QWidget *keyboardGrabber();
364
// Update/refresh functions
365
inline bool updatesEnabled() const;
366
void setUpdatesEnabled(bool enable);
369
void repaintUnclipped(const QRegion &, bool erase = true);
377
inline void update(int x, int y, int w, int h);
378
void update(const QRect&);
379
void update(const QRegion&);
381
void repaint(int x, int y, int w, int h);
382
void repaint(const QRect &);
383
void repaint(const QRegion &);
386
// Widget management functions
388
virtual void setVisible(bool visible);
389
inline void setHidden(bool hidden) { setVisible(!hidden); }
390
inline void show() { setVisible(true); }
391
inline void hide() { setVisible(false); }
392
inline QT_MOC_COMPAT void setShown(bool shown) { setVisible(shown); }
394
void showMinimized();
395
void showMaximized();
396
void showFullScreen();
404
void stackUnder(QWidget*);
405
void move(int x, int y);
406
void move(const QPoint &);
407
void resize(int w, int h);
408
void resize(const QSize &);
409
inline void setGeometry(int x, int y, int w, int h);
410
void setGeometry(const QRect &);
412
bool isVisible() const;
413
bool isVisibleTo(QWidget*) const;
414
inline bool isHidden() const;
416
bool isMinimized() const;
417
bool isMaximized() const;
418
bool isFullScreen() const;
420
Qt::WindowStates windowState() const;
421
void setWindowState(Qt::WindowStates state);
422
void overrideWindowState(Qt::WindowStates state);
424
virtual QSize sizeHint() const;
425
virtual QSize minimumSizeHint() const;
427
QSizePolicy sizePolicy() const;
428
void setSizePolicy(QSizePolicy);
429
inline void setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical);
430
virtual int heightForWidth(int) const;
432
QRegion visibleRegion() const;
434
void setContentsMargins(int left, int top, int right, int bottom);
435
void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
436
QRect contentsRect() const;
440
QLayout *layout() const;
441
void setLayout(QLayout *);
443
void updateGeometry();
445
void setParent(QWidget *parent);
446
void setParent(QWidget *parent, Qt::WFlags f);
448
void scroll(int dx, int dy);
449
void scroll(int dx, int dy, const QRect&);
453
QWidget *focusWidget() const;
454
QWidget *nextInFocusChain() const;
457
bool acceptDrops() const;
458
void setAcceptDrops(bool on);
461
void addAction(QAction *action);
462
void addActions(QList<QAction*> actions);
463
void insertAction(QAction *before, QAction *action);
464
void insertActions(QAction *before, QList<QAction*> actions);
465
void removeAction(QAction *action);
466
QList<QAction*> actions() const;
468
QWidget *parentWidget() const;
470
void setWindowFlags(Qt::WindowFlags type);
471
inline Qt::WindowFlags windowFlags() const;
472
void overrideWindowFlags(Qt::WindowFlags type);
474
inline Qt::WindowType windowType() const;
476
static QWidget *find(WId);
478
static QT3_SUPPORT QWidgetMapper *wmapper();
480
inline QWidget *childAt(int x, int y) const;
481
QWidget *childAt(const QPoint &p) const;
483
#if defined(Q_WS_X11)
484
const QX11Info &x11Info() const;
485
Qt::HANDLE x11PictureHandle() const;
488
#if defined(Q_WS_WIN)
490
void releaseDC(HDC) const;
492
Qt::HANDLE handle() const;
495
void setAttribute(Qt::WidgetAttribute, bool on = true);
496
inline bool testAttribute(Qt::WidgetAttribute) const;
498
QPaintEngine *paintEngine() const;
500
void ensurePolished() const;
502
QInputContext *inputContext();
503
void setInputContext(QInputContext *);
505
bool isAncestorOf(const QWidget *child) const;
508
void customContextMenuRequested(const QPoint &pos);
512
bool event(QEvent *);
513
virtual void mousePressEvent(QMouseEvent *);
514
virtual void mouseReleaseEvent(QMouseEvent *);
515
virtual void mouseDoubleClickEvent(QMouseEvent *);
516
virtual void mouseMoveEvent(QMouseEvent *);
517
#ifndef QT_NO_WHEELEVENT
518
virtual void wheelEvent(QWheelEvent *);
520
virtual void keyPressEvent(QKeyEvent *);
521
virtual void keyReleaseEvent(QKeyEvent *);
522
virtual void focusInEvent(QFocusEvent *);
523
virtual void focusOutEvent(QFocusEvent *);
524
virtual void enterEvent(QEvent *);
525
virtual void leaveEvent(QEvent *);
526
virtual void paintEvent(QPaintEvent *);
527
virtual void moveEvent(QMoveEvent *);
528
virtual void resizeEvent(QResizeEvent *);
529
virtual void closeEvent(QCloseEvent *);
530
virtual void contextMenuEvent(QContextMenuEvent *);
531
virtual void tabletEvent(QTabletEvent *);
532
virtual void actionEvent(QActionEvent *);
534
#ifndef QT_NO_DRAGANDDROP
535
virtual void dragEnterEvent(QDragEnterEvent *);
536
virtual void dragMoveEvent(QDragMoveEvent *);
537
virtual void dragLeaveEvent(QDragLeaveEvent *);
538
virtual void dropEvent(QDropEvent *);
541
virtual void showEvent(QShowEvent *);
542
virtual void hideEvent(QHideEvent *);
544
#if defined(Q_WS_MAC)
545
virtual bool macEvent(EventHandlerCallRef, EventRef);
547
#if defined(Q_WS_WIN)
548
virtual bool winEvent(MSG *message, long *result);
550
#if defined(Q_WS_X11)
551
virtual bool x11Event(XEvent *);
553
#if defined(Q_WS_QWS)
554
virtual bool qwsEvent(QWSEvent *);
555
virtual const uchar *qwsScanLine(int) const;
556
virtual int qwsBytesPerLine() const;
559
// Misc. protected functions
560
virtual void changeEvent(QEvent *);
562
int metric(PaintDeviceMetric) const;
564
virtual void inputMethodEvent(QInputMethodEvent *);
566
virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const;
568
void resetInputContext();
569
void updateMicroFocus();
571
void create(WId = 0, bool initializeWindow = true,
572
bool destroyOldWindow = true);
573
void destroy(bool destroyWindow = true,
574
bool destroySubWindows = true);
576
virtual bool focusNextPrevChild(bool next);
577
inline bool focusNextChild() { return focusNextPrevChild(true); }
578
inline bool focusPreviousChild() { return focusNextPrevChild(false); }
581
QWidget(QWidgetPrivate &d, QWidget* parent, Qt::WFlags f);
584
bool testAttribute_helper(Qt::WidgetAttribute) const;
586
friend class QApplication;
587
friend class QApplicationPrivate;
588
friend class QBaseApplication;
589
friend class QPainter;
590
friend class QPixmap; // for QPixmap::fill()
591
friend class QFontMetrics;
592
friend class QFontInfo;
593
friend class QETWidget;
594
friend class QLayout;
595
friend class QWidgetItem;
596
friend class QGLContext;
597
friend class QX11PaintEngine;
598
friend class QWin32PaintEngine;
599
friend class QShortcutPrivate;
602
friend class QMacSavedPortInfo;
603
friend class QQuickDrawPaintEngine;
604
friend class QCoreGraphicsPaintEnginePrivate;
605
friend QPoint qt_mac_posInWindow(const QWidget *w);
608
friend class QWSManager;
609
friend class QWSManagerPrivate;
610
friend class QDecoration;
614
Q_DISABLE_COPY(QWidget)
620
inline QT3_SUPPORT bool isUpdatesEnabled() const { return updatesEnabled(); }
621
QT3_SUPPORT QStyle *setStyle(const QString&);
622
inline QT3_SUPPORT bool isVisibleToTLW() const;
623
QT3_SUPPORT QRect visibleRect() const;
624
inline QT3_SUPPORT void iconify() { showMinimized(); }
625
inline QT3_SUPPORT void constPolish() const { ensurePolished(); }
626
inline QT3_SUPPORT void polish() { ensurePolished(); }
627
inline QT3_SUPPORT void reparent(QWidget *parent, Qt::WFlags f, const QPoint &p, bool showIt=false)
628
{ setParent(parent, f); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
629
inline QT3_SUPPORT void reparent(QWidget *parent, const QPoint &p, bool showIt=false)
630
{ setParent(parent, windowFlags() & ~Qt::WindowType_Mask); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
631
inline QT3_SUPPORT void recreate(QWidget *parent, Qt::WFlags f, const QPoint & p, bool showIt=false)
632
{ setParent(parent, f); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
633
inline QT3_SUPPORT void setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw)
634
{ QSizePolicy sp(hor, ver); sp.setHeightForWidth(hfw); setSizePolicy(sp);}
635
inline QT3_SUPPORT bool hasMouse() const { return testAttribute(Qt::WA_UnderMouse); }
637
inline QT3_SUPPORT bool ownCursor() const { return testAttribute(Qt::WA_SetCursor); }
639
inline QT3_SUPPORT bool ownFont() const { return testAttribute(Qt::WA_SetFont); }
640
inline QT3_SUPPORT void unsetFont() { setFont(QFont()); }
641
inline QT3_SUPPORT bool ownPalette() const { return testAttribute(Qt::WA_SetPalette); }
642
inline QT3_SUPPORT void unsetPalette() { setPalette(QPalette()); }
643
Qt::BackgroundMode QT3_SUPPORT backgroundMode() const;
644
void QT3_SUPPORT setBackgroundMode(Qt::BackgroundMode, Qt::BackgroundMode = Qt::PaletteBackground);
645
const QT3_SUPPORT QColor &eraseColor() const;
646
void QT3_SUPPORT setEraseColor(const QColor &);
647
const QT3_SUPPORT QColor &foregroundColor() const;
648
const QT3_SUPPORT QPixmap *erasePixmap() const;
649
void QT3_SUPPORT setErasePixmap(const QPixmap &);
650
const QT3_SUPPORT QColor &paletteForegroundColor() const;
651
void QT3_SUPPORT setPaletteForegroundColor(const QColor &);
652
const QT3_SUPPORT QColor &paletteBackgroundColor() const;
653
void QT3_SUPPORT setPaletteBackgroundColor(const QColor &);
654
const QT3_SUPPORT QPixmap *paletteBackgroundPixmap() const;
655
void QT3_SUPPORT setPaletteBackgroundPixmap(const QPixmap &);
656
const QT3_SUPPORT QBrush& backgroundBrush() const;
657
const QT3_SUPPORT QColor &backgroundColor() const;
658
const QT3_SUPPORT QPixmap *backgroundPixmap() const;
659
void QT3_SUPPORT setBackgroundPixmap(const QPixmap &);
660
QT3_SUPPORT void setBackgroundColor(const QColor &);
661
QT3_SUPPORT QColorGroup colorGroup() const;
662
QT3_SUPPORT QWidget *parentWidget(bool sameWindow) const;
663
inline QT3_SUPPORT void setKeyCompression(bool b) { setAttribute(Qt::WA_KeyCompression, b); }
664
inline QT3_SUPPORT void setFont(const QFont &f, bool) { setFont(f); }
665
inline QT3_SUPPORT void setPalette(const QPalette &p, bool) { setPalette(p); }
666
enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin };
667
inline QT3_SUPPORT void setBackgroundOrigin(BackgroundOrigin){};
668
inline QT3_SUPPORT BackgroundOrigin backgroundOrigin() const { return WindowOrigin; }
669
inline QT3_SUPPORT QPoint backgroundOffset() const { return QPoint(); }
670
inline QT3_SUPPORT void repaint(bool) { repaint(); }
671
inline QT3_SUPPORT void repaint(int x, int y, int w, int h, bool) { repaint(x,y,w,h); }
672
inline QT3_SUPPORT void repaint(const QRect &r, bool) { repaint(r); }
673
inline QT3_SUPPORT void repaint(const QRegion &rgn, bool) { repaint(rgn); }
674
QT3_SUPPORT void erase();
675
inline QT3_SUPPORT void erase(int x, int y, int w, int h) { erase_helper(x, y, w, h); }
676
QT3_SUPPORT void erase(const QRect &);
677
QT3_SUPPORT void erase(const QRegion &);
678
QT3_SUPPORT void drawText(const QPoint &p, const QString &s)
679
{ drawText_helper(p.x(), p.y(), s); }
680
inline QT3_SUPPORT void drawText(int x, int y, const QString &s)
681
{ drawText_helper(x, y, s); }
682
QT3_SUPPORT bool close(bool);
683
inline QT3_SUPPORT QWidget *childAt(int x, int y, bool includeThis) const
685
QWidget *w = childAt(x, y);
686
return w ? w : ((includeThis && rect().contains(x,y))?const_cast<QWidget*>(this):0);
688
inline QT3_SUPPORT QWidget *childAt(const QPoint &p, bool includeThis) const
690
QWidget *w = childAt(p);
691
return w ? w : ((includeThis && rect().contains(p))?const_cast<QWidget*>(this):0);
693
inline QT3_SUPPORT void setCaption(const QString &c) { setWindowTitle(c); }
694
QT3_SUPPORT void setIcon(const QPixmap &i);
695
inline QT3_SUPPORT void setIconText(const QString &it) { setWindowIconText(it); }
696
inline QT3_SUPPORT QString caption() const { return windowTitle(); }
697
QT3_SUPPORT const QPixmap *icon() const;
698
inline QT3_SUPPORT QString iconText() const { return windowIconText(); }
699
inline QT3_SUPPORT void setInputMethodEnabled(bool b) { setAttribute(Qt::WA_InputMethodEnabled, b); }
700
inline QT3_SUPPORT bool isInputMethodEnabled() const { return testAttribute(Qt::WA_InputMethodEnabled); }
701
inline QT3_SUPPORT void setActiveWindow() { activateWindow(); }
702
inline QT3_SUPPORT bool isShown() const { return !isHidden(); }
703
inline QT3_SUPPORT bool isDialog() const { return windowType() == Qt::Dialog; }
704
inline QT3_SUPPORT bool isPopup() const { return windowType() == Qt::Popup; }
705
inline QT3_SUPPORT bool isDesktop() const { return windowType() == Qt::Desktop; }
709
void drawText_helper(int x, int y, const QString &);
710
void erase_helper(int x, int y, int w, int h);
714
virtual void styleChange(QStyle&); // compat
715
virtual void enabledChange(bool); // compat
716
virtual void paletteChange(const QPalette &); // compat
717
virtual void fontChange(const QFont &); // compat
718
virtual void windowActivationChange(bool); // compat
719
virtual void languageChange(); // compat
722
#if defined Q_CC_MSVC && _MSC_VER < 1300
723
template <> inline QWidget *qobject_cast_helper<QWidget*>(QObject *o, QWidget *)
725
if (!o || !o->isWidgetType()) return 0;
726
return (QWidget*)(o);
729
template <> inline QWidget *qobject_cast<QWidget*>(QObject *o)
731
if (!o || !o->isWidgetType()) return 0;
732
return static_cast<QWidget*>(o);
734
template <> inline const QWidget *qobject_cast<const QWidget*>(const QObject *o)
736
if (!o || !o->isWidgetType()) return 0;
737
return static_cast<const QWidget*>(o);
741
inline QWidget *QWidget::childAt(int ax, int ay) const
742
{ return childAt(QPoint(ax, ay)); }
744
inline Qt::WindowType QWidget::windowType() const
745
{ return static_cast<Qt::WindowType>(int(data->window_flags & Qt::WindowType_Mask)); }
746
inline Qt::WindowFlags QWidget::windowFlags() const
747
{ return data->window_flags; }
749
inline WId QWidget::winId() const
750
{ return data->winid; }
752
inline bool QWidget::isTopLevel() const
753
{ return (windowType() & Qt::Window); }
755
inline bool QWidget::isWindow() const
756
{ return (windowType() & Qt::Window); }
758
inline bool QWidget::isEnabled() const
759
{ return !testAttribute(Qt::WA_Disabled); }
761
inline bool QWidget::isModal() const
762
{ return testAttribute(Qt::WA_ShowModal); }
764
inline bool QWidget::isEnabledToTLW() const
765
{ return isEnabled(); }
767
inline int QWidget::minimumWidth() const
768
{ return minimumSize().width(); }
770
inline int QWidget::minimumHeight() const
771
{ return minimumSize().height(); }
773
inline int QWidget::maximumWidth() const
774
{ return maximumSize().width(); }
776
inline int QWidget::maximumHeight() const
777
{ return maximumSize().height(); }
779
inline void QWidget::setMinimumSize(const QSize &s)
780
{ setMinimumSize(s.width(),s.height()); }
782
inline void QWidget::setMaximumSize(const QSize &s)
783
{ setMaximumSize(s.width(),s.height()); }
785
inline void QWidget::setSizeIncrement(const QSize &s)
786
{ setSizeIncrement(s.width(),s.height()); }
788
inline void QWidget::setBaseSize(const QSize &s)
789
{ setBaseSize(s.width(),s.height()); }
791
inline const QFont &QWidget::font() const
792
{ return data->fnt; }
794
inline QFontMetrics QWidget::fontMetrics() const
795
{ return QFontMetrics(data->fnt); }
797
inline QFontInfo QWidget::fontInfo() const
798
{ return QFontInfo(data->fnt); }
800
inline void QWidget::setMouseTracking(bool enable)
801
{ setAttribute(Qt::WA_MouseTracking, enable); }
803
inline bool QWidget::hasMouseTracking() const
804
{ return testAttribute(Qt::WA_MouseTracking); }
806
inline bool QWidget::underMouse() const
807
{ return testAttribute(Qt::WA_UnderMouse); }
809
inline bool QWidget::updatesEnabled() const
810
{ return !testAttribute(Qt::WA_UpdatesDisabled); }
812
inline void QWidget::update(int ax, int ay, int aw, int ah)
813
{ update(QRect(ax, ay, aw, ah)); }
815
inline bool QWidget::isVisible() const
816
{ return testAttribute(Qt::WA_WState_Visible); }
818
inline bool QWidget::isHidden() const
819
{ return testAttribute(Qt::WA_WState_Hidden); }
821
inline void QWidget::move(int ax, int ay)
822
{ move(QPoint(ax, ay)); }
824
inline void QWidget::resize(int w, int h)
825
{ resize(QSize(w, h)); }
827
inline void QWidget::setGeometry(int ax, int ay, int aw, int ah)
828
{ setGeometry(QRect(ax, ay, aw, ah)); }
830
inline QRect QWidget::rect() const
831
{ return QRect(0,0,data->crect.width(),data->crect.height()); }
833
inline const QRect &QWidget::geometry() const
834
{ return data->crect; }
836
inline QSize QWidget::size() const
837
{ return data->crect.size(); }
839
inline int QWidget::width() const
840
{ return data->crect.width(); }
842
inline int QWidget::height() const
843
{ return data->crect.height(); }
845
inline QWidget *QWidget::parentWidget() const
846
{ return static_cast<QWidget *>(QObject::parent()); }
848
inline void QWidget::setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver)
849
{ setSizePolicy(QSizePolicy(hor, ver)); }
851
inline bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const
853
if (attribute < int(8*sizeof(uint)))
854
return data->widget_attributes & (1<<attribute);
855
return testAttribute_helper(attribute);
859
inline bool QWidget::isVisibleToTLW() const
860
{ return isVisible(); }
861
inline QWidget *QWidget::parentWidget(bool sameWindow) const
863
if (sameWindow && isWindow())
865
return static_cast<QWidget *>(QObject::parent());
867
inline QColorGroup QWidget::colorGroup() const
868
{ return QColorGroup(palette()); }
869
inline void QWidget::setPaletteForegroundColor(const QColor &c)
870
{ QPalette p = palette(); p.setColor(foregroundRole(), c); setPalette(p); }
871
inline const QBrush& QWidget::backgroundBrush() const { return palette().brush(backgroundRole()); }
872
inline void QWidget::setBackgroundPixmap(const QPixmap &pm)
873
{ QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
874
inline const QPixmap *QWidget::backgroundPixmap() const { return 0; }
875
inline void QWidget::setBackgroundColor(const QColor &c)
876
{ QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
877
inline const QColor & QWidget::backgroundColor() const { return palette().color(backgroundRole()); }
878
inline const QColor &QWidget::foregroundColor() const { return palette().color(foregroundRole());}
879
inline const QColor &QWidget::eraseColor() const { return palette().color(backgroundRole()); }
880
inline void QWidget::setEraseColor(const QColor &c)
881
{ QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
882
inline const QPixmap *QWidget::erasePixmap() const { return 0; }
883
inline void QWidget::setErasePixmap(const QPixmap &pm)
884
{ QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
885
inline const QColor &QWidget::paletteForegroundColor() const { return palette().color(foregroundRole());}
886
inline const QColor &QWidget::paletteBackgroundColor() const { return palette().color(backgroundRole()); }
887
inline void QWidget::setPaletteBackgroundColor(const QColor &c)
888
{ QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
889
inline const QPixmap *QWidget::paletteBackgroundPixmap() const
891
inline void QWidget::setPaletteBackgroundPixmap(const QPixmap &pm)
892
{ QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
893
inline QT3_SUPPORT void QWidget::erase() { erase_helper(0, 0, data->crect.width(), data->crect.height()); }
894
inline QT3_SUPPORT void QWidget::erase(const QRect &r) { erase_helper(r.x(), r.y(), r.width(), r.height()); }
897
#define QWIDGETSIZE_MAX ((1<<24)-1)