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 // File: QtxWorkspace.cxx
23 // Author: Sergey TELKOV
25 #include "QtxWorkspace.h"
27 #include <QWidgetList>
31 \brief A workspace widget which can be used in the MDI application
32 as top-level widget in the application main window.
34 Provides methods to tile child windows in horizontal or vertical
40 \param parent parent widget
42 QtxWorkspace::QtxWorkspace( QWidget* parent )
43 : QWorkspace( parent )
50 QtxWorkspace::~QtxWorkspace()
55 \brief Tiles child windows vertically.
57 void QtxWorkspace::tileVertical()
59 QWidgetList winList = windowList();
60 if ( winList.isEmpty() )
64 for ( QWidgetList::const_iterator itr = winList.begin(); itr != winList.end(); ++itr )
65 if ( !( (*itr)->windowState() & Qt::WindowMinimized ) )
71 if ( activeWindow() && ( activeWindow()->windowState() & Qt::WindowMaximized ) )
72 activeWindow()->showNormal();
75 int heightForEach = height() / count;
76 for ( QWidgetList::iterator it = winList.begin(); it != winList.end(); ++it )
79 if ( win->windowState() & Qt::WindowMinimized )
82 if ( win->windowState() & Qt::WindowMaximized )
88 // QApplication::sendPostedEvents( 0, QEvent::ShowNormal );
90 int prefH = win->minimumHeight() + win->parentWidget()->baseSize().height();
91 int actualH = qMax( heightForEach, prefH );
93 win->parentWidget()->setGeometry( 0, y, width(), actualH );
99 \brief Tiles child windows horizontally.
101 void QtxWorkspace::tileHorizontal()
103 QWidgetList winList = windowList();
104 if ( winList.isEmpty() )
108 for ( QWidgetList::const_iterator itr = winList.begin(); itr != winList.end(); ++itr )
109 if ( !( (*itr)->windowState() & Qt::WindowMinimized ) )
115 if ( activeWindow() && activeWindow()->windowState() & Qt::WindowMaximized )
116 activeWindow()->showNormal();
119 int widthForEach = width() / count;
120 for ( QWidgetList::iterator it = winList.begin(); it != winList.end(); ++it )
123 if ( win->windowState() & Qt::WindowMinimized )
126 if ( win->windowState() & Qt::WindowMaximized )
132 // QApplication::sendPostedEvents( 0, QEvent::ShowNormal );
134 int prefW = win->minimumWidth();
135 int actualW = qMax( widthForEach, prefW );
137 win->parentWidget()->setGeometry( x, 0, actualW, height() );