1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtGui module of the Qt Toolkit.
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.
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.
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.
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.
40 ****************************************************************************/
45 #include <QtCore/QObject>
46 #include <QtCore/QEvent>
47 #include <QtCore/QMargins>
48 #include <QtCore/QRect>
50 #include <QtCore/qnamespace.h>
52 #include <QtGui/qsurface.h>
53 #include <QtGui/qsurfaceformat.h>
54 #include <QtGui/qwindowdefs.h>
56 #include <QtGui/qicon.h>
59 #include <QtGui/qcursor.h>
77 #ifndef QT_NO_WHEELEVENT
81 #ifndef QT_NO_TABLETEVENT
85 class QPlatformSurface;
86 class QPlatformWindow;
89 class QAccessibleInterface;
91 class Q_GUI_EXPORT QWindow : public QObject, public QSurface
94 Q_DECLARE_PRIVATE(QWindow)
96 Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle)
97 Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath)
98 Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
99 Q_PROPERTY(Qt::WindowModality windowModality READ windowModality WRITE setWindowModality NOTIFY windowModalityChanged)
100 Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged)
101 Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged)
102 Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
103 Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
104 Q_PROPERTY(QPoint pos READ pos WRITE setPos)
105 Q_PROPERTY(QSize size READ size WRITE resize)
106 Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
107 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
108 Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged)
110 Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor)
115 explicit QWindow(QScreen *screen = 0);
116 explicit QWindow(QWindow *parent);
119 void setSurfaceType(SurfaceType surfaceType);
120 SurfaceType surfaceType() const;
122 bool isVisible() const;
128 QWindow *parent() const;
129 void setParent(QWindow *parent);
131 bool isTopLevel() const;
133 bool isModal() const;
134 Qt::WindowModality windowModality() const;
135 void setWindowModality(Qt::WindowModality windowModality);
137 void setFormat(const QSurfaceFormat &format);
138 QSurfaceFormat format() const;
139 QSurfaceFormat requestedFormat() const;
141 void setWindowFlags(Qt::WindowFlags flags);
142 Qt::WindowFlags windowFlags() const;
143 Qt::WindowType windowType() const;
145 QString windowTitle() const;
147 void setOpacity(qreal level);
148 void requestActivateWindow();
150 bool isActive() const;
152 void reportContentOrientationChange(Qt::ScreenOrientation orientation);
153 Qt::ScreenOrientation contentOrientation() const;
155 bool requestWindowOrientation(Qt::ScreenOrientation orientation);
156 Qt::ScreenOrientation windowOrientation() const;
158 Qt::WindowState windowState() const;
159 void setWindowState(Qt::WindowState state);
161 void setTransientParent(QWindow *parent);
162 QWindow *transientParent() const;
169 bool isAncestorOf(const QWindow *child, AncestorMode mode = IncludeTransients) const;
171 bool isExposed() const;
173 QSize minimumSize() const;
174 QSize maximumSize() const;
175 QSize baseSize() const;
176 QSize sizeIncrement() const;
178 void setMinimumSize(const QSize &size);
179 void setMaximumSize(const QSize &size);
180 void setBaseSize(const QSize &size);
181 void setSizeIncrement(const QSize &size);
183 void setGeometry(int posx, int posy, int w, int h) { setGeometry(QRect(posx, posy, w, h)); }
184 void setGeometry(const QRect &rect);
185 QRect geometry() const;
187 QMargins frameMargins() const;
188 QRect frameGeometry() const;
190 QPoint framePos() const;
191 void setFramePos(const QPoint &point);
193 inline int width() const { return geometry().width(); }
194 inline int height() const { return geometry().height(); }
195 inline int x() const { return geometry().x(); }
196 inline int y() const { return geometry().y(); }
198 inline QSize size() const { return geometry().size(); }
199 inline QPoint pos() const { return geometry().topLeft(); }
201 inline void setPos(const QPoint &pt) { setGeometry(QRect(pt, size())); }
202 inline void setPos(int posx, int posy) { setPos(QPoint(posx, posy)); }
204 void resize(const QSize &newSize);
205 inline void resize(int w, int h) { resize(QSize(w, h)); }
207 void setWindowFilePath(const QString &filePath);
208 QString windowFilePath() const;
210 void setWindowIcon(const QIcon &icon);
211 QIcon windowIcon() const;
215 QPlatformWindow *handle() const;
217 bool setKeyboardGrabEnabled(bool grab);
218 bool setMouseGrabEnabled(bool grab);
220 QScreen *screen() const;
221 void setScreen(QScreen *screen);
223 virtual QAccessibleInterface *accessibleRoot() const;
224 virtual QObject *focusObject() const;
226 QPoint mapToGlobal(const QPoint &pos) const;
227 QPoint mapFromGlobal(const QPoint &pos) const;
230 QCursor cursor() const;
231 void setCursor(const QCursor &);
236 void setVisible(bool visible);
241 void showMinimized();
242 void showMaximized();
243 void showFullScreen();
250 void setWindowTitle(const QString &);
255 setGeometry(QRect(arg, y(), width(), height()));
261 setGeometry(QRect(x(), arg, width(), height()));
264 void setWidth(int arg)
267 setGeometry(QRect(x(), y(), arg, height()));
270 void setHeight(int arg)
273 setGeometry(QRect(x(), y(), width(), arg));
277 void screenChanged(QScreen *screen);
278 void windowModalityChanged(Qt::WindowModality windowModality);
280 void xChanged(int arg);
281 void yChanged(int arg);
283 void widthChanged(int arg);
284 void heightChanged(int arg);
286 void visibleChanged(bool arg);
287 void contentOrientationChanged(Qt::ScreenOrientation orientation);
289 void focusObjectChanged(QObject *object);
292 void screenDestroyed(QObject *screen);
295 virtual void exposeEvent(QExposeEvent *);
296 virtual void resizeEvent(QResizeEvent *);
297 virtual void moveEvent(QMoveEvent *);
298 virtual void focusInEvent(QFocusEvent *);
299 virtual void focusOutEvent(QFocusEvent *);
301 virtual void showEvent(QShowEvent *);
302 virtual void hideEvent(QHideEvent *);
304 virtual bool event(QEvent *);
305 virtual void keyPressEvent(QKeyEvent *);
306 virtual void keyReleaseEvent(QKeyEvent *);
307 virtual void mousePressEvent(QMouseEvent *);
308 virtual void mouseReleaseEvent(QMouseEvent *);
309 virtual void mouseDoubleClickEvent(QMouseEvent *);
310 virtual void mouseMoveEvent(QMouseEvent *);
311 #ifndef QT_NO_WHEELEVENT
312 virtual void wheelEvent(QWheelEvent *);
314 virtual void touchEvent(QTouchEvent *);
315 #ifndef QT_NO_TABLETEVENT
316 virtual void tabletEvent(QTabletEvent *);
318 virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result);
320 QWindow(QWindowPrivate &dd, QWindow *parent);
323 QPlatformSurface *surfaceHandle() const;
325 Q_DISABLE_COPY(QWindow)
327 friend class QGuiApplication;
328 friend class QGuiApplicationPrivate;
329 friend Q_GUI_EXPORT QWindowPrivate *qt_window_private(QWindow *window);