]>
Dogcows Code - chaz/openbox/blob - src/Geometry.cc
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 void Point::setX(const int x
) {
37 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 unsigned int w
, const unsigned int h
) : m_w(w
), m_h(h
) {
50 void Size::setW(const unsigned int w
) {
54 void Size::setH(const unsigned 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 unsigned int w
, const unsigned int h
)
66 : m_origin(x
, y
), m_size(w
, h
) {
69 void Rect::setSize(const Size
&size
) {
73 void Rect::setSize(const unsigned int w
, const unsigned int h
) {
78 void Rect::setOrigin(const Point
&origin
) {
82 void Rect::setOrigin(const int x
, const int y
) {
87 void Rect::setX(const int x
) {
91 void Rect::setY(const int y
) {
95 void Rect::setW(unsigned int w
) {
99 void Rect::setH(unsigned int h
) {
103 bool Rect::Intersect(const Rect
&r
) const {
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());
111 Rect
Rect::Inflate(const unsigned int i
) const {
112 return Rect(x(), y(), w()+i
, h()+i
);
115 Rect
Rect::Inflate(const unsigned int iw
, const unsigned int ih
) const {
116 return Rect(x(), y(), w()+iw
, h()+ih
);
119 Rect
Rect::Inflate(const Size
&i
) const {
120 return Rect(x(), y(), w()+i
.w(), h()+i
.h());
123 Rect
Rect::Deflate(const unsigned int d
) const {
124 return Rect(x(), y(), w()-d
, h()-d
);
127 Rect
Rect::Deflate(const unsigned int dw
, const unsigned int dh
) const {
128 return Rect(x(), y(), w()-dw
, h()-dh
);
131 Rect
Rect::Deflate(const Size
&d
) const {
132 return Rect(x(), y(), w()-d
.w(), h()-d
.h());
135 Rect
Rect::Translate(const int t
) const {
136 return Rect(x()+t
, y()+t
, w(), h());
139 Rect
Rect::Translate(const int tx
, const int ty
) const {
140 return Rect(x()+tx
, y()+ty
, w(), h());
143 Rect
Rect::Translate(const Point
&t
) const {
144 return Rect(x()+t
.x(), y()+t
.y(), w(), h());
This page took 0.04767 seconds and 4 git commands to generate.