1 // SALOME PatchQt : patch for Qt
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : qsplitterP.h
27 /****************************************************************************
30 ** Defintion of QSplitter class
34 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
36 ** This file is part of the widgets module of the Qt GUI Toolkit.
38 ** This file may be distributed under the terms of the Q Public License
39 ** as defined by Trolltech AS of Norway and appearing in the file
40 ** LICENSE.QPL included in the packaging of this file.
42 ** This file may be distributed and/or modified under the terms of the
43 ** GNU General Public License version 2 as published by the Free Software
44 ** Foundation and appearing in the file LICENSE.GPL included in the
45 ** packaging of this file.
47 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
48 ** licenses may use this file in accordance with the Qt Commercial License
49 ** Agreement provided with the Software.
51 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
52 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
54 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
55 ** information about Qt Commercial License Agreements.
56 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
57 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
59 ** Contact info@trolltech.com if any conditions of this licensing are
62 **********************************************************************/
68 #include <qvaluelist.h>
69 #include <qwidgetlist.h> // by STV
71 #include <qpushbutton.h>
73 #ifndef QT_NO_COMPLEXWIDGETS
75 class QSplitterPHandle;
77 class QSplitterPLayoutStruct;
79 class Q_EXPORT QSplitterP : public QFrame
82 Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
85 enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
87 QSplitterP( QWidget *parent=0, const char *name=0 );
88 QSplitterP( Orientation, QWidget *parent=0, const char *name=0 );
91 virtual void setOrientation( Orientation );
92 Orientation orientation() const { return orient; }
94 virtual void setResizeMode( QWidget *w, ResizeMode );
95 virtual void setOpaqueResize( bool = TRUE );
96 bool opaqueResize() const;
98 void moveToFirst( QWidget * );
99 void moveToLast( QWidget * );
101 void refresh() { recalc( TRUE ); }
102 QSize sizeHint() const;
103 QSize minimumSizeHint() const;
104 QSizePolicy sizePolicy() const;
106 QValueList<int> sizes() const;
107 void setSizes( QValueList<int> );
108 bool isCompressEnabled() const;
109 void setCompressEnabled(bool on);
111 void compress(QWidget*);
112 void unCompress(QWidget*);
114 // VSR 21/11/02 -> ================================
115 QSplitterPHandle* getHandleAfter(QWidget* w);
116 QSplitterPHandle* getHandleBefore(QWidget* w);
117 // VSR 21/11/02 <- ================================
120 void childEvent( QChildEvent * );
122 bool event( QEvent * );
123 void resizeEvent( QResizeEvent * );
125 int idAfter( QWidget* ) const;
126 QWidget* widgetBefore( int id ) const;
127 QWidget* widgetAfter( int id ) const;
128 bool isCompressed(const QWidget*) const;
129 QSize minSize( const QWidget *w ) const;
130 QSize maxSize( const QWidget *w ) const;
132 void moveSplitter( QCOORD pos, int id );
133 virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y,
134 QCOORD w, QCOORD h );
135 void styleChange( QStyle& );
136 int adjustPos( int , int );
137 virtual void setRubberband( int );
138 void getRange( int id, int*, int* );
142 void recalc( bool update = FALSE );
146 void processChildEvents();
147 QSplitterPLayoutStruct *addWidget( QWidget*, bool first = FALSE );
149 void moveBefore( int pos, int id, bool upLeft );
150 void moveAfter( int pos, int id, bool upLeft );
151 void setG( QWidget *w, int p, int s );
152 void updateSplitterHandles() const;
154 QCOORD pick( const QPoint &p ) const
155 { return orient == Horizontal ? p.x() : p.y(); }
156 QCOORD pick( const QSize &s ) const
157 { return orient == Horizontal ? s.width() : s.height(); }
159 QCOORD trans( const QPoint &p ) const
160 { return orient == Vertical ? p.x() : p.y(); }
161 QCOORD trans( const QSize &s ) const
162 { return orient == Vertical ? s.width() : s.height(); }
164 QSplitterPData *data;
165 QWidgetList compressed_widgets;
169 friend class QSplitterPHandle;
170 private: // Disabled copy constructor and operator=
171 #if defined(Q_DISABLE_COPY)
172 QSplitterP( const QSplitterP & );
173 QSplitterP& operator=( const QSplitterP & );
177 #endif // QT_NO_COMPLEXWIDGETS
180 class Q_EXPORT QSplitterPHandle : public QWidget
184 QSplitterPHandle( Qt::Orientation o,
185 QSplitterP *parent, const char* name=0 );
186 void setOrientation( Qt::Orientation o );
187 Qt::Orientation orientation() const { return orient; }
189 bool opaque() const { return s->opaqueResize(); }
191 QSize sizeHint() const;
192 QSizePolicy sizePolicy() const;
194 int id() const { return myId; } // data->list.at(id())->wid == this
195 void setId( int i ) { myId = i; }
196 void updateButtonState();
198 // VSR 21/11/02 -> ================================
199 void compressAfter();
200 void unCompressAfter();
201 void compressBefore();
202 void unCompressBefore();
203 // VSR 21/11/02 <- ================================
206 void paintEvent( QPaintEvent * );
207 void mouseMoveEvent( QMouseEvent * );
208 void mousePressEvent( QMouseEvent * );
209 void mouseReleaseEvent( QMouseEvent * );
212 void onBeforeCompress();
213 void onAfterCompress();
214 void onBeforeUnCompress();
215 void onAfterUnCompress();
218 Qt::Orientation orient;
227 QPushButton* unright;
231 #endif // QSPLITTERP_H