wmi

git clone git://oldgit.suckless.org/wmi/
Log | Files | Refs | LICENSE

rectangle.cpp (1163B)


      1 // Copyright (c) 2003 - 2009 Anselm R Garbe <anselm@garbe.us>
      2 // See LICENSE for license details.
      3 
      4 #include "rectangle.h"
      5 
      6 Rectangle::Rectangle()
      7 {
      8     x_ = 0;
      9     y_ = 0;
     10     w_ = 0;
     11     h_ = 0;
     12 }
     13 
     14 Rectangle::Rectangle(int x, int y, unsigned int w, unsigned int h) {
     15     x_ = x;
     16     y_ = y;
     17     w_ = w;
     18     h_ = h;
     19 }
     20 
     21 void Rectangle::copy(Rectangle *source) {
     22     x_ = source->x();
     23     y_ = source->y();
     24     w_ = source->width();
     25     h_ = source->height();
     26 }
     27 
     28 bool Rectangle::fitsInto(Rectangle *rect) {
     29     return ((x_ >= rect->x()) &&
     30             (y_ >= rect->y()) &&
     31             (w_ <= rect->width()) &&
     32             (h_ <= rect->height()) &&
     33             (x_ + w_ <= rect->x() + rect->width()) &&
     34             (y_ + h_ <= rect->y() + rect->height()));
     35 }
     36 
     37 
     38 Rectangle::~Rectangle() {}
     39 
     40 int Rectangle::x() const { return x_; }
     41 void Rectangle::setX(int x) { x_ = x; }
     42 
     43 int Rectangle::y() const { return y_; }
     44 void Rectangle::setY(int y) { y_ = y; }
     45 
     46 unsigned int Rectangle::width() const { return w_; }
     47 void Rectangle::setWidth(unsigned int w) { w_ = w; }
     48 
     49 unsigned int Rectangle::height() const { return h_; }
     50 void Rectangle::setHeight(unsigned int h) { h_ = h; }