Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/gui.git] / src / Qtx / QtxWorkstack.h
index fa9c4584afc320aba4672b6e8e6acca0edf1107b..36b4382bde524afc874d817630a22831ad423f77 100644 (file)
@@ -1,3 +1,21 @@
+// 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/
+//
 // File:      QtxWorkstack.h
 // Author:    Sergey TELKOV
 
@@ -11,6 +29,7 @@
 #include <qtabbar.h>
 #include <qwidgetlist.h>
 
+class QAction;
 class QTabBar;
 class QPainter;
 class QSplitter;
@@ -22,11 +41,23 @@ class QtxWorkstackDrag;
 class QtxWorkstackChild;
 class QtxWorkstackTabBar;
 
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
 class QTX_EXPORT QtxWorkstack : public QWidget
 {
   Q_OBJECT
 
-  enum { SplitVertical, SplitHorizontal, Close };
+public:
+  enum { SplitVertical, SplitHorizontal, Close, Rename };
+    
+  enum SplitType
+  {
+    SPLIT_STAY, //!< given widget stays in its workarea, others are moved into a new one
+    SPLIT_AT,   //!< widgets before a given widget stays in they workarea, others are moved into a new one
+    SPLIT_MOVE  //!< given widget is moved into a new workarea, others stay in an old one
+  };
 
 public:
   QtxWorkstack( QWidget* = 0 );
@@ -37,20 +68,36 @@ public:
 
   QWidget*            activeWindow() const;
 
+  int                 accel( const int ) const;
+  void                setAccel( const int, const int );
+
   void                split( const int );
 
+  // STV: Useless function. wid->setFocus() should be used instead.
+  // void OnTop( QWidget* wid);
+
+  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& );
+
 signals:
   void                windowActivated( QWidget* );
 
 public slots:
   void                splitVertical();
   void                splitHorizontal();
-
+  
 private slots:
-  void                onPopupActivated( int );
+  void                onRename();
+  void                onCloseWindow();
   void                onDestroyed( QObject* );
   void                onWindowActivated( QWidget* );
-  void                onContextMenuRequested( QPoint );
+  void                onContextMenuRequested( QWidget*, QPoint );
   void                onDeactivated( QtxWorkstackArea* );
 
 protected:
@@ -80,11 +127,20 @@ private:
   void                updateState( QSplitter* );
 
   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*,QValueList<int> >& );
+  
 private:
   QWidget*            myWin;
   QtxWorkstackArea*   myArea;
   QSplitter*          mySplit;
+  QWidget*            myWorkWin;
+  QtxWorkstackArea*   myWorkArea;
+
+  QMap<int, QAction*> myActionsMap; //!< The map of the actions. Allows to get the QAction object by the key.
 
   friend class QtxWorkstackArea;
   friend class QtxWorkstackDrag;
@@ -101,7 +157,7 @@ public:
   bool                isEmpty() const;
 
   void                insertWidget( QWidget*, const int = -1 );
-  void                removeWidget( QWidget* );
+  void                removeWidget( QWidget*, const bool = true );
 
   QWidget*            activeWidget() const;
   void                setActiveWidget( QWidget* );
@@ -124,7 +180,7 @@ public:
 
 signals:
   void                activated( QWidget* );
-  void                contextMenuRequested( QPoint );
+  void                contextMenuRequested( QWidget*, QPoint );
   void                deactivated( QtxWorkstackArea* );
 
 public slots:
@@ -135,20 +191,24 @@ private slots:
   void                onClose();
   void                onSelected( int );
 
-  void                onDragActiveTab();
+  void                onWidgetDestroyed();
+
   void                onChildDestroyed( QObject* );
   void                onChildShown( QtxWorkstackChild* );
   void                onChildHided( QtxWorkstackChild* );
   void                onChildActivated( QtxWorkstackChild* );
   void                onChildCaptionChanged( QtxWorkstackChild* );
 
+  void                onDragActiveTab();
+  void                onContextMenuRequested( QPoint );
+
 protected:
   virtual void        customEvent( QCustomEvent* );
   virtual void        focusInEvent( QFocusEvent* );
   virtual void        mousePressEvent( QMouseEvent* );
 
 private:
-  enum { ActivateEvent = QEvent::User, FocusEvent, RemoveEvent };
+  enum { ActivateWidget = QEvent::User, FocusWidget, RemoveWidget };
 
 private:
   void                updateState();
@@ -170,9 +230,14 @@ private:
   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 struct { int id; bool vis; }       WidgetInfo;
   typedef QMap<QWidget*, WidgetInfo>         WidgetInfoMap;
 
 private:
@@ -270,6 +335,11 @@ private:
   int                 myTab;
   QtxWorkstackArea*   myArea;
   QPainter*           myPainter;
+  
 };
 
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
 #endif