Scribus
Open source desktop publishing at your fingertips
guidemanagercore.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 #ifndef GUIDEMANAGERCORE_H
9 #define GUIDEMANAGERCORE_H
10 
11 #include <QPair>
12 
13 #include "undoobject.h"
14 #include "scribusapi.h"
15 
16 class QColor;
17 class ScPage;
18 class ScPainter;
19 class UndoManager;
20 class ScribusDoc;
21 typedef QList<double> Guides;
22 
36 class SCRIBUS_API GuideManagerCore
37 {
38 public:
40  GuideManagerCore(ScPage* parentPage);
42 
43  typedef enum {Standard, Auto} GuideType;
44 
45  void addHorizontal(double value, GuideType type);
46  void addHorizontals(Guides values, GuideType type);
47  void addVertical(double value, GuideType type);
48  void addVerticals(Guides values, GuideType type);
49  void deleteHorizontal(double value, GuideType type);
50  void deleteVertical(double value, GuideType type);
51  void moveHorizontal(double from, double to, GuideType type);
52  void moveVertical(double from, double to, GuideType type);
53 
54  Guides horizontals(GuideType type);
55  Guides verticals(GuideType type);
56  double horizontal(uint ix, GuideType type);
57  double vertical(uint ix, GuideType type);
58 
59  Guides getAutoHorizontals(ScPage* page = NULL);
60  Guides getAutoVerticals(ScPage* page = NULL);
61 
62  void clearHorizontals(GuideType type);
63  void clearVerticals(GuideType type);
64 
65  void copy(GuideManagerCore *target);
66  void copy(GuideManagerCore *target, GuideType type);
67 
68  void drawPage(ScPainter *p, ScribusDoc *doc, double lineWidth);
69 
70  int isMouseOnHorizontal(double low, double high, GuideType type);
71  int isMouseOnVertical(double low, double high, GuideType type);
72 
73  void setPage(ScPage *p);
74 
75  QPair<double, double> topLeft(double x, double y);// const;
76  QPair<double, double> topRight(double x, double y);// const;
77  QPair<double, double> bottomLeft(double x, double y);// const;
78  QPair<double, double> bottomRight(double x, double y);// const;
79 
81  int horizontalAutoCount() { return m_horizontalAutoCount; };
83  void setHorizontalAutoCount(int val) { m_horizontalAutoCount = val; };
85  int verticalAutoCount() { return m_verticalAutoCount; };
87  void setVerticalAutoCount(int val) { m_verticalAutoCount = val; };
89  double horizontalAutoGap(){ return m_horizontalAutoGap; };
91  double verticalAutoGap(){return m_verticalAutoGap; };
93  void setHorizontalAutoGap(double gap){ m_horizontalAutoGap = gap; };
95  void setVerticalAutoGap(double gap){ m_verticalAutoGap = gap; };
97  int horizontalAutoRefer() { return m_horizontalAutoRefer; };
99  void setHorizontalAutoRefer(int val) { m_horizontalAutoRefer = val; };
101  int verticalAutoRefer() { return m_verticalAutoRefer; };
103  void setVerticalAutoRefer(int val) { m_verticalAutoRefer = val; };
104 
108  double gx, gy, gw, gh;
109 
110 
111 private:
112  UndoManager * const undoManager;
113  ScPage* m_page;
114  Guides horizontalStdG;
115  Guides verticalStdG;
116  Guides horizontalAutoG;
117  Guides verticalAutoG;
118 
119  double m_horizontalAutoGap;
120  double m_verticalAutoGap;
121  int m_horizontalAutoCount;
122  int m_verticalAutoCount;
123  int m_horizontalAutoRefer;
124  int m_verticalAutoRefer;
125 
126  double closestHorAbove(double y);// const;
127  double closestHorBelow(double y);// const;
128  double closestVertLeft(double x);// const;
129  double closestVertRight(double x);// const;
130 };
131 
132 
137 class SCRIBUS_API GuideManagerIO
138 {
139  public:
140  GuideManagerIO(){};
141  ~GuideManagerIO(){};
142 
152  static void readHorizontalGuides(const QString guideString,
153  ScPage *page,
154  GuideManagerCore::GuideType type,
155  bool useOldGuides=false);
156 
166  static void readVerticalGuides(const QString guideString,
167  ScPage *page,
168  GuideManagerCore::GuideType type,
169  bool useOldGuides=false);
170 
171  static QString writeHorizontalGuides(ScPage *page, GuideManagerCore::GuideType type);
172  static QString writeVerticalGuides(ScPage *page, GuideManagerCore::GuideType type);
173 
174  static void readSelection(const QString guideString, ScPage *page);
175  static QString writeSelection(ScPage *page);
176 };
177 
178 #endif
A separate clas for Guides IO operations in reading or closing the documents.
Definition: guidemanagercore.h:137
void setVerticalAutoRefer(int val)
Properties for Auto guides remembrance. See GuideManager.
Definition: guidemanagercore.h:103
void setHorizontalAutoCount(int val)
Properties for Auto guides remembrance. See GuideManager.
Definition: guidemanagercore.h:83
Definition: scpage.h:46
void setVerticalAutoCount(int val)
Properties for Auto guides remembrance. See GuideManager.
Definition: guidemanagercore.h:87
int verticalAutoRefer()
Properties for Auto guides remembrance. See GuideManager.
Definition: guidemanagercore.h:101
int verticalAutoCount()
Properties for Auto guides remembrance. See GuideManager.
Definition: guidemanagercore.h:85
int horizontalAutoCount()
Properties for Auto guides remembrance. See GuideManager.
Definition: guidemanagercore.h:81
Core manipulation with the guides. Basic idea:
Definition: guidemanagercore.h:36
the Document Class
Definition: scribusdoc.h:90
Definition: scpainter.h:33
double verticalAutoGap()
Properties for Auto guides remembrance. See GuideManager.
Definition: guidemanagercore.h:91
int horizontalAutoRefer()
Properties for Auto guides remembrance. See GuideManager.
Definition: guidemanagercore.h:97
double horizontalAutoGap()
Properties for Auto guides remembrance. See GuideManager.
Definition: guidemanagercore.h:89
UndoManager handles the undo stack.
Definition: undomanager.h:81
void setVerticalAutoGap(double gap)
Properties for Auto guides remembrance. See GuideManager.
Definition: guidemanagercore.h:95
void setHorizontalAutoGap(double gap)
Properties for Auto guides remembrance. See GuideManager.
Definition: guidemanagercore.h:93
void setHorizontalAutoRefer(int val)
Properties for Auto guides remembrance. See GuideManager.
Definition: guidemanagercore.h:99