Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qpaintdevicewindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QtGui/QGuiApplication>
7#include <QtGui/QScreen>
8
10
12 = default;
13
15 = default;
16
44{
45 update(QRect(QPoint(0,0), size()));
46}
47
58{
60 d->dirtyRegion += rect;
61 if (isExposed())
62 requestUpdate();
63}
64
75{
77 d->dirtyRegion += region;
78 if (isExposed())
79 requestUpdate();
80}
81
90{
92 // Do nothing
93}
94
99{
100 QScreen *screen = this->screen();
103
104 switch (metric) {
105 case PdmWidth:
106 return width();
107 case PdmWidthMM:
108 if (screen)
109 return width() * screen->physicalSize().width() / screen->geometry().width();
110 break;
111 case PdmHeight:
112 return height();
113 case PdmHeightMM:
114 if (screen)
115 return height() * screen->physicalSize().height() / screen->geometry().height();
116 break;
117 case PdmDpiX:
118 if (screen)
120 break;
121 case PdmDpiY:
122 if (screen)
124 break;
125 case PdmPhysicalDpiX:
126 if (screen)
128 break;
129 case PdmPhysicalDpiY:
130 if (screen)
132 break;
134 return int(QWindow::devicePixelRatio());
135 break;
137 return int(QWindow::devicePixelRatio() * devicePixelRatioFScale());
138 break;
139 default:
140 break;
141 }
142
144}
145
153
158{
160
161 if (event->type() == QEvent::UpdateRequest) {
162 if (handle()) // platform window may be gone when the window is closed during app exit
163 d->handleUpdateEvent();
164 return true;
165 } else if (event->type() == QEvent::Paint) {
166 d->markWindowAsDirty();
167 // Do not rely on exposeEvent->region() as it has some issues for the
168 // time being, namely that it is sometimes in local coordinates,
169 // sometimes relative to the parent, depending on the platform plugin.
170 // We require local coords here.
171 auto region = QRect(QPoint(0, 0), size());
172 d->doFlush(region); // Will end up calling paintEvent
173 return true;
174 } else if (event->type() == QEvent::Resize) {
175 d->handleResizeEvent();
176 }
177
178 return QWindow::event(event);
179}
180
188
193{
194 return nullptr;
195}
196
198
199#include "moc_qpaintdevicewindow.cpp"
\inmodule QtCore
Definition qcoreevent.h:45
@ UpdateRequest
Definition qcoreevent.h:113
The QExposeEvent class contains event parameters for expose events. \inmodule QtGui.
Definition qevent.h:515
QScreen * primaryScreen
the primary (or default) screen of the application.
~QPaintDeviceWindowPrivate() override
bool event(QEvent *event) override
QPaintDeviceWindow(QPaintDeviceWindowPrivate &dd, QWindow *parent)
int width
the width of the window's geometry
Definition qwindow.h:82
void exposeEvent(QExposeEvent *) override
QPaintEngine * paintEngine() const override
void update()
Marks the entire window as dirty and schedules a repaint.
void paintEvent(QPaintEvent *event) override
Handles paint events passed in the event parameter.
int metric(PaintDeviceMetric metric) const override
int height
the height of the window's geometry
Definition qwindow.h:83
@ PdmDevicePixelRatioScaled
virtual int metric(PaintDeviceMetric metric) const
static qreal devicePixelRatioFScale()
\inmodule QtGui
The QPaintEvent class contains event parameters for paint events.
Definition qevent.h:486
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:239
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:236
The QRegion class specifies a clip region for a painter.
Definition qregion.h:27
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
qreal logicalDotsPerInchY
the number of logical dots or pixels per inch in the vertical direction
Definition qscreen.h:57
qreal logicalDotsPerInchX
the number of logical dots or pixels per inch in the horizontal direction
Definition qscreen.h:56
QSizeF physicalSize
the screen's physical size (in millimeters)
Definition qscreen.h:50
QRect geometry
the screen's geometry in pixels
Definition qscreen.h:45
qreal physicalDotsPerInchY
the number of physical dots or pixels per inch in the vertical direction
Definition qscreen.h:54
qreal physicalDotsPerInchX
the number of physical dots or pixels per inch in the horizontal direction
Definition qscreen.h:52
constexpr qreal width() const noexcept
Returns the width.
Definition qsize.h:332
constexpr qreal height() const noexcept
Returns the height.
Definition qsize.h:335
\inmodule QtGui
Definition qwindow.h:63
virtual void exposeEvent(QExposeEvent *)
The expose event (ev) is sent by the window system when a window moves between the un-exposed and exp...
Definition qwindow.cpp:2423
QSize size() const override
Returns the size of the window excluding any window frame.
Definition qwindow.h:210
virtual bool event(QEvent *) override
Override this to handle any event (ev) sent to the window.
Definition qwindow.cpp:2511
rect
[4]
Combined button and popup list for selecting options.
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:327
GLuint64 GLenum void * handle
struct _cl_event * event
QScreen * screen
[1]
Definition main.cpp:29
#define Q_UNUSED(x)