Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 09:22:38

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 // Qt-Security score:significant reason:default
0004 
0005 #ifndef QDRAWUTIL_H
0006 #define QDRAWUTIL_H
0007 
0008 #include <QtWidgets/qtwidgetsglobal.h>
0009 #include <QtCore/qnamespace.h>
0010 #include <QtCore/qstring.h> // char*->QString conversion
0011 #include <QtCore/qmargins.h>
0012 #include <QtGui/qpixmap.h>
0013 QT_BEGIN_NAMESPACE
0014 
0015 
0016 class QPainter;
0017 class QPalette;
0018 class QPoint;
0019 class QColor;
0020 class QBrush;
0021 class QRect;
0022 
0023 //
0024 // Standard shade drawing
0025 //
0026 
0027 Q_WIDGETS_EXPORT void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
0028                               const QPalette &pal, bool sunken = true,
0029                               int lineWidth = 1, int midLineWidth = 0);
0030 
0031 Q_WIDGETS_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
0032                               const QPalette &pal, bool sunken = true,
0033                               int lineWidth = 1, int midLineWidth = 0);
0034 
0035 Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
0036                               const QPalette &pal, bool sunken = false,
0037                               int lineWidth = 1, int midLineWidth = 0,
0038                               const QBrush *fill = nullptr);
0039 
0040 Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r,
0041                               const QPalette &pal, bool sunken = false,
0042                               int lineWidth = 1, int midLineWidth = 0,
0043                               const QBrush *fill = nullptr);
0044 
0045 Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
0046                                const QPalette &pal, bool sunken = false,
0047                                int lineWidth = 1, const QBrush *fill = nullptr);
0048 
0049 Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r,
0050                                const QPalette &pal, bool sunken = false,
0051                                int lineWidth = 1, const QBrush *fill = nullptr);
0052 
0053 Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
0054                               const QPalette &pal, bool sunken = false,
0055                               const QBrush *fill = nullptr);
0056 
0057 Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
0058                               const QPalette &pal, bool sunken = false,
0059                               const QBrush *fill = nullptr);
0060 
0061 Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
0062                               const QPalette &pal, bool sunken = false,
0063                              const QBrush *fill = nullptr);
0064 
0065 Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
0066                               const QPalette &pal, bool sunken = false,
0067                              const QBrush *fill = nullptr);
0068 
0069 Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
0070                               int lineWidth = 1, const QBrush *fill = nullptr);
0071 
0072 Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
0073                               int lineWidth = 1, const QBrush *fill = nullptr);
0074 
0075 Q_WIDGETS_EXPORT void qDrawPlainRoundedRect(QPainter *p, int x, int y, int w, int h,
0076                               qreal rx, qreal ry, const QColor &, int lineWidth = 1,
0077                               const QBrush *fill = nullptr);
0078 
0079 inline void qDrawPlainRoundedRect(QPainter *painter, const QRect& rect, qreal rx, qreal ry,
0080                                   const QColor &lineColor, int lineWidth = 1,
0081                                   const QBrush *fill = nullptr)
0082 {
0083     qDrawPlainRoundedRect(painter, rect.x(), rect.y(), rect.width(), rect.height(),
0084                           rx, ry, lineColor, lineWidth, fill);
0085 }
0086 
0087 
0088 struct QTileRules
0089 {
0090     inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
0091             : horizontal(horizontalRule), vertical(verticalRule) {}
0092     inline QTileRules(Qt::TileRule rule = Qt::StretchTile)
0093             : horizontal(rule), vertical(rule) {}
0094     Qt::TileRule horizontal;
0095     Qt::TileRule vertical;
0096 };
0097 
0098 #ifndef Q_QDOC
0099 // For internal use only.
0100 namespace QDrawBorderPixmap
0101 {
0102     enum DrawingHint
0103     {
0104         OpaqueTopLeft = 0x0001,
0105         OpaqueTop = 0x0002,
0106         OpaqueTopRight = 0x0004,
0107         OpaqueLeft = 0x0008,
0108         OpaqueCenter = 0x0010,
0109         OpaqueRight = 0x0020,
0110         OpaqueBottomLeft = 0x0040,
0111         OpaqueBottom = 0x0080,
0112         OpaqueBottomRight = 0x0100,
0113         OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight,
0114         OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom,
0115         OpaqueFrame = OpaqueCorners | OpaqueEdges,
0116         OpaqueAll = OpaqueCenter | OpaqueFrame
0117     };
0118 
0119     Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
0120 }
0121 #endif
0122 
0123 Q_WIDGETS_EXPORT void qDrawBorderPixmap(QPainter *painter,
0124                                     const QRect &targetRect,
0125                                     const QMargins &targetMargins,
0126                                     const QPixmap &pixmap,
0127                                     const QRect &sourceRect,
0128                                     const QMargins &sourceMargins,
0129                                     const QTileRules &rules = QTileRules()
0130 #ifndef Q_QDOC
0131                                     , QDrawBorderPixmap::DrawingHints hints = QDrawBorderPixmap::DrawingHints()
0132 #endif
0133                                     );
0134 
0135 inline void qDrawBorderPixmap(QPainter *painter,
0136                                            const QRect &target,
0137                                            const QMargins &margins,
0138                                            const QPixmap &pixmap)
0139 {
0140     qDrawBorderPixmap(painter, target, margins, pixmap, pixmap.rect(), margins);
0141 }
0142 
0143 QT_END_NAMESPACE
0144 
0145 #endif // QDRAWUTIL_H