Subversion Repositories Scribus

Rev

Rev 13510 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5088 subik 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
 
10223 cbradney 11
#include <QPair>
5088 subik 12
 
13
#include "undoobject.h"
14
#include "scribusapi.h"
15
 
16
class QColor;
17
class Page;
18
class ScPainter;
19
class UndoManager;
10601 mrdocs 20
class ScribusDoc;
21
typedef QList<double> Guides;
5088 subik 22
 
23
/*! \brief Core manipulation with the guides.
24
Basic idea:
7715 subik 25
- guides are handled "on the fly", no by modal dialog.
26
- 2 types of guides: Standard = created one by one.
27
Auto = created by automatic division algorithms.
28
Automatic guides are kept by 2 ways: 1st its parameters (m_horizontalAutoCount etc.)
29
to setup the GUI and compute guides itself. 2nd the horizontalAutoG etc. set
30
with precomputed values from GUI actions for drawing.
5088 subik 31
- user can move only Stnadard ones
32
- Auto guides can be deleted only in manipulation dialog
10749 cbradney 33
- Auto guides are painted in different color / (probably) with diff. line.
7715 subik 34
\author Petr vanek <petr@scribus.info>
35
*/
5088 subik 36
class SCRIBUS_API GuideManagerCore
37
{
5164 tsoots 38
public:
39
        GuideManagerCore();
40
        GuideManagerCore(Page* parentPage);
41
        ~GuideManagerCore();
5088 subik 42
 
5164 tsoots 43
        typedef enum {Standard, Auto} GuideType;
5088 subik 44
 
5164 tsoots 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);
5088 subik 53
 
5164 tsoots 54
        Guides horizontals(GuideType type);
55
        Guides verticals(GuideType type);
56
        double horizontal(uint ix, GuideType type);
57
        double vertical(uint ix, GuideType type);
5088 subik 58
 
14732 jghali 59
        Guides getAutoHorizontals(Page* page = NULL);
60
        Guides getAutoVerticals(Page* page = NULL);
61
 
5164 tsoots 62
        void clearHorizontals(GuideType type);
63
        void clearVerticals(GuideType type);
5088 subik 64
 
5164 tsoots 65
        void copy(GuideManagerCore *target);
66
        void copy(GuideManagerCore *target, GuideType type);
5088 subik 67
 
5164 tsoots 68
        void drawPage(ScPainter *p, ScribusDoc *doc, double lineWidth);
5088 subik 69
 
11190 avox 70
        int isMouseOnHorizontal(double low, double high, GuideType type);
71
        int isMouseOnVertical(double low, double high, GuideType type);
5088 subik 72
 
5164 tsoots 73
        void setPage(Page *p);
5104 subik 74
 
6203 subik 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;
5164 tsoots 79
 
5909 subik 80
        //! \brief Properties for Auto guides remembrance. See GuideManager.
81
        int horizontalAutoCount() { return m_horizontalAutoCount; };
82
        //! \brief Properties for Auto guides remembrance. See GuideManager.
83
        void setHorizontalAutoCount(int val) { m_horizontalAutoCount = val; };
84
        //! \brief Properties for Auto guides remembrance. See GuideManager.
85
        int verticalAutoCount() { return m_verticalAutoCount; };
86
        //! \brief Properties for Auto guides remembrance. See GuideManager.
87
        void setVerticalAutoCount(int val) { m_verticalAutoCount = val; };
88
        //! \brief Properties for Auto guides remembrance. See GuideManager.
89
        double horizontalAutoGap(){ return m_horizontalAutoGap; };
90
        //! \brief Properties for Auto guides remembrance. See GuideManager.
91
        double verticalAutoGap(){return m_verticalAutoGap; };
92
        //! \brief Properties for Auto guides remembrance. See GuideManager.
93
        void setHorizontalAutoGap(double gap){ m_horizontalAutoGap = gap; };
94
        //! \brief Properties for Auto guides remembrance. See GuideManager.
95
        void setVerticalAutoGap(double gap){ m_verticalAutoGap = gap; };
96
        //! \brief Properties for Auto guides remembrance. See GuideManager.
6747 subik 97
        int horizontalAutoRefer() { return m_horizontalAutoRefer; };
5909 subik 98
        //! \brief Properties for Auto guides remembrance. See GuideManager.
6747 subik 99
        void setHorizontalAutoRefer(int val) { m_horizontalAutoRefer = val; };
100
        //! \brief Properties for Auto guides remembrance. See GuideManager.
101
        int verticalAutoRefer() { return m_verticalAutoRefer; };
102
        //! \brief Properties for Auto guides remembrance. See GuideManager.
103
        void setVerticalAutoRefer(int val) { m_verticalAutoRefer = val; };
5909 subik 104
 
7715 subik 105
        /*! \brief Selection/group coordinates
106
        It's used to simulate the original selection "freezed in time"
107
        for parent page */
108
        double gx, gy, gw, gh;
109
 
110
 
5164 tsoots 111
private:
112
        UndoManager * const undoManager;
5199 subik 113
        Page* m_page;
5164 tsoots 114
        Guides horizontalStdG;
115
        Guides verticalStdG;
7713 subik 116
        Guides horizontalAutoG;
117
        Guides verticalAutoG;
6203 subik 118
 
5909 subik 119
        double m_horizontalAutoGap;
120
        double m_verticalAutoGap;
121
        int m_horizontalAutoCount;
122
        int m_verticalAutoCount;
6747 subik 123
        int m_horizontalAutoRefer;
124
        int m_verticalAutoRefer;
5164 tsoots 125
 
6203 subik 126
        double closestHorAbove(double y);// const;
127
        double closestHorBelow(double y);// const;
128
        double closestVertLeft(double x);// const;
129
        double closestVertRight(double x);// const;
5088 subik 130
};
131
 
7682 subik 132
 
133
/*! \brief A separate clas for Guides IO operations in reading or closing
134
the documents.
135
\author Petr Vanek <petr@scribus.info>
136
*/
137
class SCRIBUS_API GuideManagerIO
138
{
139
        public:
140
                GuideManagerIO(){};
141
                ~GuideManagerIO(){};
142
 
143
                /*! \brief Read the guides from XML attribute (file opening).
144
                It's statis method sou you can call it without instance initialized:
145
                GuideManagerIO::readHorizontalGuides(foo blah);
146
                \param guideString a string with all values separated by space (' '). E.g. "1.0 23.17 6"
147
                \param page a reference to the Page object to append the separated guideString values
148
                \param type Guide type to load
149
                \param useOldGuides A little bit hacking here. The guides were stored in a little mess
150
                in the ancient times. So when is the obsolete XML attribute found in reading document
151
                the old reading method is used. All guides are saved in new format then. */
152
                static void readHorizontalGuides(const QString guideString,
153
                                                                                 Page *page,
154
                                                                                 GuideManagerCore::GuideType type,
155
                                                                                 bool useOldGuides=false);
156
 
157
                /*! \brief Read the guides from XML attribute (file opening).
158
                It's statis method sou you can call it without instance initialized:
159
                GuideManagerIO::readVerticalGuides(foo blah);
160
                \param guideString a string with all values separated by space (' '). E.g. "1.0 23.17 6"
161
                \param page a reference to the Page object to append the separated guideString values
162
                \param type Guide type to load
163
                \param useOldGuides A little bit hacking here. The guides were stored in a little mess
164
                in the ancient times. So when is the obsolete XML attribute found in reading document
165
                the old reading method is used. All guides are saved in new format then. */
166
                static void readVerticalGuides(const QString guideString,
167
                                                                           Page *page,
168
                                                                           GuideManagerCore::GuideType type,
169
                                                                           bool useOldGuides=false);
170
 
171
                static QString writeHorizontalGuides(Page *page, GuideManagerCore::GuideType type);
172
                static QString writeVerticalGuides(Page *page, GuideManagerCore::GuideType type);
7715 subik 173
 
174
                static void readSelection(const QString guideString, Page *page);
175
                static QString writeSelection(Page *page);
7682 subik 176
};
177
 
5088 subik 178
#endif