00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef QSPLITTER_H
00038 #define QSPLITTER_H
00039
00040 #ifndef QT_H
00041 #include "qframe.h"
00042 #include "qvaluelist.h"
00043 #endif // QT_H
00044
00045 class QSplitterHandle;
00046 class QSplitterData;
00047 class QSplitterLayoutStruct;
00048
00049 class Q_EXPORT QSplitter : public QFrame
00050 {
00051 Q_OBJECT
00052 Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
00053
00054 public:
00055 enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
00056
00057 QSplitter( QWidget *parent=0, const char *name=0 );
00058 QSplitter( Orientation, QWidget *parent=0, const char *name=0 );
00059 ~QSplitter();
00060
00061 virtual void setOrientation( Orientation );
00062 Orientation orientation() const { return orient; }
00063
00064 virtual void setResizeMode( QWidget *w, ResizeMode );
00065 virtual void setOpaqueResize( bool = TRUE );
00066 bool opaqueResize() const;
00067
00068 void moveToFirst( QWidget * );
00069 void moveToLast( QWidget * );
00070
00071 void refresh() { recalc( TRUE ); }
00072 QSize sizeHint() const;
00073 QSize minimumSizeHint() const;
00074 QSizePolicy sizePolicy() const;
00075
00076 QValueList<int> sizes() const;
00077 void setSizes( QValueList<int> );
00078
00079 protected:
00080 void childEvent( QChildEvent * );
00081
00082 bool event( QEvent * );
00083 void resizeEvent( QResizeEvent * );
00084
00085 int idAfter( QWidget* ) const;
00086
00087 void moveSplitter( QCOORD pos, int id );
00088 virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y,
00089 QCOORD w, QCOORD h );
00090 void styleChange( QStyle& );
00091 int adjustPos( int , int );
00092 virtual void setRubberband( int );
00093 void getRange( int id, int*, int* );
00094
00095 private:
00096 void init();
00097 void recalc( bool update = FALSE );
00098 void doResize();
00099 void storeSizes();
00100 void processChildEvents();
00101 QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE );
00102 void recalcId();
00103 void moveBefore( int pos, int id, bool upLeft );
00104 void moveAfter( int pos, int id, bool upLeft );
00105 void setG( QWidget *w, int p, int s );
00106
00107 QCOORD pick( const QPoint &p ) const
00108 { return orient == Horizontal ? p.x() : p.y(); }
00109 QCOORD pick( const QSize &s ) const
00110 { return orient == Horizontal ? s.width() : s.height(); }
00111
00112 QCOORD trans( const QPoint &p ) const
00113 { return orient == Vertical ? p.x() : p.y(); }
00114 QCOORD trans( const QSize &s ) const
00115 { return orient == Vertical ? s.width() : s.height(); }
00116
00117 QSplitterData *data;
00118
00119 Orientation orient;
00120 friend class QSplitterHandle;
00121 private:
00122 #if defined(Q_DISABLE_COPY)
00123 QSplitter( const QSplitter & );
00124 QSplitter& operator=( const QSplitter & );
00125 #endif
00126 };
00127
00128 #endif // QSPLITTER_H