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
4#ifndef QDRAWUTIL_H
5#define QDRAWUTIL_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtCore/qnamespace.h>
9#include <QtCore/qstring.h> // char*->QString conversion
10#include <QtCore/qmargins.h>
11#include <QtGui/qpixmap.h>
12QT_BEGIN_NAMESPACE
13
14
15class QPainter;
16class QPalette;
17class QPoint;
18class QColor;
19class QBrush;
20class QRect;
21
22//
23// Standard shade drawing
24//
25
26Q_WIDGETS_EXPORT void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
27 const QPalette &pal, bool sunken = true,
28 int lineWidth = 1, int midLineWidth = 0);
29
30Q_WIDGETS_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
31 const QPalette &pal, bool sunken = true,
32 int lineWidth = 1, int midLineWidth = 0);
33
34Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
35 const QPalette &pal, bool sunken = false,
36 int lineWidth = 1, int midLineWidth = 0,
37 const QBrush *fill = nullptr);
38
39Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r,
40 const QPalette &pal, bool sunken = false,
41 int lineWidth = 1, int midLineWidth = 0,
42 const QBrush *fill = nullptr);
43
44Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
45 const QPalette &pal, bool sunken = false,
46 int lineWidth = 1, const QBrush *fill = nullptr);
47
48Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r,
49 const QPalette &pal, bool sunken = false,
50 int lineWidth = 1, const QBrush *fill = nullptr);
51
52Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
53 const QPalette &pal, bool sunken = false,
54 const QBrush *fill = nullptr);
55
56Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
57 const QPalette &pal, bool sunken = false,
58 const QBrush *fill = nullptr);
59
60Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
61 const QPalette &pal, bool sunken = false,
62 const QBrush *fill = nullptr);
63
64Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
65 const QPalette &pal, bool sunken = false,
66 const QBrush *fill = nullptr);
67
68Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
69 int lineWidth = 1, const QBrush *fill = nullptr);
70
71Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
72 int lineWidth = 1, const QBrush *fill = nullptr);
73
74Q_WIDGETS_EXPORT void qDrawPlainRoundedRect(QPainter *p, int x, int y, int w, int h,
75 qreal rx, qreal ry, const QColor &, int lineWidth = 1,
76 const QBrush *fill = nullptr);
77
78inline void qDrawPlainRoundedRect(QPainter *painter, const QRect& rect, qreal rx, qreal ry,
79 const QColor &lineColor, int lineWidth = 1,
80 const QBrush *fill = nullptr)
81{
82 qDrawPlainRoundedRect(p: painter, x: rect.x(), y: rect.y(), w: rect.width(), h: rect.height(),
83 rx, ry, lineColor, lineWidth, fill);
84}
85
86
87struct QTileRules
88{
89 inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
90 : horizontal(horizontalRule), vertical(verticalRule) {}
91 inline QTileRules(Qt::TileRule rule = Qt::StretchTile)
92 : horizontal(rule), vertical(rule) {}
93 Qt::TileRule horizontal;
94 Qt::TileRule vertical;
95};
96
97#ifndef Q_QDOC
98// For internal use only.
99namespace QDrawBorderPixmap
100{
101 enum DrawingHint
102 {
103 OpaqueTopLeft = 0x0001,
104 OpaqueTop = 0x0002,
105 OpaqueTopRight = 0x0004,
106 OpaqueLeft = 0x0008,
107 OpaqueCenter = 0x0010,
108 OpaqueRight = 0x0020,
109 OpaqueBottomLeft = 0x0040,
110 OpaqueBottom = 0x0080,
111 OpaqueBottomRight = 0x0100,
112 OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight,
113 OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom,
114 OpaqueFrame = OpaqueCorners | OpaqueEdges,
115 OpaqueAll = OpaqueCenter | OpaqueFrame
116 };
117
118 Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
119}
120#endif
121
122Q_WIDGETS_EXPORT void qDrawBorderPixmap(QPainter *painter,
123 const QRect &targetRect,
124 const QMargins &targetMargins,
125 const QPixmap &pixmap,
126 const QRect &sourceRect,
127 const QMargins &sourceMargins,
128 const QTileRules &rules = QTileRules()
129#ifndef Q_QDOC
130 , QDrawBorderPixmap::DrawingHints hints = QDrawBorderPixmap::DrawingHints()
131#endif
132 );
133
134inline void qDrawBorderPixmap(QPainter *painter,
135 const QRect &target,
136 const QMargins &margins,
137 const QPixmap &pixmap)
138{
139 qDrawBorderPixmap(painter, targetRect: target, targetMargins: margins, pixmap, sourceRect: pixmap.rect(), sourceMargins: margins);
140}
141
142QT_END_NAMESPACE
143
144#endif // QDRAWUTIL_H
145

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtbase/src/widgets/styles/qdrawutil.h