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