Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 2a30346..fb5d4e3 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -83,385 +83,385 @@ KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, | |||
83 | mMouseDown = false; | 83 | mMouseDown = false; |
84 | //setMaximumHeight( 5 ); // test only | 84 | //setMaximumHeight( 5 ); // test only |
85 | } | 85 | } |
86 | 86 | ||
87 | QSize KDGanttSplitterHandle::sizeHint() const | 87 | QSize KDGanttSplitterHandle::sizeHint() const |
88 | { | 88 | { |
89 | return mSizeHint; | 89 | return mSizeHint; |
90 | } | 90 | } |
91 | 91 | ||
92 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) | 92 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) |
93 | { | 93 | { |
94 | orient = o; | 94 | orient = o; |
95 | #ifndef QT_NO_CURSOR | 95 | #ifndef QT_NO_CURSOR |
96 | if ( o == KDGanttMinimizeSplitter::Horizontal ) | 96 | if ( o == KDGanttMinimizeSplitter::Horizontal ) |
97 | setCursor( splitHCursor ); | 97 | setCursor( splitHCursor ); |
98 | else | 98 | else |
99 | setCursor( splitVCursor ); | 99 | setCursor( splitVCursor ); |
100 | #endif | 100 | #endif |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | 104 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) |
105 | { | 105 | { |
106 | updateCursor( e->pos() ); | 106 | updateCursor( e->pos() ); |
107 | if ( !(e->state()&LeftButton) ) | 107 | if ( !(e->state()&LeftButton) ) |
108 | return; | 108 | return; |
109 | 109 | ||
110 | if ( _activeButton != 0) | 110 | if ( _activeButton != 0) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 113 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
114 | - mouseOffset; | 114 | - mouseOffset; |
115 | if ( opaque() ) { | 115 | if ( opaque() ) { |
116 | s->moveSplitter( pos, id() ); | 116 | s->moveSplitter( pos, id() ); |
117 | } else { | 117 | } else { |
118 | int min = pos; int max = pos; | 118 | int min = pos; int max = pos; |
119 | s->getRange( id(), &min, &max ); | 119 | s->getRange( id(), &min, &max ); |
120 | s->setRubberband( QMAX( min, QMIN(max, pos ))); | 120 | s->setRubberband( QMAX( min, QMIN(max, pos ))); |
121 | } | 121 | } |
122 | _collapsed = false; | 122 | _collapsed = false; |
123 | } | 123 | } |
124 | 124 | ||
125 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) | 125 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) |
126 | { | 126 | { |
127 | if ( e->button() == LeftButton ) { | 127 | if ( e->button() == LeftButton ) { |
128 | _activeButton = onButton( e->pos() ); | 128 | _activeButton = onButton( e->pos() ); |
129 | mouseOffset = s->pick(e->pos()); | 129 | mouseOffset = s->pick(e->pos()); |
130 | mMouseDown = true; | 130 | mMouseDown = true; |
131 | repaint(); | 131 | repaint(); |
132 | updateCursor( e->pos() ); | 132 | updateCursor( e->pos() ); |
133 | } | 133 | } |
134 | } | 134 | } |
135 | 135 | ||
136 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) | 136 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) |
137 | { | 137 | { |
138 | if ( onButton( p ) != 0 ) { | 138 | if ( onButton( p ) != 0 ) { |
139 | setCursor( arrowCursor ); | 139 | setCursor( arrowCursor ); |
140 | } | 140 | } |
141 | else { | 141 | else { |
142 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) | 142 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) |
143 | setCursor( splitHCursor ); | 143 | setCursor( splitHCursor ); |
144 | else | 144 | else |
145 | setCursor( splitVCursor ); | 145 | setCursor( splitVCursor ); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | void KDGanttSplitterHandle::toggle() | 148 | void KDGanttSplitterHandle::toggle() |
149 | { | 149 | { |
150 | int pos; | 150 | int pos; |
151 | int min, max; | 151 | int min, max; |
152 | if ( !_collapsed ) { | 152 | if ( !_collapsed ) { |
153 | s->expandPos( id(), &min, &max ); | 153 | s->expandPos( id(), &min, &max ); |
154 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left | 154 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left |
155 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { | 155 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { |
156 | pos = min; | 156 | pos = min; |
157 | } | 157 | } |
158 | else { | 158 | else { |
159 | pos = max; | 159 | pos = max; |
160 | } | 160 | } |
161 | 161 | ||
162 | _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); | 162 | _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); |
163 | s->moveSplitter( pos, id() ); | 163 | s->moveSplitter( pos, id() ); |
164 | _collapsed = true; | 164 | _collapsed = true; |
165 | } | 165 | } |
166 | else { | 166 | else { |
167 | s->moveSplitter( _origPos, id() ); | 167 | s->moveSplitter( _origPos, id() ); |
168 | _collapsed = false; | 168 | _collapsed = false; |
169 | } | 169 | } |
170 | repaint(); | 170 | repaint(); |
171 | } | 171 | } |
172 | 172 | ||
173 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | 173 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) |
174 | { | 174 | { |
175 | mMouseDown = false; | 175 | mMouseDown = false; |
176 | if ( _activeButton != 0 ) { | 176 | if ( _activeButton != 0 ) { |
177 | if ( onButton( e->pos() ) == _activeButton ) | 177 | if ( onButton( e->pos() ) == _activeButton ) |
178 | { | 178 | { |
179 | toggle(); | 179 | toggle(); |
180 | } | 180 | } |
181 | _activeButton = 0; | 181 | _activeButton = 0; |
182 | updateCursor( e->pos() ); | 182 | updateCursor( e->pos() ); |
183 | } | 183 | } |
184 | else { | 184 | else { |
185 | if ( !opaque() && e->button() == LeftButton ) { | 185 | if ( !opaque() && e->button() == LeftButton ) { |
186 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 186 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
187 | - mouseOffset; | 187 | - mouseOffset; |
188 | s->setRubberband( -1 ); | 188 | s->setRubberband( -1 ); |
189 | s->moveSplitter( pos, id() ); | 189 | s->moveSplitter( pos, id() ); |
190 | } | 190 | } |
191 | } | 191 | } |
192 | if ( s->rubberBand() ) | 192 | if ( s->rubberBand() ) |
193 | s->rubberBand()->hide(); | 193 | s->rubberBand()->hide(); |
194 | repaint(); | 194 | repaint(); |
195 | } | 195 | } |
196 | 196 | ||
197 | int KDGanttSplitterHandle::onButton( const QPoint& p ) | 197 | int KDGanttSplitterHandle::onButton( const QPoint& p ) |
198 | { | 198 | { |
199 | QValueList<QPointArray> list = buttonRegions(); | 199 | QValueList<QPointArray> list = buttonRegions(); |
200 | int index = 1; | 200 | int index = 1; |
201 | int add = 12; | 201 | int add = 12; |
202 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 202 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
203 | QRect rect = (*it).boundingRect(); | 203 | QRect rect = (*it).boundingRect(); |
204 | rect.setLeft( rect.left()- add ); | 204 | rect.setLeft( rect.left()- add ); |
205 | rect.setRight( rect.right() + add); | 205 | rect.setRight( rect.right() + add); |
206 | rect.setTop( rect.top()- add ); | 206 | rect.setTop( rect.top()- add ); |
207 | rect.setBottom( rect.bottom() + add); | 207 | rect.setBottom( rect.bottom() + add); |
208 | if ( rect.contains( p ) ) { | 208 | if ( rect.contains( p ) ) { |
209 | return index; | 209 | return index; |
210 | } | 210 | } |
211 | index++; | 211 | index++; |
212 | } | 212 | } |
213 | return 0; | 213 | return 0; |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() | 217 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() |
218 | { | 218 | { |
219 | QValueList<QPointArray> list; | 219 | QValueList<QPointArray> list; |
220 | 220 | ||
221 | int sw = 8; | 221 | int sw = 8; |
222 | int yyy = 1; | 222 | int yyy = 1; |
223 | int xxx = 1; | 223 | int xxx = 1; |
224 | int voffset[] = { (int) -sw*3, (int) sw*3 }; | 224 | int voffset[] = { (int) -sw*3, (int) sw*3 }; |
225 | for ( int i = 0; i < 2; i++ ) { | 225 | for ( int i = 0; i < 2; i++ ) { |
226 | QPointArray arr; | 226 | QPointArray arr; |
227 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || | 227 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || |
228 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { | 228 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { |
229 | int mid = height()/2 + voffset[i]; | 229 | int mid = height()/2 + voffset[i]; |
230 | arr.setPoints( 3, | 230 | arr.setPoints( 3, |
231 | 1-xxx, mid - sw + 4, | 231 | 1-xxx, mid - sw + 4, |
232 | sw-3-xxx, mid, | 232 | sw-3-xxx, mid, |
233 | 1-xxx, mid + sw -4); | 233 | 1-xxx, mid + sw -4); |
234 | } | 234 | } |
235 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 235 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
236 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 236 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
237 | int mid = height()/2 + voffset[i]; | 237 | int mid = height()/2 + voffset[i]; |
238 | arr.setPoints( 3, | 238 | arr.setPoints( 3, |
239 | sw-4, mid - sw + 4, | 239 | sw-4, mid - sw + 4, |
240 | 0, mid, | 240 | 0, mid, |
241 | sw-4, mid + sw - 4); | 241 | sw-4, mid + sw - 4); |
242 | } | 242 | } |
243 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || | 243 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || |
244 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { | 244 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { |
245 | int mid = width()/2 + voffset[i]; | 245 | int mid = width()/2 + voffset[i]; |
246 | arr.setPoints( 3, | 246 | arr.setPoints( 3, |
247 | mid - sw + 4, sw-4, | 247 | mid - sw + 4, sw-4, |
248 | mid, 0, | 248 | mid, 0, |
249 | mid + sw - 4, sw-4 ); | 249 | mid + sw - 4, sw-4 ); |
250 | } | 250 | } |
251 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || | 251 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || |
252 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { | 252 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { |
253 | int mid = width()/2 + voffset[i]; | 253 | int mid = width()/2 + voffset[i]; |
254 | arr.setPoints( 3, | 254 | arr.setPoints( 3, |
255 | mid - sw + 4, 1-yyy, | 255 | mid - sw + 4, 1-yyy, |
256 | mid, sw-3-yyy, | 256 | mid, sw-3-yyy, |
257 | mid + sw -4, 1-yyy); | 257 | mid + sw -4, 1-yyy); |
258 | } | 258 | } |
259 | list.append( arr ); | 259 | list.append( arr ); |
260 | } | 260 | } |
261 | return list; | 261 | return list; |
262 | } | 262 | } |
263 | 263 | ||
264 | void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) | 264 | void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) |
265 | { | 265 | { |
266 | QPixmap buffer( size() ); | 266 | QPixmap buffer( size() ); |
267 | QPainter p( &buffer ); | 267 | QPainter p( &buffer ); |
268 | 268 | ||
269 | //LR | 269 | //LR |
270 | // Draw the splitter rectangle | 270 | // Draw the splitter rectangle |
271 | p.setBrush( colorGroup().background() ); | 271 | p.setBrush( colorGroup().background() ); |
272 | p.setPen( colorGroup().foreground() ); | 272 | p.setPen( colorGroup().foreground() ); |
273 | //p.drawRect( rect() ); | 273 | //p.drawRect( rect() ); |
274 | #ifndef DESKTOP_VERSION | 274 | #ifndef DESKTOP_VERSION |
275 | if ( mMouseDown ) | 275 | if ( mMouseDown && ! _activeButton) |
276 | buffer.fill( colorGroup().background().dark() ); | 276 | buffer.fill( colorGroup().background().dark() ); |
277 | else | 277 | else |
278 | #endif | 278 | #endif |
279 | buffer.fill( colorGroup().background() ); | 279 | buffer.fill( colorGroup().background() ); |
280 | //buffer.fill( backgroundColor() ); | 280 | //buffer.fill( backgroundColor() ); |
281 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); | 281 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); |
282 | 282 | ||
283 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size | 283 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size |
284 | 284 | ||
285 | // arrow color | 285 | // arrow color |
286 | QColor col; | 286 | QColor col; |
287 | if ( _activeButton ) | 287 | if ( _activeButton ) |
288 | col = colorGroup().background().dark( 250 ); | 288 | col = colorGroup().background().dark( 250 ); |
289 | else { | 289 | else { |
290 | if ( mMouseDown ) | 290 | if ( mMouseDown ) |
291 | col = Qt::white; | 291 | col = Qt::white; |
292 | else | 292 | else |
293 | col = colorGroup().background().dark( 150 ); | 293 | col = colorGroup().background().dark( 150 ); |
294 | } | 294 | } |
295 | //QColor col = backgroundColor().dark( 130 ); | 295 | //QColor col = backgroundColor().dark( 130 ); |
296 | p.setBrush( col ); | 296 | p.setBrush( col ); |
297 | p.setPen( col ); | 297 | p.setPen( col ); |
298 | 298 | ||
299 | QValueList<QPointArray> list = buttonRegions(); | 299 | QValueList<QPointArray> list = buttonRegions(); |
300 | int index = 1; | 300 | int index = 1; |
301 | if ( mUseOffset ) | 301 | if ( mUseOffset ) |
302 | p.translate( 0, 1 ); | 302 | p.translate( 0, 1 ); |
303 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 303 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
304 | if ( index == _activeButton ) { | 304 | if ( index == _activeButton ) { |
305 | 305 | ||
306 | /* | 306 | /* |
307 | if ( ! _collapsed ) { | 307 | if ( ! _collapsed ) { |
308 | p.save(); | 308 | p.save(); |
309 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), | 309 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), |
310 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); | 310 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); |
311 | p.translate( -1, 0 ); | 311 | p.translate( -1, 0 ); |
312 | p.drawPolygon( *it, true ); | 312 | p.drawPolygon( *it, true ); |
313 | p.restore(); } else | 313 | p.restore(); } else |
314 | */ | 314 | */ |
315 | p.drawPolygon( *it, true ); | 315 | p.drawPolygon( *it, true ); |
316 | 316 | ||
317 | } | 317 | } |
318 | else { | 318 | else { |
319 | /* | 319 | /* |
320 | if ( ! _collapsed ) { | 320 | if ( ! _collapsed ) { |
321 | p.save(); | 321 | p.save(); |
322 | p.translate( -1, 0 ); | 322 | p.translate( -1, 0 ); |
323 | p.drawPolygon( *it, true ); | 323 | p.drawPolygon( *it, true ); |
324 | p.restore(); | 324 | p.restore(); |
325 | } else | 325 | } else |
326 | */ | 326 | */ |
327 | p.drawPolygon( *it, true ); | 327 | p.drawPolygon( *it, true ); |
328 | 328 | ||
329 | } | 329 | } |
330 | index++; | 330 | index++; |
331 | } | 331 | } |
332 | 332 | ||
333 | // Draw the lines between the arrows | 333 | // Draw the lines between the arrows |
334 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 334 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
335 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 335 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
336 | int mid = height()/2; | 336 | int mid = height()/2; |
337 | p.drawLine ( 1, mid - sw, 1, mid + sw ); | 337 | p.drawLine ( 1, mid - sw, 1, mid + sw ); |
338 | p.drawLine ( 3, mid - sw, 3, mid + sw ); | 338 | p.drawLine ( 3, mid - sw, 3, mid + sw ); |
339 | } | 339 | } |
340 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || | 340 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || |
341 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { | 341 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { |
342 | int mid = width()/2; | 342 | int mid = width()/2; |
343 | p.drawLine( mid -sw, 1, mid +sw, 1 ); | 343 | p.drawLine( mid -sw, 1, mid +sw, 1 ); |
344 | p.drawLine( mid -sw, 3, mid +sw, 3 ); | 344 | p.drawLine( mid -sw, 3, mid +sw, 3 ); |
345 | } | 345 | } |
346 | bitBlt( this, 0, 0, &buffer ); | 346 | bitBlt( this, 0, 0, &buffer ); |
347 | 347 | ||
348 | } | 348 | } |
349 | #endif | 349 | #endif |
350 | 350 | ||
351 | class QSplitterLayoutStruct | 351 | class QSplitterLayoutStruct |
352 | { | 352 | { |
353 | public: | 353 | public: |
354 | KDGanttMinimizeSplitter::ResizeMode mode; | 354 | KDGanttMinimizeSplitter::ResizeMode mode; |
355 | QCOORD sizer; | 355 | QCOORD sizer; |
356 | bool isSplitter; | 356 | bool isSplitter; |
357 | QWidget *wid; | 357 | QWidget *wid; |
358 | }; | 358 | }; |
359 | 359 | ||
360 | class QSplitterData | 360 | class QSplitterData |
361 | { | 361 | { |
362 | public: | 362 | public: |
363 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} | 363 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} |
364 | 364 | ||
365 | QPtrList<QSplitterLayoutStruct> list; | 365 | QPtrList<QSplitterLayoutStruct> list; |
366 | bool opaque; | 366 | bool opaque; |
367 | bool firstShow; | 367 | bool firstShow; |
368 | }; | 368 | }; |
369 | 369 | ||
370 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, | 370 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, |
371 | int space, int spacer ); | 371 | int space, int spacer ); |
372 | #endif // DOXYGEN_SKIP_INTERNAL | 372 | #endif // DOXYGEN_SKIP_INTERNAL |
373 | 373 | ||
374 | 374 | ||
375 | /*! | 375 | /*! |
376 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h | 376 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h |
377 | \brief The KDGanttMinimizeSplitter class implements a splitter | 377 | \brief The KDGanttMinimizeSplitter class implements a splitter |
378 | widget with minimize buttons. | 378 | widget with minimize buttons. |
379 | 379 | ||
380 | This class (and its documentation) is largely a copy of Qt's | 380 | This class (and its documentation) is largely a copy of Qt's |
381 | QSplitter; the copying was necessary because QSplitter is not | 381 | QSplitter; the copying was necessary because QSplitter is not |
382 | extensible at all. QSplitter and its documentation are licensed | 382 | extensible at all. QSplitter and its documentation are licensed |
383 | according to the GPL and the Qt Professional License (if you hold | 383 | according to the GPL and the Qt Professional License (if you hold |
384 | such a license) and are (C) Trolltech AS. | 384 | such a license) and are (C) Trolltech AS. |
385 | 385 | ||
386 | A splitter lets the user control the size of child widgets by | 386 | A splitter lets the user control the size of child widgets by |
387 | dragging the boundary between the children. Any number of widgets | 387 | dragging the boundary between the children. Any number of widgets |
388 | may be controlled. | 388 | may be controlled. |
389 | 389 | ||
390 | To show a QListBox, a QListView and a QTextEdit side by side: | 390 | To show a QListBox, a QListView and a QTextEdit side by side: |
391 | 391 | ||
392 | \code | 392 | \code |
393 | KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); | 393 | KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); |
394 | QListBox *lb = new QListBox( split ); | 394 | QListBox *lb = new QListBox( split ); |
395 | QListView *lv = new QListView( split ); | 395 | QListView *lv = new QListView( split ); |
396 | QTextEdit *ed = new QTextEdit( split ); | 396 | QTextEdit *ed = new QTextEdit( split ); |
397 | \endcode | 397 | \endcode |
398 | 398 | ||
399 | In KDGanttMinimizeSplitter, the boundary can be either horizontal or | 399 | In KDGanttMinimizeSplitter, the boundary can be either horizontal or |
400 | vertical. The default is horizontal (the children are side by side) | 400 | vertical. The default is horizontal (the children are side by side) |
401 | but you can use setOrientation( QSplitter::Vertical ) to set it to | 401 | but you can use setOrientation( QSplitter::Vertical ) to set it to |
402 | vertical. | 402 | vertical. |
403 | 403 | ||
404 | Use setResizeMode() to specify | 404 | Use setResizeMode() to specify |
405 | that a widget should keep its size when the splitter is resized. | 405 | that a widget should keep its size when the splitter is resized. |
406 | 406 | ||
407 | Although KDGanttMinimizeSplitter normally resizes the children only | 407 | Although KDGanttMinimizeSplitter normally resizes the children only |
408 | at the end of a resize operation, if you call setOpaqueResize( TRUE | 408 | at the end of a resize operation, if you call setOpaqueResize( TRUE |
409 | ) the widgets are resized as often as possible. | 409 | ) the widgets are resized as often as possible. |
410 | 410 | ||
411 | The initial distribution of size between the widgets is determined | 411 | The initial distribution of size between the widgets is determined |
412 | by the initial size of each widget. You can also use setSizes() to | 412 | by the initial size of each widget. You can also use setSizes() to |
413 | set the sizes of all the widgets. The function sizes() returns the | 413 | set the sizes of all the widgets. The function sizes() returns the |
414 | sizes set by the user. | 414 | sizes set by the user. |
415 | 415 | ||
416 | If you hide() a child, its space will be distributed among the other | 416 | If you hide() a child, its space will be distributed among the other |
417 | children. It will be reinstated when you show() it again. It is also | 417 | children. It will be reinstated when you show() it again. It is also |
418 | possible to reorder the widgets within the splitter using | 418 | possible to reorder the widgets within the splitter using |
419 | moveToFirst() and moveToLast(). | 419 | moveToFirst() and moveToLast(). |
420 | */ | 420 | */ |
421 | 421 | ||
422 | 422 | ||
423 | 423 | ||
424 | static QSize minSize( const QWidget* /*w*/ ) | 424 | static QSize minSize( const QWidget* /*w*/ ) |
425 | { | 425 | { |
426 | return QSize(0,0); | 426 | return QSize(0,0); |
427 | } | 427 | } |
428 | 428 | ||
429 | // This is the original version of minSize | 429 | // This is the original version of minSize |
430 | static QSize minSizeHint( const QWidget* w ) | 430 | static QSize minSizeHint( const QWidget* w ) |
431 | { | 431 | { |
432 | QSize min = w->minimumSize(); | 432 | QSize min = w->minimumSize(); |
433 | QSize s; | 433 | QSize s; |
434 | if ( min.height() <= 0 || min.width() <= 0 ) | 434 | if ( min.height() <= 0 || min.width() <= 0 ) |
435 | s = w->minimumSizeHint(); | 435 | s = w->minimumSizeHint(); |
436 | if ( min.height() > 0 ) | 436 | if ( min.height() > 0 ) |
437 | s.setHeight( min.height() ); | 437 | s.setHeight( min.height() ); |
438 | if ( min.width() > 0 ) | 438 | if ( min.width() > 0 ) |
439 | s.setWidth( min.width() ); | 439 | s.setWidth( min.width() ); |
440 | return s.expandedTo(QSize(0,0)); | 440 | return s.expandedTo(QSize(0,0)); |
441 | } | 441 | } |
442 | 442 | ||
443 | 443 | ||
444 | /*! | 444 | /*! |
445 | Constructs a horizontal splitter with the \a parent and \a | 445 | Constructs a horizontal splitter with the \a parent and \a |
446 | name arguments being passed on to the QFrame constructor. | 446 | name arguments being passed on to the QFrame constructor. |
447 | */ | 447 | */ |
448 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) | 448 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) |
449 | :QFrame(parent,name,WPaintUnclipped) | 449 | :QFrame(parent,name,WPaintUnclipped) |
450 | { | 450 | { |
451 | mRubberBand = 0; | 451 | mRubberBand = 0; |
452 | mFirstHandle = 0; | 452 | mFirstHandle = 0; |
453 | #if QT_VERSION >= 232 | 453 | #if QT_VERSION >= 232 |
454 | orient = Horizontal; | 454 | orient = Horizontal; |
455 | init(); | 455 | init(); |
456 | #endif | 456 | #endif |
457 | } | 457 | } |
458 | 458 | ||
459 | /*! | 459 | /*! |
460 | Constructs a splitter with orientation \a o with the \a parent | 460 | Constructs a splitter with orientation \a o with the \a parent |
461 | and \a name arguments being passed on to the QFrame constructor. | 461 | and \a name arguments being passed on to the QFrame constructor. |
462 | */ | 462 | */ |
463 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) | 463 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) |
464 | :QFrame(parent,name,WPaintUnclipped) | 464 | :QFrame(parent,name,WPaintUnclipped) |
465 | { | 465 | { |
466 | 466 | ||
467 | mRubberBand = 0; | 467 | mRubberBand = 0; |