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 72 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 79 of file rect.h.

79  :
80  x(0),
81  y(0),
82  width(0),
83  height(0)
84  {
85  }

◆ 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 95 of file rect.h.

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

◆ Rect() [3/3]

Rect::Rect ( const Rect r)
inline

Definition at line 106 of file rect.h.

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

◆ ~Rect()

virtual Rect::~Rect ( )
inlinevirtual

Definition at line 125 of file rect.h.

126  { }

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 153 of file rect.h.

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

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 196 of file rect.h.

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

References height, width, x, and y.

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

◆ operator=()

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

Definition at line 116 of file rect.h.

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

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 136 of file rect.h.

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

References height, width, x, and y.

Field Documentation

◆ height

int Rect::height

Holds the height of the rectangle.

Definition at line 223 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(), ProgressIndicator::draw(), DebugWindow::draw(), Desktop::draw(), DropDown::draw(), Icon::draw(), ProgressBar::draw(), PlayerBox::draw(), Popup::draw(), TextPreview::draw(), StaticBrowserBox::draw(), Tab::draw(), Label::draw(), BrowserBox::draw(), GuiTable::draw(), Slider::draw(), Window::draw(), BasicContainer2::draw(), Button::draw(), Minimap::draw2(), DropDown::drawButton(), TextField::drawCaret(), BasicContainer::drawChildren(), DropDown::drawFrame(), PlayerBox::drawFrame(), TextField::drawFrame(), ScrollArea::drawFrame(), ScrollArea::drawHBar(), ScrollArea::drawHMarker(), TouchManager::drawText(), ScrollArea::drawVBar(), ScrollArea::drawVMarker(), DropDown::dropDown(), Window::ensureOnScreen(), MiniStatusWindow::getChildrenArea(), GuiTable::getChildrenArea(), BasicContainer::getChildrenArea(), DropDown::getChildrenArea(), Popup::getChildrenArea(), ScrollArea::getChildrenArea(), Window::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(), Slider::mouseDragged(), ScrollArea::mouseDragged(), Window::mouseDragged(), Slider::mousePressed(), DropDown::mouseReleased(), operator=(), Popup::position(), EquipmentWindow::postInit(), Graphics::pushClipArea(), Window::redraw(), CharacterViewSmall::resize(), ProgressIndicator::safeDraw(), DebugWindow::safeDraw(), Icon::safeDraw(), ProgressBar::safeDraw(), Popup::safeDraw(), Tab::safeDraw(), GuiTable::safeDraw(), Slider::safeDraw(), Window::safeDraw(), BasicContainer2::safeDraw(), Button::safeDraw(), BasicContainer::safeDrawChildren(), DropDown::safeDrawFrame(), PlayerBox::safeDrawFrame(), TextField::safeDrawFrame(), ScrollArea::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(), PopupList::show(), TextBoxPopup::show(), TextPopup::show(), BasicContainer::showWidgetPart(), ScrollArea::updateCalcFlag(), SliderList::updateLabel(), WhoIsOnline::updateSize(), Slider::valueToMarkerPosition(), SpellPopup::view(), ClanWindow::widgetResized(), DebugWindow::widgetResized(), EmoteWindow::widgetResized(), SetupWindow::widgetResized(), LayoutHelper::widgetResized(), Window::widgetResized(), ScrollArea::widgetResized(), and TabbedArea::widgetResized().

◆ width

int Rect::width

Holds the width of the rectangle.

Definition at line 218 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(), ColorPage::draw(), EmotePage::draw(), ExtendedListBox::draw(), ProgressIndicator::draw(), DebugWindow::draw(), SliderList::draw(), ShopListBox::draw(), Desktop::draw(), Icon::draw(), DropDown::draw(), ProgressBar::draw(), PlayerBox::draw(), Popup::draw(), TextPreview::draw(), StaticBrowserBox::draw(), ListBox::draw(), Tab::draw(), Label::draw(), BrowserBox::draw(), GuiTable::draw(), Window::draw(), BasicContainer2::draw(), Button::draw(), Minimap::draw2(), DropDown::drawButton(), BasicContainer::drawChildren(), DropDown::drawFrame(), PlayerBox::drawFrame(), TextField::drawFrame(), ScrollArea::drawFrame(), ScrollArea::drawHBar(), ScrollArea::drawHMarker(), TouchManager::drawText(), ScrollArea::drawVBar(), ScrollArea::drawVMarker(), DropDown::dropDown(), Window::ensureOnScreen(), TextField::fixScroll(), MiniStatusWindow::getChildrenArea(), GuiTable::getChildrenArea(), BasicContainer::getChildrenArea(), DropDown::getChildrenArea(), Popup::getChildrenArea(), ScrollArea::getChildrenArea(), Window::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(), EmotePage::safeDraw(), ProgressIndicator::safeDraw(), DebugWindow::safeDraw(), SliderList::safeDraw(), Icon::safeDraw(), ProgressBar::safeDraw(), Popup::safeDraw(), Tab::safeDraw(), GuiTable::safeDraw(), Window::safeDraw(), BasicContainer2::safeDraw(), Button::safeDraw(), BasicContainer::safeDrawChildren(), DropDown::safeDrawFrame(), PlayerBox::safeDrawFrame(), TextField::safeDrawFrame(), ScrollArea::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(), PopupList::show(), TextBoxPopup::show(), TextPopup::show(), BasicContainer::showWidgetPart(), TabbedArea::updateArrowEnableState(), ScrollArea::updateCalcFlag(), StaticBrowserBox::updateHeight(), BrowserBox::updateHeight(), SliderList::updateLabel(), WhoIsOnline::updateSize(), ItemContainer::updateSize(), Slider::valueToMarkerPosition(), SpellPopup::view(), ClanWindow::widgetResized(), ShortcutContainer::widgetResized(), DebugWindow::widgetResized(), EmoteWindow::widgetResized(), SetupWindow::widgetResized(), LayoutHelper::widgetResized(), Window::widgetResized(), ScrollArea::widgetResized(), and TabbedArea::widgetResized().

◆ x

int Rect::x

◆ y

int Rect::y

The documentation for this class was generated from the following file:
Rect::height
int height
Definition: rect.h:223
Rect::y
int y
Definition: rect.h:213
Rect::width
int width
Definition: rect.h:218
Rect::x
int x
Definition: rect.h:208