[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/canvas/qcanvas.cpp:3456 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QCanvasView Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QCanvasView Class Reference<br><small>[<a href="canvas.html">canvas module</a>]</small></h1>
|
---|
| 33 |
|
---|
| 34 | <p>The QCanvasView class provides an on-screen view of a QCanvas.
|
---|
| 35 | <a href="#details">More...</a>
|
---|
| 36 | <p><tt>#include <<a href="qcanvas-h.html">qcanvas.h</a>></tt>
|
---|
| 37 | <p>Inherits <a href="qscrollview.html">QScrollView</a>.
|
---|
| 38 | <p><a href="qcanvasview-members.html">List of all member functions.</a>
|
---|
| 39 | <h2>Public Members</h2>
|
---|
| 40 | <ul>
|
---|
| 41 | <li class=fn><a href="#QCanvasView"><b>QCanvasView</b></a> ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )</li>
|
---|
| 42 | <li class=fn><a href="#QCanvasView-2"><b>QCanvasView</b></a> ( QCanvas * canvas, QWidget * parent = 0, const char * name = 0, WFlags f = 0 )</li>
|
---|
| 43 | <li class=fn><a href="#~QCanvasView"><b>~QCanvasView</b></a> ()</li>
|
---|
| 44 | <li class=fn>QCanvas * <a href="#canvas"><b>canvas</b></a> () const</li>
|
---|
| 45 | <li class=fn>void <a href="#setCanvas"><b>setCanvas</b></a> ( QCanvas * canvas )</li>
|
---|
| 46 | <li class=fn>const QWMatrix & <a href="#worldMatrix"><b>worldMatrix</b></a> () const</li>
|
---|
| 47 | <li class=fn>const QWMatrix & <a href="#inverseWorldMatrix"><b>inverseWorldMatrix</b></a> () const</li>
|
---|
| 48 | <li class=fn>bool <a href="#setWorldMatrix"><b>setWorldMatrix</b></a> ( const QWMatrix & wm )</li>
|
---|
| 49 | </ul>
|
---|
| 50 | <h2>Protected Members</h2>
|
---|
| 51 | <ul>
|
---|
| 52 | <li class=fn>virtual void <a href="#drawContents"><b>drawContents</b></a> ( QPainter * p, int cx, int cy, int cw, int ch )</li>
|
---|
| 53 | <li class=fn>virtual QSize <a href="#sizeHint"><b>sizeHint</b></a> () const</li>
|
---|
| 54 | </ul>
|
---|
| 55 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | The QCanvasView class provides an on-screen view of a <a href="qcanvas.html">QCanvas</a>.
|
---|
| 59 |
|
---|
| 60 | <p>
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | <p> A QCanvasView is widget which provides a view of a QCanvas.
|
---|
| 64 | <p> If you want users to be able to interact with a canvas view,
|
---|
| 65 | subclass QCanvasView. You might then reimplement
|
---|
| 66 | <a href="qscrollview.html#contentsMousePressEvent">QScrollView::contentsMousePressEvent</a>(). For example, assuming no
|
---|
| 67 | <a href="qwmatrix.html#TransformationMode">transformation matrix</a> is set:
|
---|
| 68 | <p> <pre>
|
---|
| 69 | void MyCanvasView::contentsMousePressEvent( <a href="qmouseevent.html">QMouseEvent</a>* e )
|
---|
| 70 | {
|
---|
| 71 | <a href="qcanvasitemlist.html">QCanvasItemList</a> l = <a href="#canvas">canvas</a>()->collisions(e-><a href="qmouseevent.html#pos">pos</a>());
|
---|
| 72 | for (QCanvasItemList::Iterator it=l.<a href="qvaluelist.html#begin">begin</a>(); it!=l.<a href="qvaluelist.html#end">end</a>(); ++it) {
|
---|
| 73 | if ( (*it)->rtti() == QCanvasRectangle::RTTI )
|
---|
| 74 | <a href="qapplication.html#qDebug">qDebug</a>("A QCanvasRectangle lies somewhere at this point");
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 | </pre>
|
---|
| 78 |
|
---|
| 79 | <p> The canvas view shows canvas <a href="#canvas">canvas</a>(); this can be changed using
|
---|
| 80 | <a href="#setCanvas">setCanvas</a>().
|
---|
| 81 | <p> A transformation matrix can be used to transform the view of the
|
---|
| 82 | canvas in various ways, for example, zooming in or out or rotating.
|
---|
| 83 | For example:
|
---|
| 84 | <p> <pre>
|
---|
| 85 | <a href="qwmatrix.html">QWMatrix</a> wm;
|
---|
| 86 | wm.<a href="qwmatrix.html#scale">scale</a>( 2, 2 ); // Zooms in by 2 times
|
---|
| 87 | wm.<a href="qwmatrix.html#rotate">rotate</a>( 90 ); // Rotates 90 degrees counter clockwise
|
---|
| 88 | // around the origin.
|
---|
| 89 | wm.<a href="qwmatrix.html#translate">translate</a>( 0, -canvas->height() );
|
---|
| 90 | // moves the canvas down so what was visible
|
---|
| 91 | // before is still visible.
|
---|
| 92 | myCanvasView->setWorldMatrix( wm );
|
---|
| 93 | </pre>
|
---|
| 94 |
|
---|
| 95 | <p> Use <a href="#setWorldMatrix">setWorldMatrix</a>() to set the canvas view's world matrix: you must
|
---|
| 96 | ensure that the world matrix is invertible. The current world matrix
|
---|
| 97 | is retrievable with <a href="#worldMatrix">worldMatrix</a>(), and its inversion is retrievable
|
---|
| 98 | with <a href="#inverseWorldMatrix">inverseWorldMatrix</a>().
|
---|
| 99 | <p> Example:
|
---|
| 100 | <p> The following code finds the part of the canvas that is visible in
|
---|
| 101 | this view, i.e. the bounding rectangle of the view in canvas coordinates.
|
---|
| 102 | <p> <pre>
|
---|
| 103 | <a href="qrect.html">QRect</a> rc = QRect( myCanvasView->contentsX(), myCanvasView->contentsY(),
|
---|
| 104 | myCanvasView->visibleWidth(), myCanvasView->visibleHeight() );
|
---|
| 105 | <a href="qrect.html">QRect</a> canvasRect = myCanvasView->inverseWorldMatrix().mapRect(rc);
|
---|
| 106 | </pre>
|
---|
| 107 |
|
---|
| 108 | <p> <p>See also <a href="qwmatrix.html">QWMatrix</a>, <a href="qpainter.html#setWorldMatrix">QPainter::setWorldMatrix</a>(), <a href="graphics.html">Graphics Classes</a>, and <a href="images.html">Image Processing Classes</a>.
|
---|
| 109 |
|
---|
| 110 | <p>
|
---|
| 111 | <hr><h2>Member Function Documentation</h2>
|
---|
| 112 | <h3 class=fn><a name="QCanvasView"></a>QCanvasView::QCanvasView ( <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0, WFlags f = 0 )
|
---|
| 113 | </h3>
|
---|
| 114 | Constructs a QCanvasView with parent <em>parent</em>, and name <em>name</em>,
|
---|
| 115 | using the widget flags <em>f</em>. The canvas view is not associated
|
---|
| 116 | with a canvas, so you must to call <a href="#setCanvas">setCanvas</a>() to view a
|
---|
| 117 | canvas.
|
---|
| 118 |
|
---|
| 119 | <h3 class=fn><a name="QCanvasView-2"></a>QCanvasView::QCanvasView ( <a href="qcanvas.html">QCanvas</a> * canvas, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0, WFlags f = 0 )
|
---|
| 120 | </h3>
|
---|
| 121 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 122 | <p> Constructs a QCanvasView which views canvas <em>canvas</em>, with parent
|
---|
| 123 | <em>parent</em>, and name <em>name</em>, using the widget flags <em>f</em>.
|
---|
| 124 |
|
---|
| 125 | <h3 class=fn><a name="~QCanvasView"></a>QCanvasView::~QCanvasView ()
|
---|
| 126 | </h3>
|
---|
| 127 | Destroys the canvas view. The associated canvas is <em>not</em> deleted.
|
---|
| 128 |
|
---|
| 129 | <h3 class=fn><a href="qcanvas.html">QCanvas</a> * <a name="canvas"></a>QCanvasView::canvas () const
|
---|
| 130 | </h3>
|
---|
| 131 |
|
---|
| 132 | <p> Returns a pointer to the canvas which the QCanvasView is currently
|
---|
| 133 | showing.
|
---|
| 134 |
|
---|
| 135 | <h3 class=fn>void <a name="drawContents"></a>QCanvasView::drawContents ( <a href="qpainter.html">QPainter</a> * p, int cx, int cy, int cw, int ch )<tt> [virtual protected]</tt>
|
---|
| 136 | </h3>
|
---|
| 137 | Repaints part of the <a href="qcanvas.html">QCanvas</a> that the canvas view is showing
|
---|
| 138 | starting at <em>cx</em> by <em>cy</em>, with a width of <em>cw</em> and a height of <em>ch</em> using the painter <em>p</em>.
|
---|
| 139 | <p> <b>Warning:</b> When double buffering is enabled, <a href="#drawContents">drawContents</a>() will
|
---|
| 140 | not respect the current settings of the painter when setting up
|
---|
| 141 | the painter for the double buffer (e.g., <a href="qscrollview.html#viewport">viewport</a>() and
|
---|
| 142 | window()). Also, be aware that <a href="qcanvas.html#update">QCanvas::update</a>() bypasses
|
---|
| 143 | drawContents(), which means any reimplementation of
|
---|
| 144 | drawContents() is not called.
|
---|
| 145 | <p> <p>See also <a href="qcanvas.html#setDoubleBuffering">QCanvas::setDoubleBuffering</a>().
|
---|
| 146 |
|
---|
| 147 | <p>Reimplemented from <a href="qscrollview.html#drawContents">QScrollView</a>.
|
---|
| 148 | <h3 class=fn>const <a href="qwmatrix.html">QWMatrix</a> & <a name="inverseWorldMatrix"></a>QCanvasView::inverseWorldMatrix () const
|
---|
| 149 | </h3>
|
---|
| 150 | Returns a reference to the inverse of the canvas view's current
|
---|
| 151 | <a href="qwmatrix.html#TransformationMode">transformation matrix</a>.
|
---|
| 152 | <p> <p>See also <a href="#setWorldMatrix">setWorldMatrix</a>() and <a href="#worldMatrix">worldMatrix</a>().
|
---|
| 153 |
|
---|
| 154 | <h3 class=fn>void <a name="setCanvas"></a>QCanvasView::setCanvas ( <a href="qcanvas.html">QCanvas</a> * canvas )
|
---|
| 155 | </h3>
|
---|
| 156 | Sets the canvas that the QCanvasView is showing to the canvas <em>canvas</em>.
|
---|
| 157 |
|
---|
| 158 | <h3 class=fn>bool <a name="setWorldMatrix"></a>QCanvasView::setWorldMatrix ( const <a href="qwmatrix.html">QWMatrix</a> & wm )
|
---|
| 159 | </h3>
|
---|
| 160 | Sets the <a href="qwmatrix.html#TransformationMode">transformation matrix</a> of the QCanvasView to <em>wm</em>. The
|
---|
| 161 | matrix must be invertible (i.e. if you create a world matrix that
|
---|
| 162 | zooms out by 2 times, then the inverse of this matrix is one that
|
---|
| 163 | will zoom in by 2 times).
|
---|
| 164 | <p> When you use this, you should note that the performance of the
|
---|
| 165 | QCanvasView will decrease considerably.
|
---|
| 166 | <p> Returns FALSE if <em>wm</em> is not invertable; otherwise returns TRUE.
|
---|
| 167 | <p> <p>See also <a href="#worldMatrix">worldMatrix</a>(), <a href="#inverseWorldMatrix">inverseWorldMatrix</a>(), and <a href="qwmatrix.html#isInvertible">QWMatrix::isInvertible</a>().
|
---|
| 168 |
|
---|
| 169 | <p>Example: <a href="canvas-example.html#x2930">canvas/canvas.cpp</a>.
|
---|
| 170 | <h3 class=fn><a href="qsize.html">QSize</a> <a name="sizeHint"></a>QCanvasView::sizeHint () const<tt> [virtual protected]</tt>
|
---|
| 171 | </h3>
|
---|
| 172 | Suggests a size sufficient to view the entire canvas.
|
---|
| 173 |
|
---|
| 174 | <h3 class=fn>const <a href="qwmatrix.html">QWMatrix</a> & <a name="worldMatrix"></a>QCanvasView::worldMatrix () const
|
---|
| 175 | </h3>
|
---|
| 176 | Returns a reference to the canvas view's current <a href="qwmatrix.html#TransformationMode">transformation matrix</a>.
|
---|
| 177 | <p> <p>See also <a href="#setWorldMatrix">setWorldMatrix</a>() and <a href="#inverseWorldMatrix">inverseWorldMatrix</a>().
|
---|
| 178 |
|
---|
| 179 | <p>Example: <a href="canvas-example.html#x2931">canvas/canvas.cpp</a>.
|
---|
| 180 | <!-- eof -->
|
---|
| 181 | <hr><p>
|
---|
| 182 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 183 | Copyright © 1995-2007
|
---|
| 184 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 185 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 186 | <td>Copyright © 2007
|
---|
| 187 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 188 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 189 | </table></div></address></body>
|
---|
| 190 | </html>
|
---|