#include <xrect.h>
Inheritance diagram for Ars::XRect:

Public Types | |
| enum | ERelativePosition { RELPOS_ABOVE = 1, RELPOS_BELOW = 2, RELPOS_LEFT = 4, RELPOS_RIGHT = 8, RELPOS_INSIDE = 16 } |
Public Member Functions | |
| XRect (void) | |
| The default constructor will initialize all 4 corners to (0, 0). | |
| XRect (const int ax, const int ay, const int aw, const int ah) | |
| XRect (const XPoint &p1, const XPoint &p2) | |
| XRect (const XRect &r) | |
| virtual | ~XRect (void) |
| Standard Destructor. | |
| int | Width (void) const |
| The width (along the X axis) of the CRect. | |
| int | Height (void) const |
| The height (along the Y axis) of the CRect. | |
| XPoint | Size () const |
| the size | |
| XPoint | TopLeft (void) const |
| A point representing the Top Left corner of the CRect. | |
| XPoint | TopRight (void) const |
| A point representing the Top Right corner of the CRect. | |
| XPoint | BottomLeft (void) const |
| A point representing the Bottom Left corner of the CRect. | |
| XPoint | BottomRight (void) const |
| A point representing the Bottom Right corner of the CRect. | |
| const int | Right (void) const |
| const int | Bottom (void) const |
| void | SetBottom (const int y2) |
| void | SetRight (const int x2) |
| XPoint | Center (void) const |
| A point representing the center of the CRect. | |
| operator SDL_Rect (void) | |
| operator const SDL_Rect (void) const | |
| XRect & | operator= (const XRect &r) |
| Assignment operator will copy the values of the other rect. | |
| XRect & | operator= (const SDL_Rect &r) |
| XRect | operator+ (const XPoint &p) const |
| XRect | operator- (const XPoint &p) const |
| XRect & | Grow (const int iGrowAmount) |
| const bool | Overlaps (const XRect &r) |
| void | ClipTo (const XRect &r) |
| unsigned int | HitTest (const XPoint &p) const |
| The HitTest will test to see where a point is in relation to the rect. | |
Definition at line 55 of file xrect.h.
|
|
Definition at line 170 of file xrect.h.
00171 {
00172 RELPOS_ABOVE = 1,
00173 RELPOS_BELOW = 2,
00174 RELPOS_LEFT = 4,
00175 RELPOS_RIGHT = 8,
00176 RELPOS_INSIDE = 16
00177 };
|
|
|
The default constructor will initialize all 4 corners to (0, 0).
Definition at line 58 of file xrect.h. Referenced by Ars::XTextBox::Init(), Ars::XScrollBar::Init(), Ars::XListBox::Init(), Ars::XDropDown::Init(), operator+(), operator-(), Ars::XTextBox::SetWindowRect(), Ars::XScrollBar::SetWindowRect(), Ars::XListBox::SetWindowRect(), and Ars::View::wmResize().
00059 { x = 0; y = 0; w = 0; h = 0; } // constructor
|
|
||||||||||||||||||||
|
Definition at line 65 of file xrect.h.
00066 { x = ax; y = ay; w = aw; h = ah; } // constructor
|
|
||||||||||||
|
Create a CRect using a pair of CPoints that represent the Top-Left, and Bottom-Right corners
Definition at line 71 of file xrect.h. References Ars::XPoint::x, and Ars::XPoint::y.
00072 {
00073 x = min( p2.x , p1.x ); y = min( p2.y , p1.y );
00074 w = max( p2.x , p1.x ) - x;
00075 h = max( p2.y , p1.y ) - y;
00076 } // constructor
|
|
|
Copy constructor
Definition at line 80 of file xrect.h.
00081 { x = r.x; y = r.y; w = r.w; h = r.h; } // constructor
|
|
|
Standard Destructor.
Definition at line 84 of file xrect.h.
00084 { }
|
|
|
Definition at line 108 of file xrect.h. References Height(). Referenced by Ars::HPaint::_TextOut(), Ars::Graf::ButtonImg(), ClipTo(), Ars::XTextBox::Draw(), Ars::XListBox::Draw(), Ars::XEditBox::Draw(), Ars::XBox::Draw(), Ars::XBox::DrawFocus(), Ars::XBox::DrawRaised(), Ars::HPaint::DrawRect(), Ars::XBox::DrawSunken(), Ars::Form::FindWindowParent(), Ars::XScrollBar::Init(), Ars::Thing::Init(), and Ars::XScrollBar::SetWindowRect().
00108 { return y + Height(); }
|
|
|
A point representing the Bottom Left corner of the CRect.
Definition at line 102 of file xrect.h. Referenced by Ars::XCheckBox::Draw(), Ars::XBox::DrawRaised(), Ars::XBox::DrawSunken(), and Overlaps().
00102 { return XPoint( x , y + h ); }
|
|
|
A point representing the Bottom Right corner of the CRect.
Definition at line 105 of file xrect.h. Referenced by Ars::XCheckBox::Draw(), Ars::XBox::DrawRaised(), Ars::XBox::DrawSunken(), Ars::Window::GetClientRect(), Ars::XScrollBar::Init(), Overlaps(), and Ars::XScrollBar::SetWindowRect().
00105 { return XPoint( x + w , y + h); }
|
|
|
A point representing the center of the CRect.
Definition at line 114 of file xrect.h. References Height(), and Width(). Referenced by Ars::XEditBox::Draw(), and Ars::XButtonImage::Draw().
|
|
|
Clips the CRect to fit in another CRect
Definition at line 152 of file xrect.h. References Bottom(), Overlaps(), Right(), SetBottom(), and SetRight(). Referenced by Ars::XTextBox::Draw(), Ars::XListBox::Draw(), Ars::XEditBox::Draw(), and Ars::Window::GetClientRect().
|
|
|
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)
Definition at line 138 of file xrect.h. Referenced by Ars::XTextBox::Draw(), Ars::XScrollBar::Draw(), Ars::XProgress::Draw(), Ars::XListBox::Draw(), Ars::XGroupBox::Draw(), Ars::XEditBox::Draw(), Ars::XCheckBox::Draw(), Ars::XButtonImage::Draw(), Ars::XBox::Draw(), Ars::HPaint::DrawRect(), Ars::XEditBox::evMouseButtonDown(), Ars::XEditBox::evMouseMove(), Ars::XDropDown::Init(), Ars::XTextBox::SetWindowRect(), and Ars::XListBox::SetWindowRect().
00138 { x -= iGrowAmount; y -= iGrowAmount; w += 2 * iGrowAmount; h += 2 * iGrowAmount; return *this; }
|
|
|
The height (along the Y axis) of the CRect.
Definition at line 90 of file xrect.h. Referenced by Ars::XListBox::AddItem(), Bottom(), Ars::Graf::ButtonImg(), Center(), Ars::XTextBox::Draw(), Ars::XCheckBox::Draw(), Ars::Window::DrawBG(), Ars::XListBox::evKeyDown(), Ars::XScrollBar::evMouseMove(), Ars::XTextBox::Init(), Ars::XScrollBar::Init(), Ars::XListBox::Init(), Ars::XDropDown::Init(), Ars::XListBox::RemoveItem(), Ars::Graf::SDL_StretchBlt(), Ars::XTextBox::SetWindowRect(), Ars::XScrollBar::SetWindowRect(), Ars::XListBox::SetWindowRect(), Ars::Window::SetWindowRect(), Ars::XTextBox::SetWndText(), Ars::HPaint::TextOutStr(), Ars::View::View(), and Ars::View::wmResize().
00090 { return (short int)h; }
|
|
|
The HitTest will test to see where a point is in relation to the rect.
Definition at line 182 of file xrect.h. References RELPOS_ABOVE, RELPOS_BELOW, RELPOS_INSIDE, RELPOS_LEFT, RELPOS_RIGHT, Ars::XPoint::x, and Ars::XPoint::y. Referenced by Ars::HPaint::_TextOut(), Ars::XScrollBar::Draw(), Ars::XScrollBar::evMouseButtonDown(), Ars::XListBox::evMouseButtonDown(), Ars::XListBox::evMouseButtonUp(), Ars::XEditBox::evMouseMove(), Ars::Window::FindWindow(), Overlaps(), and Ars::Window::RelposInside().
00183 {
00184 unsigned int eRelPos = 0;
00185
00186 eRelPos |= (p.x < x) ? RELPOS_LEFT : 0;
00187 eRelPos |= (p.y < y) ? RELPOS_ABOVE: 0;
00188 eRelPos |= (p.x > (x+w)) ? RELPOS_RIGHT : 0;
00189 eRelPos |= (p.y > (y+h)) ? RELPOS_BELOW: 0;
00190 eRelPos |= (p.x >= x && p.x <= (x+w) && p.y >= y && p.y <= (y+h)) ? RELPOS_INSIDE : 0;
00191
00192 return eRelPos;
00193 }
|
|
|
Definition at line 119 of file xrect.h.
00119 { return static_cast<const SDL_Rect>( *this ); }
|
|
|
Converts the CRect into a SDL style rect
Definition at line 118 of file xrect.h.
00118 { return static_cast<SDL_Rect>( *this ); }
|
|
|
Addition operator to add a CPoint, will offset the CRect
Definition at line 127 of file xrect.h. References Ars::XPoint::x, XRect(), and Ars::XPoint::y.
00127 { return XRect( x + p.x , y + p.y , w , y ); }
|
|
|
Subtraction operator to subtract a CPoint, will offset the CRect
Definition at line 131 of file xrect.h. References Ars::XPoint::x, XRect(), and Ars::XPoint::y.
00131 { return XRect( x - p.x , y - p.y , w , y ); }
|
|
|
Definition at line 123 of file xrect.h.
00123 { x = r.x; y = r.y; w = r.w; h = r.h; return *this; } // assignment operator
|
|
|
Assignment operator will copy the values of the other rect.
Definition at line 122 of file xrect.h.
00122 { x = r.x; y = r.y; w = r.w; h = r.h; return *this; } // assignment operator
|
|
|
Tests to see if the two CRects overlap
Definition at line 143 of file xrect.h. References BottomLeft(), BottomRight(), HitTest(), RELPOS_INSIDE, TopLeft(), and TopRight(). Referenced by ClipTo(), Ars::XTextBox::Draw(), and Ars::XListBox::Draw().
00144 {
00145 return (HitTest(r.TopLeft()) == RELPOS_INSIDE || HitTest(r.TopRight()) == RELPOS_INSIDE || HitTest(r.BottomRight()) == RELPOS_INSIDE
00146 || HitTest(r.BottomLeft()) == RELPOS_INSIDE || r.HitTest(TopLeft()) == RELPOS_INSIDE || r.HitTest(TopRight()) == RELPOS_INSIDE
00147 || r.HitTest(BottomRight()) == RELPOS_INSIDE || r.HitTest(BottomLeft()) == RELPOS_INSIDE);
00148 }
|
|
|
Definition at line 107 of file xrect.h. References Width(). Referenced by Ars::HPaint::_TextOut(), Ars::Graf::ButtonImg(), ClipTo(), Ars::XEditBox::Draw(), Ars::XBox::Draw(), Ars::XBox::DrawFocus(), Ars::XBox::DrawRaised(), Ars::HPaint::DrawRect(), Ars::XBox::DrawSunken(), Ars::Form::FindWindowParent(), Ars::XTextBox::Init(), Ars::XScrollBar::Init(), Ars::XListBox::Init(), Ars::XDropDown::Init(), Ars::Thing::Init(), Ars::XTextBox::SetWindowRect(), Ars::XScrollBar::SetWindowRect(), and Ars::XListBox::SetWindowRect().
00107 { return x + Width(); }
|
|
|
Definition at line 110 of file xrect.h. Referenced by Ars::Graf::ButtonImg(), ClipTo(), Ars::XTextBox::Draw(), Ars::XListBox::Draw(), Ars::XEditBox::Draw(), Ars::XScrollBar::SetWindowRect(), and Ars::View::wmResize().
00110 { h = abs( y2 - y ); }
|
|
|
Definition at line 111 of file xrect.h. Referenced by Ars::Graf::ButtonImg(), ClipTo(), Ars::XEditBox::Draw(), Ars::XCheckBox::Draw(), Ars::XScrollBar::SetWindowRect(), and Ars::View::wmResize().
00111 { w = abs( x2 - x ); }
|
|
|
the size
Reimplemented in Ars::XDropDown. Definition at line 93 of file xrect.h.
00093 { return XPoint( w , h ); }
|
|
|
A point representing the Top Left corner of the CRect.
Definition at line 96 of file xrect.h. Referenced by Ars::XScrollBar::Draw(), Ars::XCheckBox::Draw(), Ars::XBox::DrawRaised(), Ars::XBox::DrawSunken(), Ars::Window::GetClientRect(), Ars::XScrollBar::Init(), Overlaps(), Ars::XScrollBar::SetWindowRect(), and Ars::HPaint::TextOutStr().
00096 { return XPoint( x , y ); }
|
|
|
A point representing the Top Right corner of the CRect.
Definition at line 99 of file xrect.h. Referenced by Ars::XCheckBox::Draw(), Ars::XBox::DrawRaised(), Ars::XBox::DrawSunken(), and Overlaps().
00099 { return XPoint( x + w, y ); }
|
|
|
The width (along the X axis) of the CRect.
Definition at line 87 of file xrect.h. Referenced by Ars::HPaint::_TextOut(), Ars::Graf::ButtonImg(), Center(), Ars::XTextBox::Draw(), Ars::XListBox::Draw(), Ars::Window::DrawBG(), Ars::XScrollBar::evMouseMove(), Ars::XScrollBar::Init(), Right(), Ars::Graf::SDL_StretchBlt(), Ars::XTextBox::SetWindowRect(), Ars::XScrollBar::SetWindowRect(), Ars::XListBox::SetWindowRect(), Ars::Window::SetWindowRect(), Ars::View::View(), and Ars::View::wmResize().
00087 { return (short int)w; }
|
1.3.3