1 /*
2  For general Scribus (>=1.3.2) copyright and licensing information please refer
3  to the COPYING file provided with the program. Following this notice may exist
4  a copyright and/or license notice that predates the release of Scribus 1.3.2
5  for which a new license (GPL+exception) is in place.
6  */
7 /***************************************************************************
8 *                                                                         *
9 *   This program is free software; you can redistribute it and/or modify  *
10 *   it under the terms of the GNU General Public License as published by  *
11 *   the Free Software Foundation; either version 2 of the License, or     *
12 *   (at your option) any later version.                                   *
13 *                                                                         *
14 ***************************************************************************/
15 
16 #ifndef CANVAS_MODE_ROTATE_H
17 #define CANVAS_MODE_ROTATE_H
18 
19 #include "scribusapi.h"
20 #include "canvasmode.h"
21 #include "fpoint.h"
22 
23 class QDragEnterEvent;
24 class QDragMoveEvent;
25 class QDragLeaveEvent;
26 class QDropEvent;
27 class QEvent;
28 class QInputMethodEvent;
29 class QMouseEvent;
30 class QKeyEvent;
31 class QPainter;
32 
33 class PageItem;
34 
35 class SCRIBUS_API CanvasMode_Rotate : public CanvasMode
36 {
37 	public:
38 		explicit CanvasMode_Rotate(ScribusView* view);
39 		~CanvasMode_Rotate() override = default;
40 
41 		void enterEvent(QEvent *) override;
42 		void leaveEvent(QEvent *) override;
43 
44 		void drawControls(QPainter* p) override;
45 		void activate(bool) override;
46 		void deactivate(bool) override;
47 
48 		void keyReleaseEvent(QKeyEvent *e) override;
49 		void keyPressEvent(QKeyEvent *e) override;
50 
51 		void mousePressEvent(QMouseEvent *m) override;
52 		void mouseReleaseEvent(QMouseEvent *m) override;
53 		void mouseMoveEvent(QMouseEvent *m) override;
54 
55 	private:
56 		inline bool GetItem(PageItem** pi);
57 
58 		void   createContextMenu(PageItem *currItem, double mx, double my);
59 		void   drawItemOutlines(QPainter*);
60 		void   getNewItemPosition(PageItem* item, FPoint& pos, double& rotation);
61 		// 	void   setResizeCursor(int how);
62 
63 		FPoint m_canvasCurrCoord;
64 		FPoint m_canvasPressCoord;
65 		FPoint m_oldRotCenter;
66 		FPoint m_rotCenter;
67 		bool   m_angleConstrained {false};
68 		bool   m_inItemRotation {false};
69 		double m_startAngle {0.0};
70 		int    m_oldRotMode {0};
71 		int    m_rotMode {0};
72 };
73 
74 #endif
75