Scribus
Open source desktop publishing at your fingertips
canvasmode_editpolygon.h
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  canvasmode_editpolygon.h - description
17  -------------------
18  begin : Wed Jan 12 2011
19  copyright : (C) 2011 by Franz Schmid
20  email : Franz.Schmid@altmuehlnet.de
21  ***************************************************************************/
22 
23 #ifndef CANVAS_MODE_EDITPOLYGON_H
24 #define CANVAS_MODE_EDITPOLYGON_H
25 
26 #include <QObject>
27 #include <QTime>
28 
29 #include "canvasmode.h"
30 #include "fpointarray.h"
31 #include "ui/polyprops.h"
32 #include "undotransaction.h"
33 
34 class PageItem;
35 class ScribusMainWindow;
36 class ScribusView;
37 
38 
39 // This class encapsulate the old code for mouse interaction from scribusview.cpp
40 
42 {
43  Q_OBJECT
44 public:
45  explicit CanvasMode_EditPolygon(ScribusView* view);
46  virtual ~CanvasMode_EditPolygon() {}
47 
48  virtual void enterEvent(QEvent *);
49  virtual void leaveEvent(QEvent *);
50 
51  virtual void activate(bool);
52  virtual void deactivate(bool);
53  virtual void mouseDoubleClickEvent(QMouseEvent *m);
54  virtual void mouseReleaseEvent(QMouseEvent *m);
55  virtual void mouseMoveEvent(QMouseEvent *m);
56  virtual void mousePressEvent(QMouseEvent *m);
57  virtual void drawControls(QPainter* p);
58  void drawControlsPolygon(QPainter* pp, PageItem* currItem);
59 
60 private:
61 
62  typedef enum
63  {
64  noPointDefined,
65  useControlOuter,
66  useControlInner,
67  useControlInnerCurve,
68  useControlOuterCurve
69  } ePolygonPoint;
70 
71  inline bool GetItem(PageItem** pi);
72  double GetZeroFactor();
73  double GetMaxFactor();
74  double getUserValFromFactor(double factor);
75 
76  double Mxp, Myp;
77  ScribusMainWindow* m_ScMW;
78  QPointF startPoint;
79  QPointF endPoint;
80  QPointF centerPoint;
81  QPointF innerCPoint;
82  QPointF outerCPoint;
83  int polyCorners;
84  bool polyUseFactor;
85  double polyFactor;
86  double polyRotation;
87  double polyCurvature;
88  double polyInnerRot;
89  double polyOuterCurvature;
90  ePolygonPoint m_polygonPoint;
91  PolyVectorDialog *VectorDialog;
92  UndoTransaction m_transaction;
93 
94  int m_blockUpdateFromItem;
95  void blockUpdateFromItem(bool block) { if (block) ++m_blockUpdateFromItem; else --m_blockUpdateFromItem; }
96  bool updateFromItemBlocked() { return (m_blockUpdateFromItem > 0); }
97 
98 public slots:
99  void applyValues(int polyC, double polyF, bool polyUseCF, double polyR, double polyCur, double polyIRot, double polyOCur);
100  void updateFromItem();
101  void endEditing(bool active);
102  void endEditing();
103 };
104 
105 
106 #endif
Definition: undotransaction.h:45
virtual void drawControls(QPainter *p)
Definition: canvasmode_editpolygon.cpp:77
This Class is the base class for your application. It sets up the main window and providing a menubar...
Definition: scribus.h:123
Definition: polyprops.h:19
Definition: canvasmode.h:72
virtual void deactivate(bool)
Definition: canvasmode_editpolygon.cpp:221
virtual void activate(bool)
Definition: canvasmode_editpolygon.cpp:176
Definition: pageitem.h:92
Definition: scribusview.h:87
Definition: canvasmode_editpolygon.h:41