]>
Dogcows Code - chaz/openbox/blob - otk/rect.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
4 # include "../config.h"
11 void Rect::setX(int x
)
18 void Rect::setY(int y
)
25 void Rect::setPos(const Point
&location
)
27 _x2
+= location
.x() - _x1
;
29 _y2
+= location
.y() - _y1
;
34 void Rect::setPos(int x
, int y
)
43 void Rect::setWidth(int w
)
49 void Rect::setHeight(int h
)
55 void Rect::setSize(int w
, int h
)
62 void Rect::setSize(const Point
&size
)
64 _x2
= size
.x() + _x1
- 1;
65 _y2
= size
.y() + _y1
- 1;
69 void Rect::setRect(int x
, int y
, int w
, int h
)
71 *this = Rect(x
, y
, w
, h
);
75 void Rect::setRect(const Point
&location
, const Point
&size
)
77 *this = Rect(location
, size
);
81 void Rect::setCoords(int l
, int t
, int r
, int b
)
90 void Rect::setCoords(const Point
&tl
, const Point
&br
)
99 Rect
Rect::operator|(const Rect
&a
) const
103 b
._x1
= std::min(_x1
, a
._x1
);
104 b
._y1
= std::min(_y1
, a
._y1
);
105 b
._x2
= std::max(_x2
, a
._x2
);
106 b
._y2
= std::max(_y2
, a
._y2
);
112 Rect
Rect::operator&(const Rect
&a
) const
116 b
._x1
= std::max(_x1
, a
._x1
);
117 b
._y1
= std::max(_y1
, a
._y1
);
118 b
._x2
= std::min(_x2
, a
._x2
);
119 b
._y2
= std::min(_y2
, a
._y2
);
125 bool Rect::intersects(const Rect
&a
) const
127 return std::max(_x1
, a
._x1
) <= std::min(_x2
, a
._x2
) &&
128 std::max(_y1
, a
._y1
) <= std::min(_y2
, a
._y2
);
132 bool Rect::contains(int x
, int y
) const
134 return x
>= _x1
&& x
<= _x2
&&
135 y
>= _y1
&& y
<= _y2
;
139 bool Rect::contains(const Point
&p
) const
141 return contains(p
.x(), p
.y());
145 bool Rect::contains(const Rect
& a
) const
147 return a
._x1
>= _x1
&& a
._x2
<= _x2
&&
148 a
._y1
>= _y1
&& a
._y2
<= _y2
;
This page took 0.042227 seconds and 4 git commands to generate.