summaryrefslogtreecommitdiffabout
path: root/microkde/KDGanttMinimizeSplitter.cpp
Unidiff
Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index 84edc0d..c60b566 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -1,473 +1,479 @@
1/* -*- Mode: C++ -*- 1/* -*- Mode: C++ -*-
2 $Id$ 2 $Id$
3*/ 3*/
4 4
5/**************************************************************************** 5/****************************************************************************
6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. 6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
7 ** 7 **
8 ** This file is part of the KDGantt library. 8 ** This file is part of the KDGantt library.
9 ** 9 **
10 ** This file may be distributed and/or modified under the terms of the 10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software 11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the 12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file. 13 ** packaging of this file.
14 ** 14 **
15 ** Licensees holding valid commercial KDGantt licenses may use this file in 15 ** Licensees holding valid commercial KDGantt licenses may use this file in
16 ** accordance with the KDGantt Commercial License Agreement provided with 16 ** accordance with the KDGantt Commercial License Agreement provided with
17 ** the Software. 17 ** the Software.
18 ** 18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 ** 21 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for 22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements. 23 ** information about KDGantt Commercial License Agreements.
24 ** 24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this 25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you. 26 ** licensing are not clear to you.
27 ** 27 **
28 ** As a special exception, permission is given to link this program 28 ** As a special exception, permission is given to link this program
29 ** with any edition of Qt, and distribute the resulting executable, 29 ** with any edition of Qt, and distribute the resulting executable,
30 ** without including the source code for Qt in the source distribution. 30 ** without including the source code for Qt in the source distribution.
31 ** 31 **
32 **********************************************************************/ 32 **********************************************************************/
33 33
34#include "KDGanttMinimizeSplitter.h" 34#include "KDGanttMinimizeSplitter.h"
35#ifndef QT_NO_SPLITTER___ 35#ifndef QT_NO_SPLITTER___
36 36
37#include "qpainter.h" 37#include "qpainter.h"
38#include "qdrawutil.h" 38#include "qdrawutil.h"
39#include "qbitmap.h" 39#include "qbitmap.h"
40#if QT_VERSION >= 0x030000 40#if QT_VERSION >= 0x030000
41#include "qptrlist.h" 41#include "qptrlist.h"
42#include "qmemarray.h" 42#include "qmemarray.h"
43#else 43#else
44#include <qlist.h> 44#include <qlist.h>
45#include <qarray.h> 45#include <qarray.h>
46#define QPtrList QList 46#define QPtrList QList
47#define QMemArray QArray 47#define QMemArray QArray
48#endif 48#endif
49#include "qlayoutengine_p.h" 49#include "qlayoutengine_p.h"
50#include "qobjectlist.h" 50#include "qobjectlist.h"
51#include "qstyle.h" 51#include "qstyle.h"
52#include "qapplication.h" //sendPostedEvents 52#include "qapplication.h" //sendPostedEvents
53#include <qvaluelist.h> 53#include <qvaluelist.h>
54#include <qcursor.h> 54#include <qcursor.h>
55#ifndef KDGANTT_MASTER_CVS 55#ifndef KDGANTT_MASTER_CVS
56//#include "KDGanttMinimizeSplitter.moc" 56//#include "KDGanttMinimizeSplitter.moc"
57#endif 57#endif
58 58
59 59
60 60
61#ifndef DOXYGEN_SKIP_INTERNAL 61#ifndef DOXYGEN_SKIP_INTERNAL
62 62
63#if QT_VERSION >= 232 63#if QT_VERSION >= 232
64static int mouseOffset; 64static int mouseOffset;
65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky 65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky
66 66
67 67
68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, 68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o,
69 KDGanttMinimizeSplitter *parent, const char * name ) 69 KDGanttMinimizeSplitter *parent, const char * name )
70 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) 70 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false )
71{ 71{
72 72
73 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { 73 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) {
74 mSizeHint = QSize(7,7); 74 mSizeHint = QSize(7,7);
75 mUseOffset = true; 75 mUseOffset = true;
76 } else { 76 } else {
77 mSizeHint = QSize(6,6); 77 mSizeHint = QSize(6,6);
78 mUseOffset = false; 78 mUseOffset = false;
79 } 79 }
80 s = parent; 80 s = parent;
81 setOrientation(o); 81 setOrientation(o);
82 setMouseTracking( true ); 82 setMouseTracking( true );
83 mMouseDown = false;
83 //setMaximumHeight( 5 ); // test only 84 //setMaximumHeight( 5 ); // test only
84} 85}
85 86
86QSize KDGanttSplitterHandle::sizeHint() const 87QSize KDGanttSplitterHandle::sizeHint() const
87{ 88{
88 return mSizeHint; 89 return mSizeHint;
89} 90}
90 91
91void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) 92void KDGanttSplitterHandle::setOrientation( Qt::Orientation o )
92{ 93{
93 orient = o; 94 orient = o;
94#ifndef QT_NO_CURSOR 95#ifndef QT_NO_CURSOR
95 if ( o == KDGanttMinimizeSplitter::Horizontal ) 96 if ( o == KDGanttMinimizeSplitter::Horizontal )
96 setCursor( splitHCursor ); 97 setCursor( splitHCursor );
97 else 98 else
98 setCursor( splitVCursor ); 99 setCursor( splitVCursor );
99#endif 100#endif
100} 101}
101 102
102 103
103void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) 104void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e )
104{ 105{
105 updateCursor( e->pos() ); 106 updateCursor( e->pos() );
106 if ( !(e->state()&LeftButton) ) 107 if ( !(e->state()&LeftButton) )
107 return; 108 return;
108 109
109 if ( _activeButton != 0) 110 if ( _activeButton != 0)
110 return; 111 return;
111 112
112 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 113 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
113 - mouseOffset; 114 - mouseOffset;
114 if ( true /*opaque()*/ ) { 115 if ( true /*opaque()*/ ) {
115 s->moveSplitter( pos, id() ); 116 s->moveSplitter( pos, id() );
116 } else { 117 } else {
117 int min = pos; int max = pos; 118 int min = pos; int max = pos;
118 s->getRange( id(), &min, &max ); 119 s->getRange( id(), &min, &max );
119 s->setRubberband( QMAX( min, QMIN(max, pos ))); 120 s->setRubberband( QMAX( min, QMIN(max, pos )));
120 } 121 }
121 _collapsed = false; 122 _collapsed = false;
122} 123}
123 124
124void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) 125void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e )
125{ 126{
126 if ( e->button() == LeftButton ) { 127 if ( e->button() == LeftButton ) {
127 _activeButton = onButton( e->pos() ); 128 _activeButton = onButton( e->pos() );
128 mouseOffset = s->pick(e->pos()); 129 mouseOffset = s->pick(e->pos());
129 if ( _activeButton != 0) 130 mMouseDown = true;
130 repaint(); 131 repaint();
131 updateCursor( e->pos() ); 132 updateCursor( e->pos() );
132 } 133 }
133} 134}
134 135
135void KDGanttSplitterHandle::updateCursor( const QPoint& p) 136void KDGanttSplitterHandle::updateCursor( const QPoint& p)
136{ 137{
137 if ( onButton( p ) != 0 ) { 138 if ( onButton( p ) != 0 ) {
138 setCursor( arrowCursor ); 139 setCursor( arrowCursor );
139 } 140 }
140 else { 141 else {
141 if ( orient == KDGanttMinimizeSplitter::Horizontal ) 142 if ( orient == KDGanttMinimizeSplitter::Horizontal )
142 setCursor( splitHCursor ); 143 setCursor( splitHCursor );
143 else 144 else
144 setCursor( splitVCursor ); 145 setCursor( splitVCursor );
145 } 146 }
146} 147}
147void KDGanttSplitterHandle::toggle() 148void KDGanttSplitterHandle::toggle()
148{ 149{
149 int pos; 150 int pos;
150 int min, max; 151 int min, max;
151 if ( !_collapsed ) { 152 if ( !_collapsed ) {
152 s->expandPos( id(), &min, &max ); 153 s->expandPos( id(), &min, &max );
153 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left 154 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left
154 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 155 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
155 pos = min; 156 pos = min;
156 } 157 }
157 else { 158 else {
158 pos = max; 159 pos = max;
159 } 160 }
160 161
161 _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); 162 _origPos = s->pick(mapToParent( QPoint( 0,0 ) ));
162 s->moveSplitter( pos, id() ); 163 s->moveSplitter( pos, id() );
163 _collapsed = true; 164 _collapsed = true;
164 } 165 }
165 else { 166 else {
166 s->moveSplitter( _origPos, id() ); 167 s->moveSplitter( _origPos, id() );
167 _collapsed = false; 168 _collapsed = false;
168 } 169 }
169 repaint(); 170 repaint();
170} 171}
171 172
172void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) 173void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
173{ 174{
175 mMouseDown = false;
174 if ( _activeButton != 0 ) { 176 if ( _activeButton != 0 ) {
175 if ( onButton( e->pos() ) == _activeButton ) 177 if ( onButton( e->pos() ) == _activeButton )
176 { 178 {
177 toggle(); 179 toggle();
178 } 180 }
179 _activeButton = 0; 181 _activeButton = 0;
180 updateCursor( e->pos() ); 182 updateCursor( e->pos() );
181 } 183 }
182 else { 184 else {
183 if ( !opaque() && e->button() == LeftButton ) { 185 if ( !opaque() && e->button() == LeftButton ) {
184 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 186 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
185 - mouseOffset; 187 - mouseOffset;
186 s->setRubberband( -1 ); 188 s->setRubberband( -1 );
187 s->moveSplitter( pos, id() ); 189 s->moveSplitter( pos, id() );
188 } 190 }
189 } 191 }
190 repaint(); 192 repaint();
191} 193}
192 194
193int KDGanttSplitterHandle::onButton( const QPoint& p ) 195int KDGanttSplitterHandle::onButton( const QPoint& p )
194{ 196{
195 QValueList<QPointArray> list = buttonRegions(); 197 QValueList<QPointArray> list = buttonRegions();
196 int index = 1; 198 int index = 1;
197 int add = 12; 199 int add = 12;
198 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 200 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
199 QRect rect = (*it).boundingRect(); 201 QRect rect = (*it).boundingRect();
200 rect.setLeft( rect.left()- add ); 202 rect.setLeft( rect.left()- add );
201 rect.setRight( rect.right() + add); 203 rect.setRight( rect.right() + add);
202 rect.setTop( rect.top()- add ); 204 rect.setTop( rect.top()- add );
203 rect.setBottom( rect.bottom() + add); 205 rect.setBottom( rect.bottom() + add);
204 if ( rect.contains( p ) ) { 206 if ( rect.contains( p ) ) {
205 return index; 207 return index;
206 } 208 }
207 index++; 209 index++;
208 } 210 }
209 return 0; 211 return 0;
210} 212}
211 213
212 214
213QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() 215QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions()
214{ 216{
215 QValueList<QPointArray> list; 217 QValueList<QPointArray> list;
216 218
217 int sw = 8; 219 int sw = 8;
218 int yyy = 1; 220 int yyy = 1;
219 int xxx = 1; 221 int xxx = 1;
220 int voffset[] = { (int) -sw*3, (int) sw*3 }; 222 int voffset[] = { (int) -sw*3, (int) sw*3 };
221 for ( int i = 0; i < 2; i++ ) { 223 for ( int i = 0; i < 2; i++ ) {
222 QPointArray arr; 224 QPointArray arr;
223 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || 225 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ||
224 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { 226 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) {
225 int mid = height()/2 + voffset[i]; 227 int mid = height()/2 + voffset[i];
226 arr.setPoints( 3, 228 arr.setPoints( 3,
227 1-xxx, mid - sw + 4, 229 1-xxx, mid - sw + 4,
228 sw-3-xxx, mid, 230 sw-3-xxx, mid,
229 1-xxx, mid + sw -4); 231 1-xxx, mid + sw -4);
230 } 232 }
231 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 233 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
232 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 234 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
233 int mid = height()/2 + voffset[i]; 235 int mid = height()/2 + voffset[i];
234 arr.setPoints( 3, 236 arr.setPoints( 3,
235 sw-4, mid - sw + 4, 237 sw-4, mid - sw + 4,
236 0, mid, 238 0, mid,
237 sw-4, mid + sw - 4); 239 sw-4, mid + sw - 4);
238 } 240 }
239 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 241 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
240 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { 242 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) {
241 int mid = width()/2 + voffset[i]; 243 int mid = width()/2 + voffset[i];
242 arr.setPoints( 3, 244 arr.setPoints( 3,
243 mid - sw + 4, sw-4, 245 mid - sw + 4, sw-4,
244 mid, 0, 246 mid, 0,
245 mid + sw - 4, sw-4 ); 247 mid + sw - 4, sw-4 );
246 } 248 }
247 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || 249 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down ||
248 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 250 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
249 int mid = width()/2 + voffset[i]; 251 int mid = width()/2 + voffset[i];
250 arr.setPoints( 3, 252 arr.setPoints( 3,
251 mid - sw + 4, 1-yyy, 253 mid - sw + 4, 1-yyy,
252 mid, sw-3-yyy, 254 mid, sw-3-yyy,
253 mid + sw -4, 1-yyy); 255 mid + sw -4, 1-yyy);
254 } 256 }
255 list.append( arr ); 257 list.append( arr );
256 } 258 }
257 return list; 259 return list;
258} 260}
259 261
260void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) 262void KDGanttSplitterHandle::paintEvent( QPaintEvent * )
261{ 263{
262 QPixmap buffer( size() ); 264 QPixmap buffer( size() );
263 QPainter p( &buffer ); 265 QPainter p( &buffer );
264 266
265 //LR 267 //LR
266 // Draw the splitter rectangle 268 // Draw the splitter rectangle
267 p.setBrush( colorGroup().background() ); 269 p.setBrush( colorGroup().background() );
268 p.setPen( colorGroup().foreground() ); 270 p.setPen( colorGroup().foreground() );
269 //p.drawRect( rect() ); 271 //p.drawRect( rect() );
270 buffer.fill( colorGroup().background() ); 272 buffer.fill( colorGroup().background() );
271 //buffer.fill( backgroundColor() ); 273 //buffer.fill( backgroundColor() );
272 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); 274 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup());
273 275
274 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size 276 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size
275 277
276 // arrow color 278 // arrow color
277 QColor col; 279 QColor col;
278 if ( _activeButton ) 280 if ( _activeButton )
279 col = colorGroup().background().dark( 250 ); 281 col = colorGroup().background().dark( 250 );
280 else 282 else {
281 col = colorGroup().background().dark( 150 ); 283 if ( mMouseDown )
284 col = Qt::white;
285 else
286 col = colorGroup().background().dark( 150 );
287 }
282 //QColor col = backgroundColor().dark( 130 ); 288 //QColor col = backgroundColor().dark( 130 );
283 p.setBrush( col ); 289 p.setBrush( col );
284 p.setPen( col ); 290 p.setPen( col );
285 291
286 QValueList<QPointArray> list = buttonRegions(); 292 QValueList<QPointArray> list = buttonRegions();
287 int index = 1; 293 int index = 1;
288 if ( mUseOffset ) 294 if ( mUseOffset )
289 p.translate( 0, 1 ); 295 p.translate( 0, 1 );
290 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 296 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
291 if ( index == _activeButton ) { 297 if ( index == _activeButton ) {
292 298
293 /* 299 /*
294 if ( ! _collapsed ) { 300 if ( ! _collapsed ) {
295 p.save(); 301 p.save();
296 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), 302 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ),
297 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); 303 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) );
298 p.translate( -1, 0 ); 304 p.translate( -1, 0 );
299 p.drawPolygon( *it, true ); 305 p.drawPolygon( *it, true );
300 p.restore(); } else 306 p.restore(); } else
301 */ 307 */
302 p.drawPolygon( *it, true ); 308 p.drawPolygon( *it, true );
303 309
304 } 310 }
305 else { 311 else {
306 /* 312 /*
307 if ( ! _collapsed ) { 313 if ( ! _collapsed ) {
308 p.save(); 314 p.save();
309 p.translate( -1, 0 ); 315 p.translate( -1, 0 );
310 p.drawPolygon( *it, true ); 316 p.drawPolygon( *it, true );
311 p.restore(); 317 p.restore();
312 } else 318 } else
313 */ 319 */
314 p.drawPolygon( *it, true ); 320 p.drawPolygon( *it, true );
315 321
316 } 322 }
317 index++; 323 index++;
318 } 324 }
319 325
320 // Draw the lines between the arrows 326 // Draw the lines between the arrows
321 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 327 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
322 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 328 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
323 int mid = height()/2; 329 int mid = height()/2;
324 p.drawLine ( 1, mid - sw, 1, mid + sw ); 330 p.drawLine ( 1, mid - sw, 1, mid + sw );
325 p.drawLine ( 3, mid - sw, 3, mid + sw ); 331 p.drawLine ( 3, mid - sw, 3, mid + sw );
326 } 332 }
327 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 333 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
328 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { 334 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) {
329 int mid = width()/2; 335 int mid = width()/2;
330 p.drawLine( mid -sw, 1, mid +sw, 1 ); 336 p.drawLine( mid -sw, 1, mid +sw, 1 );
331 p.drawLine( mid -sw, 3, mid +sw, 3 ); 337 p.drawLine( mid -sw, 3, mid +sw, 3 );
332 } 338 }
333 bitBlt( this, 0, 0, &buffer ); 339 bitBlt( this, 0, 0, &buffer );
334 340
335} 341}
336#endif 342#endif
337 343
338class QSplitterLayoutStruct 344class QSplitterLayoutStruct
339{ 345{
340public: 346public:
341 KDGanttMinimizeSplitter::ResizeMode mode; 347 KDGanttMinimizeSplitter::ResizeMode mode;
342 QCOORD sizer; 348 QCOORD sizer;
343 bool isSplitter; 349 bool isSplitter;
344 QWidget *wid; 350 QWidget *wid;
345}; 351};
346 352
347class QSplitterData 353class QSplitterData
348{ 354{
349public: 355public:
350 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} 356 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {}
351 357
352 QPtrList<QSplitterLayoutStruct> list; 358 QPtrList<QSplitterLayoutStruct> list;
353 bool opaque; 359 bool opaque;
354 bool firstShow; 360 bool firstShow;
355}; 361};
356 362
357void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 363void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos,
358 int space, int spacer ); 364 int space, int spacer );
359#endif // DOXYGEN_SKIP_INTERNAL 365#endif // DOXYGEN_SKIP_INTERNAL
360 366
361 367
362/*! 368/*!
363 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h 369 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h
364 \brief The KDGanttMinimizeSplitter class implements a splitter 370 \brief The KDGanttMinimizeSplitter class implements a splitter
365 widget with minimize buttons. 371 widget with minimize buttons.
366 372
367 This class (and its documentation) is largely a copy of Qt's 373 This class (and its documentation) is largely a copy of Qt's
368 QSplitter; the copying was necessary because QSplitter is not 374 QSplitter; the copying was necessary because QSplitter is not
369 extensible at all. QSplitter and its documentation are licensed 375 extensible at all. QSplitter and its documentation are licensed
370 according to the GPL and the Qt Professional License (if you hold 376 according to the GPL and the Qt Professional License (if you hold
371 such a license) and are (C) Trolltech AS. 377 such a license) and are (C) Trolltech AS.
372 378
373 A splitter lets the user control the size of child widgets by 379 A splitter lets the user control the size of child widgets by
374 dragging the boundary between the children. Any number of widgets 380 dragging the boundary between the children. Any number of widgets
375 may be controlled. 381 may be controlled.
376 382
377 To show a QListBox, a QListView and a QTextEdit side by side: 383 To show a QListBox, a QListView and a QTextEdit side by side:
378 384
379 \code 385 \code
380 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); 386 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent );
381 QListBox *lb = new QListBox( split ); 387 QListBox *lb = new QListBox( split );
382 QListView *lv = new QListView( split ); 388 QListView *lv = new QListView( split );
383 QTextEdit *ed = new QTextEdit( split ); 389 QTextEdit *ed = new QTextEdit( split );
384 \endcode 390 \endcode
385 391
386 In KDGanttMinimizeSplitter, the boundary can be either horizontal or 392 In KDGanttMinimizeSplitter, the boundary can be either horizontal or
387 vertical. The default is horizontal (the children are side by side) 393 vertical. The default is horizontal (the children are side by side)
388 but you can use setOrientation( QSplitter::Vertical ) to set it to 394 but you can use setOrientation( QSplitter::Vertical ) to set it to
389 vertical. 395 vertical.
390 396
391 Use setResizeMode() to specify 397 Use setResizeMode() to specify
392 that a widget should keep its size when the splitter is resized. 398 that a widget should keep its size when the splitter is resized.
393 399
394 Although KDGanttMinimizeSplitter normally resizes the children only 400 Although KDGanttMinimizeSplitter normally resizes the children only
395 at the end of a resize operation, if you call setOpaqueResize( TRUE 401 at the end of a resize operation, if you call setOpaqueResize( TRUE
396 ) the widgets are resized as often as possible. 402 ) the widgets are resized as often as possible.
397 403
398 The initial distribution of size between the widgets is determined 404 The initial distribution of size between the widgets is determined
399 by the initial size of each widget. You can also use setSizes() to 405 by the initial size of each widget. You can also use setSizes() to
400 set the sizes of all the widgets. The function sizes() returns the 406 set the sizes of all the widgets. The function sizes() returns the
401 sizes set by the user. 407 sizes set by the user.
402 408
403 If you hide() a child, its space will be distributed among the other 409 If you hide() a child, its space will be distributed among the other
404 children. It will be reinstated when you show() it again. It is also 410 children. It will be reinstated when you show() it again. It is also
405 possible to reorder the widgets within the splitter using 411 possible to reorder the widgets within the splitter using
406 moveToFirst() and moveToLast(). 412 moveToFirst() and moveToLast().
407*/ 413*/
408 414
409 415
410 416
411static QSize minSize( const QWidget* /*w*/ ) 417static QSize minSize( const QWidget* /*w*/ )
412{ 418{
413 return QSize(0,0); 419 return QSize(0,0);
414} 420}
415 421
416// This is the original version of minSize 422// This is the original version of minSize
417static QSize minSizeHint( const QWidget* w ) 423static QSize minSizeHint( const QWidget* w )
418{ 424{
419 QSize min = w->minimumSize(); 425 QSize min = w->minimumSize();
420 QSize s; 426 QSize s;
421 if ( min.height() <= 0 || min.width() <= 0 ) 427 if ( min.height() <= 0 || min.width() <= 0 )
422 s = w->minimumSizeHint(); 428 s = w->minimumSizeHint();
423 if ( min.height() > 0 ) 429 if ( min.height() > 0 )
424 s.setHeight( min.height() ); 430 s.setHeight( min.height() );
425 if ( min.width() > 0 ) 431 if ( min.width() > 0 )
426 s.setWidth( min.width() ); 432 s.setWidth( min.width() );
427 return s.expandedTo(QSize(0,0)); 433 return s.expandedTo(QSize(0,0));
428} 434}
429 435
430 436
431 437
432/*! 438/*!
433 Constructs a horizontal splitter with the \a parent and \a 439 Constructs a horizontal splitter with the \a parent and \a
434 name arguments being passed on to the QFrame constructor. 440 name arguments being passed on to the QFrame constructor.
435*/ 441*/
436KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) 442KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name )
437 :QFrame(parent,name,WPaintUnclipped) 443 :QFrame(parent,name,WPaintUnclipped)
438{ 444{
439 mFirstHandle = 0; 445 mFirstHandle = 0;
440#if QT_VERSION >= 232 446#if QT_VERSION >= 232
441 orient = Horizontal; 447 orient = Horizontal;
442 init(); 448 init();
443#endif 449#endif
444} 450}
445 451
446/*! 452/*!
447 Constructs a splitter with orientation \a o with the \a parent 453 Constructs a splitter with orientation \a o with the \a parent
448 and \a name arguments being passed on to the QFrame constructor. 454 and \a name arguments being passed on to the QFrame constructor.
449*/ 455*/
450KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) 456KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name )
451 :QFrame(parent,name,WPaintUnclipped) 457 :QFrame(parent,name,WPaintUnclipped)
452{ 458{
453 mFirstHandle = 0; 459 mFirstHandle = 0;
454#if QT_VERSION >= 232 460#if QT_VERSION >= 232
455 orient = o; 461 orient = o;
456 init(); 462 init();
457#endif 463#endif
458} 464}
459 465
460/*! 466/*!
461 Destroys the splitter and any children. 467 Destroys the splitter and any children.
462*/ 468*/
463KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() 469KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter()
464{ 470{
465#if QT_VERSION >= 232 471#if QT_VERSION >= 232
466 data->list.setAutoDelete( TRUE ); 472 data->list.setAutoDelete( TRUE );
467 delete data; 473 delete data;
468#endif 474#endif
469} 475}
470 476
471 477
472#if QT_VERSION >= 232 478#if QT_VERSION >= 232
473void KDGanttMinimizeSplitter::init() 479void KDGanttMinimizeSplitter::init()