'\" t
.TH TQCanvasView 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
TQCanvasView \- On-screen view of a TQCanvas
.SH SYNOPSIS
\fC#include <tqcanvas.h>\fR
.PP
Inherits QScrollView.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBTQCanvasView\fR ( TQWidget * parent = 0, const char * name = 0, WFlags f = 0 )"
.br
.ti -1c
.BI "\fBTQCanvasView\fR ( TQCanvas * canvas, TQWidget * parent = 0, const char * name = 0, WFlags f = 0 )"
.br
.ti -1c
.BI "\fB~TQCanvasView\fR ()"
.br
.ti -1c
.BI "TQCanvas * \fBcanvas\fR () const"
.br
.ti -1c
.BI "void \fBsetCanvas\fR ( TQCanvas * canvas )"
.br
.ti -1c
.BI "const QWMatrix & \fBworldMatrix\fR () const"
.br
.ti -1c
.BI "const QWMatrix & \fBinverseWorldMatrix\fR () const"
.br
.ti -1c
.BI "bool \fBsetWorldMatrix\fR ( const QWMatrix & wm )"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "virtual void \fBdrawContents\fR ( TQPainter * p, int cx, int cy, int cw, int ch )"
.br
.ti -1c
.BI "virtual TQSize \fBsizeHint\fR () const"
.br
.in -1c
.SH DESCRIPTION
The TQCanvasView class provides an on-screen view of a TQCanvas.
.PP
A TQCanvasView is widget which provides a view of a TQCanvas.
.PP
If you want users to be able to interact with a canvas view, subclass TQCanvasView. You might then reimplement QScrollView::contentsMousePressEvent(). For example, assuming no transformation matrix is set:
.PP
.nf
.br
void MyCanvasView::contentsMousePressEvent( QMouseEvent* e )
.br
{
.br
TQCanvasItemList l = canvas()->collisions(e->pos());
.br
for (TQCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
.br
if ( (*it)->rtti() == TQCanvasRectangle::RTTI )
.br
tqDebug("A TQCanvasRectangle lies somewhere at this point");
.br
}
.br
}
.br
.fi
.PP
The canvas view shows canvas canvas(); this can be changed using setCanvas().
.PP
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:
.PP
.nf
.br
QWMatrix wm;
.br
wm.scale( 2, 2 ); // Zooms in by 2 times
.br
wm.rotate( 90 ); // Rotates 90 degrees counter clockwise
.br
// around the origin.
.br
wm.translate( 0, -canvas->height() );
.br
// moves the canvas down so what was visible
.br
// before is still visible.
.br
myCanvasView->setWorldMatrix( wm );
.br
.fi
.PP
Use setWorldMatrix() to set the canvas view's world matrix: you must ensure that the world matrix is invertible. The current world matrix is retrievable with worldMatrix(), and its inversion is retrievable with inverseWorldMatrix().
.PP
Example:
.PP
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.
.PP
.nf
.br
QRect rc = QRect( myCanvasView->contentsX(), myCanvasView->contentsY(),
.br
myCanvasView->visibleWidth(), myCanvasView->visibleHeight() );
.br
QRect canvasRect = myCanvasView->inverseWorldMatrix().mapRect(rc);
.br
.fi
.PP
See also QWMatrix, TQPainter::setWorldMatrix(), Graphics Classes, and Image Processing Classes.
.PP
.SH MEMBER FUNCTION DOCUMENTATION
.SH "TQCanvasView::TQCanvasView ( TQWidget * parent = 0, const char * name = 0, WFlags f = 0 )"
Constructs a TQCanvasView with parent \fIparent\fR, and name \fIname\fR, using the widget flags \fIf\fR. The canvas view is not associated with a canvas, so you must to call setCanvas() to view a canvas.
.SH "TQCanvasView::TQCanvasView ( TQCanvas * canvas, TQWidget * parent = 0, const char * name = 0, WFlags f = 0 )"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Constructs a TQCanvasView which views canvas \fIcanvas\fR, with parent \fIparent\fR, and name \fIname\fR, using the widget flags \fIf\fR.
.SH "TQCanvasView::~TQCanvasView ()"
Destroys the canvas view. The associated canvas is \fInot\fR deleted.
.SH "TQCanvas * TQCanvasView::canvas () const"
Returns a pointer to the canvas which the TQCanvasView is currently showing.
.SH "void TQCanvasView::drawContents ( TQPainter * p, int cx, int cy, int cw, int ch )\fC [virtual protected]\fR"
Repaints part of the TQCanvas that the canvas view is showing starting at \fIcx\fR by \fIcy\fR, with a width of \fIcw\fR and a height of \fIch\fR using the painter \fIp\fR.
.PP
\fBWarning:\fR When double buffering is enabled, drawContents() will not respect the current settings of the painter when setting up the painter for the double buffer (e.g., viewport() and window()). Also, be aware that TQCanvas::update() bypasses drawContents(), which means any reimplementation of drawContents() is not called.
.PP
See also TQCanvas::setDoubleBuffering().
.PP
Reimplemented from QScrollView.
.SH "const QWMatrix & TQCanvasView::inverseWorldMatrix () const"
Returns a reference to the inverse of the canvas view's current transformation matrix.
.PP
See also setWorldMatrix() and worldMatrix().
.SH "void TQCanvasView::setCanvas ( TQCanvas * canvas )"
Sets the canvas that the TQCanvasView is showing to the canvas \fIcanvas\fR.
.SH "bool TQCanvasView::setWorldMatrix ( const QWMatrix & wm )"
Sets the transformation matrix of the TQCanvasView to \fIwm\fR. 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).
.PP
When you use this, you should note that the performance of the TQCanvasView will decrease considerably.
.PP
Returns FALSE if \fIwm\fR is not invertable; otherwise returns TRUE.
.PP
See also worldMatrix(), inverseWorldMatrix(), and QWMatrix::isInvertible().
.PP
Example: canvas/canvas.cpp.
.SH "TQSize TQCanvasView::sizeHint () const\fC [virtual protected]\fR"
Suggests a size sufficient to view the entire canvas.
.SH "const QWMatrix & TQCanvasView::worldMatrix () const"
Returns a reference to the canvas view's current transformation matrix.
.PP
See also setWorldMatrix() and inverseWorldMatrix().
.PP
Example: canvas/canvas.cpp.
.SH "SEE ALSO"
.BR http://doc.trolltech.com/tqcanvasview.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqcanvasview.3qt) and the Qt
version (3.3.8).