1 // Copyright (C) 2007-2023 CEA, EDF, 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, or (at your option) any later version.
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
23 #include "STD_SDIDesktop.h"
25 #include <SUIT_ViewWindow.h>
28 #include <QVBoxLayout>
30 /*!Constructor. Create instance of QVBox*/
31 STD_SDIDesktop::STD_SDIDesktop()
34 myMainWidget = new QFrame( this );
35 myMainWidget->setFrameStyle( QFrame::Panel | QFrame::Sunken );
37 QVBoxLayout* main = new QVBoxLayout( myMainWidget );
40 setCentralWidget( myMainWidget );
44 STD_SDIDesktop::~STD_SDIDesktop()
48 /*!\retval SUIT_ViewWindow - return const active window.*/
49 SUIT_ViewWindow* STD_SDIDesktop::activeWindow() const
51 const QObjectList& lst = myMainWidget->children();
52 QList<SUIT_ViewWindow*> winList;
53 for ( QObjectList::const_iterator it = lst.begin(); it != lst.end(); ++it )
55 SUIT_ViewWindow* vw = ::qobject_cast<SUIT_ViewWindow*>( *it );
60 SUIT_ViewWindow* win = 0;
61 for ( QList<SUIT_ViewWindow*>::iterator itr = winList.begin(); itr != winList.end() && !win; ++itr )
63 if ( (*itr)->isActiveWindow() )
67 if ( !win && !winList.isEmpty() )
68 win = winList.first();
73 /*!\retval QPtrList<SUIT_ViewWindow> - return const active window list.*/
74 QList<SUIT_ViewWindow*> STD_SDIDesktop::windows() const
76 QList<SUIT_ViewWindow*> winList;
77 winList.append( activeWindow() );
81 /*! add new widget into desktop.*/
82 void STD_SDIDesktop::addWindow( QWidget* w )
84 if ( !w || !centralWidget() || !centralWidget()->layout() )
87 w->setParent( centralWidget() );
88 centralWidget()->layout()->addWidget( w );