1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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.
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
17 // See http://www.salome-platform.org/
19 #include "LightApp_WidgetContainer.h"
21 #include <qobjectlist.h>
22 #include <qwidgetstack.h>
27 LightApp_WidgetContainer::LightApp_WidgetContainer( const int type, QWidget* parent )
28 : QDockWindow( QDockWindow::InDock, parent ),
31 setWidget( myStack = new QWidgetStack( this ) );
38 LightApp_WidgetContainer::~LightApp_WidgetContainer()
43 Checks: is widget container is empty?
45 bool LightApp_WidgetContainer::isEmpty() const
47 const QObjectList* lst = myStack->children();
52 for ( QObjectListIt it( *lst ); it.current() && res; ++it )
54 if ( it.current()->isWidgetType() && myStack->id( (QWidget*)it.current() ) != -1 )
61 Gets type of widget container.
63 int LightApp_WidgetContainer::type() const
69 Checks: is container contains widget with id \a id.
71 bool LightApp_WidgetContainer::contains( const int id ) const
73 return myStack->widget( id ) != 0;
77 * Insert widget(\a wid with id \a id) to container.And return id of widget in stack.
78 *\warning remove widget with id = \a id , if it was in container.
80 int LightApp_WidgetContainer::insert( const int id, QWidget* wid )
82 if ( id == -1 || !wid )
88 int stackId = myStack->addWidget( wid, id );
89 if ( !myStack->visibleWidget() )
90 myStack->raiseWidget( wid );
92 setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
98 Remove widget(\a wid) from stack.
100 void LightApp_WidgetContainer::remove( const int id )
102 remove( myStack->widget( id ) );
104 setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
108 Remove widget(\a wid) from stack.
110 void LightApp_WidgetContainer::remove( QWidget* wid )
112 myStack->removeWidget( wid );
114 setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
118 Raise widget with id = \a id.
120 void LightApp_WidgetContainer::activate( const int id )
122 myStack->raiseWidget( id );
124 setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
128 Raise widget (\a wid).
130 void LightApp_WidgetContainer::activate( QWidget* wid )
132 myStack->raiseWidget( wid );
134 setCaption( myStack->visibleWidget() ? myStack->visibleWidget()->caption() : QString::null );
138 Gets widget from container list(stack) by id = \a id.
140 QWidget* LightApp_WidgetContainer::widget( const int id ) const
142 return myStack->widget( id );
148 QWidget* LightApp_WidgetContainer::active() const
150 return myStack->visibleWidget();