1 // Geometry.cc for Openbox
2 // Copyright (c) 2002 - 2002 ben Jansens (ben@orodu.net)
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:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
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.
24 Point::Point() : m_x(0), m_y(0) {
27 Point::Point(const Point &point) : m_x(point.m_x), m_y(point.m_y) {
30 Point::Point(const int x, const int y) : m_x(x), m_y(y) {
33 inline void Point::setX(const int x) {
37 inline void Point::setY(const int y) {
41 Size::Size() : m_w(0), m_h(0) {
44 Size::Size(const Size &size) : m_w(size.m_w), m_h(size.m_h) {
47 Size::Size(const int w, const int h) : m_w(w), m_h(h) {
50 inline void Size::setW(const int w) {
54 inline void Size::setH(const int h) {
58 Rect::Rect() : m_origin(0, 0), m_size(0, 0) {
61 Rect::Rect(const Point &origin, const Size &size) : m_origin(origin),
65 Rect::Rect(const int x, const int y, const int w, const int h) : m_origin(x, y),
69 void Rect::setSize(const Size &size) {
73 void Rect::setOrigin(const Point &origin) {
77 void Rect::setX(const int x) {
81 void Rect::setY(const int y) {
85 void Rect::setW(int w) {
89 void Rect::setH(int h) {
93 bool Rect::Intersect(const Rect &r) const {
95 (x() < (r.x()+r.w()) ) &&
96 ( (x()+w()) > r.x()) &&
97 (y() < (r.y()+r.h()) ) &&