Scribus
Open source desktop publishing at your fingertips
margins.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  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef MARGINS_H
18 #define MARGINS_H
19 
20 #include <QDebug>
21 #if QT_VERSION >= 0x050300
22 #include <QMarginsF>
23 #endif
24 
26 {
27  public:
28  MarginStruct() : m_top(0), m_left(0), m_bottom(0), m_right(0) {}
29  MarginStruct(double top, double left, double bottom, double right) :
30  m_top(top), m_left(left), m_bottom(bottom), m_right(right) {}
31  MarginStruct(const MarginStruct& rhs) {m_top=rhs.m_top;m_bottom=rhs.m_bottom;m_left=rhs.m_left;m_right=rhs.m_right;}
32  void set(double top, double left, double bottom, double right) {m_top=top;m_bottom=bottom;m_left=left;m_right=right;}
33  void resetToZero() {m_top=0.0;m_bottom=0.0;m_left=0.0;m_right=0.0;}
34  bool isNull() const {return qFuzzyIsNull(m_left) && qFuzzyIsNull(m_top) && qFuzzyIsNull(m_right) && qFuzzyIsNull(m_bottom);}
35  //bool hasNonZeroValue() const { return m_top!=0.0 || m_bottom!=0.0 || m_left!=0.0 || m_right!=0.0;}
36  void print() const {qDebug() << m_top << m_left << m_bottom << m_right;}
37  inline double left() const { return m_left; }
38  inline double top() const { return m_top; }
39  inline double bottom() const { return m_bottom; }
40  inline double right() const { return m_right; }
41 
42  inline void setLeft(double aleft) { m_left = aleft; }
43  inline void setTop(double atop) { m_top = atop; }
44  inline void setRight(double aright) { m_right = aright; }
45  inline void setBottom(double abottom) { m_bottom = abottom; }
46 
47 
48  protected:
49  double m_top;
50  double m_left;
51  double m_bottom;
52  double m_right;
53 };
54 
55 #if QT_VERSION >= 0x050300
56 class ScMargins : public QMarginsF
57 {
58  public:
59  ScMargins(qreal left, qreal top, qreal right, qreal bottom) : QMarginsF(left, top, right, bottom) {};
60  void set(qreal left, qreal top, qreal right, qreal bottom)
61  {
62  setTop(top);
63  setBottom(bottom);
64  setLeft(left);
65  setRight(right);
66  }
67 };
68 #endif
69 
70 #endif // MARGINS_H
Pagemargins and bleeds.
Definition: margins.h:25