From 882f9830d102800eef3ba85386bf5a01b17f9271 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 2 Apr 2009 10:45:06 +0000 Subject: [PATCH] Exclude reparent event for ViewWindow --- src/STD/STD_MDIDesktop.cxx | 22 ++++++++++++++++++++-- src/SUIT/SUIT_Desktop.cxx | 8 ++++---- src/SUIT/SUIT_Desktop.h | 7 ++++--- src/SUIT/SUIT_ViewManager.cxx | 3 ++- src/SUIT/SUIT_ViewWindow.cxx | 2 +- 5 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/STD/STD_MDIDesktop.cxx b/src/STD/STD_MDIDesktop.cxx index de0dcf880..52cd57421 100755 --- a/src/STD/STD_MDIDesktop.cxx +++ b/src/STD/STD_MDIDesktop.cxx @@ -31,6 +31,7 @@ #include #include +#include #include @@ -102,10 +103,27 @@ QList STD_MDIDesktop::windows() const */ void STD_MDIDesktop::addWindow( QWidget* w ) { - if ( !w || !workspace() ) + if ( !w || !myWorkspace ) return; - workspace()->addWindow( w ); + QWidget* aWnd = myWorkspace->addWindow( w ); + //aWnd->setAutoFillBackground(false); + //setBackgroundRole(QPalette::NoRole); + QSize aSize = myWorkspace->size(); + + QWidget* aCurrWnd = myWorkspace->activeWindow(); + int xPos = 0, yPos = 0; + if (aCurrWnd) { + const QRect& aCurrGeom = aCurrWnd->geometry(); + int aShift = 20; + if (statusBar()) + aShift = statusBar()->geometry().height(); + int aXLow = aSize.width() * 1./3.; + int aYLow = aSize.height() * 1./3.; + xPos = (aCurrGeom.x() > aXLow)? 0 : aCurrGeom.x() + aShift; + yPos = (aCurrGeom.y() > aYLow)? 0 : aCurrGeom.y() + aShift; + } + aWnd->setGeometry(xPos, yPos, aSize.width() * 2./3., aSize.height() * 2./3.); } /*!Call method perform for operation \a type.*/ diff --git a/src/SUIT/SUIT_Desktop.cxx b/src/SUIT/SUIT_Desktop.cxx index e7019f467..c661d1c2b 100755 --- a/src/SUIT/SUIT_Desktop.cxx +++ b/src/SUIT/SUIT_Desktop.cxx @@ -102,15 +102,15 @@ void SUIT_Desktop::closeEvent( QCloseEvent* e ) /*! Child event. */ -void SUIT_Desktop::childEvent( QChildEvent* e ) +/*void SUIT_Desktop::childEvent( QChildEvent* e ) { if ( e->type() == QEvent::ChildAdded && e->child()->isWidgetType() ) QApplication::postEvent( this, new ReparentEvent( QEvent::Type( Reparent ), e->child() ) ); else QtxMainWindow::childEvent( e ); -} +}*/ -void SUIT_Desktop::customEvent( QEvent* e ) +/*void SUIT_Desktop::customEvent( QEvent* e ) { if ( (int)e->type() != Reparent ) return; @@ -125,7 +125,7 @@ void SUIT_Desktop::customEvent( QEvent* e ) addWindow( wid ); wid->setShown( !invis ); } -} +}*/ /*! Gets menu manager. diff --git a/src/SUIT/SUIT_Desktop.h b/src/SUIT/SUIT_Desktop.h index ad49bd55e..b119c6cb9 100755 --- a/src/SUIT/SUIT_Desktop.h +++ b/src/SUIT/SUIT_Desktop.h @@ -71,6 +71,8 @@ public: void emitActivated(); void emitMessage( const QString& ); + virtual void addWindow( QWidget* ) = 0; + signals: void activated(); void deactivated(); @@ -80,11 +82,10 @@ signals: protected: virtual bool event( QEvent* ); - virtual void customEvent( QEvent* ); + //virtual void customEvent( QEvent* ); virtual void closeEvent( QCloseEvent* ); - virtual void childEvent( QChildEvent* ); + //virtual void childEvent( QChildEvent* ); - virtual void addWindow( QWidget* ) = 0; private: QtxActionMenuMgr* myMenuMgr; diff --git a/src/SUIT/SUIT_ViewManager.cxx b/src/SUIT/SUIT_ViewManager.cxx index c3ff10c41..295050358 100755 --- a/src/SUIT/SUIT_ViewManager.cxx +++ b/src/SUIT/SUIT_ViewManager.cxx @@ -153,7 +153,7 @@ SUIT_ViewWindow* SUIT_ViewManager::createViewWindow() setViewName( aView ); aView->setWindowIcon( QIcon( myIcon ) ); - //myDesktop->addViewWindow( aView ); + myDesktop->addWindow( aView ); //it is done automatically during creation of view aView->setViewManager( this ); @@ -162,6 +162,7 @@ SUIT_ViewWindow* SUIT_ViewManager::createViewWindow() // Special treatment for the case when is the first one in this view manager // -> call onWindowActivated() directly, because somebody may always want // to use getActiveView() + aView->show(); if ( !myActiveView ) onWindowActivated( aView ); diff --git a/src/SUIT/SUIT_ViewWindow.cxx b/src/SUIT/SUIT_ViewWindow.cxx index cb7045eee..9b6a62863 100755 --- a/src/SUIT/SUIT_ViewWindow.cxx +++ b/src/SUIT/SUIT_ViewWindow.cxx @@ -192,7 +192,7 @@ bool SUIT_ViewWindow::event( QEvent* e ) SUIT_MessageBox::critical( this, tr( "ERROR" ), tr( "ERR_CANT_DUMP_VIEW" ) ); return true; - } + } return QMainWindow::event( e ); } -- 2.39.2