1 /****************************************************************************
4 ** Defintion of QSplitter class
8 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
10 ** This file is part of the widgets module of the Qt GUI Toolkit.
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.
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.
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.
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.
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.
33 ** Contact info@trolltech.com if any conditions of this licensing are
36 **********************************************************************/
42 #include <qvaluelist.h>
43 #include <qwidgetlist.h> // by STV
45 #include <qpushbutton.h>
47 #ifndef QT_NO_COMPLEXWIDGETS
49 class QSplitterPHandle;
51 class QSplitterPLayoutStruct;
53 class Q_EXPORT QSplitterP : public QFrame
56 Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
59 enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
61 QSplitterP( QWidget *parent=0, const char *name=0 );
62 QSplitterP( Orientation, QWidget *parent=0, const char *name=0 );
65 virtual void setOrientation( Orientation );
66 Orientation orientation() const { return orient; }
68 virtual void setResizeMode( QWidget *w, ResizeMode );
69 virtual void setOpaqueResize( bool = TRUE );
70 bool opaqueResize() const;
72 void moveToFirst( QWidget * );
73 void moveToLast( QWidget * );
75 void refresh() { recalc( TRUE ); }
76 QSize sizeHint() const;
77 QSize minimumSizeHint() const;
78 QSizePolicy sizePolicy() const;
80 QValueList<int> sizes() const;
81 void setSizes( QValueList<int> );
82 bool isCompressEnabled() const;
83 void setCompressEnabled(bool on);
85 void compress(QWidget*);
86 void unCompress(QWidget*);
88 // VSR 21/11/02 -> ================================
89 QSplitterPHandle* getHandleAfter(QWidget* w);
90 QSplitterPHandle* getHandleBefore(QWidget* w);
91 // VSR 21/11/02 <- ================================
94 void childEvent( QChildEvent * );
96 bool event( QEvent * );
97 void resizeEvent( QResizeEvent * );
99 int idAfter( QWidget* ) const;
100 QWidget* widgetBefore( int id ) const;
101 QWidget* widgetAfter( int id ) const;
102 bool isCompressed(const QWidget*) const;
103 QSize minSize( const QWidget *w ) const;
104 QSize maxSize( const QWidget *w ) const;
106 void moveSplitter( QCOORD pos, int id );
107 virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y,
108 QCOORD w, QCOORD h );
109 void styleChange( QStyle& );
110 int adjustPos( int , int );
111 virtual void setRubberband( int );
112 void getRange( int id, int*, int* );
116 void recalc( bool update = FALSE );
120 void processChildEvents();
121 QSplitterPLayoutStruct *addWidget( QWidget*, bool first = FALSE );
123 void moveBefore( int pos, int id, bool upLeft );
124 void moveAfter( int pos, int id, bool upLeft );
125 void setG( QWidget *w, int p, int s );
126 void updateSplitterHandles() const;
128 QCOORD pick( const QPoint &p ) const
129 { return orient == Horizontal ? p.x() : p.y(); }
130 QCOORD pick( const QSize &s ) const
131 { return orient == Horizontal ? s.width() : s.height(); }
133 QCOORD trans( const QPoint &p ) const
134 { return orient == Vertical ? p.x() : p.y(); }
135 QCOORD trans( const QSize &s ) const
136 { return orient == Vertical ? s.width() : s.height(); }
138 QSplitterPData *data;
139 QWidgetList compressed_widgets;
143 friend class QSplitterPHandle;
144 private: // Disabled copy constructor and operator=
145 #if defined(Q_DISABLE_COPY)
146 QSplitterP( const QSplitterP & );
147 QSplitterP& operator=( const QSplitterP & );
151 #endif // QT_NO_COMPLEXWIDGETS
154 class Q_EXPORT QSplitterPHandle : public QWidget
158 QSplitterPHandle( Qt::Orientation o,
159 QSplitterP *parent, const char* name=0 );
160 void setOrientation( Qt::Orientation o );
161 Qt::Orientation orientation() const { return orient; }
163 bool opaque() const { return s->opaqueResize(); }
165 QSize sizeHint() const;
166 QSizePolicy sizePolicy() const;
168 int id() const { return myId; } // data->list.at(id())->wid == this
169 void setId( int i ) { myId = i; }
170 void updateButtonState();
172 // VSR 21/11/02 -> ================================
173 void compressAfter();
174 void unCompressAfter();
175 void compressBefore();
176 void unCompressBefore();
177 // VSR 21/11/02 <- ================================
180 void paintEvent( QPaintEvent * );
181 void mouseMoveEvent( QMouseEvent * );
182 void mousePressEvent( QMouseEvent * );
183 void mouseReleaseEvent( QMouseEvent * );
186 void onBeforeCompress();
187 void onAfterCompress();
188 void onBeforeUnCompress();
189 void onAfterUnCompress();
192 Qt::Orientation orient;
201 QPushButton* unright;
205 #endif // QSPLITTERP_H