Salome HOME
d436fe25466770a878f04a9713e818850e50796b
[modules/gui.git] / src / Qtx / QtxWorkstackAction.h
1 // Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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, or (at your option) any later version.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File:      QtxWorkstackAction.h
24 // Author:    Sergey TELKOV
25 //
26 #ifndef QTXWORKSTACKACTION_H
27 #define QTXWORKSTACKACTION_H
28
29 #include "QtxActionSet.h"
30 #include <QDialog>
31
32 class QtxWorkstack;
33 class QRadioButton;
34 class QStackedLayout;
35 class QListWidget;
36 class QComboBox;
37 class QLabel;
38 class QToolButton;
39
40 #ifdef WIN32
41 #pragma warning( disable:4251 )
42 #endif
43
44 class QTX_EXPORT QtxWorkstackAction : public QtxActionSet
45 {
46   Q_OBJECT
47
48 public:
49   //! Actions (menu items) ID
50   enum { SplitVertical   = 0x0001,   //!< "Split window vertically" operation
51          SplitHorizontal = 0x0002,   //!< "Split window horizontally" operation
52          Windows         = 0x0010,   //!< A list of child windows menu items
53          Split           = SplitVertical | SplitHorizontal,
54          Standard        = Split | Windows };
55
56   QtxWorkstackAction( QtxWorkstack*, QObject* = 0 );
57   virtual ~QtxWorkstackAction();
58
59   QtxWorkstack* workstack() const;
60   QAction*      getArrangeViewsAction();
61
62   int           menuActions() const;
63   void          setMenuActions( const int );
64
65   QIcon         icon( const int ) const;
66   QString       text( const int ) const;
67   int           accel( const int ) const;
68   QString       statusTip( const int ) const;
69
70   void          setAccel( const int, const int );
71   void          setIcon( const int, const QIcon& );
72   void          setText( const int, const QString& );
73   void          setStatusTip( const int, const QString& );
74
75   void          perform( const int );
76
77 private slots:
78   void          onAboutToShow();
79   void          onTriggered( int );
80
81 protected:
82   virtual void  addedTo( QWidget* );
83   virtual void  removedFrom( QWidget* );
84
85 private:
86   void          updateContent();
87   void          updateWindows();
88   void          splitVertical();
89   void          splitHorizontal();
90   void          activateItem( const int );
91
92 private:
93   QtxWorkstack* myWorkstack;       //!< parent workstack
94   bool          myWindowsFlag;     //!< "show child windows items" flag
95   QAction*      myArrangeViewsAction;
96 };
97
98 enum QtxSplitDlgMode{ ArrangeViews, CreateSubViews };
99
100 class QTX_EXPORT QtxSplitDlg : public QDialog
101 {
102   Q_OBJECT
103
104   enum ViewMode{ XYZ, XY, XZ, YZ };
105
106 public:
107   QtxSplitDlg( QWidget* = 0, QtxWorkstack* = NULL, QtxSplitDlgMode = ArrangeViews );
108   ~QtxSplitDlg();
109   int getSplitMode();
110   QList<int> getViewsMode();
111
112 private :
113   QToolButton* createSplitButton( int, int );
114   void initialize();
115   void valid();
116
117   QStackedLayout* myStackedSplitLayout;
118   QRadioButton* myButton2Views;
119   QRadioButton* myButton3Views;
120   QRadioButton* myButton4Views;
121   QPushButton* myButtonApply;
122   QPushButton* myButtonPrevious;
123   QPushButton* myButtonNext;
124   QList<QLabel*> myLabels;
125   QList<QComboBox*> myComboBox;
126   QListWidget* myViewsList;
127
128   QtxWorkstack* myWorkstack;
129   QtxSplitDlgMode myDlgMode;
130
131   int myViewsNB;
132   int mySplitMode;
133   int myNBSelectedViews;
134   bool myIsCloseViews;
135   QMap<QComboBox*, ViewMode> myMapComboBoxMode;
136   QMap<ViewMode, bool> myMapModeIsBusy;
137
138 private slots:
139
140   void onChangeIcons();
141   void onSplitChanged(int);
142   void onComboBoxChanged(int);
143   void onPreviousViews();
144   void onNextViews();
145   void onSynchronize();
146   void onCloseViews();
147   void onStackViews();
148   void onApply();
149 };
150
151 #ifdef WIN32
152 #pragma warning( default:4251 )
153 #endif
154
155 #endif