Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 10 |
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 @@ -1,88 +1,88 @@ /* -*- Mode: C++ -*- $Id$ */ /**************************************************************************** ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. ** ** This file is part of the KDGantt library. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** Licensees holding valid commercial KDGantt licenses may use this file in ** accordance with the KDGantt Commercial License Agreement provided with ** the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for ** information about KDGantt Commercial License Agreements. ** ** Contact info@klaralvdalens-datakonsult.se if any conditions of this ** licensing are not clear to you. ** ** As a special exception, permission is given to link this program ** with any edition of Qt, and distribute the resulting executable, ** without including the source code for Qt in the source distribution. ** **********************************************************************/ #include "KDGanttMinimizeSplitter.h" #ifndef QT_NO_SPLITTER___ #include "qpainter.h" #include "qdrawutil.h" -#include "qbitmap.h" -#if QT_VERSION >= 300 +#include "qbitmap.h" +#if QT_VERSION >= 0x030000 #include "qptrlist.h" #include "qmemarray.h" #else #include <qlist.h> #include <qarray.h> #define QPtrList QList #define QMemArray QArray #endif #include "qlayoutengine_p.h" #include "qobjectlist.h" #include "qstyle.h" #include "qapplication.h" //sendPostedEvents #include <qvaluelist.h> #include <qcursor.h> #ifndef KDGANTT_MASTER_CVS //#include "KDGanttMinimizeSplitter.moc" #endif #ifndef DOXYGEN_SKIP_INTERNAL #if QT_VERSION >= 232 static int mouseOffset; static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, KDGanttMinimizeSplitter *parent, const char * name ) : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) { if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { mSizeHint = QSize(7,7); mUseOffset = true; } else { mSizeHint = QSize(6,6); mUseOffset = false; } s = parent; setOrientation(o); setMouseTracking( true ); //setMaximumHeight( 5 ); // test only } QSize KDGanttSplitterHandle::sizeHint() const { return mSizeHint; @@ -582,97 +582,97 @@ void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) return; QSplitterLayoutStruct *s = data->list.first(); while ( s ) { if ( s->wid == c->child() ) return; s = data->list.next(); } addWidget( (QWidget*)c->child() ); recalc( isVisible() ); } else if ( c->type() == QEvent::ChildRemoved ) { QSplitterLayoutStruct *p = 0; if ( data->list.count() > 1 ) p = data->list.at(1); //remove handle _after_ first widget. QSplitterLayoutStruct *s = data->list.first(); while ( s ) { if ( s->wid == c->child() ) { data->list.removeRef( s ); delete s; if ( p && p->isSplitter ) { data->list.removeRef( p ); delete p->wid; //will call childEvent delete p; } recalcId(); doResize(); return; } p = s; s = data->list.next(); } } } /*! Shows a rubber band at position \a p. If \a p is negative, the rubber band is removed. */ void KDGanttMinimizeSplitter::setRubberband( int p ) { QPainter paint( this ); paint.setPen( gray ); paint.setBrush( gray ); paint.setRasterOp( XorROP ); QRect r = contentsRect(); const int rBord = 3; //Themable???? -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); #else int sw = style().splitterWidth(); #endif if ( orient == Horizontal ) { if ( opaqueOldPos >= 0 ) paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 2*rBord, r.height() ); if ( p >= 0 ) paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); } else { if ( opaqueOldPos >= 0 ) paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, r.width(), 2*rBord ); if ( p >= 0 ) paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); } opaqueOldPos = p; } /*! \reimp */ bool KDGanttMinimizeSplitter::event( QEvent *e ) { if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { recalc( isVisible() ); if ( e->type() == QEvent::Show ) data->firstShow = FALSE; } return QWidget::event( e ); } /*! \obsolete Draws the splitter handle in the rectangle described by \a x, \a y, \a w, \a h using painter \a p. \sa QStyle::drawPrimitive() */ void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, QCOORD x, QCOORD y, QCOORD w, QCOORD h ) { #if 0 // LR style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), (orientation() == Qt::Horizontal ? QStyle::Style_Horizontal : 0)); @@ -864,97 +864,97 @@ void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) QWidget* w = s->wid; *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; } } /*! Returns the valid range of the splitter with id \a id in \a *min and \a *max. \sa idAfter() */ void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) { int minB = 0; //before int maxB = 0; int minA = 0; int maxA = 0; //after int n = data->list.count(); if ( id < 0 || id >= n ) return; int i; for ( i = 0; i < id; i++ ) { QSplitterLayoutStruct *s = data->list.at(i); if ( s->wid->isHidden() ) { //ignore } else if ( s->isSplitter ) { minB += s->sizer; maxB += s->sizer; } else { minB += pick( minSize(s->wid) ); maxB += pick( s->wid->maximumSize() ); } } for ( i = id; i < n; i++ ) { QSplitterLayoutStruct *s = data->list.at(i); if ( s->wid->isHidden() ) { //ignore } else if ( s->isSplitter ) { minA += s->sizer; maxA += s->sizer; } else { minA += pick( minSize(s->wid) ); maxA += pick( s->wid->maximumSize() ); } } QRect r = contentsRect(); if ( orient == Horizontal && false ) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); #else int splitterWidth = style().splitterWidth(); #endif if ( min ) *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; if ( max ) *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; } else { if ( min ) *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); if ( max ) *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); } } /*! Returns the closest legal position to \a p of the splitter with id \a id. \sa idAfter() */ int KDGanttMinimizeSplitter::adjustPos( int p, int id ) { int min = 0; int max = 0; getRange( id, &min, &max ); p = QMAX( min, QMIN( p, max ) ); return p; } void KDGanttMinimizeSplitter::doResize() { QRect r = contentsRect(); int i; int n = data->list.count(); QMemArray<QLayoutStruct> a( n ); for ( i = 0; i< n; i++ ) { a[i].init(); QSplitterLayoutStruct *s = data->list.at(i); if ( s->wid->isHidden() ) { a[i].stretch = 0; a[i].sizeHint = a[i].minimumSize = 0; a[i].maximumSize = 0; @@ -1342,97 +1342,97 @@ QValueList<int> KDGanttMinimizeSplitter::sizes() const /*! Sets the size parameters to the values given in \a list. If the splitter is horizontal, the values set the sizes from left to right. If it is vertical, the sizes are applied from top to bottom. Extra values in \a list are ignored. If \a list contains too few values, the result is undefined but the program will still be well-behaved. \sa sizes() */ void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) { processChildEvents(); QValueList<int>::Iterator it = list.begin(); QSplitterLayoutStruct *s = data->list.first(); while ( s && it != list.end() ) { if ( !s->isSplitter ) { s->sizer = *it; ++it; } s = data->list.next(); } doResize(); } /*! Gets all posted child events, ensuring that the internal state of the splitter is consistent. */ void KDGanttMinimizeSplitter::processChildEvents() { QApplication::sendPostedEvents( this, QEvent::ChildInserted ); } /*! \reimp */ void KDGanttMinimizeSplitter::styleChange( QStyle& old ) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); #else int sw = style().splitterWidth(); #endif QSplitterLayoutStruct *s = data->list.first(); while ( s ) { if ( s->isSplitter ) s->sizer = sw; s = data->list.next(); } doResize(); QFrame::styleChange( old ); } #endif /*! Specifies the direction of the minimize buttons. If the orientation of the splitter is horizontal then with KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down should be used. */ void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) { _direction = direction; } /*! Returns the direction of the minimize buttons. */ KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const { return _direction; } /* This is a copy of qGeomCalc() in qlayoutengine.cpp which unfortunately isn't exported. */ static inline int toFixed( int i ) { return i * 256; } static inline int fRound( int i ) { return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; } void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, int space, int spacer ) { typedef int fixed; |