summaryrefslogtreecommitdiffabout
path: root/microkde/KDGanttMinimizeSplitter.cpp
authorzautrix <zautrix>2005-04-01 13:07:01 (UTC)
committer zautrix <zautrix>2005-04-01 13:07:01 (UTC)
commit93003b1f8348f112648d3cc20acb21b062220e21 (patch) (unidiff)
tree901bebe154a15f05296158db5da3689b849e8281 /microkde/KDGanttMinimizeSplitter.cpp
parentf8e027db1d950ec27a3c47fc2a5ea2fe49ae9772 (diff)
downloadkdepimpi-93003b1f8348f112648d3cc20acb21b062220e21.zip
kdepimpi-93003b1f8348f112648d3cc20acb21b062220e21.tar.gz
kdepimpi-93003b1f8348f112648d3cc20acb21b062220e21.tar.bz2
fixes
Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index 029f14b..ea3a329 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -180,24 +180,26 @@ void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
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() )
193 s->rubberBand()->hide();
192 repaint(); 194 repaint();
193} 195}
194 196
195int KDGanttSplitterHandle::onButton( const QPoint& p ) 197int KDGanttSplitterHandle::onButton( const QPoint& p )
196{ 198{
197 QValueList<QPointArray> list = buttonRegions(); 199 QValueList<QPointArray> list = buttonRegions();
198 int index = 1; 200 int index = 1;
199 int add = 12; 201 int add = 12;
200 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 202 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
201 QRect rect = (*it).boundingRect(); 203 QRect rect = (*it).boundingRect();
202 rect.setLeft( rect.left()- add ); 204 rect.setLeft( rect.left()- add );
203 rect.setRight( rect.right() + add); 205 rect.setRight( rect.right() + add);
@@ -425,62 +427,66 @@ static QSize minSizeHint( const QWidget* w )
425 QSize min = w->minimumSize(); 427 QSize min = w->minimumSize();
426 QSize s; 428 QSize s;
427 if ( min.height() <= 0 || min.width() <= 0 ) 429 if ( min.height() <= 0 || min.width() <= 0 )
428 s = w->minimumSizeHint(); 430 s = w->minimumSizeHint();
429 if ( min.height() > 0 ) 431 if ( min.height() > 0 )
430 s.setHeight( min.height() ); 432 s.setHeight( min.height() );
431 if ( min.width() > 0 ) 433 if ( min.width() > 0 )
432 s.setWidth( min.width() ); 434 s.setWidth( min.width() );
433 return s.expandedTo(QSize(0,0)); 435 return s.expandedTo(QSize(0,0));
434} 436}
435 437
436 438
437
438/*! 439/*!
439 Constructs a horizontal splitter with the \a parent and \a 440 Constructs a horizontal splitter with the \a parent and \a
440 name arguments being passed on to the QFrame constructor. 441 name arguments being passed on to the QFrame constructor.
441*/ 442*/
442KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) 443KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name )
443 :QFrame(parent,name,WPaintUnclipped) 444 :QFrame(parent,name,WPaintUnclipped)
444{ 445{
446 mRubberBand = 0;
445 mFirstHandle = 0; 447 mFirstHandle = 0;
446#if QT_VERSION >= 232 448#if QT_VERSION >= 232
447 orient = Horizontal; 449 orient = Horizontal;
448 init(); 450 init();
449#endif 451#endif
450} 452}
451 453
452/*! 454/*!
453 Constructs a splitter with orientation \a o with the \a parent 455 Constructs a splitter with orientation \a o with the \a parent
454 and \a name arguments being passed on to the QFrame constructor. 456 and \a name arguments being passed on to the QFrame constructor.
455*/ 457*/
456KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) 458KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name )
457 :QFrame(parent,name,WPaintUnclipped) 459 :QFrame(parent,name,WPaintUnclipped)
458{ 460{
461
462 mRubberBand = 0;
459 mFirstHandle = 0; 463 mFirstHandle = 0;
460#if QT_VERSION >= 232 464#if QT_VERSION >= 232
461 orient = o; 465 orient = o;
462 init(); 466 init();
463#endif 467#endif
464} 468}
465 469
466/*! 470/*!
467 Destroys the splitter and any children. 471 Destroys the splitter and any children.
468*/ 472*/
469KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() 473KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter()
470{ 474{
471#if QT_VERSION >= 232 475#if QT_VERSION >= 232
472 data->list.setAutoDelete( TRUE ); 476 data->list.setAutoDelete( TRUE );
473 delete data; 477 delete data;
474#endif 478#endif
479 if ( mRubberBand )
480 delete mRubberBand;
475} 481}
476 482
477 483
478#if QT_VERSION >= 232 484#if QT_VERSION >= 232
479void KDGanttMinimizeSplitter::init() 485void KDGanttMinimizeSplitter::init()
480{ 486{
481 data = new QSplitterData; 487 data = new QSplitterData;
482 if ( orient == Horizontal ) 488 if ( orient == Horizontal )
483 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); 489 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) );
484 else 490 else
485 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); 491 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) );
486#ifndef DESKTOP_VERSION 492#ifndef DESKTOP_VERSION
@@ -633,24 +639,25 @@ void KDGanttMinimizeSplitter::childEvent( QChildEvent *c )
633 s = data->list.next(); 639 s = data->list.next();
634 } 640 }
635 } 641 }
636} 642}
637 643
638 644
639/*! 645/*!
640 Shows a rubber band at position \a p. If \a p is negative, the 646 Shows a rubber band at position \a p. If \a p is negative, the
641 rubber band is removed. 647 rubber band is removed.
642*/ 648*/
643void KDGanttMinimizeSplitter::setRubberband( int p ) 649void KDGanttMinimizeSplitter::setRubberband( int p )
644{ 650{
651#ifdef DESKTOP_VERSION
645 QPainter paint( this ); 652 QPainter paint( this );
646 paint.setPen( gray ); 653 paint.setPen( gray );
647 paint.setBrush( gray ); 654 paint.setBrush( gray );
648 paint.setRasterOp( XorROP ); 655 paint.setRasterOp( XorROP );
649 QRect r = contentsRect(); 656 QRect r = contentsRect();
650 const int rBord = 3; //Themable???? 657 const int rBord = 3; //Themable????
651#if QT_VERSION >= 0x030000 658#if QT_VERSION >= 0x030000
652 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 659 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
653#else 660#else
654 int sw = style().splitterWidth(); 661 int sw = style().splitterWidth();
655#endif 662#endif
656 if ( orient == Horizontal ) { 663 if ( orient == Horizontal ) {
@@ -658,24 +665,47 @@ void KDGanttMinimizeSplitter::setRubberband( int p )
658 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 665 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
659 2*rBord, r.height() ); 666 2*rBord, r.height() );
660 if ( p >= 0 ) 667 if ( p >= 0 )
661 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 668 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
662 } else { 669 } else {
663 if ( opaqueOldPos >= 0 ) 670 if ( opaqueOldPos >= 0 )
664 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 671 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
665 r.width(), 2*rBord ); 672 r.width(), 2*rBord );
666 if ( p >= 0 ) 673 if ( p >= 0 )
667 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 674 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
668 } 675 }
669 opaqueOldPos = p; 676 opaqueOldPos = p;
677#else
678 if ( !mRubberBand ) {
679 mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop);
680 mRubberBand->setFrameStyle( Box | Raised );
681 mRubberBand->setPalette( QPalette ( Qt::green.light(),Qt::green.dark() ) );
682 }
683 QRect r = contentsRect();
684 const int rBord = 5; //Themable????
685 int sw = style().splitterWidth();
686 if ( orient == Horizontal ) {
687 if ( p >= 0 ) {
688 QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y()));
689 mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() );
690 }
691 } else {
692 if ( p >= 0 ) {
693 QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord));
694 mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord);
695 }
696 }
697 opaqueOldPos = p;
698 mRubberBand->show();
699#endif
670} 700}
671 701
672 702
673/*! \reimp */ 703/*! \reimp */
674bool KDGanttMinimizeSplitter::event( QEvent *e ) 704bool KDGanttMinimizeSplitter::event( QEvent *e )
675{ 705{
676 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 706 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
677 recalc( isVisible() ); 707 recalc( isVisible() );
678 if ( e->type() == QEvent::Show ) 708 if ( e->type() == QEvent::Show )
679 data->firstShow = FALSE; 709 data->firstShow = FALSE;
680 } 710 }
681 return QWidget::event( e ); 711 return QWidget::event( e );