summaryrefslogtreecommitdiffstats
path: root/doc/html/qcanvasview.html
blob: 41662cbd794124b3f2174886ac99d2f14e08bb68 (plain)
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/canvas/qcanvas.cpp:3456 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQCanvasView Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQCanvasView Class Reference<br><small>[<a href="canvas.html">canvas module</a>]</small></h1>

<p>The TQCanvasView class provides an on-screen view of a TQCanvas.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qcanvas-h.html">ntqcanvas.h</a>&gt;</tt>
<p>Inherits <a href="ntqscrollview.html">TQScrollView</a>.
<p><a href="qcanvasview-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQCanvasView"><b>TQCanvasView</b></a> ( TQWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = 0 )</li>
<li class=fn><a href="#TQCanvasView-2"><b>TQCanvasView</b></a> ( TQCanvas&nbsp;*&nbsp;canvas, TQWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = 0 )</li>
<li class=fn><a href="#~TQCanvasView"><b>~TQCanvasView</b></a> ()</li>
<li class=fn>TQCanvas * <a href="#canvas"><b>canvas</b></a> () const</li>
<li class=fn>void <a href="#setCanvas"><b>setCanvas</b></a> ( TQCanvas&nbsp;*&nbsp;canvas )</li>
<li class=fn>const TQWMatrix &amp; <a href="#worldMatrix"><b>worldMatrix</b></a> () const</li>
<li class=fn>const TQWMatrix &amp; <a href="#inverseWorldMatrix"><b>inverseWorldMatrix</b></a> () const</li>
<li class=fn>bool <a href="#setWorldMatrix"><b>setWorldMatrix</b></a> ( const&nbsp;TQWMatrix&nbsp;&amp;&nbsp;wm )</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual void <a href="#drawContents"><b>drawContents</b></a> ( TQPainter&nbsp;*&nbsp;p, int&nbsp;cx, int&nbsp;cy, int&nbsp;cw, int&nbsp;ch )</li>
<li class=fn>virtual TQSize <a href="#sizeHint"><b>sizeHint</b></a> () const</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The TQCanvasView class provides an on-screen view of a <a href="ntqcanvas.html">TQCanvas</a>.

<p> 


<p> A TQCanvasView is widget which provides a view of a TQCanvas.
<p> If you want users to be able to interact with a canvas view,
subclass TQCanvasView. You might then reimplement
<a href="ntqscrollview.html#contentsMousePressEvent">TQScrollView::contentsMousePressEvent</a>(). For example, assuming no
<a href="ntqwmatrix.html#TransformationMode">transformation matrix</a> is set:
<p> <pre>
    void MyCanvasView::contentsMousePressEvent( <a href="qmouseevent.html">TQMouseEvent</a>* e )
    {
        <a href="qcanvasitemlist.html">TQCanvasItemList</a> l = <a href="#canvas">canvas</a>()-&gt;collisions(e-&gt;<a href="qmouseevent.html#pos">pos</a>());
        for (TQCanvasItemList::Iterator it=l.<a href="ntqvaluelist.html#begin">begin</a>(); it!=l.<a href="ntqvaluelist.html#end">end</a>(); ++it) {
            if ( (*it)-&gt;rtti() == TQCanvasRectangle::RTTI )
                <a href="ntqapplication.html#qDebug">qDebug</a>("A TQCanvasRectangle lies somewhere at this point");
        }
    }
    </pre>
 
<p> The canvas view shows canvas <a href="#canvas">canvas</a>(); this can be changed using
<a href="#setCanvas">setCanvas</a>().
<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> <pre>
    <a href="ntqwmatrix.html">TQWMatrix</a> wm;
    wm.<a href="ntqwmatrix.html#scale">scale</a>( 2, 2 );   // Zooms in by 2 times
    wm.<a href="ntqwmatrix.html#rotate">rotate</a>( 90 );    // Rotates 90 degrees counter clockwise
                        // around the origin.
    wm.<a href="ntqwmatrix.html#translate">translate</a>( 0, -canvas-&gt;height() );
                        // moves the canvas down so what was visible
                        // before is still visible.
    myCanvasView-&gt;setWorldMatrix( wm );
    </pre>
 
<p> Use <a href="#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="#worldMatrix">worldMatrix</a>(), and its inversion is retrievable
with <a href="#inverseWorldMatrix">inverseWorldMatrix</a>().
<p> Example:
<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> <pre>
    <a href="ntqrect.html">TQRect</a> rc = TQRect( myCanvasView-&gt;contentsX(), myCanvasView-&gt;contentsY(),
                        myCanvasView-&gt;visibleWidth(), myCanvasView-&gt;visibleHeight() );
    <a href="ntqrect.html">TQRect</a> canvasRect = myCanvasView-&gt;inverseWorldMatrix().mapRect(rc);
    </pre>
 
<p> <p>See also <a href="ntqwmatrix.html">TQWMatrix</a>, <a href="ntqpainter.html#setWorldMatrix">TQPainter::setWorldMatrix</a>(), <a href="graphics.html">Graphics Classes</a>, and <a href="images.html">Image Processing Classes</a>.

<p> 
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQCanvasView"></a>TQCanvasView::TQCanvasView ( <a href="ntqwidget.html">TQWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = 0 )
</h3>
Constructs a TQCanvasView with parent <em>parent</em>, and name <em>name</em>,
using the widget flags <em>f</em>. The canvas view is not associated
with a canvas, so you must to call <a href="#setCanvas">setCanvas</a>() to view a
canvas.

<h3 class=fn><a name="TQCanvasView-2"></a>TQCanvasView::TQCanvasView ( <a href="ntqcanvas.html">TQCanvas</a>&nbsp;*&nbsp;canvas, <a href="ntqwidget.html">TQWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0, WFlags&nbsp;f = 0 )
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Constructs a TQCanvasView which views canvas <em>canvas</em>, with parent
<em>parent</em>, and name <em>name</em>, using the widget flags <em>f</em>.

<h3 class=fn><a name="~TQCanvasView"></a>TQCanvasView::~TQCanvasView ()
</h3>
Destroys the canvas view. The associated canvas is <em>not</em> deleted.

<h3 class=fn><a href="ntqcanvas.html">TQCanvas</a>&nbsp;* <a name="canvas"></a>TQCanvasView::canvas () const
</h3>

<p> Returns a pointer to the canvas which the TQCanvasView is currently
showing.

<h3 class=fn>void <a name="drawContents"></a>TQCanvasView::drawContents ( <a href="ntqpainter.html">TQPainter</a>&nbsp;*&nbsp;p, int&nbsp;cx, int&nbsp;cy, int&nbsp;cw, int&nbsp;ch )<tt> [virtual protected]</tt>
</h3>
Repaints part of the <a href="ntqcanvas.html">TQCanvas</a> that the canvas view is showing
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>.
<p> <b>Warning:</b> When double buffering is enabled, <a href="#drawContents">drawContents</a>() will
not respect the current settings of the painter when setting up
the painter for the double buffer (e.g., <a href="ntqscrollview.html#viewport">viewport</a>() and
window()). Also, be aware that <a href="ntqcanvas.html#update">TQCanvas::update</a>() bypasses
drawContents(), which means any reimplementation of
drawContents() is not called.
<p> <p>See also <a href="ntqcanvas.html#setDoubleBuffering">TQCanvas::setDoubleBuffering</a>().

<p>Reimplemented from <a href="ntqscrollview.html#drawContents">TQScrollView</a>.
<h3 class=fn>const&nbsp;<a href="ntqwmatrix.html">TQWMatrix</a>&nbsp;&amp; <a name="inverseWorldMatrix"></a>TQCanvasView::inverseWorldMatrix () const
</h3>
Returns a reference to the inverse of the canvas view's current
<a href="ntqwmatrix.html#TransformationMode">transformation matrix</a>.
<p> <p>See also <a href="#setWorldMatrix">setWorldMatrix</a>() and <a href="#worldMatrix">worldMatrix</a>().

<h3 class=fn>void <a name="setCanvas"></a>TQCanvasView::setCanvas ( <a href="ntqcanvas.html">TQCanvas</a>&nbsp;*&nbsp;canvas )
</h3>
Sets the canvas that the TQCanvasView is showing to the canvas <em>canvas</em>.

<h3 class=fn>bool <a name="setWorldMatrix"></a>TQCanvasView::setWorldMatrix ( const&nbsp;<a href="ntqwmatrix.html">TQWMatrix</a>&nbsp;&amp;&nbsp;wm )
</h3>
Sets the <a href="ntqwmatrix.html#TransformationMode">transformation matrix</a> of the TQCanvasView to <em>wm</em>. 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> When you use this, you should note that the performance of the
TQCanvasView will decrease considerably.
<p> Returns FALSE if <em>wm</em> is not invertable; otherwise returns TRUE.
<p> <p>See also <a href="#worldMatrix">worldMatrix</a>(), <a href="#inverseWorldMatrix">inverseWorldMatrix</a>(), and <a href="ntqwmatrix.html#isInvertible">TQWMatrix::isInvertible</a>().

<p>Example: <a href="canvas-example.html#x2930">canvas/canvas.cpp</a>.
<h3 class=fn><a href="ntqsize.html">TQSize</a> <a name="sizeHint"></a>TQCanvasView::sizeHint () const<tt> [virtual protected]</tt>
</h3>
Suggests a size sufficient to view the entire canvas.

<h3 class=fn>const&nbsp;<a href="ntqwmatrix.html">TQWMatrix</a>&nbsp;&amp; <a name="worldMatrix"></a>TQCanvasView::worldMatrix () const
</h3>
Returns a reference to the canvas view's current <a href="ntqwmatrix.html#TransformationMode">transformation matrix</a>.
<p> <p>See also <a href="#setWorldMatrix">setWorldMatrix</a>() and <a href="#inverseWorldMatrix">inverseWorldMatrix</a>().

<p>Example: <a href="canvas-example.html#x2931">canvas/canvas.cpp</a>.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 1995-2007
<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 &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>