smjg.libs.sdwf.geometry.Rect Union Reference

The smjg.libs.sdwf.geometry.Rect union represents a rectangle defined by integer coordinates. More...

List of all members.

Public Types

typedef centreX centerX
typedef centreY centerY
typedef centreOn centerOn
typedef centreXOn centerXOn
typedef centreYOn centerYOn

Public Member Functions

void centreOn (Rect r)
 Moves this rectangle's centre to be the same as that of r.
void centreOn (Rect r, int w, int h)
 Sets this rectangle's centre and dimensions.
void centreOn (Rect r, RectDim dim)
 Sets this rectangle's centre and dimensions.
void centreXOn (Rect r, int w)
 Sets this rectangle's horizontal centre and width.
void centreYOn (Rect r, int h)
 Sets this rectangle's vertical centre and height.
void clipTo (Rect r)
 Clips this rectangle to the bounds of r.
bool contains (Point p)
 Determines whether this rectangle contains the given point.
bool contains (Rect r)
 Determines whether this rectangle completely contains the given rectangle.
bool overlaps (Rect r)
 Determines whether this rectangle completely overlaps the given rectangle.
void border (int width)
 Enlarges or reduces this rectangle by a specified amount, as if to add or subtract a border.
void border (int x, int y)
 Enlarges or reduces this rectangle by a specified amount, as if to add or subtract a border.
Properties
string toString ()
 Returns a string representation of this Rect.
int width ()
 The width of this rectangle.
int width (int w)
 Sets the width of this rectangle, by changing right and leaving left unchanged.
int height ()
 The height of this rectangle.
int height (int h)
 Sets the height of this rectangle, by changing bottom and leaving top unchanged.
RectDim dim ()
 The dimensions of this rectangle.
RectDim dim (RectDim d)
 Sets the dimensions of this rectangle by changing bottom and right, leaving top and left unchanged.
Point bottomLeft ()
 The bottom-left corner of this rectangle.
Point bottomLeft (Point p)
 The bottom-left corner of this rectangle.
Point topRight ()
 The top-right corner of this rectangle.
Point topRight (Point p)
 The top-right corner of this rectangle.
int centreX ()
 The horizontal coordinate of this rectangle's centre.
int centreX (int x)
 Sets the horizontal coordinate of this rectangle's centre.
int centreY ()
 The vertical coordinate of this rectangle's centre.
int centreY (int y)
 Sets the vertical coordinate of this rectangle's centre.
long area ()
 The area of this rectangle.
bool isNormal ()
 Checks whether this rectangle is 'normal'.
Operators
{ Returns the intersection of this rectangle with another rectangle.

Rect opAnd (Rect r)

Static Public Member Functions

static Rect desktopArea ()
 The Windows desktop area.
Pseudo-Constructors
static Rect opCall (int l, int t, int r, int b)
 Constructs a Rect with the given extremities.
static Rect opCall (Point tl, Point br)
 Constructs a Rect with the given opposite corners.
static Rect opCall (Point tl, RectDim dim)
 Constructs a Rect with the given position and dimensions.

Public Attributes

RECT rect
 This rectangle as a Windows RECT structure.
int left
int top
int right
int bottom
Point topLeft
Point bottomRight


Detailed Description

The smjg.libs.sdwf.geometry.Rect union represents a rectangle defined by integer coordinates.

Examples are:

In typical uses involving bitmapped displays or images, left and top are just inside the rectangle, whereas right and bottom are just outside it. This interpretation provides compatibility with the Windows API, and makes for simple, efficient operations without fencepost errors.

It is called Rect to avoid confusion with the Windows API function Rectangle.

This type is a wrapper around the Windows API RECT structure,


Member Typedef Documentation

typedef centreX smjg.libs.sdwf.geometry.Rect.centerX

typedef centreY smjg.libs.sdwf.geometry.Rect.centerY

typedef centreOn smjg.libs.sdwf.geometry.Rect.centerOn

typedef centreXOn smjg.libs.sdwf.geometry.Rect.centerXOn

typedef centreYOn smjg.libs.sdwf.geometry.Rect.centerYOn


Member Function Documentation

static Rect smjg.libs.sdwf.geometry.Rect.desktopArea (  )  [static]

The Windows desktop area.

This is the screen area minus the taskbar, if the taskbar is always on top. Otherwise, it is the entire screen area. It is useful for positioning a window.

static Rect smjg.libs.sdwf.geometry.Rect.opCall ( int  l,
int  t,
int  r,
int  b 
) [static]

Constructs a Rect with the given extremities.

Returns:
the newly constructed Rect.

static Rect smjg.libs.sdwf.geometry.Rect.opCall ( Point  tl,
Point  br 
) [static]

Constructs a Rect with the given opposite corners.

Parameters:
tl the top-left corner.
br the bottom-right corner.
Returns:
the newly constructed Rect.

static Rect smjg.libs.sdwf.geometry.Rect.opCall ( Point  tl,
RectDim  dim 
) [static]

Constructs a Rect with the given position and dimensions.

Parameters:
tl the top-left corner.
dim the rectangle's dimensions.
Returns:
the newly constructed Rect.

string smjg.libs.sdwf.geometry.Rect.toString (  ) 

Returns a string representation of this Rect.

Returns:
string representation in form (left, top)-(right, bottom).
Since:
0.4
Status:
done

int smjg.libs.sdwf.geometry.Rect.width (  ) 

The width of this rectangle.

int smjg.libs.sdwf.geometry.Rect.width ( int  w  ) 

Sets the width of this rectangle, by changing right and leaving left unchanged.

int smjg.libs.sdwf.geometry.Rect.height (  ) 

The height of this rectangle.

int smjg.libs.sdwf.geometry.Rect.height ( int  h  ) 

Sets the height of this rectangle, by changing bottom and leaving top unchanged.

RectDim smjg.libs.sdwf.geometry.Rect.dim (  ) 

The dimensions of this rectangle.

RectDim smjg.libs.sdwf.geometry.Rect.dim ( RectDim  d  ) 

Sets the dimensions of this rectangle by changing bottom and right, leaving top and left unchanged.

Point smjg.libs.sdwf.geometry.Rect.bottomLeft (  ) 

The bottom-left corner of this rectangle.

Point smjg.libs.sdwf.geometry.Rect.bottomLeft ( Point  p  ) 

The bottom-left corner of this rectangle.

Point smjg.libs.sdwf.geometry.Rect.topRight (  ) 

The top-right corner of this rectangle.

Point smjg.libs.sdwf.geometry.Rect.topRight ( Point  p  ) 

The top-right corner of this rectangle.

int smjg.libs.sdwf.geometry.Rect.centreX (  ) 

The horizontal coordinate of this rectangle's centre.

int smjg.libs.sdwf.geometry.Rect.centreX ( int  x  ) 

Sets the horizontal coordinate of this rectangle's centre.

The rectangle's dimensions remain unchanged.

int smjg.libs.sdwf.geometry.Rect.centreY (  ) 

The vertical coordinate of this rectangle's centre.

int smjg.libs.sdwf.geometry.Rect.centreY ( int  y  ) 

Sets the vertical coordinate of this rectangle's centre.

The rectangle's dimensions remain unchanged.

long smjg.libs.sdwf.geometry.Rect.area (  ) 

The area of this rectangle.

Since:
0.5

bool smjg.libs.sdwf.geometry.Rect.isNormal (  ) 

Checks whether this rectangle is 'normal'.

Returns:
whether this rectangle is 'normal', i.e. left <= right and top <= bottom.
Since:
0.5

Rect smjg.libs.sdwf.geometry.Rect.opAnd ( Rect  r  ) 

Since:
0.5

void smjg.libs.sdwf.geometry.Rect.centreOn ( Rect  r  ) 

Moves this rectangle's centre to be the same as that of r.

Does not alter the rectangle's dimensions.

void smjg.libs.sdwf.geometry.Rect.centreOn ( Rect  r,
int  w,
int  h 
)

Sets this rectangle's centre and dimensions.

Parameters:
r the rectangle whose centre is to be used.
w the new width.
h the new height.

void smjg.libs.sdwf.geometry.Rect.centreOn ( Rect  r,
RectDim  dim 
)

Sets this rectangle's centre and dimensions.

Parameters:
r the rectangle whose centre is to be used.
dim the rectangle's new dimensions.

void smjg.libs.sdwf.geometry.Rect.centreXOn ( Rect  r,
int  w 
)

Sets this rectangle's horizontal centre and width.

Parameters:
r the rectangle whose horizontal centre is to be used.
w the new width.

void smjg.libs.sdwf.geometry.Rect.centreYOn ( Rect  r,
int  h 
)

Sets this rectangle's vertical centre and height.

Parameters:
r the rectangle whose vertical centre is to be used.
h the new height.

void smjg.libs.sdwf.geometry.Rect.clipTo ( Rect  r  ) 

Clips this rectangle to the bounds of r.

Precondition:
Assumes that both this rectangle and are 'normal'.

bool smjg.libs.sdwf.geometry.Rect.contains ( Point  p  ) 

Determines whether this rectangle contains the given point.

Considers left and top to be just inside, and right and bottom to be just outside.

Precondition:
Assumes that this rectangle is 'normal'.
Parameters:
p point to check.
Returns:
whether p is within this rectangle.
Since:
0.5
Status:
test

bool smjg.libs.sdwf.geometry.Rect.contains ( Rect  r  ) 

Determines whether this rectangle completely contains the given rectangle.

Precondition:
Assumes that both this rectangle and r are 'normal'.
Parameters:
r rectangle to check.
Returns:
whether r is completely contained within this rectangle.
Since:
0.5
Status:
test

bool smjg.libs.sdwf.geometry.Rect.overlaps ( Rect  r  ) 

Determines whether this rectangle completely overlaps the given rectangle.

Precondition:
Assumes that both this rectangle and r are 'normal'.
Parameters:
r rectangle to check.
Returns:
whether r has any area in common with this rectangle.
Since:
0.5
Status:
test

void smjg.libs.sdwf.geometry.Rect.border ( int  width  ) 

Enlarges or reduces this rectangle by a specified amount, as if to add or subtract a border.

Parameters:
width value by which to adjust each side of the rectangle.
Note:
Positive values enlarge the rectangle, and negative values reduce it, assuming that r.left < r.right and r.top < r.bottom.
Since:
0.4
Status:
done

void smjg.libs.sdwf.geometry.Rect.border ( int  x,
int  y 
)

Enlarges or reduces this rectangle by a specified amount, as if to add or subtract a border.

Parameters:
x value by which to adjust the left and right sides.
y value by which to adjust the top and bottom sides.
Note:
Positive values enlarge the rectangle, and negative values reduce it, assuming that r.left < r.right and r.top < r.bottom.
Since:
0.4
Status:
done


Member Data Documentation

int smjg.libs.sdwf.geometry.Rect.left

int smjg.libs.sdwf.geometry.Rect.top

int smjg.libs.sdwf.geometry.Rect.right

int smjg.libs.sdwf.geometry.Rect.bottom

Point smjg.libs.sdwf.geometry.Rect.topLeft

Point smjg.libs.sdwf.geometry.Rect.bottomRight

RECT smjg.libs.sdwf.geometry.Rect.rect

This rectangle as a Windows RECT structure.


The documentation for this union was generated from the following file:
Generated on Sun Jan 11 21:54:14 2009 for Stewart's D Windows Framework by  doxygen 1.5.4