From: stv Date: Fri, 18 May 2007 06:54:56 +0000 (+0000) Subject: no message X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a959633170a1d51286a11363e394ca1ae17ce6de;p=modules%2Fgui.git no message --- diff --git a/src/Qtx/QtxWorkspace.cxx b/src/Qtx/QtxWorkspace.cxx new file mode 100644 index 000000000..46bd175c9 --- /dev/null +++ b/src/Qtx/QtxWorkspace.cxx @@ -0,0 +1,128 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File: QtxWorkspace.cxx +// Author: Sergey TELKOV + +#include "QtxWorkspace.h" + +#include + +/*! + \brief Constructor. + \param parent parent widget +*/ +QtxWorkspace::QtxWorkspace( QWidget* parent ) +: QWorkspace( parent ) +{ +} + +/*! + \brief Destructor. +*/ +QtxWorkspace::~QtxWorkspace() +{ +} + +/*! + \brief Performs tile vertical action +*/ +void QtxWorkspace::tileVertical() +{ + QWidgetList winList = windowList(); + if ( winList.isEmpty() ) + return; + + int count = 0; + for ( QWidgetList::const_iterator itr = winList.begin(); itr != winList.end(); ++itr ) + if ( !( (*itr)->windowState() & Qt::WindowMinimized ) ) + count++; + + if ( !count ) + return; + + if ( activeWindow() && ( activeWindow()->windowState() & Qt::WindowMaximized ) ) + activeWindow()->showNormal(); + + int y = 0; + int heightForEach = height() / count; + for ( QWidgetList::iterator it = winList.begin(); it != winList.end(); ++it ) + { + QWidget* win = *it; + if ( win->windowState() & Qt::WindowMinimized ) + continue; + + if ( win->windowState() & Qt::WindowMaximized ) + { + win->hide(); + win->showNormal(); + } + +// QApplication::sendPostedEvents( 0, QEvent::ShowNormal ); + + int prefH = win->minimumHeight() + win->parentWidget()->baseSize().height(); + int actualH = qMax( heightForEach, prefH ); + + win->parentWidget()->setGeometry( 0, y, width(), actualH ); + y += actualH; + } +} + +/*! + \brief Performs tile horizontal action +*/ +void QtxWorkspace::tileHorizontal() +{ + QWidgetList winList = windowList(); + if ( winList.isEmpty() ) + return; + + int count = 0; + for ( QWidgetList::const_iterator itr = winList.begin(); itr != winList.end(); ++itr ) + if ( !( (*itr)->windowState() & Qt::WindowMinimized ) ) + count++; + + if ( !count ) + return; + + if ( activeWindow() && activeWindow()->windowState() & Qt::WindowMaximized ) + activeWindow()->showNormal(); + + int x = 0; + int widthForEach = width() / count; + for ( QWidgetList::iterator it = winList.begin(); it != winList.end(); ++it ) + { + QWidget* win = *it; + if ( win->windowState() & Qt::WindowMinimized ) + continue; + + if ( win->windowState() & Qt::WindowMaximized ) + { + win->hide(); + win->showNormal(); + } + +// QApplication::sendPostedEvents( 0, QEvent::ShowNormal ); + + int prefW = win->minimumWidth(); + int actualW = qMax( widthForEach, prefW ); + + win->parentWidget()->setGeometry( x, 0, actualW, height() ); + x += actualW; + } +} diff --git a/src/Qtx/QtxWorkspace.h b/src/Qtx/QtxWorkspace.h new file mode 100644 index 000000000..224d729c1 --- /dev/null +++ b/src/Qtx/QtxWorkspace.h @@ -0,0 +1,50 @@ +// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File: QtxWorkspace.h +// Author: Sergey TELKOV + +#ifndef QTXWORKSPACE_H +#define QTXWORKSPACE_H + +#include "Qtx.h" + +#include + +#ifdef WIN32 +#pragma warning( disable:4251 ) +#endif + +class QTX_EXPORT QtxWorkspace : public QWorkspace +{ + Q_OBJECT + +public: + QtxWorkspace( QWidget* = 0 ); + virtual ~QtxWorkspace(); + +public slots: + void tileVertical(); + void tileHorizontal(); +}; + +#ifdef WIN32 +#pragma warning( default:4251 ) +#endif + +#endif