1 /////////////////////////////////////////////////////////////////////////////
4 // Description : the patch for Qt's QSplitter class (qsplitter.h)
5 /////////////////////////////////////////////////////////////////////////////
7 /****************************************************************************
10 ** Defintion of QSplitter class
14 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
16 ** This file is part of the widgets module of the Qt GUI Toolkit.
18 ** This file may be distributed under the terms of the Q Public License
19 ** as defined by Trolltech AS of Norway and appearing in the file
20 ** LICENSE.QPL included in the packaging of this file.
22 ** This file may be distributed and/or modified under the terms of the
23 ** GNU General Public License version 2 as published by the Free Software
24 ** Foundation and appearing in the file LICENSE.GPL included in the
25 ** packaging of this file.
27 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
28 ** licenses may use this file in accordance with the Qt Commercial License
29 ** Agreement provided with the Software.
31 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
32 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
34 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
35 ** information about Qt Commercial License Agreements.
36 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
37 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
39 ** Contact info@trolltech.com if any conditions of this licensing are
42 **********************************************************************/
48 #include <qvaluelist.h>
49 #include <qwidgetlist.h> // by STV
51 #include <qpushbutton.h>
53 #ifndef QT_NO_COMPLEXWIDGETS
55 class QSplitterPHandle;
57 class QSplitterPLayoutStruct;
59 class Q_EXPORT QSplitterP : public QFrame
62 Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
65 enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
67 QSplitterP( QWidget *parent=0, const char *name=0 );
68 QSplitterP( Orientation, QWidget *parent=0, const char *name=0 );
71 virtual void setOrientation( Orientation );
72 Orientation orientation() const { return orient; }
74 virtual void setResizeMode( QWidget *w, ResizeMode );
75 virtual void setOpaqueResize( bool = TRUE );
76 bool opaqueResize() const;
78 void moveToFirst( QWidget * );
79 void moveToLast( QWidget * );
81 void refresh() { recalc( TRUE ); }
82 QSize sizeHint() const;
83 QSize minimumSizeHint() const;
84 QSizePolicy sizePolicy() const;
86 QValueList<int> sizes() const;
87 void setSizes( QValueList<int> );
88 bool isCompressEnabled() const;
89 void setCompressEnabled(bool on);
91 void compress(QWidget*);
92 void unCompress(QWidget*);
94 // VSR 21/11/02 -> ================================
95 QSplitterPHandle* getHandleAfter(QWidget* w);
96 QSplitterPHandle* getHandleBefore(QWidget* w);
97 // VSR 21/11/02 <- ================================
100 bool isCompressed( const QWidget* ) const;
104 void childEvent( QChildEvent * );
106 bool event( QEvent * );
107 void resizeEvent( QResizeEvent * );
109 int idAfter( QWidget* ) const;
110 QWidget* widgetBefore( int id ) const;
111 QWidget* widgetAfter( int id ) const;
113 QSize minSize( const QWidget *w ) const;
114 QSize maxSize( const QWidget *w ) const;
116 void moveSplitter( QCOORD pos, int id );
117 virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y,
118 QCOORD w, QCOORD h );
119 void styleChange( QStyle& );
120 int adjustPos( int , int );
121 virtual void setRubberband( int );
122 void getRange( int id, int*, int* );
126 void recalc( bool update = FALSE );
130 void processChildEvents();
131 QSplitterPLayoutStruct *addWidget( QWidget*, bool first = FALSE );
133 void moveBefore( int pos, int id, bool upLeft );
134 void moveAfter( int pos, int id, bool upLeft );
135 void setG( QWidget *w, int p, int s );
136 void updateSplitterHandles() const;
138 QCOORD pick( const QPoint &p ) const
139 { return orient == Horizontal ? p.x() : p.y(); }
140 QCOORD pick( const QSize &s ) const
141 { return orient == Horizontal ? s.width() : s.height(); }
143 QCOORD trans( const QPoint &p ) const
144 { return orient == Vertical ? p.x() : p.y(); }
145 QCOORD trans( const QSize &s ) const
146 { return orient == Vertical ? s.width() : s.height(); }
148 QSplitterPData *data;
149 QWidgetList compressed_widgets;
153 friend class QSplitterPHandle;
154 private: // Disabled copy constructor and operator=
155 #if defined(Q_DISABLE_COPY)
156 QSplitterP( const QSplitterP & );
157 QSplitterP& operator=( const QSplitterP & );
161 #endif // QT_NO_COMPLEXWIDGETS
164 class Q_EXPORT QSplitterPHandle : public QWidget
168 QSplitterPHandle( Qt::Orientation o,
169 QSplitterP *parent, const char* name=0 );
170 void setOrientation( Qt::Orientation o );
171 Qt::Orientation orientation() const { return orient; }
173 bool opaque() const { return s->opaqueResize(); }
175 QSize sizeHint() const;
176 QSizePolicy sizePolicy() const;
178 int id() const { return myId; } // data->list.at(id())->wid == this
179 void setId( int i ) { myId = i; }
180 void updateButtonState();
182 // VSR 21/11/02 -> ================================
183 void compressAfter();
184 void unCompressAfter();
185 void compressBefore();
186 void unCompressBefore();
187 // VSR 21/11/02 <- ================================
190 void paintEvent( QPaintEvent * );
191 void mouseMoveEvent( QMouseEvent * );
192 void mousePressEvent( QMouseEvent * );
193 void mouseReleaseEvent( QMouseEvent * );
196 void onBeforeCompress();
197 void onAfterCompress();
198 void onBeforeUnCompress();
199 void onAfterUnCompress();
202 Qt::Orientation orient;
211 QPushButton* unright;
215 #endif // QSPLITTERP_H