From 68b81013e8668f50fc18b7e26a520ec93a7a1251 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Fri, 31 May 2024 11:32:43 +0900 Subject: Rename nt* canvas related files to equivalent tq* Signed-off-by: Michele Calgaro --- doc/html/tutorial2-06.html | 64 +++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'doc/html/tutorial2-06.html') diff --git a/doc/html/tutorial2-06.html b/doc/html/tutorial2-06.html index 4f1ff0bf5..3d5977d7f 100644 --- a/doc/html/tutorial2-06.html +++ b/doc/html/tutorial2-06.html @@ -43,7 +43,7 @@ drawElements() function is called to redraw the canvas when necessary.
    void ChartForm::drawElements()
     {
-        TQCanvasItemList list = m_canvas->allItems();
+        TQCanvasItemList list = m_canvas->allItems();
         for ( TQCanvasItemList::iterator it = list.begin(); it != list.end(); ++it )
             delete *it;
 
@@ -135,15 +135,15 @@ it to NoPen so that no outlines are drawn.

We iterate over every element in the element vector, skipping invalid elements. The extent of each bar (its length) is simply its scaled value. -

                TQCanvasRectangle *rect = new TQCanvasRectangle(
+

                TQCanvasRectangle *rect = new TQCanvasRectangle(
                                                 0, y, extent, proheight, m_canvas );
-                rect->setBrush( TQBrush( m_elements[i].valueColor(),
+                rect->setBrush( TQBrush( m_elements[i].valueColor(),
                                         BrushStyle(m_elements[i].valuePattern()) ) );
-                rect->setPen( pen );
-                rect->setZ( 0 );
-                rect->show();
+                rect->setPen( pen );
+                rect->setZ( 0 );
+                rect->show();
 
-

We create a new TQCanvasRectangle for each bar with an x position of 0 +

We create a new TQCanvasRectangle for each bar with an x position of 0 (since this is a horizontal bar chart every bar begins at the left), a y value that starts at 0 and grows by the height of each bar as each one is drawn, the height of the bar and the canvas that the bar should @@ -176,11 +176,11 @@ containing the label text. (The valueLabel() function adds on the value or percentage to the textual label if the user has set the appropriate options.)

                    CanvasText *text = new CanvasText( i, label, m_font, m_canvas );
-                    text->setColor( m_elements[i].labelColor() );
-                    text->setX( proX * width );
-                    text->setY( proY * height );
-                    text->setZ( 1 );
-                    text->show();
+                    text->setColor( m_elements[i].labelColor() );
+                    text->setX( proX * width );
+                    text->setY( proY * height );
+                    text->setZ( 1 );
+                    text->show();
                     m_elements[i].setProX( HORIZONTAL_BAR, proX );
                     m_elements[i].setProY( HORIZONTAL_BAR, proY );
 
@@ -201,22 +201,22 @@ proportional height ready to draw the next element. } }
-

Subclassing TQCanvasText +

Subclassing TQCanvasText

(Extracts from canvastext.h.)

-

    class CanvasText : public TQCanvasText
+
    class CanvasText : public TQCanvasText
     {
     public:
         enum { CANVAS_TEXT = 1100 };
 
         CanvasText( int index, TQCanvas *canvas )
-            : TQCanvasText( canvas ), m_index( index ) {}
+            : TQCanvasText( canvas ), m_index( index ) {}
         CanvasText( int index, const TQString& text, TQCanvas *canvas )
-            : TQCanvasText( text, canvas ), m_index( index ) {}
+            : TQCanvasText( text, canvas ), m_index( index ) {}
         CanvasText( int index, const TQString& text, TQFont font, TQCanvas *canvas )
-            : TQCanvasText( text, font, canvas ), m_index( index ) {}
+            : TQCanvasText( text, font, canvas ), m_index( index ) {}
 
         int index() const { return m_index; }
         void setIndex( int index ) { m_index = index; }
@@ -228,21 +228,21 @@ proportional height ready to draw the next element.
     };
 

Our CanvasText subclass is a very simple specialisation of -TQCanvasText. All we've done is added a single private member m_index which holds the element vector index of the element associated +TQCanvasText. All we've done is added a single private member m_index which holds the element vector index of the element associated with this text item, and provided a getter and setter for this value. -

Subclassing TQCanvasView +

Subclassing TQCanvasView

(Extracts from canvasview.h.)

-

    class CanvasView : public TQCanvasView
+
    class CanvasView : public TQCanvasView
     {
         TQ_OBJECT
     public:
-        CanvasView( TQCanvas *canvas, ElementVector *elements,
+        CanvasView( TQCanvas *canvas, ElementVector *elements,
                     TQWidget* parent = 0, const char* name = "canvas view",
                     WFlags f = 0 )
-            : TQCanvasView( canvas, parent, name, f ), m_movingItem(0),
+            : TQCanvasView( canvas, parent, name, f ), m_movingItem(0),
               m_elements( elements ) {}
 
     protected:
@@ -252,12 +252,12 @@ with this text item, and provided a getter and setter for this value.
         void contentsContextMenuEvent( TQContextMenuEvent *e );
 
     private:
-        TQCanvasItem *m_movingItem;
+        TQCanvasItem *m_movingItem;
         TQPoint m_pos;
         ElementVector *m_elements;
     };
 
-

We need to subclass TQCanvasView so that we can handle: +

We need to subclass TQCanvasView so that we can handle:

  1. Context menu requests.
  2. Form resizing. @@ -284,7 +284,7 @@ position.

        void CanvasView::viewportResizeEvent( TQResizeEvent *e )
         {
    -        canvas()->resize( e->size().width(), e->size().height() );
    +        canvas()->resize( e->size().width(), e->size().height() );
             ((ChartForm*)parent())->drawElements();
         }
     
    @@ -299,7 +299,7 @@ drawn correctly. drag and release at the new position.

        void CanvasView::contentsMousePressEvent( TQMouseEvent *e )
         {
    -        TQCanvasItemList list = canvas()->collisions( e->pos() );
    +        TQCanvasItemList list = canvas()->collisions( e->pos() );
             for ( TQCanvasItemList::iterator it = list.begin(); it != list.end(); ++it )
                 if ( (*it)->rtti() == CanvasText::CANVAS_TEXT ) {
                     m_movingItem = *it;
    @@ -328,7 +328,7 @@ and record its position. Otherwise we set there to be no moving item.
                 (*m_elements)[i].setProX( chartType, item->x() / canvas()->width() );
                 (*m_elements)[i].setProY( chartType, item->y() / canvas()->height() );
     
    -            canvas()->update();
    +            canvas()->update();
             }
         }
     
    @@ -342,16 +342,16 @@ element's proportional x and y positions for the current chart type to the current x and y positions proportional to the width and height respectively. We know which element to update because when we create each canvas text item we pass it the index position of the element it -corresponds to. We subclassed TQCanvasText so that we could set and get +corresponds to. We subclassed TQCanvasText so that we could set and get this index value. Finally we call update() to make the canvas redraw.

    -
    A TQCanvas has no visual representation. To see the contents of a -canvas you must create a TQCanvasView to present the canvas. Items only +A TQCanvas has no visual representation. To see the contents of a +canvas you must create a TQCanvasView to present the canvas. Items only appear in the canvas view if they have been show()n, and then, only if -TQCanvas::update() has been called. By default a TQCanvas's background +TQCanvas::update() has been called. By default a TQCanvas's background color is white, and by default shapes drawn on the canvas, e.g. -TQCanvasRectangle, TQCanvasEllipse, etc., have their fill color set to +TQCanvasRectangle, TQCanvasEllipse, etc., have their fill color set to white, so setting a non-white brush color is highly recommended!

    -- cgit v1.2.3