summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qwindow.cpp60
-rw-r--r--src/gui/kernel/qwindow.h17
-rw-r--r--src/gui/kernel/qwindow_p.h9
3 files changed, 81 insertions, 5 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 759ee8dbc4..118844a0a2 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -412,9 +412,13 @@ void QWindow::setSizeIncrement(const QSize &size)
d->platformWindow->propagateSizeHints();
}
+/*!
+ Sets the geometry of the window excluding its window frame.
+*/
void QWindow::setGeometry(const QRect &rect)
{
Q_D(QWindow);
+ d->positionPolicy = QWindowPrivate::WindowFrameExclusive;
if (d->platformWindow) {
d->platformWindow->setGeometry(rect);
} else {
@@ -422,6 +426,9 @@ void QWindow::setGeometry(const QRect &rect)
}
}
+/*!
+ Returns the geometry of the window excluding its window frame.
+*/
QRect QWindow::geometry() const
{
Q_D(const QWindow);
@@ -430,6 +437,9 @@ QRect QWindow::geometry() const
return d->geometry;
}
+/*!
+ Returns the window frame margins surrounding the window.
+*/
QMargins QWindow::frameMargins() const
{
Q_D(const QWindow);
@@ -438,6 +448,56 @@ QMargins QWindow::frameMargins() const
return QMargins();
}
+/*!
+ Returns the geometry of the window including its window frame.
+*/
+QRect QWindow::frameGeometry() const
+{
+ Q_D(const QWindow);
+ if (d->platformWindow) {
+ QMargins m = frameMargins();
+ return d->platformWindow->geometry().adjusted(-m.left(), -m.top(), m.right(), m.bottom());
+ }
+ return d->geometry;
+}
+
+/*!
+ Returns the top left position of the window including its window frame.
+*/
+QPoint QWindow::framePos() const
+{
+ Q_D(const QWindow);
+ if (d->platformWindow) {
+ QMargins margins = frameMargins();
+ return d->platformWindow->geometry().topLeft() - QPoint(margins.left(), margins.top());
+ }
+ return d->geometry.topLeft();
+}
+
+/*!
+ Sets the upper left position of the window including its window frame.
+*/
+void QWindow::setFramePos(const QPoint &point)
+{
+ Q_D(QWindow);
+ d->positionPolicy = QWindowPrivate::WindowFrameInclusive;
+ if (d->platformWindow) {
+ d->platformWindow->setGeometry(QRect(point, size()));
+ } else {
+ d->geometry.setTopLeft(point);
+ }
+}
+
+void QWindow::resize(const QSize &newSize)
+{
+ Q_D(QWindow);
+ if (d->platformWindow) {
+ d->platformWindow->setGeometry(QRect(pos(), newSize));
+ } else {
+ d->geometry.setSize(newSize);
+ }
+}
+
void QWindow::setWindowIcon(const QImage &icon) const
{
Q_UNUSED(icon);
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 4bb1ff77a5..7a075e624d 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -142,6 +142,12 @@ public:
void setGeometry(const QRect &rect);
QRect geometry() const;
+ QMargins frameMargins() const;
+ QRect frameGeometry() const;
+
+ QPoint framePos() const;
+ void setFramePos(const QPoint &point);
+
inline int width() const { return geometry().width(); }
inline int height() const { return geometry().height(); }
inline int x() const { return geometry().x(); }
@@ -150,13 +156,14 @@ public:
inline QSize size() const { return geometry().size(); }
inline QPoint pos() const { return geometry().topLeft(); }
- inline void move(const QPoint &pt) { setGeometry(QRect(pt, size())); }
- inline void move(int posx, int posy) { move(QPoint(posx, posy)); }
+ QT_DEPRECATED inline void move(const QPoint &pt) { setPos(pt); }
+ QT_DEPRECATED inline void move(int posx, int posy) { setPos(posx, posy); }
- inline void resize(const QSize &newsize) { setGeometry(QRect(pos(), newsize)); }
- inline void resize(int w, int h) { setGeometry(QRect(x(), y(), w, h)); }
+ inline void setPos(const QPoint &pt) { setGeometry(QRect(pt, size())); }
+ inline void setPos(int posx, int posy) { setPos(QPoint(posx, posy)); }
- QMargins frameMargins() const;
+ void resize(const QSize &newSize);
+ inline void resize(int w, int h) { setGeometry(QRect(x(), y(), w, h)); }
void setWindowIcon(const QImage &icon) const;
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index 8a3bc0d7fe..1ef8f59d33 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -43,6 +43,7 @@
#define QWINDOW_QPA_P_H
#include <QtGui/qwindow.h>
+#include <QtGui/qplatformwindow_qpa.h>
#include <QtCore/private/qobject_p.h>
@@ -59,6 +60,12 @@ class Q_GUI_EXPORT QWindowPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QWindow)
public:
+ enum PositionPolicy
+ {
+ WindowFrameInclusive,
+ WindowFrameExclusive
+ };
+
QWindowPrivate()
: QObjectPrivate()
, surfaceType(QWindow::RasterSurface)
@@ -68,6 +75,7 @@ public:
, visible(false)
, windowState(Qt::WindowNoState)
, resizeEventPending(true)
+ , positionPolicy(WindowFrameExclusive)
, maximumSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX)
, modality(Qt::NonModal)
, transientParent(0)
@@ -101,6 +109,7 @@ public:
QRect geometry;
Qt::WindowState windowState;
bool resizeEventPending;
+ PositionPolicy positionPolicy;
QSize minimumSize;
QSize maximumSize;