00001 // Copyright (c) 2003 - 2004 Anselm R. Garbe <anselmg at t-online.de> 00002 // See ../LICENSE.txt for license details. 00003 // 00004 // $Id: rectangle.cpp 2 2007-05-16 10:38:27Z eg $ 00005 00006 #include "rectangle.h" 00007 00008 Rectangle::Rectangle() 00009 { 00010 x_ = 0; 00011 y_ = 0; 00012 w_ = 0; 00013 h_ = 0; 00014 } 00015 00016 Rectangle::Rectangle(int x, int y, unsigned int w, unsigned int h) { 00017 x_ = x; 00018 y_ = y; 00019 w_ = w; 00020 h_ = h; 00021 } 00022 00023 void Rectangle::copy(Rectangle *source) { 00024 x_ = source->x(); 00025 y_ = source->y(); 00026 w_ = source->width(); 00027 h_ = source->height(); 00028 } 00029 00030 bool Rectangle::fitsInto(Rectangle *rect) { 00031 return ((x_ >= rect->x()) && 00032 (y_ >= rect->y()) && 00033 (w_ <= rect->width()) && 00034 (h_ <= rect->height()) && 00035 (x_ + w_ <= rect->x() + rect->width()) && 00036 (y_ + h_ <= rect->y() + rect->height())); 00037 } 00038 00039 00040 Rectangle::~Rectangle() {}; 00041 00042 int Rectangle::x() const { return x_; }; 00043 void Rectangle::setX(int x) { x_ = x; }; 00044 00045 int Rectangle::y() const { return y_; }; 00046 void Rectangle::setY(int y) { y_ = y; }; 00047 00048 unsigned int Rectangle::width() const { return w_; }; 00049 void Rectangle::setWidth(unsigned int w) { w_ = w; }; 00050 00051 unsigned int Rectangle::height() const { return h_; }; 00052 void Rectangle::setHeight(unsigned int h) { h_ = h; };