FifeGUI 0.2.0
A C++ GUI library designed for games.
fcn::Rectangle Class Reference

#include <rectangle.hpp>

Inheritance diagram for fcn::Rectangle:
fcn::ClipRectangle

Public Member Functions

Rectangle intersection (Rectangle const &rh) const
bool isContaining (int x, int y) const
bool isContaining (Rectangle const &other) const
bool isEmpty () const
bool isIntersecting (Rectangle const &rectangle) const
Rectangle operator+ (Rectangle const &rh) const
Rectangle const & operator+= (Rectangle const &rh)
 Rectangle ()
 Rectangle (int x, int y, int width, int height)
void setAll (int x, int y, int width, int height)

Public Attributes

int height
int width
int x
int y

Friends

std::ostream & operator<< (std::ostream &out, Rectangle const &rectangle)

Detailed Description

Represents a rectangular area (X, Y, Width, Height).

Definition at line 19 of file rectangle.hpp.

Constructor & Destructor Documentation

◆ Rectangle() [1/2]

fcn::Rectangle::Rectangle ( )

Constructor.

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

Definition at line 11 of file rectangle.cpp.

References height, width, x, and y.

Referenced by fcn::ClipRectangle::ClipRectangle(), intersection(), isContaining(), isIntersecting(), operator+(), operator+=(), operator<<, and fcn::ClipRectangle::operator=().

◆ Rectangle() [2/2]

fcn::Rectangle::Rectangle ( int x,
int y,
int width,
int height )

Constructor.

Parameters
xThe x coordinate of the rectangle.
yThe y coordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.

Definition at line 13 of file rectangle.cpp.

References height, width, x, and y.

Member Function Documentation

◆ intersection()

Rectangle fcn::Rectangle::intersection ( Rectangle const & rh) const

Gets the intersection between two rectangles.

Parameters
rhThe rectangle to calculate the intersection with.
Returns
The intersection between two rectangles.

Definition at line 109 of file rectangle.cpp.

References height, isEmpty(), Rectangle(), width, x, and y.

Referenced by fcn::Graphics::pushClipArea().

◆ isContaining() [1/2]

bool fcn::Rectangle::isContaining ( int x,
int y ) const

Checks the rectangle contains a point.

Parameters
xThe x coordinate of the point.
yThe y coordinate of the point.
Returns
True if the rectangle contains the point, false otherwise.

Definition at line 52 of file rectangle.cpp.

References height, isEmpty(), width, x, and y.

Referenced by fcn::sdl2::Graphics::drawPoint(), fcn::Widget::getWidgetAt(), fcn::Gui::handleHiddenWidgets(), and fcn::Gui::handleShownWidgets().

◆ isContaining() [2/2]

bool fcn::Rectangle::isContaining ( Rectangle const & other) const

Checks if the rectangle contains a rectangle.

Parameters
otherThe rectangle to check.
Returns
True if the rectangle contains the rectangle, false otherwise.

Definition at line 61 of file rectangle.cpp.

References height, isEmpty(), Rectangle(), width, x, and y.

◆ isEmpty()

bool fcn::Rectangle::isEmpty ( ) const

Checks whether the rectangle is empty or not.

A rectangle is considered empty when it's width or height is either zero or negative.

Returns
True if the rectangle is empty, false otherwise.

Definition at line 71 of file rectangle.cpp.

References height, and width.

Referenced by fcn::ScrollArea::getChildrenArea(), intersection(), isContaining(), isContaining(), operator+(), operator+=(), and fcn::Graphics::pushClipArea().

◆ isIntersecting()

bool fcn::Rectangle::isIntersecting ( Rectangle const & rectangle) const

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 23 of file rectangle.cpp.

References height, Rectangle(), width, x, and y.

Referenced by fcn::Widget::_draw(), fcn::sdl2::Graphics::fillRectangle(), and fcn::Widget::getWidgetsIn().

◆ operator+()

Rectangle fcn::Rectangle::operator+ ( Rectangle const & rh) const

Adds a rectangle to this rectangle.

The resulting rectangle is the union of the two rectangles.

Parameters
rhThe rectangle to add.
Returns
The union of the two rectangles.

Definition at line 76 of file rectangle.cpp.

References height, isEmpty(), Rectangle(), width, x, and y.

◆ operator+=()

Rectangle const & fcn::Rectangle::operator+= ( Rectangle const & rh)

Adds a rectangle to this rectangle.

This rectangle will be the union of the two rectangles.

Parameters
rhThe rectangle to add.
Returns
A reference to this rectangle.

Definition at line 89 of file rectangle.cpp.

References height, isEmpty(), Rectangle(), width, x, and y.

◆ setAll()

void fcn::Rectangle::setAll ( int x,
int y,
int width,
int height )

Sets the dimension of a rectangle.

Parameters
xThe x coordinate of the rectangle.
yThe y coordinate of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.

Definition at line 15 of file rectangle.cpp.

References height, width, x, and y.

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
Rectangle const & rectangle )
friend

Output operator for output.

Parameters
outThe stream to output to.
rectangleThe rectangle to output.

Definition at line 129 of file rectangle.cpp.

References height, operator<<, Rectangle(), width, x, and y.

Referenced by operator<<.

Member Data Documentation

◆ height

int fcn::Rectangle::height

Holds the height of the rectangle.

Definition at line 136 of file rectangle.hpp.

Referenced by fcn::sdl2::Graphics::_beginDraw(), fcn::Widget::_draw(), fcn::FlowContainer::adjustContent(), fcn::DropDown::adjustHeight(), fcn::TextBox::adjustSizeImpl(), fcn::ClipRectangle::ClipRectangle(), fcn::Button::draw(), fcn::DropDown::draw(), fcn::Icon::draw(), fcn::ImageButton::draw(), fcn::Label::draw(), fcn::ListBox::draw(), fcn::Tab::draw(), fcn::CheckBox::drawBox(), fcn::DropDown::drawButton(), fcn::TextField::drawCaret(), fcn::CheckBox::drawCheckmark(), fcn::CheckBox::drawCross(), fcn::CheckBox::drawDot(), fcn::ScrollArea::drawDownButton(), fcn::ScrollArea::drawHBar(), fcn::ScrollArea::drawHMarker(), fcn::sdl2::Graphics::drawHorizontalLine(), fcn::ScrollArea::drawLeftButton(), fcn::CheckBox::drawMarkerImage(), fcn::opengl::Graphics::drawRectangle(), fcn::sdl2::Graphics::drawRectangle(), fcn::ScrollArea::drawRightButton(), fcn::ScrollArea::drawUpButton(), fcn::ScrollArea::drawVBar(), fcn::sdl2::Graphics::drawVerticalLine(), fcn::ScrollArea::drawVMarker(), fcn::Container::expandContent(), fcn::opengl::Graphics::fillRectangle(), fcn::sdl2::Graphics::fillRectangle(), fcn::Text::getCaretDimension(), fcn::AdjustingContainer::getChildrenArea(), fcn::Container::getChildrenArea(), fcn::Tab::getChildrenArea(), fcn::TabbedArea::getChildrenArea(), fcn::Window::getChildrenArea(), fcn::ScrollArea::getVerticalBarDimension(), fcn::ScrollArea::getVerticalMarkerDimension(), fcn::ScrollArea::getVerticalMaxScroll(), intersection(), isContaining(), isContaining(), isEmpty(), isIntersecting(), fcn::TextBox::keyPressed(), fcn::ScrollArea::mouseDragged(), operator+(), operator+=(), operator<<, fcn::ClipRectangle::operator=(), fcn::sdl2::Graphics::popClipArea(), fcn::Graphics::pushClipArea(), fcn::sdl2::Graphics::pushClipArea(), Rectangle(), Rectangle(), fcn::Container::resizeToContent(), setAll(), fcn::Widget::setDimension(), fcn::Widget::setHeight(), fcn::ListBox::setSelected(), fcn::Widget::setSize(), and fcn::Widget::showWidgetPart().

◆ width

int fcn::Rectangle::width

Holds the width of the rectangle.

Definition at line 131 of file rectangle.hpp.

Referenced by fcn::sdl2::Graphics::_beginDraw(), fcn::Widget::_draw(), fcn::FlowContainer::adjustContent(), fcn::TextBox::adjustSizeImpl(), fcn::TextField::adjustSizeImpl(), fcn::ClipRectangle::ClipRectangle(), fcn::Button::draw(), fcn::DropDown::draw(), fcn::Icon::draw(), fcn::ImageButton::draw(), fcn::Label::draw(), fcn::Tab::draw(), fcn::CheckBox::drawBox(), fcn::DropDown::drawButton(), fcn::CheckBox::drawCheckmark(), fcn::CheckBox::drawCross(), fcn::CheckBox::drawDot(), fcn::ScrollArea::drawDownButton(), fcn::ScrollArea::drawHBar(), fcn::ScrollArea::drawHMarker(), fcn::sdl2::Graphics::drawHorizontalLine(), fcn::ScrollArea::drawLeftButton(), fcn::CheckBox::drawMarkerImage(), fcn::opengl::Graphics::drawRectangle(), fcn::sdl2::Graphics::drawRectangle(), fcn::ScrollArea::drawRightButton(), fcn::ScrollArea::drawUpButton(), fcn::ScrollArea::drawVBar(), fcn::sdl2::Graphics::drawVerticalLine(), fcn::ScrollArea::drawVMarker(), fcn::Container::expandContent(), fcn::opengl::Graphics::fillRectangle(), fcn::sdl2::Graphics::fillRectangle(), fcn::Text::getCaretDimension(), fcn::AdjustingContainer::getChildrenArea(), fcn::Container::getChildrenArea(), fcn::Tab::getChildrenArea(), fcn::TabbedArea::getChildrenArea(), fcn::Window::getChildrenArea(), fcn::ScrollArea::getHorizontalBarDimension(), fcn::ScrollArea::getHorizontalMarkerDimension(), fcn::ScrollArea::getHorizontalMaxScroll(), intersection(), isContaining(), isContaining(), isEmpty(), isIntersecting(), fcn::ScrollArea::mouseDragged(), operator+(), operator+=(), operator<<, fcn::ClipRectangle::operator=(), fcn::sdl2::Graphics::popClipArea(), fcn::Graphics::pushClipArea(), fcn::sdl2::Graphics::pushClipArea(), Rectangle(), Rectangle(), fcn::Container::resizeToContent(), setAll(), fcn::Widget::setDimension(), fcn::Widget::setSize(), fcn::Widget::setWidth(), and fcn::Widget::showWidgetPart().

◆ x

int fcn::Rectangle::x

Holds the x coordinate of the rectangle.

Definition at line 121 of file rectangle.hpp.

Referenced by fcn::sdl2::Graphics::_beginDraw(), fcn::Widget::_draw(), fcn::FlowContainer::adjustContent(), fcn::ClipRectangle::ClipRectangle(), fcn::Button::draw(), fcn::Icon::draw(), fcn::ImageButton::draw(), fcn::Label::draw(), fcn::CheckBox::drawBox(), fcn::CheckBox::drawCheckmark(), fcn::CheckBox::drawCross(), fcn::CheckBox::drawDot(), fcn::sdl2::Graphics::drawHorizontalLine(), fcn::CheckBox::drawMarkerImage(), fcn::opengl::Graphics::drawRectangle(), fcn::sdl2::Graphics::drawRectangle(), fcn::sdl2::Graphics::drawVerticalLine(), fcn::Container::expandContent(), fcn::opengl::Graphics::fillRectangle(), fcn::sdl2::Graphics::fillRectangle(), fcn::Widget::getAbsolutePosition(), fcn::Text::getCaretDimension(), fcn::AdjustingContainer::getChildrenArea(), fcn::Container::getChildrenArea(), fcn::Tab::getChildrenArea(), fcn::TabbedArea::getChildrenArea(), fcn::Window::getChildrenArea(), fcn::ScrollArea::getHorizontalMarkerDimension(), fcn::ScrollArea::getVerticalMarkerDimension(), fcn::Widget::getWidgetAt(), intersection(), isContaining(), isContaining(), isIntersecting(), fcn::ScrollArea::mouseDragged(), fcn::ScrollArea::mousePressed(), operator+(), operator+=(), operator<<, fcn::ClipRectangle::operator=(), fcn::sdl2::Graphics::popClipArea(), fcn::Graphics::pushClipArea(), fcn::sdl2::Graphics::pushClipArea(), Rectangle(), Rectangle(), fcn::Container::resizeToContent(), setAll(), fcn::Widget::setDimension(), fcn::Widget::setPosition(), fcn::Widget::setX(), and fcn::Widget::showWidgetPart().

◆ y

int fcn::Rectangle::y

Holds the x coordinate of the rectangle.

Definition at line 126 of file rectangle.hpp.

Referenced by fcn::sdl2::Graphics::_beginDraw(), fcn::Widget::_draw(), fcn::FlowContainer::adjustContent(), fcn::ClipRectangle::ClipRectangle(), fcn::Button::draw(), fcn::Icon::draw(), fcn::ImageButton::draw(), fcn::Label::draw(), fcn::CheckBox::drawBox(), fcn::CheckBox::drawCheckmark(), fcn::CheckBox::drawCross(), fcn::CheckBox::drawDot(), fcn::sdl2::Graphics::drawHorizontalLine(), fcn::CheckBox::drawMarkerImage(), fcn::opengl::Graphics::drawRectangle(), fcn::sdl2::Graphics::drawRectangle(), fcn::sdl2::Graphics::drawVerticalLine(), fcn::Container::expandContent(), fcn::opengl::Graphics::fillRectangle(), fcn::sdl2::Graphics::fillRectangle(), fcn::Widget::getAbsolutePosition(), fcn::Text::getCaretDimension(), fcn::AdjustingContainer::getChildrenArea(), fcn::Container::getChildrenArea(), fcn::Tab::getChildrenArea(), fcn::TabbedArea::getChildrenArea(), fcn::Window::getChildrenArea(), fcn::ScrollArea::getHorizontalMarkerDimension(), fcn::ScrollArea::getVerticalMarkerDimension(), fcn::Widget::getWidgetAt(), intersection(), isContaining(), isContaining(), isIntersecting(), fcn::ScrollArea::mouseDragged(), fcn::ScrollArea::mousePressed(), operator+(), operator+=(), operator<<, fcn::ClipRectangle::operator=(), fcn::sdl2::Graphics::popClipArea(), fcn::Graphics::pushClipArea(), fcn::sdl2::Graphics::pushClipArea(), Rectangle(), Rectangle(), fcn::Container::resizeToContent(), setAll(), fcn::Widget::setDimension(), fcn::Widget::setPosition(), fcn::ListBox::setSelected(), fcn::Widget::setY(), and fcn::Widget::showWidgetPart().


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