1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
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, or (at your option) any later version.
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/ or email : webmaster.salome@opencascade.com
20 // File: QtxWorkspace.cxx
21 // Author: Sergey TELKOV
23 #include "QtxWorkspace.h"
25 #include <QMdiSubWindow>
29 \brief A workspace widget which can be used in the MDI application
30 as top-level widget in the application main window.
32 Provides methods to tile child windows in horizontal or vertical
38 \param parent parent widget
40 QtxWorkspace::QtxWorkspace( QWidget* parent )
48 QtxWorkspace::~QtxWorkspace()
53 \brief Tiles child windows vertically.
55 void QtxWorkspace::tileVertical()
57 QList<QMdiSubWindow *> winList = subWindowList();
58 if ( winList.isEmpty() )
62 for ( QList<QMdiSubWindow *>::const_iterator itr = winList.begin(); itr != winList.end(); ++itr )
63 if ( !( (*itr)->windowState() & Qt::WindowMinimized ) )
69 if ( activeSubWindow() && ( activeSubWindow()->windowState() & Qt::WindowMaximized ) )
70 activeSubWindow()->showNormal();
73 int heightForEach = height() / count;
74 for ( QList<QMdiSubWindow *>::iterator it = winList.begin(); it != winList.end(); ++it )
77 if ( win->windowState() & Qt::WindowMinimized )
80 if ( win->windowState() & Qt::WindowMaximized )
86 // QApplication::sendPostedEvents( 0, QEvent::ShowNormal );
88 int prefH = win->minimumHeight() + win->parentWidget()->baseSize().height();
89 int actualH = qMax( heightForEach, prefH );
91 win->parentWidget()->setGeometry( 0, y, width(), actualH );
97 \brief Tiles child windows horizontally.
99 void QtxWorkspace::tileHorizontal()
101 QList<QMdiSubWindow *> winList = subWindowList();
102 if ( winList.isEmpty() )
106 for ( QList<QMdiSubWindow *>::const_iterator itr = winList.begin(); itr != winList.end(); ++itr )
107 if ( !( (*itr)->windowState() & Qt::WindowMinimized ) )
113 if ( activeSubWindow() && activeSubWindow()->windowState() & Qt::WindowMaximized )
114 activeSubWindow()->showNormal();
117 int widthForEach = width() / count;
118 for ( QList<QMdiSubWindow *>::iterator it = winList.begin(); it != winList.end(); ++it )
121 if ( win->windowState() & Qt::WindowMinimized )
124 if ( win->windowState() & Qt::WindowMaximized )
130 // QApplication::sendPostedEvents( 0, QEvent::ShowNormal );
132 int prefW = win->minimumWidth();
133 int actualW = qMax( widthForEach, prefW );
135 win->parentWidget()->setGeometry( x, 0, actualW, height() );
140 void QtxWorkspace::onSubWindowActivated( QMdiSubWindow* subWindow )
144 w = subWindow->widget();
145 emit windowActivated( w );