Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages | Examples

fgl::FGSize Class Reference

#include <base.h>

List of all members.


Detailed Description

The FGSize class defines the size of a two-dimensional object.

A size is specified by a width and a height.

The coordinate type is FGCOORD (defined as int). The minimum value of FGCOORD is FGCOORD_MIN (-2147483648) and the maximum value is FGCOORD_MAX (2147483647).

The size can be set in the constructor and changed with setWidth() and setHeight(), or using operator+=(), operator-=(), operator*=() and operator/=(), etc. You can swap the width and height with transpose(). You can get a size which holds the maximum height and width of two sizes using expandedTo(), and the minimum height and width of two sizes using boundedTo().

See also:
FGPoint, FGRect


Public Member Functions

 FGSize ()
 FGSize (int w, int h)
bool isNull () const
bool isEmpty () const
bool isValid () const
int width () const
int height () const
void setWidth (int w)
void setHeight (int h)
void transpose ()
FGSize expandedTo (const FGSize &) const
FGSize boundedTo (const FGSize &) const
void scale (int w, int h, ScaleMode mode)
void scale (const FGSize &s, ScaleMode mode)
FGCOORDrwidth ()
FGCOORDrheight ()
FGSizeoperator+= (const FGSize &)
FGSizeoperator-= (const FGSize &)
FGSizeoperator *= (int c)
FGSizeoperator *= (double c)
FGSizeoperator/= (int c)
FGSizeoperator/= (double c)

Public Attributes

FGCOORD wd
FGCOORD ht

Friends

bool operator== (const FGSize &, const FGSize &)
bool operator!= (const FGSize &, const FGSize &)
const FGSize operator+ (const FGSize &, const FGSize &)
const FGSize operator- (const FGSize &, const FGSize &)
const FGSize operator * (const FGSize &, int)
const FGSize operator * (int, const FGSize &)
const FGSize operator * (const FGSize &, double)
const FGSize operator * (double, const FGSize &)
const FGSize operator/ (const FGSize &, int)
const FGSize operator/ (const FGSize &, double)


Constructor & Destructor Documentation

fgl::FGSize::FGSize  )  [inline]
 

Constructs a size with invalid (negative) width and height.

fgl::FGSize::FGSize int  w,
int  h
[inline]
 

Constructs a size with width w and height h.


Member Function Documentation

FGSize fgl::FGSize::boundedTo const FGSize otherSize  )  const [inline]
 

Returns a size with the minimum width and height of this size and otherSize.

FGSize fgl::FGSize::expandedTo const FGSize otherSize  )  const [inline]
 

Returns a size with the maximum width and height of this size and otherSize.

int fgl::FGSize::height  )  const [inline]
 

Returns the height.

See also:
width()

bool fgl::FGSize::isEmpty  )  const [inline]
 

Returns TRUE if the width is less than or equal to 0, or the height is less than or equal to 0; otherwise returns FALSE.

bool fgl::FGSize::isNull void   )  const [inline]
 

Returns TRUE if the width is 0 and the height is 0; otherwise returns FALSE.

bool fgl::FGSize::isValid  )  const [inline]
 

Returns TRUE if the width is equal to or greater than 0 and the height is equal to or greater than 0; otherwise returns FALSE.

FGSize & fgl::FGSize::operator *= int  c  )  [inline]
 

Multiplies both the width and height by c and returns a reference to the size.

FGSize & fgl::FGSize::operator+= const FGSize s  )  [inline]
 

Adds s to the size and returns a reference to this size.

Example:

    FGSize s(  3, 7 );
    FGSize r( -1, 4 );
    s += r;         // s becomes (2,11)

FGSize & fgl::FGSize::operator-= const FGSize s  )  [inline]
 

Subtracts s from the size and returns a reference to this size.

Example:

    FGSize s(  3, 7 );
    FGSize r( -1, 4 );
    s -= r;         // s becomes (4,3)

FGSize & fgl::FGSize::operator/= double  c  )  [inline]
 

Divides both the width and height by c and returns a reference to the size.

Note that the result is truncated.

FGCOORD & fgl::FGSize::rheight  )  [inline]
 

Returns a reference to the height.

Using a reference makes it possible to directly manipulate the height.

Example:

    FGSize s( 100, 10 );
    s.rheight() += 5;       // s becomes (100,15)

See also:
rwidth()

FGCOORD & fgl::FGSize::rwidth  )  [inline]
 

Returns a reference to the width.

Using a reference makes it possible to directly manipulate the width.

Example:

    FGSize s( 100, 10 );
    s.rwidth() += 20;       // s becomes (120,10)

See also:
rheight()

void fgl::FGSize::scale const FGSize s,
ScaleMode  mode
 

Equivalent to scale( {s}.width(), {s}.height(), mode).

void fgl::FGSize::scale int  w,
int  h,
ScaleMode  mode
 

Scales the size to a rectangle of width w and height h according to the ScaleMode mode.

  • If mode is ScaleFree, the size is set to (w, h).
  • If mode is ScaleMin, the current size is scaled to a rectangle as large as possible inside (w, h), preserving the aspect ratio.
  • If mode is ScaleMax, the current size is scaled to a rectangle as small as possible outside (w, h), preserving the aspect ratio.

Example:

    FGSize t1( 10, 12 );
    t1.scale( 60, 60, FGSize::ScaleFree );
    // t1 is (60, 60)

    FGSize t2( 10, 12 );
    t2.scale( 60, 60, FGSize::ScaleMin );
    // t2 is (50, 60)

    FGSize t3( 10, 12 );
    t3.scale( 60, 60, FGSize::ScaleMax );
    // t3 is (60, 72)

void fgl::FGSize::setHeight int  h  )  [inline]
 

Sets the height to h.

See also:
height(), setWidth()

void fgl::FGSize::setWidth int  w  )  [inline]
 

Sets the width to w.

See also:
width(), setHeight()

void fgl::FGSize::transpose  ) 
 

Swaps the values of width and height.

int fgl::FGSize::width  )  const [inline]
 

Returns the width.

See also:
height()


Generated on Wed Feb 9 11:31:37 2005 for OpenGUI by  doxygen 1.4.0