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