1 /////////////////////////////////////////////////////////////////////////////
3 // File : qworkspaceP.h
4 // Description : the patch for Qt's QWorkspace class (qworkspace.h)
5 /////////////////////////////////////////////////////////////////////////////
7 /****************************************************************************
10 ** Definition of the QWorkspace class
14 ** Copyright (C) 1999-2000 Trolltech AS. All rights reserved.
16 ** This file is part of the workspace module of the Qt GUI Toolkit.
18 ** This file may be distributed under the terms of the Q Public License
19 ** as defined by Trolltech AS of Norway and appearing in the file
20 ** LICENSE.QPL included in the packaging of this file.
22 ** This file may be distributed and/or modified under the terms of the
23 ** GNU General Public License version 2 as published by the Free Software
24 ** Foundation and appearing in the file LICENSE.GPL included in the
25 ** packaging of this file.
27 ** Licensees holding valid Qt Enterprise Edition licenses may use this
28 ** file in accordance with the Qt Commercial License Agreement provided
31 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
32 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
34 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
35 ** information about Qt Commercial License Agreements.
36 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
37 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
39 ** Contact info@trolltech.com if any conditions of this licensing are
42 **********************************************************************/
50 #include <qwidgetlist.h>
52 #include <qguardedptr.h>
57 #if QT_VERSION > 0x030005
58 #include <qworkspace.h>
59 #define QWorkspaceP QWorkspace
62 class QWorkspacePChild;
64 class QWorkspacePPrivate;
66 class QWidgetResizeHandlerP;
69 class Q_EXPORT QWorkspaceP : public QWidget
72 Q_PROPERTY( bool scrollBarsEnabled READ scrollBarsEnabled WRITE setScrollBarsEnabled )
74 QWorkspaceP( QWidget* parent=0, const char* name=0 );
77 QWidget* activeWindow() const;
78 QWidgetList windowList() const;
80 QSize sizeHint() const;
82 bool scrollBarsEnabled() const;
83 void setScrollBarsEnabled( bool enable );
85 void setPaletteBackgroundColor( const QColor & );
86 void setPaletteBackgroundPixmap( const QPixmap & );
89 void windowActivated( QWidget* w);
97 void styleChange( QStyle& );
99 void childEvent( QChildEvent * );
100 void resizeEvent( QResizeEvent * );
101 bool eventFilter( QObject *, QEvent * );
102 void showEvent( QShowEvent *e );
103 void hideEvent( QHideEvent *e );
104 #ifndef QT_NO_WHEELEVENT
105 void wheelEvent( QWheelEvent *e );
109 void closeActiveWindow();
110 void closeAllWindows();
111 void normalizeActiveWindow();
112 void minimizeActiveWindow();
113 void showOperationMenu();
114 void popupOperationMenu( const QPoint& );
115 void operationMenuActivated( int );
116 void operationMenuAboutToShow();
117 void toolMenuAboutToShow();
118 void scrollBarChanged();
120 void activateNextWindow();
121 void activatePreviousWindow();
124 void activateWindow( QWidget* w, bool change_focus = TRUE );
127 void insertIcon( QWidget* w);
128 void removeIcon( QWidget* w);
129 void place( QWidget* );
131 QWorkspacePChild* findChild( QWidget* w);
132 void showMaximizeControls();
133 void hideMaximizeControls();
134 void showWindow( QWidget* w);
135 void maximizeWindow( QWidget* w);
136 void minimizeWindow( QWidget* w);
137 void normalizeWindow( QWidget* w);
139 QRect updateWorkspace();
142 QWorkspacePPrivate* d;
144 friend class QWorkspacePChild;
146 private: // Disabled copy constructor and operator=
147 #if defined(Q_DISABLE_COPY)
148 QWorkspaceP( const QWorkspaceP & );
149 QWorkspaceP& operator=( const QWorkspaceP & );
153 class QWorkspacePChild : public QFrame
157 friend class QWorkspaceP;
158 friend class QTitleBarP;
161 QWorkspacePChild( QWidget* window,
162 QWorkspaceP* parent=0, const char* name=0 );
165 void setActive( bool );
166 bool isActive() const;
168 void adjustToFullscreen();
171 QWidget* windowWidget() const;
172 QWidget* iconWidget() const;
177 QSize sizeHint() const;
178 QSize minimumSizeHint() const;
180 QSize baseSize() const;
183 void showOperationMenu();
184 void popupOperationMenu( const QPoint& );
188 void showMinimized();
189 void showMaximized();
192 void setCaption( const QString& );
193 void internalRaise();
194 void titleBarDoubleClicked();
196 void move( int x, int y );
199 void enterEvent( QEvent * );
200 void leaveEvent( QEvent * );
201 void childEvent( QChildEvent* );
202 void resizeEvent( QResizeEvent * );
203 void moveEvent( QMoveEvent * );
204 bool eventFilter( QObject *, QEvent * );
206 bool focusNextPrevChild( bool );
208 void drawFrame( QPainter * );
209 void styleChange( QStyle & );
212 QWidget* childWidget;
214 QWidgetResizeHandlerP *widgetResizeHandler;
215 QTitleBarP* titlebar;
216 QGuardedPtr<QTitleBarP> iconw;
219 QSize shadeRestoreMin;
222 bool snappedRight :1;
231 class Q_EXPORT QWidgetResizeHandlerP : public QObject
236 QWidgetResizeHandlerP( QWidget *parent, QWidget *cw = 0, const char *name = 0 );
237 void setActive( bool b ) { active = b; if ( !active ) setMouseCursor( Nowhere ); }
238 bool isActive() const { return active; }
239 void setMovingEnabled( bool b ) { moving = b; }
240 bool isMovingEnabled() const { return moving; }
242 bool isButtonDown() const { return buttonDown; }
244 void setExtraHeight( int h ) { extrahei = h; }
245 void setSizeProtection( bool b ) { sizeprotect = b; }
254 bool eventFilter( QObject *o, QEvent *e );
255 void mouseMoveEvent( QMouseEvent *e );
256 void keyPressEvent( QKeyEvent *e );
261 TopLeft, BottomRight, BottomLeft, TopRight,
262 Top, Bottom, Left, Right,
267 QWidget *childWidget;
269 QPoint invertedMoveOffset;
274 uint moveResizeMode :1;
279 void setMouseCursor( MousePosition m );
280 bool isMove() const {
281 return moveResizeMode && mode == Center;
283 bool isResize() const {
284 return moveResizeMode && !isMove();
287 private: // Disabled copy constructor and operator=
288 #if defined(Q_DISABLE_COPY)
289 QWidgetResizeHandlerP( const QWidgetResizeHandlerP & );
290 QWidgetResizeHandlerP& operator=( const QWidgetResizeHandlerP & );
296 class QTitleBarPPrivate;
299 class Q_EXPORT QTitleBarP : public QWidget
302 Q_PROPERTY( bool autoRaise READ autoRaise WRITE setAutoRaise )
303 Q_PROPERTY( bool movable READ isMovable WRITE setMovable )
306 QTitleBarP (QWidget* w, QWidget* parent, const char* name=0);
309 bool isActive() const;
310 bool usesActiveColor() const;
311 virtual QString visibleText() const;
313 bool isMovable() const;
314 void setMovable(bool);
316 bool autoRaise() const;
317 void setAutoRaise(bool);
319 QWidget *window() const;
321 QSize sizeHint() const;
324 void setActive( bool );
325 void setCaption( const QString& title );
326 void setIcon( const QPixmap& icon );
335 void showOperationMenu();
336 void popupOperationMenu( const QPoint& );
337 void doubleClicked();
340 bool event( QEvent *);
341 void resizeEvent( QResizeEvent *);
342 void contextMenuEvent( QContextMenuEvent * );
343 void mousePressEvent( QMouseEvent * );
344 void mouseDoubleClickEvent( QMouseEvent * );
345 void mouseReleaseEvent( QMouseEvent * );
346 void mouseMoveEvent( QMouseEvent * );
347 void enterEvent( QEvent *e );
348 void leaveEvent( QEvent *e );
349 void paintEvent( QPaintEvent *p );
351 virtual void cutText();
356 QTitleBarPPrivate *d;
359 #endif // QWORKSPACEP_H