-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// 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 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, or (at your option) any later version.
//
-// 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File: QtxWorkstack.h
// Author: Sergey TELKOV
//
#include "Qtx.h"
-#include <QWidget>
+#include <QMap>
#include <QFrame>
-#include <QTabBar>
#include <QEvent>
-#include <QMap>
+#include <QWidget>
+#include <QTabBar>
+#include <QPointer>
+#include <QSplitter>
+#include <QByteArray>
class QAction;
-class QSplitter;
-class QStackedWidget;
+class QDataStream;
class QRubberBand;
+class QStackedWidget;
class QAbstractButton;
class QtxWorkstackArea;
class QtxWorkstackDrag;
class QtxWorkstackChild;
class QtxWorkstackTabBar;
+class QtxWorkstackSplitter;
#ifdef WIN32
#pragma warning( disable:4251 )
public:
//! Workstack actions (context menu items)
enum { SplitVertical = 0x01, //!< "Split vertically" menu item
- SplitHorizontal = 0x02, //!< "Split horizontally" menu item
- Close = 0x04, //!< "Close" menu item
- Rename = 0x08, //!< "Rename" menu item
- All = SplitVertical | SplitHorizontal |
- Close | Rename //!< all menu items
+ SplitHorizontal = 0x02, //!< "Split horizontally" menu item
+ Close = 0x04, //!< "Close" menu item
+ Rename = 0x08, //!< "Rename" menu item
+ All = SplitVertical | SplitHorizontal |
+ Close | Rename //!< all menu items
+ };
+
+ enum { VersionMarker = 0x01,
+ SplitMarker = 0x02,
+ AreaMarker = 0x04,
+ WidgetMarker = 0x08
};
-
+
+ enum { Horizontal = 0x01,
+ Visible = 0x02
+ };
+
//! Workstack splitting type
enum SplitType
{
QWidgetList splitWindowList() const;
QWidget* activeWindow() const;
+ void setActiveWindow( QWidget* );
int accel( const int ) const;
void setAccel( const int, const int );
void setMenuActions( const int );
int menuActions() const;
+ void stack();
void split( const int );
bool move( QWidget* wid, QWidget* wid_to, const bool before );
- void stack();
QWidget* addWindow( QWidget*, Qt::WindowFlags = 0 );
+ QByteArray saveState( int ) const;
+ bool restoreState( const QByteArray&, int );
+
+ void setOpaqueResize( bool = true );
+ bool opaqueResize() const;
+
+ void splittersVisible( QWidget*, bool = true );
+
void Split( QWidget* wid, const Qt::Orientation o, const SplitType type );
void Attract( QWidget* wid1, QWidget* wid2, const bool all );
void SetRelativePosition( QWidget* wid, const Qt::Orientation o, const double pos );
void SetRelativePositionInSplitter( QWidget* wid, const double pos );
- // asv: Store/Restore visual parameters - geometry of inner windows
- QtxWorkstack& operator<<( const QString& );
- QtxWorkstack& operator>>( QString& );
+ void updateState();
signals:
void windowActivated( QWidget* );
public slots:
void splitVertical();
void splitHorizontal();
-
+
private slots:
void onRename();
void onCloseWindow();
protected:
virtual void customEvent( QEvent* );
+ QAction* action( const int ) const;
+
+ void saveState( QDataStream& ) const;
+ bool restoreState( QDataStream& );
+
private:
QSplitter* splitter( QtxWorkstackArea* ) const;
void splitters( QSplitter*, QList<QSplitter*>&, const bool = false ) const;
QtxWorkstackArea* createArea( QWidget* ) const;
- void updateState();
void updateState( QSplitter* );
+ void splitterVisible(QWidget*, QList<QSplitter*>&, QSplitter*, bool );
+
void distributeSpace( QSplitter* ) const;
+
int setPosition( QWidget* wid, QSplitter* split, const Qt::Orientation o,
- const int need_pos, const int splitter_pos );
-
- void splitterInfo( QSplitter*, QString& ) const;
- void setSplitter( QSplitter*, const QString&, QMap< QSplitter*, QList<int> >& );
-
+ const int need_pos, const int splitter_pos );
+
private:
- QWidget* myWin; //!< active widget
- QtxWorkstackArea* myArea; //!< active workarea
- QSplitter* mySplit; //!< tol-level splitter
- QWidget* myWorkWin; //!< widget where popup menu is invoked (used internally)
- QtxWorkstackArea* myWorkArea; //!< workarea where popup menu is invoked (used internally)
+ QPointer<QWidget> myWin; //!< active widget
+ QPointer<QtxWorkstackArea> myArea; //!< active workarea
+ QtxWorkstackSplitter* mySplit; //!< tol-level splitter
+ QPointer<QWidget> myWorkWin; //!< widget where popup menu is invoked (used internally)
+ QPointer<QtxWorkstackArea> myWorkArea; //!< workarea where popup menu is invoked (used internally)
QMap<int, QAction*> myActionsMap; //!< actions map
friend class QtxWorkstackArea;
friend class QtxWorkstackDrag;
+ friend class QtxWorkstackAction;
+ friend class QtxWorkstackSplitter;
};
-class QtxWorkstackArea : public QFrame
+class QtxWorkstackSplitter : public QSplitter
+{
+ Q_OBJECT
+
+public:
+ QtxWorkstackSplitter( QWidget* = 0 );
+ virtual ~QtxWorkstackSplitter();
+
+ QtxWorkstack* workstack() const;
+
+ void saveState( QDataStream& ) const;
+ bool restoreState( QDataStream&, QMap<QString, QtxWorkstackChild*>& );
+};
+
+class QTX_EXPORT QtxWorkstackArea : public QFrame
{
Q_OBJECT
class WidgetEvent;
+ class RestoreEvent;
public:
QtxWorkstackArea( QWidget* );
bool isNull() const;
bool isEmpty() const;
- QWidget* insertWidget( QWidget*, const int = -1, Qt::WindowFlags = 0 );
+ QtxWorkstackChild* insertWidget( QWidget*, const int = -1, Qt::WindowFlags = 0 );
void removeWidget( QWidget*, const bool = true );
+ void insertChild( QtxWorkstackChild*, const int = -1 );
+ void removeChild( QtxWorkstackChild*, const bool = true );
+
QWidget* activeWidget() const;
void setActiveWidget( QWidget* );
bool contains( QWidget* ) const;
QWidgetList widgetList() const;
+ QList<QtxWorkstackChild*> childList() const;
bool isActive() const;
void updateActiveState();
int tabAt( const QPoint& ) const;
+ void saveState( QDataStream& ) const;
+ bool restoreState( QDataStream&, QMap<QString, QtxWorkstackChild*>& );
+
+ void showTabBar( bool = true);
+
signals:
void activated( QWidget* );
void contextMenuRequested( QWidget*, QPoint );
void deactivated( QtxWorkstackArea* );
-public slots:
- virtual void setVisible( bool );
-
private slots:
void onClose();
void onCurrentChanged( int );
- void onWidgetDestroyed();
-
void onChildDestroyed( QObject* );
void onChildShown( QtxWorkstackChild* );
void onChildHidden( QtxWorkstackChild* );
private:
//! Custom events
enum { ActivateWidget = QEvent::User, //!< activate widget event
- FocusWidget, //!< focus receiving widget event
- RemoveWidget //!< widget removing event
+ FocusWidget, //!< focus receiving widget event
+ MakeCurrent,
+ RestoreWidget
};
private:
QWidget* widget( const int ) const;
int widgetId( QWidget* ) const;
- bool widgetVisibility( QWidget* ) const;
+
+ QtxWorkstackChild* child( QWidget* ) const;
+ QtxWorkstackChild* child( const int ) const;
void setWidgetActive( QWidget* );
- void setWidgetShown( QWidget*, const bool );
int generateId() const;
- bool isBlocked( QWidget* ) const;
- void setBlocked( QWidget*, const bool );
-
- QtxWorkstackChild* child( QWidget* ) const;
-
private:
- struct WidgetInfo
- {
- WidgetInfo() : id( 0 ), vis( false ) {}
- int id; bool vis;
- };
-
- typedef QMap<QWidget*, bool> BlockMap;
- typedef QMap<QWidget*, QtxWorkstackChild*> ChildMap;
- typedef QMap<QWidget*, WidgetInfo> WidgetInfoMap;
+ typedef QList<QtxWorkstackChild*> ChildList;
private:
+ QWidget* myTop; //!< workarea top widget
QtxWorkstackTabBar* myBar; //!< workarea tab bar header
+ ChildList myList; //!< child widgets list
QAbstractButton* myClose; //!< close button
QStackedWidget* myStack; //!< widget stack
-
- QWidgetList myList; //!< child widgets list
- WidgetInfoMap myInfo; //!< widgets states mp
- ChildMap myChild; //!< child widget containers map
- BlockMap myBlock; //!< blocked widgets
};
class QtxWorkstackChild : public QWidget
QtxWorkstackChild( QWidget*, QWidget* = 0, Qt::WindowFlags = 0 );
virtual ~QtxWorkstackChild();
- QWidget* widget() const;
+ QWidget* widget() const
+;
+
+ int id() const;
+ void setId( const int );
+
+ bool visibility();
+
+ QtxWorkstackArea* area() const;
virtual bool eventFilter( QObject*, QEvent* );
virtual void childEvent( QChildEvent* );
private:
- QWidget* myWidget; //!< child widget
+ int myId; //!< id
+ QPointer<QWidget> myWidget; //!< child widget
};
class QtxWorkstackTabBar : public QTabBar
void onCurrentChanged( int );
protected:
+ virtual void changeEvent( QEvent* );
virtual void mouseMoveEvent( QMouseEvent* );
virtual void mousePressEvent( QMouseEvent* );
virtual void mouseReleaseEvent( QMouseEvent* );
virtual void contextMenuEvent( QContextMenuEvent* );
- virtual void changeEvent( QEvent* );
-
-// virtual void paintLabel( QPainter*, const QRect&, QTab*, bool ) const;
private:
int myId; //!< current tab page index