TRect

TRect

TRect是Delphi語言裡面的一個數據類型,形同c++裡面的CRect類,定義了一個矩形,包括top、bottom、left、right、width、height。

基本介紹

  • 外文名:TRect
  • 解釋:Delphi 語言裡面的一個數據類型
  • 包括:top,bottom,left,right等
  • 補充:重載了運算符
簡述,TRect類型,

簡述

當然,重載了運算符。

TRect類型

TRect defines a rectangle.
Unit
Types
Delphi syntax:
type
TRect = packed record
case Integer of
0: (Left, Top, Right, Bottom: Integer);
1: (TopLeft, BottomRight: TPoint);
end;
C++ syntax:
struct TRect
{
TRect() {}
TRect(const TPoint& TL, const TPoint& BR) { left=TL.x; top=TL.y; right=BR.x; bottom=BR.y; }
TRect(int l, int t, int r, int b) { left=l; top=t; right=r; bottom=b; }
TRect(RECT& r)
{
left = r.left;
top = r.top;
right = r.right;
bottom = r.bottom;
}
int Width () const { return right - left; }
int Height() const { return bottom - top ; }
bool operator ==(const TRect& rc) const
{
return left == rc.left && top==rc.top &&
right == rc.right && bottom==rc.bottom;
}
bool operator !=(const TRect& rc) const
{ return !(rc==*this); }
__property LONG Left = { read=left, write=left };
__property LONG Top = { read=top, write=top };
__property LONG Right = { read=right, write=right };
__property LONG Bottom = { read=bottom, write=bottom };
};
Description
TRect represents the dimensions of a rectangle. The coordinates are specified as either four separate integers representing the left, top, right, and bottom sides, or as two points representing the locations of the top left and bottom right corners.
Typically, TRect values represent pixel locations, where the origin of the pixel coordinate system is in the top left corner of the screen (screen coordinates) or the top left corner of a control抯 client area (client coordinates). When a TRect value represents a rectangle on the screen, by convention the top and left edges are considered inside the rectangle and the bottom and right edges are considered outside the rectangle. This convention allows the width of the rectangle to be Right - Left and the height to be Bottom - Top.

相關詞條

熱門詞條

聯絡我們