1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtGui module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
45 #include <QtCore/qnamespace.h>
46 #include <QtCore/qstring.h> // char*->QString conversion
47 #include <QtCore/qmargins.h>
48 #include <QtGui/qpixmap.h>
66 // Standard shade drawing
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);
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);
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);
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);
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);
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);
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);
99 Q_GUI_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
100 const QPalette &pal, bool sunken = false,
101 const QBrush *fill = 0);
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);
107 Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
108 const QPalette &pal, bool sunken = false,
109 const QBrush *fill = 0);
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);
114 Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
115 int lineWidth = 1, const QBrush *fill = 0);
120 // Use QStyle::itemRect(), QStyle::drawItem() and QStyle::drawArrow() instead.
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);
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);
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);
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;
147 // For internal use only.
148 namespace QDrawBorderPixmap
152 OpaqueTopLeft = 0x0001,
154 OpaqueTopRight = 0x0004,
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
167 Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
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()
179 , QDrawBorderPixmap::DrawingHints hints = 0
183 inline void qDrawBorderPixmap(QPainter *painter,
185 const QMargins &margins,
186 const QPixmap &pixmap)
188 qDrawBorderPixmap(painter, target, margins, pixmap, pixmap.rect(), margins);
195 #endif // QDRAWUTIL_H