diff options
Diffstat (limited to 'kommander/editor/layout.cpp')
-rw-r--r-- | kommander/editor/layout.cpp | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/kommander/editor/layout.cpp b/kommander/editor/layout.cpp index 1b55de9c..8d7d3d50 100644 --- a/kommander/editor/layout.cpp +++ b/kommander/editor/layout.cpp @@ -37,18 +37,18 @@ bool operator<( const TQGuardedPtr<TQWidget> &p1, const TQGuardedPtr<TQWidget> & /*! \class Layout tqlayout.h - \brief Baseclass for tqlayouting widgets in the Designer + \brief Baseclass for layouting widgets in the Designer - Classes derived from this abstract base class are used for tqlayouting + Classes derived from this abstract base class are used for layouting operations in the Designer. */ -/*! \a p specifies the tqparent of the tqlayoutBase \a lb. The tqparent - might be changed in setup(). If the tqlayoutBase is a - container, the tqparent and the tqlayoutBase are the same. Also they +/*! \a p specifies the tqparent of the layoutBase \a lb. The tqparent + might be changed in setup(). If the layoutBase is a + container, the tqparent and the layoutBase are the same. Also they always have to be a widget known to the designer (e.g. in the case - of the tabwidget tqparent and tqlayoutBase are the tabwidget and not the + of the tabwidget tqparent and layoutBase are the tabwidget and not the page which actually gets laid out. For actual usage the correct widget is found later by Layout.) */ @@ -57,13 +57,13 @@ Layout::Layout( const TQWidgetList &wl, TQWidget *p, FormWindow *fw, TQWidget *l : widgets( wl ), tqparent( p ), formWindow( fw ), isBreak( !doSetup ), useSplitter( splitter ) { widgets.setAutoDelete( false ); - tqlayoutBase = lb; - if ( !doSetup && tqlayoutBase ) - oldGeometry = tqlayoutBase->tqgeometry(); + layoutBase = lb; + if ( !doSetup && layoutBase ) + oldGeometry = layoutBase->tqgeometry(); } /*! The widget list we got in the constructor might contain too much - widgets (like widgets with different tqparents, already laid out + widgets (like widgets with different parents, already laid out widgets, etc.). Here we set up the list and so the only the "best" widgets get laid out. */ @@ -83,14 +83,14 @@ void Layout::setup() // childs which has the most entries. // Widgets which are already laid out are thrown away here too for ( w = widgets.first(); w; w = widgets.next() ) { - if ( w->tqparentWidget() && WidgetFactory::tqlayoutType( w->tqparentWidget() ) != WidgetFactory::NoLayout ) + if ( w->parentWidget() && WidgetFactory::layoutType( w->parentWidget() ) != WidgetFactory::NoLayout ) continue; - if ( lastParent != w->tqparentWidget() ) { + if ( lastParent != w->parentWidget() ) { lastList = 0; - lastParent = w->tqparentWidget(); + lastParent = w->parentWidget(); TQValueList<TQWidgetList>::Iterator it = lists.begin(); for ( ; it != lists.end(); ++it ) { - if ( ( *it ).first()->tqparentWidget() == w->tqparentWidget() ) + if ( ( *it ).first()->parentWidget() == w->parentWidget() ) lastList = &( *it ); } if ( !lastList ) { @@ -115,9 +115,9 @@ void Layout::setup() // best list has only one entry and we do not tqlayout a container, // we leave here. if ( !lastList || ( lastList->count() < 2 && - ( !tqlayoutBase || - ( !WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf(TQT_TQOBJECT( tqlayoutBase )) ) ) && - tqlayoutBase != formWindow->mainContainer() ) ) + ( !layoutBase || + ( !WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf(TQT_TQOBJECT( layoutBase )) ) ) && + layoutBase != formWindow->mainContainer() ) ) ) ) { widgets.clear(); startPoint = TQPoint( 0, 0 ); @@ -128,7 +128,7 @@ void Layout::setup() // to tqlayout widgets = *lastList; // Also use the only correct tqparent later, so store it - tqparent = WidgetFactory::widgetOfContainer( widgets.first()->tqparentWidget() ); + tqparent = WidgetFactory::widgetOfContainer( widgets.first()->parentWidget() ); // Now calculate the position where the tqlayout-meta-widget should // be placed and connect to widgetDestroyed() signals of the // widgets to get informed if one gets deleted to be able to @@ -158,17 +158,17 @@ bool Layout::prepareLayout( bool &needMove, bool &needRetqparent ) return false; for ( TQWidget *w = widgets.first(); w; w = widgets.next() ) w->raise(); - needMove = !tqlayoutBase; - needRetqparent = needMove || tqlayoutBase->inherits( TQLAYOUTWIDGET_OBJECT_NAME_STRING ) || tqlayoutBase->inherits( TQSPLITTER_OBJECT_NAME_STRING ); - if ( !tqlayoutBase ) { + needMove = !layoutBase; + needRetqparent = needMove || layoutBase->inherits( TQLAYOUTWIDGET_OBJECT_NAME_STRING ) || layoutBase->inherits( TQSPLITTER_OBJECT_NAME_STRING ); + if ( !layoutBase ) { if ( !useSplitter ) - tqlayoutBase = WidgetFactory::create( WidgetDatabase::idFromClassName( TQLAYOUTWIDGET_OBJECT_NAME_STRING ), + layoutBase = WidgetFactory::create( WidgetDatabase::idFromClassName( TQLAYOUTWIDGET_OBJECT_NAME_STRING ), WidgetFactory::containerOfWidget( tqparent ) ); else - tqlayoutBase = WidgetFactory::create( WidgetDatabase::idFromClassName( TQSPLITTER_OBJECT_NAME_STRING ), + layoutBase = WidgetFactory::create( WidgetDatabase::idFromClassName( TQSPLITTER_OBJECT_NAME_STRING ), WidgetFactory::containerOfWidget( tqparent ) ); } else { - WidgetFactory::deleteLayout( tqlayoutBase ); + WidgetFactory::deleteLayout( layoutBase ); } return true; @@ -177,21 +177,21 @@ bool Layout::prepareLayout( bool &needMove, bool &needRetqparent ) void Layout::finishLayout( bool needMove, TQLayout *tqlayout ) { if ( needMove ) - tqlayoutBase->move( startPoint ); - TQRect g( TQRect( tqlayoutBase->pos(), tqlayoutBase->size() ) ); - if ( WidgetFactory::tqlayoutType( tqlayoutBase->tqparentWidget() ) == WidgetFactory::NoLayout && !isBreak ) - tqlayoutBase->adjustSize(); + layoutBase->move( startPoint ); + TQRect g( TQRect( layoutBase->pos(), layoutBase->size() ) ); + if ( WidgetFactory::layoutType( layoutBase->parentWidget() ) == WidgetFactory::NoLayout && !isBreak ) + layoutBase->adjustSize(); else if ( isBreak ) - tqlayoutBase->setGeometry( oldGeometry ); + layoutBase->setGeometry( oldGeometry ); oldGeometry = g; - tqlayoutBase->show(); + layoutBase->show(); tqlayout->activate(); - formWindow->insertWidget( tqlayoutBase ); - formWindow->selectWidget( TQT_TQOBJECT(tqlayoutBase) ); - TQString n = tqlayoutBase->name(); + formWindow->insertWidget( layoutBase ); + formWindow->selectWidget( TQT_TQOBJECT(layoutBase) ); + TQString n = layoutBase->name(); if ( n.tqfind( "qt_dead_widget_" ) != -1 ) { n.remove( 0, TQString( "qt_dead_widget_" ).length() ); - tqlayoutBase->setName( n ); + layoutBase->setName( n ); } } @@ -206,15 +206,15 @@ void Layout::undoLayout() it.key()->reparent( WidgetFactory::containerOfWidget( tqparent ), 0, ( *it ).topLeft(), it.key()->isVisibleTo( formWindow ) ); it.key()->resize( ( *it ).size() ); } - formWindow->selectWidget( TQT_TQOBJECT(tqlayoutBase), false ); - WidgetFactory::deleteLayout( tqlayoutBase ); - if ( tqparent != tqlayoutBase && !tqlayoutBase->inherits( TQMAINWINDOW_OBJECT_NAME_STRING ) ) { - tqlayoutBase->hide(); - TQString n = tqlayoutBase->name(); + formWindow->selectWidget( TQT_TQOBJECT(layoutBase), false ); + WidgetFactory::deleteLayout( layoutBase ); + if ( tqparent != layoutBase && !layoutBase->inherits( TQMAINWINDOW_OBJECT_NAME_STRING ) ) { + layoutBase->hide(); + TQString n = layoutBase->name(); n.prepend( "qt_dead_widget_" ); - tqlayoutBase->setName( n ); + layoutBase->setName( n ); } else { - tqlayoutBase->setGeometry( oldGeometry ); + layoutBase->setGeometry( oldGeometry ); } if ( widgets.first() ) formWindow->selectWidget( TQT_TQOBJECT(widgets.first()) ); @@ -230,33 +230,33 @@ void Layout::breakLayout() for ( w = widgets.first(); w; w = widgets.next() ) rects.insert( w, w->tqgeometry() ); } - WidgetFactory::deleteLayout( tqlayoutBase ); - bool needRetqparent = qstrcmp( tqlayoutBase->className(), TQLAYOUTWIDGET_OBJECT_NAME_STRING ) == 0 || - qstrcmp( tqlayoutBase->className(), TQSPLITTER_OBJECT_NAME_STRING ) == 0 || - ( !WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf(TQT_TQOBJECT( tqlayoutBase )) ) ) && - tqlayoutBase != formWindow->mainContainer() ); - bool needResize = qstrcmp( tqlayoutBase->className(), TQSPLITTER_OBJECT_NAME_STRING ) == 0; + WidgetFactory::deleteLayout( layoutBase ); + bool needRetqparent = qstrcmp( layoutBase->className(), TQLAYOUTWIDGET_OBJECT_NAME_STRING ) == 0 || + qstrcmp( layoutBase->className(), TQSPLITTER_OBJECT_NAME_STRING ) == 0 || + ( !WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf(TQT_TQOBJECT( layoutBase )) ) ) && + layoutBase != formWindow->mainContainer() ); + bool needResize = qstrcmp( layoutBase->className(), TQSPLITTER_OBJECT_NAME_STRING ) == 0; bool add = geometries.isEmpty(); for ( TQWidget *w = widgets.first(); w; w = widgets.next() ) { if ( needRetqparent ) - w->reparent( tqlayoutBase->tqparentWidget(), 0, - tqlayoutBase->pos() + w->pos(), true ); + w->reparent( layoutBase->parentWidget(), 0, + layoutBase->pos() + w->pos(), true ); if ( needResize ) { TQMap<TQWidget*, TQRect>::Iterator it = rects.tqfind( w ); if ( it != rects.end() ) - w->setGeometry( TQRect( tqlayoutBase->pos() + (*it).topLeft(), (*it).size() ) ); + w->setGeometry( TQRect( layoutBase->pos() + (*it).topLeft(), (*it).size() ) ); } if ( add ) geometries.insert( w, TQRect( w->pos(), w->size() ) ); } if ( needRetqparent ) { - tqlayoutBase->hide(); - tqparent = tqlayoutBase->tqparentWidget(); - TQString n = tqlayoutBase->name(); + layoutBase->hide(); + tqparent = layoutBase->parentWidget(); + TQString n = layoutBase->name(); n.prepend( "qt_dead_widget_" ); - tqlayoutBase->setName( n ); + layoutBase->setName( n ); } else { - tqparent = tqlayoutBase; + tqparent = layoutBase; } if ( widgets.first() && widgets.first()->isVisibleTo( formWindow ) ) formWindow->selectWidget( TQT_TQOBJECT(widgets.first()) ); @@ -303,11 +303,11 @@ void HorizontalLayout::doLayout() if ( !prepareLayout( needMove, needRetqparent ) ) return; - TQHBoxLayout *tqlayout = (TQHBoxLayout*)WidgetFactory::createLayout( tqlayoutBase, 0, WidgetFactory::HBox ); + TQHBoxLayout *tqlayout = (TQHBoxLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::HBox ); for ( TQWidget *w = widgets.first(); w; w = widgets.next() ) { - if ( needRetqparent && TQT_BASE_OBJECT(w->tqparent()) != TQT_BASE_OBJECT(tqlayoutBase) ) - w->reparent( tqlayoutBase, 0, TQPoint( 0, 0 ), false ); + if ( needRetqparent && TQT_BASE_OBJECT(w->tqparent()) != TQT_BASE_OBJECT(layoutBase) ) + w->reparent( layoutBase, 0, TQPoint( 0, 0 ), false ); if ( !useSplitter ) { if ( qstrcmp( w->className(), "Spacer" ) == 0 ) tqlayout->addWidget( w, 0, ( (Spacer*)w )->tqalignment() ); @@ -319,8 +319,8 @@ void HorizontalLayout::doLayout() w->show(); } - if ( tqlayoutBase->inherits( TQSPLITTER_OBJECT_NAME_STRING ) ) - ( (TQSplitter*)tqlayoutBase )->setOrientation( Qt::Horizontal ); + if ( layoutBase->inherits( TQSPLITTER_OBJECT_NAME_STRING ) ) + ( (TQSplitter*)layoutBase )->setOrientation( Qt::Horizontal ); finishLayout( needMove, tqlayout ); } @@ -367,11 +367,11 @@ void VerticalLayout::doLayout() if ( !prepareLayout( needMove, needRetqparent ) ) return; - TQVBoxLayout *tqlayout = (TQVBoxLayout*)WidgetFactory::createLayout( tqlayoutBase, 0, WidgetFactory::VBox ); + TQVBoxLayout *tqlayout = (TQVBoxLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::VBox ); for ( TQWidget *w = widgets.first(); w; w = widgets.next() ) { - if ( needRetqparent && TQT_BASE_OBJECT(w->tqparent()) != TQT_BASE_OBJECT(tqlayoutBase) ) - w->reparent( tqlayoutBase, 0, TQPoint( 0, 0 ), false ); + if ( needRetqparent && TQT_BASE_OBJECT(w->tqparent()) != TQT_BASE_OBJECT(layoutBase) ) + w->reparent( layoutBase, 0, TQPoint( 0, 0 ), false ); if ( !useSplitter ) { if ( qstrcmp( w->className(), "Spacer" ) == 0 ) tqlayout->addWidget( w, 0, ( (Spacer*)w )->tqalignment() ); @@ -383,8 +383,8 @@ void VerticalLayout::doLayout() w->show(); } - if ( tqlayoutBase->inherits( TQSPLITTER_OBJECT_NAME_STRING ) ) - ( (TQSplitter*)tqlayoutBase )->setOrientation( Qt::Vertical ); + if ( layoutBase->inherits( TQSPLITTER_OBJECT_NAME_STRING ) ) + ( (TQSplitter*)layoutBase )->setOrientation( Qt::Vertical ); finishLayout( needMove, tqlayout ); } @@ -733,7 +733,7 @@ void GridLayout::doLayout() if ( !prepareLayout( needMove, needRetqparent ) ) return; - QDesignerGridLayout *tqlayout = (QDesignerGridLayout*)WidgetFactory::createLayout( tqlayoutBase, 0, WidgetFactory::Grid ); + QDesignerGridLayout *tqlayout = (QDesignerGridLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::Grid ); if ( !grid ) buildGrid(); @@ -742,8 +742,8 @@ void GridLayout::doLayout() int r, c, rs, cs; for ( w = widgets.first(); w; w = widgets.next() ) { if ( grid->locateWidget( w, r, c, rs, cs) ) { - if ( needRetqparent && TQT_BASE_OBJECT(w->tqparent()) != TQT_BASE_OBJECT(tqlayoutBase) ) - w->reparent( tqlayoutBase, 0, TQPoint( 0, 0 ), false ); + if ( needRetqparent && TQT_BASE_OBJECT(w->tqparent()) != TQT_BASE_OBJECT(layoutBase) ) + w->reparent( layoutBase, 0, TQPoint( 0, 0 ), false ); if ( rs * cs == 1 ) { tqlayout->addWidget( w, r, c, w->inherits( "Spacer" ) ? ( (Spacer*)w )->tqalignment() : 0 ); } else { @@ -846,7 +846,7 @@ void Spacer::paintEvent( TQPaintEvent * ) void Spacer::resizeEvent( TQResizeEvent* e) { TQWidget::resizeEvent( e ); - if ( !tqparentWidget() || WidgetFactory::tqlayoutType( tqparentWidget() ) == WidgetFactory::NoLayout ) + if ( !parentWidget() || WidgetFactory::layoutType( parentWidget() ) == WidgetFactory::NoLayout ) sh = size(); } @@ -912,7 +912,7 @@ TQSize Spacer::tqsizeHint() const void Spacer::setSizeHint( const TQSize &s ) { sh = s; - if ( !tqparentWidget() || WidgetFactory::tqlayoutType( tqparentWidget() ) == WidgetFactory::NoLayout ) + if ( !parentWidget() || WidgetFactory::layoutType( parentWidget() ) == WidgetFactory::NoLayout ) resize( tqsizeHint() ); updateGeometry(); } @@ -932,7 +932,7 @@ void Spacer::setOrientation( Qt::Orientation o ) setSizeType( st ); if ( interactive ) { sh = TQSize( sh.height(), sh.width() ); - if (!tqparentWidget() || WidgetFactory::tqlayoutType( tqparentWidget() ) == WidgetFactory::NoLayout ) + if (!parentWidget() || WidgetFactory::layoutType( parentWidget() ) == WidgetFactory::NoLayout ) resize( height(), width() ); } updateMask(); |