4832adfb634c193c1e56d6b1ab0f7164a868c321
[profile/ivi/qtbase.git] / src / gui / kernel / qwindow.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 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 QWINDOW_H
43 #define QWINDOW_H
44
45 #include <QtCore/QObject>
46 #include <QtCore/QEvent>
47 #include <QtCore/QMargins>
48 #include <QtCore/QRect>
49
50 #include <QtCore/qnamespace.h>
51
52 #include <QtGui/qsurface.h>
53 #include <QtGui/qsurfaceformat.h>
54 #include <QtGui/qwindowdefs.h>
55
56 #include <QtGui/qicon.h>
57
58 #ifndef QT_NO_CURSOR
59 #include <QtGui/qcursor.h>
60 #endif
61
62 QT_BEGIN_HEADER
63
64 QT_BEGIN_NAMESPACE
65
66
67 class QWindowPrivate;
68
69 class QExposeEvent;
70 class QFocusEvent;
71 class QMoveEvent;
72 class QResizeEvent;
73 class QShowEvent;
74 class QHideEvent;
75 class QKeyEvent;
76 class QMouseEvent;
77 #ifndef QT_NO_WHEELEVENT
78 class QWheelEvent;
79 #endif
80 class QTouchEvent;
81 #ifndef QT_NO_TABLETEVENT
82 class QTabletEvent;
83 #endif
84
85 class QPlatformSurface;
86 class QPlatformWindow;
87 class QBackingStore;
88 class QScreen;
89 class QAccessibleInterface;
90
91 class Q_GUI_EXPORT QWindow : public QObject, public QSurface
92 {
93     Q_OBJECT
94     Q_DECLARE_PRIVATE(QWindow)
95
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(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged)
108     Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged)
109     Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged)
110     Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged)
111     Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
112     Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged)
113 #ifndef QT_NO_CURSOR
114     Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor)
115 #endif
116
117 public:
118
119     explicit QWindow(QScreen *screen = 0);
120     explicit QWindow(QWindow *parent);
121     virtual ~QWindow();
122
123     void setSurfaceType(SurfaceType surfaceType);
124     SurfaceType surfaceType() const;
125
126     bool isVisible() const;
127
128     void create();
129
130     WId winId() const;
131
132     QWindow *parent() const;
133     void setParent(QWindow *parent);
134
135     bool isTopLevel() const;
136
137     bool isModal() const;
138     Qt::WindowModality windowModality() const;
139     void setWindowModality(Qt::WindowModality windowModality);
140
141     void setFormat(const QSurfaceFormat &format);
142     QSurfaceFormat format() const;
143     QSurfaceFormat requestedFormat() const;
144
145     void setWindowFlags(Qt::WindowFlags flags);
146     Qt::WindowFlags windowFlags() const;
147     Qt::WindowType windowType() const;
148
149     QString windowTitle() const;
150
151     void setOpacity(qreal level);
152     void requestActivateWindow();
153
154     bool isActive() const;
155
156     void reportContentOrientationChange(Qt::ScreenOrientation orientation);
157     Qt::ScreenOrientation contentOrientation() const;
158
159     bool requestWindowOrientation(Qt::ScreenOrientation orientation);
160     Qt::ScreenOrientation windowOrientation() const;
161
162     Qt::WindowState windowState() const;
163     void setWindowState(Qt::WindowState state);
164
165     void setTransientParent(QWindow *parent);
166     QWindow *transientParent() const;
167
168     enum AncestorMode {
169         ExcludeTransients,
170         IncludeTransients
171     };
172
173     bool isAncestorOf(const QWindow *child, AncestorMode mode = IncludeTransients) const;
174
175     bool isExposed() const;
176
177     int minimumWidth() const { return minimumSize().width(); }
178     int minimumHeight() const { return minimumSize().height(); }
179     int maximumWidth() const { return maximumSize().width(); }
180     int maximumHeight() const { return maximumSize().height(); }
181
182     QSize minimumSize() const;
183     QSize maximumSize() const;
184     QSize baseSize() const;
185     QSize sizeIncrement() const;
186
187     void setMinimumSize(const QSize &size);
188     void setMaximumSize(const QSize &size);
189     void setBaseSize(const QSize &size);
190     void setSizeIncrement(const QSize &size);
191
192     void setGeometry(int posx, int posy, int w, int h) { setGeometry(QRect(posx, posy, w, h)); }
193     void setGeometry(const QRect &rect);
194     QRect geometry() const;
195
196     QMargins frameMargins() const;
197     QRect frameGeometry() const;
198
199     QPoint framePos() const;
200     void setFramePos(const QPoint &point);
201
202     inline int width() const { return geometry().width(); }
203     inline int height() const { return geometry().height(); }
204     inline int x() const { return geometry().x(); }
205     inline int y() const { return geometry().y(); }
206
207     inline QSize size() const { return geometry().size(); }
208     inline QPoint pos() const { return geometry().topLeft(); }
209
210     inline void setPos(const QPoint &pt) { setGeometry(QRect(pt, size())); }
211     inline void setPos(int posx, int posy) { setPos(QPoint(posx, posy)); }
212
213     void resize(const QSize &newSize);
214     inline void resize(int w, int h) { resize(QSize(w, h)); }
215
216     void setWindowFilePath(const QString &filePath);
217     QString windowFilePath() const;
218
219     void setWindowIcon(const QIcon &icon);
220     QIcon windowIcon() const;
221
222     void destroy();
223
224     QPlatformWindow *handle() const;
225
226     bool setKeyboardGrabEnabled(bool grab);
227     bool setMouseGrabEnabled(bool grab);
228
229     QScreen *screen() const;
230     void setScreen(QScreen *screen);
231
232     virtual QAccessibleInterface *accessibleRoot() const;
233     virtual QObject *focusObject() const;
234
235     QPoint mapToGlobal(const QPoint &pos) const;
236     QPoint mapFromGlobal(const QPoint &pos) const;
237
238 #ifndef QT_NO_CURSOR
239     QCursor cursor() const;
240     void setCursor(const QCursor &);
241     void unsetCursor();
242 #endif
243
244 public Q_SLOTS:
245     void setVisible(bool visible);
246
247     void show();
248     void hide();
249
250     void showMinimized();
251     void showMaximized();
252     void showFullScreen();
253     void showNormal();
254
255     bool close();
256     void raise();
257     void lower();
258
259     void setWindowTitle(const QString &);
260
261     void setX(int arg)
262     {
263         if (x() != arg)
264             setGeometry(QRect(arg, y(), width(), height()));
265     }
266
267     void setY(int arg)
268     {
269         if (y() != arg)
270             setGeometry(QRect(x(), arg, width(), height()));
271     }
272
273     void setWidth(int arg)
274     {
275         if (width() != arg)
276             setGeometry(QRect(x(), y(), arg, height()));
277     }
278
279     void setHeight(int arg)
280     {
281         if (height() != arg)
282             setGeometry(QRect(x(), y(), width(), arg));
283     }
284
285     void setMinimumWidth(int w);
286     void setMinimumHeight(int h);
287     void setMaximumWidth(int w);
288     void setMaximumHeight(int h);
289
290 Q_SIGNALS:
291     void screenChanged(QScreen *screen);
292     void windowModalityChanged(Qt::WindowModality windowModality);
293
294     void xChanged(int arg);
295     void yChanged(int arg);
296
297     void widthChanged(int arg);
298     void heightChanged(int arg);
299
300     void minimumWidthChanged(int arg);
301     void minimumHeightChanged(int arg);
302     void maximumWidthChanged(int arg);
303     void maximumHeightChanged(int arg);
304
305     void visibleChanged(bool arg);
306     void contentOrientationChanged(Qt::ScreenOrientation orientation);
307
308     void focusObjectChanged(QObject *object);
309
310 private Q_SLOTS:
311     void screenDestroyed(QObject *screen);
312
313 protected:
314     virtual void exposeEvent(QExposeEvent *);
315     virtual void resizeEvent(QResizeEvent *);
316     virtual void moveEvent(QMoveEvent *);
317     virtual void focusInEvent(QFocusEvent *);
318     virtual void focusOutEvent(QFocusEvent *);
319
320     virtual void showEvent(QShowEvent *);
321     virtual void hideEvent(QHideEvent *);
322
323     virtual bool event(QEvent *);
324     virtual void keyPressEvent(QKeyEvent *);
325     virtual void keyReleaseEvent(QKeyEvent *);
326     virtual void mousePressEvent(QMouseEvent *);
327     virtual void mouseReleaseEvent(QMouseEvent *);
328     virtual void mouseDoubleClickEvent(QMouseEvent *);
329     virtual void mouseMoveEvent(QMouseEvent *);
330 #ifndef QT_NO_WHEELEVENT
331     virtual void wheelEvent(QWheelEvent *);
332 #endif
333     virtual void touchEvent(QTouchEvent *);
334 #ifndef QT_NO_TABLETEVENT
335     virtual void tabletEvent(QTabletEvent *);
336 #endif
337     virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result);
338
339     QWindow(QWindowPrivate &dd, QWindow *parent);
340
341 private:
342     QPlatformSurface *surfaceHandle() const;
343
344     Q_DISABLE_COPY(QWindow)
345
346     friend class QGuiApplication;
347     friend class QGuiApplicationPrivate;
348     friend Q_GUI_EXPORT QWindowPrivate *qt_window_private(QWindow *window);
349 };
350
351 QT_END_NAMESPACE
352
353 QT_END_HEADER
354
355 #endif // QWINDOW_H