Back to index

scribus-ng  1.3.4.dfsg+svn20071115
rulermover.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 /***************************************************************************
00008                           rulermover.cpp  -  description
00009                              -------------------
00010     begin                : Sun Jul 24 2005
00011     copyright            : (C) 2005 by Franz Schmid
00012     email                : Franz.Schmid@altmuehlnet.de
00013  ***************************************************************************/
00014 
00015 /***************************************************************************
00016  *                                                                         *
00017  *   This program is free software; you can redistribute it and/or modify  *
00018  *   it under the terms of the GNU General Public License as published by  *
00019  *   the Free Software Foundation; either version 2 of the License, or     *
00020  *   (at your option) any later version.                                   *
00021  *                                                                         *
00022  ***************************************************************************/
00023 
00024 #include "rulermover.h"
00025 #include "rulermover.moc"
00026 #include "scribusview.h"
00027 #include "scribusdoc.h"
00028 #include <qcursor.h>
00029 #include <qapplication.h>
00030 extern QPixmap loadIcon(QString nam);
00031 
00032 RulerMover::RulerMover(ScribusView *pa) : QWidget(pa)
00033 {
00034        setErasePixmap(loadIcon("mover.png"));
00035        currView = pa;
00036        Mpressed = false;
00037 }
00038 
00039 void RulerMover::mouseDoubleClickEvent(QMouseEvent *)
00040 {
00041        currView->Doc->rulerXoffset = 0;
00042        currView->Doc->rulerYoffset = 0;
00043        currView->DrawNew();
00044 }
00045 
00046 void RulerMover::mousePressEvent(QMouseEvent *m)
00047 {
00048        Mpressed = true;
00049        QPoint py = currView->viewport()->mapFromGlobal(m->globalPos());
00050        currView->DrVX = py.x();
00051        currView->DrHY = py.y();
00052        qApp->setOverrideCursor(QCursor(SizeAllCursor), true);
00053 }
00054 
00055 void RulerMover::mouseReleaseEvent(QMouseEvent *m)
00056 {
00057        if ((Mpressed) && (m->pos().x() > width()) && (m->pos().y() > height()))
00058        {
00059               currView->DrVX = -1;
00060               currView->DrHY = -1;
00061               currView->setNewRulerOrigin(m);
00062        }
00063        qApp->setOverrideCursor(QCursor(ArrowCursor), true);
00064        Mpressed = false;
00065 }
00066 
00067 void RulerMover::mouseMoveEvent(QMouseEvent *m)
00068 {
00069        if ((Mpressed) && (m->pos().x() > width()) && (m->pos().y() > height()))
00070               currView->rulerMove(m);
00071 }