summaryrefslogtreecommitdiffstats
path: root/knights/tabgrip.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'knights/tabgrip.cpp')
-rw-r--r--knights/tabgrip.cpp109
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 );
+ }
+ }
+}