Public Types | Public Member Functions | Static Public Attributes

Wt::WLength Class Reference

A class that specifies a CSS length. More...

#include <Wt/WLength>

List of all members.

Public Types

enum  Unit {
  FontEm, FontEx, Pixel, Inch,
  Centimeter, Millimeter, Point, Pica,
  Percentage
}
 

The unit.

More...

Public Member Functions

 WLength ()
 Creates an 'auto' length.
 WLength (const char *c)
 Creates a length by parsing the argument as a css length string.
 WLength (double value, Unit unit=Pixel)
 Creates a length with value and unit.
 WLength (int value, Unit unit=Pixel)
 Creates a length with value and unit.
 WLength (long value, Unit unit=Pixel)
 Creates a length with value and unit.
 WLength (unsigned int value, Unit unit=Pixel)
 Creates a length with value and unit.
 WLength (unsigned long value, Unit unit=Pixel)
 Creates a length with value and unit.
bool isAuto () const
 Returns whether the length is 'auto'.
double value () const
 Returns the value.
Unit unit () const
 Returns the unit.
const std::string cssText () const
 Returns the CSS text.
bool operator== (const WLength &other) const
 Comparison operator.
bool operator!= (const WLength &other) const
 Comparison operator.
double toPixels (double fontSize=16.0) const
 Returns the (approximate) length in pixels.

Static Public Attributes

static WLength Auto
 An 'auto' length.

Detailed Description

A class that specifies a CSS length.

The class combines a value with a unit. There is a special value auto which has a different meaning depending on the context.


Member Enumeration Documentation

The unit.

Enumerator:
FontEm 

The relative font size.

FontEx 

The height of an 'x' in the font.

Pixel 

Pixel, relative to canvas resolution.

Inch 

Inche.

Centimeter 

Centimeter.

Millimeter 

Millimeter.

Point 

Point (1/72 Inch)

Pica 

Pica (12 Point)

Percentage 

Percentage (meaning context-sensitive)


Constructor & Destructor Documentation

Wt::WLength::WLength (  )

Creates an 'auto' length.

Specifies an 'auto' length.

See also:
Auto
Wt::WLength::WLength ( const char *  c )

Creates a length by parsing the argument as a css length string.

Only a combination of a value and a unit is supported. If the string is an illegal css length an exception is thrown.

Wt::WLength::WLength ( double  value,
Unit  unit = Pixel 
)

Creates a length with value and unit.

This constructor will also provide the implicit conversion between a double and WLength, using a pixel unit.

Wt::WLength::WLength ( int  value,
Unit  unit = Pixel 
)

Creates a length with value and unit.

This constructor will also provide the implicit conversion between an int and WLength, using a pixel unit.

Wt::WLength::WLength ( long  value,
Unit  unit = Pixel 
)

Creates a length with value and unit.

This constructor will also provide the implicit conversion between a long and WLength, using a pixel unit.

Wt::WLength::WLength ( unsigned int  value,
Unit  unit = Pixel 
)

Creates a length with value and unit.

This constructor will also provide the implicit conversion between an unsigned int and WLength, using a pixel unit.

Wt::WLength::WLength ( unsigned long  value,
Unit  unit = Pixel 
)

Creates a length with value and unit.

This constructor will also provide the implicit conversion between an unsigned long and WLength, using a pixel unit.


Member Function Documentation

bool Wt::WLength::isAuto (  ) const

Returns whether the length is 'auto'.

See also:
WLength(), Auto
double Wt::WLength::toPixels ( double  fontSize = 16.0 ) const

Returns the (approximate) length in pixels.

When the length isAuto(), 0 is returned, otherwise the approximate length in pixels.

Unit Wt::WLength::unit (  ) const

Returns the unit.

See also:
value()
double Wt::WLength::value (  ) const

Returns the value.

See also:
unit()

Member Data Documentation

An 'auto' length.

See also:
WLength()
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator

Generated on Fri Jul 8 2011 for the C++ Web Toolkit (Wt) by doxygen 1.7.2