summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp14
-rw-r--r--microkde/KDGanttMinimizeSplitter.h1
2 files changed, 11 insertions, 4 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index 84edc0d..c60b566 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -35,187 +35,189 @@
#ifndef QT_NO_SPLITTER___
#include "qpainter.h"
#include "qdrawutil.h"
#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 );
+ mMouseDown = false;
//setMaximumHeight( 5 ); // test only
}
QSize KDGanttSplitterHandle::sizeHint() const
{
return mSizeHint;
}
void KDGanttSplitterHandle::setOrientation( Qt::Orientation o )
{
orient = o;
#ifndef QT_NO_CURSOR
if ( o == KDGanttMinimizeSplitter::Horizontal )
setCursor( splitHCursor );
else
setCursor( splitVCursor );
#endif
}
void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e )
{
updateCursor( e->pos() );
if ( !(e->state()&LeftButton) )
return;
if ( _activeButton != 0)
return;
QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
- mouseOffset;
if ( true /*opaque()*/ ) {
s->moveSplitter( pos, id() );
} else {
int min = pos; int max = pos;
s->getRange( id(), &min, &max );
s->setRubberband( QMAX( min, QMIN(max, pos )));
}
_collapsed = false;
}
void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e )
{
if ( e->button() == LeftButton ) {
_activeButton = onButton( e->pos() );
mouseOffset = s->pick(e->pos());
- if ( _activeButton != 0)
- repaint();
+ mMouseDown = true;
+ repaint();
updateCursor( e->pos() );
}
}
void KDGanttSplitterHandle::updateCursor( const QPoint& p)
{
if ( onButton( p ) != 0 ) {
setCursor( arrowCursor );
}
else {
if ( orient == KDGanttMinimizeSplitter::Horizontal )
setCursor( splitHCursor );
else
setCursor( splitVCursor );
}
}
void KDGanttSplitterHandle::toggle()
{
int pos;
int min, max;
if ( !_collapsed ) {
s->expandPos( id(), &min, &max );
if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left
|| s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
pos = min;
}
else {
pos = max;
}
_origPos = s->pick(mapToParent( QPoint( 0,0 ) ));
s->moveSplitter( pos, id() );
_collapsed = true;
}
else {
s->moveSplitter( _origPos, id() );
_collapsed = false;
}
repaint();
}
void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
{
+ mMouseDown = false;
if ( _activeButton != 0 ) {
if ( onButton( e->pos() ) == _activeButton )
{
toggle();
}
_activeButton = 0;
updateCursor( e->pos() );
}
else {
if ( !opaque() && e->button() == LeftButton ) {
QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
- mouseOffset;
s->setRubberband( -1 );
s->moveSplitter( pos, id() );
}
}
repaint();
}
int KDGanttSplitterHandle::onButton( const QPoint& p )
{
QValueList<QPointArray> list = buttonRegions();
int index = 1;
int add = 12;
for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
QRect rect = (*it).boundingRect();
rect.setLeft( rect.left()- add );
rect.setRight( rect.right() + add);
rect.setTop( rect.top()- add );
rect.setBottom( rect.bottom() + add);
if ( rect.contains( p ) ) {
return index;
}
index++;
}
return 0;
}
QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions()
{
QValueList<QPointArray> list;
int sw = 8;
int yyy = 1;
int xxx = 1;
int voffset[] = { (int) -sw*3, (int) sw*3 };
for ( int i = 0; i < 2; i++ ) {
@@ -232,98 +234,102 @@ QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions()
_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
int mid = height()/2 + voffset[i];
arr.setPoints( 3,
sw-4, mid - sw + 4,
0, mid,
sw-4, mid + sw - 4);
}
else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) {
int mid = width()/2 + voffset[i];
arr.setPoints( 3,
mid - sw + 4, sw-4,
mid, 0,
mid + sw - 4, sw-4 );
}
else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down ||
_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
int mid = width()/2 + voffset[i];
arr.setPoints( 3,
mid - sw + 4, 1-yyy,
mid, sw-3-yyy,
mid + sw -4, 1-yyy);
}
list.append( arr );
}
return list;
}
void KDGanttSplitterHandle::paintEvent( QPaintEvent * )
{
QPixmap buffer( size() );
QPainter p( &buffer );
//LR
// Draw the splitter rectangle
p.setBrush( colorGroup().background() );
p.setPen( colorGroup().foreground() );
//p.drawRect( rect() );
buffer.fill( colorGroup().background() );
//buffer.fill( backgroundColor() );
// parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup());
int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size
// arrow color
QColor col;
if ( _activeButton )
col = colorGroup().background().dark( 250 );
- else
- col = colorGroup().background().dark( 150 );
+ else {
+ if ( mMouseDown )
+ col = Qt::white;
+ else
+ col = colorGroup().background().dark( 150 );
+ }
//QColor col = backgroundColor().dark( 130 );
p.setBrush( col );
p.setPen( col );
QValueList<QPointArray> list = buttonRegions();
int index = 1;
if ( mUseOffset )
p.translate( 0, 1 );
for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
if ( index == _activeButton ) {
/*
if ( ! _collapsed ) {
p.save();
// p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ),
// parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) );
p.translate( -1, 0 );
p.drawPolygon( *it, true );
p.restore(); } else
*/
p.drawPolygon( *it, true );
}
else {
/*
if ( ! _collapsed ) {
p.save();
p.translate( -1, 0 );
p.drawPolygon( *it, true );
p.restore();
} else
*/
p.drawPolygon( *it, true );
}
index++;
}
// Draw the lines between the arrows
if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
int mid = height()/2;
p.drawLine ( 1, mid - sw, 1, mid + sw );
p.drawLine ( 3, mid - sw, 3, mid + sw );
}
else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) {
int mid = width()/2;
diff --git a/microkde/KDGanttMinimizeSplitter.h b/microkde/KDGanttMinimizeSplitter.h
index 8120d14..84d3d8e 100644
--- a/microkde/KDGanttMinimizeSplitter.h
+++ b/microkde/KDGanttMinimizeSplitter.h
@@ -124,65 +124,66 @@ private:
#endif
private:
Orientation orient;
Direction _direction;
#ifndef DOXYGEN_SKIP_INTERNAL
friend class KDGanttSplitterHandle;
#endif
private: // Disabled copy constructor and operator=
#if defined(Q_DISABLE_COPY)
KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & );
KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & );
#endif
};
#ifndef DOXYGEN_SKIP_INTERNAL
// This class was continued from a verbatim copy of the
// QSplitterHandle pertaining to the Qt Enterprise License and the
// GPL. It has only been renamed to KDGanttSplitterHandler in order to
// avoid a symbol clash on some platforms.
class KDGanttSplitterHandle : public QWidget
{
Q_OBJECT
#if QT_VERSION >= 232
public:
KDGanttSplitterHandle( Qt::Orientation o,
KDGanttMinimizeSplitter *parent, const char* name=0 );
void setOrientation( Qt::Orientation o );
Qt::Orientation orientation() const { return orient; }
bool opaque() const { return s->opaqueResize(); }
QSize sizeHint() const;
void toggle();
int id() const { return myId; } // data->list.at(id())->wid == this
void setId( int i ) { myId = i; }
protected:
QValueList<QPointArray> buttonRegions();
void paintEvent( QPaintEvent * );
void mouseMoveEvent( QMouseEvent * );
void mousePressEvent( QMouseEvent * );
void mouseReleaseEvent( QMouseEvent * );
int onButton( const QPoint& p );
void updateCursor( const QPoint& p );
private:
+ bool mMouseDown;
QSize mSizeHint;
bool mUseOffset;
Qt::Orientation orient;
bool opaq;
int myId;
KDGanttMinimizeSplitter *s;
int _activeButton;
bool _collapsed;
int _origPos;
#endif
};
#endif
#endif // QT_NO_SPLITTER
#endif // KDGANTTMINIMIZESPLITTER_H