Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qpaintdevicewindow_p.h
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// Qt-Security score:significant reason:default
4
5#ifndef QPAINTDEVICEWINDOW_P_H
6#define QPAINTDEVICEWINDOW_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtGui/private/qtguiglobal_p.h>
20#include <QtGui/QPaintDeviceWindow>
21#include <QtCore/QCoreApplication>
22#include <QtGui/private/qwindow_p.h>
23#include <QtGui/QPaintEvent>
24
26
27class Q_GUI_EXPORT QPaintDeviceWindowPrivate : public QWindowPrivate
28{
29 Q_DECLARE_PUBLIC(QPaintDeviceWindow)
30
31public:
32 QPaintDeviceWindowPrivate();
33 ~QPaintDeviceWindowPrivate() override;
34
35 virtual void handleResizeEvent() {}
36
37 virtual void beginPaint(const QRegion &region)
38 {
39 Q_UNUSED(region);
40 }
41
42 virtual void endPaint()
43 {
44 }
45
46 virtual void flush(const QRegion &region)
47 {
48 Q_UNUSED(region);
49 }
50
51 bool paint(const QRegion &region)
52 {
53 Q_Q(QPaintDeviceWindow);
54 QRegion toPaint = region & dirtyRegion;
55 if (toPaint.isEmpty())
56 return false;
57
58 // Clear the region now. The overridden functions may call update().
59 dirtyRegion -= toPaint;
60
61 beginPaint(toPaint);
62
63 QPaintEvent paintEvent(toPaint);
64 q->paintEvent(&paintEvent);
65
66 endPaint();
67
68 return true;
69 }
70
71 void doFlush(const QRegion &region)
72 {
73 QRegion toFlush = region;
74 if (paint(toFlush))
75 flush(toFlush);
76 }
77
78 void handleUpdateEvent()
79 {
80 if (dirtyRegion.isEmpty())
81 return;
82 doFlush(dirtyRegion);
83 }
84
85 void markWindowAsDirty()
86 {
87 Q_Q(QPaintDeviceWindow);
88 dirtyRegion = QRect(QPoint(0, 0), q->size());
89 }
90
91private:
92 QRegion dirtyRegion;
93};
94
95
96QT_END_NAMESPACE
97
98#endif //QPAINTDEVICEWINDOW_P_H
Combined button and popup list for selecting options.