Poppler CPP 25.12.90
poppler-rectangle.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009-2010, Pino Toscano <pino@kde.org>
3 * Copyright (C) 2025, Albert Astals Cid <aacid@kde.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#ifndef POPPLER_RECTANGLE_H
21#define POPPLER_RECTANGLE_H
22
23#include "poppler-global.h"
24
25namespace poppler {
26
27template<typename T>
28class rectangle
29{
30public:
31 rectangle() : x1(), y1(), x2(), y2() { }
32 rectangle(T _x, T _y, T w, T h) : x1(_x), y1(_y), x2(x1 + w), y2(y1 + h) { }
33 ~rectangle() = default;
34
35 bool is_empty() const { return (x1 == x2) && (y1 == y2); }
36
37 T x() const { return x1; }
38
39 T y() const { return y1; }
40
41 T width() const { return x2 - x1; }
42
43 T height() const { return y2 - y1; }
44
45 T left() const { return x1; }
46 T top() const { return y1; }
47 T right() const { return x2; }
48 T bottom() const { return y2; }
49
50 void set_left(T value) { x1 = value; }
51 void set_top(T value) { y1 = value; }
52 void set_right(T value) { x2 = value; }
53 void set_bottom(T value) { y2 = value; }
54
55private:
56 T x1, y1, x2, y2;
57};
58
61
62POPPLER_CPP_EXPORT std::ostream &operator<<(std::ostream &stream, const rect r);
63POPPLER_CPP_EXPORT std::ostream &operator<<(std::ostream &stream, const rectf &r);
64
65}
66
67#endif
A rectangle.
Definition poppler-rectangle.h:29
Single namespace containing all the classes and functions of poppler-cpp.
Definition poppler-destination.h:27
rectangle< int > rect
A rectangle with int dimensions and coordinates.
Definition poppler-rectangle.h:59
rectangle< double > rectf
A rectangle with float (double) dimensions and coordinates.
Definition poppler-rectangle.h:60