3
For general Scribus (>=1.3.2) copyright and licensing information please refer
4
to the COPYING file provided with the program. Following this notice may exist
5
a copyright and/or license notice that predates the release of Scribus 1.3.2
6
for which a new license (GPL+exception) is in place.
8
/***************************************************************************
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
15
***************************************************************************/
19
#include "canvasgesture_rectselect.h"
21
#include "scribusview.h"
23
#include <QDragEnterEvent>
24
#include <QDragMoveEvent>
25
#include <QDragLeaveEvent>
28
#include <QInputMethodEvent>
29
#include <QMouseEvent>
32
#include <QRubberBand>
34
void RectSelect::enterEvent(QEvent * e){}
35
void RectSelect::leaveEvent(QEvent * e){}
38
void RectSelect::prepare(QPoint start)
41
m_rectangle = new QRubberBand(QRubberBand::Rectangle);
43
m_rectangle->setGeometry(m_start.x(), m_start.y(), 1, 1);
46
void RectSelect::clear()
49
m_start = QPoint(0,0);
53
void RectSelect::activate(bool)
59
void RectSelect::deactivate(bool)
64
void RectSelect::setStart(QPoint globalPos)
69
void RectSelect::setEnd(QPoint globalPos)
71
m_rectangle->setGeometry(QRect(m_start.x(),
73
globalPos.x()-m_start.x(),
74
globalPos.y()-m_start.y())
79
QRectF RectSelect::result() const
81
return m_canvas->globalToCanvas(m_rectangle->geometry());
84
void RectSelect::mousePressEvent(QMouseEvent *m)
86
prepare(m->globalPos());
91
void RectSelect::mouseReleaseEvent(QMouseEvent *m)
93
// qDebug() << "RectSelect::mouseRelease" << m->globalPos();
94
setEnd(m->globalPos());
96
m_view->stopGesture();
99
void RectSelect::mouseMoveEvent(QMouseEvent *m)
101
setEnd(m->globalPos());