Home | History | Annotate | Download | only in gfx

Lines Matching refs:rect

5 #include "base/gfx/rect.h"
35 Rect::Rect() {
38 Rect::Rect(int width, int height) {
43 Rect::Rect(int x, int y, int width, int height)
49 Rect::Rect(const gfx::Point& origin, const gfx::Size& size)
54 Rect::Rect(const RECT& r)
60 Rect& Rect::operator=(const RECT& r) {
67 Rect::Rect(const CGRect& r)
73 Rect& Rect::operator=(const CGRect& r) {
80 Rect::Rect(const GdkRectangle& r)
86 Rect& Rect::operator=(const GdkRectangle& r) {
94 void Rect::set_width(int width) {
97 void Rect::set_height(int height) {
101 void Rect::SetRect(int x, int y, int width, int height) {
107 void Rect::Inset(int left, int top, int right, int bottom) {
113 void Rect::Offset(int horizontal, int vertical) {
118 bool Rect::operator==(const Rect& other) const {
123 RECT Rect::ToRECT() const {
124 RECT r;
132 CGRect Rect::ToCGRect() const {
136 GdkRectangle Rect::ToGdkRectangle() const {
142 bool Rect::Contains(int point_x, int point_y) const {
147 bool Rect::Contains(const Rect& rect) const {
148 return (rect.x() >= x() && rect.right() <= right() &&
149 rect.y() >= y() && rect.bottom() <= bottom());
152 bool Rect::Intersects(const Rect& rect) const {
153 return !(rect.x() >= right() || rect.right() <= x() ||
154 rect.y() >= bottom() || rect.bottom() <= y());
157 Rect Rect::Intersect(const Rect& rect) const {
158 int rx = std::max(x(), rect.x());
159 int ry = std::max(y(), rect.y());
160 int rr = std::min(right(), rect.right());
161 int rb = std::min(bottom(), rect.bottom());
166 return Rect(rx, ry, rr - rx, rb - ry);
169 Rect Rect::Union(const Rect& rect) const {
172 return rect;
173 if (rect.IsEmpty())
176 int rx = std::min(x(), rect.x());
177 int ry = std::min(y(), rect.y());
178 int rr = std::max(right(), rect.right());
179 int rb = std::max(bottom(), rect.bottom());
181 return Rect(rx, ry, rr - rx, rb - ry);
184 Rect Rect::Subtract(const Rect& rect) const {
186 if (!Intersects(rect))
188 if (rect.Contains(*this))
189 return Rect();
196 if (rect.y() <= y() && rect.bottom() >= bottom()) {
198 if (rect.x() <= x()) {
199 rx = rect.right();
201 rr = rect.x();
203 } else if (rect.x() <= x() && rect.right() >= right()) {
205 if (rect.y() <= y()) {
206 ry = rect.bottom();
208 rb = rect.y();
211 return Rect(rx, ry, rr - rx, rb - ry);
214 Rect Rect::AdjustToFit(const Rect& rect) const {
219 AdjustAlongAxis(rect.x(), rect.width(), &new_x, &new_width);
220 AdjustAlongAxis(rect.y(), rect.height(), &new_y, &new_height);
221 return Rect(new_x, new_y, new_width, new_height);
224 Point Rect::CenterPoint() const {
228 bool Rect::SharesEdgeWith(const gfx::Rect& rect) const {
229 return (y() == rect.y() && height() == rect.height() &&
230 (x() == rect.right() || right() == rect.x())) ||
231 (x() == rect.x() && width() == rect.width() &&
232 (y() == rect.bottom() || bottom() == rect.y()));
237 std::ostream& operator<<(std::ostream& out, const gfx::Rect& r) {