~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/q3canvasview.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/qt3support/canvas/q3canvas.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: Q3CanvasView Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">Q3CanvasView Class Reference</h1>
 
21
<p>The Q3CanvasView class provides an on-screen view of a <a href="q3canvas.html">Q3Canvas</a>. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;Q3CanvasView&gt;</pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See the <a href="porting4.html">Porting Guide</a> for more information.</p>
 
23
<p>Part of the <a href="qt3support.html">Qt3Support</a> module.</p>
 
24
<p>Inherits <a href="q3scrollview.html">Q3ScrollView</a>.</p>
 
25
<ul>
 
26
<li><a href="q3canvasview-members.html">List of all members, including inherited members</a></li>
 
27
</ul>
 
28
<a name="public-functions"></a>
 
29
<h3>Public Functions</h3>
 
30
<ul>
 
31
<li><div class="fn"/><b><a href="q3canvasview.html#Q3CanvasView">Q3CanvasView</a></b> ( QWidget * <i>parent</i> = 0, const char * <i>name</i> = 0, Qt::WFlags <i>f</i> = 0 )</li>
 
32
<li><div class="fn"/><b><a href="q3canvasview.html#Q3CanvasView-2">Q3CanvasView</a></b> ( Q3Canvas * <i>canvas</i>, QWidget * <i>parent</i> = 0, const char * <i>name</i> = 0, Qt::WFlags <i>f</i> = 0 )</li>
 
33
<li><div class="fn"/><b><a href="q3canvasview.html#dtor.Q3CanvasView">~Q3CanvasView</a></b> ()</li>
 
34
<li><div class="fn"/>Q3Canvas * <b><a href="q3canvasview.html#canvas">canvas</a></b> () const</li>
 
35
<li><div class="fn"/>const QMatrix &amp; <b><a href="q3canvasview.html#inverseWorldMatrix">inverseWorldMatrix</a></b> () const</li>
 
36
<li><div class="fn"/>void <b><a href="q3canvasview.html#setCanvas">setCanvas</a></b> ( Q3Canvas * <i>canvas</i> )</li>
 
37
<li><div class="fn"/>bool <b><a href="q3canvasview.html#setWorldMatrix">setWorldMatrix</a></b> ( const QMatrix &amp; <i>wm</i> )</li>
 
38
<li><div class="fn"/>const QMatrix &amp; <b><a href="q3canvasview.html#worldMatrix">worldMatrix</a></b> () const</li>
 
39
</ul>
 
40
<ul>
 
41
<li><div class="fn"/>46 public functions inherited from <a href="q3scrollview.html#public-functions">Q3ScrollView</a></li>
 
42
<li><div class="fn"/>4 public functions inherited from <a href="q3frame.html#public-functions">Q3Frame</a></li>
 
43
<li><div class="fn"/>13 public functions inherited from <a href="qframe.html#public-functions">QFrame</a></li>
 
44
<li><div class="fn"/>183 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
 
45
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
46
<li><div class="fn"/>10 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
 
47
</ul>
 
48
<a name="protected-functions"></a>
 
49
<h3>Protected Functions</h3>
 
50
<ul>
 
51
<li><div class="fn"/>virtual void <b><a href="q3canvasview.html#drawContents">drawContents</a></b> ( QPainter * <i>p</i>, int <i>cx</i>, int <i>cy</i>, int <i>cw</i>, int <i>ch</i> )</li>
 
52
<li><div class="fn"/>virtual QSize <b><a href="q3canvasview.html#sizeHint">sizeHint</a></b> () const</li>
 
53
</ul>
 
54
<ul>
 
55
<li><div class="fn"/>17 protected functions inherited from <a href="q3scrollview.html#protected-functions">Q3ScrollView</a></li>
 
56
<li><div class="fn"/>5 protected functions inherited from <a href="q3frame.html#protected-functions">Q3Frame</a></li>
 
57
<li><div class="fn"/>39 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
 
58
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
59
</ul>
 
60
<h3>Additional Inherited Members</h3>
 
61
<ul>
 
62
<li><div class="fn"/>10 properties inherited from <a href="q3scrollview.html#properties">Q3ScrollView</a></li>
 
63
<li><div class="fn"/>2 properties inherited from <a href="q3frame.html#properties">Q3Frame</a></li>
 
64
<li><div class="fn"/>6 properties inherited from <a href="qframe.html#properties">QFrame</a></li>
 
65
<li><div class="fn"/>52 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
 
66
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
67
<li><div class="fn"/>8 public slots inherited from <a href="q3scrollview.html#public-slots">Q3ScrollView</a></li>
 
68
<li><div class="fn"/>17 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
 
69
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
70
<li><div class="fn"/>5 signals inherited from <a href="q3scrollview.html#signals">Q3ScrollView</a></li>
 
71
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
 
72
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
73
<li><div class="fn"/>2 static public members inherited from <a href="qframe.html#static-public-members">QFrame</a></li>
 
74
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
 
75
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
76
</ul>
 
77
<a name="details"></a>
 
78
<hr />
 
79
<h2>Detailed Description</h2>
 
80
<p>The Q3CanvasView class provides an on-screen view of a <a href="q3canvas.html">Q3Canvas</a>.</p>
 
81
<p>A Q3CanvasView is widget which provides a view of a <a href="q3canvas.html">Q3Canvas</a>.</p>
 
82
<p>If you want users to be able to interact with a canvas view, subclass Q3CanvasView. You might then reimplement <a href="q3scrollview.html#contentsMousePressEvent">Q3ScrollView::contentsMousePressEvent</a>(). For example:</p>
 
83
<pre>&nbsp;   void MyCanvasView::contentsMousePressEvent(QMouseEvent* e)
 
84
    {
 
85
        Q3CanvasItemList l = canvas()-&gt;collisions(e-&gt;pos());
 
86
        for (Q3CanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
 
87
            if ((*it)-&gt;rtti() == Q3CanvasRectangle::RTTI)
 
88
                qDebug(&quot;A Q3CanvasRectangle lies somewhere at this point&quot;);
 
89
        }
 
90
    }</pre>
 
91
<p>The canvas view shows canvas <a href="q3canvasview.html#canvas">canvas</a>(); this can be changed using <a href="q3canvasview.html#setCanvas">setCanvas</a>().</p>
 
92
<p>A transformation matrix can be used to transform the view of the canvas in various ways, for example, zooming in or out or rotating. For example:</p>
 
93
<pre>&nbsp;   QMatrix wm;
 
94
    wm.scale(2, 2);   // Zooms in by 2 times
 
95
    wm.rotate(90);    // Rotates 90 degrees counter clockwise
 
96
                        // around the origin.
 
97
    wm.translate(0, -canvas-&gt;height());
 
98
                        // moves the canvas down so what was visible
 
99
                        // before is still visible.
 
100
    myCanvasView-&gt;setWorldMatrix(wm);</pre>
 
101
<p>Use <a href="q3canvasview.html#setWorldMatrix">setWorldMatrix</a>() to set the canvas view's world matrix: you must ensure that the world matrix is invertible. The current world matrix is retrievable with <a href="q3canvasview.html#worldMatrix">worldMatrix</a>(), and its inversion is retrievable with <a href="q3canvasview.html#inverseWorldMatrix">inverseWorldMatrix</a>().</p>
 
102
<p>Example:</p>
 
103
<p>The following code finds the part of the canvas that is visible in this view, i.e. the bounding rectangle of the view in canvas coordinates.</p>
 
104
<pre>&nbsp;   QRect rc = QRect(myCanvasView-&gt;contentsX(), myCanvasView-&gt;contentsY(),
 
105
                        myCanvasView-&gt;visibleWidth(), myCanvasView-&gt;visibleHeight());
 
106
    QRect canvasRect = myCanvasView-&gt;inverseWorldMatrix().mapRect(rc);</pre>
 
107
<p>See also <a href="qmatrix.html">QMatrix</a> and <a href="qpainter-qt3.html#setWorldMatrix">QPainter::setWorldMatrix</a>().</p>
 
108
<hr />
 
109
<h2>Member Function Documentation</h2>
 
110
<h3 class="fn"><a name="Q3CanvasView"></a>Q3CanvasView::Q3CanvasView ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, const char * <i>name</i> = 0, <a href="qt.html#WFlags-typedef">Qt::WFlags</a> <i>f</i> = 0 )</h3>
 
111
<p>Constructs a <a href="q3canvasview.html">Q3CanvasView</a> with parent <i>parent</i>, and name <i>name</i>, using the widget flags <i>f</i>. The canvas view is not associated with a canvas, so you must to call <a href="q3canvasview.html#setCanvas">setCanvas</a>() to view a canvas.</p>
 
112
<h3 class="fn"><a name="Q3CanvasView-2"></a>Q3CanvasView::Q3CanvasView ( <a href="q3canvas.html">Q3Canvas</a> * <i>canvas</i>, <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, const char * <i>name</i> = 0, <a href="qt.html#WFlags-typedef">Qt::WFlags</a> <i>f</i> = 0 )</h3>
 
113
<p>Constructs a <a href="q3canvasview.html">Q3CanvasView</a> which views canvas <i>canvas</i>, with parent <i>parent</i>, and name <i>name</i>, using the widget flags <i>f</i>.</p>
 
114
<h3 class="fn"><a name="dtor.Q3CanvasView"></a>Q3CanvasView::~Q3CanvasView ()</h3>
 
115
<p>Destroys the canvas view. The associated canvas is <i>not</i> deleted.</p>
 
116
<h3 class="fn"><a name="canvas"></a><a href="q3canvas.html">Q3Canvas</a> * Q3CanvasView::canvas () const</h3>
 
117
<p>Returns a pointer to the canvas which the <a href="q3canvasview.html">Q3CanvasView</a> is currently showing.</p>
 
118
<h3 class="fn"><a name="drawContents"></a>void Q3CanvasView::drawContents ( <a href="qpainter.html">QPainter</a> * <i>p</i>, int <i>cx</i>, int <i>cy</i>, int <i>cw</i>, int <i>ch</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
119
<p>Repaints part of the <a href="q3canvas.html">Q3Canvas</a> that the canvas view is showing starting at <i>cx</i> by <i>cy</i>, with a width of <i>cw</i> and a height of <i>ch</i> using the painter <i>p</i>.</p>
 
120
<p>Reimplemented from <a href="q3scrollview.html#drawContents">Q3ScrollView</a>.</p>
 
121
<h3 class="fn"><a name="inverseWorldMatrix"></a>const <a href="qmatrix.html">QMatrix</a> &amp; Q3CanvasView::inverseWorldMatrix () const</h3>
 
122
<p>Returns a reference to the inverse of the canvas view's current transformation matrix.</p>
 
123
<p>See also <a href="q3canvasview.html#setWorldMatrix">setWorldMatrix</a>() and <a href="q3canvasview.html#worldMatrix">worldMatrix</a>().</p>
 
124
<h3 class="fn"><a name="setCanvas"></a>void Q3CanvasView::setCanvas ( <a href="q3canvas.html">Q3Canvas</a> * <i>canvas</i> )</h3>
 
125
<p>Sets the canvas that the <a href="q3canvasview.html">Q3CanvasView</a> is showing to the canvas <i>canvas</i>.</p>
 
126
<h3 class="fn"><a name="setWorldMatrix"></a>bool Q3CanvasView::setWorldMatrix ( const <a href="qmatrix.html">QMatrix</a> &amp; <i>wm</i> )</h3>
 
127
<p>Sets the transformation matrix of the <a href="q3canvasview.html">Q3CanvasView</a> to <i>wm</i>. The matrix must be invertible (i.e. if you create a world matrix that zooms out by 2 times, then the inverse of this matrix is one that will zoom in by 2 times).</p>
 
128
<p>When you use this, you should note that the performance of the <a href="q3canvasview.html">Q3CanvasView</a> will decrease considerably.</p>
 
129
<p>Returns false if <i>wm</i> is not invertable; otherwise returns true.</p>
 
130
<p>See also <a href="q3canvasview.html#worldMatrix">worldMatrix</a>(), <a href="q3canvasview.html#inverseWorldMatrix">inverseWorldMatrix</a>(), and <a href="qmatrix.html#isInvertible">QMatrix::isInvertible</a>().</p>
 
131
<h3 class="fn"><a name="sizeHint"></a><a href="qsize.html">QSize</a> Q3CanvasView::sizeHint () const&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
132
<p>Suggests a size sufficient to view the entire canvas.</p>
 
133
<p>Reimplemented from <a href="qwidget.html#sizeHint-prop">QWidget</a>.</p>
 
134
<h3 class="fn"><a name="worldMatrix"></a>const <a href="qmatrix.html">QMatrix</a> &amp; Q3CanvasView::worldMatrix () const</h3>
 
135
<p>Returns a reference to the canvas view's current transformation matrix.</p>
 
136
<p>See also <a href="q3canvasview.html#setWorldMatrix">setWorldMatrix</a>() and <a href="q3canvasview.html#inverseWorldMatrix">inverseWorldMatrix</a>().</p>
 
137
<p /><address><hr /><div align="center">
 
138
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
139
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
140
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
141
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
142
</tr></table></div></address></body>
 
143
</html>