OpenTTD Source  20241108-master-g80f628063a
Rect Struct Reference

Specification of a rectangle with absolute coordinates of all edges. More...

#include <geometry_type.hpp>

Inheritance diagram for Rect:
StationRect

Public Member Functions

int Width () const
 Get width of Rect. More...
 
int Height () const
 Get height of Rect. More...
 
Rect Shrink (int s) const
 Copy and shrink Rect by s pixels. More...
 
Rect Shrink (int h, int v) const
 Copy and shrink Rect by h horizontal and v vertical pixels. More...
 
Rect Shrink (int left, int top, int right, int bottom) const
 Copy and shrink Rect by pixels. More...
 
Rect Shrink (const RectPadding &other) const
 Copy and shrink Rect by a RectPadding. More...
 
Rect Shrink (const RectPadding &horz, const RectPadding &vert) const
 Copy and shrink Rect by a different horizontal and vertical RectPadding. More...
 
Rect Expand (int s) const
 Copy and expand Rect by s pixels. More...
 
Rect Expand (const RectPadding &other) const
 Copy and expand Rect by a RectPadding. More...
 
Rect Translate (int x, int y) const
 Copy and translate Rect by x,y pixels. More...
 
Rect WithWidth (int width, bool end) const
 Copy Rect and set its width. More...
 
Rect Indent (int indent, bool end) const
 Copy Rect and indent it from its position. More...
 
Rect WithHeight (int height, bool end=false) const
 Copy Rect and set its height. More...
 
bool Contains (const Point &pt) const
 Test if a point falls inside this Rect. More...
 

Data Fields

int left
 
int top
 
int right
 
int bottom
 

Detailed Description

Specification of a rectangle with absolute coordinates of all edges.

Definition at line 75 of file geometry_type.hpp.

Member Function Documentation

◆ Contains()

bool Rect::Contains ( const Point pt) const
inline

Test if a point falls inside this Rect.

Parameters
ptthe point to test.
Returns
true iff the point falls inside the Rect.

Definition at line 223 of file geometry_type.hpp.

◆ Expand() [1/2]

Rect Rect::Expand ( const RectPadding other) const
inline

Copy and expand Rect by a RectPadding.

Parameters
otherRectPadding to add to each side of Rect.
Returns
the new larger Rect.

Definition at line 163 of file geometry_type.hpp.

◆ Expand() [2/2]

Rect Rect::Expand ( int  s) const
inline

Copy and expand Rect by s pixels.

Parameters
snumber of pixels to add to each side of Rect.
Returns
the new larger Rect.

Definition at line 153 of file geometry_type.hpp.

References Shrink().

◆ Height()

int Rect::Height ( ) const
inline

Get height of Rect.

Returns
height of Rect.

Definition at line 91 of file geometry_type.hpp.

Referenced by EnsureVisibleCaption(), BitmapTileArea::Initialize(), and PreventHiding().

◆ Indent()

Rect Rect::Indent ( int  indent,
bool  end 
) const
inline

Copy Rect and indent it from its position.

Parameters
indentoffset in pixels for new Rect.
endif set, set indent at end of Rect, i.e. on right.
Returns
the new resized Rect.

Definition at line 198 of file geometry_type.hpp.

Referenced by StationViewWindow::DrawCargoRatings(), DrawCategory(), GoalListWindow::DrawListColumn(), TownAuthorityWindow::DrawRatings(), and DepotWindow::DrawVehicleInDepot().

◆ Shrink() [1/5]

Rect Rect::Shrink ( const RectPadding horz,
const RectPadding vert 
) const
inline

Copy and shrink Rect by a different horizontal and vertical RectPadding.

Parameters
horzRectPadding to remove from left and right of Rect.
vertRectPadding to remove from top and bottom of Rect.
Returns
the new smaller Rect.

Definition at line 143 of file geometry_type.hpp.

◆ Shrink() [2/5]

Rect Rect::Shrink ( const RectPadding other) const
inline

Copy and shrink Rect by a RectPadding.

Parameters
otherRectPadding to remove from each side of Rect.
Returns
the new smaller Rect.

Definition at line 132 of file geometry_type.hpp.

◆ Shrink() [3/5]

Rect Rect::Shrink ( int  h,
int  v 
) const
inline

Copy and shrink Rect by h horizontal and v vertical pixels.

Parameters
hnumber of pixels to remove from left and right sides.
vnumber of pixels to remove from top and bottom sides.
Returns
the new smaller Rect.

Definition at line 109 of file geometry_type.hpp.

◆ Shrink() [4/5]

Rect Rect::Shrink ( int  left,
int  top,
int  right,
int  bottom 
) const
inline

Copy and shrink Rect by pixels.

Parameters
leftnumber of pixels to remove from left side.
topnumber of pixels to remove from top side.
rightnumber of pixels to remove from right side.
bottomnumber of pixels to remove from bottom side.
Returns
the new smaller Rect.

Definition at line 122 of file geometry_type.hpp.

◆ Shrink() [5/5]

◆ Translate()

Rect Rect::Translate ( int  x,
int  y 
) const
inline

Copy and translate Rect by x,y pixels.

Parameters
xnumber of pixels to move horizontally.
ynumber of pixels to move vertically.
Returns
the new translated Rect.

Definition at line 174 of file geometry_type.hpp.

Referenced by DropdownWindow::UpdateSizeAndPosition().

◆ Width()

int Rect::Width ( ) const
inline

◆ WithHeight()

Rect Rect::WithHeight ( int  height,
bool  end = false 
) const
inline

Copy Rect and set its height.

Parameters
widthheight in pixels for new Rect.
endif set, set height at end of Rect, i.e. at bottom.
Returns
the new resized Rect.

Definition at line 211 of file geometry_type.hpp.

Referenced by NetworkContentListWindow::DrawDetails(), NetworkContentListWindow::DrawMatrix(), BaseVehicleListWindow::DrawVehicleListItems(), and DrawVerticalScrollbar().

◆ WithWidth()

Rect Rect::WithWidth ( int  width,
bool  end 
) const
inline

Copy Rect and set its width.

Parameters
widthwidth in pixels for new Rect.
endif set, set width at end of Rect, i.e. on right.
Returns
the new resized Rect.

Definition at line 185 of file geometry_type.hpp.

Referenced by DrawHorizontalScrollbar(), GoalListWindow::DrawListColumn(), and TownAuthorityWindow::DrawRatings().


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