Wt  3.3.9
Public Types | Public Member Functions | Static Public Attributes | List of all members
Wt::WLength Class Reference

A value class that describes a CSS length. More...

#include <Wt/WLength>

Public Types

Public Member Functions

 WLength ()
 Creates an 'auto' length. More...
 
template<std::size_t N>
 WLength (const char(&str)[N])
 Creates a length by parsing the argument as a css length string. More...
 
 WLength (const std::string &str)
 Creates a length by parsing the argument as a css length string. More...
 
 WLength (double value, Unit unit=Pixel)
 Creates a length with value and unit. More...
 
bool isAuto () const
 Returns whether the length is 'auto'. More...
 
double value () const
 Returns the value. More...
 
Unit unit () const
 Returns the unit. More...
 
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. More...
 

Static Public Attributes

static WLength Auto
 An 'auto' length. More...
 

Detailed Description

A value class that describes 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 

Inch.

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
template<std::size_t N>
Wt::WLength::WLength ( const char(&)  str[N])

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

This supports all CSS length formats that have an API counterpart.

This is an overload for the std::string version that accepts a string literal.

Wt::WLength::WLength ( const std::string &  str)

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

This supports all CSS length formats that have an API counterpart.

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

Creates a length with value and unit.

This constructor is also used for the implicit conversion of a double to a WLength, assuming 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

WLength Wt::WLength::Auto
static

An 'auto' length.

See also
WLength()

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