~ubuntu-branches/ubuntu/saucy/emscripten/saucy-proposed

« back to all changes in this revision

Viewing changes to tests/poppler/cpp/poppler-rectangle.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
24
namespace poppler
 
25
{
 
26
 
 
27
template <typename T> class rectangle
 
28
{
 
29
public:
 
30
    rectangle()
 
31
        : x1(), y1(), x2(), y2()
 
32
    {}
 
33
    rectangle(T _x, T _y, T w, T h)
 
34
        : x1(_x), y1(_y), x2(x1 + w), y2(y1 + h)
 
35
    {}
 
36
    ~rectangle()
 
37
    {}
 
38
 
 
39
    bool is_empty() const
 
40
    { return (x1 == x2) && (y1 == y2); }
 
41
 
 
42
    T x() const
 
43
    { return x1; }
 
44
 
 
45
    T y() const
 
46
    { return y1; }
 
47
 
 
48
    T width() const
 
49
    { return x2 - x1; }
 
50
 
 
51
    T height() const
 
52
    { return y2 - y1; }
 
53
 
 
54
    T left() const
 
55
    { return x1; }
 
56
    T top() const
 
57
    { return y1; }
 
58
    T right() const
 
59
    { return x2; }
 
60
    T bottom() const
 
61
    { return y2; }
 
62
 
 
63
    void set_left(T value)
 
64
    { x1 = value; }
 
65
    void set_top(T value)
 
66
    { y1 = value; }
 
67
    void set_right(T value)
 
68
    { x2 = value; }
 
69
    void set_bottom(T value)
 
70
    { y2 = value; }
 
71
 
 
72
private:
 
73
    T x1, y1, x2, y2;
 
74
};
 
75
 
 
76
typedef rectangle<int> rect;
 
77
typedef rectangle<double> rectf;
 
78
 
 
79
POPPLER_CPP_EXPORT std::ostream& operator<<(std::ostream& stream, const rect &r);
 
80
POPPLER_CPP_EXPORT std::ostream& operator<<(std::ostream& stream, const rectf &r);
 
81
 
 
82
}
 
83
 
 
84
#endif