diff options
Diffstat (limited to 'doc/html/tutorial1-14.html')
-rw-r--r-- | doc/html/tutorial1-14.html | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/doc/html/tutorial1-14.html b/doc/html/tutorial1-14.html index 962f6866e..1c8bf07f4 100644 --- a/doc/html/tutorial1-14.html +++ b/doc/html/tutorial1-14.html @@ -72,10 +72,10 @@ three mouse event handlers. The names say it all. <p> <pre> void paintBarrier( <a href="tqpainter.html">TQPainter</a> * ); </pre> <p> This private function paints the barrier wall. -<p> <pre> <a href="ntqrect.html">TQRect</a> barrierRect() const; +<p> <pre> <a href="tqrect.html">TQRect</a> barrierRect() const; </pre> <p> This private function returns the enclosing rectangle of the barrier. -<p> <pre> bool barrelHit( const <a href="ntqpoint.html">TQPoint</a> & ) const; +<p> <pre> bool barrelHit( const <a href="tqpoint.html">TQPoint</a> & ) const; </pre> <p> This private function checks if a point is inside the barrel of the cannon. <p> <pre> bool barrelPressed; @@ -90,8 +90,8 @@ barrel and not released it. </pre> <p> This line has been added to the constructor. Initially, the mouse is not pressed on the barrel. -<p> <pre> <a name="x2429"></a> } else if ( shotR.<a href="ntqrect.html#x">x</a>() > width() || shotR.<a href="ntqrect.html#y">y</a>() > height() || - shotR.<a href="ntqrect.html#intersects">intersects</a>(barrierRect()) ) { +<p> <pre> <a name="x2429"></a> } else if ( shotR.<a href="tqrect.html#x">x</a>() > width() || shotR.<a href="tqrect.html#y">y</a>() > height() || + shotR.<a href="tqrect.html#intersects">intersects</a>(barrierRect()) ) { </pre> <p> Now that we have a barrier, there are three ways to miss. We test for the third, too. @@ -115,12 +115,12 @@ coordinate system. { if ( !barrelPressed ) return; - <a href="ntqpoint.html">TQPoint</a> pnt = e-><a href="qmouseevent.html#pos">pos</a>(); - <a name="x2424"></a> if ( pnt.<a href="ntqpoint.html#x">x</a>() <= 0 ) - <a name="x2422"></a> pnt.<a href="ntqpoint.html#setX">setX</a>( 1 ); - <a name="x2425"></a> if ( pnt.<a href="ntqpoint.html#y">y</a>() >= <a href="tqwidget.html#height">height</a>() ) - <a name="x2423"></a> pnt.<a href="ntqpoint.html#setY">setY</a>( <a href="tqwidget.html#height">height</a>() - 1 ); - double rad = atan(((double)<a href="tqwidget.html#rect">rect</a>().bottom()-pnt.<a href="ntqpoint.html#y">y</a>())/pnt.<a href="ntqpoint.html#x">x</a>()); + <a href="tqpoint.html">TQPoint</a> pnt = e-><a href="qmouseevent.html#pos">pos</a>(); + <a name="x2424"></a> if ( pnt.<a href="tqpoint.html#x">x</a>() <= 0 ) + <a name="x2422"></a> pnt.<a href="tqpoint.html#setX">setX</a>( 1 ); + <a name="x2425"></a> if ( pnt.<a href="tqpoint.html#y">y</a>() >= <a href="tqwidget.html#height">height</a>() ) + <a name="x2423"></a> pnt.<a href="tqpoint.html#setY">setY</a>( <a href="tqwidget.html#height">height</a>() - 1 ); + double rad = atan(((double)<a href="tqwidget.html#rect">rect</a>().bottom()-pnt.<a href="tqpoint.html#y">y</a>())/pnt.<a href="tqpoint.html#x">x</a>()); setAngle( tqRound ( rad*180/3.14159265 ) ); } </pre> @@ -149,7 +149,7 @@ button and it was pressed inside this widget. <p> If the left button is released, we can be sure that the barrel is no longer pressed. <p> The paint event has two extra lines: -<p> <pre> <a name="x2427"></a> if ( updateR.<a href="ntqrect.html#intersects">intersects</a>( barrierRect() ) ) +<p> <pre> <a name="x2427"></a> if ( updateR.<a href="tqrect.html#intersects">intersects</a>( barrierRect() ) ) paintBarrier( &p ); </pre> <p> paintBarrier() does the same sort of thing as paintShot(), @@ -170,26 +170,26 @@ yellow and with a black outline. </pre> <p> This private function returns the rectangle of the barrier. We fix the bottom edge of the barrier to the bottom edge of the widget. -<p> <pre> bool CannonField::barrelHit( const <a href="ntqpoint.html">TQPoint</a> &p ) const +<p> <pre> bool CannonField::barrelHit( const <a href="tqpoint.html">TQPoint</a> &p ) const { - <a href="ntqwmatrix.html">TQWMatrix</a> mtx; - <a name="x2436"></a> mtx.<a href="ntqwmatrix.html#translate">translate</a>( 0, height() - 1 ); - <a name="x2435"></a> mtx.<a href="ntqwmatrix.html#rotate">rotate</a>( -ang ); - <a name="x2433"></a> mtx = mtx.<a href="ntqwmatrix.html#invert">invert</a>(); - <a name="x2434"></a><a name="x2426"></a> return barrelRect.<a href="ntqrect.html#contains">contains</a>( mtx.<a href="ntqwmatrix.html#map">map</a>(p) ); + <a href="tqwmatrix.html">TQWMatrix</a> mtx; + <a name="x2436"></a> mtx.<a href="tqwmatrix.html#translate">translate</a>( 0, height() - 1 ); + <a name="x2435"></a> mtx.<a href="tqwmatrix.html#rotate">rotate</a>( -ang ); + <a name="x2433"></a> mtx = mtx.<a href="tqwmatrix.html#invert">invert</a>(); + <a name="x2434"></a><a name="x2426"></a> return barrelRect.<a href="tqrect.html#contains">contains</a>( mtx.<a href="tqwmatrix.html#map">map</a>(p) ); } </pre> <p> This function returns TRUE if the point is in the barrel; otherwise it returns FALSE. -<p> Here we use the class <a href="ntqwmatrix.html">TQWMatrix</a>. It is defined in the header file -ntqwmatrix.h, which is included by tqpainter.h. -<p> <a href="ntqwmatrix.html">TQWMatrix</a> defines a coordinate system mapping. It can perform the same +<p> Here we use the class <a href="tqwmatrix.html">TQWMatrix</a>. It is defined in the header file +tqwmatrix.h, which is included by tqpainter.h. +<p> <a href="tqwmatrix.html">TQWMatrix</a> defines a coordinate system mapping. It can perform the same transformations as the <a href="tqpainter.html">TQPainter</a>. <p> Here we perform the same transformation steps as we do when drawing the barrel in the paintCannon() function. First we translate the coordinate system and then we rotate it. <p> Now we need to check whether the point <tt>p</tt> (in widget coordinates) lies -inside the barrel. To do this, we invert the <a href="ntqwmatrix.html#TransformationMode">transformation matrix</a>. +inside the barrel. To do this, we invert the <a href="tqwmatrix.html#TransformationMode">transformation matrix</a>. The inverted matrix performs the inverse transformation that we used when drawing the barrel. We map the point <tt>p</tt> using the inverted matrix and return TRUE if it is inside the original barrel rectangle. |