X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Frect.hh;h=de4f5e0397174700c5b83fb0a7fcd56fc866decb;hb=59ef3022a4ce0a23e6d54f7d73a2aa77721e9cc9;hp=dc3d05d658b41008cd880d5684b36dc4a94784ae;hpb=bf160f210a5cb3a05add2684b915379b64cdcfa1;p=chaz%2Fopenbox diff --git a/otk/rect.hh b/otk/rect.hh index dc3d05d6..de4f5e03 100644 --- a/otk/rect.hh +++ b/otk/rect.hh @@ -1,4 +1,4 @@ -// -*- mode: C++; indent-tabs-mode: nil; -*- +// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- #ifndef __rect_hh #define __rect_hh @@ -6,6 +6,7 @@ extern "C" { #include } +#include "point.hh" #include namespace otk { @@ -24,7 +25,7 @@ public: @param w The width of the rectangle @param h The height of the rectangle */ - inline Rect(int x, int y, unsigned int w, unsigned int h) + inline Rect(int x, int y, int w, int h) : _x1(x), _y1(y), _x2(w + x - 1), _y2(h + y - 1) { } //! Constructs a Rect from 2 Point objects /*! @@ -34,6 +35,12 @@ public: inline Rect(const Point &location, const Point &size) : _x1(location.x()), _y1(location.y()), _x2(size.x() + location.x() - 1), _y2(size.y() + location.y() - 1) { } + //! Constructs a Rect from another Rect + /*! + @param rect The rectangle from which to construct this new one + */ + inline Rect(const Rect &rect) + : _x1(rect._x1), _y1(rect._y1), _x2(rect._x2), _y2(rect._y2) { } //! Constructs a Rect from an XRectangle inline explicit Rect(const XRectangle& xrect) : _x1(xrect.x), _y1(xrect.y), _x2(xrect.width + xrect.x - 1), @@ -82,9 +89,9 @@ public: void setPos(const Point &location); //! The width of the Rect - inline unsigned int width(void) const { return _x2 - _x1 + 1; } + inline int width(void) const { return _x2 - _x1 + 1; } //! The height of the Rect - inline unsigned int height(void) const { return _y2 - _y1 + 1; } + inline int height(void) const { return _y2 - _y1 + 1; } //! Returns the size of the Rect inline Point size() const { return Point(_x2 - _x1 + 1, _y2 - _y1 + 1); } @@ -92,18 +99,18 @@ public: /*! @param w The new width of the rectangle */ - void setWidth(unsigned int w); + void setWidth(int w); //! Sets the height of the Rect /*! @param h The new height of the rectangle */ - void setHeight(unsigned int h); + void setHeight(int h); //! Sets the size of the Rect. /*! @param w The new width of the rectangle @param h The new height of the rectangle */ - void setSize(unsigned int w, unsigned int h); + void setSize(int w, int h); //! Sets the size of the Rect. /*! @param size The new size of the rectangle @@ -119,7 +126,7 @@ public: @param w The new width of the rectangle @param h The new height of the rectangle */ - void setRect(int x, int y, unsigned int w, unsigned int h); + void setRect(int x, int y, int w, int h); //! Sets the position and size of the Rect /*! @param location The new point defining the top left corner of the rectangle @@ -212,6 +219,14 @@ public: @return true if the point is contained within this Rect; otherwise, false */ bool contains(int x, int y) const; + //! Determines if this Rect contains a point + /*! + The rectangle contains the point if it falls within the rectangle's + boundaries. + @param p The point to operate on + @return true if the point is contained within this Rect; otherwise, false + */ + bool contains(const Point &p) const; //! Determines if this Rect contains another Rect entirely /*! This rectangle contains the second rectangle if it is entirely within this