]> Dogcows Code - chaz/openbox/blob - src/Geometry.cc
set the button windows to None when they are destroyed so we know they are no longer...
[chaz/openbox] / 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 unsigned int w, const unsigned int h) : m_w(w), m_h(h) {
48 }
49
50 void Size::setW(const unsigned int w) {
51 m_w = w;
52 }
53
54 void Size::setH(const unsigned 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 unsigned int w, const unsigned int h)
66 : m_origin(x, y), m_size(w, h) {
67 }
68
69 void Rect::setSize(const Size &size) {
70 m_size = size;
71 }
72
73 void Rect::setSize(const unsigned int w, const unsigned int h) {
74 m_size.setW(w);
75 m_size.setH(h);
76 }
77
78 void Rect::setOrigin(const Point &origin) {
79 m_origin = origin;
80 }
81
82 void Rect::setOrigin(const int x, const int y) {
83 m_origin.setX(x);
84 m_origin.setY(y);
85 }
86
87 void Rect::setX(const int x) {
88 m_origin.setX(x);
89 }
90
91 void Rect::setY(const int y) {
92 m_origin.setY(y);
93 }
94
95 void Rect::setW(unsigned int w) {
96 m_size.setW(w);
97 }
98
99 void Rect::setH(unsigned int h) {
100 m_size.setH(h);
101 }
102
103 bool Rect::Intersect(const Rect &r) const {
104 return
105 (x() < (r.x()+(signed)r.w()) ) &&
106 ( (x()+(signed)w()) > r.x()) &&
107 (y() < (r.y()+(signed)r.h()) ) &&
108 ( (y()+(signed)h()) > r.y());
109 }
110
111 Rect Rect::Inflate(const unsigned int i) const {
112 return Rect(x(), y(), w()+i, h()+i);
113 }
114
115 Rect Rect::Inflate(const unsigned int iw, const unsigned int ih) const {
116 return Rect(x(), y(), w()+iw, h()+ih);
117 }
118
119 Rect Rect::Inflate(const Size &i) const {
120 return Rect(x(), y(), w()+i.w(), h()+i.h());
121 }
122
123 Rect Rect::Deflate(const unsigned int d) const {
124 return Rect(x(), y(), w()-d, h()-d);
125 }
126
127 Rect Rect::Deflate(const unsigned int dw, const unsigned int dh) const {
128 return Rect(x(), y(), w()-dw, h()-dh);
129 }
130
131 Rect Rect::Deflate(const Size &d) const {
132 return Rect(x(), y(), w()-d.w(), h()-d.h());
133 }
134
135 Rect Rect::Translate(const int t) const {
136 return Rect(x()+t, y()+t, w(), h());
137 }
138
139 Rect Rect::Translate(const int tx, const int ty) const {
140 return Rect(x()+tx, y()+ty, w(), h());
141 }
142
143 Rect Rect::Translate(const Point &t) const {
144 return Rect(x()+t.x(), y()+t.y(), w(), h());
145 }
This page took 0.038993 seconds and 4 git commands to generate.