~ubuntu-branches/ubuntu/maverick/scribus-ng/maverick-backports

« back to all changes in this revision

Viewing changes to scribus/canvasgesture_rectselect.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Oleksandr Moskalenko
  • Date: 2009-02-09 09:25:18 UTC
  • mfrom: (5.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090209092518-iqsxmh3pjspgrdyd
Tags: 1.3.5.dfsg~svn20090208-2
debian/control: Use "type-handling -n arm,armel,armeb any" to generate the
list of architectures to build on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
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.
 
7
 */
 
8
/***************************************************************************
 
9
*                                                                         *
 
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.                                   *
 
14
*                                                                         *
 
15
***************************************************************************/
 
16
 
 
17
 
 
18
 
 
19
#include "canvasgesture_rectselect.h"
 
20
#include "canvas.h"
 
21
#include "scribusview.h"
 
22
 
 
23
#include <QDragEnterEvent>
 
24
#include <QDragMoveEvent>
 
25
#include <QDragLeaveEvent>
 
26
#include <QDropEvent>
 
27
#include <QEvent>
 
28
#include <QInputMethodEvent>
 
29
#include <QMouseEvent>
 
30
#include <QKeyEvent>
 
31
#include <QPainter>
 
32
#include <QRubberBand>
 
33
 
 
34
void RectSelect::enterEvent(QEvent * e){}
 
35
void RectSelect::leaveEvent(QEvent * e){}
 
36
 
 
37
 
 
38
void RectSelect::prepare(QPoint start)
 
39
{
 
40
        if (!m_rectangle)
 
41
                m_rectangle = new QRubberBand(QRubberBand::Rectangle);
 
42
        setStart(start);
 
43
        m_rectangle->setGeometry(m_start.x(), m_start.y(), 1, 1);
 
44
}
 
45
 
 
46
void RectSelect::clear()
 
47
{
 
48
        m_rectangle->hide();
 
49
        m_start = QPoint(0,0);
 
50
}
 
51
 
 
52
 
 
53
void RectSelect::activate(bool)
 
54
{
 
55
        prepare(m_start);
 
56
        m_rectangle->show();
 
57
}
 
58
 
 
59
void RectSelect::deactivate(bool)
 
60
{
 
61
        m_rectangle->hide();
 
62
}
 
63
 
 
64
void RectSelect::setStart(QPoint globalPos)
 
65
{
 
66
        m_start = globalPos;
 
67
}
 
68
 
 
69
void RectSelect::setEnd(QPoint globalPos)
 
70
{
 
71
        m_rectangle->setGeometry(QRect(m_start.x(), 
 
72
                                                                   m_start.y(), 
 
73
                                                                   globalPos.x()-m_start.x(), 
 
74
                                                                   globalPos.y()-m_start.y())
 
75
                                                         .normalized());        
 
76
}
 
77
 
 
78
 
 
79
QRectF RectSelect::result() const
 
80
 
81
        return m_canvas->globalToCanvas(m_rectangle->geometry());
 
82
}
 
83
 
 
84
void RectSelect::mousePressEvent(QMouseEvent *m)
 
85
{
 
86
        prepare(m->globalPos());
 
87
        m->accept();
 
88
}
 
89
 
 
90
 
 
91
void RectSelect::mouseReleaseEvent(QMouseEvent *m)
 
92
{
 
93
//      qDebug() << "RectSelect::mouseRelease" << m->globalPos();
 
94
        setEnd(m->globalPos());
 
95
        m->accept();
 
96
        m_view->stopGesture();
 
97
}
 
98
 
 
99
void RectSelect::mouseMoveEvent(QMouseEvent *m)
 
100
{
 
101
        setEnd(m->globalPos());
 
102
        m->accept();
 
103
}