| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at qt-info@nokia.com.
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #ifndef QDRAWUTIL_H
|
|---|
| 43 | #define QDRAWUTIL_H
|
|---|
| 44 |
|
|---|
| 45 | #include <QtCore/qnamespace.h>
|
|---|
| 46 | #include <QtCore/qstring.h> // char*->QString conversion
|
|---|
| 47 | #include <QtCore/qmargins.h>
|
|---|
| 48 | #include <QtGui/qpixmap.h>
|
|---|
| 49 | QT_BEGIN_HEADER
|
|---|
| 50 |
|
|---|
| 51 | QT_BEGIN_NAMESPACE
|
|---|
| 52 |
|
|---|
| 53 | QT_MODULE(Gui)
|
|---|
| 54 |
|
|---|
| 55 | class QPainter;
|
|---|
| 56 | #ifndef QT3_SUPPORT
|
|---|
| 57 | class QColorGroup;
|
|---|
| 58 | #endif
|
|---|
| 59 | class QPalette;
|
|---|
| 60 | class QPoint;
|
|---|
| 61 | class QColor;
|
|---|
| 62 | class QBrush;
|
|---|
| 63 | class QRect;
|
|---|
| 64 |
|
|---|
| 65 | //
|
|---|
| 66 | // Standard shade drawing
|
|---|
| 67 | //
|
|---|
| 68 |
|
|---|
| 69 | Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
|
|---|
| 70 | const QPalette &pal, bool sunken = true,
|
|---|
| 71 | int lineWidth = 1, int midLineWidth = 0);
|
|---|
| 72 |
|
|---|
| 73 | Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
|
|---|
| 74 | const QPalette &pal, bool sunken = true,
|
|---|
| 75 | int lineWidth = 1, int midLineWidth = 0);
|
|---|
| 76 |
|
|---|
| 77 | Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
|
|---|
| 78 | const QPalette &pal, bool sunken = false,
|
|---|
| 79 | int lineWidth = 1, int midLineWidth = 0,
|
|---|
| 80 | const QBrush *fill = 0);
|
|---|
| 81 |
|
|---|
| 82 | Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r,
|
|---|
| 83 | const QPalette &pal, bool sunken = false,
|
|---|
| 84 | int lineWidth = 1, int midLineWidth = 0,
|
|---|
| 85 | const QBrush *fill = 0);
|
|---|
| 86 |
|
|---|
| 87 | Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
|
|---|
| 88 | const QPalette &pal, bool sunken = false,
|
|---|
| 89 | int lineWidth = 1, const QBrush *fill = 0);
|
|---|
| 90 |
|
|---|
| 91 | Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r,
|
|---|
| 92 | const QPalette &pal, bool sunken = false,
|
|---|
| 93 | int lineWidth = 1, const QBrush *fill = 0);
|
|---|
| 94 |
|
|---|
| 95 | Q_GUI_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
|
|---|
| 96 | const QPalette &pal, bool sunken = false,
|
|---|
| 97 | const QBrush *fill = 0);
|
|---|
| 98 |
|
|---|
| 99 | Q_GUI_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
|
|---|
| 100 | const QPalette &pal, bool sunken = false,
|
|---|
| 101 | const QBrush *fill = 0);
|
|---|
| 102 |
|
|---|
| 103 | Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
|
|---|
| 104 | const QPalette &pal, bool sunken = false,
|
|---|
| 105 | const QBrush *fill = 0);
|
|---|
| 106 |
|
|---|
| 107 | Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
|
|---|
| 108 | const QPalette &pal, bool sunken = false,
|
|---|
| 109 | const QBrush *fill = 0);
|
|---|
| 110 |
|
|---|
| 111 | Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
|
|---|
| 112 | int lineWidth = 1, const QBrush *fill = 0);
|
|---|
| 113 |
|
|---|
| 114 | Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
|
|---|
| 115 | int lineWidth = 1, const QBrush *fill = 0);
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 | #ifdef QT3_SUPPORT
|
|---|
| 119 | //
|
|---|
| 120 | // Use QStyle::itemRect(), QStyle::drawItem() and QStyle::drawArrow() instead.
|
|---|
| 121 | //
|
|---|
| 122 | Q_GUI_EXPORT QT3_SUPPORT QRect qItemRect(QPainter *p, Qt::GUIStyle gs, int x, int y, int w, int h,
|
|---|
| 123 | int flags, bool enabled,
|
|---|
| 124 | const QPixmap *pixmap, const QString& text, int len=-1);
|
|---|
| 125 |
|
|---|
| 126 | Q_GUI_EXPORT QT3_SUPPORT void qDrawItem(QPainter *p, Qt::GUIStyle gs, int x, int y, int w, int h,
|
|---|
| 127 | int flags, const QPalette &pal, bool enabled,
|
|---|
| 128 | const QPixmap *pixmap, const QString& text,
|
|---|
| 129 | int len=-1, const QColor* penColor = 0);
|
|---|
| 130 |
|
|---|
| 131 | Q_GUI_EXPORT QT3_SUPPORT void qDrawArrow(QPainter *p, Qt::ArrowType type, Qt::GUIStyle style, bool down,
|
|---|
| 132 | int x, int y, int w, int h,
|
|---|
| 133 | const QPalette &pal, bool enabled);
|
|---|
| 134 | #endif
|
|---|
| 135 |
|
|---|
| 136 | struct QTileRules
|
|---|
| 137 | {
|
|---|
| 138 | inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
|
|---|
| 139 | : horizontal(horizontalRule), vertical(verticalRule) {}
|
|---|
| 140 | inline QTileRules(Qt::TileRule rule = Qt::StretchTile)
|
|---|
| 141 | : horizontal(rule), vertical(rule) {}
|
|---|
| 142 | Qt::TileRule horizontal;
|
|---|
| 143 | Qt::TileRule vertical;
|
|---|
| 144 | };
|
|---|
| 145 |
|
|---|
| 146 | #ifndef Q_QDOC
|
|---|
| 147 | // For internal use only.
|
|---|
| 148 | namespace QDrawBorderPixmap
|
|---|
| 149 | {
|
|---|
| 150 | enum DrawingHint
|
|---|
| 151 | {
|
|---|
| 152 | OpaqueTopLeft = 0x0001,
|
|---|
| 153 | OpaqueTop = 0x0002,
|
|---|
| 154 | OpaqueTopRight = 0x0004,
|
|---|
| 155 | OpaqueLeft = 0x0008,
|
|---|
| 156 | OpaqueCenter = 0x0010,
|
|---|
| 157 | OpaqueRight = 0x0020,
|
|---|
| 158 | OpaqueBottomLeft = 0x0040,
|
|---|
| 159 | OpaqueBottom = 0x0080,
|
|---|
| 160 | OpaqueBottomRight = 0x0100,
|
|---|
| 161 | OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight,
|
|---|
| 162 | OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom,
|
|---|
| 163 | OpaqueFrame = OpaqueCorners | OpaqueEdges,
|
|---|
| 164 | OpaqueAll = OpaqueCenter | OpaqueFrame
|
|---|
| 165 | };
|
|---|
| 166 |
|
|---|
| 167 | Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
|
|---|
| 168 | }
|
|---|
| 169 | #endif
|
|---|
| 170 |
|
|---|
| 171 | Q_GUI_EXPORT void qDrawBorderPixmap(QPainter *painter,
|
|---|
| 172 | const QRect &targetRect,
|
|---|
| 173 | const QMargins &targetMargins,
|
|---|
| 174 | const QPixmap &pixmap,
|
|---|
| 175 | const QRect &sourceRect,
|
|---|
| 176 | const QMargins &sourceMargins,
|
|---|
| 177 | const QTileRules &rules = QTileRules()
|
|---|
| 178 | #ifndef Q_QDOC
|
|---|
| 179 | , QDrawBorderPixmap::DrawingHints hints = 0
|
|---|
| 180 | #endif
|
|---|
| 181 | );
|
|---|
| 182 |
|
|---|
| 183 | inline void qDrawBorderPixmap(QPainter *painter,
|
|---|
| 184 | const QRect &target,
|
|---|
| 185 | const QMargins &margins,
|
|---|
| 186 | const QPixmap &pixmap)
|
|---|
| 187 | {
|
|---|
| 188 | qDrawBorderPixmap(painter, target, margins, pixmap, pixmap.rect(), margins);
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | // For internal use only.
|
|---|
| 192 | namespace QDrawPixmaps
|
|---|
| 193 | {
|
|---|
| 194 | struct Data
|
|---|
| 195 | {
|
|---|
| 196 | QPointF point;
|
|---|
| 197 | QRectF source;
|
|---|
| 198 | qreal scaleX;
|
|---|
| 199 | qreal scaleY;
|
|---|
| 200 | qreal rotation;
|
|---|
| 201 | qreal opacity;
|
|---|
| 202 | };
|
|---|
| 203 |
|
|---|
| 204 | enum DrawingHint
|
|---|
| 205 | {
|
|---|
| 206 | OpaqueHint = 0x01
|
|---|
| 207 | };
|
|---|
| 208 |
|
|---|
| 209 | Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | // This function is private and may change without notice. Do not use outside Qt!!!
|
|---|
| 213 | Q_GUI_EXPORT void qDrawPixmaps(QPainter *painter, const QDrawPixmaps::Data *drawingData,
|
|---|
| 214 | int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints = 0);
|
|---|
| 215 |
|
|---|
| 216 | QT_END_NAMESPACE
|
|---|
| 217 |
|
|---|
| 218 | QT_END_HEADER
|
|---|
| 219 |
|
|---|
| 220 | #endif // QDRAWUTIL_H
|
|---|