Wt  3.3.9
Public Member Functions | List of all members
Wt::WRectF Class Reference

A value class that defines a rectangle. More...

#include <Wt/WRectF>

Inheritance diagram for Wt::WRectF:
Inheritance graph
[legend]

Public Member Functions

 WRectF ()
 Default constructor. More...
 
 WRectF (double x, double y, double width, double height)
 Creates a rectangle. More...
 
 WRectF (const WPointF &topLeft, const WPointF &bottomRight)
 Creates a rectangle. More...
 
bool operator== (const WRectF &rhs) const
 Comparison operator.
 
bool isNull () const
 Checks for a null rectangle. More...
 
bool isEmpty () const
 Determines whether or not this rectangle is empty. More...
 
void setX (double x)
 Sets the X-position of the left side. More...
 
void setY (double y)
 Sets the Y-position of the top side. More...
 
void setWidth (double width)
 Sets the width. More...
 
void setHeight (double height)
 Sets the Y-position of the top side. More...
 
double x () const
 Returns the X-position (left side offset). More...
 
double y () const
 Returns the Y-position (top side offset). More...
 
double width () const
 Returns the width. More...
 
double height () const
 Returns the height. More...
 
double left () const
 Returns the X position (left side offset). More...
 
double top () const
 Returns the Y position (top side offset). More...
 
double right () const
 Returns the the right side offset. More...
 
double bottom () const
 Returns the bottom side offset. More...
 
WPointF topLeft () const
 Returns the top left point. More...
 
WPointF topRight () const
 Returns the top right point. More...
 
WPointF center () const
 Returns the center point.
 
WPointF bottomLeft () const
 Returns the bottom left point. More...
 
WPointF bottomRight () const
 Returns the bottom right point. More...
 
bool contains (const WPointF &p) const
 Tests if a rectangle contains a point. More...
 
bool contains (double x, double y) const
 Tests if a rectangle contains a point. More...
 
bool intersects (const WRectF &other) const
 Tests if two rectangles intersect.
 
WRectF united (const WRectF &other) const
 Makes the union of to rectangles. More...
 
WRectF normalized () const
 Returns a normalized rectangle. More...
 
virtual std::string jsValue () const WT_CXX11ONLY(override)
 Returns a JavaScript representation of the value of this object. More...
 
- Public Member Functions inherited from Wt::WJavaScriptExposableObject
bool isJavaScriptBound () const
 Returns whether this object is JavaScript bound. More...
 
std::string jsRef () const
 Returns a JavaScript reference to this object. More...
 

Detailed Description

A value class that defines a rectangle.

The rectangle is defined by a top-left point and a width and height.

JavaScript exposability

A WRectF is JavaScript exposable. If a WRectF is JavaScript bound, it can be accessed in your custom JavaScript code through its handle's jsRef(). A rectangle is represented in JavaScript as an array of four elements (x,y,width,height), e.g. a rectangle WRectF(10,20,30,40) will be represented in JavaScript as:

[10, 20, 30, 40]
Warning
A WRectF that is JavaScript exposed should be modified only through its handle. Any attempt at modifying it will cause an exception to be thrown.
See also
WPaintedWidget::createJSRect()

Constructor & Destructor Documentation

Wt::WRectF::WRectF ( )

Default constructor.

Constructs a null rectangle.

See also
isNull()
Wt::WRectF::WRectF ( double  x,
double  y,
double  width,
double  height 
)

Creates a rectangle.

Constructs a rectangle with top left point (x, y) and size width x height.

Wt::WRectF::WRectF ( const WPointF topLeft,
const WPointF bottomRight 
)

Creates a rectangle.

Constructs a rectangle from the two points topLeft and bottomRight.

If you want to create a rectangle from two arbitrary corner points, you can use this constructor too, but should call normalized() afterwords.

Member Function Documentation

double Wt::WRectF::bottom ( ) const

Returns the bottom side offset.

See also
top()
WPointF Wt::WRectF::bottomLeft ( ) const

Returns the bottom left point.

See also
left(), bottom()
WPointF Wt::WRectF::bottomRight ( ) const

Returns the bottom right point.

See also
right(), bottom()
bool Wt::WRectF::contains ( const WPointF p) const

Tests if a rectangle contains a point.

Note
This method is not supported if this rectangle isJavaScriptBound()
bool Wt::WRectF::contains ( double  x,
double  y 
) const

Tests if a rectangle contains a point.

Note
This method is not supported if this rectangle isJavaScriptBound()
double Wt::WRectF::height ( ) const

Returns the height.

See also
width()
bool Wt::WRectF::isEmpty ( ) const

Determines whether or not this rectangle is empty.

A rectangle is empty if its width and height are zero.

A rectangle that isJavaScriptBound() is JavaScript bound is never empty.

bool Wt::WRectF::isNull ( ) const

Checks for a null rectangle.

A rectangle that isJavaScriptBound() is never null.

See also
WRectF()
std::string Wt::WRectF::jsValue ( ) const
overridevirtual

Returns a JavaScript representation of the value of this object.

Note
The value returned will reflect the current server side value of the object. If this object is JavaScript bound, this value may not reflect the actual client side value. If you need access to the client side value, use jsRef() intead.

Implements Wt::WJavaScriptExposableObject.

double Wt::WRectF::left ( ) const

Returns the X position (left side offset).

See also
x(), right()
WRectF Wt::WRectF::normalized ( ) const

Returns a normalized rectangle.

A normalized rectangle has a positive width and height.

This method supports JavaScript bound rectangles.

double Wt::WRectF::right ( ) const

Returns the the right side offset.

See also
left()
void Wt::WRectF::setHeight ( double  height)

Sets the Y-position of the top side.

The bottom side of the rectangle may move, but this does not affect the Y position of the top side.

Exceptions
WExceptionif the rectangle is JavaScript bound
void Wt::WRectF::setWidth ( double  width)

Sets the width.

The right side of the rectangle may move, but this does not affect the left side.

Exceptions
WExceptionif the rectangle is JavaScript bound
void Wt::WRectF::setX ( double  x)

Sets the X-position of the left side.

The right side of the rectangle does not move, and as a result, the rectangle may be resized.

Exceptions
WExceptionif the rectangle is JavaScript bound
void Wt::WRectF::setY ( double  y)

Sets the Y-position of the top side.

The bottom side of the rectangle does not move, and as a result, the rectangle may be resized.

Exceptions
WExceptionif the rectangle is JavaScript bound
double Wt::WRectF::top ( ) const

Returns the Y position (top side offset).

See also
y(), bottom()
WPointF Wt::WRectF::topLeft ( ) const

Returns the top left point.

See also
left(), top()
WPointF Wt::WRectF::topRight ( ) const

Returns the top right point.

See also
right(), top()
WRectF Wt::WRectF::united ( const WRectF other) const

Makes the union of to rectangles.

Note
This method is not supported if this rectangle is JavaScript bound.
double Wt::WRectF::width ( ) const

Returns the width.

See also
height()
double Wt::WRectF::x ( ) const

Returns the X-position (left side offset).

This is equivalent to left().

See also
y(), left()
double Wt::WRectF::y ( ) const

Returns the Y-position (top side offset).

This is equivalent to top().

See also
x(), top()

Generated on Tue Nov 21 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.11