author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt3Support module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
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 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "q3painter.h" |
|
43 |
#include "qpaintengine.h" |
|
44 |
||
45 |
#include <private/qpainter_p.h> |
|
46 |
||
47 |
QT_BEGIN_NAMESPACE |
|
48 |
||
49 |
/*! |
|
50 |
\class Q3Painter |
|
51 |
\brief The Q3Painter class is a Qt 3 compatibility wrapper for QPainter. |
|
52 |
||
53 |
\compat |
|
54 |
||
55 |
Prior to Qt 4, QPainter specialized the pen drawing for rectangle |
|
56 |
based functions (in particular: drawRect, drawEllipse, |
|
57 |
drawRoundRect, drawArc, drawChord and drawPie). When stroking a |
|
58 |
rectangle of width 10, the pen would draw a rectangle of width 10. |
|
59 |
Drawing a polygon defined by the corner points of the same |
|
60 |
rectangle the stroke would have a width of 11. |
|
61 |
||
62 |
The reason for this is best explained using the picture below: |
|
63 |
||
64 |
\img q3painter_rationale.png |
|
65 |
||
66 |
As we can see, stroking the rectangle so it gets a width of 10, |
|
67 |
means the pen is drawn on a rectangle on width 9. The polygon, |
|
68 |
however follows a consistent model. |
|
69 |
||
70 |
In Qt 4, all rectangle based functions have changed to follow the |
|
71 |
polygon approach, which means that the rectangle defines the size of |
|
72 |
the fill, and the pen follows the edges of the shape. For pen widths |
|
73 |
of 0 and 1 this means that the stroke will be inside the shape on the |
|
74 |
left and the top and outside on the bottom and right. |
|
75 |
||
76 |
The reason for the change in Qt 4 is so that we provide consistency |
|
77 |
for all drawing functions even with complex transformations. |
|
78 |
*/ |
|
79 |
||
80 |
/*! |
|
81 |
\fn Q3Painter::Q3Painter() |
|
82 |
||
83 |
Constructs a Q3Painter. |
|
84 |
*/ |
|
85 |
||
86 |
/*! |
|
87 |
\fn Q3Painter::Q3Painter(QPaintDevice *pdev) |
|
88 |
||
89 |
Constructs a Q3Painter that operates on device \a pdev. |
|
90 |
*/ |
|
91 |
||
92 |
/*! |
|
93 |
\internal |
|
94 |
*/ |
|
95 |
QRect Q3Painter::adjustedRectangle(const QRect &r) |
|
96 |
{ |
|
97 |
QRect rect = r.normalized(); |
|
98 |
int subtract = d_func()->rectSubtraction(); |
|
99 |
if (subtract != 0) |
|
100 |
rect.setSize(QSize(rect.width() - subtract, rect.height() - subtract)); |
|
101 |
return rect; |
|
102 |
} |
|
103 |
||
104 |
||
105 |
/*! |
|
106 |
\fn void Q3Painter::drawRect(int x, int y, int w, int h) |
|
107 |
||
108 |
\overload |
|
109 |
||
110 |
Draws the rectangle that fits inside the bounds specified by \a x, |
|
111 |
\a y, \a w and \a h using the current pen and brush. |
|
112 |
*/ |
|
113 |
||
114 |
/*! |
|
115 |
\fn void Q3Painter::drawRect(const QRect &r) |
|
116 |
||
117 |
Draws a rectangle that fits inside the rectangle \a r using the |
|
118 |
current pen and brush. |
|
119 |
||
120 |
*/ |
|
121 |
||
122 |
||
123 |
||
124 |
/*! |
|
125 |
\fn Q3Painter::drawEllipse(const QRect &r) |
|
126 |
||
127 |
Draws the ellipse that fits inside the bounds \a r using the |
|
128 |
current pen and brush. |
|
129 |
||
130 |
*/ |
|
131 |
||
132 |
/*! |
|
133 |
\fn Q3Painter::drawEllipse(int x, int y, int width, int height) |
|
134 |
||
135 |
\overload |
|
136 |
||
137 |
Draws an ellipse that fits inside the bounds specified by \a x, |
|
138 |
\a y, \a width and \a height using the current pen and brush. |
|
139 |
||
140 |
*/ |
|
141 |
||
142 |
/*! |
|
143 |
\fn void Q3Painter::drawPie(int x, int y, int w, int h, int |
|
144 |
startAngle, int spanAngle) |
|
145 |
||
146 |
\overload |
|
147 |
||
148 |
Draws a pie segment that fits inside the bounds (\a{x}, \a{y}, |
|
149 |
\a{w}, \a{h}) with the given \a startAngle and \a spanAngle. |
|
150 |
*/ |
|
151 |
||
152 |
/*! |
|
153 |
\fn void Q3Painter::drawPie(const QRect &r, int a, int alen) |
|
154 |
||
155 |
Draws a pie defined by the rectangle \a r, the start angle \a a |
|
156 |
and the arc length \a alen. |
|
157 |
||
158 |
The pie is filled with the current brush(). |
|
159 |
||
160 |
The angles \a a and \a alen are 1/16th of a degree, i.e. a full |
|
161 |
circle equals 5760 (16*360). Positive values of \a a and \a alen |
|
162 |
mean counter-clockwise while negative values mean the clockwise |
|
163 |
direction. Zero degrees is at the 3 o'clock position. |
|
164 |
||
165 |
\sa drawArc(), drawChord() |
|
166 |
*/ |
|
167 |
||
168 |
/*! |
|
169 |
\fn void Q3Painter::drawArc(int x, int y, int w, int h, int |
|
170 |
startAngle, int spanAngle) |
|
171 |
||
172 |
\overload |
|
173 |
||
174 |
Draws the arc that fits inside the rectangle (\a{x}, \a{y}, \a{w}, |
|
175 |
\a{h}), with the given \a startAngle and \a spanAngle. |
|
176 |
*/ |
|
177 |
||
178 |
/*! |
|
179 |
\fn void Q3Painter::drawArc(const QRect &r, int a, int alen) |
|
180 |
||
181 |
Draws an arc defined by the rectangle \a r, the start angle \a a |
|
182 |
and the arc length \a alen. |
|
183 |
||
184 |
The angles \a a and \a alen are 1/16th of a degree, i.e. a full |
|
185 |
circle equals 5760 (16*360). Positive values of \a a and \a alen |
|
186 |
mean counter-clockwise while negative values mean the clockwise |
|
187 |
direction. Zero degrees is at the 3 o'clock position. |
|
188 |
||
189 |
Example: |
|
190 |
\snippet doc/src/snippets/code/src_qt3support_painting_q3painter.cpp 0 |
|
191 |
||
192 |
\sa drawPie(), drawChord() |
|
193 |
*/ |
|
194 |
||
195 |
/*! |
|
196 |
\fn void Q3Painter::drawChord(int x, int y, int w, int h, int |
|
197 |
startAngle, int spanAngle) |
|
198 |
||
199 |
\overload |
|
200 |
||
201 |
Draws a chord that fits inside the rectangle (\a{x}, \a{y}, \a{w}, |
|
202 |
\a{h}) with the given \a startAngle and \a spanAngle. |
|
203 |
*/ |
|
204 |
||
205 |
||
206 |
/*! |
|
207 |
\fn void Q3Painter::drawChord(const QRect &r, int a, int alen) |
|
208 |
||
209 |
Draws a chord defined by the rectangle \a r, the start angle \a a |
|
210 |
and the arc length \a alen. |
|
211 |
||
212 |
The chord is filled with the current brush(). |
|
213 |
||
214 |
The angles \a a and \a alen are 1/16th of a degree, i.e. a full |
|
215 |
circle equals 5760 (16*360). Positive values of \a a and \a alen |
|
216 |
mean counter-clockwise while negative values mean the clockwise |
|
217 |
direction. Zero degrees is at the 3 o'clock position. |
|
218 |
||
219 |
\sa drawArc(), drawPie() |
|
220 |
*/ |
|
221 |
||
222 |
/*! |
|
223 |
\fn void Q3Painter::drawRoundRect(const QRect &r, int xrnd, int yrnd) |
|
224 |
||
225 |
Draws a rounded rect that fits into the bounds \a r using the current |
|
226 |
pen and brush. The parameters \a xrnd and \a yrnd specifies the roundness |
|
227 |
in x and y direction. |
|
228 |
*/ |
|
229 |
||
230 |
/*! |
|
231 |
\fn void Q3Painter::drawRoundRect(int x, int y, int w, int h, int xrnd, int yrnd) |
|
232 |
||
233 |
\overload |
|
234 |
||
235 |
Draws a rounded rect that fits into the bounds \a x, \a y, \a w |
|
236 |
and \a h using the current pen and brush. The parameters \a xrnd |
|
237 |
and \a yrnd specifies the roundness in x and y direction. |
|
238 |
*/ |
|
239 |
||
240 |
QT_END_NAMESPACE |