Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 6cb1f31..253175e 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -146,269 +146,278 @@ void KDGanttSplitterHandle::updateCursor( const QPoint& p) | |||
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 | buffer.fill( colorGroup().background() ); | 274 | #ifndef DESKTOP_VERSION |
275 | if ( mMouseDown ) | ||
276 | buffer.fill( QColor( 242,27,255 ) ); | ||
277 | else | ||
278 | #endif | ||
279 | buffer.fill( colorGroup().background() ); | ||
275 | //buffer.fill( backgroundColor() ); | 280 | //buffer.fill( backgroundColor() ); |
276 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); | 281 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); |
277 | 282 | ||
278 | 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 |
279 | 284 | ||
280 | // arrow color | 285 | // arrow color |
281 | QColor col; | 286 | QColor col; |
282 | if ( _activeButton ) | 287 | if ( _activeButton ) |
283 | col = colorGroup().background().dark( 250 ); | 288 | col = colorGroup().background().dark( 250 ); |
284 | else { | 289 | else { |
285 | if ( mMouseDown ) | 290 | if ( mMouseDown ) |
286 | col = Qt::white; | 291 | #ifndef DESKTOP_VERSION |
292 | col = QColor( 178,18,188);//QColor( 242,27,255 );//Qt::white; | ||
293 | #else | ||
294 | col = Qt::white; | ||
295 | #endif | ||
287 | else | 296 | else |
288 | col = colorGroup().background().dark( 150 ); | 297 | col = colorGroup().background().dark( 150 ); |
289 | } | 298 | } |
290 | //QColor col = backgroundColor().dark( 130 ); | 299 | //QColor col = backgroundColor().dark( 130 ); |
291 | p.setBrush( col ); | 300 | p.setBrush( col ); |
292 | p.setPen( col ); | 301 | p.setPen( col ); |
293 | 302 | ||
294 | QValueList<QPointArray> list = buttonRegions(); | 303 | QValueList<QPointArray> list = buttonRegions(); |
295 | int index = 1; | 304 | int index = 1; |
296 | if ( mUseOffset ) | 305 | if ( mUseOffset ) |
297 | p.translate( 0, 1 ); | 306 | p.translate( 0, 1 ); |
298 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 307 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
299 | if ( index == _activeButton ) { | 308 | if ( index == _activeButton ) { |
300 | 309 | ||
301 | /* | 310 | /* |
302 | if ( ! _collapsed ) { | 311 | if ( ! _collapsed ) { |
303 | p.save(); | 312 | p.save(); |
304 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), | 313 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), |
305 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); | 314 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); |
306 | p.translate( -1, 0 ); | 315 | p.translate( -1, 0 ); |
307 | p.drawPolygon( *it, true ); | 316 | p.drawPolygon( *it, true ); |
308 | p.restore(); } else | 317 | p.restore(); } else |
309 | */ | 318 | */ |
310 | p.drawPolygon( *it, true ); | 319 | p.drawPolygon( *it, true ); |
311 | 320 | ||
312 | } | 321 | } |
313 | else { | 322 | else { |
314 | /* | 323 | /* |
315 | if ( ! _collapsed ) { | 324 | if ( ! _collapsed ) { |
316 | p.save(); | 325 | p.save(); |
317 | p.translate( -1, 0 ); | 326 | p.translate( -1, 0 ); |
318 | p.drawPolygon( *it, true ); | 327 | p.drawPolygon( *it, true ); |
319 | p.restore(); | 328 | p.restore(); |
320 | } else | 329 | } else |
321 | */ | 330 | */ |
322 | p.drawPolygon( *it, true ); | 331 | p.drawPolygon( *it, true ); |
323 | 332 | ||
324 | } | 333 | } |
325 | index++; | 334 | index++; |
326 | } | 335 | } |
327 | 336 | ||
328 | // Draw the lines between the arrows | 337 | // Draw the lines between the arrows |
329 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 338 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
330 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 339 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
331 | int mid = height()/2; | 340 | int mid = height()/2; |
332 | p.drawLine ( 1, mid - sw, 1, mid + sw ); | 341 | p.drawLine ( 1, mid - sw, 1, mid + sw ); |
333 | p.drawLine ( 3, mid - sw, 3, mid + sw ); | 342 | p.drawLine ( 3, mid - sw, 3, mid + sw ); |
334 | } | 343 | } |
335 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || | 344 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || |
336 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { | 345 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { |
337 | int mid = width()/2; | 346 | int mid = width()/2; |
338 | p.drawLine( mid -sw, 1, mid +sw, 1 ); | 347 | p.drawLine( mid -sw, 1, mid +sw, 1 ); |
339 | p.drawLine( mid -sw, 3, mid +sw, 3 ); | 348 | p.drawLine( mid -sw, 3, mid +sw, 3 ); |
340 | } | 349 | } |
341 | bitBlt( this, 0, 0, &buffer ); | 350 | bitBlt( this, 0, 0, &buffer ); |
342 | 351 | ||
343 | } | 352 | } |
344 | #endif | 353 | #endif |
345 | 354 | ||
346 | class QSplitterLayoutStruct | 355 | class QSplitterLayoutStruct |
347 | { | 356 | { |
348 | public: | 357 | public: |
349 | KDGanttMinimizeSplitter::ResizeMode mode; | 358 | KDGanttMinimizeSplitter::ResizeMode mode; |
350 | QCOORD sizer; | 359 | QCOORD sizer; |
351 | bool isSplitter; | 360 | bool isSplitter; |
352 | QWidget *wid; | 361 | QWidget *wid; |
353 | }; | 362 | }; |
354 | 363 | ||
355 | class QSplitterData | 364 | class QSplitterData |
356 | { | 365 | { |
357 | public: | 366 | public: |
358 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} | 367 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} |
359 | 368 | ||
360 | QPtrList<QSplitterLayoutStruct> list; | 369 | QPtrList<QSplitterLayoutStruct> list; |
361 | bool opaque; | 370 | bool opaque; |
362 | bool firstShow; | 371 | bool firstShow; |
363 | }; | 372 | }; |
364 | 373 | ||
365 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, | 374 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, |
366 | int space, int spacer ); | 375 | int space, int spacer ); |
367 | #endif // DOXYGEN_SKIP_INTERNAL | 376 | #endif // DOXYGEN_SKIP_INTERNAL |
368 | 377 | ||
369 | 378 | ||
370 | /*! | 379 | /*! |
371 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h | 380 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h |
372 | \brief The KDGanttMinimizeSplitter class implements a splitter | 381 | \brief The KDGanttMinimizeSplitter class implements a splitter |
373 | widget with minimize buttons. | 382 | widget with minimize buttons. |
374 | 383 | ||
375 | This class (and its documentation) is largely a copy of Qt's | 384 | This class (and its documentation) is largely a copy of Qt's |
376 | QSplitter; the copying was necessary because QSplitter is not | 385 | QSplitter; the copying was necessary because QSplitter is not |
377 | extensible at all. QSplitter and its documentation are licensed | 386 | extensible at all. QSplitter and its documentation are licensed |
378 | according to the GPL and the Qt Professional License (if you hold | 387 | according to the GPL and the Qt Professional License (if you hold |
379 | such a license) and are (C) Trolltech AS. | 388 | such a license) and are (C) Trolltech AS. |
380 | 389 | ||
381 | A splitter lets the user control the size of child widgets by | 390 | A splitter lets the user control the size of child widgets by |
382 | dragging the boundary between the children. Any number of widgets | 391 | dragging the boundary between the children. Any number of widgets |
383 | may be controlled. | 392 | may be controlled. |
384 | 393 | ||
385 | To show a QListBox, a QListView and a QTextEdit side by side: | 394 | To show a QListBox, a QListView and a QTextEdit side by side: |
386 | 395 | ||
387 | \code | 396 | \code |
388 | KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); | 397 | KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); |
389 | QListBox *lb = new QListBox( split ); | 398 | QListBox *lb = new QListBox( split ); |
390 | QListView *lv = new QListView( split ); | 399 | QListView *lv = new QListView( split ); |
391 | QTextEdit *ed = new QTextEdit( split ); | 400 | QTextEdit *ed = new QTextEdit( split ); |
392 | \endcode | 401 | \endcode |
393 | 402 | ||
394 | In KDGanttMinimizeSplitter, the boundary can be either horizontal or | 403 | In KDGanttMinimizeSplitter, the boundary can be either horizontal or |
395 | vertical. The default is horizontal (the children are side by side) | 404 | vertical. The default is horizontal (the children are side by side) |
396 | but you can use setOrientation( QSplitter::Vertical ) to set it to | 405 | but you can use setOrientation( QSplitter::Vertical ) to set it to |
397 | vertical. | 406 | vertical. |
398 | 407 | ||
399 | Use setResizeMode() to specify | 408 | Use setResizeMode() to specify |
400 | that a widget should keep its size when the splitter is resized. | 409 | that a widget should keep its size when the splitter is resized. |
401 | 410 | ||
402 | Although KDGanttMinimizeSplitter normally resizes the children only | 411 | Although KDGanttMinimizeSplitter normally resizes the children only |
403 | at the end of a resize operation, if you call setOpaqueResize( TRUE | 412 | at the end of a resize operation, if you call setOpaqueResize( TRUE |
404 | ) the widgets are resized as often as possible. | 413 | ) the widgets are resized as often as possible. |
405 | 414 | ||
406 | The initial distribution of size between the widgets is determined | 415 | The initial distribution of size between the widgets is determined |
407 | by the initial size of each widget. You can also use setSizes() to | 416 | by the initial size of each widget. You can also use setSizes() to |
408 | set the sizes of all the widgets. The function sizes() returns the | 417 | set the sizes of all the widgets. The function sizes() returns the |
409 | sizes set by the user. | 418 | sizes set by the user. |
410 | 419 | ||
411 | If you hide() a child, its space will be distributed among the other | 420 | If you hide() a child, its space will be distributed among the other |
412 | children. It will be reinstated when you show() it again. It is also | 421 | children. It will be reinstated when you show() it again. It is also |
413 | possible to reorder the widgets within the splitter using | 422 | possible to reorder the widgets within the splitter using |
414 | moveToFirst() and moveToLast(). | 423 | moveToFirst() and moveToLast(). |