| 1 | /**************************************************************************** | 
|---|
| 2 | ** $Id: qdockwindow.h 2 2005-11-16 15:49:26Z dmik $ | 
|---|
| 3 | ** | 
|---|
| 4 | ** Definition of the QDockWindow class | 
|---|
| 5 | ** | 
|---|
| 6 | ** Created : 001010 | 
|---|
| 7 | ** | 
|---|
| 8 | ** Copyright (C) 1992-2002 Trolltech AS.  All rights reserved. | 
|---|
| 9 | ** | 
|---|
| 10 | ** This file is part of the workspace module of the Qt GUI Toolkit. | 
|---|
| 11 | ** | 
|---|
| 12 | ** This file may be distributed under the terms of the Q Public License | 
|---|
| 13 | ** as defined by Trolltech AS of Norway and appearing in the file | 
|---|
| 14 | ** LICENSE.QPL included in the packaging of this file. | 
|---|
| 15 | ** | 
|---|
| 16 | ** This file may be distributed and/or modified under the terms of the | 
|---|
| 17 | ** GNU General Public License version 2 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 19 | ** packaging of this file. | 
|---|
| 20 | ** | 
|---|
| 21 | ** Licensees holding valid Qt Enterprise Edition licenses may use this | 
|---|
| 22 | ** file in accordance with the Qt Commercial License Agreement provided | 
|---|
| 23 | ** with the Software. | 
|---|
| 24 | ** | 
|---|
| 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 
|---|
| 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 
|---|
| 27 | ** | 
|---|
| 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 
|---|
| 29 | **   information about Qt Commercial License Agreements. | 
|---|
| 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 
|---|
| 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 
|---|
| 32 | ** | 
|---|
| 33 | ** Contact info@trolltech.com if any conditions of this licensing are | 
|---|
| 34 | ** not clear to you. | 
|---|
| 35 | ** | 
|---|
| 36 | **********************************************************************/ | 
|---|
| 37 |  | 
|---|
| 38 | #ifndef QDOCKWINDOW_H | 
|---|
| 39 | #define QDOCKWINDOW_H | 
|---|
| 40 |  | 
|---|
| 41 | #ifndef QT_H | 
|---|
| 42 | #include "qframe.h" | 
|---|
| 43 | #endif // QT_H | 
|---|
| 44 |  | 
|---|
| 45 | #ifndef QT_NO_MAINWINDOW | 
|---|
| 46 |  | 
|---|
| 47 | class QDockWindowHandle; | 
|---|
| 48 | class QDockWindowTitleBar; | 
|---|
| 49 | class QPainter; | 
|---|
| 50 | class QDockWindowResizeHandle; | 
|---|
| 51 | class QBoxLayout; | 
|---|
| 52 | class QHBoxLayout; | 
|---|
| 53 | class QVBoxLayout; | 
|---|
| 54 | class QDockArea; | 
|---|
| 55 | class QWidgetResizeHandler; | 
|---|
| 56 | class QMainWindow; | 
|---|
| 57 | class QDockAreaLayout; | 
|---|
| 58 | class QDockWindowPrivate; | 
|---|
| 59 | class QToolBar; | 
|---|
| 60 | class QWindowsXPStyle; | 
|---|
| 61 |  | 
|---|
| 62 | class Q_EXPORT QDockWindow : public QFrame | 
|---|
| 63 | { | 
|---|
| 64 | Q_OBJECT | 
|---|
| 65 | Q_ENUMS( CloseMode Place ) | 
|---|
| 66 | Q_PROPERTY( int closeMode READ closeMode  WRITE setCloseMode ) //### this shouldn't be of type int?! | 
|---|
| 67 | Q_PROPERTY( bool resizeEnabled READ isResizeEnabled  WRITE setResizeEnabled ) | 
|---|
| 68 | Q_PROPERTY( bool movingEnabled READ isMovingEnabled  WRITE setMovingEnabled ) | 
|---|
| 69 | Q_PROPERTY( bool horizontallyStretchable READ isHorizontallyStretchable  WRITE setHorizontallyStretchable ) | 
|---|
| 70 | Q_PROPERTY( bool verticallyStretchable READ isVerticallyStretchable  WRITE setVerticallyStretchable ) | 
|---|
| 71 | Q_PROPERTY( bool stretchable READ isStretchable ) | 
|---|
| 72 | Q_PROPERTY( bool newLine READ newLine  WRITE setNewLine ) | 
|---|
| 73 | Q_PROPERTY( bool opaqueMoving READ opaqueMoving  WRITE setOpaqueMoving ) | 
|---|
| 74 | Q_PROPERTY( int offset READ offset  WRITE setOffset ) | 
|---|
| 75 | Q_PROPERTY( Place place READ place ) | 
|---|
| 76 |  | 
|---|
| 77 | friend class QDockWindowHandle; | 
|---|
| 78 | friend class QDockWindowTitleBar; | 
|---|
| 79 | friend class QDockArea; | 
|---|
| 80 | friend class QDockAreaLayout; | 
|---|
| 81 | friend class QMainWindow; | 
|---|
| 82 | friend class QCEMainWindow; | 
|---|
| 83 | friend class QToolBar; | 
|---|
| 84 | friend class QWindowsXPStyle; | 
|---|
| 85 |  | 
|---|
| 86 | public: | 
|---|
| 87 | enum Place { InDock, OutsideDock }; | 
|---|
| 88 | enum CloseMode { Never = 0, Docked = 1, Undocked = 2, Always = Docked | Undocked }; | 
|---|
| 89 |  | 
|---|
| 90 | QDockWindow( Place p = InDock, QWidget* parent=0, const char* name=0, WFlags f = 0 ); | 
|---|
| 91 | QDockWindow( QWidget* parent, const char* name=0, WFlags f = 0 ); | 
|---|
| 92 | ~QDockWindow(); | 
|---|
| 93 |  | 
|---|
| 94 | virtual void setWidget( QWidget *w ); | 
|---|
| 95 | QWidget *widget() const; | 
|---|
| 96 |  | 
|---|
| 97 | Place place() const { return curPlace; } | 
|---|
| 98 |  | 
|---|
| 99 | QDockArea *area() const; | 
|---|
| 100 |  | 
|---|
| 101 | virtual void setCloseMode( int m ); | 
|---|
| 102 | bool isCloseEnabled() const; | 
|---|
| 103 | int closeMode() const; | 
|---|
| 104 |  | 
|---|
| 105 | virtual void setResizeEnabled( bool b ); | 
|---|
| 106 | virtual void setMovingEnabled( bool b ); | 
|---|
| 107 | bool isResizeEnabled() const; | 
|---|
| 108 | bool isMovingEnabled() const; | 
|---|
| 109 |  | 
|---|
| 110 | virtual void setHorizontallyStretchable( bool b ); | 
|---|
| 111 | virtual void setVerticallyStretchable( bool b ); | 
|---|
| 112 | bool isHorizontallyStretchable() const; | 
|---|
| 113 | bool isVerticallyStretchable() const; | 
|---|
| 114 | void setHorizontalStretchable( bool b ) { setHorizontallyStretchable( b ); } | 
|---|
| 115 | void setVerticalStretchable( bool b ) { setVerticallyStretchable( b ); } | 
|---|
| 116 | bool isHorizontalStretchable() const { return isHorizontallyStretchable(); } | 
|---|
| 117 | bool isVerticalStretchable() const { return isVerticallyStretchable(); } | 
|---|
| 118 | bool isStretchable() const; | 
|---|
| 119 |  | 
|---|
| 120 | virtual void setOffset( int o ); | 
|---|
| 121 | int offset() const; | 
|---|
| 122 |  | 
|---|
| 123 | virtual void setFixedExtentWidth( int w ); | 
|---|
| 124 | virtual void setFixedExtentHeight( int h ); | 
|---|
| 125 | QSize fixedExtent() const; | 
|---|
| 126 |  | 
|---|
| 127 | virtual void setNewLine( bool b ); | 
|---|
| 128 | bool newLine() const; | 
|---|
| 129 |  | 
|---|
| 130 | Qt::Orientation orientation() const; | 
|---|
| 131 |  | 
|---|
| 132 | QSize sizeHint() const; | 
|---|
| 133 | QSize minimumSize() const; | 
|---|
| 134 | QSize minimumSizeHint() const; | 
|---|
| 135 |  | 
|---|
| 136 | QBoxLayout *boxLayout(); | 
|---|
| 137 |  | 
|---|
| 138 | virtual void setOpaqueMoving( bool b ); | 
|---|
| 139 | bool opaqueMoving() const; | 
|---|
| 140 |  | 
|---|
| 141 | bool eventFilter( QObject *o, QEvent *e ); | 
|---|
| 142 |  | 
|---|
| 143 | #ifdef QT_NO_WIDGET_TOPEXTRA | 
|---|
| 144 | QString caption() const; | 
|---|
| 145 | #endif | 
|---|
| 146 |  | 
|---|
| 147 | signals: | 
|---|
| 148 | void orientationChanged( Orientation o ); | 
|---|
| 149 | void placeChanged( QDockWindow::Place p ); | 
|---|
| 150 | void visibilityChanged( bool ); | 
|---|
| 151 |  | 
|---|
| 152 | public slots: | 
|---|
| 153 | virtual void undock( QWidget *w ); | 
|---|
| 154 | virtual void undock() { undock( 0 ); } | 
|---|
| 155 | virtual void dock(); | 
|---|
| 156 | virtual void setOrientation( Orientation o ); | 
|---|
| 157 | void setCaption( const QString &s ); | 
|---|
| 158 |  | 
|---|
| 159 | protected: | 
|---|
| 160 | void resizeEvent( QResizeEvent *e ); | 
|---|
| 161 | void showEvent( QShowEvent *e ); | 
|---|
| 162 | void hideEvent( QHideEvent *e ); | 
|---|
| 163 | void contextMenuEvent( QContextMenuEvent *e ); | 
|---|
| 164 |  | 
|---|
| 165 | void drawFrame( QPainter * ); | 
|---|
| 166 | void drawContents( QPainter * ); | 
|---|
| 167 |  | 
|---|
| 168 | bool event( QEvent *e ); | 
|---|
| 169 |  | 
|---|
| 170 | private slots: | 
|---|
| 171 | void toggleVisible() { if ( !isVisible() ) show(); else hide(); } | 
|---|
| 172 |  | 
|---|
| 173 | private: | 
|---|
| 174 | QDockWindow( Place p, QWidget* parent, const char* name, WFlags f, bool toolbar ); | 
|---|
| 175 |  | 
|---|
| 176 | void handleMove( const QPoint &pos, const QPoint &gp, bool drawRect ); | 
|---|
| 177 | void updateGui(); | 
|---|
| 178 | void updateSplitterVisibility( bool visible ); | 
|---|
| 179 |  | 
|---|
| 180 | void startRectDraw( const QPoint &so, bool drawRect ); | 
|---|
| 181 | void endRectDraw( bool drawRect ); | 
|---|
| 182 | void updatePosition( const QPoint &globalPos  ); | 
|---|
| 183 | QWidget *areaAt( const QPoint &gp ); | 
|---|
| 184 | void removeFromDock( bool fixNewLines = TRUE ); | 
|---|
| 185 | void swapRect( QRect &r, Qt::Orientation o, const QPoint &offset, QDockArea *area ); | 
|---|
| 186 | void init(); | 
|---|
| 187 |  | 
|---|
| 188 | private: | 
|---|
| 189 | QDockWindowHandle *horHandle, *verHandle; | 
|---|
| 190 | QDockWindowTitleBar *titleBar; | 
|---|
| 191 | QWidget *wid; | 
|---|
| 192 | QPainter *unclippedPainter; | 
|---|
| 193 | QDockArea *dockArea, *tmpDockArea; | 
|---|
| 194 | QRect currRect; | 
|---|
| 195 | Place curPlace; | 
|---|
| 196 | Place state; | 
|---|
| 197 | bool resizeEnabled : 1; | 
|---|
| 198 | bool moveEnabled : 1; | 
|---|
| 199 | bool nl : 1; | 
|---|
| 200 | bool opaque : 1; | 
|---|
| 201 | bool isToolbar : 1; | 
|---|
| 202 | bool stretchable[ 3 ]; | 
|---|
| 203 | Orientation startOrientation; | 
|---|
| 204 | int cMode; | 
|---|
| 205 | QPoint startOffset; | 
|---|
| 206 | int offs; | 
|---|
| 207 | QSize fExtent; | 
|---|
| 208 | QDockWindowResizeHandle *hHandleTop, *hHandleBottom, *vHandleLeft, *vHandleRight; | 
|---|
| 209 | QVBoxLayout *hbox; | 
|---|
| 210 | QHBoxLayout *vbox; | 
|---|
| 211 | QBoxLayout *childBox; | 
|---|
| 212 | void *dockWindowData; | 
|---|
| 213 | QPoint lastPos; | 
|---|
| 214 | QSize lastSize; | 
|---|
| 215 | QWidgetResizeHandler *widgetResizeHandler; | 
|---|
| 216 | QDockWindowPrivate *d; | 
|---|
| 217 |  | 
|---|
| 218 | private:        // Disabled copy constructor and operator= | 
|---|
| 219 | #if defined(Q_DISABLE_COPY) | 
|---|
| 220 | QDockWindow( const QDockWindow & ); | 
|---|
| 221 | QDockWindow& operator=( const QDockWindow & ); | 
|---|
| 222 | #endif | 
|---|
| 223 | }; | 
|---|
| 224 |  | 
|---|
| 225 | inline QDockArea *QDockWindow::area() const | 
|---|
| 226 | { | 
|---|
| 227 | return dockArea; | 
|---|
| 228 | } | 
|---|
| 229 |  | 
|---|
| 230 | #define Q_DEFINED_QDOCKWINDOW | 
|---|
| 231 | #include "qwinexport.h" | 
|---|
| 232 | #endif | 
|---|
| 233 |  | 
|---|
| 234 | #endif // QDOCKWINDOW_H | 
|---|