1 /***************************************************************************
2 DockWidget part of KDEStudio
4 copyright : (C) 1999 by Judin Max
5 email : novaprint@mtu-net.ru
6 ***************************************************************************/
9 DockTabCtl and DockSplitter always have parent DockWidget;
24 #include <qpushbutton.h>
26 #include "knewpanner.h"
32 class DockMoveManager
;
37 typedef QList
<QWidget
> WidgetList
;
39 class DockTabCtl
: public STabCtl
42 DockTabCtl( QWidget
*parent
= 0, const char *name
= 0 )
43 :STabCtl( parent
, name
){};
58 class SDockButton
: public QPushButton
61 SDockButton( QWidget
*parent
=0, const char *name
=0 );
64 virtual void drawButton( QPainter
* );
65 virtual void enterEvent( QEvent
* );
66 virtual void leaveEvent( QEvent
* );
72 class DockWidget
: public QWidget
74 friend class DockManager
;
75 friend class DockSplitter
;
76 friend class DockMainWindow
;
79 DockWidget( DockManager
* dockManager
, const char* name
, const QPixmap
&pixmap
, QWidget
* parent
= 0L );
80 virtual ~DockWidget();
82 /* if target is null - dock move to desktop at position pos;
83 check - only for internal uses;
84 return result GroupDockWidget
86 DockWidget
* manualDock( DockWidget
* target
, DockPosition dockPos
, int spliPos
= 50, QPoint pos
= QPoint(0,0), bool check
= false );
88 void setEnableDocking( int pos
);
89 int enableDocking(){ return eDocking
; }
91 void setDockSite( int pos
){ sDocking
= pos
;}
92 int dockSite(){ return sDocking
; }
94 void setWidget( QWidget
* );
96 virtual bool event( QEvent
* );
99 void makeDockVisible();
104 void changeHideShowState();
107 void updateCaptionButton();
108 virtual void paintCaption();
111 //emit for dock when another DockWidget docking in this DockWidget
112 void docking( DockWidget
*, DockPosition
);
113 void setDockDefaultPos();
119 void slotCloseButtonClick();
122 void setDockTabName( DockTabCtl
* );
123 void applyToWidget( QWidget
* s
, const QPoint
& p
= QPoint(0,0) );
127 SDockButton
* closeButton
;
128 SDockButton
* stayButton
;
129 DockManager
* manager
;
135 int dockCaptionHeight
;
138 const char* firstName
;
139 const char* lastName
;
140 int splitterOrientation
;
148 menuDockData( QWidget
* _dock
, bool _hide
)
160 class DockManager
: public QObject
162 friend class DockWidget
;
163 friend class DockMainWindow
;
166 DockManager( QWidget
* mainWindow
, const char* name
= 0L );
167 virtual ~DockManager();
171 void writeConfig( KConfig
* c
= 0L, QString group
= QString() );
172 void readConfig ( KConfig
* c
= 0L, QString group
= QString() );
174 bool eventFilter( QObject
*, QEvent
* );
176 void startDrag( DockWidget
* );
177 void dragMove( DockWidget
*, QPoint pos
);
180 DockWidget
* findWidgetParentDock( QWidget
* );
181 void makeWidgetDockVisible( QWidget
* w
){ findWidgetParentDock(w
)->makeDockVisible(); }
184 QPopupMenu
* dockMenu(){ return menu
; }
187 DockWidget
* findDockWidgetAt( const QPoint
& pos
);
188 void findChildDockWidget( QWidget
*&, const QWidget
* p
, const QPoint
& pos
);
189 void findChildDockWidget( const QWidget
* p
, WidgetList
*& );
190 DockWidget
* getDockWidgetFromName( const char* dockName
);
193 * Create a DockTabCtl or derived class. This implementation just returns
194 * new DockTabCtl(parent, name).
196 virtual DockTabCtl
* createTabCtrl( QWidget
*parent
= 0, const char *name
= 0 );
198 * Create a DockSplitter or derived class. This implementation just returns
199 * new DockSplitter(parent, name, orient, units, pos).
201 virtual DockSplitter
* createDockSplitter(QWidget
*parent
= 0, const char *name
= 0,
202 KNewPanner::Orientation orient
= KNewPanner::Vertical
,
203 KNewPanner::Units units
= KNewPanner::Percent
,
208 void replaceDock( DockWidget
* oldDock
, DockWidget
* newDock
);
209 void setDockDefaultPos( DockWidget
* );
213 // void slotTabShowPopup( int, QPoint );
214 // void slotUndockTab();
215 // void slotHideTab();
216 // void slotMenuPopup();
217 // void slotMenuActivated( int );
223 DockWidget
* currentDragWidget
;
224 DockWidget
* currentMoveWidget
; // widget where mouse moving
225 WidgetList
* childDockWidgetList
;
227 QList
<DockWidget
>* childDock
;
228 QObjectList
* autoCreateDock
;
236 /* right mouse button click on the tabbar data: */
237 DockWidget
* curTabDockWidget
;
239 QList
<menuDockData
> *menuData
;