/usr/include/Wt/WLength is in libwt-dev 3.3.0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WLENGTH_H_
#define WLENGTH_H_
#include <string>
#include <Wt/WDllDefs.h>
namespace Wt {
/*! \class WLength Wt/WLength Wt/WLength
* \brief A value class that describes a CSS length.
*
* The class combines a value with a unit. There is a special value
* <i>auto</i> which has a different meaning depending on the context.
*/
class WT_API WLength
{
public:
/*! \brief The unit
*/
enum Unit { 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)
};
/*! \brief An 'auto' length.
*
* \sa WLength()
*/
static WLength Auto;
/*! \brief Creates an 'auto' length
*
* Specifies an 'auto' length.
*
* \sa Auto
*/
WLength();
/*! \brief Creates a length by parsing the argument as a css length string.
*
* This supports all CSS length formats that have an API counterpart.
*/
WLength(const char* c);
/*! \brief 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.
*/
WLength(double value, Unit unit = Pixel);
/*! \brief Creates a length with value and unit.
*
* This constructor is also used for the implicit conversion of a
* int to a WLength, assuming a pixel unit.
*/
WLength(int value, Unit unit = Pixel);
/*! \brief Creates a length with value and unit.
*
* This constructor is also used for the implicit conversion of a
* long to a WLength, assuming a pixel unit.
*/
WLength(long value, Unit unit = Pixel);
/*! \brief Creates a length with value and unit.
*
* This constructor is also used for the implicit conversion of an
* unsigned to a WLength, assuming a pixel unit.
*/
WLength(unsigned value, Unit unit = Pixel);
/*! \brief Creates a length with value and unit.
*
* This constructor is also used for the implicit conversion of an
* unsigned long to a WLength, assuming a pixel unit.
*/
WLength(unsigned long value, Unit unit = Pixel);
/*! \brief Returns whether the length is 'auto'.
*
* \sa WLength(), Auto
*/
bool isAuto() const { return auto_; }
/*! \brief Returns the value.
*
* \sa unit()
*/
double value() const { return value_; }
/*! \brief Returns the unit.
*
* \sa value()
*/
Unit unit() const { return unit_; }
/*! \brief Returns the CSS text.
*/
const std::string cssText() const;
/*! \brief Comparison operator.
*/
bool operator== (const WLength& other) const;
/*! \brief Comparison operator.
*/
bool operator!= (const WLength& other) const;
/*! \brief Returns the (approximate) length in pixels.
*
* When the length isAuto(), 0 is returned, otherwise the approximate
* length in pixels.
*/
double toPixels(double fontSize = 16.0) const;
private:
bool auto_;
Unit unit_;
double value_;
void setUnit(Unit unit);
};
inline Wt::WLength operator*(const Wt::WLength &l, double s)
{
return Wt::WLength(l.value() * s, l.unit());
}
inline Wt::WLength operator*(double s, const Wt::WLength &l)
{
return l * s;
}
inline Wt::WLength operator/(const Wt::WLength &l, double s)
{
return l * (1/s);
}
}
#endif // WLENGTH_H_
|