From 7ed83b6c6666eb8b6b104c211ae7e52907350372 Mon Sep 17 00:00:00 2001 From: craig Date: Sun, 1 Jan 2012 11:40:09 +0000 Subject: Branch 1.3.5 tree to 1.4.x tree, goodbye 1.3.x git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17163 11d20701-8431-0410-a711-e3c959e3b870 --- scribus/canvasgesture_rulermove.h | 98 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 scribus/canvasgesture_rulermove.h (limited to 'scribus/canvasgesture_rulermove.h') diff --git a/scribus/canvasgesture_rulermove.h b/scribus/canvasgesture_rulermove.h new file mode 100644 index 0000000..5821e28 --- /dev/null +++ b/scribus/canvasgesture_rulermove.h @@ -0,0 +1,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 + +#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 -- cgit