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