From 82ecd83484c9fa1ede059986ab771e74e33e68ef Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Fri, 16 Aug 2024 19:11:00 +0900 Subject: Rename layout nt* related files to equivalent tq* Signed-off-by: Michele Calgaro --- doc/html/customlayout.html | 76 +++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'doc/html/customlayout.html') diff --git a/doc/html/customlayout.html b/doc/html/customlayout.html index ec772f1c6..3341c0de6 100644 --- a/doc/html/customlayout.html +++ b/doc/html/customlayout.html @@ -35,46 +35,46 @@ body { background: #ffffff; color: black; }

Here we present an example in detail. The class CardLayout is inspired by the Java layout manager of the same name. It lays out the items (widgets or nested layouts) on top of each other, each item offset by -TQLayout::spacing(). +TQLayout::spacing().

To write your own layout class, you must define the following:

-

In most cases, you will also implement minimumSize(). +

In most cases, you will also implement minimumSize().

card.h

 #ifndef CARD_H
 #define CARD_H
 
-#include <ntqlayout.h>
+#include <tqlayout.h>
 #include <tqptrlist.h>
 
-class CardLayout : public TQLayout
+class CardLayout : public TQLayout
 {
 public:
     CardLayout( TQWidget *parent, int dist )
-        : TQLayout( parent, 0, dist ) {}
-    CardLayout( TQLayout* parent, int dist)
-        : TQLayout( parent, dist ) { }
+        : TQLayout( parent, 0, dist ) {}
+    CardLayout( TQLayout* parent, int dist)
+        : TQLayout( parent, dist ) { }
     CardLayout( int dist )
-        : TQLayout( dist ) {}
+        : TQLayout( dist ) {}
     ~CardLayout();
 
     void addItem(TQLayoutItem *item);
     TQSize sizeHint() const;
     TQSize minimumSize() const;
-    TQLayoutIterator iterator();
+    TQLayoutIterator iterator();
     void setGeometry(const TQRect &rect);
 
 private:
@@ -93,28 +93,28 @@ private:
 

First we define an iterator over the layout. Layout iterators are used internally by the layout system to handle deletion of widgets. They are also available for application programmers. -

There are two different classes involved: TQLayoutIterator is the class +

There are two different classes involved: TQLayoutIterator is the class that is visible to application programmers, it is explicitly shared. -The TQLayoutIterator contains a TQGLayoutIterator that does all the +The TQLayoutIterator contains a TQGLayoutIterator that does all the work. We must create a subclass of TQGLayoutIterator that knows how to iterate over our layout class.

In this case, we choose a simple implementation: we store an integer -index into the list and a pointer to the list. Every TQGLayoutIterator subclass must implement current(), next() and takeCurrent(), as well as a +index into the list and a pointer to the list. Every TQGLayoutIterator subclass must implement current(), next() and takeCurrent(), as well as a constructor. In our example we do not need a destructor.

-class CardLayoutIterator : public TQGLayoutIterator
+class CardLayoutIterator : public TQGLayoutIterator
 {
 public:
     CardLayoutIterator( TQPtrList<TQLayoutItem> *l )
         : idx( 0 ), list( l ) {}
 
-    TQLayoutItem *current()
+    TQLayoutItem *current()
     { return idx < int(list->count()) ? list->at(idx) : 0;  }
 
-    TQLayoutItem *next()
+    TQLayoutItem *next()
     { idx++; return current(); }
 
-    TQLayoutItem *takeCurrent()
+    TQLayoutItem *takeCurrent()
     { return list->take( idx ); }
 
 private:
@@ -123,7 +123,7 @@ private:
 };
 
-

We must implement TQLayout:iterator() to return a TQLayoutIterator over +

We must implement TQLayout:iterator() to return a TQLayoutIterator over this layout.

 TQLayoutIterator CardLayout::iterator()
@@ -133,21 +133,21 @@ TQLayoutIterator CardLayout::iterator()
 

addItem() implements the default placement strategy for layout items. -It must be implemented. It is used by TQLayout::add(), by the TQLayout +It must be implemented. It is used by TQLayout::add(), by the TQLayout constructor that takes a layout as parent, and it is used to implement -the auto-add feature. If your layout +the auto-add feature. If your layout has advanced placement options that require parameters, you must provide extra access functions such as TQGridLayout::addMultiCell().

-void CardLayout::addItem( TQLayoutItem *item )
+void CardLayout::addItem( TQLayoutItem *item )
 {
     list.append( item );
 }
 

The layout takes over responsibility of the items added. Since -TQLayoutItem does not inherit TQObject, we must delete the items -manually. The function TQLayout::deleteAllItems() uses the iterator we +TQLayoutItem does not inherit TQObject, we must delete the items +manually. The function TQLayout::deleteAllItems() uses the iterator we defined above to delete all the items in the layout.

 CardLayout::~CardLayout()
@@ -162,13 +162,13 @@ spacing() as the distance between items.
 

 void CardLayout::setGeometry( const TQRect &rect )
 {
-    TQLayout::setGeometry( rect );
+    TQLayout::setGeometry( rect );
 
     TQPtrListIterator<TQLayoutItem> it( list );
     if (it.count() == 0)
         return;
 
-    TQLayoutItem *item;
+    TQLayoutItem *item;
 
     int i = 0;
 
@@ -179,7 +179,7 @@ void CardLayout::setGeometry( const TQRect &rect )
         ++it;
         TQRect geom( rect.x() + i * spacing(), rect.y() + i * spacing(),
                     w, h );
-        item->setGeometry( geom );
+        item->setGeometry( geom );
         ++i;
     }
 }
@@ -196,10 +196,10 @@ TQSize CardLayout::sizeHint() const
     if ( n > 0 )
         s = TQSize( 100, 70 ); // start with a nice default size
     TQPtrListIterator<TQLayoutItem> it( list );
-    TQLayoutItem *item;
+    TQLayoutItem *item;
     while ( (item = it.current()) != 0 ) {
         ++it;
-        s = s.expandedTo( item->minimumSize() );
+        s = s.expandedTo( item->minimumSize() );
     }
     return s + n * TQSize( spacing(), spacing() );
 }
@@ -209,10 +209,10 @@ TQSize CardLayout::minimumSize() const
     TQSize s( 0, 0 );
     int n = list.count();
     TQPtrListIterator<TQLayoutItem> it( list );
-    TQLayoutItem *item;
+    TQLayoutItem *item;
     while ( (item = it.current()) != 0 ) {
         ++it;
-        s = s.expandedTo( item->minimumSize() );
+        s = s.expandedTo( item->minimumSize() );
     }
     return s + n * TQSize( spacing(), spacing() );
 }
@@ -221,15 +221,15 @@ TQSize CardLayout::minimumSize() const
 

Further Notes

This layout does not implement heightForWidth(). -

We ignore TQLayoutItem::isEmpty(), this means that the layout will +

We ignore TQLayoutItem::isEmpty(), this means that the layout will treat hidden widgets as visible.

For complex layouts, speed can be greatly increased by caching -calculated values. In that case, implement TQLayoutItem::invalidate() +calculated values. In that case, implement TQLayoutItem::invalidate() to mark the cached data as dirty. -

Calling TQLayoutItem::sizeHint(), etc. may be expensive, so you should +

Calling TQLayoutItem::sizeHint(), etc. may be expensive, so you should store the value in a local variable if you need it again later in the same function. -

You should not call TQLayoutItem::setGeometry() twice on the same item +

You should not call TQLayoutItem::setGeometry() twice on the same item in the same function. That can be very expensive if the item has several child widgets, because it will have to do a complete layout every time. Instead, calculate the geometry and then set it. (This -- cgit v1.2.3