Salome HOME
db6aebf30fb5ff3a01db4c084948960d1d6b02cc
[modules/gui.git] / src / STD / STD_SDIDesktop.cxx
1 #include "STD_SDIDesktop.h"
2
3 #include <SUIT_ViewWindow.h>
4
5 #include <qvbox.h>
6 #include <qmenubar.h>
7 #include <qobjectlist.h>
8
9 /*!Constructor. Create instance of QVBox*/
10 STD_SDIDesktop::STD_SDIDesktop()
11 : SUIT_Desktop()
12 {
13   myMainWidget = new QVBox( this );
14   myMainWidget->setFrameStyle( QFrame::Panel | QFrame::Sunken );
15
16   setCentralWidget( myMainWidget );
17 }
18
19 /*!Destructor.*/
20 STD_SDIDesktop::~STD_SDIDesktop()
21 {
22 }
23
24 /*!\retval SUIT_ViewWindow - return const active window.*/
25 SUIT_ViewWindow* STD_SDIDesktop::activeWindow() const
26 {
27   const QObjectList* children = myMainWidget->children();
28   if ( !children )
29     return 0;
30
31   QPtrList<SUIT_ViewWindow> winList;
32   for ( QObjectListIt it( *children ); it.current(); ++it )
33   {
34     if ( it.current()->inherits( "SUIT_ViewWindow" ) )
35       winList.append( (SUIT_ViewWindow*)it.current() );
36   }
37
38   SUIT_ViewWindow* win = 0;
39   for ( QPtrListIterator<SUIT_ViewWindow> itr( winList ); itr.current() && !win; ++itr )
40   {
41     if ( itr.current()->isActiveWindow() )
42       win = itr.current();
43   }
44
45   if ( !win && !winList.isEmpty() )
46     win = winList.getFirst();
47
48   return win;
49 }
50
51 /*!\retval QPtrList<SUIT_ViewWindow> - return const active window list.*/
52 QPtrList<SUIT_ViewWindow> STD_SDIDesktop::windows() const
53 {
54   QPtrList<SUIT_ViewWindow> winList;
55       winList.append( activeWindow() );
56   return winList;
57 }
58
59 /*!\retval QWidget - pointer to main window.*/
60 QWidget* STD_SDIDesktop::parentArea() const
61 {
62   return myMainWidget;
63 }