00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __FL_RECT_H__
00023 #define __FL_RECT_H__
00024
00025 #include "Fl_Point.h"
00026
00028 class FL_API Fl_Rect
00029 {
00030 int x_, y_, width_, height_;
00031 public:
00032 Fl_Rect() : x_(0), y_(0), width_(0), height_(0) {}
00033 Fl_Rect(int x, int y, int w, int h) : x_(x), y_(y), width_(w), height_(h) {}
00034
00035 Fl_Rect &operator=( const Fl_Rect &r ) { set(r.x(), r.y(), r.w(), r.h()); return *this; }
00036
00037 bool pos_in_rect(int xs, int ys) const {
00038 if( xs > x_ && xs < (x_ + width_) && ys > y_ && ys < (y_ + height_) ) {
00039 return true;
00040 }
00041 return false;
00042 }
00043 bool posInRect(int x, int y) const { return pos_in_rect(x,y); }
00044
00045 bool pos_in_rect(Fl_Point p) const {
00046 if( p.x() > x_ && p.x() < (x_ + width_) && p.y() > y_ && p.y() < (y_ + height_) ) {
00047 return true;
00048 }
00049 return false;
00050 }
00051 bool posInRect(Fl_Point p) const { return pos_in_rect(p); }
00052
00053 int x() const { return x_; }
00054 int y() const { return y_; }
00055
00056 int w() const { return width(); }
00057 int width() const { return width_; }
00058
00059 int h() const { return height(); }
00060 int height() const { return height_; }
00061
00062 int left() const { return x(); }
00063 int right() const { return x()+w(); }
00064 int top() const { return y(); }
00065 int bottom() const { return y()+h(); }
00066
00067 void x(int x) { x_ = x; }
00068 void y(int y) { y_ = y; }
00069 void w(int w) { width_ = w; }
00070 void h(int h) { height_ = h; }
00071
00072 void set(int x, int y, int w, int h) { x_=x; y_=y; width_=w; height_=h; }
00073 };
00074
00075 #endif