Public Member Functions | Friends | List of all members
BSize Class Reference

The BSize class defines the size of a two - dimensional object using integer point precision. More...

#include <BSize.h>

Public Member Functions

 BSize ()
 Constructs a BSize with an invalid width and height (i.e., IsValid() returns false). More...
 
 BSize (int w, int h)
 Constructs a BSize with the given width and height. More...
 
bool IsNull () const
 Returns true if both the width and height are 0; otherwise returns false. More...
 
bool IsEmpty () const
 Returns true if either of the width or height is less than or equal to 0; otherwise returns false. More...
 
bool IsValid () const
 Returns true if both the width and height are equal to or greater than 0; otherwise returns false. More...
 
int Width () const
 Returns the width. More...
 
int Height () const
 Returns the height. More...
 
void SetWidth (int w)
 Sets the width to the given width. More...
 
void SetHeight (int h)
 Sets the height to the given height. More...
 
void Transpose ()
 Swaps the width and height values. More...
 
BSize ExpandedTo (const BSize &) const
 Sets the width and height to the largest from this BSize and the given BSize. More...
 
BSize BoundedTo (const BSize &) const
 Sets the width and height to the smallest from this BSize and the given BSize. More...
 
BSizeoperator+= (const BSize &)
 Operator overload for += (add and assign). More...
 
BSizeoperator-= (const BSize &)
 Operator overload for -= (substract and assign). More...
 
BSizeoperator*= (double c)
 Operator overload for *= (multiply and assign). More...
 
BSizeoperator/= (double c)
 Operator overload for /= (divide and assign). More...
 

Friends

bool operator== (const BSize &, const BSize &)
 Operator overload for == (equality test). More...
 
bool operator!= (const BSize &, const BSize &)
 Operator overload for != (not equal test). More...
 
const BSize operator+ (const BSize &, const BSize &)
 Operator overload for + (add). More...
 
const BSize operator- (const BSize &, const BSize &)
 Operator overload for - (subtract). More...
 
const BSize operator* (const BSize &, double)
 Operator overload for * (multiply). More...
 
const BSize operator* (double, const BSize &)
 Operator overload for * (multiply). More...
 
const BSize operator/ (const BSize &, double)
 Operator overload for / (divide). More...
 

Detailed Description

The BSize class defines the size of a two - dimensional object using integer point precision.

A size is specified by a Width() and a Height(). It can be set in the constructor and changed using the SetWidth(), SetHeight(), or Scale() functions, or using arithmetic operators. The width and height can be swapped using the Transpose() function.

The IsValid() function determines if a size is valid (a valid size has both width and height greater than zero). The IsEmpty() function returns true if either of the width and height is less than, or equal to, zero, while the IsNull() function returns true only if both the width and the height is zero.

Use the ExpandedTo() function to retrieve a size which holds the maximum height and width of this size and a given size. Similarly, the BoundedTo() function returns a size which holds the minimum height and width of this size and a given size.

Constructor & Destructor Documentation

BSize ( )

Constructs a BSize with an invalid width and height (i.e., IsValid() returns false).

BSize ( int  w,
int  h 
)

Constructs a BSize with the given width and height.

Member Function Documentation

BSize BoundedTo ( const BSize ) const

Sets the width and height to the smallest from this BSize and the given BSize.

BSize ExpandedTo ( const BSize ) const

Sets the width and height to the largest from this BSize and the given BSize.

int Height ( ) const

Returns the height.

Referenced by operator!=(), operator*(), operator+(), operator-(), operator/(), and operator==().

bool IsEmpty ( ) const

Returns true if either of the width or height is less than or equal to 0; otherwise returns false.

bool IsNull ( ) const

Returns true if both the width and height are 0; otherwise returns false.

bool IsValid ( ) const

Returns true if both the width and height are equal to or greater than 0; otherwise returns false.

BSize& operator*= ( double  c)

Operator overload for *= (multiply and assign).

BSize& operator+= ( const BSize )

Operator overload for += (add and assign).

BSize& operator-= ( const BSize )

Operator overload for -= (substract and assign).

BSize& operator/= ( double  c)

Operator overload for /= (divide and assign).

void SetHeight ( int  h)

Sets the height to the given height.

void SetWidth ( int  w)

Sets the width to the given width.

void Transpose ( )

Swaps the width and height values.

int Width ( ) const

Returns the width.

Referenced by operator!=(), operator*(), operator+(), operator-(), operator/(), and operator==().

Friends And Related Function Documentation

bool operator!= ( const BSize s1,
const BSize s2 
)
friend

Operator overload for != (not equal test).

const BSize operator* ( const BSize s,
double  c 
)
friend

Operator overload for * (multiply).

const BSize operator* ( double  c,
const BSize s 
)
friend

Operator overload for * (multiply).

const BSize operator+ ( const BSize s1,
const BSize s2 
)
friend

Operator overload for + (add).

const BSize operator- ( const BSize s1,
const BSize s2 
)
friend

Operator overload for - (subtract).

const BSize operator/ ( const BSize s,
double  c 
)
friend

Operator overload for / (divide).

bool operator== ( const BSize s1,
const BSize s2 
)
friend

Operator overload for == (equality test).


The documentation for this class was generated from the following file:

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.