1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). |
4 | ** Contact: http://www.qt-project.org/ |
5 | ** |
6 | ** This file is part of the QtGui module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** GNU Lesser General Public License Usage |
10 | ** This file may be used under the terms of the GNU Lesser General Public |
11 | ** License version 2.1 as published by the Free Software Foundation and |
12 | ** appearing in the file LICENSE.LGPL included in the packaging of this |
13 | ** file. Please review the following information to ensure the GNU Lesser |
14 | ** General Public License version 2.1 requirements will be met: |
15 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
16 | ** |
17 | ** In addition, as a special exception, Nokia gives you certain additional |
18 | ** rights. These rights are described in the Nokia Qt LGPL Exception |
19 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
20 | ** |
21 | ** GNU General Public License Usage |
22 | ** Alternatively, this file may be used under the terms of the GNU General |
23 | ** Public License version 3.0 as published by the Free Software Foundation |
24 | ** and appearing in the file LICENSE.GPL included in the packaging of this |
25 | ** file. Please review the following information to ensure the GNU General |
26 | ** Public License version 3.0 requirements will be met: |
27 | ** http://www.gnu.org/copyleft/gpl.html. |
28 | ** |
29 | ** Other Usage |
30 | ** Alternatively, this file may be used in accordance with the terms and |
31 | ** conditions contained in a signed written agreement between you and Nokia. |
32 | ** |
33 | ** |
34 | ** |
35 | ** |
36 | ** |
37 | ** |
38 | ** $QT_END_LICENSE$ |
39 | ** |
40 | ****************************************************************************/ |
41 | |
42 | #ifndef QWIDGET_H |
43 | #define QWIDGET_H |
44 | |
45 | #include <QtGui/qwindowdefs.h> |
46 | #include <QtCore/qobject.h> |
47 | #include <QtCore/qmargins.h> |
48 | #include <QtGui/qpaintdevice.h> |
49 | #include <QtGui/qpalette.h> |
50 | #include <QtGui/qfont.h> |
51 | #include <QtGui/qfontmetrics.h> |
52 | #include <QtGui/qfontinfo.h> |
53 | #include <QtGui/qsizepolicy.h> |
54 | #include <QtGui/qregion.h> |
55 | #include <QtGui/qbrush.h> |
56 | #include <QtGui/qcursor.h> |
57 | #include <QtGui/qkeysequence.h> |
58 | |
59 | #ifdef Q_WS_QPA //should this go somewhere else? |
60 | #include <QtGui/qplatformwindowformat_qpa.h> |
61 | #endif |
62 | |
63 | #ifdef QT_INCLUDE_COMPAT |
64 | #include <QtGui/qevent.h> |
65 | #endif |
66 | |
67 | QT_BEGIN_HEADER |
68 | |
69 | QT_BEGIN_NAMESPACE |
70 | |
71 | QT_MODULE(Gui) |
72 | |
73 | class QLayout; |
74 | class QWSRegionManager; |
75 | class QStyle; |
76 | class QAction; |
77 | class QVariant; |
78 | |
79 | class QActionEvent; |
80 | class QMouseEvent; |
81 | class QWheelEvent; |
82 | class QHoverEvent; |
83 | class QKeyEvent; |
84 | class QFocusEvent; |
85 | class QPaintEvent; |
86 | class QMoveEvent; |
87 | class QResizeEvent; |
88 | class QCloseEvent; |
89 | class QContextMenuEvent; |
90 | class QInputMethodEvent; |
91 | class QTabletEvent; |
92 | class QDragEnterEvent; |
93 | class QDragMoveEvent; |
94 | class QDragLeaveEvent; |
95 | class QDropEvent; |
96 | class QShowEvent; |
97 | class QHideEvent; |
98 | class QInputContext; |
99 | class QIcon; |
100 | class QWindowSurface; |
101 | class QPlatformWindow; |
102 | class QLocale; |
103 | class QGraphicsProxyWidget; |
104 | class QGraphicsEffect; |
105 | class QRasterWindowSurface; |
106 | class QUnifiedToolbarSurface; |
107 | #if defined(Q_WS_X11) |
108 | class QX11Info; |
109 | #endif |
110 | |
111 | class QWidgetData |
112 | { |
113 | public: |
114 | WId winid; |
115 | uint widget_attributes; |
116 | Qt::WindowFlags window_flags; |
117 | uint window_state : 4; |
118 | uint focus_policy : 4; |
119 | uint sizehint_forced :1; |
120 | uint is_closing :1; |
121 | uint in_show : 1; |
122 | uint in_set_window_state : 1; |
123 | mutable uint fstrut_dirty : 1; |
124 | uint : 3; |
125 | uint window_modality : 2; |
126 | uint in_destructor : 1; |
127 | uint unused : 13; |
128 | QRect crect; |
129 | mutable QPalette pal; |
130 | QFont fnt; |
131 | #if defined(Q_WS_QWS) |
132 | // QRegion req_region; // Requested region |
133 | // mutable QRegion paintable_region; // Paintable region |
134 | // mutable bool paintable_region_dirty;// needs to be recalculated |
135 | // mutable QRegion alloc_region; // Allocated region |
136 | // mutable bool alloc_region_dirty; // needs to be recalculated |
137 | // mutable int overlapping_children; // Handle overlapping children |
138 | |
139 | int alloc_region_index; |
140 | // int alloc_region_revision; |
141 | #endif |
142 | QRect wrect; |
143 | }; |
144 | |
145 | class QWidgetPrivate; |
146 | |
147 | class Q_GUI_EXPORT QWidget : public QObject, public QPaintDevice |
148 | { |
149 | Q_OBJECT |
150 | Q_DECLARE_PRIVATE(QWidget) |
151 | |
152 | Q_PROPERTY(bool modal READ isModal) |
153 | Q_PROPERTY(Qt::WindowModality windowModality READ windowModality WRITE setWindowModality) |
154 | Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) |
155 | Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry) |
156 | Q_PROPERTY(QRect frameGeometry READ frameGeometry) |
157 | Q_PROPERTY(QRect normalGeometry READ normalGeometry) |
158 | Q_PROPERTY(int x READ x) |
159 | Q_PROPERTY(int y READ y) |
160 | Q_PROPERTY(QPoint pos READ pos WRITE move DESIGNABLE false STORED false) |
161 | Q_PROPERTY(QSize frameSize READ frameSize) |
162 | Q_PROPERTY(QSize size READ size WRITE resize DESIGNABLE false STORED false) |
163 | Q_PROPERTY(int width READ width) |
164 | Q_PROPERTY(int height READ height) |
165 | Q_PROPERTY(QRect rect READ rect) |
166 | Q_PROPERTY(QRect childrenRect READ childrenRect) |
167 | Q_PROPERTY(QRegion childrenRegion READ childrenRegion) |
168 | Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy) |
169 | Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize) |
170 | Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize) |
171 | Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false DESIGNABLE false) |
172 | Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false DESIGNABLE false) |
173 | Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false DESIGNABLE false) |
174 | Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false DESIGNABLE false) |
175 | Q_PROPERTY(QSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement) |
176 | Q_PROPERTY(QSize baseSize READ baseSize WRITE setBaseSize) |
177 | Q_PROPERTY(QPalette palette READ palette WRITE setPalette) |
178 | Q_PROPERTY(QFont font READ font WRITE setFont) |
179 | #ifndef QT_NO_CURSOR |
180 | Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor) |
181 | #endif |
182 | Q_PROPERTY(bool mouseTracking READ hasMouseTracking WRITE setMouseTracking) |
183 | Q_PROPERTY(bool isActiveWindow READ isActiveWindow) |
184 | Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy) |
185 | Q_PROPERTY(bool focus READ hasFocus) |
186 | Q_PROPERTY(Qt::ContextMenuPolicy contextMenuPolicy READ contextMenuPolicy WRITE setContextMenuPolicy) |
187 | Q_PROPERTY(bool updatesEnabled READ updatesEnabled WRITE setUpdatesEnabled DESIGNABLE false) |
188 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false) |
189 | Q_PROPERTY(bool minimized READ isMinimized) |
190 | Q_PROPERTY(bool maximized READ isMaximized) |
191 | Q_PROPERTY(bool fullScreen READ isFullScreen) |
192 | Q_PROPERTY(QSize sizeHint READ sizeHint) |
193 | Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint) |
194 | Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops) |
195 | Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE isWindow) |
196 | Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon DESIGNABLE isWindow) |
197 | Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText DESIGNABLE isWindow) |
198 | Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow) |
199 | Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow) |
200 | #ifndef QT_NO_TOOLTIP |
201 | Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip) |
202 | #endif |
203 | #ifndef QT_NO_STATUSTIP |
204 | Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip) |
205 | #endif |
206 | #ifndef QT_NO_WHATSTHIS |
207 | Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis) |
208 | #endif |
209 | #ifndef QT_NO_ACCESSIBILITY |
210 | Q_PROPERTY(QString accessibleName READ accessibleName WRITE setAccessibleName) |
211 | Q_PROPERTY(QString accessibleDescription READ accessibleDescription WRITE setAccessibleDescription) |
212 | #endif |
213 | Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection) |
214 | QDOC_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags) |
215 | Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground) |
216 | #ifndef QT_NO_STYLE_STYLESHEET |
217 | Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet) |
218 | #endif |
219 | Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET unsetLocale) |
220 | Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath DESIGNABLE isWindow) |
221 | Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints) |
222 | |
223 | public: |
224 | enum RenderFlag { |
225 | DrawWindowBackground = 0x1, |
226 | DrawChildren = 0x2, |
227 | IgnoreMask = 0x4 |
228 | }; |
229 | Q_DECLARE_FLAGS(RenderFlags, RenderFlag) |
230 | |
231 | explicit QWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); |
232 | #ifdef QT3_SUPPORT |
233 | QT3_SUPPORT_CONSTRUCTOR QWidget(QWidget* parent, const char *name, Qt::WindowFlags f = 0); |
234 | #endif |
235 | ~QWidget(); |
236 | |
237 | int devType() const; |
238 | |
239 | WId winId() const; |
240 | void createWinId(); // internal, going away |
241 | inline WId internalWinId() const { return data->winid; } |
242 | WId effectiveWinId() const; |
243 | |
244 | // GUI style setting |
245 | QStyle *style() const; |
246 | void setStyle(QStyle *); |
247 | // Widget types and states |
248 | |
249 | bool isTopLevel() const; |
250 | bool isWindow() const; |
251 | |
252 | bool isModal() const; |
253 | Qt::WindowModality windowModality() const; |
254 | void setWindowModality(Qt::WindowModality windowModality); |
255 | |
256 | bool isEnabled() const; |
257 | bool isEnabledTo(QWidget*) const; |
258 | bool isEnabledToTLW() const; |
259 | |
260 | public Q_SLOTS: |
261 | void setEnabled(bool); |
262 | void setDisabled(bool); |
263 | void setWindowModified(bool); |
264 | |
265 | // Widget coordinates |
266 | |
267 | public: |
268 | QRect frameGeometry() const; |
269 | const QRect &geometry() const; |
270 | QRect normalGeometry() const; |
271 | |
272 | int x() const; |
273 | int y() const; |
274 | QPoint pos() const; |
275 | QSize frameSize() const; |
276 | QSize size() const; |
277 | inline int width() const; |
278 | inline int height() const; |
279 | inline QRect rect() const; |
280 | QRect childrenRect() const; |
281 | QRegion childrenRegion() const; |
282 | |
283 | QSize minimumSize() const; |
284 | QSize maximumSize() const; |
285 | int minimumWidth() const; |
286 | int minimumHeight() const; |
287 | int maximumWidth() const; |
288 | int maximumHeight() const; |
289 | void setMinimumSize(const QSize &); |
290 | void setMinimumSize(int minw, int minh); |
291 | void setMaximumSize(const QSize &); |
292 | void setMaximumSize(int maxw, int maxh); |
293 | void setMinimumWidth(int minw); |
294 | void setMinimumHeight(int minh); |
295 | void setMaximumWidth(int maxw); |
296 | void setMaximumHeight(int maxh); |
297 | |
298 | #ifdef Q_QDOC |
299 | void setupUi(QWidget *widget); |
300 | #endif |
301 | |
302 | QSize sizeIncrement() const; |
303 | void setSizeIncrement(const QSize &); |
304 | void setSizeIncrement(int w, int h); |
305 | QSize baseSize() const; |
306 | void setBaseSize(const QSize &); |
307 | void setBaseSize(int basew, int baseh); |
308 | |
309 | void setFixedSize(const QSize &); |
310 | void setFixedSize(int w, int h); |
311 | void setFixedWidth(int w); |
312 | void setFixedHeight(int h); |
313 | |
314 | // Widget coordinate mapping |
315 | |
316 | QPoint mapToGlobal(const QPoint &) const; |
317 | QPoint mapFromGlobal(const QPoint &) const; |
318 | QPoint mapToParent(const QPoint &) const; |
319 | QPoint mapFromParent(const QPoint &) const; |
320 | QPoint mapTo(QWidget *, const QPoint &) const; |
321 | QPoint mapFrom(QWidget *, const QPoint &) const; |
322 | |
323 | QWidget *window() const; |
324 | QWidget *nativeParentWidget() const; |
325 | inline QWidget *topLevelWidget() const { return window(); } |
326 | |
327 | // Widget appearance functions |
328 | const QPalette &palette() const; |
329 | void setPalette(const QPalette &); |
330 | |
331 | void setBackgroundRole(QPalette::ColorRole); |
332 | QPalette::ColorRole backgroundRole() const; |
333 | |
334 | void setForegroundRole(QPalette::ColorRole); |
335 | QPalette::ColorRole foregroundRole() const; |
336 | |
337 | const QFont &font() const; |
338 | void setFont(const QFont &); |
339 | QFontMetrics fontMetrics() const; |
340 | QFontInfo fontInfo() const; |
341 | |
342 | #ifndef QT_NO_CURSOR |
343 | QCursor cursor() const; |
344 | void setCursor(const QCursor &); |
345 | void unsetCursor(); |
346 | #endif |
347 | |
348 | void setMouseTracking(bool enable); |
349 | bool hasMouseTracking() const; |
350 | bool underMouse() const; |
351 | |
352 | void setMask(const QBitmap &); |
353 | void setMask(const QRegion &); |
354 | QRegion mask() const; |
355 | void clearMask(); |
356 | |
357 | void render(QPaintDevice *target, const QPoint &targetOffset = QPoint(), |
358 | const QRegion &sourceRegion = QRegion(), |
359 | RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren)); |
360 | |
361 | void render(QPainter *painter, const QPoint &targetOffset = QPoint(), |
362 | const QRegion &sourceRegion = QRegion(), |
363 | RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren)); |
364 | |
365 | #ifndef QT_NO_GRAPHICSEFFECT |
366 | QGraphicsEffect *graphicsEffect() const; |
367 | void setGraphicsEffect(QGraphicsEffect *effect); |
368 | #endif //QT_NO_GRAPHICSEFFECT |
369 | |
370 | #ifndef QT_NO_GESTURES |
371 | void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags()); |
372 | void ungrabGesture(Qt::GestureType type); |
373 | #endif |
374 | |
375 | public Q_SLOTS: |
376 | void setWindowTitle(const QString &); |
377 | #ifndef QT_NO_STYLE_STYLESHEET |
378 | void setStyleSheet(const QString& styleSheet); |
379 | #endif |
380 | public: |
381 | #ifndef QT_NO_STYLE_STYLESHEET |
382 | QString styleSheet() const; |
383 | #endif |
384 | QString windowTitle() const; |
385 | void setWindowIcon(const QIcon &icon); |
386 | QIcon windowIcon() const; |
387 | void setWindowIconText(const QString &); |
388 | QString windowIconText() const; |
389 | void setWindowRole(const QString &); |
390 | QString windowRole() const; |
391 | void setWindowFilePath(const QString &filePath); |
392 | QString windowFilePath() const; |
393 | |
394 | void setWindowOpacity(qreal level); |
395 | qreal windowOpacity() const; |
396 | |
397 | bool isWindowModified() const; |
398 | #ifndef QT_NO_TOOLTIP |
399 | void setToolTip(const QString &); |
400 | QString toolTip() const; |
401 | #endif |
402 | #ifndef QT_NO_STATUSTIP |
403 | void setStatusTip(const QString &); |
404 | QString statusTip() const; |
405 | #endif |
406 | #ifndef QT_NO_WHATSTHIS |
407 | void setWhatsThis(const QString &); |
408 | QString whatsThis() const; |
409 | #endif |
410 | #ifndef QT_NO_ACCESSIBILITY |
411 | QString accessibleName() const; |
412 | void setAccessibleName(const QString &name); |
413 | QString accessibleDescription() const; |
414 | void setAccessibleDescription(const QString &description); |
415 | #endif |
416 | |
417 | void setLayoutDirection(Qt::LayoutDirection direction); |
418 | Qt::LayoutDirection layoutDirection() const; |
419 | void unsetLayoutDirection(); |
420 | |
421 | void setLocale(const QLocale &locale); |
422 | QLocale locale() const; |
423 | void unsetLocale(); |
424 | |
425 | inline bool isRightToLeft() const { return layoutDirection() == Qt::RightToLeft; } |
426 | inline bool isLeftToRight() const { return layoutDirection() == Qt::LeftToRight; } |
427 | |
428 | public Q_SLOTS: |
429 | inline void setFocus() { setFocus(Qt::OtherFocusReason); } |
430 | |
431 | public: |
432 | bool isActiveWindow() const; |
433 | void activateWindow(); |
434 | void clearFocus(); |
435 | |
436 | void setFocus(Qt::FocusReason reason); |
437 | Qt::FocusPolicy focusPolicy() const; |
438 | void setFocusPolicy(Qt::FocusPolicy policy); |
439 | bool hasFocus() const; |
440 | static void setTabOrder(QWidget *, QWidget *); |
441 | void setFocusProxy(QWidget *); |
442 | QWidget *focusProxy() const; |
443 | Qt::ContextMenuPolicy () const; |
444 | void (Qt::ContextMenuPolicy policy); |
445 | |
446 | // Grab functions |
447 | void grabMouse(); |
448 | #ifndef QT_NO_CURSOR |
449 | void grabMouse(const QCursor &); |
450 | #endif |
451 | void releaseMouse(); |
452 | void grabKeyboard(); |
453 | void releaseKeyboard(); |
454 | #ifndef QT_NO_SHORTCUT |
455 | int grabShortcut(const QKeySequence &key, Qt::ShortcutContext context = Qt::WindowShortcut); |
456 | void releaseShortcut(int id); |
457 | void setShortcutEnabled(int id, bool enable = true); |
458 | void setShortcutAutoRepeat(int id, bool enable = true); |
459 | #endif |
460 | static QWidget *mouseGrabber(); |
461 | static QWidget *keyboardGrabber(); |
462 | |
463 | // Update/refresh functions |
464 | inline bool updatesEnabled() const; |
465 | void setUpdatesEnabled(bool enable); |
466 | |
467 | #if 0 //def Q_WS_QWS |
468 | void repaintUnclipped(const QRegion &, bool erase = true); |
469 | #endif |
470 | |
471 | #ifndef QT_NO_GRAPHICSVIEW |
472 | QGraphicsProxyWidget *graphicsProxyWidget() const; |
473 | #endif |
474 | |
475 | public Q_SLOTS: |
476 | void update(); |
477 | void repaint(); |
478 | |
479 | public: |
480 | inline void update(int x, int y, int w, int h); |
481 | void update(const QRect&); |
482 | void update(const QRegion&); |
483 | |
484 | void repaint(int x, int y, int w, int h); |
485 | void repaint(const QRect &); |
486 | void repaint(const QRegion &); |
487 | |
488 | public Q_SLOTS: |
489 | // Widget management functions |
490 | |
491 | virtual void setVisible(bool visible); |
492 | inline void setHidden(bool hidden) { setVisible(!hidden); } |
493 | #ifndef Q_WS_WINCE |
494 | inline void show() { setVisible(true); } |
495 | #else |
496 | void show(); |
497 | #endif |
498 | inline void hide() { setVisible(false); } |
499 | inline QT_MOC_COMPAT void setShown(bool shown) { setVisible(shown); } |
500 | |
501 | void showMinimized(); |
502 | void showMaximized(); |
503 | void showFullScreen(); |
504 | void showNormal(); |
505 | |
506 | bool close(); |
507 | void raise(); |
508 | void lower(); |
509 | |
510 | public: |
511 | void stackUnder(QWidget*); |
512 | void move(int x, int y); |
513 | void move(const QPoint &); |
514 | void resize(int w, int h); |
515 | void resize(const QSize &); |
516 | inline void setGeometry(int x, int y, int w, int h); |
517 | void setGeometry(const QRect &); |
518 | QByteArray saveGeometry() const; |
519 | bool restoreGeometry(const QByteArray &geometry); |
520 | void adjustSize(); |
521 | bool isVisible() const; |
522 | bool isVisibleTo(QWidget*) const; |
523 | // ### Qt 5: bool isVisibleTo(_const_ QWidget *) const |
524 | inline bool isHidden() const; |
525 | |
526 | bool isMinimized() const; |
527 | bool isMaximized() const; |
528 | bool isFullScreen() const; |
529 | |
530 | Qt::WindowStates windowState() const; |
531 | void setWindowState(Qt::WindowStates state); |
532 | void overrideWindowState(Qt::WindowStates state); |
533 | |
534 | virtual QSize sizeHint() const; |
535 | virtual QSize minimumSizeHint() const; |
536 | |
537 | QSizePolicy sizePolicy() const; |
538 | void setSizePolicy(QSizePolicy); |
539 | inline void setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical); |
540 | virtual int heightForWidth(int) const; |
541 | |
542 | QRegion visibleRegion() const; |
543 | |
544 | void setContentsMargins(int left, int top, int right, int bottom); |
545 | void setContentsMargins(const QMargins &margins); |
546 | void getContentsMargins(int *left, int *top, int *right, int *bottom) const; |
547 | QMargins contentsMargins() const; |
548 | |
549 | QRect contentsRect() const; |
550 | |
551 | public: |
552 | QLayout *layout() const; |
553 | void setLayout(QLayout *); |
554 | void updateGeometry(); |
555 | |
556 | void setParent(QWidget *parent); |
557 | void setParent(QWidget *parent, Qt::WindowFlags f); |
558 | |
559 | void scroll(int dx, int dy); |
560 | void scroll(int dx, int dy, const QRect&); |
561 | |
562 | // Misc. functions |
563 | |
564 | QWidget *focusWidget() const; |
565 | QWidget *nextInFocusChain() const; |
566 | QWidget *previousInFocusChain() const; |
567 | |
568 | // drag and drop |
569 | bool acceptDrops() const; |
570 | void setAcceptDrops(bool on); |
571 | |
572 | #ifndef QT_NO_ACTION |
573 | //actions |
574 | void addAction(QAction *action); |
575 | void addActions(QList<QAction*> actions); |
576 | void insertAction(QAction *before, QAction *action); |
577 | void insertActions(QAction *before, QList<QAction*> actions); |
578 | void removeAction(QAction *action); |
579 | QList<QAction*> actions() const; |
580 | #endif |
581 | |
582 | QWidget *parentWidget() const; |
583 | |
584 | void setWindowFlags(Qt::WindowFlags type); |
585 | inline Qt::WindowFlags windowFlags() const; |
586 | void overrideWindowFlags(Qt::WindowFlags type); |
587 | |
588 | inline Qt::WindowType windowType() const; |
589 | |
590 | static QWidget *find(WId); |
591 | #ifdef QT3_SUPPORT |
592 | static QT3_SUPPORT QWidgetMapper *wmapper(); |
593 | #endif |
594 | inline QWidget *childAt(int x, int y) const; |
595 | QWidget *childAt(const QPoint &p) const; |
596 | |
597 | #if defined(Q_WS_X11) |
598 | const QX11Info &x11Info() const; |
599 | Qt::HANDLE x11PictureHandle() const; |
600 | #endif |
601 | |
602 | #if defined(Q_WS_MAC) |
603 | Qt::HANDLE macQDHandle() const; |
604 | Qt::HANDLE macCGHandle() const; |
605 | #endif |
606 | |
607 | #if defined(Q_WS_WIN) |
608 | HDC getDC() const; |
609 | void releaseDC(HDC) const; |
610 | #else |
611 | Qt::HANDLE handle() const; |
612 | #endif |
613 | |
614 | void setAttribute(Qt::WidgetAttribute, bool on = true); |
615 | inline bool testAttribute(Qt::WidgetAttribute) const; |
616 | |
617 | QPaintEngine *paintEngine() const; |
618 | |
619 | void ensurePolished() const; |
620 | |
621 | QInputContext *inputContext(); |
622 | void setInputContext(QInputContext *); |
623 | |
624 | bool isAncestorOf(const QWidget *child) const; |
625 | |
626 | #ifdef QT_KEYPAD_NAVIGATION |
627 | bool hasEditFocus() const; |
628 | void setEditFocus(bool on); |
629 | #endif |
630 | |
631 | bool autoFillBackground() const; |
632 | void setAutoFillBackground(bool enabled); |
633 | |
634 | void setWindowSurface(QWindowSurface *surface); |
635 | QWindowSurface *windowSurface() const; |
636 | |
637 | #if defined(Q_WS_QPA) |
638 | void setPlatformWindow(QPlatformWindow *window); |
639 | QPlatformWindow *platformWindow() const; |
640 | |
641 | void setPlatformWindowFormat(const QPlatformWindowFormat &format); |
642 | QPlatformWindowFormat platformWindowFormat() const; |
643 | |
644 | friend class QDesktopScreenWidget; |
645 | #endif |
646 | |
647 | Q_SIGNALS: |
648 | void (const QPoint &pos); |
649 | |
650 | protected: |
651 | // Event handlers |
652 | bool event(QEvent *); |
653 | virtual void mousePressEvent(QMouseEvent *); |
654 | virtual void mouseReleaseEvent(QMouseEvent *); |
655 | virtual void mouseDoubleClickEvent(QMouseEvent *); |
656 | virtual void mouseMoveEvent(QMouseEvent *); |
657 | #ifndef QT_NO_WHEELEVENT |
658 | virtual void wheelEvent(QWheelEvent *); |
659 | #endif |
660 | virtual void keyPressEvent(QKeyEvent *); |
661 | virtual void keyReleaseEvent(QKeyEvent *); |
662 | virtual void focusInEvent(QFocusEvent *); |
663 | virtual void focusOutEvent(QFocusEvent *); |
664 | virtual void enterEvent(QEvent *); |
665 | virtual void leaveEvent(QEvent *); |
666 | virtual void paintEvent(QPaintEvent *); |
667 | virtual void moveEvent(QMoveEvent *); |
668 | virtual void resizeEvent(QResizeEvent *); |
669 | virtual void closeEvent(QCloseEvent *); |
670 | #ifndef QT_NO_CONTEXTMENU |
671 | virtual void (QContextMenuEvent *); |
672 | #endif |
673 | #ifndef QT_NO_TABLETEVENT |
674 | virtual void tabletEvent(QTabletEvent *); |
675 | #endif |
676 | #ifndef QT_NO_ACTION |
677 | virtual void actionEvent(QActionEvent *); |
678 | #endif |
679 | |
680 | #ifndef QT_NO_DRAGANDDROP |
681 | virtual void dragEnterEvent(QDragEnterEvent *); |
682 | virtual void dragMoveEvent(QDragMoveEvent *); |
683 | virtual void dragLeaveEvent(QDragLeaveEvent *); |
684 | virtual void dropEvent(QDropEvent *); |
685 | #endif |
686 | |
687 | virtual void showEvent(QShowEvent *); |
688 | virtual void hideEvent(QHideEvent *); |
689 | |
690 | #if defined(Q_WS_MAC) |
691 | virtual bool macEvent(EventHandlerCallRef, EventRef); |
692 | #endif |
693 | #if defined(Q_WS_WIN) |
694 | virtual bool winEvent(MSG *message, long *result); |
695 | #endif |
696 | #if defined(Q_WS_X11) |
697 | virtual bool x11Event(XEvent *); |
698 | #endif |
699 | #if defined(Q_WS_QWS) |
700 | virtual bool qwsEvent(QWSEvent *); |
701 | #endif |
702 | |
703 | // Misc. protected functions |
704 | virtual void changeEvent(QEvent *); |
705 | |
706 | int metric(PaintDeviceMetric) const; |
707 | |
708 | virtual void inputMethodEvent(QInputMethodEvent *); |
709 | public: |
710 | virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const; |
711 | |
712 | Qt::InputMethodHints inputMethodHints() const; |
713 | void setInputMethodHints(Qt::InputMethodHints hints); |
714 | |
715 | protected: |
716 | void resetInputContext(); |
717 | protected Q_SLOTS: |
718 | void updateMicroFocus(); |
719 | protected: |
720 | |
721 | void create(WId = 0, bool initializeWindow = true, |
722 | bool destroyOldWindow = true); |
723 | void destroy(bool destroyWindow = true, |
724 | bool destroySubWindows = true); |
725 | |
726 | virtual bool focusNextPrevChild(bool next); |
727 | inline bool focusNextChild() { return focusNextPrevChild(true); } |
728 | inline bool focusPreviousChild() { return focusNextPrevChild(false); } |
729 | |
730 | protected: |
731 | QWidget(QWidgetPrivate &d, QWidget* parent, Qt::WindowFlags f); |
732 | private: |
733 | |
734 | bool testAttribute_helper(Qt::WidgetAttribute) const; |
735 | |
736 | QLayout *takeLayout(); |
737 | |
738 | friend class QBackingStoreDevice; |
739 | friend class QWidgetBackingStore; |
740 | friend class QApplication; |
741 | friend class QApplicationPrivate; |
742 | friend class QBaseApplication; |
743 | friend class QPainter; |
744 | friend class QPainterPrivate; |
745 | friend class QPixmap; // for QPixmap::fill() |
746 | friend class QFontMetrics; |
747 | friend class QFontInfo; |
748 | friend class QETWidget; |
749 | friend class QLayout; |
750 | friend class QWidgetItem; |
751 | friend class QWidgetItemV2; |
752 | friend class QGLContext; |
753 | friend class QGLWidget; |
754 | friend class QGLWindowSurface; |
755 | friend class QX11PaintEngine; |
756 | friend class QWin32PaintEngine; |
757 | friend class QShortcutPrivate; |
758 | friend class QShortcutMap; |
759 | friend class QWindowSurface; |
760 | friend class QGraphicsProxyWidget; |
761 | friend class QGraphicsProxyWidgetPrivate; |
762 | friend class QStyleSheetStyle; |
763 | friend struct QWidgetExceptionCleaner; |
764 | #ifndef QT_NO_GESTURES |
765 | friend class QGestureManager; |
766 | friend class QWinNativePanGestureRecognizer; |
767 | #endif // QT_NO_GESTURES |
768 | friend class QWidgetEffectSourcePrivate; |
769 | |
770 | #ifdef Q_WS_MAC |
771 | friend class QCoreGraphicsPaintEnginePrivate; |
772 | friend QPoint qt_mac_posInWindow(const QWidget *w); |
773 | friend OSWindowRef qt_mac_window_for(const QWidget *w); |
774 | friend bool qt_mac_is_metal(const QWidget *w); |
775 | friend OSViewRef qt_mac_nativeview_for(const QWidget *w); |
776 | friend void qt_event_request_window_change(QWidget *widget); |
777 | friend bool qt_mac_sendMacEventToWidget(QWidget *widget, EventRef ref); |
778 | friend class QRasterWindowSurface; |
779 | friend class QUnifiedToolbarSurface; |
780 | #endif |
781 | #ifdef Q_WS_QWS |
782 | friend class QWSBackingStore; |
783 | friend class QWSManager; |
784 | friend class QWSManagerPrivate; |
785 | friend class QDecoration; |
786 | friend class QWSWindowSurface; |
787 | friend class QScreen; |
788 | friend class QVNCScreen; |
789 | friend bool isWidgetOpaque(const QWidget *); |
790 | friend class QGLWidgetPrivate; |
791 | #endif |
792 | #ifdef Q_OS_SYMBIAN |
793 | friend class QSymbianControl; |
794 | friend class QS60WindowSurface; |
795 | #endif |
796 | #ifdef Q_WS_X11 |
797 | friend void qt_net_update_user_time(QWidget *tlw, unsigned long timestamp); |
798 | friend void qt_net_remove_user_time(QWidget *tlw); |
799 | friend void qt_set_winid_on_widget(QWidget*, Qt::HANDLE); |
800 | #endif |
801 | |
802 | friend Q_GUI_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget); |
803 | friend Q_GUI_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget); |
804 | |
805 | private: |
806 | Q_DISABLE_COPY(QWidget) |
807 | Q_PRIVATE_SLOT(d_func(), void _q_showIfNotHidden()) |
808 | #ifdef Q_OS_SYMBIAN |
809 | Q_PRIVATE_SLOT(d_func(), void void _q_cleanupWinIds()) |
810 | #endif |
811 | |
812 | QWidgetData *data; |
813 | |
814 | #ifdef QT3_SUPPORT |
815 | public: |
816 | inline QT3_SUPPORT bool isUpdatesEnabled() const { return updatesEnabled(); } |
817 | QT3_SUPPORT QStyle *setStyle(const QString&); |
818 | inline QT3_SUPPORT bool isVisibleToTLW() const; |
819 | QT3_SUPPORT QRect visibleRect() const; |
820 | inline QT3_SUPPORT void iconify() { showMinimized(); } |
821 | inline QT3_SUPPORT void constPolish() const { ensurePolished(); } |
822 | inline QT3_SUPPORT void polish() { ensurePolished(); } |
823 | inline QT3_SUPPORT void reparent(QWidget *parent, Qt::WindowFlags f, const QPoint &p, bool showIt=false) |
824 | { setParent(parent, f); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); } |
825 | inline QT3_SUPPORT void reparent(QWidget *parent, const QPoint &p, bool showIt=false) |
826 | { setParent(parent, windowFlags() & ~Qt::WindowType_Mask); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); } |
827 | inline QT3_SUPPORT void recreate(QWidget *parent, Qt::WindowFlags f, const QPoint & p, bool showIt=false) |
828 | { setParent(parent, f); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); } |
829 | inline QT3_SUPPORT void setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw) |
830 | { QSizePolicy sp(hor, ver); sp.setHeightForWidth(hfw); setSizePolicy(sp);} |
831 | inline QT3_SUPPORT bool hasMouse() const { return testAttribute(Qt::WA_UnderMouse); } |
832 | #ifndef QT_NO_CURSOR |
833 | inline QT3_SUPPORT bool ownCursor() const { return testAttribute(Qt::WA_SetCursor); } |
834 | #endif |
835 | inline QT3_SUPPORT bool ownFont() const { return testAttribute(Qt::WA_SetFont); } |
836 | inline QT3_SUPPORT void unsetFont() { setFont(QFont()); } |
837 | inline QT3_SUPPORT bool ownPalette() const { return testAttribute(Qt::WA_SetPalette); } |
838 | inline QT3_SUPPORT void unsetPalette() { setPalette(QPalette()); } |
839 | Qt::BackgroundMode QT3_SUPPORT backgroundMode() const; |
840 | void QT3_SUPPORT setBackgroundMode(Qt::BackgroundMode, Qt::BackgroundMode = Qt::PaletteBackground); |
841 | const QT3_SUPPORT QColor &eraseColor() const; |
842 | void QT3_SUPPORT setEraseColor(const QColor &); |
843 | const QT3_SUPPORT QColor &foregroundColor() const; |
844 | const QT3_SUPPORT QPixmap *erasePixmap() const; |
845 | void QT3_SUPPORT setErasePixmap(const QPixmap &); |
846 | const QT3_SUPPORT QColor &paletteForegroundColor() const; |
847 | void QT3_SUPPORT setPaletteForegroundColor(const QColor &); |
848 | const QT3_SUPPORT QColor &paletteBackgroundColor() const; |
849 | void QT3_SUPPORT setPaletteBackgroundColor(const QColor &); |
850 | const QT3_SUPPORT QPixmap *paletteBackgroundPixmap() const; |
851 | void QT3_SUPPORT setPaletteBackgroundPixmap(const QPixmap &); |
852 | const QT3_SUPPORT QBrush& backgroundBrush() const; |
853 | const QT3_SUPPORT QColor &backgroundColor() const; |
854 | const QT3_SUPPORT QPixmap *backgroundPixmap() const; |
855 | void QT3_SUPPORT setBackgroundPixmap(const QPixmap &); |
856 | QT3_SUPPORT void setBackgroundColor(const QColor &); |
857 | QT3_SUPPORT QColorGroup colorGroup() const; |
858 | QT3_SUPPORT QWidget *parentWidget(bool sameWindow) const; |
859 | inline QT3_SUPPORT void setKeyCompression(bool b) { setAttribute(Qt::WA_KeyCompression, b); } |
860 | inline QT3_SUPPORT void setFont(const QFont &f, bool) { setFont(f); } |
861 | inline QT3_SUPPORT void setPalette(const QPalette &p, bool) { setPalette(p); } |
862 | enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin }; |
863 | inline QT3_SUPPORT void setBackgroundOrigin(BackgroundOrigin) {} |
864 | inline QT3_SUPPORT BackgroundOrigin backgroundOrigin() const { return WindowOrigin; } |
865 | inline QT3_SUPPORT QPoint backgroundOffset() const { return QPoint(); } |
866 | inline QT3_SUPPORT void repaint(bool) { repaint(); } |
867 | inline QT3_SUPPORT void repaint(int x, int y, int w, int h, bool) { repaint(x,y,w,h); } |
868 | inline QT3_SUPPORT void repaint(const QRect &r, bool) { repaint(r); } |
869 | inline QT3_SUPPORT void repaint(const QRegion &rgn, bool) { repaint(rgn); } |
870 | QT3_SUPPORT void erase(); |
871 | inline QT3_SUPPORT void erase(int x, int y, int w, int h) { erase_helper(x, y, w, h); } |
872 | QT3_SUPPORT void erase(const QRect &); |
873 | QT3_SUPPORT void erase(const QRegion &); |
874 | QT3_SUPPORT void drawText(const QPoint &p, const QString &s) |
875 | { drawText_helper(p.x(), p.y(), s); } |
876 | inline QT3_SUPPORT void drawText(int x, int y, const QString &s) |
877 | { drawText_helper(x, y, s); } |
878 | QT3_SUPPORT bool close(bool); |
879 | inline QT3_SUPPORT QWidget *childAt(int x, int y, bool includeThis) const |
880 | { |
881 | QWidget *w = childAt(x, y); |
882 | return w ? w : ((includeThis && rect().contains(x,y))?const_cast<QWidget*>(this):0); |
883 | } |
884 | inline QT3_SUPPORT QWidget *childAt(const QPoint &p, bool includeThis) const |
885 | { |
886 | QWidget *w = childAt(p); |
887 | return w ? w : ((includeThis && rect().contains(p))?const_cast<QWidget*>(this):0); |
888 | } |
889 | inline QT3_SUPPORT void setCaption(const QString &c) { setWindowTitle(c); } |
890 | QT3_SUPPORT void setIcon(const QPixmap &i); |
891 | inline QT3_SUPPORT void setIconText(const QString &it) { setWindowIconText(it); } |
892 | inline QT3_SUPPORT QString caption() const { return windowTitle(); } |
893 | QT3_SUPPORT const QPixmap *icon() const; |
894 | inline QT3_SUPPORT QString iconText() const { return windowIconText(); } |
895 | inline QT3_SUPPORT void setInputMethodEnabled(bool b) { setAttribute(Qt::WA_InputMethodEnabled, b); } |
896 | inline QT3_SUPPORT bool isInputMethodEnabled() const { return testAttribute(Qt::WA_InputMethodEnabled); } |
897 | inline QT3_SUPPORT void setActiveWindow() { activateWindow(); } |
898 | inline QT3_SUPPORT bool isShown() const { return !isHidden(); } |
899 | inline QT3_SUPPORT bool isDialog() const { return windowType() == Qt::Dialog; } |
900 | inline QT3_SUPPORT bool isPopup() const { return windowType() == Qt::Popup; } |
901 | inline QT3_SUPPORT bool isDesktop() const { return windowType() == Qt::Desktop; } |
902 | |
903 | |
904 | private: |
905 | void drawText_helper(int x, int y, const QString &); |
906 | void erase_helper(int x, int y, int w, int h); |
907 | #endif // QT3_SUPPORT |
908 | |
909 | protected: |
910 | virtual void styleChange(QStyle&); // compat |
911 | virtual void enabledChange(bool); // compat |
912 | virtual void paletteChange(const QPalette &); // compat |
913 | virtual void fontChange(const QFont &); // compat |
914 | virtual void windowActivationChange(bool); // compat |
915 | virtual void languageChange(); // compat |
916 | }; |
917 | |
918 | Q_DECLARE_OPERATORS_FOR_FLAGS(QWidget::RenderFlags) |
919 | |
920 | template <> inline QWidget *qobject_cast<QWidget*>(QObject *o) |
921 | { |
922 | if (!o || !o->isWidgetType()) return 0; |
923 | return static_cast<QWidget*>(o); |
924 | } |
925 | template <> inline const QWidget *qobject_cast<const QWidget*>(const QObject *o) |
926 | { |
927 | if (!o || !o->isWidgetType()) return 0; |
928 | return static_cast<const QWidget*>(o); |
929 | } |
930 | |
931 | inline QWidget *QWidget::childAt(int ax, int ay) const |
932 | { return childAt(QPoint(ax, ay)); } |
933 | |
934 | inline Qt::WindowType QWidget::windowType() const |
935 | { return static_cast<Qt::WindowType>(int(data->window_flags & Qt::WindowType_Mask)); } |
936 | inline Qt::WindowFlags QWidget::windowFlags() const |
937 | { return data->window_flags; } |
938 | |
939 | inline bool QWidget::isTopLevel() const |
940 | { return (windowType() & Qt::Window); } |
941 | |
942 | inline bool QWidget::isWindow() const |
943 | { return (windowType() & Qt::Window); } |
944 | |
945 | inline bool QWidget::isEnabled() const |
946 | { return !testAttribute(Qt::WA_Disabled); } |
947 | |
948 | inline bool QWidget::isModal() const |
949 | { return data->window_modality != Qt::NonModal; } |
950 | |
951 | inline bool QWidget::isEnabledToTLW() const |
952 | { return isEnabled(); } |
953 | |
954 | inline int QWidget::minimumWidth() const |
955 | { return minimumSize().width(); } |
956 | |
957 | inline int QWidget::minimumHeight() const |
958 | { return minimumSize().height(); } |
959 | |
960 | inline int QWidget::maximumWidth() const |
961 | { return maximumSize().width(); } |
962 | |
963 | inline int QWidget::maximumHeight() const |
964 | { return maximumSize().height(); } |
965 | |
966 | inline void QWidget::setMinimumSize(const QSize &s) |
967 | { setMinimumSize(s.width(),s.height()); } |
968 | |
969 | inline void QWidget::setMaximumSize(const QSize &s) |
970 | { setMaximumSize(s.width(),s.height()); } |
971 | |
972 | inline void QWidget::setSizeIncrement(const QSize &s) |
973 | { setSizeIncrement(s.width(),s.height()); } |
974 | |
975 | inline void QWidget::setBaseSize(const QSize &s) |
976 | { setBaseSize(s.width(),s.height()); } |
977 | |
978 | inline const QFont &QWidget::font() const |
979 | { return data->fnt; } |
980 | |
981 | inline QFontMetrics QWidget::fontMetrics() const |
982 | { return QFontMetrics(data->fnt); } |
983 | |
984 | inline QFontInfo QWidget::fontInfo() const |
985 | { return QFontInfo(data->fnt); } |
986 | |
987 | inline void QWidget::setMouseTracking(bool enable) |
988 | { setAttribute(Qt::WA_MouseTracking, enable); } |
989 | |
990 | inline bool QWidget::hasMouseTracking() const |
991 | { return testAttribute(Qt::WA_MouseTracking); } |
992 | |
993 | inline bool QWidget::underMouse() const |
994 | { return testAttribute(Qt::WA_UnderMouse); } |
995 | |
996 | inline bool QWidget::updatesEnabled() const |
997 | { return !testAttribute(Qt::WA_UpdatesDisabled); } |
998 | |
999 | inline void QWidget::update(int ax, int ay, int aw, int ah) |
1000 | { update(QRect(ax, ay, aw, ah)); } |
1001 | |
1002 | inline bool QWidget::isVisible() const |
1003 | { return testAttribute(Qt::WA_WState_Visible); } |
1004 | |
1005 | inline bool QWidget::isHidden() const |
1006 | { return testAttribute(Qt::WA_WState_Hidden); } |
1007 | |
1008 | inline void QWidget::move(int ax, int ay) |
1009 | { move(QPoint(ax, ay)); } |
1010 | |
1011 | inline void QWidget::resize(int w, int h) |
1012 | { resize(QSize(w, h)); } |
1013 | |
1014 | inline void QWidget::setGeometry(int ax, int ay, int aw, int ah) |
1015 | { setGeometry(QRect(ax, ay, aw, ah)); } |
1016 | |
1017 | inline QRect QWidget::rect() const |
1018 | { return QRect(0,0,data->crect.width(),data->crect.height()); } |
1019 | |
1020 | inline const QRect &QWidget::geometry() const |
1021 | { return data->crect; } |
1022 | |
1023 | inline QSize QWidget::size() const |
1024 | { return data->crect.size(); } |
1025 | |
1026 | inline int QWidget::width() const |
1027 | { return data->crect.width(); } |
1028 | |
1029 | inline int QWidget::height() const |
1030 | { return data->crect.height(); } |
1031 | |
1032 | inline QWidget *QWidget::parentWidget() const |
1033 | { return static_cast<QWidget *>(QObject::parent()); } |
1034 | |
1035 | inline void QWidget::setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver) |
1036 | { setSizePolicy(QSizePolicy(hor, ver)); } |
1037 | |
1038 | inline bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const |
1039 | { |
1040 | if (attribute < int(8*sizeof(uint))) |
1041 | return data->widget_attributes & (1<<attribute); |
1042 | return testAttribute_helper(attribute); |
1043 | } |
1044 | |
1045 | #ifdef QT3_SUPPORT |
1046 | inline bool QWidget::isVisibleToTLW() const |
1047 | { return isVisible(); } |
1048 | inline QWidget *QWidget::parentWidget(bool sameWindow) const |
1049 | { |
1050 | if (sameWindow && isWindow()) |
1051 | return 0; |
1052 | return static_cast<QWidget *>(QObject::parent()); |
1053 | } |
1054 | inline QColorGroup QWidget::colorGroup() const |
1055 | { return QColorGroup(palette()); } |
1056 | inline void QWidget::setPaletteForegroundColor(const QColor &c) |
1057 | { QPalette p = palette(); p.setColor(foregroundRole(), c); setPalette(p); } |
1058 | inline const QBrush& QWidget::backgroundBrush() const { return palette().brush(backgroundRole()); } |
1059 | inline void QWidget::setBackgroundPixmap(const QPixmap &pm) |
1060 | { QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); } |
1061 | inline const QPixmap *QWidget::backgroundPixmap() const { return 0; } |
1062 | inline void QWidget::setBackgroundColor(const QColor &c) |
1063 | { QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); } |
1064 | inline const QColor & QWidget::backgroundColor() const { return palette().color(backgroundRole()); } |
1065 | inline const QColor &QWidget::foregroundColor() const { return palette().color(foregroundRole());} |
1066 | inline const QColor &QWidget::eraseColor() const { return palette().color(backgroundRole()); } |
1067 | inline void QWidget::setEraseColor(const QColor &c) |
1068 | { QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); } |
1069 | inline const QPixmap *QWidget::erasePixmap() const { return 0; } |
1070 | inline void QWidget::setErasePixmap(const QPixmap &pm) |
1071 | { QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); } |
1072 | inline const QColor &QWidget::paletteForegroundColor() const { return palette().color(foregroundRole());} |
1073 | inline const QColor &QWidget::paletteBackgroundColor() const { return palette().color(backgroundRole()); } |
1074 | inline void QWidget::setPaletteBackgroundColor(const QColor &c) |
1075 | { QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); } |
1076 | inline const QPixmap *QWidget::paletteBackgroundPixmap() const |
1077 | { return 0; } |
1078 | inline void QWidget::setPaletteBackgroundPixmap(const QPixmap &pm) |
1079 | { QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); } |
1080 | inline QT3_SUPPORT void QWidget::erase() { erase_helper(0, 0, data->crect.width(), data->crect.height()); } |
1081 | inline QT3_SUPPORT void QWidget::erase(const QRect &r) { erase_helper(r.x(), r.y(), r.width(), r.height()); } |
1082 | #endif |
1083 | |
1084 | #define QWIDGETSIZE_MAX ((1<<24)-1) |
1085 | |
1086 | QT_END_NAMESPACE |
1087 | |
1088 | QT_END_HEADER |
1089 | |
1090 | #endif // QWIDGET_H |
1091 | |