diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 01:24:36 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 01:24:36 +0000 |
commit | a8c9924456e5335c964e4e55b2dde1963c88726f (patch) | |
tree | f5bf107ba079ae460536da778ce2da5e6c68aa69 /knights/tabgrip.cpp | |
download | knights-a8c9924456e5335c964e4e55b2dde1963c88726f.tar.gz knights-a8c9924456e5335c964e4e55b2dde1963c88726f.zip |
Added KDE3 version of Knights
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/knights@1091568 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'knights/tabgrip.cpp')
-rw-r--r-- | knights/tabgrip.cpp | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/knights/tabgrip.cpp b/knights/tabgrip.cpp new file mode 100644 index 0000000..563dd8f --- /dev/null +++ b/knights/tabgrip.cpp @@ -0,0 +1,109 @@ +/*************************************************************************** + tabgrip.cpp - description + ------------------- + begin : Fri Sep 13 2002 + copyright : (C) 2003 by Troy Corbin Jr. + email : tcorbin@users.sf.net + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "tabgrip.moc" +#include "resource.h" +#include <qpainter.h> + +TabGrip::TabGrip(QWidget *parent, const char *name ) : QWidget(parent,name) +{ + setMaximumSize( 3200, 12 ); + setMinimumSize( 32, 12 ); + + isDragging = FALSE; + couldDrag = FALSE; + + setCursor( Qt::SizeAllCursor ); + + show(); +} +TabGrip::~TabGrip() +{ +} +/////////////////////////////////////// +// +// TabGrip::paintEvent +// +/////////////////////////////////////// +void TabGrip::paintEvent( QPaintEvent* ) +{ + QPainter paint( this ); + QColorGroup group( colorGroup() ); + paint.setPen( group.light() ); + paint.drawLine( 2, 2, width() - 3, 2 ); + paint.drawLine( 2, 5, width() - 3, 5 ); + paint.drawLine( 2, 8, width() - 3, 8 ); + paint.setPen( group.dark() ); + paint.drawLine( 2, 3, width() - 3, 3 ); + paint.drawLine( 2, 6, width() - 3, 6 ); + paint.drawLine( 2, 9, width() - 3, 9 ); +} +/////////////////////////////////////// +// +// TabGrip::mousePressEvent +// +/////////////////////////////////////// +void TabGrip::mousePressEvent( QMouseEvent *event ) +{ + event->accept(); + if(event->button() == Qt::LeftButton) + { + couldDrag = TRUE; + offset = mapToGlobal( event->pos() ); + offset.setX( topLevelWidget()->x() - offset.x() ); + offset.setY( topLevelWidget()->y() - offset.y() ); + } +} +/////////////////////////////////////// +// +// TabGrip::mouseMoveEvent +// +/////////////////////////////////////// +void TabGrip::mouseMoveEvent( QMouseEvent *event ) +{ + /* + By default, MouseMoveEvent is never called unless the user has + a button held down, so this should only be called if we're dragging. + */ + event->accept(); + if( couldDrag == TRUE ) + { + /* Dragging Page */ + isDragging = TRUE; + couldDrag = FALSE; + QApplication::setOverrideCursor( Qt::SizeAllCursor ); + } +} +/////////////////////////////////////// +// +// TabGrip::mouseReleaseEvent +// +/////////////////////////////////////// +void TabGrip::mouseReleaseEvent( QMouseEvent *event ) +{ + event->accept(); + if(event->button() == Qt::LeftButton) + { + couldDrag = FALSE; + if( isDragging ) + { + QApplication::restoreOverrideCursor(); + isDragging = FALSE; + emit wasDragged( event->globalPos(), offset ); + } + } +} |