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

  1. /****************************************************************************
  2. ** $Id:  qt/qdockarea.h   3.0.0   edited Sep 21 17:17 $
  3. **
  4. ** Definition of the QDockArea 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 QDOCKAREA_H
  39. #define QDOCKAREA_H
  40.  
  41. #ifndef QT_H
  42. #include "qwidget.h"
  43. #include "qptrlist.h"
  44. #include "qdockwindow.h"
  45. #include "qlayout.h"
  46. #include "qvaluelist.h"
  47. #include "qguardedptr.h"
  48. #include "qtextstream.h"
  49. #endif // QT_H
  50.  
  51. #ifndef QT_NO_MAINWINDOW
  52.  
  53. class QSplitter;
  54. class QBoxLayout;
  55. class QDockAreaLayout;
  56. class QMouseEvent;
  57. class QDockWindowResizeHandle;
  58. class QDockAreaPrivate;
  59.  
  60. #if defined(Q_TEMPLATEDLL)
  61. // MOC_SKIP_BEGIN
  62. template class Q_EXPORT QValueList<QRect>;
  63. template class Q_EXPORT QPtrList<QDockWindow>;
  64. // MOC_SKIP_END
  65. #endif
  66.  
  67. class Q_EXPORT QDockAreaLayout : public QLayout
  68. {
  69.     Q_OBJECT
  70.     friend class QDockArea;
  71.  
  72. public:
  73.     QDockAreaLayout( QWidget* parent, Qt::Orientation o, QPtrList<QDockWindow> *wl, int space = -1, int margin = -1, const char *name = 0 )
  74.     : QLayout( parent, space, margin, name ), orient( o ), dockWindows( wl ), parentWidget( parent ) { init(); }
  75.     ~QDockAreaLayout() {}
  76.  
  77.     void addItem( QLayoutItem * ) {}
  78.     bool hasHeightForWidth() const;
  79.     int heightForWidth( int ) const;
  80.     int widthForHeight( int ) const;
  81.     QSize sizeHint() const;
  82.     QSize minimumSize() const;
  83.     QLayoutIterator iterator();
  84.     QSizePolicy::ExpandData expanding() const { return QSizePolicy::NoDirection; }
  85.     void invalidate();
  86.     Qt::Orientation orientation() const { return orient; }
  87.     QValueList<QRect> lineList() const { return lines; }
  88.     QPtrList<QDockWindow> lineStarts() const { return ls; }
  89.  
  90. protected:
  91.     void setGeometry( const QRect& );
  92.  
  93. private:
  94.     void init();
  95.     int layoutItems( const QRect&, bool testonly = FALSE );
  96.     Qt::Orientation orient;
  97.     int cached_width, cached_height;
  98.     int cached_hfw, cached_wfh;
  99.     QPtrList<QDockWindow> *dockWindows;
  100.     QWidget *parentWidget;
  101.     QValueList<QRect> lines;
  102.     QPtrList<QDockWindow> ls;
  103.  
  104. };
  105.  
  106. class Q_EXPORT QDockArea : public QWidget
  107. {
  108.     Q_OBJECT
  109.     Q_ENUMS( HandlePosition )
  110.     Q_PROPERTY( Orientation orientation READ orientation )
  111.     Q_PROPERTY( int count READ count )
  112.     Q_PROPERTY( bool empty READ isEmpty )
  113.     Q_PROPERTY( HandlePosition handlePosition READ handlePosition )
  114.  
  115.     friend class QDockWindow;
  116.     friend class QDockWindowResizeHandle;
  117.     friend class QDockAreaLayout;
  118.  
  119. public:
  120.     enum HandlePosition { Normal, Reverse };
  121.  
  122.     QDockArea( Orientation o, HandlePosition h = Normal, QWidget* parent=0, const char* name=0 );
  123.     ~QDockArea();
  124.  
  125.     void moveDockWindow( QDockWindow *w, const QPoint &globalPos, const QRect &rect, bool swap );
  126.     void removeDockWindow( QDockWindow *w, bool makeFloating, bool swap, bool fixNewLines = TRUE );
  127.     void moveDockWindow( QDockWindow *w, int index = -1 );
  128.     bool hasDockWindow( QDockWindow *w, int *index = 0 );
  129.  
  130.     void invalidNextOffset( QDockWindow *dw );
  131.  
  132.     Orientation orientation() const { return orient; }
  133.     HandlePosition handlePosition() const { return hPos; }
  134.  
  135.     bool eventFilter( QObject *, QEvent * );
  136.     bool isEmpty() const;
  137.     int count() const;
  138.     QPtrList<QDockWindow> dockWindowList() const;
  139.  
  140.     bool isDockWindowAccepted( QDockWindow *dw );
  141.     void setAcceptDockWindow( QDockWindow *dw, bool accept );
  142.  
  143. public slots:
  144.     void lineUp( bool keepNewLines );
  145.  
  146. private:
  147.     struct DockWindowData
  148.     {
  149.     int index;
  150.     int offset;
  151.     int line;
  152.     QSize fixedExtent;
  153.     QGuardedPtr<QDockArea> area;
  154.     };
  155.  
  156.     int findDockWindow( QDockWindow *w );
  157.     int lineOf( int index );
  158.     DockWindowData *dockWindowData( QDockWindow *w );
  159.     void dockWindow( QDockWindow *dockWindow, DockWindowData *data );
  160.     void updateLayout();
  161.     void invalidateFixedSizes();
  162.     int maxSpace( int hint, QDockWindow *dw );
  163.     void setFixedExtent( int d, QDockWindow *dw );
  164.     bool isLastDockWindow( QDockWindow *dw );
  165.  
  166. private:
  167.     Orientation orient;
  168.     QPtrList<QDockWindow> *dockWindows;
  169.     QDockAreaLayout *layout;
  170.     HandlePosition hPos;
  171.     QPtrList<QDockWindow> forbiddenWidgets;
  172.     QDockAreaPrivate *d;
  173.  
  174. private:    // Disabled copy constructor and operator=
  175. #if defined(Q_DISABLE_COPY)
  176.     QDockArea( const QDockArea & );
  177.     QDockArea& operator=( const QDockArea & );
  178. #endif
  179.  
  180. };
  181.  
  182. #ifndef QT_NO_TEXTSTREAM
  183. Q_EXPORT QTextStream &operator<<( QTextStream &, const QDockArea & );
  184. Q_EXPORT QTextStream &operator>>( QTextStream &, QDockArea & );
  185. #endif
  186.  
  187. #endif
  188.  
  189. #endif //QT_NO_MAINWINDOW
  190.