kdockwidget.h Source File (kdeui Library)

| # kdeui Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kdockwidget.h

    00001 /* This file is part of the KDE libraries
    00002    Copyright (C) 2000 Max Judin <novaprint@mtu-net.ru>
    00003    Copyright (C) 2000 Falk Brettschneider <falk@kdevelop.org>
    00004
    00005    This library is free software; you can redistribute it and/or
    00006    modify it under the terms of the GNU Library General Public
    00007    License version 2 as published by the Free Software Foundation.
    00008
    00009    This library is distributed in the hope that it will be useful,
    00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00012    Library General Public License for more details.
    00013
    00014    You should have received a copy of the GNU Library General Public License
    00015    along with this library; see the file COPYING.LIB.  If not, write to
    00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00017    Boston, MA 02111-1307, USA.
    00018 */
    00019
    00020 /*
    00021    activities:
    00022    -----------
    00023    05/2001 -               : useful patches, bugfixes by Christoph Cullmann <crossfire@babylon2k.de>,
    00024                              Joseph Wenninger <jowenn@bigfoot.com> and  Falk Brettschneider
    00025    03/2001 - 05/2001       : maintained and enhanced by Falk Brettschneider <falk@kdevelop.org>
    00026    03/2000                 : class documentation added by Falk Brettschneider <gigafalk@yahoo.com>
    00027    10/1999 - 03/2000       : programmed by Max Judin <novaprint@mtu-net.ru>
    00028
    00029    C++ classes in this file:
    00030    -------------------------
    00031    - KDockWidgetAbstractHeader     - minor helper class
    00032    - KDockWidgetAbstractHeaderDrag - minor helper class
    00033    - KDockWidgetHeaderDrag         - drag panel in a dockwidget title bar
    00034    - KDockWidgetHeader             - dockwidget title bar containing the drag panel
    00035    - KDockTabGroup                 - minor helper class
    00036    - KDockWidget                   - IMPORTANT CLASS: the one and only dockwidget class
    00037    - KDockManager                  - helper class
    00038    - KDockMainWindow               - IMPORTANT CLASS: a special KMainWindow that can have dockwidgets
    00039    - KDockArea                     - like KDockMainWindow but inherits just QWidget
    00040
    00041    IMPORTANT Note: This file compiles also in Qt-only mode by using the NO_KDE2 precompiler definition!
    00042 */
    00043
    00044
    00045 #ifndef KDOCKWIDGET_H
    00046 #define KDOCKWIDGET_H
    00047
    00048 #define _KDOCKWIDGET_2_2_
    00049
    00050 #include <qpoint.h>
    00051 #include <qptrlist.h>
    00052 #include <qframe.h>
    00053 #include <qdom.h>
    00054 #include <qtabwidget.h>
    00055
    00056 #ifndef NO_KDE2
    00057 #include <kmainwindow.h>
    00058 #include <netwm_def.h>
    00059 #undef  EXPORT_DOCKCLASS
    00060 #define EXPORT_DOCKCLASS
    00061 #else
    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
    00098 class KDockWidgetAbstractHeader : public QFrame
    00099 {
    00100   Q_OBJECT
    00101 public:
    00102
    00109   KDockWidgetAbstractHeader( KDockWidget* parent, const char* name = 0L );
    00110
    00114   virtual ~KDockWidgetAbstractHeader(){};
    00115
    00119   virtual void setTopLevel( bool ){};
    00120
    00121 #ifndef NO_KDE2
    00122
    00125   virtual void saveConfig( KConfig* ){};
    00126
    00130   virtual void loadConfig( KConfig* ){};
    00131 #endif
    00132
    00133 protected:
    00134   virtual void virtual_hook( int id, void* data );
    00135 private:
    00136   class KDockWidgetAbstractHeaderPrivate;
    00137   KDockWidgetAbstractHeaderPrivate *d;
    00138 };
    00139
    00147 class KDockWidgetAbstractHeaderDrag : public QFrame
    00148 {
    00149   Q_OBJECT
    00150 public:
    00151
    00159   KDockWidgetAbstractHeaderDrag( KDockWidgetAbstractHeader* parent,
    00160                                  KDockWidget* dock, const char* name = 0L );
    00161
    00165   virtual ~KDockWidgetAbstractHeaderDrag(){};
    00166
    00170   KDockWidget* dockWidget() const { return dw; }
    00171
    00172 private:
    00176   KDockWidget* dw;
    00177 protected:
    00178   virtual void virtual_hook( int id, void* data );
    00179 private:
    00180   class KDockWidgetAbstractHeaderDragPrivate;
    00181   KDockWidgetAbstractHeaderDragPrivate *d;
    00182 };
    00183
    00192 class KDockWidgetHeaderDrag : public KDockWidgetAbstractHeaderDrag
    00193 {
    00194   Q_OBJECT
    00195 public:
    00196
    00204   KDockWidgetHeaderDrag( KDockWidgetAbstractHeader* parent, KDockWidget* dock,
    00205                          const char* name = 0L );
    00206
    00210   virtual ~KDockWidgetHeaderDrag(){};
    00211
    00212 protected:
    00213
    00217   virtual void paintEvent( QPaintEvent* );
    00218
    00219 protected:
    00220   virtual void virtual_hook( int id, void* data );
    00221 private:
    00222   class KDockWidgetHeaderDragPrivate;
    00223   KDockWidgetHeaderDragPrivate *d;
    00224 };
    00225
    00233 class KDockWidgetHeader : public KDockWidgetAbstractHeader
    00234 {
    00235   Q_OBJECT
    00236 public:
    00237
    00244   KDockWidgetHeader( KDockWidget* parent, const char* name = 0L );
    00245
    00249   virtual ~KDockWidgetHeader(){};
    00250
    00256   virtual void setTopLevel( bool t);
    00257
    00263   void setDragPanel( KDockWidgetHeaderDrag* nd );
    00264
    00265   bool dragEnabled() const;
    00266   void setDragEnabled(bool b);
    00268   void showUndockButton(bool show);
    00269
    00270 #ifndef NO_KDE2
    00271
    00276   virtual void saveConfig( KConfig* c);
    00277
    00283   virtual void loadConfig( KConfig* );
    00284 #endif
    00285
    00286 protected slots:
    00290   void slotStayClicked();
    00291
    00292 protected:
    00293
    00297   QHBoxLayout* layout;
    00298
    00302   KDockButton_Private* closeButton;
    00303
    00307   KDockButton_Private* stayButton;
    00308
    00312   KDockButton_Private* dockbackButton;
    00313
    00317   KDockWidgetHeaderDrag* drag;
    00318
    00319 protected:
    00320   virtual void virtual_hook( int id, void* data );
    00321 private:
    00322   KDockWidgetHeaderPrivate *d;
    00323 };
    00324
    00333 class EXPORT_DOCKCLASS KDockTabGroup : public QTabWidget
    00334 {
    00335   Q_OBJECT
    00336 public:
    00340   KDockTabGroup( QWidget *parent = 0, const char *name = 0 )
    00341   :QTabWidget( parent, name ){};
    00342
    00346   virtual ~KDockTabGroup(){};
    00347
    00348 protected:
    00349   virtual void virtual_hook( int id, void* data );
    00350 private:
    00351   class KDockTabGroupPrivate;
    00352   KDockTabGroupPrivate *d;
    00353 };
    00354
    00355
    00392 class EXPORT_DOCKCLASS KDockWidget: public QWidget
    00393 {
    00394   Q_OBJECT
    00395 friend class KDockManager;
    00396 friend class KDockSplitter;
    00397 friend class KDockMainWindow;
    00398 friend class KDockArea;
    00399
    00400 public:
    00415   KDockWidget( KDockManager* dockManager, const char* name,
    00416                const QPixmap &pixmap, QWidget* parent = 0L, const QString& strCaption = QString::null,
    00417                const QString& strTabPageLabel = QString::fromLatin1( " " ), WFlags f = 0);
    00418
    00422   virtual ~KDockWidget();
    00423
    00427   enum DockPosition
    00428   {
    00429     DockNone   = 0,
    00430     DockTop    = 0x0001,
    00431     DockLeft   = 0x0002,
    00432     DockRight  = 0x0004,
    00433     DockBottom = 0x0008,
    00434     DockCenter = 0x0010,
    00435     DockDesktop= 0x0020,
    00436     DockToSpecialSites=0x0040,
    00437     DockCorner = DockTop | DockLeft | DockRight | DockBottom,
    00438     DockFullSite = DockCorner | DockCenter,
    00439     DockFullDocking = DockFullSite | DockDesktop
    00440   };
    00441
    00461   KDockWidget* manualDock( KDockWidget* target, DockPosition dockPos, int spliPos = 50, QPoint pos = QPoint(0,0), bool check = false, int tabIndex = -1);
    00462
    00468   void setEnableDocking( int pos );
    00469
    00473   int enableDocking() const { return eDocking; }
    00474
    00480   void setDockSite( int pos ){ sDocking = pos;}
    00481
    00485   int dockSite() const { return sDocking; }
    00486
    00494   void setWidget( QWidget* w);
    00495
    00501   QWidget* getWidget() const { return widget; };
    00502
    00511   void setHeader( KDockWidgetAbstractHeader* ah);
    00512
    00518   void makeDockVisible();
    00519
    00529   bool mayBeHide() const;
    00530
    00538   bool mayBeShow() const;
    00539
    00543   KDockManager* dockManager() const { return manager; }
    00544
    00555   void setToolTipString(const QString& ttStr) { toolTipStr = ttStr; };
    00556
    00560   const QString& toolTipString() const { return toolTipStr; };
    00561
    00565   bool isDockBackPossible() const;
    00566
    00571   void setTabPageLabel( const QString& label) { tabPageTitle = label; };
    00572
    00576   const QString& tabPageLabel() const { return tabPageTitle; };
    00577
    00581   virtual bool event( QEvent * );
    00582
    00586   virtual void show();
    00590   KDockTabGroup* parentDockTabGroup() const;
    00591
    00593   QWidget *parentDockContainer() const;
    00594
    00595 #ifndef NO_KDE2
    00596
    00602   void setDockWindowType (NET::WindowType windowType);
    00603
    00604 #endif
    00605
    00611   void setDockWindowTransient (QWidget *parent, bool transientEnabled);
    00612
    00619   KDockWidget *findNearestDockWidget(DockPosition pos);
    00620
    00621 public slots:
    00628   void setForcedFixedWidth(int);
    00635   void setForcedFixedHeight(int);
    00637   void restoreFromForcedFixedSize();
    00638
    00640   int forcedFixedWidth();
    00642   int forcedFixedHeight();
    00643
    00648   void dockBack();
    00649
    00653   void changeHideShowState();
    00654
    00660   void undock();
    00661
    00666   void toDesktop( );
    00667
    00668 protected:
    00669
    00677   void updateHeader();
    00678
    00680   void setLatestKDockContainer(QWidget *);
    00682   QWidget *latestKDockContainer();
    00683
    00684 signals:
    00691   void docking( KDockWidget* dw, KDockWidget::DockPosition dp);
    00692
    00696   void setDockDefaultPos();
    00697
    00701   void headerCloseButtonClicked();
    00702
    00706   void headerDockbackButtonClicked();
    00707
    00711   void iMBeingClosed();
    00715   void hasUndocked();
    00716
    00717 protected slots:
    00718
    00723   void loseFormerBrotherDockWidget();
    00724
    00725   virtual void paintEvent(QPaintEvent*);
    00726
    00727   virtual void mousePressEvent(QMouseEvent*);
    00728   virtual void mouseReleaseEvent(QMouseEvent*);
    00729   virtual void mouseMoveEvent(QMouseEvent*);
    00730   virtual void leaveEvent(QEvent*);
    00731 protected:
    00735   KDockWidget* formerBrotherDockWidget;
    00739   DockPosition currentDockPos;
    00743   DockPosition formerDockPos;
    00747   QString toolTipStr;
    00751   QString tabPageTitle;
    00752
    00753 private:
    00759   void setDockTabName( KDockTabGroup* g);
    00760
    00768   void applyToWidget( QWidget* s, const QPoint& p  = QPoint(0,0) );
    00769
    00773   KDockWidgetAbstractHeader* header;
    00774
    00778   QWidget* widget;
    00779
    00783   QVBoxLayout* layout;
    00784
    00788   KDockManager* manager;
    00789
    00793   QPixmap* pix;
    00794
    00798   int eDocking;
    00799
    00803   int sDocking;
    00804
    00808   KDockWidget::DockPosition prevSideDockPosBeforeDrag;
    00809
    00810   // GROUP data
    00811   QString firstName;
    00812   QString lastName;
    00813   Orientation splitterOrientation;
    00814   bool isGroup;
    00815   bool isTabGroup;
    00816 protected:
    00817   virtual void virtual_hook( int id, void* data );
    00818 private:
    00819   KDockWidgetPrivate *d;
    00820 };
    00821
    00834 class EXPORT_DOCKCLASS KDockManager: public QObject
    00835 {
    00836   Q_OBJECT
    00837 friend class KDockWidget;
    00838 friend class KDockMainWindow;
    00839
    00840 public:
    00851   KDockManager( QWidget* mainWindow, const char* name = 0L );
    00852
    00856   virtual ~KDockManager();
    00857
    00858 #ifndef NO_KDE2
    00859
    00868   void writeConfig( KConfig* c = 0L, QString group = QString::null );
    00869
    00886   void readConfig ( KConfig* c = 0L, QString group = QString::null );
    00887 #endif
    00888
    00890   void setMainDockWidget2(KDockWidget *);
    00891
    00895   void writeConfig(QDomElement &base);
    00899   void readConfig(QDomElement &base);
    00900
    00905   void activate();
    00906
    00915   virtual bool eventFilter( QObject *, QEvent * );
    00916
    00924   KDockWidget* findWidgetParentDock( QWidget* w) const;
    00925
    00931   void makeWidgetDockVisible( QWidget* w ){ findWidgetParentDock(w)->makeDockVisible(); }
    00932
    00936   QPopupMenu* dockHideShowMenu() const { return menu; }
    00937
    00942   KDockWidget* getDockWidgetFromName( const QString& dockName );
    00943
    00948   void setSplitterOpaqueResize(bool b=true);
    00949
    00953   bool splitterOpaqueResize() const;
    00954
    00960   void setSplitterKeepSize(bool b=true);
    00961
    00965   bool splitterKeepSize() const;
    00966
    00973   void setSplitterHighResolution(bool b=true);
    00974
    00978   bool splitterHighResolution() const;
    00979
    00980 signals:
    00981
    00985   void change();
    00986
    00990   void replaceDock( KDockWidget* oldDock, KDockWidget* newDock );
    00991
    00995   void setDockDefaultPos( KDockWidget* );
    00996
    00997 private slots:
    00998
    01002   void slotMenuPopup();
    01003
    01009   void slotMenuActivated( int id);
    01010
    01011   /* clears the old drawn drag rectangle (oldDragRect) from screen and
    01012    * draws the new current drag rectangle (dragRect) depending on the current mouse position.
    01013    * This highlights the dockwidget which is the currently chosen target during a dock action.
    01014    */
    01015   void drawDragRectangle();
    01016
    01017 private:
    01018
    01022   struct MenuDockData
    01023   {
    01024     MenuDockData( KDockWidget* _dock, bool _hide )
    01025     {
    01026       dock = _dock;
    01027       hide = _hide;
    01028     };
    01029     ~MenuDockData(){};
    01030
    01031     KDockWidget* dock;
    01032     bool hide;
    01033   };
    01034
    01041   KDockWidget* findDockWidgetAt( const QPoint& pos );
    01042
    01050   void findChildDockWidget( QWidget*& w, const QWidget* p, const QPoint& pos );
    01051
    01058   void findChildDockWidget( const QWidget* p, QWidgetList*& l);
    01059
    01063   void startDrag( KDockWidget* );
    01064
    01071   void dragMove( KDockWidget* d, QPoint pos );
    01072
    01076   void cancelDrop();
    01077
    01082   void drop();
    01083
    01084 // class members
    01085
    01089   QWidget* main;
    01090
    01094   KDockWidget* currentDragWidget;
    01095
    01099   KDockWidget* currentMoveWidget; // widget where mouse moving
    01100
    01104   QWidgetList* childDockWidgetList;
    01105
    01109   KDockWidget::DockPosition curPos;
    01110
    01115   QObjectList* childDock;
    01116
    01120   QObjectList* autoCreateDock;
    01121
    01125   int storeW;
    01126
    01130   int storeH;
    01131
    01135   bool draging;
    01136
    01140   bool undockProcess;
    01141
    01146   bool dropCancel;
    01147
    01152   QPopupMenu* menu;
    01153
    01157   QPtrList<MenuDockData> *menuData;
    01158
    01159 protected:
    01160   virtual void virtual_hook( int id, void* data );
    01161 private:
    01162   class KDockManagerPrivate;
    01163   KDockManagerPrivate *d;
    01164 };
    01165
    01209 class EXPORT_DOCKCLASS KDockMainWindow : public KMainWindow
    01210 {
    01211   Q_OBJECT
    01212
    01213 friend class KDockManager;
    01214
    01215 public:
    01216
    01227   KDockMainWindow( QWidget* parent = 0L, const char *name = 0L, WFlags f = WType_TopLevel | WDestructiveClose );
    01228
    01232   virtual ~KDockMainWindow();
    01233
    01238   KDockManager* manager() const { return dockManager; }
    01239
    01246   void setMainDockWidget( KDockWidget* );
    01247
    01253   KDockWidget* getMainDockWidget() const { return mainDockWidget; }
    01254
    01267   KDockWidget* createDockWidget( const QString& name, const QPixmap &pixmap, QWidget* parent = 0L,
    01268     const QString& strCaption = QString::null, const QString& strTabPageLabel = QString::fromLatin1( " " ) );
    01269
    01273   void writeDockConfig(QDomElement &base);
    01277   void readDockConfig(QDomElement &base);
    01278
    01279 #ifndef NO_KDE2
    01280
    01286   void writeDockConfig( KConfig* c = 0L, QString group = QString::null );
    01287
    01294   void readDockConfig ( KConfig* c = 0L, QString group = QString::null );
    01295 #endif
    01296
    01302   void activateDock(){ dockManager->activate(); }
    01303
    01310   QPopupMenu* dockHideShowMenu() const { return dockManager->dockHideShowMenu(); }
    01311
    01319   void makeDockVisible( KDockWidget* dock );
    01320
    01326   void makeDockInvisible( KDockWidget* dock );
    01327
    01332   void makeWidgetDockVisible( QWidget* widget );
    01333
    01340   void setView( QWidget* );
    01341
    01342 signals:
    01346   void dockWidgetHasUndocked(KDockWidget*);
    01347
    01348 protected:
    01349
    01353   KDockWidget* mainDockWidget;
    01354
    01358   KDockManager* dockManager;
    01359
    01360 protected slots:
    01364   void slotDockWidgetUndocked();
    01365
    01366 protected:
    01367   virtual void virtual_hook( int id, void* data );
    01368 private:
    01369   class KDockMainWindowPrivate;
    01370   KDockMainWindowPrivate *d;
    01371 };
    01372
    01373
    01374
    01375
    01376
    01377
    01378
    01379
    01380
    01381
    01382
    01383
    01384
    01385
    01386
    01387
    01388 class EXPORT_DOCKCLASS KDockArea : public QWidget
    01389 {
    01390   Q_OBJECT
    01391
    01392 friend class KDockManager;
    01393
    01394 public:
    01395
    01396
    01397   KDockArea( QWidget* parent = 0L, const char *name = 0L);
    01398
    01399   virtual ~KDockArea();
    01400
    01401   KDockManager* manager(){ return dockManager; }
    01402
    01403
    01404   void setMainDockWidget( KDockWidget* );
    01405   KDockWidget* getMainDockWidget(){ return mainDockWidget; }
    01406
    01407   KDockWidget* createDockWidget( const QString& name, const QPixmap &pixmap, QWidget* parent = 0L,
    01408     const QString& strCaption = QString::null, const QString& strTabPageLabel = QString::fromLatin1( " " ) );
    01409
    01410   void writeDockConfig(QDomElement &base);
    01411   void readDockConfig(QDomElement &base);
    01412
    01413 #ifndef NO_KDE2
    01414   void writeDockConfig( KConfig* c = 0L, QString group = QString::null );
    01415   void readDockConfig ( KConfig* c = 0L, QString group = QString::null );
    01416 #endif
    01417
    01418
    01419
    01420   void activateDock(){ dockManager->activate(); }
    01421   QPopupMenu* dockHideShowMenu(){ return dockManager->dockHideShowMenu(); }
    01422   void makeDockVisible( KDockWidget* dock );
    01423   void makeDockInvisible( KDockWidget* dock );
    01424   void makeWidgetDockVisible( QWidget* widget );
    01425   //void setView( QWidget* );
    01426
    01427 signals:
    01431   void dockWidgetHasUndocked(KDockWidget*);
    01432
    01433 protected:
    01434
    01435   KDockWidget* mainDockWidget;
    01436   KDockManager* dockManager;
    01437
    01438 protected slots:
    01439   void slotDockWidgetUndocked();
    01440
    01441 public:
    01442         virtual void resizeEvent(QResizeEvent *);
    01443
    01444 protected:
    01445   virtual void virtual_hook( int id, void* data );
    01446 private:
    01447   class KDockMainWindowPrivate;
    01448   KDockMainWindowPrivate *d;
    01449 };
    01450
    01451
    01452 #endif
    01453
    01454

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:56:38 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001