Salome HOME
Initialisation de la base KERNEL avec la version operationnelle de KERNEL_SRC issue...
[modules/kernel.git] / src / PatchQt / qsplitterP.h
1 /****************************************************************************
2 ** $Id$
3 **
4 ** Defintion 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 #ifndef QSPLITTERP_H
38 #define QSPLITTERP_H
39
40 #ifndef QT_H
41 #include <qframe.h>
42 #include <qvaluelist.h>
43 #include <qwidgetlist.h>        // by STV
44 #endif // QT_H
45 #include <qpushbutton.h>
46
47 #ifndef QT_NO_COMPLEXWIDGETS
48
49 class QSplitterPHandle;
50 class QSplitterPData;
51 class QSplitterPLayoutStruct;
52
53 class Q_EXPORT QSplitterP : public QFrame
54 {
55     Q_OBJECT
56     Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
57       
58 public:
59     enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
60
61     QSplitterP( QWidget *parent=0, const char *name=0 );
62     QSplitterP( Orientation, QWidget *parent=0, const char *name=0 );
63     ~QSplitterP();
64
65     virtual void setOrientation( Orientation );
66     Orientation orientation() const { return orient; }
67
68     virtual void setResizeMode( QWidget *w, ResizeMode );
69     virtual void setOpaqueResize( bool = TRUE );
70     bool opaqueResize() const;
71
72     void moveToFirst( QWidget * );
73     void moveToLast( QWidget * );
74
75     void refresh() { recalc( TRUE ); }
76     QSize sizeHint() const;
77     QSize minimumSizeHint() const;
78     QSizePolicy sizePolicy() const;
79
80     QValueList<int> sizes() const;
81     void setSizes( QValueList<int> );
82     bool isCompressEnabled() const;
83     void setCompressEnabled(bool on);
84
85     void compress(QWidget*);
86     void unCompress(QWidget*);
87
88 // VSR 21/11/02 -> ================================
89     QSplitterPHandle* getHandleAfter(QWidget* w);
90     QSplitterPHandle* getHandleBefore(QWidget* w);
91 // VSR 21/11/02 <- ================================
92
93 protected:
94     void childEvent( QChildEvent * );
95
96     bool event( QEvent * );
97     void resizeEvent( QResizeEvent * );
98
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;
105     
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* );
113
114 private:
115     void init();
116     void recalc( bool update = FALSE );
117     int hit( QPoint p );
118     void doResize();
119     void storeSizes();
120     void processChildEvents();
121     QSplitterPLayoutStruct *addWidget( QWidget*, bool first = FALSE );
122     void recalcId();
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;
127
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(); }
132
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(); }
137
138     QSplitterPData *data;
139     QWidgetList compressed_widgets;
140
141     Orientation orient;
142     bool compress_flag;
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 & );
148 #endif
149 };
150
151 #endif // QT_NO_COMPLEXWIDGETS
152
153
154 class Q_EXPORT QSplitterPHandle : public QWidget
155 {
156   Q_OBJECT
157 public:
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; }
162   
163     bool opaque() const { return s->opaqueResize(); }
164
165     QSize sizeHint() const;
166     QSizePolicy sizePolicy() const;
167
168     int id() const { return myId; } // data->list.at(id())->wid == this
169     void setId( int i ) { myId = i; }
170     void updateButtonState();
171
172 // VSR 21/11/02 -> ================================
173     void compressAfter();
174     void unCompressAfter();
175     void compressBefore();
176     void unCompressBefore();
177 // VSR 21/11/02 <- ================================
178
179 protected:
180     void paintEvent( QPaintEvent * );
181     void mouseMoveEvent( QMouseEvent * );
182     void mousePressEvent( QMouseEvent * );
183     void mouseReleaseEvent( QMouseEvent * );
184
185 protected slots:
186     void onBeforeCompress();
187     void onAfterCompress();
188     void onBeforeUnCompress();
189     void onAfterUnCompress();
190
191 private:
192     Qt::Orientation orient;
193     bool opaq;
194     int myId;
195
196     QSplitterP *s;
197     int oldpos;
198     QPushButton* left;
199     QPushButton* right;
200     QPushButton* unleft;
201     QPushButton* unright;
202 };
203
204
205 #endif // QSPLITTERP_H