qpaintdevicewindow.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qpaintdevicewindow.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
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 The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qpaintdevicewindow_p.h"-
41-
42#include <QtGui/QGuiApplication>-
43#include <QtGui/QScreen>-
44-
45QT_BEGIN_NAMESPACE-
46-
47/*!-
48 \class QPaintDeviceWindow-
49 \inmodule QtGui-
50 \since 5.4-
51 \brief Convenience subclass of QWindow that is also a QPaintDevice.-
52-
53 QPaintDeviceWindow is like a regular QWindow, with the added functionality-
54 of being a paint device too. Whenever the content needs to be updated,-
55 the virtual paintEvent() function is called. Subclasses, that reimplement-
56 this function, can then simply open a QPainter on the window.-
57-
58 \note This class cannot directly be used in applications. It rather serves-
59 as a base for subclasses like QOpenGLWindow.-
60-
61 \sa QOpenGLWindow-
62*/-
63-
64/*!-
65 Marks the entire window as dirty and schedules a repaint.-
66-
67 \note Subsequent calls to this function before the next paint-
68 event will get ignored.-
69-
70 \note For non-exposed windows the update is deferred until the-
71 window becomes exposed again.-
72*/-
73void QPaintDeviceWindow::update()-
74{-
75 update(QRect(QPoint(0,0), size()));-
76}
never executed: end of block
0
77-
78/*!-
79 Marks the \a rect of the window as dirty and schedules a repaint.-
80-
81 \note Subsequent calls to this function before the next paint-
82 event will get ignored, but \a rect is added to the region to update.-
83-
84 \note For non-exposed windows the update is deferred until the-
85 window becomes exposed again.-
86*/-
87void QPaintDeviceWindow::update(const QRect &rect)-
88{-
89 Q_D(QPaintDeviceWindow);-
90 d->dirtyRegion += rect;-
91 if (isExposed())
isExposed()Description
TRUEnever evaluated
FALSEnever evaluated
0
92 requestUpdate();
never executed: requestUpdate();
0
93}
never executed: end of block
0
94-
95/*!-
96 Marks the \a region of the window as dirty and schedules a repaint.-
97-
98 \note Subsequent calls to this function before the next paint-
99 event will get ignored, but \a region is added to the region to update.-
100-
101 \note For non-exposed windows the update is deferred until the-
102 window becomes exposed again.-
103*/-
104void QPaintDeviceWindow::update(const QRegion &region)-
105{-
106 Q_D(QPaintDeviceWindow);-
107 d->dirtyRegion += region;-
108 if (isExposed())
isExposed()Description
TRUEnever evaluated
FALSEnever evaluated
0
109 requestUpdate();
never executed: requestUpdate();
0
110}
never executed: end of block
0
111-
112/*!-
113 Handles paint events passed in the \a event parameter.-
114-
115 The default implementation does nothing. Reimplement this function to-
116 perform painting. If necessary, the dirty area is retrievable from-
117 the \a event.-
118*/-
119void QPaintDeviceWindow::paintEvent(QPaintEvent *event)-
120{-
121 Q_UNUSED(event);-
122 // Do nothing-
123}
never executed: end of block
0
124-
125/*!-
126 \internal-
127 */-
128int QPaintDeviceWindow::metric(PaintDeviceMetric metric) const-
129{-
130 QScreen *screen = this->screen();-
131 if (!screen && QGuiApplication::primaryScreen())
!screenDescription
TRUEnever evaluated
FALSEnever evaluated
QGuiApplicatio...rimaryScreen()Description
TRUEnever evaluated
FALSEnever evaluated
0
132 screen = QGuiApplication::primaryScreen();
never executed: screen = QGuiApplication::primaryScreen();
0
133-
134 switch (metric) {-
135 case PdmWidth:
never executed: case PdmWidth:
0
136 return width();
never executed: return width();
0
137 case PdmWidthMM:
never executed: case PdmWidthMM:
0
138 if (screen)
screenDescription
TRUEnever evaluated
FALSEnever evaluated
0
139 return width() * screen->physicalSize().width() / screen->geometry().width();
never executed: return width() * screen->physicalSize().width() / screen->geometry().width();
0
140 break;
never executed: break;
0
141 case PdmHeight:
never executed: case PdmHeight:
0
142 return height();
never executed: return height();
0
143 case PdmHeightMM:
never executed: case PdmHeightMM:
0
144 if (screen)
screenDescription
TRUEnever evaluated
FALSEnever evaluated
0
145 return height() * screen->physicalSize().height() / screen->geometry().height();
never executed: return height() * screen->physicalSize().height() / screen->geometry().height();
0
146 break;
never executed: break;
0
147 case PdmDpiX:
never executed: case PdmDpiX:
0
148 if (screen)
screenDescription
TRUEnever evaluated
FALSEnever evaluated
0
149 return qRound(screen->logicalDotsPerInchX());
never executed: return qRound(screen->logicalDotsPerInchX());
0
150 break;
never executed: break;
0
151 case PdmDpiY:
never executed: case PdmDpiY:
0
152 if (screen)
screenDescription
TRUEnever evaluated
FALSEnever evaluated
0
153 return qRound(screen->logicalDotsPerInchY());
never executed: return qRound(screen->logicalDotsPerInchY());
0
154 break;
never executed: break;
0
155 case PdmPhysicalDpiX:
never executed: case PdmPhysicalDpiX:
0
156 if (screen)
screenDescription
TRUEnever evaluated
FALSEnever evaluated
0
157 return qRound(screen->physicalDotsPerInchX());
never executed: return qRound(screen->physicalDotsPerInchX());
0
158 break;
never executed: break;
0
159 case PdmPhysicalDpiY:
never executed: case PdmPhysicalDpiY:
0
160 if (screen)
screenDescription
TRUEnever evaluated
FALSEnever evaluated
0
161 return qRound(screen->physicalDotsPerInchY());
never executed: return qRound(screen->physicalDotsPerInchY());
0
162 break;
never executed: break;
0
163 case PdmDevicePixelRatio:
never executed: case PdmDevicePixelRatio:
0
164 return int(QWindow::devicePixelRatio());
never executed: return int(QWindow::devicePixelRatio());
0
165 break;
dead code: break;
-
166 case PdmDevicePixelRatioScaled:
never executed: case PdmDevicePixelRatioScaled:
0
167 return int(QWindow::devicePixelRatio() * devicePixelRatioFScale());
never executed: return int(QWindow::devicePixelRatio() * devicePixelRatioFScale());
0
168 break;
dead code: break;
-
169 default:
never executed: default:
0
170 break;
never executed: break;
0
171 }-
172-
173 return QPaintDevice::metric(metric);
never executed: return QPaintDevice::metric(metric);
0
174}-
175-
176/*!-
177 \internal-
178 */-
179void QPaintDeviceWindow::exposeEvent(QExposeEvent *exposeEvent)-
180{-
181 Q_UNUSED(exposeEvent);-
182 Q_D(QPaintDeviceWindow);-
183 if (isExposed()) {
isExposed()Description
TRUEnever evaluated
FALSEnever evaluated
0
184 d->markWindowAsDirty();-
185 // Do not rely on exposeEvent->region() as it has some issues for the-
186 // time being, namely that it is sometimes in local coordinates,-
187 // sometimes relative to the parent, depending on the platform plugin.-
188 // We require local coords here.-
189 d->doFlush(QRect(QPoint(0, 0), size()));-
190 } else if (!d->dirtyRegion.isEmpty()) {
never executed: end of block
!d->dirtyRegion.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
191 // Updates while non-exposed were ignored. Schedule an update now.-
192 requestUpdate();-
193 }
never executed: end of block
0
194}
never executed: end of block
0
195-
196/*!-
197 \internal-
198 */-
199bool QPaintDeviceWindow::event(QEvent *event)-
200{-
201 Q_D(QPaintDeviceWindow);-
202-
203 if (event->type() == QEvent::UpdateRequest) {
event->type() ...:UpdateRequestDescription
TRUEnever evaluated
FALSEnever evaluated
0
204 if (handle()) // platform window may be gone when the window is closed during app exit
handle()Description
TRUEnever evaluated
FALSEnever evaluated
0
205 d->handleUpdateEvent();
never executed: d->handleUpdateEvent();
0
206 return true;
never executed: return true;
0
207 }-
208-
209 return QWindow::event(event);
never executed: return QWindow::event(event);
0
210}-
211-
212/*!-
213 \internal-
214 */-
215QPaintDeviceWindow::QPaintDeviceWindow(QPaintDeviceWindowPrivate &dd, QWindow *parent)-
216 : QWindow(dd, parent)-
217{-
218}
never executed: end of block
0
219-
220/*!-
221 \internal-
222 */-
223QPaintEngine *QPaintDeviceWindow::paintEngine() const-
224{-
225 return 0;
never executed: return 0;
0
226}-
227-
228QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9