1 // File: QtxWorkstack.h
2 // Author: Sergey TELKOV
12 #include <qwidgetlist.h>
20 class QtxWorkstackArea;
21 class QtxWorkstackDrag;
22 class QtxWorkstackChild;
23 class QtxWorkstackTabBar;
25 class QTX_EXPORT QtxWorkstack : public QWidget
29 enum { SplitVertical, SplitHorizontal, Close };
32 QtxWorkstack( QWidget* = 0 );
33 virtual ~QtxWorkstack();
35 QWidgetList windowList() const;
36 QWidgetList splitWindowList() const;
38 QWidget* activeWindow() const;
40 void split( const int );
43 void windowActivated( QWidget* );
47 void splitHorizontal();
50 void onPopupActivated( int );
51 void onDestroyed( QObject* );
52 void onWindowActivated( QWidget* );
53 void onContextMenuRequested( QPoint );
54 void onDeactivated( QtxWorkstackArea* );
57 virtual void childEvent( QChildEvent* );
58 virtual void customEvent( QCustomEvent* );
61 QSplitter* splitter( QtxWorkstackArea* ) const;
62 void splitters( QSplitter*, QPtrList<QSplitter>&, const bool = false ) const;
63 void areas( QSplitter*, QPtrList<QtxWorkstackArea>&, const bool = false ) const;
65 QSplitter* wrapSplitter( QtxWorkstackArea* );
66 void insertWidget( QWidget*, QWidget*, QWidget* );
68 QtxWorkstackArea* areaAt( const QPoint& ) const;
70 QtxWorkstackArea* targetArea();
71 QtxWorkstackArea* activeArea() const;
72 QtxWorkstackArea* currentArea() const;
74 void setActiveArea( QtxWorkstackArea* );
75 QtxWorkstackArea* neighbourArea( QtxWorkstackArea* ) const;
77 QtxWorkstackArea* createArea( QWidget* ) const;
80 void updateState( QSplitter* );
82 void distributeSpace( QSplitter* ) const;
86 QtxWorkstackArea* myArea;
89 friend class QtxWorkstackArea;
90 friend class QtxWorkstackDrag;
93 class QtxWorkstackArea : public QWidget
98 QtxWorkstackArea( QWidget* );
99 virtual ~QtxWorkstackArea();
101 bool isEmpty() const;
103 void insertWidget( QWidget*, const int = -1 );
104 void removeWidget( QWidget* );
106 QWidget* activeWidget() const;
107 void setActiveWidget( QWidget* );
109 bool contains( QWidget* ) const;
111 QWidgetList widgetList() const;
113 bool isActive() const;
114 void updateActiveState();
116 QtxWorkstack* workstack() const;
118 virtual bool eventFilter( QObject*, QEvent* );
120 QRect floatRect() const;
121 QRect floatTab( const int ) const;
123 int tabAt( const QPoint& ) const;
126 void activated( QWidget* );
127 void contextMenuRequested( QPoint );
128 void deactivated( QtxWorkstackArea* );
136 void onSelected( int );
138 void onDragActiveTab();
139 void onChildDestroyed( QObject* );
140 void onChildShown( QtxWorkstackChild* );
141 void onChildHided( QtxWorkstackChild* );
142 void onChildActivated( QtxWorkstackChild* );
143 void onChildCaptionChanged( QtxWorkstackChild* );
146 virtual void customEvent( QCustomEvent* );
147 virtual void focusInEvent( QFocusEvent* );
148 virtual void mousePressEvent( QMouseEvent* );
151 enum { ActivateEvent = QEvent::User, FocusEvent, RemoveEvent };
155 void updateCurrent();
156 void updateTab( QWidget* );
158 QWidget* widget( const int ) const;
159 int widgetId( QWidget* ) const;
160 bool widgetVisibility( QWidget* ) const;
162 void setWidgetActive( QWidget* );
163 void setWidgetShown( QWidget*, const bool );
165 int generateId() const;
167 bool isBlocked( QWidget* ) const;
168 void setBlocked( QWidget*, const bool );
170 QtxWorkstackChild* child( QWidget* ) const;
173 typedef QMap<QWidget*, bool> BlockMap;
174 typedef QMap<QWidget*, QtxWorkstackChild*> ChildMap;
175 typedef struct { int id; bool vis; } WidgetInfo;
176 typedef QMap<QWidget*, WidgetInfo> WidgetInfoMap;
179 QtxWorkstackTabBar* myBar;
180 QPushButton* myClose;
181 QWidgetStack* myStack;
184 WidgetInfoMap myInfo;
189 class QtxWorkstackChild : public QHBox
194 QtxWorkstackChild( QWidget*, QWidget* = 0 );
195 virtual ~QtxWorkstackChild();
197 QWidget* widget() const;
199 virtual bool eventFilter( QObject*, QEvent* );
202 void shown( QtxWorkstackChild* );
203 void hided( QtxWorkstackChild* );
204 void activated( QtxWorkstackChild* );
205 void captionChanged( QtxWorkstackChild* );
208 void onDestroyed( QObject* );
211 virtual void childEvent( QChildEvent* );
217 class QtxWorkstackTabBar : public QTabBar
222 QtxWorkstackTabBar( QWidget* = 0 );
223 virtual ~QtxWorkstackTabBar();
225 QRect tabRect( const int ) const;
227 void setActive( const bool );
230 void dragActiveTab();
231 void contextMenuRequested( QPoint );
234 virtual void mouseMoveEvent( QMouseEvent* );
235 virtual void mousePressEvent( QMouseEvent* );
236 virtual void mouseReleaseEvent( QMouseEvent* );
237 virtual void contextMenuEvent( QContextMenuEvent* );
239 virtual void paintLabel( QPainter*, const QRect&, QTab*, bool ) const;
245 class QtxWorkstackDrag : public QObject
250 QtxWorkstackDrag( QtxWorkstack*, QtxWorkstackChild* );
251 virtual ~QtxWorkstackDrag();
253 virtual bool eventFilter( QObject*, QEvent* );
258 void updateTarget( const QPoint& );
259 QtxWorkstackArea* detectTarget( const QPoint&, int& ) const;
260 void setTarget( QtxWorkstackArea*, const int );
264 void startDrawRect();
268 QtxWorkstackChild* myChild;
271 QtxWorkstackArea* myArea;