]> icculus.org git repositories - mikachu/openbox.git/blob - src/Geometry.cc
changed OpenboxWindow to not have getFrameX/getWidth/etc functions, and to return...
[mikachu/openbox.git] / src / Geometry.cc
1 // Geometry.cc for Openbox
2 // Copyright (c) 2002 - 2002 ben Jansens (ben@orodu.net)
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
21
22 #include "Geometry.h"
23
24 Point::Point() : m_x(0), m_y(0) {
25 }
26
27 Point::Point(const Point &point) : m_x(point.m_x), m_y(point.m_y) {
28 }
29
30 Point::Point(const int x, const int y) : m_x(x), m_y(y) {
31 }
32
33 void Point::setX(const int x) {
34   m_x = x;
35 }
36
37 void Point::setY(const int y) {
38   m_y = y;
39 }
40
41 Size::Size() : m_w(0), m_h(0) {
42 }
43
44 Size::Size(const Size &size) : m_w(size.m_w), m_h(size.m_h) {
45 }
46
47 Size::Size(const int w, const int h) : m_w(w), m_h(h) {
48 }
49
50 void Size::setW(const int w) {
51   m_w = w;
52 }
53
54 void Size::setH(const int h) {
55   m_h = h;
56 }
57
58 Rect::Rect() : m_origin(0, 0), m_size(0, 0) {
59 }
60
61 Rect::Rect(const Point &origin, const Size &size) : m_origin(origin),
62   m_size(size) {
63 }
64
65 Rect::Rect(const int x, const int y, const int w, const int h) : m_origin(x, y),
66   m_size(w, h) {
67 }
68
69 void Rect::setSize(const Size &size) {
70   m_size = size;
71 }
72
73 void Rect::setOrigin(const Point &origin) {
74   m_origin = origin;
75 }
76
77 void Rect::setX(const int x) {
78   m_origin.setX(x);
79 }
80
81 void Rect::setY(const int y) {
82   m_origin.setY(y);
83 }
84
85 void Rect::setW(int w) {
86   m_size.setW(w);
87 }
88
89 void Rect::setH(int h) {
90   m_size.setH(h);
91 }
92
93 bool Rect::Intersect(const Rect &r) const {
94   return
95     (x() < (r.x()+r.w()) ) &&
96     ( (x()+w()) > r.x()) &&
97     (y() < (r.y()+r.h()) ) &&
98     ( (y()+h()) > r.y());
99 }