diff options
Diffstat (limited to 'doc/html/tutorial2-06.html')
-rw-r--r-- | doc/html/tutorial2-06.html | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/doc/html/tutorial2-06.html b/doc/html/tutorial2-06.html index 09dab5723..baf5493c6 100644 --- a/doc/html/tutorial2-06.html +++ b/doc/html/tutorial2-06.html @@ -44,7 +44,7 @@ drawElements() function is called to redraw the canvas when necessary. <pre> void ChartForm::drawElements() { <a href="qcanvasitemlist.html">TQCanvasItemList</a> list = m_canvas->allItems(); - for ( TQCanvasItemList::iterator it = list.<a href="qvaluelist.html#begin">begin</a>(); it != list.<a href="qvaluelist.html#end">end</a>(); ++it ) + for ( TQCanvasItemList::iterator it = list.<a href="ntqvaluelist.html#begin">begin</a>(); it != list.<a href="ntqvaluelist.html#end">end</a>(); ++it ) delete *it; </pre> <p> The first thing we do in drawElements() is delete all the existing @@ -123,8 +123,8 @@ required) and a count of the number of values. <p> We retrieve the width and height of the canvas and calculate the proportional height (<tt>proheight</tt>). We set the initial <tt>y</tt> position to 0. -<p> <pre> <a href="qpen.html">TQPen</a> pen; - <a name="x2575"></a> pen.<a href="qpen.html#setStyle">setStyle</a>( NoPen ); +<p> <pre> <a href="ntqpen.html">TQPen</a> pen; + <a name="x2575"></a> pen.<a href="ntqpen.html#setStyle">setStyle</a>( NoPen ); </pre> <p> We create a pen that we will use to draw each bar (rectangle); we set it to <tt>NoPen</tt> so that no outlines are drawn. @@ -151,8 +151,8 @@ be drawn on. We then set the bar's brush to the color and pattern that the user has specified for the element, set the pen to the pen we created earlier (i.e. to <tt>NoPen</tt>) and we place the bar at position 0 in the Z-order. Finally we call show() to draw the bar on the canvas. -<p> <pre> <a href="qstring.html">TQString</a> label = m_elements[i].label(); - <a name="x2576"></a> if ( !label.<a href="qstring.html#isEmpty">isEmpty</a>() || m_addValues != NO ) { +<p> <pre> <a href="ntqstring.html">TQString</a> label = m_elements[i].label(); + <a name="x2576"></a> if ( !label.<a href="ntqstring.html#isEmpty">isEmpty</a>() || m_addValues != NO ) { double proX = m_elements[i].proX( HORIZONTAL_BAR ); double proY = m_elements[i].proY( HORIZONTAL_BAR ); if ( proX < 0 || proY < 0 ) { @@ -213,9 +213,9 @@ proportional height ready to draw the next element. CanvasText( int index, TQCanvas *canvas ) : <a href="qcanvastext.html">TQCanvasText</a>( canvas ), m_index( index ) {} - CanvasText( int index, const <a href="qstring.html">TQString</a>& text, TQCanvas *canvas ) + CanvasText( int index, const <a href="ntqstring.html">TQString</a>& text, TQCanvas *canvas ) : <a href="qcanvastext.html">TQCanvasText</a>( text, canvas ), m_index( index ) {} - CanvasText( int index, const <a href="qstring.html">TQString</a>& text, TQFont font, TQCanvas *canvas ) + CanvasText( int index, const <a href="ntqstring.html">TQString</a>& text, TQFont font, TQCanvas *canvas ) : <a href="qcanvastext.html">TQCanvasText</a>( text, font, canvas ), m_index( index ) {} int index() const { return m_index; } @@ -239,8 +239,8 @@ with this text item, and provided a getter and setter for this value. { <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a> public: - CanvasView( <a href="qcanvas.html">TQCanvas</a> *canvas, ElementVector *elements, - <a href="qwidget.html">TQWidget</a>* parent = 0, const char* name = "canvas view", + CanvasView( <a href="ntqcanvas.html">TQCanvas</a> *canvas, ElementVector *elements, + <a href="ntqwidget.html">TQWidget</a>* parent = 0, const char* name = "canvas view", WFlags f = 0 ) : <a href="qcanvasview.html">TQCanvasView</a>( canvas, parent, name, f ), m_movingItem(0), m_elements( elements ) {} @@ -253,7 +253,7 @@ with this text item, and provided a getter and setter for this value. private: <a href="qcanvasitem.html">TQCanvasItem</a> *m_movingItem; - <a href="qpoint.html">TQPoint</a> m_pos; + <a href="ntqpoint.html">TQPoint</a> m_pos; ElementVector *m_elements; }; </pre> @@ -271,9 +271,9 @@ vector. <a name="3-1"></a><p> (Extracts from <tt>canvasview.cpp</tt>.) <p> -<pre> <a name="x2584"></a>void CanvasView::<a href="qscrollview.html#contentsContextMenuEvent">contentsContextMenuEvent</a>( <a href="qcontextmenuevent.html">TQContextMenuEvent</a> * ) +<pre> <a name="x2584"></a>void CanvasView::<a href="ntqscrollview.html#contentsContextMenuEvent">contentsContextMenuEvent</a>( <a href="qcontextmenuevent.html">TQContextMenuEvent</a> * ) { - <a name="x2579"></a> ((ChartForm*)<a href="qobject.html#parent">parent</a>())->optionsMenu->exec( TQCursor::<a href="qcursor.html#pos">pos</a>() ); + <a name="x2579"></a> ((ChartForm*)<a href="ntqobject.html#parent">parent</a>())->optionsMenu->exec( TQCursor::<a href="ntqcursor.html#pos">pos</a>() ); } </pre> <p> When the user invokes a context menu (e.g. by right-clicking on most @@ -282,10 +282,10 @@ to the right type and then exec()ute the options menu at the cursor position. <p> <h3> Handling Resizing </h3> -<a name="3-2"></a><p> <pre> <a name="x2587"></a>void CanvasView::<a href="qscrollview.html#viewportResizeEvent">viewportResizeEvent</a>( <a href="qresizeevent.html">TQResizeEvent</a> *e ) +<a name="3-2"></a><p> <pre> <a name="x2587"></a>void CanvasView::<a href="ntqscrollview.html#viewportResizeEvent">viewportResizeEvent</a>( <a href="qresizeevent.html">TQResizeEvent</a> *e ) { <a name="x2583"></a> <a href="qcanvasview.html#canvas">canvas</a>()->resize( e-><a href="qresizeevent.html#size">size</a>().width(), e-><a href="qresizeevent.html#size">size</a>().height() ); - ((ChartForm*)<a href="qobject.html#parent">parent</a>())->drawElements(); + ((ChartForm*)<a href="ntqobject.html#parent">parent</a>())->drawElements(); } </pre> <p> To resize we simply resize the canvas that the canvas view is @@ -297,10 +297,10 @@ drawn correctly. </h3> <a name="3-3"></a><p> When the user wants to drag a label into position they click it, then drag and release at the new position. -<p> <pre> <a name="x2586"></a>void CanvasView::<a href="qscrollview.html#contentsMousePressEvent">contentsMousePressEvent</a>( <a href="qmouseevent.html">TQMouseEvent</a> *e ) +<p> <pre> <a name="x2586"></a>void CanvasView::<a href="ntqscrollview.html#contentsMousePressEvent">contentsMousePressEvent</a>( <a href="qmouseevent.html">TQMouseEvent</a> *e ) { <a name="x2580"></a> <a href="qcanvasitemlist.html">TQCanvasItemList</a> list = <a href="qcanvasview.html#canvas">canvas</a>()->collisions( e-><a href="qmouseevent.html#pos">pos</a>() ); - <a name="x2589"></a><a name="x2588"></a> for ( TQCanvasItemList::iterator it = list.<a href="qvaluelist.html#begin">begin</a>(); it != list.<a href="qvaluelist.html#end">end</a>(); ++it ) + <a name="x2589"></a><a name="x2588"></a> for ( TQCanvasItemList::iterator it = list.<a href="ntqvaluelist.html#begin">begin</a>(); it != list.<a href="ntqvaluelist.html#end">end</a>(); ++it ) if ( (*it)->rtti() == CanvasText::CANVAS_TEXT ) { m_movingItem = *it; m_pos = e-><a href="qmouseevent.html#pos">pos</a>(); @@ -313,13 +313,13 @@ drag and release at the new position. the mouse click "collided" with (if any). We then iterate over this list and if we find a <tt>CanvasText</tt> item we set it as the moving item and record its position. Otherwise we set there to be no moving item. -<p> <pre> <a name="x2585"></a>void CanvasView::<a href="qscrollview.html#contentsMouseMoveEvent">contentsMouseMoveEvent</a>( <a href="qmouseevent.html">TQMouseEvent</a> *e ) +<p> <pre> <a name="x2585"></a>void CanvasView::<a href="ntqscrollview.html#contentsMouseMoveEvent">contentsMouseMoveEvent</a>( <a href="qmouseevent.html">TQMouseEvent</a> *e ) { if ( m_movingItem ) { - <a href="qpoint.html">TQPoint</a> offset = e-><a href="qmouseevent.html#pos">pos</a>() - m_pos; - <a name="x2582"></a><a name="x2581"></a> m_movingItem->moveBy( offset.<a href="qpoint.html#x">x</a>(), offset.<a href="qpoint.html#y">y</a>() ); + <a href="ntqpoint.html">TQPoint</a> offset = e-><a href="qmouseevent.html#pos">pos</a>() - m_pos; + <a name="x2582"></a><a name="x2581"></a> m_movingItem->moveBy( offset.<a href="ntqpoint.html#x">x</a>(), offset.<a href="ntqpoint.html#y">y</a>() ); m_pos = e-><a href="qmouseevent.html#pos">pos</a>(); - ChartForm *form = (ChartForm*)<a href="qobject.html#parent">parent</a>(); + ChartForm *form = (ChartForm*)<a href="ntqobject.html#parent">parent</a>(); form->setChanged( TRUE ); int chartType = form->chartType(); CanvasText *item = (CanvasText*)m_movingItem; @@ -346,10 +346,10 @@ corresponds to. We subclassed <a href="qcanvastext.html">TQCanvasText</a> so tha this index value. Finally we call update() to make the canvas redraw. <p> <center><table cellpadding="4" cellspacing="2" border="0"> <tr bgcolor="#f0f0f0"> -<td valign="top">A <a href="qcanvas.html">TQCanvas</a> has no visual representation. To see the contents of a +<td valign="top">A <a href="ntqcanvas.html">TQCanvas</a> has no visual representation. To see the contents of a canvas you must create a <a href="qcanvasview.html">TQCanvasView</a> to present the canvas. Items only appear in the canvas view if they have been show()n, and then, only if -<a href="qcanvas.html#update">TQCanvas::update</a>() has been called. By default a TQCanvas's background +<a href="ntqcanvas.html#update">TQCanvas::update</a>() has been called. By default a TQCanvas's background color is white, and by default shapes drawn on the canvas, e.g. <a href="qcanvasrectangle.html">TQCanvasRectangle</a>, <a href="qcanvasellipse.html">TQCanvasEllipse</a>, etc., have their fill color set to white, so setting a non-white brush color is highly recommended! |