Blender  V2.93
Public Member Functions | Public Attributes | List of all members
GHOST_Rect Class Reference

#include <GHOST_Rect.h>

Public Member Functions

 GHOST_Rect (GHOST_TInt32 l=0, GHOST_TInt32 t=0, GHOST_TInt32 r=0, GHOST_TInt32 b=0)
 
virtual ~GHOST_Rect ()
 
virtual GHOST_TInt32 getWidth () const
 
virtual GHOST_TInt32 getHeight () const
 
virtual void set (GHOST_TInt32 l, GHOST_TInt32 t, GHOST_TInt32 r, GHOST_TInt32 b)
 
virtual bool isEmpty () const
 
virtual bool isValid () const
 
virtual void inset (GHOST_TInt32 i)
 
virtual void unionRect (const GHOST_Rect &r)
 
virtual void unionPoint (GHOST_TInt32 x, GHOST_TInt32 y)
 
virtual void wrapPoint (GHOST_TInt32 &x, GHOST_TInt32 &y, GHOST_TInt32 ofs, GHOST_TAxisFlag axis)
 
virtual bool isInside (GHOST_TInt32 x, GHOST_TInt32 y) const
 
virtual GHOST_TVisibility getVisibility (GHOST_Rect &r) const
 
virtual void setCenter (GHOST_TInt32 cx, GHOST_TInt32 cy)
 
virtual void setCenter (GHOST_TInt32 cx, GHOST_TInt32 cy, GHOST_TInt32 w, GHOST_TInt32 h)
 
virtual bool clip (GHOST_Rect &r) const
 

Public Attributes

GHOST_TInt32 m_l
 
GHOST_TInt32 m_t
 
GHOST_TInt32 m_r
 
GHOST_TInt32 m_b
 

Detailed Description

Implements rectangle functionality. The four extreme coordinates are stored as left, top, right and bottom. To be valid, a rectangle should have a left coordinate smaller than or equal to right. To be valid, a rectangle should have a top coordinate smaller than or equal to bottom.

Definition at line 36 of file GHOST_Rect.h.

Constructor & Destructor Documentation

◆ GHOST_Rect()

GHOST_Rect::GHOST_Rect ( GHOST_TInt32  l = 0,
GHOST_TInt32  t = 0,
GHOST_TInt32  r = 0,
GHOST_TInt32  b = 0 
)
inline

Constructs a rectangle with the given values.

Parameters
lrequested left coordinate of the rectangle.
trequested top coordinate of the rectangle.
rrequested right coordinate of the rectangle.
brequested bottom coordinate of the rectangle.

Definition at line 45 of file GHOST_Rect.h.

◆ ~GHOST_Rect()

virtual GHOST_Rect::~GHOST_Rect ( )
inlinevirtual

Destructor.

Definition at line 53 of file GHOST_Rect.h.

Member Function Documentation

◆ clip()

bool GHOST_Rect::clip ( GHOST_Rect r) const
virtual

Clips a rectangle. Updates the rectangle given such that it will fit within this one. This can result in an empty rectangle.

Parameters
rthe rectangle to clip.
Returns
whether clipping has occurred

Definition at line 107 of file GHOST_Rect.cpp.

References m_b, m_l, m_r, m_t, and r.

◆ getHeight()

GHOST_TInt32 GHOST_Rect::getHeight ( ) const
inlinevirtual

◆ getVisibility()

GHOST_TVisibility GHOST_Rect::getVisibility ( GHOST_Rect r) const
virtual

Returns whether the rectangle is inside this rectangle.

Parameters
rrectangle to test.
Returns
visibility (not, partially or fully visible).

Definition at line 57 of file GHOST_Rect.cpp.

References GHOST_kFullyVisible, GHOST_kNotVisible, GHOST_kPartiallyVisible, isInside(), m_b, m_l, m_r, m_t, r, and v.

◆ getWidth()

GHOST_TInt32 GHOST_Rect::getWidth ( ) const
inlinevirtual

◆ inset()

void GHOST_Rect::inset ( GHOST_TInt32  i)
virtual

Grows (or shrinks the rectangle). The method avoids negative insets making the rectangle invalid

Parameters
iThe amount of offset given to each extreme (negative values shrink the rectangle).

Definition at line 26 of file GHOST_Rect.cpp.

References getHeight(), getWidth(), m_b, m_l, m_r, and m_t.

◆ isEmpty()

bool GHOST_Rect::isEmpty ( ) const
inlinevirtual

Returns whether this rectangle is empty. Empty rectangles are rectangles that have width==0 and/or height==0.

Returns
boolean value (true==empty rectangle)

Definition at line 200 of file GHOST_Rect.h.

References getHeight(), and getWidth().

◆ isInside()

bool GHOST_Rect::isInside ( GHOST_TInt32  x,
GHOST_TInt32  y 
) const
inlinevirtual

Returns whether the point is inside this rectangle. Point on the boundary is considered inside.

Parameters
xx-coordinate of point to test.
yy-coordinate of point to test.
Returns
boolean value (true if point is inside).

Definition at line 261 of file GHOST_Rect.h.

References m_b, m_l, m_r, m_t, x, and y.

Referenced by getVisibility().

◆ isValid()

bool GHOST_Rect::isValid ( ) const
inlinevirtual

Returns whether this rectangle is valid. Valid rectangles are rectangles that have m_l <= m_r and m_t <= m_b. Thus, empty rectangles are valid.

Returns
boolean value (true==valid rectangle)

Definition at line 205 of file GHOST_Rect.h.

References m_b, m_l, m_r, and m_t.

◆ set()

void GHOST_Rect::set ( GHOST_TInt32  l,
GHOST_TInt32  t,
GHOST_TInt32  r,
GHOST_TInt32  b 
)
inlinevirtual

Sets all members of the rectangle.

Parameters
lrequested left coordinate of the rectangle.
trequested top coordinate of the rectangle.
rrequested right coordinate of the rectangle.
brequested bottom coordinate of the rectangle.

Definition at line 192 of file GHOST_Rect.h.

References l, m_b, m_l, m_r, m_t, r, and t.

◆ setCenter() [1/2]

void GHOST_Rect::setCenter ( GHOST_TInt32  cx,
GHOST_TInt32  cy 
)
virtual

Sets rectangle members. Sets rectangle members such that it is centered at the given location.

Parameters
cxrequested center x-coordinate of the rectangle.
cyrequested center y-coordinate of the rectangle.

Definition at line 85 of file GHOST_Rect.cpp.

References m_b, m_l, m_r, and m_t.

◆ setCenter() [2/2]

void GHOST_Rect::setCenter ( GHOST_TInt32  cx,
GHOST_TInt32  cy,
GHOST_TInt32  w,
GHOST_TInt32  h 
)
virtual

Sets rectangle members. Sets rectangle members such that it is centered at the given location, with the width requested.

Parameters
cxrequested center x-coordinate of the rectangle.
cyrequested center y-coordinate of the rectangle.
wrequested width of the rectangle.
hrequested height of the rectangle.

Definition at line 95 of file GHOST_Rect.cpp.

References m_b, m_l, m_r, m_t, and w().

◆ unionPoint()

void GHOST_Rect::unionPoint ( GHOST_TInt32  x,
GHOST_TInt32  y 
)
inlinevirtual

Grows the rectangle to included a point.

Parameters
xThe x-coordinate of the point.
yThe y-coordinate of the point.

Definition at line 222 of file GHOST_Rect.h.

References m_b, m_l, m_r, m_t, x, and y.

◆ unionRect()

void GHOST_Rect::unionRect ( const GHOST_Rect r)
inlinevirtual

Does a union of the rectangle given and this rectangle. The result is stored in this rectangle.

Parameters
rThe rectangle that is input for the union operation.

Definition at line 210 of file GHOST_Rect.h.

References m_b, m_l, m_r, m_t, and r.

◆ wrapPoint()

void GHOST_Rect::wrapPoint ( GHOST_TInt32 x,
GHOST_TInt32 y,
GHOST_TInt32  ofs,
GHOST_TAxisFlag  axis 
)
inlinevirtual

Grows the rectangle to included a point.

Parameters
xThe x-coordinate of the point.
yThe y-coordinate of the point.

Definition at line 234 of file GHOST_Rect.h.

References getHeight(), getWidth(), GHOST_kAxisX, GHOST_kGrabAxisY, m_b, m_l, m_r, m_t, w(), x, and y.

Referenced by GHOST_SystemCocoa::handleMouseEvent().

Member Data Documentation

◆ m_b

GHOST_TInt32 GHOST_Rect::m_b

◆ m_l

GHOST_TInt32 GHOST_Rect::m_l

◆ m_r

GHOST_TInt32 GHOST_Rect::m_r

◆ m_t

GHOST_TInt32 GHOST_Rect::m_t

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