| 1 | /****************************************************************************
 | 
|---|
| 2 | ** $Id: qsplitter.h 2 2005-11-16 15:49:26Z dmik $
 | 
|---|
| 3 | **
 | 
|---|
| 4 | ** Definition of QSplitter class
 | 
|---|
| 5 | **
 | 
|---|
| 6 | **  Created : 980105
 | 
|---|
| 7 | **
 | 
|---|
| 8 | ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
 | 
|---|
| 9 | **
 | 
|---|
| 10 | ** This file is part of the widgets 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 or Qt Professional Edition
 | 
|---|
| 22 | ** licenses may use this file in accordance with the Qt Commercial License
 | 
|---|
| 23 | ** Agreement provided 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 QSPLITTER_H
 | 
|---|
| 39 | #define QSPLITTER_H
 | 
|---|
| 40 | 
 | 
|---|
| 41 | #ifndef QT_H
 | 
|---|
| 42 | #include "qframe.h"
 | 
|---|
| 43 | #include "qvaluelist.h"
 | 
|---|
| 44 | #endif // QT_H
 | 
|---|
| 45 | 
 | 
|---|
| 46 | #ifndef QT_NO_SPLITTER
 | 
|---|
| 47 | 
 | 
|---|
| 48 | class QSplitterHandle;
 | 
|---|
| 49 | class QSplitterPrivate;
 | 
|---|
| 50 | class QSplitterLayoutStruct;
 | 
|---|
| 51 | class QTextStream;
 | 
|---|
| 52 | 
 | 
|---|
| 53 | class Q_EXPORT QSplitter : public QFrame
 | 
|---|
| 54 | {
 | 
|---|
| 55 |     Q_OBJECT
 | 
|---|
| 56 |     Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
 | 
|---|
| 57 |     Q_PROPERTY( bool opaqueResize READ opaqueResize WRITE setOpaqueResize )
 | 
|---|
| 58 |     Q_PROPERTY( int handleWidth READ handleWidth WRITE setHandleWidth )
 | 
|---|
| 59 |     Q_PROPERTY( bool childrenCollapsible READ childrenCollapsible WRITE setChildrenCollapsible )
 | 
|---|
| 60 | 
 | 
|---|
| 61 | public:
 | 
|---|
| 62 |     // ### Qt 4.0: remove Auto from public API
 | 
|---|
| 63 |     enum ResizeMode { Stretch, KeepSize, FollowSizeHint, Auto };
 | 
|---|
| 64 | 
 | 
|---|
| 65 |     QSplitter( QWidget* parent = 0, const char* name = 0 );
 | 
|---|
| 66 |     QSplitter( Orientation, QWidget* parent = 0, const char* name = 0 );
 | 
|---|
| 67 |     ~QSplitter();
 | 
|---|
| 68 | 
 | 
|---|
| 69 |     virtual void setOrientation( Orientation );
 | 
|---|
| 70 |     Orientation orientation() const { return orient; }
 | 
|---|
| 71 | 
 | 
|---|
| 72 |     // ### Qt 4.0: make setChildrenCollapsible() and setCollapsible() virtual
 | 
|---|
| 73 | 
 | 
|---|
| 74 |     void setChildrenCollapsible( bool );
 | 
|---|
| 75 |     bool childrenCollapsible() const;
 | 
|---|
| 76 | 
 | 
|---|
| 77 |     void setCollapsible( QWidget *w, bool );
 | 
|---|
| 78 |     virtual void setResizeMode( QWidget *w, ResizeMode );
 | 
|---|
| 79 |     virtual void setOpaqueResize( bool = TRUE );
 | 
|---|
| 80 |     bool opaqueResize() const;
 | 
|---|
| 81 | 
 | 
|---|
| 82 |     void moveToFirst( QWidget * );
 | 
|---|
| 83 |     void moveToLast( QWidget * );
 | 
|---|
| 84 | 
 | 
|---|
| 85 |     void refresh() { recalc( TRUE ); }
 | 
|---|
| 86 |     QSize sizeHint() const;
 | 
|---|
| 87 |     QSize minimumSizeHint() const;
 | 
|---|
| 88 | 
 | 
|---|
| 89 |     QValueList<int> sizes() const;
 | 
|---|
| 90 |     void setSizes( QValueList<int> );
 | 
|---|
| 91 | 
 | 
|---|
| 92 |     int handleWidth() const;
 | 
|---|
| 93 |     void setHandleWidth( int );
 | 
|---|
| 94 | 
 | 
|---|
| 95 | protected:
 | 
|---|
| 96 |     void childEvent( QChildEvent * );
 | 
|---|
| 97 | 
 | 
|---|
| 98 |     bool event( QEvent * );
 | 
|---|
| 99 |     void resizeEvent( QResizeEvent * );
 | 
|---|
| 100 | 
 | 
|---|
| 101 |     int idAfter( QWidget* ) const;
 | 
|---|
| 102 | 
 | 
|---|
| 103 |     void moveSplitter( QCOORD pos, int id );
 | 
|---|
| 104 |     virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y,
 | 
|---|
| 105 |                                QCOORD w, QCOORD h );
 | 
|---|
| 106 |     void styleChange( QStyle& );
 | 
|---|
| 107 |     int adjustPos( int, int );
 | 
|---|
| 108 |     virtual void setRubberband( int );
 | 
|---|
| 109 |     void getRange( int id, int *, int * );
 | 
|---|
| 110 | 
 | 
|---|
| 111 | private:
 | 
|---|
| 112 |     enum { DefaultResizeMode = 3 };
 | 
|---|
| 113 | 
 | 
|---|
| 114 |     void init();
 | 
|---|
| 115 |     void recalc( bool update = FALSE );
 | 
|---|
| 116 |     void doResize();
 | 
|---|
| 117 |     void storeSizes();
 | 
|---|
| 118 |     void getRange( int id, int *, int *, int *, int * );
 | 
|---|
| 119 |     void addContribution( int, int *, int *, bool );
 | 
|---|
| 120 |     int adjustPos( int, int, int *, int *, int *, int * );
 | 
|---|
| 121 |     bool collapsible( QSplitterLayoutStruct * );
 | 
|---|
| 122 |     void processChildEvents();
 | 
|---|
| 123 |     QSplitterLayoutStruct *findWidget( QWidget * );
 | 
|---|
| 124 |     QSplitterLayoutStruct *addWidget( QWidget *, bool prepend = FALSE );
 | 
|---|
| 125 |     void recalcId();
 | 
|---|
| 126 |     void doMove( bool backwards, int pos, int id, int delta, bool upLeft,
 | 
|---|
| 127 |                  bool mayCollapse );
 | 
|---|
| 128 |     void setGeo( QWidget *w, int pos, int size, bool splitterMoved );
 | 
|---|
| 129 |     int findWidgetJustBeforeOrJustAfter( int id, int delta, int &collapsibleSize );
 | 
|---|
| 130 |     void updateHandles();
 | 
|---|
| 131 | 
 | 
|---|
| 132 |     inline QCOORD pick( const QPoint &p ) const
 | 
|---|
| 133 |     { return orient == Horizontal ? p.x() : p.y(); }
 | 
|---|
| 134 |     inline QCOORD pick( const QSize &s ) const
 | 
|---|
| 135 |     { return orient == Horizontal ? s.width() : s.height(); }
 | 
|---|
| 136 | 
 | 
|---|
| 137 |     inline QCOORD trans( const QPoint &p ) const
 | 
|---|
| 138 |     { return orient == Vertical ? p.x() : p.y(); }
 | 
|---|
| 139 |     inline QCOORD trans( const QSize &s ) const
 | 
|---|
| 140 |     { return orient == Vertical ? s.width() : s.height(); }
 | 
|---|
| 141 | 
 | 
|---|
| 142 |     QSplitterPrivate *d;
 | 
|---|
| 143 | 
 | 
|---|
| 144 |     Orientation orient;
 | 
|---|
| 145 |     friend class QSplitterHandle;
 | 
|---|
| 146 | 
 | 
|---|
| 147 | #ifndef QT_NO_TEXTSTREAM
 | 
|---|
| 148 |     friend Q_EXPORT QTextStream& operator<<( QTextStream&, const QSplitter& );
 | 
|---|
| 149 |     friend Q_EXPORT QTextStream& operator>>( QTextStream&, QSplitter& );
 | 
|---|
| 150 | #endif
 | 
|---|
| 151 | 
 | 
|---|
| 152 | private:
 | 
|---|
| 153 | #if defined(Q_DISABLE_COPY)
 | 
|---|
| 154 |     QSplitter( const QSplitter & );
 | 
|---|
| 155 |     QSplitter& operator=( const QSplitter & );
 | 
|---|
| 156 | #endif
 | 
|---|
| 157 | };
 | 
|---|
| 158 | 
 | 
|---|
| 159 | #ifndef QT_NO_TEXTSTREAM
 | 
|---|
| 160 | Q_EXPORT QTextStream& operator<<( QTextStream&, const QSplitter& );
 | 
|---|
| 161 | Q_EXPORT QTextStream& operator>>( QTextStream&, QSplitter& );
 | 
|---|
| 162 | #endif
 | 
|---|
| 163 | 
 | 
|---|
| 164 | #endif // QT_NO_SPLITTER
 | 
|---|
| 165 | 
 | 
|---|
| 166 | #endif // QSPLITTER_H
 | 
|---|