/**************************************************************************** ** ** Definition of tqlayout classes ** ** Created : 960416 ** ** Copyright (C) 2010 Timothy Pearson and (C) 1992-2008 Trolltech ASA. ** ** This file is part of the kernel module of the TQt GUI Toolkit. ** ** This file may be used under the terms of the GNU General ** Public License versions 2.0 or 3.0 as published by the Free ** Software Foundation and appearing in the files LICENSE.GPL2 ** and LICENSE.GPL3 included in the packaging of this file. ** Alternatively you may (at your option) use any later version ** of the GNU General Public License if such license has been ** publicly approved by Trolltech ASA (or its successors, if any) ** and the KDE Free TQt Foundation. ** ** Please review the following information to ensure GNU General ** Public Licensing requirements will be met: ** http://trolltech.com/products/qt/licenses/licensing/opensource/. ** If you are unsure which license is appropriate for your use, please ** review the following information: ** http://trolltech.com/products/qt/licenses/licensing/licensingoverview ** or contact the sales department at sales@trolltech.com. ** ** This file may be used under the terms of the Q Public License as ** defined by Trolltech ASA and appearing in the file LICENSE.TQPL ** included in the packaging of this file. Licensees holding valid TQt ** Commercial licenses may use this file in accordance with the TQt ** Commercial License Agreement provided with the Software. ** ** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, ** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted ** herein. ** **********************************************************************/ // TQT TODO: // 1. TQLayout and TQGridLayout addItem functions may not be able to be subclassed by TQt classes // This will probably require an inline redirect from the Qt4 method addItem(QLayoutItem) to the TQt method addItem(TQLayoutItem) // See also TQLayout::setGeometry() for an example of how to do this // See tqlayout.cpp line 3074 for why this is needed // MAYBE????? #ifndef TQLAYOUT_H #define TQLAYOUT_H #include "tqtglobaldefines.h" #ifndef TQT_H #include "tqobject.h" #include "tqsizepolicy.h" #include "tqwidget.h" #endif // TQT_H #include #ifndef TQT_NO_LAYOUT #ifdef USE_QT4 #include #endif // USE_QT4 #if 0 TQ_OBJECT #endif static const int TQLAYOUTSIZE_MAX = INT_MAX/256/16; class TQGridLayoutBox; class TQGridLayoutData; class TQLayout; class TQLayoutItem; struct TQLayoutData; class TQMenuBar; class TQSpacerItem; class TQWidget; class TQ_EXPORT TQGLayoutIterator : public TQShared { public: virtual ~TQGLayoutIterator(); virtual TQLayoutItem *next() = 0; virtual TQLayoutItem *current() = 0; virtual TQLayoutItem *takeCurrent() = 0; }; #ifdef USE_QT4 class TQ_EXPORT TQLayoutIterator { public: TQLayoutIterator(QLayout *i); inline TQLayoutIterator(const TQLayoutIterator &i) : layout(i.layout), index(i.index) {} inline TQLayoutIterator &operator=(const TQLayoutIterator &i) { layout = i.layout; index = i.index; return *this; } TQLayoutItem *operator++(); TQLayoutItem *current(); TQLayoutItem *takeCurrent(); void deleteCurrent(); private: // hack to avoid deprecated warning friend class QLayout; friend class TQLayout; TQLayoutIterator(QLayout *i, bool); TQLayout *layout; int index; }; #else // USE_QT4 class TQ_EXPORT TQLayoutIterator { public: TQLayoutIterator( TQGLayoutIterator *i ) : it( i ) { } TQLayoutIterator( const TQLayoutIterator &i ) : it( i.it ) { if ( it ) it->ref(); } ~TQLayoutIterator() { if ( it && it->deref() ) delete it; } TQLayoutIterator &operator=( const TQLayoutIterator &i ) { if ( i.it ) i.it->ref(); if ( it && it->deref() ) delete it; it = i.it; return *this; } TQLayoutItem *operator++() { return it ? it->next() : 0; } TQLayoutItem *current() { return it ? it->current() : 0; } TQLayoutItem *takeCurrent() { return it ? it->takeCurrent() : 0; } void deleteCurrent(); private: TQGLayoutIterator *it; }; #endif // USE_QT4 #ifdef USE_QT4 // Abstract base classes cannot have their abstract methods modified or added to // Also, all TQt functions MUST be NON VIRTUAL (and are recommended to be inline as well) <-- this may not always be true // Virtual functions are resolved at run time, causing all kinds of problems at runtime with the interface layer class TQ_EXPORT TQLayoutItem : public QLayoutItem, virtual public TQt { public: TQLayoutItem( int tqalignment = 0 ) : QLayoutItem( (Qt::Alignment)tqalignment ) {} inline int tqalignment() const { return alignment(); } TQSpacerItem *tqspacerItem(); inline TQLayout *tqlayout() { return 0; } inline TQWidget *widget() { return static_cast(QLayoutItem::widget()); } // inline bool hasHeightForWidth() const { return QLayoutItem::hasHeightForWidth(); } // inline int heightForWidth( int i ) const { return QLayoutItem::heightForWidth( i ); } // inline virtual TQLayoutIterator iterator() { return TQLayoutIterator( 0 ); } inline TQLayoutIterator iterator() { return TQLayoutIterator( 0 ); } inline void tqsetAlignment( int a ) { QLayoutItem::setAlignment((Qt::AlignmentFlag)a); } virtual inline void tqinvalidate() { QLayoutItem::invalidate(); } virtual inline void invalidate() { tqinvalidate(); } // inline virtual TQSize tqsizeHint() const { return QLayoutItem::sizeHint(); } // inline virtual TQSize tqminimumSize() const { return QLayoutItem::minimumSize(); } // inline virtual TQSize tqmaximumSize() const { return QLayoutItem::maximumSize(); } // inline virtual void setGeometry( const TQRect&r ) { QLayoutItem::setGeometry(r); } // inline virtual TQRect tqgeometry() const { return QLayoutItem::geometry(); } // inline virtual TQ_SPExpandData expandingDirections() const { return QLayoutItem::expandingDirections(); } // These functions are pure virtual in Qt4 inline TQSize tqsizeHint() const { return sizeHint(); } inline TQSize tqminimumSize() const { return minimumSize(); } inline TQSize tqmaximumSize() const { return maximumSize(); } // inline void setGeometry( const TQRect&r ) { TQ_UNUSED(r); } inline TQRect tqgeometry() const { return geometry(); } }; // Use the TQt virtual functions, not the built in Qt ones... // This requires that the base virtual Qt functions be reimplemented so as to point to the TQt virtual functions instead as shown below. // This way, when Trinity overrides a TQt virtual function, the calling Qt code will blithely use the overriden TQt function instead. #define QLAYOUTITEM_REQUIRED_FUNCTIONS \ virtual inline QSize sizeHint() const { return tqsizeHint(); } \ virtual inline QSize minimumSize() const { return tqminimumSize(); } \ virtual inline QSize maximumSize() const { return tqmaximumSize(); } \ virtual inline void setGeometry( const QRect &r ) { return setGeometry( TQT_TQRECT_OBJECT(r) ); } \ virtual inline QRect geometry() const { return tqgeometry(); } // inline void setAlignment( Qt::AlignmentFlag a ) { return tqsetAlignment(a); } // class TQ_EXPORT TQLayoutItem : public QLayoutItem, virtual public TQt // { // public: // TQLayoutItem( int tqalignment = 0 ) : QLayoutItem( (Qt::Alignment)tqalignment ) {} // virtual ~TQLayoutItem(); // // inline int tqalignment() const { return alignment(); } // // virtual TQSpacerItem *tqspacerItem(); // virtual TQLayout *tqlayout(); // virtual TQWidget *widget(); // virtual bool hasHeightForWidth() const; // virtual int heightForWidth( int ) const; // virtual TQLayoutIterator iterator(); // // virtual TQSize tqsizeHint() const = 0; // virtual TQSize tqminimumSize() const = 0; // virtual TQSize tqmaximumSize() const = 0; // virtual void setGeometry( const TQRect& ) = 0; // virtual TQRect tqgeometry() const = 0; // virtual void tqsetAlignment( int a ); // virtual void tqinvalidate(); // virtual TQ_SPExpandData expandingDirections() const; // // // Use the TQt virtual functions, not the built in Qt ones... // // This requires that the base virtual Qt functions be reimplemented so as to point to the TQt virtual functions instead as shown below. // // This way, when Trinity overrides a TQt virtual function, the calling Qt code will blithely use the overriden TQt function instead. // inline QSize sizeHint() const { return tqsizeHint(); } // inline QSize minimumSize() const { return tqminimumSize(); } // inline QSize maximumSize() const { return tqmaximumSize(); } // inline void setGeometry( const QRect &r ) { return TQLayoutItem::setGeometry( r ); } // inline QRect geometry() const { return tqgeometry(); } // inline void setAlignment( Qt::AlignmentFlag a ) { return tqsetAlignment(a); } // inline void invalidate() { return tqinvalidate(); } // inline Qt::Orientations expandingDirections() const { return TQLayoutItem::expandingDirections(); } // }; #else // USE_QT4 class TQ_EXPORT TQLayoutItem { public: TQLayoutItem( int tqalignment = 0 ) : align( tqalignment ) { } virtual ~TQLayoutItem(); virtual TQSize tqsizeHint() const = 0; virtual TQSize tqminimumSize() const = 0; virtual TQSize tqmaximumSize() const = 0; virtual TQ_SPExpandData expandingDirections() const = 0; virtual void setGeometry( const TQRect& ) = 0; virtual TQRect tqgeometry() const = 0; virtual bool isEmpty() const = 0; virtual bool hasHeightForWidth() const; virtual int heightForWidth( int ) const; // ### add minimumHeightForWidth( int ) in TQt 4.0 virtual void tqinvalidate(); virtual TQWidget *widget(); virtual TQLayoutIterator iterator(); virtual TQLayout *tqlayout(); virtual TQSpacerItem *tqspacerItem(); int tqalignment() const { return align; } virtual void tqsetAlignment( int a ); protected: int align; }; #endif // USE_QT4 #ifdef USE_QT4 class TQ_EXPORT TQSpacerItem : public QSpacerItem, virtual public TQt { public: TQSpacerItem( int w, int h, TQSizePolicy::SizeType hData = TQSizePolicy::Minimum, TQSizePolicy::SizeType vData = TQSizePolicy::Minimum ) : QSpacerItem( w, h, hData, vData ) {} TQSpacerItem *tqspacerItem(); // Used by tqabstractlayout.cpp inline void changeSize( int w, int h, TQSizePolicy::SizeType hData = TQSizePolicy::Minimum, TQSizePolicy::SizeType vData = TQSizePolicy::Minimum ) { return QSpacerItem::changeSize( w, h, hData, vData ); } TQ_SPExpandData expandingDirections() const; // Used by tqabstractlayout.cpp bool isEmpty() const; // Used by tqabstractlayout.cpp TQSize tqsizeHint() const; TQSize tqminimumSize() const; TQSize tqmaximumSize() const; void setGeometry( const TQRect &qr ); TQRect tqgeometry() const; // Use the TQt virtual functions, not the built in Qt ones... // This requires that the base virtual Qt functions be reimplemented so as to point to the TQt virtual functions instead as shown below. // This way, when Trinity overrides a TQt virtual function, the calling Qt code will blithely use the overriden TQt function instead. inline QSize sizeHint() const { return tqsizeHint(); } inline QSize minimumSize() const { return tqminimumSize(); } inline QSize maximumSize() const { return tqmaximumSize(); } inline void setGeometry( const QRect &r ) { return TQSpacerItem::setGeometry( TQT_TQRECT_OBJECT(r) ); } inline QRect geometry() { return tqgeometry(); } }; #else // USE_QT4 class TQ_EXPORT TQSpacerItem : public TQLayoutItem { public: TQSpacerItem( int w, int h, TQSizePolicy::SizeType hData = TQSizePolicy::Minimum, TQSizePolicy::SizeType vData = TQSizePolicy::Minimum ) : width( w ), height( h ), sizeP( hData, vData ) { } void changeSize( int w, int h, TQSizePolicy::SizeType hData = TQSizePolicy::Minimum, TQSizePolicy::SizeType vData = TQSizePolicy::Minimum ); TQSize tqsizeHint() const; TQSize tqminimumSize() const; TQSize tqmaximumSize() const; TQ_SPExpandData expandingDirections() const; bool isEmpty() const; void setGeometry( const TQRect& ); TQRect tqgeometry() const; TQSpacerItem *tqspacerItem(); private: int width; int height; TQSizePolicy sizeP; TQRect rect; }; #endif // USE_QT4 class TQ_EXPORT TQWidgetItem : public TQLayoutItem { public: TQWidgetItem( TQWidget *w ) : wid( w ) { } TQSize tqsizeHint() const; TQSize tqminimumSize() const; TQSize tqmaximumSize() const; TQ_SPExpandData expandingDirections() const; bool isEmpty() const; void setGeometry( const TQRect& ); TQRect tqgeometry() const; virtual TQWidget *widget(); bool hasHeightForWidth() const; int heightForWidth( int ) const; QLAYOUTITEM_REQUIRED_FUNCTIONS private: TQWidget *wid; }; #ifdef USE_QT4 // #if 0 extern int menuBarHeightForWidth( QWidget *menubar, int w ); class TQ_EXPORT TQLayout : public QLayout, virtual public TQt { Q_OBJECT TQ_OBJECT public: enum ResizeMode { FreeResize = QLayout::SetNoConstraint, Minimum = QLayout::SetMinimumSize, Fixed = QLayout::SetFixedSize, Auto = QLayout::SetDefaultConstraint }; TQLayout( QWidget *parent, int margin = 0, int spacing = -1, const char *name = 0 ); TQLayout( QLayout *parentLayout, int spacing = -1, const char *name = 0 ); TQLayout( int spacing = -1, const char *name = 0 ); virtual TQ_SPExpandData expandingDirections() const; TQLayout *tqlayout(); virtual TQSize tqsizeHint() const; virtual TQSize tqminimumSize() const; virtual TQSize tqmaximumSize() const; TQWidget *mainWidget(); virtual void tqinvalidate(); virtual void invalidate(); virtual TQRect tqgeometry() const; const char *tqname() const; const char *name() const; int tqalignment() const; TQWidget *mainWidget() const; void remove(QWidget *w); void add(QWidget *w); void setResizeMode(SizeConstraint s); void setResizeMode(ResizeMode s); SizeConstraint resizeMode() const; ResizeMode tqresizeMode() const; void setAutoAdd(bool a); bool autoAdd() const; void tqsetAlignment( int a ); // bool isTopLevel() const; void freeze( int w, int h ); void freeze() { setResizeMode( Fixed ); } TQMetaObject *tqmetaObject() const; // Required to interface correctly, as QLayout is not a derived class of TQWidget or TQObject public: // TQt handler // virtual bool eventFilter( TQObject *, TQEvent * ); // Qt4 handler interface bool eventFilter( QObject *q, QEvent *e ); // TQt event handlers protected: virtual bool event( TQEvent *e ); // TQFocusData *focusData(); bool event( QEvent *e ); // virtual void mousePressEvent( TQMouseEvent * ); // NOTE: All event handlers that can be subclassed must be declared here, and // virtual void mouseReleaseEvent( TQMouseEvent * ); // declared virtual, so that run time dynamic call resolution will occur // virtual void mouseDoubleClickEvent( TQMouseEvent * ); // virtual void mouseMoveEvent( TQMouseEvent * ); // #ifndef TQT_NO_WHEELEVENT // virtual void wheelEvent( TQWheelEvent * ); // #endif // virtual void keyPressEvent( TQKeyEvent * ); // virtual void keyReleaseEvent( TQKeyEvent * ); // virtual void focusInEvent( TQFocusEvent * ); // virtual void focusOutEvent( TQFocusEvent * ); // virtual void enterEvent( TQEvent * ); // virtual void leaveEvent( TQEvent * ); // virtual void paintEvent( TQPaintEvent * ); // virtual void moveEvent( TQMoveEvent * ); // virtual void resizeEvent( TQResizeEvent * ); // virtual void closeEvent( TQCloseEvent * ); // virtual void contextMenuEvent( TQContextMenuEvent * ); // virtual void imStartEvent( TQIMEvent * ); // virtual void imComposeEvent( TQIMEvent * ); // virtual void imEndEvent( TQIMEvent * ); // virtual void tabletEvent( TQTabletEvent * ); // // #ifndef TQT_NO_DRAGANDDROP // virtual void dragEnterEvent( TQDragEnterEvent * ); // virtual void dragMoveEvent( TQDragMoveEvent * ); // virtual void dragLeaveEvent( TQDragLeaveEvent * ); // virtual void dropEvent( TQDropEvent * ); // #endif // // virtual void showEvent( TQShowEvent * ); // virtual void hideEvent( TQHideEvent * ); // // Qt4 event handler interface // protected: // inline virtual void mousePressEvent(QMouseEvent *e) { mousePressEvent(static_cast(e)); } // QLayout::mousePressEvent(e) } // inline virtual void mouseReleaseEvent(QMouseEvent *e) { mouseReleaseEvent(static_cast(e)); } // QLayout::mouseReleaseEvent(e) } // inline virtual void mouseDoubleClickEvent(QMouseEvent *e) { mouseDoubleClickEvent(static_cast(e)); } // QLayout::mouseDoubleClickEvent(e) } // inline virtual void mouseMoveEvent(QMouseEvent *e) { mouseMoveEvent(static_cast(e)); } // QLayout::mouseMoveEvent(e) } // #ifndef QT_NO_WHEELEVENT // inline virtual void wheelEvent(QWheelEvent *e) { wheelEvent(static_cast(e)); } // QLayout::wheelEvent(e) } // #endif // inline virtual void keyPressEvent(QKeyEvent *e) { keyPressEvent(static_cast(e)); } // QLayout::keyPressEvent(e) } // inline virtual void keyReleaseEvent(QKeyEvent *e) { keyReleaseEvent(static_cast(e)); } // QLayout::keyReleaseEvent(e) } // inline virtual void focusInEvent(QFocusEvent *e) { focusInEvent(static_cast(e)); } // QLayout::focusInEvent(e) } // inline virtual void focusOutEvent(QFocusEvent *e) { focusOutEvent(static_cast(e)); } // QLayout::focusOutEvent(e) } // inline virtual void enterEvent(QEvent *e) { enterEvent(static_cast(e)); } // QLayout::enterEvent(e) } // inline virtual void leaveEvent(QEvent *e) { leaveEvent(static_cast(e)); } // QLayout::leaveEvent(e) } // inline virtual void paintEvent(QPaintEvent *e) { paintEvent(static_cast(e)); } // QLayout::paintEvent(e) } // inline virtual void moveEvent(QMoveEvent *e) { moveEvent(static_cast(e)); } // QLayout::moveEvent(e) } // inline virtual void resizeEvent(QResizeEvent *e) { resizeEvent(static_cast(e)); } // QLayout::resizeEvent(e) } // inline virtual void closeEvent(QCloseEvent *e) { closeEvent(static_cast(e)); } // QLayout::closeEvent(e) } // #ifndef QT_NO_CONTEXTMENU // inline virtual void contextMenuEvent(QContextMenuEvent *e) { contextMenuEvent(static_cast(e)); } // QLayout::contextMenuEvent(e); } // #endif // #ifndef QT_NO_TABLETEVENT // inline virtual void tabletEvent(QTabletEvent *e) { tabletEvent(static_cast(e)); } // QLayout::tabletEvent(e) } // #endif // #ifndef QT_NO_ACTION // // inline virtual void actionEvent(QActionEvent *e) { actionEvent(static_cast(e)); QLayout::actionEvent(e) } // #endif // // // #ifndef QT_NO_DRAGANDDROP // // inline virtual void dragEnterEvent(QDragEnterEvent *e) { dragEnterEvent(static_cast(e)); QLayout::dragEnterEvent(e) } // // inline virtual void dragMoveEvent(QDragMoveEvent *e) { dragMoveEvent(static_cast(e)); QLayout::dragMoveEvent(e) } // // inline virtual void dragLeaveEvent(QDragLeaveEvent *e) { dragLeaveEvent(static_cast(e)); QLayout::dragLeaveEvent(e) } // // inline virtual void dropEvent(QDropEvent *e) { dropEvent(static_cast(e)); QLayout::dropEvent(e) } // // #endif // // inline virtual void showEvent(QShowEvent *e) { showEvent(static_cast(e)); } // QLayout::showEvent(e) } // inline virtual void hideEvent(QHideEvent *e) { hideEvent(static_cast(e)); } // QLayout::hideEvent(e) } // TQt event handlers protected: virtual void timerEvent( TQTimerEvent * ); virtual void childEvent( TQChildEvent * ); virtual void customEvent( TQCustomEvent * ); // Qt4 event handler interface protected: virtual void timerEvent(QTimerEvent *e); virtual void childEvent(QChildEvent *e); virtual void customEvent(QEvent *e); protected: bool eventFilter( TQObject *o, TQEvent *e ); public: // Interoperability static const TQLayout& convertFromQLayout( QLayout& ql ); // virtual void addItem( TQLayoutItem * ) = 0; TQLayoutIterator iterator(); QLayout *layout(); virtual void setGeometry(const TQRect &r); QLAYOUTITEM_REQUIRED_FUNCTIONS protected: void setSupportsMargin( bool ); // Implemented in tqabstractlayout.cpp TQRect alignmentRect( const TQRect& qr ) const; void deleteAllItems(); public Q_SLOTS: void tqt_handle_qt_destroyed(QObject* obj); Q_SIGNALS: void destroyed( TQObject* obj ); private: bool autoNewChild; mutable TQString static_object_name; }; // Interoperability inline static const TQLayout& convertFromQLayout( const QLayout& ql ) { return (*static_cast(&ql)); } #else // USE_QT4 class TQ_EXPORT TQLayout : public TQObject, public TQLayoutItem { Q_OBJECT TQ_OBJECT TQ_ENUMS( ResizeMode ) Q_PROPERTY( int margin READ margin WRITE setMargin ) Q_PROPERTY( int spacing READ spacing WRITE setSpacing ) Q_PROPERTY( ResizeMode resizeMode READ resizeMode WRITE setResizeMode ) public: // ### TQt 4.0: put 'Auto' first in enum enum ResizeMode { FreeResize, Minimum, Fixed, Auto }; TQLayout( TQWidget *parent, int margin = 0, int spacing = -1, const char *name = 0 ); TQLayout( TQLayout *parentLayout, int spacing = -1, const char *name = 0 ); TQLayout( int spacing = -1, const char *name = 0 ); ~TQLayout(); int margin() const { return outsideBorder; } int spacing() const { return insideSpacing; } virtual void setMargin( int ); virtual void setSpacing( int ); int defaultBorder() const { return insideSpacing; } void freeze( int w, int h ); void freeze() { setResizeMode( Fixed ); } void setResizeMode( ResizeMode ); ResizeMode resizeMode() const; #ifndef TQT_NO_MENUBAR virtual void setMenuBar( TQMenuBar *w ); TQMenuBar *menuBar() const { return menubar; } #endif TQWidget *mainWidget(); bool isTopLevel() const { return topLevel; } virtual void setAutoAdd( bool ); bool autoAdd() const { return autoNewChild; } void tqinvalidate(); TQRect tqgeometry() const; bool activate(); void add( TQWidget *w ) { addItem( new TQWidgetItem(w) ); } virtual void addItem( TQLayoutItem * ) = 0; void remove( TQWidget *w ); void removeItem( TQLayoutItem * ); TQ_SPExpandData expandingDirections() const; TQSize tqminimumSize() const; TQSize tqmaximumSize() const; void setGeometry( const TQRect& ) = 0; TQLayoutIterator iterator() = 0; bool isEmpty() const; int totalHeightForWidth( int w ) const; TQSize totalMinimumSize() const; TQSize totalMaximumSize() const; TQSize totalSizeHint() const; TQLayout *tqlayout(); bool supportsMargin() const { return marginImpl; } void setEnabled( bool ); bool isEnabled() const; protected: bool eventFilter( TQObject *, TQEvent * ); void childEvent( TQChildEvent *e ); void addChildLayout( TQLayout *l ); void deleteAllItems(); void setSupportsMargin( bool ); TQRect alignmentRect( const TQRect& ) const; private: void setWidgetLayout( TQWidget *, TQLayout * ); void init(); int insideSpacing; int outsideBorder; uint topLevel : 1; uint enabled : 1; uint autoNewChild : 1; uint frozen : 1; uint activated : 1; uint marginImpl : 1; uint autoMinimum : 1; uint autoResizeMode : 1; TQRect rect; TQLayoutData *extraData; #ifndef TQT_NO_MENUBAR TQMenuBar *menubar; #endif private: #if defined(TQ_DISABLE_COPY) TQLayout( const TQLayout & ); TQLayout &operator=( const TQLayout & ); #endif static void propagateSpacing( TQLayout *tqlayout ); }; inline void TQLayoutIterator::deleteCurrent() { delete takeCurrent(); } #endif // USE_QT4 #define QLAYOUT_REQUIRED_METHOD_DECLARATIONS \ int count() const; \ TQLayoutItem* itemAt(int index) const; \ TQLayoutItem* takeAt(int index); \ virtual inline QSize sizeHint() const { return tqsizeHint(); } \ virtual inline QSize minimumSize() const { return tqminimumSize(); } \ virtual inline QSize maximumSize() const { return tqmaximumSize(); } \ virtual inline void setGeometry( const QRect &r ) { return setGeometry( TQT_TQRECT_OBJECT(r) ); } \ virtual inline QRect geometry() const { return tqgeometry(); } #define QLAYOUT_REQUIRED_METHOD_IMPLEMENTATIONS \ inline int count() const { \ return data->list.count(); \ } \ \ inline TQLayoutItem* itemAt(int index) const { \ return index >= 0 && index < data->list.count() ? data->list.at(index)->item : 0; \ } \ \ inline TQLayoutItem* takeAt(int index) { \ if (index < 0 || index >= data->list.count()) \ return 0; \ TQBoxLayoutItem *b = data->list.take(index); \ TQLayoutItem *item = b->item; \ b->item = 0; \ delete b; \ \ invalidate(); \ return item; \ } #if 0 class TQ_EXPORT TQGridLayout : public QGridLayout, virtual public TQt { Q_OBJECT TQ_OBJECT public: TQGridLayout( TQWidget *parent, int nRows = 1, int nCols = 1, int border = 0, int spacing = -1, const char *name = 0 ) : QGridLayout( parent ), autoNewChild(false) { expand(nRows, nCols); setMargin(border); setSpacing(spacing < 0 ? border : spacing); setObjectName(QString::fromAscii(name)); if ( parent ) parent->installEventFilter( this ); TQT_TQOBJECT_REQUIRED_INITIALIZATION(parent) } TQGridLayout( int nRows = 1, int nCols = 1, int spacing = -1, const char *name = 0 ) : QGridLayout(), autoNewChild(false) { expand(nRows, nCols); setSpacing(spacing); setObjectName(QString::fromAscii(name)); } TQGridLayout( QLayout *parentLayout, int nRows = 1, int nCols = 1, int spacing = -1, const char *name = 0 ) : QGridLayout(), autoNewChild(false) { expand(nRows, nCols); if (spacing == -1) {setSpacing(parentLayout->spacing());} else {setSpacing(spacing);}; setObjectName(QString::fromAscii(name)); if ( parentLayout ) parentLayout->addItem(this); if ( parentLayout ) parentLayout->installEventFilter( this ); TQT_TQOBJECT_REQUIRED_INITIALIZATION(parentLayout) } void expand( int rows, int cols ) { // Nasty, nasty HACK // Yet another example of lost functionality in Qt4...sigh... QSpacerItem *hack= new QSpacerItem(1,1); addItem(hack, (rows != -1) ? rows-1 : 0, (cols != -1) ? cols-1 : 0); QGridLayout::removeItem(hack); delete hack; } inline TQSize tqsizeHint() const { return sizeHint(); } inline TQSize tqminimumSize() const { return minimumSize(); } inline TQSize tqmaximumSize() const { return maximumSize(); } inline void tqinvalidate() { invalidate(); } inline TQRect tqgeometry() const { return geometry(); } inline TQWidget *mainWidget() const { return TQT_TQWIDGET(parentWidget()); } inline void remove(QWidget *w) { removeWidget(w); } inline void add(QWidget *w) { addWidget(w); } inline void setResizeMode(SizeConstraint s) {setSizeConstraint(s);} inline void setResizeMode(TQLayout::ResizeMode s) {setResizeMode((SizeConstraint)s);} inline SizeConstraint resizeMode() const {return sizeConstraint();} inline void setAutoAdd(bool a) { autoNewChild = a; } inline bool autoAdd() const { return autoNewChild; } inline void addRowSpacing(int row, int minsize) { addItem(new QSpacerItem(0,minsize), row, 0); } inline void addColSpacing(int col, int minsize) { addItem(new QSpacerItem(minsize,0), 0, col); } inline void addMultiCellWidget(QWidget *w, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0) { addWidget(w, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); } inline void addMultiCell(QLayoutItem *l, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0) { addItem(l, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); } inline void addMultiCellLayout(QLayout *layout, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0) { addLayout(layout, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); } inline int numRows() const { return rowCount(); } inline int numCols() const { return columnCount(); } inline void setColStretch(int col, int stretch) {setColumnStretch(col, stretch); } inline int colStretch(int col) const {return columnStretch(col); } inline void setColSpacing(int col, int minSize) { setColumnMinimumWidth(col, minSize); } inline int colSpacing(int col) const { return columnMinimumWidth(col); } inline void setRowSpacing(int row, int minSize) {setRowMinimumHeight(row, minSize); } inline int rowSpacing(int row) const {return rowMinimumHeight(row); } virtual void tqsetAlignment( int a ); // Required to interface correctly, as QLayout is not a derived class of TQWidget or TQObject public: // TQt handler // virtual bool eventFilter( TQObject *, TQEvent * ); // Qt4 handler interface inline bool eventFilter( QObject *q, QEvent *e ) { return eventFilter(static_cast(q), static_cast(e)); } // TQt event handlers protected: // virtual bool event( TQEvent *e ); // TQFocusData *focusData(); // inline bool event( QEvent *e ) { return event(static_cast(e)); } virtual void mousePressEvent( TQMouseEvent * ); // NOTE: All event handlers that can be subclassed must be declared here, and virtual void mouseReleaseEvent( TQMouseEvent * ); // declared virtual, so that run time dynamic call resolution will occur virtual void mouseDoubleClickEvent( TQMouseEvent * ); virtual void mouseMoveEvent( TQMouseEvent * ); #ifndef TQT_NO_WHEELEVENT virtual void wheelEvent( TQWheelEvent * ); #endif virtual void keyPressEvent( TQKeyEvent * ); virtual void keyReleaseEvent( TQKeyEvent * ); virtual void focusInEvent( TQFocusEvent * ); virtual void focusOutEvent( TQFocusEvent * ); virtual void enterEvent( TQEvent * ); virtual void leaveEvent( TQEvent * ); virtual void paintEvent( TQPaintEvent * ); virtual void moveEvent( TQMoveEvent * ); virtual void resizeEvent( TQResizeEvent * ); virtual void closeEvent( TQCloseEvent * ); virtual void contextMenuEvent( TQContextMenuEvent * ); virtual void imStartEvent( TQIMEvent * ); virtual void imComposeEvent( TQIMEvent * ); virtual void imEndEvent( TQIMEvent * ); virtual void tabletEvent( TQTabletEvent * ); #ifndef TQT_NO_DRAGANDDROP virtual void dragEnterEvent( TQDragEnterEvent * ); virtual void dragMoveEvent( TQDragMoveEvent * ); virtual void dragLeaveEvent( TQDragLeaveEvent * ); virtual void dropEvent( TQDropEvent * ); #endif virtual void showEvent( TQShowEvent * ); virtual void hideEvent( TQHideEvent * ); // Qt4 event handler interface protected: inline virtual void mousePressEvent(QMouseEvent *e) { mousePressEvent(static_cast(e)); } // QGridLayout::mousePressEvent(e) } inline virtual void mouseReleaseEvent(QMouseEvent *e) { mouseReleaseEvent(static_cast(e)); } // QGridLayout::mouseReleaseEvent(e) } inline virtual void mouseDoubleClickEvent(QMouseEvent *e) { mouseDoubleClickEvent(static_cast(e)); } // QGridLayout::mouseDoubleClickEvent(e) } inline virtual void mouseMoveEvent(QMouseEvent *e) { mouseMoveEvent(static_cast(e)); } // QGridLayout::mouseMoveEvent(e) } #ifndef QT_NO_WHEELEVENT inline virtual void wheelEvent(QWheelEvent *e) { wheelEvent(static_cast(e)); } // QGridLayout::wheelEvent(e) } #endif inline virtual void keyPressEvent(QKeyEvent *e) { keyPressEvent(static_cast(e)); } // QGridLayout::keyPressEvent(e) } inline virtual void keyReleaseEvent(QKeyEvent *e) { keyReleaseEvent(static_cast(e)); } // QGridLayout::keyReleaseEvent(e) } inline virtual void focusInEvent(QFocusEvent *e) { focusInEvent(static_cast(e)); } // QGridLayout::focusInEvent(e) } inline virtual void focusOutEvent(QFocusEvent *e) { focusOutEvent(static_cast(e)); } // QGridLayout::focusOutEvent(e) } inline virtual void enterEvent(QEvent *e) { enterEvent(static_cast(e)); } // QGridLayout::enterEvent(e) } inline virtual void leaveEvent(QEvent *e) { leaveEvent(static_cast(e)); } // QGridLayout::leaveEvent(e) } inline virtual void paintEvent(QPaintEvent *e) { paintEvent(static_cast(e)); } // QGridLayout::paintEvent(e) } inline virtual void moveEvent(QMoveEvent *e) { moveEvent(static_cast(e)); } // QGridLayout::moveEvent(e) } inline virtual void resizeEvent(QResizeEvent *e) { resizeEvent(static_cast(e)); } // QGridLayout::resizeEvent(e) } inline virtual void closeEvent(QCloseEvent *e) { closeEvent(static_cast(e)); } // QGridLayout::closeEvent(e) } #ifndef QT_NO_CONTEXTMENU inline virtual void contextMenuEvent(QContextMenuEvent *e { contextMenuEvent(static_cast(e)); QGridLayout::contextMenuEvent(e) } #endif #ifndef QT_NO_TABLETEVENT inline virtual void tabletEvent(QTabletEvent *e) { tabletEvent(static_cast(e)); } // QGridLayout::tabletEvent(e) } #endif #ifndef QT_NO_ACTION // inline virtual void actionEvent(QActionEvent *e) { actionEvent(static_cast(e)); QGridLayout::actionEvent(e) } #endif // #ifndef QT_NO_DRAGANDDROP // inline virtual void dragEnterEvent(QDragEnterEvent *e) { dragEnterEvent(static_cast(e)); QGridLayout::dragEnterEvent(e) } // inline virtual void dragMoveEvent(QDragMoveEvent *e) { dragMoveEvent(static_cast(e)); QGridLayout::dragMoveEvent(e) } // inline virtual void dragLeaveEvent(QDragLeaveEvent *e) { dragLeaveEvent(static_cast(e)); QGridLayout::dragLeaveEvent(e) } // inline virtual void dropEvent(QDropEvent *e) { dropEvent(static_cast(e)); QGridLayout::dropEvent(e) } // #endif inline virtual void showEvent(QShowEvent *e) { showEvent(static_cast(e)); } // QGridLayout::showEvent(e) } inline virtual void hideEvent(QHideEvent *e) { hideEvent(static_cast(e)); } // QGridLayout::hideEvent(e) } // TQt event handlers protected: virtual void timerEvent( TQTimerEvent * ); virtual void childEvent( TQChildEvent * ); virtual void customEvent( TQCustomEvent * ); // Qt4 event handler interface protected: inline virtual void timerEvent(QTimerEvent *e) { timerEvent(static_cast(e)); } // QGridLayout::timerEvent(e) } inline virtual void childEvent(QChildEvent *e) { TQT_TQOBJECT_CHILDEVENT_CONDITIONAL childEvent(static_cast(e)); } // QGridLayout::childEvent(e) } // inline virtual void customEvent(QCustomEvent *e) { customEvent(static_cast(e)); } // protected: // bool eventFilter( TQObject *o, TQEvent *e ) { // TQ_UNUSED(o); // if (e->type() == TQEvent::ChildInserted) { // if (autoNewChild) { // QChildEvent *c = (QChildEvent *)e; // if (c->child()->isWidgetType()) { // QWidget *w = (QWidget *)c->child(); // if (!w->isWindow()) { // addWidget(w); // } // } // } // } // else if (e->type() == TQEvent::LayoutHint) { // // d->activated = false; // if (parent()) { // if (static_cast(parent())->isVisible()) { // activate(); // } // } // } // return FALSE; // } // Taken from TQLayout above protected: bool eventFilter( TQObject *o, TQEvent *e ) { TQ_UNUSED(o); if (e->type() == TQEvent::Resize) { activate(); TQResizeEvent *r = (TQResizeEvent *)e; int mbh = 0; #ifndef TQT_NO_MENUBAR mbh = menuBarHeightForWidth( menuBar(), r->size().width() ); #endif // int b = marginImpl ? 0 : outsideBorder; int b = 0; setGeometry( TQRect( b, mbh + b, r->size().width() - 2 * b, r->size().height() - mbh - 2 * b ) ); } else if (e->type() == TQEvent::ChildInserted) { if (autoNewChild) { QChildEvent *c = (QChildEvent *)e; if (c->child()->isWidgetType()) { QWidget *w = (QWidget *)c->child(); if (!w->isWindow()) { // #if !defined(QT_NO_MENUBAR) && !defined(QT_NO_TOOLBAR) // if (qobject_cast(w) && !qobject_cast(w->parentWidget())) { // setMenuBar( (QMenuBar *)w ); // invalidate(); // } else // #endif // #ifndef QT_NO_SIZEGRIP // if (qobject_cast(w) ) { // //SizeGrip is handled by the dialog itself. // } else // #endif // addItem(QLayoutPrivate::createWidgetItem(this, w)); addWidget(w); } } } } else if (e->type() == TQEvent::LayoutHint) { // d->d = false; if (parent()) { if (static_cast(parent())->isVisible()) { activate(); } } } return FALSE; } public: virtual void setGeometry(const TQRect &r) { return QGridLayout::setGeometry(r); } virtual inline void setGeometry(const QRect &r) { return setGeometry(TQT_TQRECT_OBJECT(r)); } public Q_SLOTS: void tqt_handle_qt_destroyed(QObject* obj) { emit destroyed(TQT_TQOBJECT(obj)); } Q_SIGNALS: void destroyed( TQObject* obj ); private: bool autoNewChild; }; #else // USE_QT4 class TQ_EXPORT TQGridLayout : public TQLayout { Q_OBJECT TQ_OBJECT public: TQGridLayout( TQWidget *parent, int nRows = 1, int nCols = 1, int border = 0, int spacing = -1, const char *name = 0 ); TQGridLayout( int nRows = 1, int nCols = 1, int spacing = -1, const char *name = 0 ); TQGridLayout( TQLayout *parentLayout, int nRows = 1, int nCols = 1, int spacing = -1, const char *name = 0 ); ~TQGridLayout(); TQSize tqsizeHint() const; TQSize tqminimumSize() const; TQSize tqmaximumSize() const; // ### remove 'virtual' in 4.0 (or add 'virtual' to set{Row,Col}Spacing()) virtual void setRowStretch( int row, int stretch ); virtual void setColStretch( int col, int stretch ); int rowStretch( int row ) const; int colStretch( int col ) const; void setRowSpacing( int row, int minSize ); void setColSpacing( int col, int minSize ); int rowSpacing( int row ) const; int colSpacing( int col ) const; int numRows() const; int numCols() const; TQRect cellGeometry( int row, int col ) const; bool hasHeightForWidth() const; int heightForWidth( int ) const; int minimumHeightForWidth( int ) const; TQ_SPExpandData expandingDirections() const; void tqinvalidate(); void addItem( QLayoutItem * ); void addItem( QLayoutItem *item, int row, int col ); void addMultiCell( QLayoutItem *, int fromRow, int toRow, int fromCol, int toCol, int align = 0 ); void addWidget( TQWidget *, int row, int col, int align = 0 ); void addMultiCellWidget( TQWidget *, int fromRow, int toRow, int fromCol, int toCol, int align = 0 ); void addLayout( TQLayout *tqlayout, int row, int col); void addMultiCellLayout( TQLayout *tqlayout, int fromRow, int toRow, int fromCol, int toCol, int align = 0 ); void addRowSpacing( int row, int minsize ); void addColSpacing( int col, int minsize ); void expand( int rows, int cols ); enum Corner { TopLeft, TopRight, BottomLeft, BottomRight }; void setOrigin( Corner ); Corner origin() const; // TQLayoutIterator iterator(); void setGeometry( const TQRect& ); #ifdef USE_QT4 QLAYOUT_REQUIRED_METHOD_DECLARATIONS #endif // USE_QT4 protected: bool findWidget( TQWidget* w, int *r, int *c ); void add( TQLayoutItem*, int row, int col ); private: #if defined(TQ_DISABLE_COPY) TQGridLayout( const TQGridLayout & ); TQGridLayout &operator=( const TQGridLayout & ); #endif void init( int rows, int cols ); TQGridLayoutData *data; }; #endif // USE_QT4 class TQBoxLayoutData; class TQDockWindow; class TQ_EXPORT TQBoxLayout : public TQLayout { Q_OBJECT TQ_OBJECT public: enum Direction { LeftToRight, RightToLeft, TopToBottom, BottomToTop, Down = TopToBottom, Up = BottomToTop }; TQBoxLayout( TQWidget *parent, Direction, int border = 0, int spacing = -1, const char *name = 0 ); TQBoxLayout( TQLayout *parentLayout, Direction, int spacing = -1, const char *name = 0 ); TQBoxLayout( Direction, int spacing = -1, const char *name = 0 ); ~TQBoxLayout(); void addItem( QLayoutItem * ); Direction direction() const { return dir; } void setDirection( Direction ); void addSpacing( int size ); void addStretch( int stretch = 0 ); void addWidget( TQWidget *, int stretch = 0, int tqalignment = 0 ); void addLayout( TQLayout *tqlayout, int stretch = 0 ); void addStrut( int ); void insertSpacing( int index, int size ); void insertStretch( int index, int stretch = 0 ); void insertWidget( int index, TQWidget *widget, int stretch = 0, int tqalignment = 0 ); void insertLayout( int index, TQLayout *tqlayout, int stretch = 0 ); bool setStretchFactor( TQWidget*, int stretch ); bool setStretchFactor( TQLayout *l, int stretch ); TQSize tqsizeHint() const; TQSize tqminimumSize() const; TQSize tqmaximumSize() const; bool hasHeightForWidth() const; int heightForWidth( int ) const; int minimumHeightForWidth( int ) const; TQ_SPExpandData expandingDirections() const; void tqinvalidate(); // TQLayoutIterator iterator(); void setGeometry( const TQRect& ); int findWidget( TQWidget* w ); #ifdef USE_QT4 QLAYOUT_REQUIRED_METHOD_DECLARATIONS #endif // USE_QT4 protected: void insertItem( int index, TQLayoutItem * ); private: friend class TQDockWindow; #if defined(TQ_DISABLE_COPY) TQBoxLayout( const TQBoxLayout & ); TQBoxLayout &operator=( const TQBoxLayout & ); #endif void setupGeom(); void calcHfw( int ); TQBoxLayoutData *data; Direction dir; TQBoxLayout *createTmpCopy(); }; class TQ_EXPORT TQHBoxLayout : public TQBoxLayout { Q_OBJECT TQ_OBJECT public: TQHBoxLayout( TQWidget *parent, int border = 0, int spacing = -1, const char *name = 0 ); TQHBoxLayout( TQLayout *parentLayout, int spacing = -1, const char *name = 0 ); TQHBoxLayout( int spacing = -1, const char *name = 0 ); ~TQHBoxLayout(); private: // Disabled copy constructor and operator= #if defined(TQ_DISABLE_COPY) TQHBoxLayout( const TQHBoxLayout & ); TQHBoxLayout &operator=( const TQHBoxLayout & ); #endif }; class TQ_EXPORT TQVBoxLayout : public TQBoxLayout { Q_OBJECT TQ_OBJECT public: TQVBoxLayout( TQWidget *parent, int border = 0, int spacing = -1, const char *name = 0 ); TQVBoxLayout( TQLayout *parentLayout, int spacing = -1, const char *name = 0 ); TQVBoxLayout( int spacing = -1, const char *name = 0 ); ~TQVBoxLayout(); private: // Disabled copy constructor and operator= #if defined(TQ_DISABLE_COPY) TQVBoxLayout( const TQVBoxLayout & ); TQVBoxLayout &operator=( const TQVBoxLayout & ); #endif }; #endif // TQT_NO_LAYOUT #endif // TQLAYOUT_H