Back to index

scribus-ng  1.3.4.dfsg+svn20071115
guidemanagercore.h
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 
00008 #ifndef GUIDEMANAGERCORE_H
00009 #define GUIDEMANAGERCORE_H
00010 
00011 #include <qpair.h>
00012 #include <qvaluelist.h>
00013 
00014 #include "scribusstructs.h"
00015 #include "undoobject.h"
00016 #include "scribusapi.h"
00017 
00018 class QColor;
00019 class Page;
00020 class ScPainter;
00021 class UndoManager;
00022 
00023 
00037 class SCRIBUS_API GuideManagerCore
00038 {
00039 public:
00040        GuideManagerCore();
00041        GuideManagerCore(Page* parentPage);
00042        ~GuideManagerCore();
00043 
00044        typedef enum {Standard, Auto} GuideType;
00045 
00046        void addHorizontal(double value, GuideType type);
00047        void addHorizontals(Guides values, GuideType type);
00048        void addVertical(double value, GuideType type);
00049        void addVerticals(Guides values, GuideType type);
00050        void deleteHorizontal(double value, GuideType type);
00051        void deleteVertical(double value, GuideType type);
00052        void moveHorizontal(double from, double to, GuideType type);
00053        void moveVertical(double from, double to, GuideType type);
00054 
00055        Guides horizontals(GuideType type);
00056        Guides verticals(GuideType type);
00057        double horizontal(uint ix, GuideType type);
00058        double vertical(uint ix, GuideType type);
00059 
00060        void clearHorizontals(GuideType type);
00061        void clearVerticals(GuideType type);
00062 
00063        void copy(GuideManagerCore *target);
00064        void copy(GuideManagerCore *target, GuideType type);
00065 
00066        void drawPage(ScPainter *p, ScribusDoc *doc, double lineWidth);
00067 
00068        bool isMouseOnHorizontal(double low, double high, GuideType type);
00069        bool isMouseOnVertical(double low, double high, GuideType type);
00070 
00071        void setPage(Page *p);
00072 
00073        QPair<double, double> topLeft(double x, double y);// const;
00074        QPair<double, double> topRight(double x, double y);// const;
00075        QPair<double, double> bottomLeft(double x, double y);// const;
00076        QPair<double, double> bottomRight(double x, double y);// const;
00077 
00079        int horizontalAutoCount() { return m_horizontalAutoCount; };
00081        void setHorizontalAutoCount(int val) { m_horizontalAutoCount = val; };
00083        int verticalAutoCount() { return m_verticalAutoCount; };
00085        void setVerticalAutoCount(int val) { m_verticalAutoCount = val; };
00087        double horizontalAutoGap(){ return m_horizontalAutoGap; };
00089        double verticalAutoGap(){return m_verticalAutoGap; };
00091        void setHorizontalAutoGap(double gap){ m_horizontalAutoGap = gap; };
00093        void setVerticalAutoGap(double gap){ m_verticalAutoGap = gap; };
00095        int horizontalAutoRefer() { return m_horizontalAutoRefer; };
00097        void setHorizontalAutoRefer(int val) { m_horizontalAutoRefer = val; };
00099        int verticalAutoRefer() { return m_verticalAutoRefer; };
00101        void setVerticalAutoRefer(int val) { m_verticalAutoRefer = val; };
00102 
00106        double gx, gy, gw, gh;
00107 
00108 
00109 private:
00110        UndoManager * const undoManager;
00111        Page* m_page;
00112        Guides horizontalStdG;
00113        Guides verticalStdG;
00114        Guides horizontalAutoG;
00115        Guides verticalAutoG;
00116 
00117        double m_horizontalAutoGap;
00118        double m_verticalAutoGap;
00119        int m_horizontalAutoCount;
00120        int m_verticalAutoCount;
00121        int m_horizontalAutoRefer;
00122        int m_verticalAutoRefer;
00123 
00124        double closestHorAbove(double y);// const;
00125        double closestHorBelow(double y);// const;
00126        double closestVertLeft(double x);// const;
00127        double closestVertRight(double x);// const;
00128 };
00129 
00130 
00135 class SCRIBUS_API GuideManagerIO
00136 {
00137        public:
00138               GuideManagerIO(){};
00139               ~GuideManagerIO(){};
00140 
00150               static void readHorizontalGuides(const QString guideString,
00151                                                                        Page *page,
00152                                                                        GuideManagerCore::GuideType type,
00153                                                                        bool useOldGuides=false);
00154 
00164               static void readVerticalGuides(const QString guideString,
00165                                                                   Page *page,
00166                                                                   GuideManagerCore::GuideType type,
00167                                                                   bool useOldGuides=false);
00168 
00169               static QString writeHorizontalGuides(Page *page, GuideManagerCore::GuideType type);
00170               static QString writeVerticalGuides(Page *page, GuideManagerCore::GuideType type);
00171 
00172               static void readSelection(const QString guideString, Page *page);
00173               static QString writeSelection(Page *page);
00174 };
00175 
00176 #endif