Rename all QWindow properties that have "window" in them
[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     // All properties which are declared here are inherited by QQuickWindow and therefore available in QML.
97     // So please think carefully about what it does to the QML namespace if you add any new ones,
98     // particularly the possible meanings these names might have in any specializations of Window.
99     // For example "state" (meaning windowState) is not a good property to declare, because it has
100     // a different meaning in QQuickItem, and users will tend to assume it is the same for Window.
101
102     Q_PROPERTY(QString title READ title WRITE setTitle)
103     Q_PROPERTY(Qt::WindowModality modality READ modality WRITE setModality NOTIFY modalityChanged)
104     Q_PROPERTY(Qt::WindowFlags flags READ flags WRITE setFlags)
105     Q_PROPERTY(int x READ x WRITE setX NOTIFY xChanged)
106     Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged)
107     Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
108     Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
109     Q_PROPERTY(QPoint pos READ pos WRITE setPos)
110     Q_PROPERTY(QSize size READ size WRITE resize)
111     Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
112     Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged)
113     Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged)
114     Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged)
115     Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged)
116     Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
117     Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged)
118
119 public:
120
121     explicit QWindow(QScreen *screen = 0);
122     explicit QWindow(QWindow *parent);
123     virtual ~QWindow();
124
125     void setSurfaceType(SurfaceType surfaceType);
126     SurfaceType surfaceType() const;
127
128     bool isVisible() const;
129
130     void create();
131
132     WId winId() const;
133
134     QWindow *parent() const;
135     void setParent(QWindow *parent);
136
137     bool isTopLevel() const;
138
139     bool isModal() const;
140     Qt::WindowModality modality() const;
141     void setModality(Qt::WindowModality modality);
142
143     void setFormat(const QSurfaceFormat &format);
144     QSurfaceFormat format() const;
145     QSurfaceFormat requestedFormat() const;
146
147     void setFlags(Qt::WindowFlags flags);
148     Qt::WindowFlags flags() const;
149     Qt::WindowType type() const;
150
151     QString title() const;
152
153     void setOpacity(qreal level);
154     void requestActivate();
155
156     bool isActive() const;
157
158     void reportContentOrientationChange(Qt::ScreenOrientation orientation);
159     Qt::ScreenOrientation contentOrientation() const;
160
161     bool requestOrientation(Qt::ScreenOrientation orientation);
162     Qt::ScreenOrientation orientation() const;
163
164     Qt::WindowState windowState() const;
165     void setWindowState(Qt::WindowState state);
166
167     void setTransientParent(QWindow *parent);
168     QWindow *transientParent() const;
169
170     enum AncestorMode {
171         ExcludeTransients,
172         IncludeTransients
173     };
174
175     bool isAncestorOf(const QWindow *child, AncestorMode mode = IncludeTransients) const;
176
177     bool isExposed() const;
178
179     int minimumWidth() const { return minimumSize().width(); }
180     int minimumHeight() const { return minimumSize().height(); }
181     int maximumWidth() const { return maximumSize().width(); }
182     int maximumHeight() const { return maximumSize().height(); }
183
184     QSize minimumSize() const;
185     QSize maximumSize() const;
186     QSize baseSize() const;
187     QSize sizeIncrement() const;
188
189     void setMinimumSize(const QSize &size);
190     void setMaximumSize(const QSize &size);
191     void setBaseSize(const QSize &size);
192     void setSizeIncrement(const QSize &size);
193
194     void setGeometry(int posx, int posy, int w, int h) { setGeometry(QRect(posx, posy, w, h)); }
195     void setGeometry(const QRect &rect);
196     QRect geometry() const;
197
198     QMargins frameMargins() const;
199     QRect frameGeometry() const;
200
201     QPoint framePos() const;
202     void setFramePos(const QPoint &point);
203
204     inline int width() const { return geometry().width(); }
205     inline int height() const { return geometry().height(); }
206     inline int x() const { return geometry().x(); }
207     inline int y() const { return geometry().y(); }
208
209     inline QSize size() const { return geometry().size(); }
210     inline QPoint pos() const { return geometry().topLeft(); }
211
212     inline void setPos(const QPoint &pt) { setGeometry(QRect(pt, size())); }
213     inline void setPos(int posx, int posy) { setPos(QPoint(posx, posy)); }
214
215     void resize(const QSize &newSize);
216     inline void resize(int w, int h) { resize(QSize(w, h)); }
217
218     void setFilePath(const QString &filePath);
219     QString filePath() const;
220
221     void setIcon(const QIcon &icon);
222     QIcon icon() const;
223
224     void destroy();
225
226     QPlatformWindow *handle() const;
227
228     bool setKeyboardGrabEnabled(bool grab);
229     bool setMouseGrabEnabled(bool grab);
230
231     QScreen *screen() const;
232     void setScreen(QScreen *screen);
233
234     virtual QAccessibleInterface *accessibleRoot() const;
235     virtual QObject *focusObject() const;
236
237     QPoint mapToGlobal(const QPoint &pos) const;
238     QPoint mapFromGlobal(const QPoint &pos) const;
239
240 #ifndef QT_NO_CURSOR
241     QCursor cursor() const;
242     void setCursor(const QCursor &);
243     void unsetCursor();
244 #endif
245
246 public Q_SLOTS:
247     void setVisible(bool visible);
248
249     void show();
250     void hide();
251
252     void showMinimized();
253     void showMaximized();
254     void showFullScreen();
255     void showNormal();
256
257     bool close();
258     void raise();
259     void lower();
260
261     void setTitle(const QString &);
262
263     void setX(int arg)
264     {
265         if (x() != arg)
266             setGeometry(QRect(arg, y(), width(), height()));
267     }
268
269     void setY(int arg)
270     {
271         if (y() != arg)
272             setGeometry(QRect(x(), arg, width(), height()));
273     }
274
275     void setWidth(int arg)
276     {
277         if (width() != arg)
278             setGeometry(QRect(x(), y(), arg, height()));
279     }
280
281     void setHeight(int arg)
282     {
283         if (height() != arg)
284             setGeometry(QRect(x(), y(), width(), arg));
285     }
286
287     void setMinimumWidth(int w);
288     void setMinimumHeight(int h);
289     void setMaximumWidth(int w);
290     void setMaximumHeight(int h);
291
292 Q_SIGNALS:
293     void screenChanged(QScreen *screen);
294     void modalityChanged(Qt::WindowModality modality);
295     void windowStateChanged(Qt::WindowState windowState);
296
297     void xChanged(int arg);
298     void yChanged(int arg);
299
300     void widthChanged(int arg);
301     void heightChanged(int arg);
302
303     void minimumWidthChanged(int arg);
304     void minimumHeightChanged(int arg);
305     void maximumWidthChanged(int arg);
306     void maximumHeightChanged(int arg);
307
308     void visibleChanged(bool arg);
309     void contentOrientationChanged(Qt::ScreenOrientation orientation);
310
311     void focusObjectChanged(QObject *object);
312
313 private Q_SLOTS:
314     void screenDestroyed(QObject *screen);
315
316 protected:
317     virtual void exposeEvent(QExposeEvent *);
318     virtual void resizeEvent(QResizeEvent *);
319     virtual void moveEvent(QMoveEvent *);
320     virtual void focusInEvent(QFocusEvent *);
321     virtual void focusOutEvent(QFocusEvent *);
322
323     virtual void showEvent(QShowEvent *);
324     virtual void hideEvent(QHideEvent *);
325
326     virtual bool event(QEvent *);
327     virtual void keyPressEvent(QKeyEvent *);
328     virtual void keyReleaseEvent(QKeyEvent *);
329     virtual void mousePressEvent(QMouseEvent *);
330     virtual void mouseReleaseEvent(QMouseEvent *);
331     virtual void mouseDoubleClickEvent(QMouseEvent *);
332     virtual void mouseMoveEvent(QMouseEvent *);
333 #ifndef QT_NO_WHEELEVENT
334     virtual void wheelEvent(QWheelEvent *);
335 #endif
336     virtual void touchEvent(QTouchEvent *);
337 #ifndef QT_NO_TABLETEVENT
338     virtual void tabletEvent(QTabletEvent *);
339 #endif
340     virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result);
341
342     QWindow(QWindowPrivate &dd, QWindow *parent);
343
344 private:
345     QPlatformSurface *surfaceHandle() const;
346
347     Q_DISABLE_COPY(QWindow)
348
349     friend class QGuiApplication;
350     friend class QGuiApplicationPrivate;
351     friend Q_GUI_EXPORT QWindowPrivate *qt_window_private(QWindow *window);
352 };
353
354 QT_END_NAMESPACE
355
356 QT_END_HEADER
357
358 #endif // QWINDOW_H