wGui::CRect Class Reference

A representation of a rectangle. More...

#include <wg_rect.h>

Public Types

Public Member Functions

Protected Attributes


Detailed Description

A representation of a rectangle.

Definition at line 39 of file wg_rect.h.


Member Enumeration Documentation

enum wGui::CRect::ERelativePosition

Used to idicate the relative position of a point to the rect.

Enumerator:
RELPOS_INVALID  This usually indicates some form of error.
RELPOS_ABOVE  The point is above the top of the CRect.
RELPOS_BELOW  The point is below the bottom of the CRect.
RELPOS_LEFT  The point is to the left of the CRect.
RELPOS_RIGHT  The point is to the right of the CRect.
RELPOS_INSIDE  The point lies within the bounds of the CRect.

Definition at line 195 of file wg_rect.h.


Constructor & Destructor Documentation

wGui::CRect::CRect ( const int  left,
const int  top,
const int  right,
const int  bottom 
) [inline]

Parameters:
left The left edge of the rectangle
top The top edge of the rectangle
right The right edge of the rectangle
bottom The bottom edge of the rectangle

Definition at line 49 of file wg_rect.h.

wGui::CRect::CRect ( const CPoint p1,
const CPoint p2 
) [inline]

Create a CRect using a pair of CPoints that represent the Top-Left, and Bottom-Right corners

Parameters:
p1 Top left corner
p2 Bottom right corner

Definition at line 55 of file wg_rect.h.

wGui::CRect::CRect ( const CRect r  )  [inline]

Copy constructor

Parameters:
r A CRect that thie new CRect will be copied from

Definition at line 60 of file wg_rect.h.


Member Function Documentation

void wGui::CRect::SetTop ( const int  top  )  [inline]

Set the Top poisition

Parameters:
top The new Top coordinate

Definition at line 68 of file wg_rect.h.

References m_Top.

Referenced by wGui::CView::AttachMenu(), wGui::CFrame::AttachMenu(), wGui::CGroupBox::CGroupBox(), wGui::CEditBox::Draw(), wGui::CScrollBar::RepositionThumb(), and wGui::CGroupBox::SetWindowRect().

void wGui::CRect::SetLeft ( const int  left  )  [inline]

Set the Left poisition

Parameters:
left The new Left coordinate

Definition at line 72 of file wg_rect.h.

References m_Left.

Referenced by wGui::CTextBox::Draw(), wGui::CPopupMenu::Draw(), wGui::CEditBox::Draw(), and wGui::CScrollBar::RepositionThumb().

void wGui::CRect::SetRight ( const int  right  )  [inline]

Set the Right poisition

Parameters:
right The new Right coordinate

Definition at line 76 of file wg_rect.h.

References m_Right.

Referenced by wGui::CTextBox::Draw(), wGui::CFrame::Draw(), wGui::CEditBox::Draw(), wGui::CScrollBar::RepositionThumb(), and wGui::CTextBox::UpdateScrollBars().

void wGui::CRect::SetBottom ( const int  bottom  )  [inline]

Set the Bottom poisition

Parameters:
bottom The new Bottom coordinate

Definition at line 80 of file wg_rect.h.

References m_Bottom.

Referenced by wGui::CEditBox::Draw(), wGui::CScrollBar::RepositionThumb(), and wGui::CTextBox::UpdateScrollBars().

int wGui::CRect::Top ( void   )  const [inline]

Gets the top of the rectangle

Returns:
The Top position

Definition at line 84 of file wg_rect.h.

References m_Top.

Referenced by wGui::CTextBox::Draw(), wGui::CScrollBar::Draw(), wGui::CPopupMenu::Draw(), wGui::CMenu::Draw(), wGui::CListBox::Draw(), wGui::CPainter::DrawRect(), wGui::CView::HandleMessage(), wGui::CTextBox::HandleMessage(), wGui::CScrollBar::HandleMessage(), wGui::CFrame::HandleMessage(), wGui::CTextBox::OnMouseButtonDown(), wGui::CListBox::OnMouseButtonDown(), wGui::CListBox::OnMouseButtonUp(), operator=(), wGui::CScrollBar::RepositionThumb(), wGui::CWindow::SetWindowRect(), and wGui::CTextBox::UpdateScrollBars().

int wGui::CRect::Left ( void   )  const [inline]

Gets the left of the rectangle

Returns:
The Left position

Definition at line 88 of file wg_rect.h.

References m_Left.

Referenced by wGui::CTextBox::Draw(), wGui::CScrollBar::Draw(), wGui::CPopupMenu::Draw(), wGui::CMenu::Draw(), wGui::CListBox::Draw(), wGui::CPainter::DrawRect(), wGui::CView::HandleMessage(), wGui::CTextBox::HandleMessage(), wGui::CScrollBar::HandleMessage(), wGui::CFrame::HandleMessage(), wGui::CTextBox::OnMouseButtonDown(), operator=(), wGui::CScrollBar::RepositionThumb(), wGui::CWindow::SetWindowRect(), wGui::CMenu::ShowActivePopup(), and wGui::CTextBox::UpdateScrollBars().

int wGui::CRect::Right ( void   )  const [inline]

Gets the right of the rectangle

Returns:
The Right position

Definition at line 92 of file wg_rect.h.

References m_Right.

Referenced by wGui::CTextBox::Draw(), wGui::CScrollBar::Draw(), wGui::CPopupMenu::Draw(), wGui::CMenu::Draw(), wGui::CListBox::Draw(), wGui::CFrame::Draw(), wGui::CPainter::DrawRect(), wGui::CFrame::HandleMessage(), operator=(), wGui::CWindow::SetWindowRect(), and wGui::CMenu::ShowActivePopup().

int wGui::CRect::Bottom ( void   )  const [inline]

Gets the bottom of the rectangle

Returns:
The Bottom position

Definition at line 96 of file wg_rect.h.

References m_Bottom.

Referenced by wGui::CTextBox::Draw(), wGui::CScrollBar::Draw(), wGui::CPopupMenu::Draw(), wGui::CMenu::Draw(), wGui::CPainter::DrawRect(), wGui::CFrame::HandleMessage(), operator=(), wGui::CWindow::SetWindowRect(), and wGui::CPopupMenu::Show().

CPoint wGui::CRect::TopLeft ( void   )  const [inline]

Gets the top-left corner of the rectangle

Returns:
A point representing the Top Left corner of the CRect

Definition at line 100 of file wg_rect.h.

References m_Left, and m_Top.

Referenced by wGui::CWindow::ClientToView(), wGui::CTextBox::CTextBox(), wGui::CTextBox::Draw(), wGui::CPopupMenu::Draw(), wGui::CFrame::Draw(), wGui::CPainter::DrawHLine(), wGui::CPainter::DrawPoint(), wGui::CPainter::DrawRect(), wGui::CPainter::DrawVLine(), wGui::CMessageBox::FitToText(), wGui::CView::HandleMessage(), wGui::CWindow::PaintToSurface(), wGui::CToolTip::PaintToSurface(), wGui::CPopupMenu::PaintToSurface(), wGui::CListBox::PaintToSurface(), wGui::CFrame::PaintToSurface(), wGui::CPainter::ReadPoint(), wGui::CPopupMenu::ShowActivePopup(), wGui::CWindow::ViewToClient(), and wGui::CWindow::ViewToWindow().

CPoint wGui::CRect::TopRight ( void   )  const [inline]

Gets the top-right corner of the rectangle

Returns:
A point representing the Top Right corner of the CRect

Definition at line 104 of file wg_rect.h.

References m_Right, and m_Top.

Referenced by wGui::CPopupMenu::ShowActivePopup().

CPoint wGui::CRect::BottomLeft ( void   )  const [inline]

Gets the bottom left corner of the rectangle

Returns:
A point representing the Bottom Left corner of the CRect

Definition at line 108 of file wg_rect.h.

References m_Bottom, and m_Left.

Referenced by wGui::CLabel::Draw(), and wGui::CMenu::ShowActivePopup().

CPoint wGui::CRect::BottomRight ( void   )  const [inline]

Gets the bottom-right corner of the rectangle

Returns:
A point representing the Bottom Right corner of the CRect

Definition at line 112 of file wg_rect.h.

References m_Bottom, and m_Right.

Referenced by wGui::CMessageBox::FitToText().

CPoint wGui::CRect::Center ( void   )  const [inline]

Gets the center of the rectangle

Returns:
A point representing the center of the CRect

Definition at line 116 of file wg_rect.h.

References m_Bottom, m_Left, m_Right, and m_Top.

Referenced by wGui::CTextBox::Draw(), wGui::CEditBox::Draw(), and wGui::CButton::Draw().

CPoint wGui::CRect::CenterLeft ( void   )  const [inline]

Gets the left side's center of the rectangle

Returns:
A point representing the CenterLeft point of the CRect

Definition at line 120 of file wg_rect.h.

References m_Bottom, m_Left, and m_Top.

CPoint wGui::CRect::CenterTop ( void   )  const [inline]

Get the top's center of the rectangle

Returns:
A point representing the CenterTop point of the CRect

Definition at line 124 of file wg_rect.h.

References m_Left, m_Right, and m_Top.

CPoint wGui::CRect::CenterBottom ( void   )  const [inline]

Gets the bottom's center of the rectangle

Returns:
A point representing the Bottom Left corner of the CRect

Definition at line 128 of file wg_rect.h.

References m_Bottom, m_Left, and m_Right.

CPoint wGui::CRect::CenterRight ( void   )  const [inline]

Gets the right side's center of the rectangle

Returns:
A point representing the Bottom Right corner of the CRect

Definition at line 132 of file wg_rect.h.

References m_Bottom, m_Right, and m_Top.

SDL_Rect wGui::CRect::SDLRect ( void   )  const

Converts the CRect into a SDL style rect

Returns:
An SDL_Rect of the same size

Definition at line 36 of file wg_rect.cpp.

References Height(), m_Bottom, m_Left, m_Right, m_Top, and Width().

Referenced by wGui::CPicture::Draw(), and wGui::CPainter::DrawRect().

int wGui::CRect::Width ( void   )  const [inline]

Gets the width of the rectangle

Returns:
The width (along the X axis) of the CRect

Definition at line 141 of file wg_rect.h.

References m_Left, and m_Right.

Referenced by wGui::CView::AttachMenu(), wGui::CFrame::AttachMenu(), wGui::CDropDown::CDropDown(), wGui::CListBox::CListBox(), wGui::CScrollBar::CScrollBar(), wGui::CTextBox::CTextBox(), wGui::CPopupMenu::Draw(), wGui::CGroupBox::Draw(), wGui::CMessageBox::FitToText(), wGui::CView::HandleMessage(), wGui::CScrollBar::HandleMessage(), wGui::CToolBar::RepositionButtons(), wGui::CScrollBar::RepositionThumb(), SDLRect(), wGui::CDropDown::SetListboxHeight(), wGui::CWindow::SetWindowRect(), wGui::CView::SetWindowRect(), wGui::CScrollBar::SetWindowRect(), wGui::CListBox::SetWindowRect(), wGui::CFrame::SetWindowRect(), wGui::CDropDown::SetWindowRect(), wGui::CPopupMenu::Show(), wGui::CPopupMenu::ShowActivePopup(), wGui::CMenu::ShowActivePopup(), and wGui::CTextBox::UpdateScrollBars().

int wGui::CRect::Height ( void   )  const [inline]

Gets the height of the rectangle

Returns:
The height (along the Y axis) of the CRect

Definition at line 145 of file wg_rect.h.

References m_Bottom, and m_Top.

Referenced by wGui::CListBox::AddItem(), wGui::CView::AttachMenu(), wGui::CFrame::AttachMenu(), wGui::CDropDown::CDropDown(), wGui::CListBox::CListBox(), wGui::CScrollBar::CScrollBar(), wGui::CTextBox::CTextBox(), wGui::CTextBox::Draw(), wGui::CPopupMenu::Draw(), wGui::CGroupBox::Draw(), wGui::CMessageBox::FitToText(), wGui::CView::HandleMessage(), wGui::CScrollBar::HandleMessage(), wGui::CListBox::HandleMessage(), wGui::CListBox::RemoveItem(), wGui::CScrollBar::RepositionThumb(), SDLRect(), wGui::CDropDown::SetListboxHeight(), wGui::CWindow::SetWindowRect(), wGui::CView::SetWindowRect(), wGui::CScrollBar::SetWindowRect(), wGui::CListBox::SetWindowRect(), wGui::CFrame::SetWindowRect(), wGui::CDropDown::SetWindowRect(), wGui::CPopupMenu::Show(), and wGui::CTextBox::UpdateScrollBars().

CRect wGui::CRect::SizeRect ( void   )  const [inline]

Creates a CRect that has the same width and height of the rect, but has 0, 0 as it's top left coordinate

Returns:
A CRect

Definition at line 149 of file wg_rect.h.

References CRect(), m_Bottom, m_Left, m_Right, and m_Top.

Referenced by wGui::CView::AttachMenu(), wGui::CFrame::AttachMenu(), wGui::CListBox::CListBox(), wGui::CWindow::Draw(), wGui::CToolTip::Draw(), wGui::CTextBox::Draw(), wGui::CRadioButton::Draw(), wGui::CProgress::Draw(), wGui::CPicture::Draw(), wGui::CPopupMenu::Draw(), wGui::CListBox::Draw(), wGui::CLabel::Draw(), wGui::CGroupBox::Draw(), wGui::CFrame::Draw(), wGui::CEditBox::Draw(), wGui::CCheckBox::Draw(), wGui::CPictureButton::Draw(), wGui::CButton::Draw(), wGui::CView::HandleMessage(), wGui::CToolTip::HandleMessage(), wGui::CPopupMenu::HandleMessage(), wGui::CMenu::HandleMessage(), wGui::CMenuBase::HandleMessage(), wGui::CFrame::HandleMessage(), wGui::CDropDown::HandleMessage(), wGui::CWindow::HitTest(), wGui::CPopupMenu::IsInsideChild(), wGui::CWindow::OnMouseButtonDown(), wGui::CPopupMenu::OnMouseButtonDown(), wGui::CMenu::OnMouseButtonDown(), wGui::CListBox::OnMouseButtonDown(), wGui::CFrame::OnMouseButtonDown(), wGui::CWindow::OnMouseButtonUp(), wGui::CWindow::PaintToSurface(), wGui::CToolTip::PaintToSurface(), wGui::CPopupMenu::PaintToSurface(), wGui::CListBox::PaintToSurface(), wGui::CFrame::PaintToSurface(), wGui::CToolBar::SetWindowRect(), wGui::CTextBox::SetWindowRect(), wGui::CPicture::SetWindowRect(), wGui::CListBox::SetWindowRect(), wGui::CGroupBox::SetWindowRect(), wGui::CPopupMenu::UpdateCachedRects(), and wGui::CMenu::UpdateCachedRects().

CRect wGui::CRect::operator+ ( const CPoint p  )  const

Addition operator to add a CPoint, will offset the CRect

Parameters:
p A point to offset the CRect by

Definition at line 61 of file wg_rect.cpp.

References m_Bottom, m_Left, m_Right, m_Top, wGui::CPoint::XPos(), and wGui::CPoint::YPos().

CRect wGui::CRect::operator- ( const CPoint p  )  const

Subtraction operator to subtract a CPoint, will offset the CRect

Parameters:
p A point to offset the CRect by

Definition at line 69 of file wg_rect.cpp.

References m_Bottom, m_Left, m_Right, m_Top, wGui::CPoint::XPos(), and wGui::CPoint::YPos().

bool wGui::CRect::operator== ( const CRect r  )  const [inline]

Equality operator

Parameters:
r The rect to compare to

Definition at line 164 of file wg_rect.h.

References m_Bottom, m_Left, m_Right, and m_Top.

bool wGui::CRect::operator!= ( const CRect r  )  const [inline]

Inequality operator

Parameters:
r The rect to compare to

Definition at line 169 of file wg_rect.h.

References m_Bottom, m_Left, m_Right, and m_Top.

CRect & wGui::CRect::Grow ( int  iGrowAmount  ) 

Grow will increase (or decrease) all of the dimensions by the given amount. This means that for a rect 20 wide by 10 tall, Grow(1) will increase the size to 22 wide, 12 tall. (each side is moved out by 1)

Parameters:
iGrowAmount The amount to grow the CRect's dimensions by, negative values can be used to shrink the rect
Returns:
A reference to the object

Definition at line 77 of file wg_rect.cpp.

References m_Bottom, m_Left, m_Right, and m_Top.

Referenced by wGui::CEditBox::CEditBox(), wGui::CGroupBox::CGroupBox(), wGui::CPicture::CPicture(), wGui::CTextBox::CTextBox(), wGui::CScrollBar::Draw(), wGui::CPopupMenu::Draw(), wGui::CMenu::Draw(), wGui::CFrame::Draw(), wGui::CPainter::DrawRect(), wGui::CEditBox::HandleMessage(), wGui::CDropDown::HandleMessage(), wGui::CTextBox::SetWindowRect(), wGui::CPicture::SetWindowRect(), wGui::CListBox::SetWindowRect(), and wGui::CGroupBox::SetWindowRect().

CRect & wGui::CRect::Move ( int  iOffsetX,
int  iOffsetY 
)

Move will move the rect by a offset specified

Parameters:
iOffsetX how many pixel to move on X axis ( + or - )
iOffsetY how many pixel to move on Y axis ( + or - )
Returns:
A reference to the object

Definition at line 88 of file wg_rect.cpp.

References m_Bottom, m_Left, m_Right, and m_Top.

Referenced by wGui::CFrame::HandleMessage().

bool wGui::CRect::Overlaps ( const CRect r  )  const

Tests to see if the two CRects overlap

Parameters:
r The other CRect to test with
Returns:
true if the CRects overlap

Definition at line 99 of file wg_rect.cpp.

References m_Left, m_Right, and m_Top.

Referenced by ClipTo().

CRect & wGui::CRect::ClipTo ( const CRect r  ) 

Clips the CRect to fit in another CRect

Parameters:
r The CRect to clip to

Definition at line 112 of file wg_rect.cpp.

References m_Bottom, m_Left, m_Right, m_Top, and Overlaps().

Referenced by wGui::CView::AttachMenu(), wGui::CFrame::AttachMenu(), wGui::CTextBox::Draw(), wGui::CEditBox::Draw(), wGui::CPainter::DrawRect(), and wGui::CView::HandleMessage().

unsigned int wGui::CRect::HitTest ( const CPoint p  )  const

The HitTest will test to see where a point is in relation to the rect

Parameters:
p The point to test against the CRect
Returns:
The appropriate values of the ERelativePosition enum are ORed together

Definition at line 146 of file wg_rect.cpp.

References m_Bottom, m_Left, m_Right, m_Top, RELPOS_ABOVE, RELPOS_BELOW, RELPOS_INSIDE, RELPOS_LEFT, RELPOS_RIGHT, wGui::CPoint::XPos(), and wGui::CPoint::YPos().

Referenced by wGui::CRenderedString::Draw(), wGui::CView::HandleMessage(), wGui::CToolTip::HandleMessage(), wGui::CTextBox::HandleMessage(), wGui::CRadioButton::HandleMessage(), wGui::CPopupMenu::HandleMessage(), wGui::CMenu::HandleMessage(), wGui::CMenuBase::HandleMessage(), wGui::CEditBox::HandleMessage(), wGui::CDropDown::HandleMessage(), wGui::CCheckBox::HandleMessage(), wGui::CWindow::HitTest(), wGui::CPopupMenu::IsInsideChild(), wGui::CWindow::OnMouseButtonDown(), wGui::CTextBox::OnMouseButtonDown(), wGui::CScrollBar::OnMouseButtonDown(), wGui::CRadioButton::OnMouseButtonDown(), wGui::CPopupMenu::OnMouseButtonDown(), wGui::CMenu::OnMouseButtonDown(), wGui::CListBox::OnMouseButtonDown(), wGui::CFrame::OnMouseButtonDown(), wGui::CEditBox::OnMouseButtonDown(), wGui::CCheckBox::OnMouseButtonDown(), wGui::CButton::OnMouseButtonDown(), wGui::CWindow::OnMouseButtonUp(), wGui::CRadioButton::OnMouseButtonUp(), wGui::CListBox::OnMouseButtonUp(), wGui::CCheckBox::OnMouseButtonUp(), wGui::CButton::OnMouseButtonUp(), wGui::CPopupMenu::ShowActivePopup(), and wGui::CMenu::ShowActivePopup().

std::wstring wGui::CRect::ToString ( void   )  const [inline]

Returns the coordinates of the rectangle as a string

Returns:
A std::string with the coordinates listed as "<left>,<top>,<right>,<bottom>", i.e. "1,2,3,4"

Definition at line 212 of file wg_rect.h.

References stdex::itoa(), m_Bottom, m_Left, m_Right, and m_Top.


The documentation for this class was generated from the following files:
Generated on Wed May 16 23:11:28 2007 for wGui by  doxygen 1.5.1