Added a Recent Executables menu.
[kdbg.git] / DockWidget / dockmanager.h
blobdec30e21adbd0d08d38fec9e6f558c3e454016f9
1 /***************************************************************************
2 DockWidget part of KDEStudio
3 -------------------
4 copyright : (C) 1999 by Judin Max
5 email : novaprint@mtu-net.ru
6 ***************************************************************************/
8 /* === MEMOS ===
9 DockTabCtl and DockSplitter always have parent DockWidget;
16 #ifndef DOCKMANAGER_H
17 #define DOCKMANAGER_H
19 #include <qwidget.h>
20 #include <qobject.h>
21 #include <qpoint.h>
22 #include <qlist.h>
23 #include <qpixmap.h>
24 #include <qpushbutton.h>
25 #include <qstrlist.h>
26 #include "knewpanner.h"
28 #include "stabctl.h"
30 class QObjectList;
31 class DockSplitter;
32 class DockMoveManager;
33 class KTMainWindow;
34 class QPopupMenu;
35 class KConfig;
37 typedef QList<QWidget> WidgetList;
39 class DockTabCtl : public STabCtl
40 { Q_OBJECT
41 public:
42 DockTabCtl( QWidget *parent = 0, const char *name = 0 )
43 :STabCtl( parent, name ){};
44 ~DockTabCtl(){};
47 enum DockPosition
49 DockNone = 0,
50 DockTop = 0x0001,
51 DockLeft = 0x0002,
52 DockRight = 0x0004,
53 DockBottom = 0x0008,
54 DockCenter = 0x0010,
55 DockDesktop= 0x0020
58 class SDockButton : public QPushButton
59 { Q_OBJECT
60 public:
61 SDockButton( QWidget *parent=0, const char *name=0 );
62 ~SDockButton();
63 protected:
64 virtual void drawButton( QPainter * );
65 virtual void enterEvent( QEvent * );
66 virtual void leaveEvent( QEvent * );
68 private:
69 bool moveMouse;
72 class DockWidget: public QWidget
73 { Q_OBJECT
74 friend class DockManager;
75 friend class DockSplitter;
76 friend class DockMainWindow;
78 public:
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 * );
97 virtual void show();
99 void makeDockVisible();
100 bool mayBeHide();
101 bool mayBeShow();
103 public slots:
104 void changeHideShowState();
106 protected:
107 void updateCaptionButton();
108 virtual void paintCaption();
110 signals:
111 //emit for dock when another DockWidget docking in this DockWidget
112 void docking( DockWidget*, DockPosition );
113 void setDockDefaultPos();
115 public slots:
116 void unDock();
118 private slots:
119 void slotCloseButtonClick();
121 private:
122 void setDockTabName( DockTabCtl* );
123 void applyToWidget( QWidget* s, const QPoint& p = QPoint(0,0) );
124 QRect crect();
126 QWidget* widget;
127 SDockButton* closeButton;
128 SDockButton* stayButton;
129 DockManager* manager;
130 QPixmap* drawBuffer;
131 QPixmap* pix;
133 int eDocking;
134 int sDocking;
135 int dockCaptionHeight;
137 // GROUP data
138 const char* firstName;
139 const char* lastName;
140 int splitterOrientation;
141 bool isGroup;
142 bool isTabGroup;
145 #ifdef DOCK_ORIGINAL
146 struct menuDockData
148 menuDockData( QWidget* _dock, bool _hide )
150 dock = _dock;
151 hide = _hide;
153 ~menuDockData(){};
155 QWidget* dock;
156 bool hide;
158 #endif
160 class DockManager: public QObject
161 {Q_OBJECT
162 friend class DockWidget;
163 friend class DockMainWindow;
165 public:
166 DockManager( QWidget* mainWindow, const char* name = 0L );
167 virtual ~DockManager();
169 void activate();
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 );
178 void drop();
180 DockWidget* findWidgetParentDock( QWidget* );
181 void makeWidgetDockVisible( QWidget* w ){ findWidgetParentDock(w)->makeDockVisible(); }
183 #ifdef DOCK_ORIGINAL
184 QPopupMenu* dockMenu(){ return menu; }
185 #endif
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,
204 int pos= 50);
206 signals:
207 void change();
208 void replaceDock( DockWidget* oldDock, DockWidget* newDock );
209 void setDockDefaultPos( DockWidget* );
211 private slots:
212 #ifdef DOCK_ORIGINAL
213 // void slotTabShowPopup( int, QPoint );
214 // void slotUndockTab();
215 // void slotHideTab();
216 // void slotMenuPopup();
217 // void slotMenuActivated( int );
218 #endif
220 private:
221 QWidget* main;
222 DockMoveManager* mg;
223 DockWidget* currentDragWidget;
224 DockWidget* currentMoveWidget; // widget where mouse moving
225 WidgetList* childDockWidgetList;
226 DockPosition curPos;
227 QList<DockWidget>* childDock;
228 QObjectList* autoCreateDock;
229 int storeW;
230 int storeH;
231 bool draging;
232 bool undockProcess;
233 bool dropCancel;
235 #ifdef DOCK_ORIGINAL
236 /* right mouse button click on the tabbar data: */
237 DockWidget* curTabDockWidget;
238 QPopupMenu* menu;
239 QList<menuDockData> *menuData;
240 #endif
243 #endif