Scribus
Open source desktop publishing at your fingertips
cellarea.h
1 /*
2  * Copyright (C) 2011 Elvis Stansvik <elvstone@gmail.com>
3  *
4  * For general Scribus (>=1.3.2) copyright and licensing information please refer
5  * to the COPYING file provided with the program. Following this notice may exist
6  * a copyright and/or license notice that predates the release of Scribus 1.3.2
7  * for which a new license (GPL+exception) is in place.
8  */
9 #ifndef CELLAREA_H
10 #define CELLAREA_H
11 
12 #include "scribusapi.h"
13 
22 class SCRIBUS_API CellArea
23 {
24 public:
26  CellArea();
27 
29  CellArea(int row, int column, int width, int height);
30 
32  CellArea(const CellArea& other);
33 
35  bool isValid() const { return m_width >= 1 && m_height >= 1; }
36 
38  int row() const { return m_row; }
40  void setRow(int row) { m_row = row; }
41 
43  int column() const { return m_column; }
45  void setColumn(int column) { m_column = column; }
46 
48  int width() const { return m_width; }
50  void setWidth(int width) { m_width = width; }
51 
53  int height() const { return m_height; }
55  void setHeight(int height) { m_height = height; }
56 
58  int bottom() const { return m_row + m_height - 1; }
60  int right() const { return m_column + m_width - 1; }
61 
63  bool contains(int row, int column) const;
65  bool contains(const CellArea& area) const;
66 
68  bool intersects(const CellArea& area);
69 
71  CellArea translated(int rows, int columns) const;
73  void translate(int rows, int columns);
74 
76  CellArea adjusted(int rows, int columns, int width, int height) const;
78  void adjust(int rows, int columns, int width, int height);
79 
81  CellArea united(CellArea& area) const;
82 
91  CellArea adjustedForRowInsertion(int index, int numRows);
92 
101  CellArea adjustedForRowRemoval(int index, int numRows);
102 
111  CellArea adjustedForColumnInsertion(int index, int numColumns);
112 
121  CellArea adjustedForColumnRemoval(int index, int numColumns);
122 
123 private:
124  int m_row;
125  int m_column;
126  int m_width;
127  int m_height;
128 };
129 Q_DECLARE_TYPEINFO(CellArea, Q_MOVABLE_TYPE);
130 
131 bool operator==(const CellArea& lhs, const CellArea& rhs);
132 bool operator!=(const CellArea& lhs, const CellArea& rhs);
133 QDebug operator<<(QDebug debug, const CellArea& area);
134 
135 #endif // CELLAREA_H
int column() const
Returns the start column of the area.
Definition: cellarea.h:43
int height() const
Returns the height of the area.
Definition: cellarea.h:53
void setWidth(int width)
Sets the width of the area to width.
Definition: cellarea.h:50
void setHeight(int height)
Sets the height of the area to height.
Definition: cellarea.h:55
std::ostream & operator<<(std::ostream &out_file, const Geom::Matrix &m)
Definition: matrix.h:109
void setColumn(int column)
Sets the start column of the area to column.
Definition: cellarea.h:45
int bottom() const
Returns the bottom row of the area.
Definition: cellarea.h:58
int row() const
Returns the start row of the area.
Definition: cellarea.h:38
int width() const
Returns the width of the area.
Definition: cellarea.h:48
int right() const
Returns the right column of the area.
Definition: cellarea.h:60
bool isValid() const
Returns true if the area is valid.
Definition: cellarea.h:35
void setRow(int row)
Sets the start row of the area to row.
Definition: cellarea.h:40
Definition: cellarea.h:22