Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/gui.git] / src / STD / STD_SDIDesktop.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "STD_SDIDesktop.h"
20
21 #include <SUIT_ViewWindow.h>
22
23 #include <qvbox.h>
24 #include <qmenubar.h>
25 #include <qobjectlist.h>
26
27 /*!Constructor. Create instance of QVBox*/
28 STD_SDIDesktop::STD_SDIDesktop()
29 : SUIT_Desktop()
30 {
31   myMainWidget = new QVBox( this );
32   myMainWidget->setFrameStyle( QFrame::Panel | QFrame::Sunken );
33
34   setCentralWidget( myMainWidget );
35 }
36
37 /*!Destructor.*/
38 STD_SDIDesktop::~STD_SDIDesktop()
39 {
40 }
41
42 /*!\retval SUIT_ViewWindow - return const active window.*/
43 SUIT_ViewWindow* STD_SDIDesktop::activeWindow() const
44 {
45   const QObjectList* children = myMainWidget->children();
46   if ( !children )
47     return 0;
48
49   QPtrList<SUIT_ViewWindow> winList;
50   for ( QObjectListIt it( *children ); it.current(); ++it )
51   {
52     if ( it.current()->inherits( "SUIT_ViewWindow" ) )
53       winList.append( (SUIT_ViewWindow*)it.current() );
54   }
55
56   SUIT_ViewWindow* win = 0;
57   for ( QPtrListIterator<SUIT_ViewWindow> itr( winList ); itr.current() && !win; ++itr )
58   {
59     if ( itr.current()->isActiveWindow() )
60       win = itr.current();
61   }
62
63   if ( !win && !winList.isEmpty() )
64     win = winList.getFirst();
65
66   return win;
67 }
68
69 /*!\retval QPtrList<SUIT_ViewWindow> - return const active window list.*/
70 QPtrList<SUIT_ViewWindow> STD_SDIDesktop::windows() const
71 {
72   QPtrList<SUIT_ViewWindow> winList;
73       winList.append( activeWindow() );
74   return winList;
75 }
76
77 /*!\retval QWidget - pointer to main window.*/
78 QWidget* STD_SDIDesktop::parentArea() const
79 {
80   return myMainWidget;
81 }