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* );
84 QtxWorkstackArea* myArea;
87 friend class QtxWorkstackArea;
88 friend class QtxWorkstackDrag;
91 class QtxWorkstackArea : public QWidget
96 QtxWorkstackArea( QWidget* );
97 virtual ~QtxWorkstackArea();
101 void insertWidget( QWidget*, const int = -1 );
102 void removeWidget( QWidget* );
104 QWidget* activeWidget() const;
105 void setActiveWidget( QWidget* );
107 bool contains( QWidget* ) const;
109 QWidgetList widgetList() const;
111 bool isActive() const;
112 void updateActiveState();
114 QtxWorkstack* workstack() const;
116 virtual bool eventFilter( QObject*, QEvent* );
118 QRect floatRect() const;
119 QRect floatTab( const int ) const;
121 int tabAt( const QPoint& ) const;
124 void activated( QWidget* );
125 void contextMenuRequested( QPoint );
126 void deactivated( QtxWorkstackArea* );
134 void onSelected( int );
136 void onDragActiveTab();
137 void onChildDestroyed( QObject* );
138 void onChildShown( QtxWorkstackChild* );
139 void onChildHided( QtxWorkstackChild* );
140 void onChildActivated( QtxWorkstackChild* );
141 void onChildCaptionChanged( QtxWorkstackChild* );
144 virtual void customEvent( QCustomEvent* );
145 virtual void focusInEvent( QFocusEvent* );
146 virtual void mousePressEvent( QMouseEvent* );
149 enum { ActivateEvent = QEvent::User, FocusEvent, RemoveEvent };
153 void updateCurrent();
154 void updateTab( QWidget* );
156 QWidget* widget( const int ) const;
157 int widgetId( QWidget* ) const;
158 bool widgetVisibility( QWidget* ) const;
160 void setWidgetActive( QWidget* );
161 void setWidgetShown( QWidget*, const bool );
163 int generateId() const;
165 bool isBlocked( QWidget* ) const;
166 void setBlocked( QWidget*, const bool );
168 QtxWorkstackChild* child( QWidget* ) const;
171 typedef QMap<QWidget*, bool> BlockMap;
172 typedef QMap<QWidget*, QtxWorkstackChild*> ChildMap;
173 typedef struct { int id; bool vis; } WidgetInfo;
174 typedef QMap<QWidget*, WidgetInfo> WidgetInfoMap;
177 QtxWorkstackTabBar* myBar;
178 QPushButton* myClose;
179 QWidgetStack* myStack;
182 WidgetInfoMap myInfo;
187 class QtxWorkstackChild : public QHBox
192 QtxWorkstackChild( QWidget*, QWidget* = 0 );
193 virtual ~QtxWorkstackChild();
195 QWidget* widget() const;
197 virtual bool eventFilter( QObject*, QEvent* );
200 void shown( QtxWorkstackChild* );
201 void hided( QtxWorkstackChild* );
202 void activated( QtxWorkstackChild* );
203 void captionChanged( QtxWorkstackChild* );
206 void onDestroyed( QObject* );
209 virtual void childEvent( QChildEvent* );
215 class QtxWorkstackTabBar : public QTabBar
220 QtxWorkstackTabBar( QWidget* = 0 );
221 virtual ~QtxWorkstackTabBar();
223 QRect tabRect( const int ) const;
225 void setActive( const bool );
228 void dragActiveTab();
229 void contextMenuRequested( QPoint );
232 virtual void mouseMoveEvent( QMouseEvent* );
233 virtual void mousePressEvent( QMouseEvent* );
234 virtual void mouseReleaseEvent( QMouseEvent* );
235 virtual void contextMenuEvent( QContextMenuEvent* );
237 virtual void paintLabel( QPainter*, const QRect&, QTab*, bool ) const;
243 class QtxWorkstackDrag : public QObject
248 QtxWorkstackDrag( QtxWorkstack*, QtxWorkstackChild* );
249 virtual ~QtxWorkstackDrag();
251 virtual bool eventFilter( QObject*, QEvent* );
256 void updateTarget( const QPoint& );
257 QtxWorkstackArea* detectTarget( const QPoint&, int& ) const;
258 void setTarget( QtxWorkstackArea*, const int );
262 void startDrawRect();
266 QtxWorkstackChild* myChild;
269 QtxWorkstackArea* myArea;