ManaPlus
Public Member Functions | Data Fields
Rect Class Reference

#include <rect.h>

Inheritance diagram for Rect:
ClipRect

Public Member Functions

 Rect ()
 
 Rect (const int x_, const int y_, const int width_, const int height_)
 
 Rect (const Rect &r)
 
Rectoperator= (const Rect &r)
 
virtual ~Rect ()
 
void setAll (const int x0, const int y0, const int width0, const int height0)
 
bool isIntersecting (const Rect &rectangle) const
 
bool isPointInRect (const int x_, const int y_) const
 

Data Fields

int x
 
int y
 
int width
 
int height
 

Detailed Description

Represents a rectangle.

Definition at line 73 of file rect.h.

Constructor & Destructor Documentation

◆ Rect() [1/3]

Rect::Rect ( )
inline

Constructor. The default rectangle is an empty rectangle at the coordinates (0,0).

Definition at line 80 of file rect.h.

80  :
81  x(0),
82  y(0),
83  width(0),
84  height(0)
85  {
86  }
int y
Definition: rect.h:214
int width
Definition: rect.h:219
int x
Definition: rect.h:209
int height
Definition: rect.h:224

◆ Rect() [2/3]

Rect::Rect ( const int  x_,
const int  y_,
const int  width_,
const int  height_ 
)
inline

Constructor.

Parameters
x_The x coordinate of the rectangle.
y_The y coordinate of the rectangle.
width_The width of the rectangle.
height_The height of the rectangle.

Definition at line 96 of file rect.h.

99  :
100  x(x_),
101  y(y_),
102  width(width_),
103  height(height_)
104  {
105  }

◆ Rect() [3/3]

Rect::Rect ( const Rect r)
inline

Definition at line 107 of file rect.h.

107  :
108  x(r.x),
109  y(r.y),
110  width(r.width),
111  height(r.height)
112  {
113  }

◆ ~Rect()

virtual Rect::~Rect ( )
inlinevirtual

Definition at line 126 of file rect.h.

127  { }

Member Function Documentation

◆ isIntersecting()

bool Rect::isIntersecting ( const Rect rectangle) const
inline

Checks if another rectangle intersects with the rectangle.

Parameters
rectangleAnother rectangle to check for intersection.
Returns
True if the rectangles intersect, false otherwise.

Definition at line 154 of file rect.h.

155  {
156  int x_ = x;
157  int y_ = y;
158  int width_ = width;
159  int height_ = height;
160 
161  x_ -= rectangle.x;
162  y_ -= rectangle.y;
163 
164  if (x_ < 0)
165  {
166  width_ += x_;
167  }
168  else if (x_ + width_ > rectangle.width)
169  {
170  width_ = rectangle.width - x_;
171  }
172 
173  if (y_ < 0)
174  {
175  height_ += y_;
176  }
177  else if (y_ + height_ > rectangle.height)
178  {
179  height_ = rectangle.height - y_;
180  }
181 
182  if (width_ <= 0 || height_ <= 0)
183  {
184  return false;
185  }
186 
187  return true;
188  }

References height, width, x, and y.

◆ isPointInRect()

bool Rect::isPointInRect ( const int  x_,
const int  y_ 
) const
inline

Checks if a point is inside the rectangle

Parameters
x_The x coordinate of the point.
y_The y coordinate of the point.
Returns
True if the point is inside the rectangle.

Definition at line 197 of file rect.h.

199  {
200  return x_ >= x
201  && y_ >= y
202  && x_ < x + width
203  && y_ < y + height;
204  }

References height, width, x, and y.

Referenced by ShortcutContainer::getIndexFromGrid(), OutfitWindow::getIndexFromGrid(), EquipmentWindow::getItem(), Window::getResizeHandles(), BasicContainer::getWidgetAt(), GuiTable::getWidgetAt(), Gui::handleMouseMoved(), Window::mousePressed(), EquipmentWindow::mousePressed(), EquipmentWindow::mouseReleased(), and TouchManager::processEvent().

◆ operator=()

Rect& Rect::operator= ( const Rect r)
inline

Definition at line 117 of file rect.h.

118  {
119  x = r.x;
120  y = r.y;
121  width = r.width;
122  height = r.height;
123  return *this;
124  }

References height, width, x, and y.

◆ setAll()

void Rect::setAll ( const int  x0,
const int  y0,
const int  width0,
const int  height0 
)
inline

Sets the dimension of a rectangle.

Parameters
x0The x coordinate of the rectangle.
y0The y coordinate of the rectangle.
width0The width of the rectangle.
height0The height of the rectangle.

Definition at line 137 of file rect.h.

141  {
142  x = x0;
143  y = y0;
144  width = width0;
145  height = height0;
146  }

References height, width, x, and y.

Field Documentation

◆ height

int Rect::height

Holds the height of the rectangle.

Definition at line 224 of file rect.h.

Referenced by Pincode::addButtons(), Window::adjustPositionAfterResize(), PopupList::adjustSize(), TabbedArea::adjustSize(), Window::adjustSizeToScreen(), ChatWindow::adjustTabSize(), ScrollArea::calcHBar(), ScrollArea::calcHMarker(), ScrollArea::calcVBar(), ScrollArea::calcVMarker(), ClanWindow::ClanWindow(), DebugWindow::DebugWindow(), Icon::draw(), DebugWindow::draw(), BasicContainer2::draw(), BrowserBox::draw(), Button::draw(), Desktop::draw(), DropDown::draw(), GuiTable::draw(), Label::draw(), PlayerBox::draw(), Popup::draw(), ProgressBar::draw(), ProgressIndicator::draw(), Slider::draw(), StaticBrowserBox::draw(), Tab::draw(), TextPreview::draw(), Window::draw(), Minimap::draw2(), DropDown::drawButton(), TextField::drawCaret(), BasicContainer::drawChildren(), DropDown::drawFrame(), PlayerBox::drawFrame(), ScrollArea::drawFrame(), TextField::drawFrame(), ScrollArea::drawHBar(), ScrollArea::drawHMarker(), TouchManager::drawText(), ScrollArea::drawVBar(), ScrollArea::drawVMarker(), DropDown::dropDown(), Window::ensureOnScreen(), BasicContainer::getChildrenArea(), DropDown::getChildrenArea(), GuiTable::getChildrenArea(), Popup::getChildrenArea(), ScrollArea::getChildrenArea(), Window::getChildrenArea(), MiniStatusWindow::getChildrenArea(), ScrollArea::getDownButtonDimension(), Widget::getHeight(), ScrollArea::getHorizontalBarDimension(), ScrollArea::getHorizontalMarkerDimension(), EmotePage::getIndexFromGrid(), ScrollArea::getLeftButtonDimension(), Window::getResizeHandles(), ScrollArea::getRightButtonDimension(), ScrollArea::getVerticalBarDimension(), ScrollArea::getVerticalMarkerDimension(), ScrollArea::getVerticalMaxScroll(), Window::getWindowArea(), isIntersecting(), isPointInRect(), TextBox::keyPressed(), Window::loadWindowState(), ScrollArea::logic(), Slider::markerPositionToValue(), ScrollArea::mouseDragged(), Slider::mouseDragged(), Window::mouseDragged(), Slider::mousePressed(), DropDown::mouseReleased(), operator=(), Popup::position(), EquipmentWindow::postInit(), Graphics::pushClipArea(), Window::redraw(), CharacterViewSmall::resize(), Icon::safeDraw(), DebugWindow::safeDraw(), BasicContainer2::safeDraw(), Button::safeDraw(), GuiTable::safeDraw(), Popup::safeDraw(), ProgressBar::safeDraw(), ProgressIndicator::safeDraw(), Slider::safeDraw(), Tab::safeDraw(), Window::safeDraw(), BasicContainer::safeDrawChildren(), DropDown::safeDrawFrame(), PlayerBox::safeDrawFrame(), ScrollArea::safeDrawFrame(), TextField::safeDrawFrame(), Window::saveWindowState(), ChatTab::scroll(), TextBox::scrollToCaret(), NpcSellDialog::sellOneItem(), setAll(), Desktop::setBestFittingWallpaper(), Window::setDefaultSize(), Widget::setDimension(), Widget::setHeight(), Popup::setLocationRelativeTo(), Window::setLocationRelativeTo(), Minimap::setMap(), Window::setResizable(), ListBox::setSelected(), Widget::setSize(), Window::setVisible(), TextBoxPopup::show(), TextPopup::show(), PopupList::show(), BasicContainer::showWidgetPart(), ScrollArea::updateCalcFlag(), SliderList::updateLabel(), WhoIsOnline::updateSize(), Slider::valueToMarkerPosition(), SpellPopup::view(), LayoutHelper::widgetResized(), ScrollArea::widgetResized(), TabbedArea::widgetResized(), Window::widgetResized(), ClanWindow::widgetResized(), DebugWindow::widgetResized(), EmoteWindow::widgetResized(), and SetupWindow::widgetResized().

◆ width

int Rect::width

Holds the width of the rectangle.

Definition at line 219 of file rect.h.

Referenced by VertContainer::add2(), Pincode::addButtons(), Window::adjustPositionAfterResize(), PopupList::adjustSize(), TabbedArea::adjustSize(), Window::adjustSizeToScreen(), ChatWindow::adjustTabSize(), ScrollArea::calcHBar(), BrowserBox::calcHeight(), ScrollArea::calcHMarker(), ScrollArea::calcVBar(), ScrollArea::calcVMarker(), ClanWindow::ClanWindow(), DebugWindow::DebugWindow(), Icon::draw(), DebugWindow::draw(), BasicContainer2::draw(), BrowserBox::draw(), Button::draw(), ColorPage::draw(), Desktop::draw(), DropDown::draw(), EmotePage::draw(), ExtendedListBox::draw(), GuiTable::draw(), Label::draw(), ListBox::draw(), PlayerBox::draw(), Popup::draw(), ProgressBar::draw(), ProgressIndicator::draw(), ShopListBox::draw(), SliderList::draw(), StaticBrowserBox::draw(), Tab::draw(), TextPreview::draw(), Window::draw(), Minimap::draw2(), DropDown::drawButton(), BasicContainer::drawChildren(), DropDown::drawFrame(), PlayerBox::drawFrame(), ScrollArea::drawFrame(), TextField::drawFrame(), ScrollArea::drawHBar(), ScrollArea::drawHMarker(), TouchManager::drawText(), ScrollArea::drawVBar(), ScrollArea::drawVMarker(), DropDown::dropDown(), Window::ensureOnScreen(), TextField::fixScroll(), BasicContainer::getChildrenArea(), DropDown::getChildrenArea(), GuiTable::getChildrenArea(), Popup::getChildrenArea(), ScrollArea::getChildrenArea(), Window::getChildrenArea(), MiniStatusWindow::getChildrenArea(), ScrollArea::getDownButtonDimension(), ScrollArea::getHorizontalBarDimension(), ScrollArea::getHorizontalMarkerDimension(), ScrollArea::getHorizontalMaxScroll(), EmotePage::getIndexFromGrid(), Window::getResizeHandles(), ScrollArea::getRightButtonDimension(), ItemContainer::getSlotByXY(), ItemContainer::getSlotIndex(), ScrollArea::getUpButtonDimension(), ScrollArea::getVerticalBarDimension(), ScrollArea::getVerticalMarkerDimension(), Widget::getWidth(), Window::getWindowArea(), isIntersecting(), isPointInRect(), Window::loadWindowState(), ScrollArea::logic(), Slider::markerPositionToValue(), ScrollArea::mouseDragged(), Window::mouseDragged(), Slider::mousePressed(), DropDown::mouseReleased(), operator=(), Popup::position(), EquipmentWindow::postInit(), Graphics::pushClipArea(), Window::redraw(), CharacterViewSmall::resize(), Icon::safeDraw(), DebugWindow::safeDraw(), BasicContainer2::safeDraw(), Button::safeDraw(), EmotePage::safeDraw(), GuiTable::safeDraw(), Popup::safeDraw(), ProgressBar::safeDraw(), ProgressIndicator::safeDraw(), SliderList::safeDraw(), Tab::safeDraw(), Window::safeDraw(), BasicContainer::safeDrawChildren(), DropDown::safeDrawFrame(), PlayerBox::safeDrawFrame(), ScrollArea::safeDrawFrame(), TextField::safeDrawFrame(), Window::saveWindowState(), TextBox::scrollToCaret(), setAll(), Desktop::setBestFittingWallpaper(), Window::setDefaultSize(), Widget::setDimension(), Window::setLocationHorisontallyRelativeTo(), Popup::setLocationRelativeTo(), Window::setLocationRelativeTo(), Minimap::setMap(), Window::setResizable(), Widget::setSize(), Window::setVisible(), Widget::setWidth(), TextBoxPopup::show(), TextPopup::show(), PopupList::show(), BasicContainer::showWidgetPart(), TabbedArea::updateArrowEnableState(), ScrollArea::updateCalcFlag(), BrowserBox::updateHeight(), StaticBrowserBox::updateHeight(), SliderList::updateLabel(), ItemContainer::updateSize(), WhoIsOnline::updateSize(), Slider::valueToMarkerPosition(), SpellPopup::view(), LayoutHelper::widgetResized(), ScrollArea::widgetResized(), ShortcutContainer::widgetResized(), TabbedArea::widgetResized(), Window::widgetResized(), ClanWindow::widgetResized(), DebugWindow::widgetResized(), EmoteWindow::widgetResized(), and SetupWindow::widgetResized().

◆ x

int Rect::x

◆ y

int Rect::y

The documentation for this class was generated from the following file: