home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qdockwindow.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  7KB  |  220 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qdockwindow.h   3.0.0   edited Sep 28 16:52 $
  3. **
  4. ** Definition of the QDockWindow class
  5. **
  6. ** Created : 001010
  7. **
  8. ** Copyright (C) 1992-2000 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 QDOCKWIDGET_H
  39. #define QDOCKWIDGET_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.  
  60. class Q_EXPORT QDockWindow : public QFrame
  61. {
  62.     Q_OBJECT
  63.     Q_ENUMS( CloseMode Place )
  64.     Q_PROPERTY( int closeMode READ closeMode  WRITE setCloseMode )
  65.     Q_PROPERTY( bool resizeEnabled READ isResizeEnabled  WRITE setResizeEnabled )
  66.     Q_PROPERTY( bool movingEnabled READ isMovingEnabled  WRITE setMovingEnabled )
  67.     Q_PROPERTY( bool horizontallyStretchable READ isHorizontallyStretchable  WRITE setHorizontallyStretchable )
  68.     Q_PROPERTY( bool verticallyStretchable READ isVerticallyStretchable  WRITE setVerticallyStretchable )
  69.     Q_PROPERTY( bool stretchable READ isStretchable )
  70.     Q_PROPERTY( bool newLine READ newLine  WRITE setNewLine )
  71.     Q_PROPERTY( bool opaqueMoving READ opaqueMoving  WRITE setOpaqueMoving )
  72.     Q_PROPERTY( int offset READ offset  WRITE setOffset )
  73.     Q_PROPERTY( Place place READ place )
  74.  
  75.     friend class QDockWindowHandle;
  76.     friend class QDockWindowTitleBar;
  77.     friend class QDockArea;
  78.     friend class QDockAreaLayout;
  79.     friend class QMainWindow;
  80.  
  81. public:
  82.     enum Place { InDock, OutsideDock };
  83.     enum CloseMode { Never = 0, Docked = 1, Undocked = 2, Always = Docked | Undocked };
  84.  
  85.     QDockWindow( Place p = InDock, QWidget* parent=0, const char* name=0, WFlags f = 0 );
  86.     ~QDockWindow();
  87.  
  88.     virtual void setWidget( QWidget *w );
  89.     QWidget *widget() const;
  90.  
  91.     Place place() const { return curPlace; }
  92.  
  93.     QDockArea *area() const;
  94.  
  95.     virtual void setCloseMode( int m );
  96.     bool isCloseEnabled() const;
  97.     int closeMode() const;
  98.  
  99.     virtual void setResizeEnabled( bool b );
  100.     virtual void setMovingEnabled( bool b );
  101.     bool isResizeEnabled() const;
  102.     bool isMovingEnabled() const;
  103.  
  104.     virtual void setHorizontallyStretchable( bool b );
  105.     virtual void setVerticallyStretchable( bool b );
  106.     bool isHorizontallyStretchable() const;
  107.     bool isVerticallyStretchable() const;
  108.     void setHorizontalStretchable( bool b ) { setHorizontallyStretchable( b ); }
  109.     void setVerticalStretchable( bool b ) { setVerticallyStretchable( b ); }
  110.     bool isHorizontalStretchable() const { return isHorizontallyStretchable(); }
  111.     bool isVerticalStretchable() const { return isVerticallyStretchable(); }
  112.     bool isStretchable() const;
  113.  
  114.     virtual void setOffset( int o );
  115.     int offset() const;
  116.  
  117.     virtual void setFixedExtentWidth( int w );
  118.     virtual void setFixedExtentHeight( int h );
  119.     QSize fixedExtent() const;
  120.  
  121.     virtual void setNewLine( bool b );
  122.     bool newLine() const;
  123.  
  124.     Qt::Orientation orientation() const;
  125.  
  126.     QSize sizeHint() const;
  127.     QSize minimumSize() const;
  128.     QSize minimumSizeHint() const;
  129.  
  130.     QBoxLayout *boxLayout();
  131.  
  132.     virtual void setOpaqueMoving( bool b );
  133.     bool opaqueMoving() const;
  134.  
  135.     bool eventFilter( QObject *o, QEvent *e );
  136.  
  137. #ifdef QT_NO_WIDGET_TOPEXTRA
  138.     QString caption() const;
  139. #endif
  140.  
  141. signals:
  142.     void orientationChanged( Orientation o );
  143.     void placeChanged( QDockWindow::Place p );
  144.     void visibilityChanged( bool );
  145.  
  146. public slots:
  147.     virtual void undock( QWidget *w );
  148.     virtual void undock() { undock( 0 ); }
  149.     virtual void dock();
  150.     virtual void setOrientation( Orientation o );
  151.     void setCaption( const QString &s );
  152.  
  153. protected:
  154.     void resizeEvent( QResizeEvent *e );
  155.     void showEvent( QShowEvent *e );
  156.     void hideEvent( QHideEvent *e );
  157.     void contextMenuEvent( QContextMenuEvent *e );
  158.  
  159.     bool event( QEvent *e );
  160.  
  161. private slots:
  162.     void toggleVisible() { if ( !isVisible() ) show(); else hide(); }
  163.  
  164. private:
  165.     void handleMove( const QPoint &pos, const QPoint &gp, bool drawRect );
  166.     void updateGui();
  167.     void updateSplitterVisibility( bool visible );
  168.  
  169.     void startRectDraw( const QPoint &so, bool drawRect );
  170.     void endRectDraw( bool drawRect );
  171.     void updatePosition( const QPoint &globalPos  );
  172.     QWidget *areaAt( const QPoint &gp );
  173.     void removeFromDock( bool fixNewLines = TRUE );
  174.     void swapRect( QRect &r, Qt::Orientation o, const QPoint &offset, QDockArea *area );
  175.  
  176. private:
  177.     QDockWindowHandle *horHandle, *verHandle;
  178.     QDockWindowTitleBar *titleBar;
  179.     QWidget *wid;
  180.     QPainter *unclippedPainter;
  181.     QDockArea *dockArea, *tmpDockArea;
  182.     QRect currRect;
  183.     Place curPlace;
  184.     Place state;
  185.     bool resizeEnabled : 1;
  186.     bool moveEnabled : 1;
  187.     bool nl : 1;
  188.     bool opaque : 1;
  189.     bool stretchable[ 3 ];
  190.     Orientation startOrientation;
  191.     int cMode;
  192.     QPoint startOffset;
  193.     int offs;
  194.     QSize fExtent;
  195.     QDockWindowResizeHandle *hHandleTop, *hHandleBottom, *vHandleLeft, *vHandleRight;
  196.     QVBoxLayout *hbox;
  197.     QHBoxLayout *vbox;
  198.     QBoxLayout *layout;
  199.     void *dockWindowData;
  200.     QPoint lastPos;
  201.     QSize lastSize;
  202.     QWidgetResizeHandler *widgetResizeHandler;
  203.     QDockWindowPrivate *d;
  204.  
  205. private:    // Disabled copy constructor and operator=
  206. #if defined(Q_DISABLE_COPY)
  207.     QDockWindow( const QDockWindow & );
  208.     QDockWindow& operator=( const QDockWindow & );
  209. #endif
  210. };
  211.  
  212. inline QDockArea *QDockWindow::area() const
  213. {
  214.     return dockArea;
  215. }
  216.  
  217. #endif
  218.  
  219. #endif //QT_NO_MAINWINDOW
  220.