00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #ifndef KDOCKWIDGET_H
00047 #define KDOCKWIDGET_H
00048
00049 #define _KDOCKWIDGET_2_2_
00050
00051 #include <qpoint.h>
00052 #include <qptrlist.h>
00053 #include <qframe.h>
00054 #include <qdom.h>
00055 #include <qtabwidget.h>
00056
00057 #ifndef NO_KDE2
00058 #include <kmainwindow.h>
00059 #include <netwm_def.h>
00060 #else
00061
00062 #include <qmainwindow.h>
00063 #include "exportdockclass.h"
00064 #include "dummykmainwindow.h"
00065 #endif
00066
00067 class KDockSplitter;
00068 class KDockManager;
00069 class KDockMoveManager;
00070 class KDockWidget;
00071 class KDockButton_Private;
00072 class KDockWidgetPrivate;
00073 class KDockWidgetHeaderPrivate;
00074 class KDockArea;
00075
00076 class QObjectList;
00077 class QPopupMenu;
00078 class QVBoxLayout;
00079 class QHBoxLayout;
00080 class QPixmap;
00081
00082 #ifndef NO_KDE2
00083 class KToolBar;
00084 class KConfig;
00085 #else
00086 class QToolBar;
00087 #endif
00088
00089 class KDockContainer;
00090
00091 namespace KMDI
00092 {
00093 class MainWindow;
00094 }
00095
00103 class KDEUI_EXPORT KDockWidgetAbstractHeader : public QFrame
00104 {
00105 Q_OBJECT
00106 public:
00107
00114 KDockWidgetAbstractHeader( KDockWidget* parent, const char* name = 0L );
00115
00119 virtual ~KDockWidgetAbstractHeader(){}
00120
00124 virtual void setTopLevel( bool ){}
00125
00126 #ifndef NO_KDE2
00127
00130 virtual void saveConfig( KConfig* ){}
00131
00135 virtual void loadConfig( KConfig* ){}
00136 #endif
00137
00138 protected:
00139 virtual void virtual_hook( int id, void* data );
00140 private:
00141 class KDockWidgetAbstractHeaderPrivate;
00142 KDockWidgetAbstractHeaderPrivate *d;
00143 };
00144
00152 class KDEUI_EXPORT KDockWidgetAbstractHeaderDrag : public QFrame
00153 {
00154 Q_OBJECT
00155 public:
00156
00164 KDockWidgetAbstractHeaderDrag( KDockWidgetAbstractHeader* parent,
00165 KDockWidget* dock, const char* name = 0L );
00166
00170 virtual ~KDockWidgetAbstractHeaderDrag(){}
00171
00175 KDockWidget* dockWidget() const { return dw; }
00176
00177 private:
00181 KDockWidget* dw;
00182 protected:
00183 virtual void virtual_hook( int id, void* data );
00184 private:
00185 class KDockWidgetAbstractHeaderDragPrivate;
00186 KDockWidgetAbstractHeaderDragPrivate *d;
00187 };
00188
00197 class KDEUI_EXPORT KDockWidgetHeaderDrag : public KDockWidgetAbstractHeaderDrag
00198 {
00199 Q_OBJECT
00200 public:
00201
00209 KDockWidgetHeaderDrag( KDockWidgetAbstractHeader* parent, KDockWidget* dock,
00210 const char* name = 0L );
00211
00215 virtual ~KDockWidgetHeaderDrag(){}
00216
00217 protected:
00218
00222 virtual void paintEvent( QPaintEvent* );
00223
00224 protected:
00225 virtual void virtual_hook( int id, void* data );
00226 private:
00227 class KDockWidgetHeaderDragPrivate;
00228 KDockWidgetHeaderDragPrivate *d;
00229 };
00230
00238 class KDEUI_EXPORT KDockWidgetHeader : public KDockWidgetAbstractHeader
00239 {
00240 Q_OBJECT
00241 public:
00242
00249 KDockWidgetHeader( KDockWidget* parent, const char* name = 0L );
00250
00254 virtual ~KDockWidgetHeader(){}
00255
00261 virtual void setTopLevel( bool t);
00262
00268 void setDragPanel( KDockWidgetHeaderDrag* nd );
00269
00275 KDockWidgetHeaderDrag *dragPanel();
00276
00277 bool dragEnabled() const;
00278 void setDragEnabled(bool b);
00280 void showUndockButton(bool show);
00281
00283 void forceCloseButtonHidden(bool enable=true);
00284 #ifndef NO_KDE2
00285
00290 virtual void saveConfig( KConfig* c);
00291
00297 virtual void loadConfig( KConfig* c);
00298 #endif
00299
00300
00301
00302
00303
00304
00305 void addButton(KDockButton_Private*);
00306
00307
00308
00309
00310
00311
00312 void removeButton(KDockButton_Private*);
00313
00314
00315
00316 protected slots:
00320 void slotStayClicked();
00321
00322 protected:
00323
00327 QHBoxLayout* layout;
00328
00332 KDockButton_Private* closeButton;
00333
00337 KDockButton_Private* stayButton;
00338
00342 KDockButton_Private* dockbackButton;
00343
00347 KDockWidgetHeaderDrag* drag;
00348
00349 protected:
00350 virtual void virtual_hook( int id, void* data );
00351 private:
00352 KDockWidgetHeaderPrivate *d;
00353 };
00354
00363 class KDEUI_EXPORT KDockTabGroup : public QTabWidget
00364 {
00365 Q_OBJECT
00366 public:
00370 KDockTabGroup( QWidget *parent = 0, const char *name = 0 )
00371 :QTabWidget( parent, name ){}
00372
00376 virtual ~KDockTabGroup(){}
00377
00378 QWidget *transientTo();
00379 protected:
00380 virtual void virtual_hook( int id, void* data );
00381 private:
00382 class KDockTabGroupPrivate;
00383 KDockTabGroupPrivate *d;
00384 };
00385
00386
00423 class KDEUI_EXPORT KDockWidget: public QWidget
00424 {
00425 Q_OBJECT
00426 friend class KDockManager;
00427 friend class KDockSplitter;
00428 friend class KDockMainWindow;
00429 friend class KDockArea;
00430
00431 public:
00447 KDockWidget( KDockManager* dockManager, const char* name,
00448 const QPixmap &pixmap, QWidget* parent = 0L, const QString& strCaption = QString::null,
00449 const QString& strTabPageLabel = QString::fromLatin1( " " ), WFlags f = 0);
00450
00454 virtual ~KDockWidget();
00455
00459 enum DockPosition
00460 {
00461 DockNone = 0,
00462 DockTop = 0x0001,
00463 DockLeft = 0x0002,
00464 DockRight = 0x0004,
00465 DockBottom = 0x0008,
00466 DockCenter = 0x0010,
00467 DockDesktop= 0x0020,
00468 DockToSpecialSites=0x0040,
00469 DockCorner = DockTop | DockLeft | DockRight | DockBottom,
00470 DockFullSite = DockCorner | DockCenter,
00471 DockFullDocking = DockFullSite | DockDesktop
00472 };
00473
00498 KDockWidget* manualDock( KDockWidget* target, DockPosition dockPos, int spliPos = 50, QPoint pos = QPoint(0,0), bool check = false, int tabIndex = -1);
00499
00505 void setEnableDocking( int pos );
00506
00510 int enableDocking() const { return eDocking; }
00511
00517 void setDockSite( int pos ){ sDocking = pos;}
00518
00522 int dockSite() const { return sDocking; }
00523
00531 void setWidget( QWidget* w);
00532
00538 QWidget* getWidget() const { return widget; }
00539
00548 void setHeader( KDockWidgetAbstractHeader* ah);
00549
00553 KDockWidgetAbstractHeader *getHeader();
00554
00560 void makeDockVisible();
00561
00571 bool mayBeHide() const;
00572
00580 bool mayBeShow() const;
00581
00585 KDockManager* dockManager() const { return manager; }
00586
00597 void setToolTipString(const QString& ttStr) { toolTipStr = ttStr; }
00598
00602 const QString& toolTipString() const { return toolTipStr; }
00603
00607 bool isDockBackPossible() const;
00608
00613 void setTabPageLabel( const QString& label) { tabPageTitle = label; }
00614
00618 const QString& tabPageLabel() const { return tabPageTitle; }
00619
00623 virtual bool event( QEvent * );
00624
00628 virtual void show();
00632 KDockTabGroup* parentDockTabGroup() const;
00633
00635 QWidget *parentDockContainer() const;
00636
00637 #ifndef NO_KDE2
00638
00644 void setDockWindowType (NET::WindowType windowType);
00645
00646 #endif
00647
00648 void setDockWindowTransient (QWidget *parent, bool transientEnabled);
00649
00654 QWidget *transientTo();
00655
00662 KDockWidget *findNearestDockWidget(DockPosition pos);
00663
00670 void setPixmap(const QPixmap& pixmap=QPixmap());
00671
00677 const QPixmap& pixmap() const;
00678
00683 KDockWidget::DockPosition currentDockPosition() const;
00684
00685 public slots:
00692 void setForcedFixedWidth(int);
00699 void setForcedFixedHeight(int);
00701 void restoreFromForcedFixedSize();
00702
00704 int forcedFixedWidth();
00706 int forcedFixedHeight();
00707
00712 void dockBack();
00713
00717 void changeHideShowState();
00718
00724 void undock();
00725
00730 void toDesktop( );
00731
00732 protected:
00733 friend class KMdiMainFrm;
00734 friend class KMDI::MainWindow;
00742 void updateHeader();
00743
00745 void setLatestKDockContainer(QWidget *);
00747 QWidget *latestKDockContainer();
00748
00750 void setFormerBrotherDockWidget(KDockWidget *);
00751
00752 signals:
00757 void widgetSet(QWidget*);
00758
00765 void docking( KDockWidget* dw, KDockWidget::DockPosition dp);
00766
00770 void setDockDefaultPos();
00771
00775 void headerCloseButtonClicked();
00776
00780 void headerDockbackButtonClicked();
00781
00785 void iMBeingClosed();
00789 void hasUndocked();
00790
00791 protected slots:
00792
00797 void loseFormerBrotherDockWidget();
00798
00799 virtual void paintEvent(QPaintEvent*);
00800
00801 virtual void mousePressEvent(QMouseEvent*);
00802 virtual void mouseReleaseEvent(QMouseEvent*);
00803 virtual void mouseMoveEvent(QMouseEvent*);
00804 virtual void leaveEvent(QEvent*);
00805 protected:
00806 friend class KDockWidgetHeader;
00810 KDockWidget* formerBrotherDockWidget;
00814 DockPosition currentDockPos;
00818 DockPosition formerDockPos;
00822 QString toolTipStr;
00826 QString tabPageTitle;
00827
00828 private:
00834 void setDockTabName( KDockTabGroup* g);
00835
00843 void applyToWidget( QWidget* s, const QPoint& p = QPoint(0,0) );
00844
00848 KDockWidgetAbstractHeader* header;
00849
00853 QWidget* widget;
00854
00858 QVBoxLayout* layout;
00859
00863 KDockManager* manager;
00864
00868 QPixmap* pix;
00869
00873 int eDocking;
00874
00878 int sDocking;
00879
00883 KDockWidget::DockPosition prevSideDockPosBeforeDrag;
00884
00885
00886 QString firstName;
00887 QString lastName;
00888 Orientation splitterOrientation;
00889 bool isGroup;
00890 bool isTabGroup;
00891 protected:
00892 virtual void virtual_hook( int id, void* data );
00893 private:
00894 KDockWidgetPrivate *d;
00895 };
00896
00909 class KDEUI_EXPORT KDockManager: public QObject
00910 {
00911 Q_OBJECT
00912 friend class KDockWidget;
00913 friend class KDockMainWindow;
00914
00915 public:
00916 enum EnReadDockConfigMode {
00917 Unknown,
00918 WrapExistingWidgetsOnly,
00919 RestoreAllDockwidgets
00920 };
00921
00922 public:
00933 KDockManager( QWidget* mainWindow, const char* name = 0L );
00934
00938 virtual ~KDockManager();
00939
00940 void dumpDockWidgets();
00941
00942 #ifndef NO_KDE2
00943
00952 void writeConfig( KConfig* c = 0L, QString group = QString::null );
00953
00970 void readConfig ( KConfig* c = 0L, QString group = QString::null );
00971 #endif
00972
00974 void setMainDockWidget2(KDockWidget *);
00975
00979 void writeConfig(QDomElement &base);
00983 void readConfig(QDomElement &base);
00984
00989 void activate();
00990
00999 virtual bool eventFilter( QObject * object, QEvent * event );
01000
01008 KDockWidget* findWidgetParentDock( QWidget* w) const;
01009
01015 void makeWidgetDockVisible( QWidget* w ){ findWidgetParentDock(w)->makeDockVisible(); }
01016
01020 QPopupMenu* dockHideShowMenu() const { return menu; }
01021
01026 KDockWidget* getDockWidgetFromName( const QString& dockName );
01027
01032 void setSplitterOpaqueResize(bool b=true);
01033
01037 bool splitterOpaqueResize() const;
01038
01044 void setSplitterKeepSize(bool b=true);
01045
01049 bool splitterKeepSize() const;
01050
01059 void setSplitterHighResolution(bool b=true);
01060
01064 bool splitterHighResolution() const;
01065
01069 void setSpecialLeftDockContainer(KDockWidget* container);
01070 void setSpecialTopDockContainer(KDockWidget* container);
01071 void setSpecialRightDockContainer(KDockWidget* container);
01072 void setSpecialBottomDockContainer(KDockWidget* container);
01073
01074 void removeFromAutoCreateList(KDockWidget* pDockWidget);
01075 void finishReadDockConfig();
01076 void setReadDockConfigMode(int mode);
01077
01078 signals:
01079
01083 void change();
01084
01088 void replaceDock( KDockWidget* oldDock, KDockWidget* newDock );
01089
01093 void setDockDefaultPos( KDockWidget* );
01094
01095 private slots:
01096
01100 void slotMenuPopup();
01101
01107 void slotMenuActivated( int id);
01108
01109
01110
01111
01112
01113 void drawDragRectangle();
01114
01115 private:
01116
01120 struct MenuDockData
01121 {
01122 MenuDockData( KDockWidget* _dock, bool _hide )
01123 {
01124 dock = _dock;
01125 hide = _hide;
01126 }
01127 ~MenuDockData(){}
01128
01129 KDockWidget* dock;
01130 bool hide;
01131 };
01132
01139 KDockWidget* findDockWidgetAt( const QPoint& pos );
01140
01148 void findChildDockWidget( QWidget*& w, const QWidget* p, const QPoint& pos );
01149
01156 void findChildDockWidget( const QWidget* p, QWidgetList*& l);
01157
01161 void startDrag( KDockWidget* );
01162
01169 void dragMove( KDockWidget* d, QPoint pos );
01170
01174 void cancelDrop();
01175
01180 void drop();
01181
01182
01183
01187 QWidget* main;
01188
01192 KDockWidget* currentDragWidget;
01193
01197 KDockWidget* currentMoveWidget;
01198
01202 QWidgetList* childDockWidgetList;
01203
01207 KDockWidget::DockPosition curPos;
01208
01213 QObjectList* childDock;
01214
01218 QObjectList* autoCreateDock;
01219
01223 int storeW;
01224
01228 int storeH;
01229
01233 bool dragging;
01234
01238 bool undockProcess;
01239
01244 bool dropCancel;
01245
01250 QPopupMenu* menu;
01251
01255 QPtrList<MenuDockData> *menuData;
01256
01257 protected:
01258 virtual void virtual_hook( int id, void* data );
01259 private:
01260 class KDockManagerPrivate;
01261 KDockManagerPrivate *d;
01262 };
01263
01307 class KDEUI_EXPORT KDockMainWindow : public KMainWindow
01308 {
01309 Q_OBJECT
01310
01311 friend class KDockManager;
01312
01313 public:
01314
01327 KDockMainWindow( QWidget* parent = 0L, const char *name = 0L, WFlags f = WType_TopLevel | WDestructiveClose );
01328
01332 virtual ~KDockMainWindow();
01333
01338 KDockManager* manager() const { return dockManager; }
01339
01346 void setMainDockWidget( KDockWidget* dockwidget);
01347
01353 KDockWidget* getMainDockWidget() const { return mainDockWidget; }
01354
01367 KDockWidget* createDockWidget( const QString& name, const QPixmap &pixmap, QWidget* parent = 0L,
01368 const QString& strCaption = QString::null, const QString& strTabPageLabel = QString::fromLatin1( " " ) );
01369
01373 void writeDockConfig(QDomElement &base);
01377 void readDockConfig(QDomElement &base);
01378
01379 #ifndef NO_KDE2
01380
01386 void writeDockConfig( KConfig* c = 0L, QString group = QString::null );
01387
01394 void readDockConfig ( KConfig* c = 0L, QString group = QString::null );
01395 #endif
01396
01402 void activateDock(){ dockManager->activate(); }
01403
01410 QPopupMenu* dockHideShowMenu() const { return dockManager->dockHideShowMenu(); }
01411
01419 void makeDockVisible( KDockWidget* dock );
01420
01426 void makeDockInvisible( KDockWidget* dock );
01427
01432 void makeWidgetDockVisible( QWidget* widget );
01433
01440 void setView( QWidget * widget );
01441
01442 signals:
01446 void dockWidgetHasUndocked(KDockWidget*);
01447
01448 protected:
01449
01453 KDockWidget* mainDockWidget;
01454
01458 KDockManager* dockManager;
01459
01460 protected slots:
01464 void slotDockWidgetUndocked();
01465
01466 protected:
01467 virtual void virtual_hook( int id, void* data );
01468 private:
01469 class KDockMainWindowPrivate;
01470 KDockMainWindowPrivate *d;
01471 };
01472
01473 class KDEUI_EXPORT KDockArea : public QWidget
01474 {
01475 Q_OBJECT
01476
01477 friend class KDockManager;
01478
01479 public:
01480
01481
01482 KDockArea( QWidget* parent = 0L, const char *name = 0L);
01483
01484 virtual ~KDockArea();
01485
01486 KDockManager* manager(){ return dockManager; }
01487
01488
01489 void setMainDockWidget( KDockWidget* );
01490 KDockWidget* getMainDockWidget(){ return mainDockWidget; }
01491
01492 KDockWidget* createDockWidget( const QString& name, const QPixmap &pixmap, QWidget* parent = 0L,
01493 const QString& strCaption = QString::null, const QString& strTabPageLabel = QString::fromLatin1( " " ) );
01494
01495 void writeDockConfig(QDomElement &base);
01496 void readDockConfig(QDomElement &base);
01497
01498 #ifndef NO_KDE2
01499 void writeDockConfig( KConfig* c = 0L, QString group = QString::null );
01500 void readDockConfig ( KConfig* c = 0L, QString group = QString::null );
01501 #endif
01502
01503
01504
01505 void activateDock(){ dockManager->activate(); }
01506 QPopupMenu* dockHideShowMenu(){ return dockManager->dockHideShowMenu(); }
01507 void makeDockVisible( KDockWidget* dock );
01508 void makeDockInvisible( KDockWidget* dock );
01509 void makeWidgetDockVisible( QWidget* widget );
01510
01511
01512 signals:
01516 void dockWidgetHasUndocked(KDockWidget*);
01517
01518 protected:
01519
01520 KDockWidget* mainDockWidget;
01521 KDockManager* dockManager;
01522
01523 protected slots:
01524 void slotDockWidgetUndocked();
01525
01526 public:
01527 virtual void resizeEvent(QResizeEvent *);
01528
01529 protected:
01530 virtual void virtual_hook( int id, void* data );
01531 private:
01532 class KDockMainWindowPrivate;
01533 KDockMainWindowPrivate *d;
01534 };
01535
01536
01537 #endif
01538
01539