1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef CANVAS_GESTURE_RULERMOVE_H
#define CANVAS_GESTURE_RULERMOVE_H
#include <QPoint>
#include "scribusapi.h"
#include "canvas.h"
#include "canvasgesture.h"
#include "canvasmode.h"
#include "scribusview.h"
class QCursor;
class QDragEnterEvent;
class QDragMoveEvent;
class QDragLeaveEvent;
class QDropEvent;
class QEvent;
class QInputMethodEvent;
class QMouseEvent;
class QKeyEvent;
class QPainter;
class ScribusMainWindow;
/**
This class realizes the moving of guides and the moving of the ruler origin
*/
class SCRIBUS_API RulerGesture : public CanvasGesture
{
Q_OBJECT
public:
enum Mode { HORIZONTAL, VERTICAL, ORIGIN };
RulerGesture (ScribusView* view, Mode mode) :
CanvasGesture(view), m_ScMW(m_view->m_ScMW), m_mode(mode), m_haveGuide(false), m_haveCursor(false), m_xy(0,0) {};
/**
Prepares the gesture for 'mode' without using an existing guide. If 'mode' is HORIZONTAL
or VERTICAL, a new guide will be created when the mouse is moved over a page.
*/
void prepare(Mode mode);
void clear();
virtual void drawControls(QPainter* p);
virtual void activate(bool);
virtual void deactivate(bool);
virtual void mouseReleaseEvent(QMouseEvent *m);
virtual void mouseMoveEvent(QMouseEvent *m);
/**
This method should be called when the mousebutton is pressed.
If there's a moveable guide near this position, it prepares the gesture for moving this guide.
*/
virtual void mousePressEvent(QMouseEvent *m);
Mode getMode() { return m_mode; }
/**
Use this to test if there's a moveable guide near this position.
It prepares the gesture for moving this guide.
*/
bool mouseHitsGuide(FPoint mousePointDoc);
/**
It tests for a guide near position, that guide being moveable or not.
If the test results in success, emits guideInfo;
*/
void mouseSelectGuide(QMouseEvent *m);
private:
ScribusMainWindow* m_ScMW;
Mode m_mode;
bool m_haveGuide;
int m_page;
double m_guide;
double m_currentGuide;
bool m_haveCursor;
QCursor m_cursor;
QPoint m_xy;
void movePoint(QMouseEvent *m, bool mouseRelease);
signals:
void guideInfo(int /*direction*/, qreal /*position*/);
};
#endif
|