1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "STD_SDIDesktop.h"
24 #include <SUIT_ViewWindow.h>
27 #include <QVBoxLayout>
29 /*!Constructor. Create instance of QVBox*/
30 STD_SDIDesktop::STD_SDIDesktop()
33 myMainWidget = new QFrame( this );
34 myMainWidget->setFrameStyle( QFrame::Panel | QFrame::Sunken );
36 QVBoxLayout* main = new QVBoxLayout( myMainWidget );
39 setCentralWidget( myMainWidget );
43 STD_SDIDesktop::~STD_SDIDesktop()
47 /*!\retval SUIT_ViewWindow - return const active window.*/
48 SUIT_ViewWindow* STD_SDIDesktop::activeWindow() const
50 const QObjectList& lst = myMainWidget->children();
51 QList<SUIT_ViewWindow*> winList;
52 for ( QObjectList::const_iterator it = lst.begin(); it != lst.end(); ++it )
54 SUIT_ViewWindow* vw = ::qobject_cast<SUIT_ViewWindow*>( *it );
59 SUIT_ViewWindow* win = 0;
60 for ( QList<SUIT_ViewWindow*>::iterator itr = winList.begin(); itr != winList.end() && !win; ++itr )
62 if ( (*itr)->isActiveWindow() )
66 if ( !win && !winList.isEmpty() )
67 win = winList.first();
72 /*!\retval QPtrList<SUIT_ViewWindow> - return const active window list.*/
73 QList<SUIT_ViewWindow*> STD_SDIDesktop::windows() const
75 QList<SUIT_ViewWindow*> winList;
76 winList.append( activeWindow() );
80 /*! add new widget into desktop.*/
81 void STD_SDIDesktop::addWindow( QWidget* w )
83 if ( !w || !centralWidget() || !centralWidget()->layout() )
86 w->setParent( centralWidget() );
87 centralWidget()->layout()->addWidget( w );