File: qregion.html

package info (click to toggle)
qt-embedded 2.3.2-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 68,608 kB
  • ctags: 45,998
  • sloc: cpp: 276,654; ansic: 71,987; makefile: 29,074; sh: 12,305; yacc: 2,465; python: 1,863; perl: 481; lex: 480; xml: 68; lisp: 15
file content (267 lines) | stat: -rw-r--r-- 18,203 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QRegion Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">

<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>

<h1 align=center>QRegion Class Reference</h1><br clear="all">
<p>
The QRegion class specifies a clip region for a painter.
<a href="#details">More...</a>
<p>
<code>#include &lt;<a href="qregion-h.html">qregion.h</a>&gt;</code>
<p><a href="qregion-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn">enum<a href="#RegionType"><b>RegionType</b></a>{Rectangle, Ellipse}</div>
<li><div class="fn"><a href="#a80dd8"><b>QRegion</b></a>()</div>
<li><div class="fn"><a href="#b666cf"><b>QRegion</b></a>(intx, inty, intw, inth, RegionType=Rectangle)</div>
<li><div class="fn"><b>QRegion</b>(constQRect&amp;, RegionType=Rectangle)</div>
<li><div class="fn"><a href="#304ab0"><b>QRegion</b></a>(constQPointArray&amp;, boolwinding=FALSE)</div>
<li><div class="fn"><a href="#b6e7a9"><b>QRegion</b></a>(constQRegion&amp;)</div>
<li><div class="fn"><a href="#39c9d9"><b>QRegion</b></a>(constQBitmap&amp;)</div>
<li><div class="fn"><a href="#b4b68b"><b>~QRegion</b></a>()</div>
<li><div class="fn">QRegion&amp;<a href="#644768"><b>operator=</b></a>(constQRegion&amp;)</div>
<li><div class="fn">bool<a href="#a2c0d0"><b>isNull</b></a>()const</div>
<li><div class="fn">bool<a href="#507d42"><b>isEmpty</b></a>()const</div>
<li><div class="fn">bool<a href="#ea58e9"><b>contains</b></a>(constQPoint&amp;p)const</div>
<li><div class="fn">bool<a href="#afba2f"><b>contains</b></a>(constQRect&amp;r)const</div>
<li><div class="fn">void<a href="#595875"><b>translate</b></a>(intdx, intdy)</div>
<li><div class="fn">QRegion<a href="#2c10d0"><b>unite</b></a>(constQRegion&amp;)const</div>
<li><div class="fn">QRegion<a href="#28e973"><b>intersect</b></a>(constQRegion&amp;)const</div>
<li><div class="fn">QRegion<a href="#ae007f"><b>subtract</b></a>(constQRegion&amp;)const</div>
<li><div class="fn">QRegion<a href="#d7aa83"><b>eor</b></a>(constQRegion&amp;)const</div>
<li><div class="fn">QRect<a href="#7cb897"><b>boundingRect</b></a>()const</div>
<li><div class="fn">QArray&lt;QRect&gt;<a href="#842bf7"><b>rects</b></a>()const</div>
<li><div class="fn">void<a href="#9c7ecf"><b>setRects</b></a>(constQRect*, int)</div>
<li><div class="fn">QRegion<a href="#4e4832"><b>operator|</b></a>(constQRegion&amp;)const</div>
<li><div class="fn">QRegion<a href="#a61e7d"><b>operator+</b></a>(constQRegion&amp;)const</div>
<li><div class="fn">QRegion<a href="#2ed087"><b>operator&amp;</b></a>(constQRegion&amp;)const</div>
<li><div class="fn">QRegion<a href="#81786a"><b>operator-</b></a>(constQRegion&amp;)const</div>
<li><div class="fn">QRegion<a href="#953473"><b>operator^</b></a>(constQRegion&amp;)const</div>
<li><div class="fn">QRegion&amp;<a href="#0a5795"><b>operator|=</b></a>(constQRegion&amp;)</div>
<li><div class="fn">QRegion&amp;<a href="#d77322"><b>operator+=</b></a>(constQRegion&amp;)</div>
<li><div class="fn">QRegion&amp;<a href="#a6c103"><b>operator&amp;=</b></a>(constQRegion&amp;)</div>
<li><div class="fn">QRegion&amp;<a href="#04eb26"><b>operator-=</b></a>(constQRegion&amp;)</div>
<li><div class="fn">QRegion&amp;<a href="#3db11a"><b>operator^=</b></a>(constQRegion&amp;)</div>
<li><div class="fn">bool<a href="#b6887c"><b>operator==</b></a>(constQRegion&amp;)const</div>
<li><div class="fn">bool<a href="#7c842c"><b>operator!=</b></a>(constQRegion&amp;r)const</div>
</ul>
<h2>Related Functions</h2>
(Note that these are not member functions.)
<ul>
<li>QDataStream &amp; <a href="qregion.html#2179e4"><b>operator&gt;&gt;</b></a> (QDataStream &amp; s, QRegion &amp; r)
<li>QDataStream &amp; <a href="qregion.html#9b85c2"><b>operator&lt;&lt;</b></a> (QDataStream &amp; s, const QRegion &amp; r)
</ul>
<hr><h2><a name="details"></a>Detailed Description</h2>
The QRegion class specifies a clip region for a painter.
<p>
QRegion is used with <a href="qpainter.html#15cc78">QPainter::setClipRegion</a>() to limit the paint area to what
needs to be painted. There is also a <a href="qwidget.html#7569b1">QWidget::repaint</a>() that takes a QRegion parameter.
QRegion is the best tool for reducing flicker.
<p>A region can be created from a rectangle, an ellipse, a polygon or a
bitmap. Complex regions may be created by combining simple regions,
using <a href="#2c10d0">unite</a>(), <a href="#28e973">intersect</a>(), <a href="#ae007f">subtract</a>() or <a href="#d7aa83">eor</a>() (exclusive or). Use
<a href="#595875">translate</a>() to move a region.
<p>You can test if a region <a href="#a2c0d0">isNull</a>(), <a href="#507d42">isEmpty</a>() or if it <a href="#afba2f">contains</a>() 
a <a href="qpoint.html">QPoint</a> or <a href="qrect.html">QRect</a>. The bounding rectangle is given by <a href="#7cb897">boundingRect</a>().
<p>The function <a href="#842bf7">rects</a>() gives a decomposition of the region into rectangles.
<p>Example of using complex regions:
<pre>    void MyWidget::paintEvent( <a href="qpaintevent.html">QPaintEvent</a> * )
    {
        <a href="qpainter.html">QPainter</a> p;                             // our painter
        <a href="qregion.html">QRegion</a> r1( <a href="qrect.html">QRect</a>(100,100,200,80),      // r1 = elliptic region
                    QRegion::Ellipse );
        <a href="qregion.html">QRegion</a> r2( <a href="qrect.html">QRect</a>(100,120,90,30) );     // r2 = rectangular region
        <a href="qregion.html">QRegion</a> r3 = r1.<a href="#28e973">intersect</a>( r2 );        // r3 = intersection
        p.<a href="qpainter.html#02ed5d">begin</a>( this );                        // start painting widget
        p.<a href="qpainter.html#15cc78">setClipRegion</a>( r3 );                  // set clip region
        ...                                     // paint clipped graphics
        p.<a href="qpainter.html#365784">end</a>();                                // painting done
    }
</pre>
<p>QRegion is an <a href="shclass.html">implicitely shared</a> class.
<p>Due to window system limitations, the width and height of a region
is limited to 65535 on Unix/X11.
<p>See also  <a href="qpainter.html#15cc78">QPainter::setClipRegion</a>() and <a href="qpainter.html#898839">QPainter::setClipRect</a>().

<hr><h2>Member Type Documentation</h2>
<h3 class="fn"><a name="RegionType">QRegion::RegionType</a></h3>
Determines the shape of the region to be created.
<ul>
<li><code>Rectangle</code> - the region covers the entire rectangle
<li><code>Ellipse</code> - the region is an ellipse inside the rectangle
</ul>
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="a80dd8"></a>QRegion::QRegion()</h3>
<p>Constructs a null region.
<p>See also  <a href="#a2c0d0">isNull</a>().
<h3 class="fn"><a name="39c9d9"></a>QRegion::QRegion(const<a href="qbitmap.html">QBitmap</a>&amp;bm)</h3>
<p>Constructs a region from the bitmap <em>bm.</em>
<p>The resulting region consists of the pixels in <em>bm</em> that are <code>color1,</code> as if each pixel was a 1 by 1 rectangle.
<p>This constructor may create complex regions that will slow
down painting when used. Note that drawing masked pixmaps
can be done much faster using <a href="qpixmap.html#68a75d">QPixmap::setMask</a>().
<h3 class="fn"><a name="304ab0"></a>QRegion::QRegion(const<a href="qpointarray.html">QPointArray</a>&amp;a, boolwinding=FALSE)</h3>
<p>Constructs a polygon region from the point array <em>a.</em>
<p>If <em>winding</em> is TRUE, the polygon
region is filled using the winding algorithm, otherwise the default
even-odd fill algorithm is used.
<p>This constructor may create complex regions that will slow
down painting when used.
<h3 class="fn"><a name="b6e7a9"></a>QRegion::QRegion(constQRegion&amp;r)</h3>
<p>Constructs a new region which is equal to <em>r.</em>
<h3 class="fn"><a name="b666cf"></a>QRegion::QRegion(intx, inty, intw, inth, <a href="qregion.html#RegionType">RegionType</a>t=Rectangle)</h3>
<p>Constructs a rectangular or elliptic region.
<p>If <em>t</em> is <code>Rectangle,</code> the region is the filled rectangle (<em>x, y, w, h).</em> If <em>t</em> is <code>Ellipse,</code> the region is the filled
ellipse ellipse with center at (<em>x</em> + <em>w</em> / 2, <em>y</em> + <em>h</em> / 2) and 
size (<em>w</em> ,<em>h</em> ).
<h3 class="fn"><a name="b4b68b"></a>QRegion::~QRegion()</h3>
<p>Destructs the region.
<h3 class="fn"><a href="qrect.html">QRect</a><a name="7cb897"></a>QRegion::boundingRect()const</h3>
<p>Returns the bounding rectangle of this region.
An empty region gives a rectangle that is  <a href="qrect.html#3090bd">QRect::isNull</a>().
<h3 class="fn">bool<a name="ea58e9"></a>QRegion::contains(const<a href="qpoint.html">QPoint</a>&amp;p)const</h3>
<p>Returns TRUE if the region contains the point <em>p,</em> or FALSE if <em>p</em> is
outside the region.
<h3 class="fn">bool<a name="afba2f"></a>QRegion::contains(const<a href="qrect.html">QRect</a>&amp;r)const</h3>
<p>Returns TRUE if the region overlaps the rectangle <em>r,</em> or FALSE if <em>r</em> is
completely outside the region.
<h3 class="fn">QRegion<a name="d7aa83"></a>QRegion::eor(constQRegion&amp;r)const</h3>
<p>Returns a region which is the exclusive or (XOR) of this region and <em>r.</em>
<p><img src=rxor.png>
<p>The figure shows the exclusive or of two elliptical regions.
<h3 class="fn">QRegion<a name="28e973"></a>QRegion::intersect(constQRegion&amp;r)const</h3>
<p>Returns a region which is the intersection of this region and <em>r.</em>
<p><img src=rintersect.png>
<p>The figure shows the intersection of two elliptical regions.
<h3 class="fn">bool<a name="507d42"></a>QRegion::isEmpty()const</h3>
<p>Returns TRUE if the region is empty, or FALSE if it is non-empty.
An empty region is a region that contains no points.
<p>Example:
<pre>    <a href="qregion.html">QRegion</a> r1( 10, 10, 20, 20 );
    <a href="qregion.html">QRegion</a> r2( 40, 40, 20, 20 );
    <a href="qregion.html">QRegion</a> r3;
    r1.<a href="#a2c0d0">isNull</a>();                // FALSE
    r1.<a href="#507d42">isEmpty</a>();               // FALSE
    r3.<a href="#a2c0d0">isNull</a>();                // TRUE
    r3.<a href="#507d42">isEmpty</a>();               // TRUE
    r3 = r1.<a href="#28e973">intersect</a>( r2 );    // r3 = intersection of r1 and r2
    r3.<a href="#a2c0d0">isNull</a>();                // FALSE
    r3.<a href="#507d42">isEmpty</a>();               // TRUE
    r3 = r1.<a href="#2c10d0">unite</a>( r2 );        // r3 = union of r1 and r2
    r3.<a href="#a2c0d0">isNull</a>();                // FALSE
    r3.<a href="#507d42">isEmpty</a>();               // FALSE
</pre>
<p>See also  <a href="#a2c0d0">isNull</a>().
<h3 class="fn">bool<a name="a2c0d0"></a>QRegion::isNull()const</h3>
<p>Returns TRUE if the region is a null region, otherwise FALSE.
<p>A null region is a region that has not been initialized. A
null region is always empty.
<p>See also  <a href="#507d42">isEmpty</a>().
<h3 class="fn">bool<a name="7c842c"></a>QRegion::operator!=(constQRegion&amp;r)const</h3>
<p>Returns TRUE if the region is different from <em>r,</em> or FALSE if the regions
are equal.
<h3 class="fn">QRegion<a name="2ed087"></a>QRegion::operator&amp;(constQRegion&amp;r)const</h3>
<p><code>r1&r2</code> is equivalent to <code>r1.<a href="#28e973">intersect</a>(r2)</code>
<p>See also  <a href="#28e973">intersect</a>().
<h3 class="fn">QRegion&amp;<a name="a6c103"></a>QRegion::operator&amp;=(constQRegion&amp;r)</h3>
<p><code>r1&=r2</code> is equivalent to <code>r1=r1.<a href="#28e973">intersect</a>(r2)</code>
<p>See also  <a href="#28e973">intersect</a>().
<h3 class="fn">QRegion<a name="a61e7d"></a>QRegion::operator+(constQRegion&amp;r)const</h3>
<p><code>r1+r2</code> is equivalent to <code>r1.<a href="#2c10d0">unite</a>(r2)</code>
<p>See also  <a href="#2c10d0">unite</a>() and <a href="#4e4832">operator|</a>().
<h3 class="fn">QRegion&amp;<a name="d77322"></a>QRegion::operator+=(constQRegion&amp;r)</h3>
<p><code>r1+=r2</code> is equivalent to <code>r1=r1.<a href="#2c10d0">unite</a>(r2)</code>
<p>See also  <a href="#28e973">intersect</a>().
<h3 class="fn">QRegion<a name="81786a"></a>QRegion::operator-(constQRegion&amp;r)const</h3>
<p><code>r1-r2</code> is equivalent to <code>r1.<a href="#ae007f">subtract</a>(r2)</code>
<p>See also  <a href="#ae007f">subtract</a>().
<h3 class="fn">QRegion&amp;<a name="04eb26"></a>QRegion::operator-=(constQRegion&amp;r)</h3>
<p><code>r1-=r2</code> is equivalent to <code>r1=r1.<a href="#ae007f">subtract</a>(r2)</code>
<p>See also  <a href="#ae007f">subtract</a>().
<h3 class="fn">QRegion&amp;<a name="644768"></a>QRegion::operator=(constQRegion&amp;r)</h3>
<p>Assigns <em>r</em> to this region and returns a reference to the
region.
<h3 class="fn">bool<a name="b6887c"></a>QRegion::operator==(constQRegion&amp;r)const</h3>
<p>Returns TRUE if the region is equal to <em>r,</em> or FALSE if the regions are
different.
<h3 class="fn">QRegion<a name="953473"></a>QRegion::operator^(constQRegion&amp;r)const</h3>
<p><code>r1^r2</code> is equivalent to <code>r1.<a href="#d7aa83">eor</a>(r2)</code>
<p>See also  <a href="#d7aa83">eor</a>().
<h3 class="fn">QRegion&amp;<a name="3db11a"></a>QRegion::operator^=(constQRegion&amp;r)</h3>
<p><code>r1^=r2</code> is equivalent to <code>r1=r1.<a href="#d7aa83">eor</a>(r2)</code>
<p>See also  <a href="#d7aa83">eor</a>().
<h3 class="fn">QRegion<a name="4e4832"></a>QRegion::operator|(constQRegion&amp;r)const</h3>
<p><code>r1|r2</code> is equivalent to <code>r1.<a href="#2c10d0">unite</a>(r2)</code>
<p>See also  <a href="#2c10d0">unite</a>() and <a href="#a61e7d">operator+</a>().
<h3 class="fn">QRegion&amp;<a name="0a5795"></a>QRegion::operator|=(constQRegion&amp;r)</h3>
<p><code>r1|=r2</code> is equivalent to <code>r1=r1.<a href="#2c10d0">unite</a>(r2)</code>
<p>See also  <a href="#2c10d0">unite</a>().
<h3 class="fn"><a href="qarray.html">QArray</a>&lt;<a href="qrect.html">QRect</a>&gt;<a name="842bf7"></a>QRegion::rects()const</h3>
<p>Returns an array of non-overlapping rectangles that make up the region.
<p>The union of all the rectangles is equal to the original region.
<h3 class="fn">void<a name="9c7ecf"></a>QRegion::setRects(const<a href="qrect.html">QRect</a>*rects, intnum)</h3>
<p>Sets the region to be the given set of rectangles.  The rectangles
<em>must</em> be optimal Y-X sorted bands as follows:
<ul>
<li> The rectangles must not intersect
<li> All rectangles with a given top coordinate must have the same height.
<li> No two rectangles may abut horizontally (they should be combined
into a single wider rectangle in that case).
<li> The rectangles must be sorted ascendingly by Y as the major sort key
and X as the minor sort key.
</ul>
<h3 class="fn">QRegion<a name="ae007f"></a>QRegion::subtract(constQRegion&amp;r)const</h3>
<p>Returns a region which is <em>r</em> subtracted from this region.
<p><img src=rsubtract.png>
<p>The figure shows the result when the ellipse on the right is subtracted
from the ellipse on the left. (<code>left-right</code> ).
<h3 class="fn">void<a name="595875"></a>QRegion::translate(intdx, intdy)</h3>
<p>Translates (moves) the region <em>dx</em> along the X axis and <em>dy</em> along the Y axis.
<h3 class="fn">QRegion<a name="2c10d0"></a>QRegion::unite(constQRegion&amp;r)const</h3>
<p>Returns a region which is the union of this region and <em>r.</em>
<p><img src=runion.png>
<p>The figure shows the union of two elliptical regions.
<hr><h2>Related Functions</h2>
<h3><a href="qdatastream.html">QDataStream</a> &amp; <a name="2179e4"></a>operator&gt;&gt; (<a href="qdatastream.html">QDataStream</a> &amp; s, QRegion &amp; r)</h3>
<p>Reads a region from the stream <em>s</em> into <em>r</em> and returns a 
reference to the stream.
<p>See also  <a href="datastreamformat.html">Format of the QDataStream operators</a>

<h3><a href="qdatastream.html">QDataStream</a> &amp; <a name="9b85c2"></a>operator&lt;&lt; (<a href="qdatastream.html">QDataStream</a> &amp; s, const QRegion &amp; r)</h3>
<p>Writes the region <em>r</em> to the stream <em>s</em> and returns a reference to 
the stream.
<p>See also  <a href="datastreamformat.html">Format of the QDataStream operators</a>

<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright &copy; 1995-2001
<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright  2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>