summaryrefslogtreecommitdiffabout
path: root/microkde/KDGanttMinimizeSplitter.cpp
Unidiff
Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index 60b8bc7..567ae54 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -7,66 +7,66 @@
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 >= 300 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
@@ -598,65 +598,65 @@ void KDGanttMinimizeSplitter::childEvent( QChildEvent *c )
598 while ( s ) { 598 while ( s ) {
599 if ( s->wid == c->child() ) { 599 if ( s->wid == c->child() ) {
600 data->list.removeRef( s ); 600 data->list.removeRef( s );
601 delete s; 601 delete s;
602 if ( p && p->isSplitter ) { 602 if ( p && p->isSplitter ) {
603 data->list.removeRef( p ); 603 data->list.removeRef( p );
604 delete p->wid; //will call childEvent 604 delete p->wid; //will call childEvent
605 delete p; 605 delete p;
606 } 606 }
607 recalcId(); 607 recalcId();
608 doResize(); 608 doResize();
609 return; 609 return;
610 } 610 }
611 p = s; 611 p = s;
612 s = data->list.next(); 612 s = data->list.next();
613 } 613 }
614 } 614 }
615} 615}
616 616
617 617
618/*! 618/*!
619 Shows a rubber band at position \a p. If \a p is negative, the 619 Shows a rubber band at position \a p. If \a p is negative, the
620 rubber band is removed. 620 rubber band is removed.
621*/ 621*/
622void KDGanttMinimizeSplitter::setRubberband( int p ) 622void KDGanttMinimizeSplitter::setRubberband( int p )
623{ 623{
624 QPainter paint( this ); 624 QPainter paint( this );
625 paint.setPen( gray ); 625 paint.setPen( gray );
626 paint.setBrush( gray ); 626 paint.setBrush( gray );
627 paint.setRasterOp( XorROP ); 627 paint.setRasterOp( XorROP );
628 QRect r = contentsRect(); 628 QRect r = contentsRect();
629 const int rBord = 3; //Themable???? 629 const int rBord = 3; //Themable????
630#if QT_VERSION >= 300 630#if QT_VERSION >= 0x030000
631 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 631 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
632#else 632#else
633 int sw = style().splitterWidth(); 633 int sw = style().splitterWidth();
634#endif 634#endif
635 if ( orient == Horizontal ) { 635 if ( orient == Horizontal ) {
636 if ( opaqueOldPos >= 0 ) 636 if ( opaqueOldPos >= 0 )
637 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 637 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
638 2*rBord, r.height() ); 638 2*rBord, r.height() );
639 if ( p >= 0 ) 639 if ( p >= 0 )
640 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 640 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
641 } else { 641 } else {
642 if ( opaqueOldPos >= 0 ) 642 if ( opaqueOldPos >= 0 )
643 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 643 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
644 r.width(), 2*rBord ); 644 r.width(), 2*rBord );
645 if ( p >= 0 ) 645 if ( p >= 0 )
646 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 646 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
647 } 647 }
648 opaqueOldPos = p; 648 opaqueOldPos = p;
649} 649}
650 650
651 651
652/*! \reimp */ 652/*! \reimp */
653bool KDGanttMinimizeSplitter::event( QEvent *e ) 653bool KDGanttMinimizeSplitter::event( QEvent *e )
654{ 654{
655 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 655 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
656 recalc( isVisible() ); 656 recalc( isVisible() );
657 if ( e->type() == QEvent::Show ) 657 if ( e->type() == QEvent::Show )
658 data->firstShow = FALSE; 658 data->firstShow = FALSE;
659 } 659 }
660 return QWidget::event( e ); 660 return QWidget::event( e );
661} 661}
662 662
@@ -880,65 +880,65 @@ void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max )
880 int minA = 0; 880 int minA = 0;
881 int maxA = 0;//after 881 int maxA = 0;//after
882 int n = data->list.count(); 882 int n = data->list.count();
883 if ( id < 0 || id >= n ) 883 if ( id < 0 || id >= n )
884 return; 884 return;
885 int i; 885 int i;
886 for ( i = 0; i < id; i++ ) { 886 for ( i = 0; i < id; i++ ) {
887 QSplitterLayoutStruct *s = data->list.at(i); 887 QSplitterLayoutStruct *s = data->list.at(i);
888 if ( s->wid->isHidden() ) { 888 if ( s->wid->isHidden() ) {
889 //ignore 889 //ignore
890 } else if ( s->isSplitter ) { 890 } else if ( s->isSplitter ) {
891 minB += s->sizer; 891 minB += s->sizer;
892 maxB += s->sizer; 892 maxB += s->sizer;
893 } else { 893 } else {
894 minB += pick( minSize(s->wid) ); 894 minB += pick( minSize(s->wid) );
895 maxB += pick( s->wid->maximumSize() ); 895 maxB += pick( s->wid->maximumSize() );
896 } 896 }
897 } 897 }
898 for ( i = id; i < n; i++ ) { 898 for ( i = id; i < n; i++ ) {
899 QSplitterLayoutStruct *s = data->list.at(i); 899 QSplitterLayoutStruct *s = data->list.at(i);
900 if ( s->wid->isHidden() ) { 900 if ( s->wid->isHidden() ) {
901 //ignore 901 //ignore
902 } else if ( s->isSplitter ) { 902 } else if ( s->isSplitter ) {
903 minA += s->sizer; 903 minA += s->sizer;
904 maxA += s->sizer; 904 maxA += s->sizer;
905 } else { 905 } else {
906 minA += pick( minSize(s->wid) ); 906 minA += pick( minSize(s->wid) );
907 maxA += pick( s->wid->maximumSize() ); 907 maxA += pick( s->wid->maximumSize() );
908 } 908 }
909 } 909 }
910 QRect r = contentsRect(); 910 QRect r = contentsRect();
911 if ( orient == Horizontal && false ) { 911 if ( orient == Horizontal && false ) {
912#if QT_VERSION >= 300 912#if QT_VERSION >= 0x030000
913 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); 913 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this);
914#else 914#else
915 int splitterWidth = style().splitterWidth(); 915 int splitterWidth = style().splitterWidth();
916#endif 916#endif
917 917
918 if ( min ) 918 if ( min )
919 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; 919 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth;
920 if ( max ) 920 if ( max )
921 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; 921 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth;
922 } else { 922 } else {
923 if ( min ) 923 if ( min )
924 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); 924 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA );
925 if ( max ) 925 if ( max )
926 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); 926 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA );
927 } 927 }
928} 928}
929 929
930 930
931/*! 931/*!
932 Returns the closest legal position to \a p of the splitter with id \a id. 932 Returns the closest legal position to \a p of the splitter with id \a id.
933 933
934 \sa idAfter() 934 \sa idAfter()
935*/ 935*/
936 936
937int KDGanttMinimizeSplitter::adjustPos( int p, int id ) 937int KDGanttMinimizeSplitter::adjustPos( int p, int id )
938{ 938{
939 int min = 0; 939 int min = 0;
940 int max = 0; 940 int max = 0;
941 getRange( id, &min, &max ); 941 getRange( id, &min, &max );
942 p = QMAX( min, QMIN( p, max ) ); 942 p = QMAX( min, QMIN( p, max ) );
943 943
944 return p; 944 return p;
@@ -1358,65 +1358,65 @@ void KDGanttMinimizeSplitter::setSizes( QValueList<int> list )
1358 processChildEvents(); 1358 processChildEvents();
1359 QValueList<int>::Iterator it = list.begin(); 1359 QValueList<int>::Iterator it = list.begin();
1360 QSplitterLayoutStruct *s = data->list.first(); 1360 QSplitterLayoutStruct *s = data->list.first();
1361 while ( s && it != list.end() ) { 1361 while ( s && it != list.end() ) {
1362 if ( !s->isSplitter ) { 1362 if ( !s->isSplitter ) {
1363 s->sizer = *it; 1363 s->sizer = *it;
1364 ++it; 1364 ++it;
1365 } 1365 }
1366 s = data->list.next(); 1366 s = data->list.next();
1367 } 1367 }
1368 doResize(); 1368 doResize();
1369} 1369}
1370 1370
1371 1371
1372/*! 1372/*!
1373 Gets all posted child events, ensuring that the internal state of 1373 Gets all posted child events, ensuring that the internal state of
1374 the splitter is consistent. 1374 the splitter is consistent.
1375*/ 1375*/
1376 1376
1377void KDGanttMinimizeSplitter::processChildEvents() 1377void KDGanttMinimizeSplitter::processChildEvents()
1378{ 1378{
1379 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1379 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1380} 1380}
1381 1381
1382 1382
1383/*! 1383/*!
1384 \reimp 1384 \reimp
1385*/ 1385*/
1386 1386
1387void KDGanttMinimizeSplitter::styleChange( QStyle& old ) 1387void KDGanttMinimizeSplitter::styleChange( QStyle& old )
1388{ 1388{
1389 1389
1390#if QT_VERSION >= 300 1390#if QT_VERSION >= 0x030000
1391 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 1391 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
1392#else 1392#else
1393 int sw = style().splitterWidth(); 1393 int sw = style().splitterWidth();
1394#endif 1394#endif
1395 QSplitterLayoutStruct *s = data->list.first(); 1395 QSplitterLayoutStruct *s = data->list.first();
1396 while ( s ) { 1396 while ( s ) {
1397 if ( s->isSplitter ) 1397 if ( s->isSplitter )
1398 s->sizer = sw; 1398 s->sizer = sw;
1399 s = data->list.next(); 1399 s = data->list.next();
1400 } 1400 }
1401 doResize(); 1401 doResize();
1402 QFrame::styleChange( old ); 1402 QFrame::styleChange( old );
1403} 1403}
1404 1404
1405#endif 1405#endif
1406 1406
1407/*! 1407/*!
1408 Specifies the direction of the minimize buttons. 1408 Specifies the direction of the minimize buttons.
1409 If the orientation of the splitter is horizontal then with 1409 If the orientation of the splitter is horizontal then with
1410 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, 1410 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used,
1411 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down 1411 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down
1412 should be used. 1412 should be used.
1413*/ 1413*/
1414void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) 1414void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction )
1415{ 1415{
1416 _direction = direction; 1416 _direction = direction;
1417} 1417}
1418 1418
1419/*! 1419/*!
1420 Returns the direction of the minimize buttons. 1420 Returns the direction of the minimize buttons.
1421*/ 1421*/
1422KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const 1422KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const