/usr/include/Wt/WGradient is in libwt-dev 3.3.4+dfsg-6ubuntu1.
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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2013 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WGRADIENT_H_
#define WGRADIENT_H_
#include <Wt/WColor>
#include <Wt/WLineF>
#include <Wt/WPointF>
namespace Wt {
/*! \class WGradient Wt/WGradient Wt/WGradient
* \brief A linear or radial gradient.
*
* \sa WPen::setGradient(), WBrush::setGradient()
*
* \ingroup painting
*/
class WT_API WGradient
{
public:
/*! \brief A gradient color stop.
*
* A color stop is defined by a color and a (relative) position. The
* interpretation of the position depends on the gradient style.
*
* \sa addColorStop()
*/
class ColorStop {
public:
/*! \brief Constructor.
*/
ColorStop(double position, const WColor& color)
: position_(position), color_(color)
{ }
/*! \brief Returns the position.
*/
double position() const { return position_; }
/*! \brief Returns the color.
*/
const WColor& color() const { return color_; }
/*! \brief Comparison operator.
*/
bool operator==(const ColorStop& other) const {
return (position_ == other.position_) && (color_ == other.color_);
}
/*! \brief Comparison operator.
*/
bool operator!=(const ColorStop& other) const {
return !(*this == other);
}
private:
double position_;
WColor color_;
};
/*! \brief Default constructor.
*
* Creates an empty linear gradient from (0,0) to (1,1) (without
* color stops).
*
* \sa isEmpty()
*/
WGradient();
/*! \brief Returns the gradient style.
*
* \sa setLinearGradient(), setRadialGradient()
*/
GradientStyle style() const { return style_; }
/*! \brief Returns whether the gradient is empty.
*
* A gradient is empty if no color stops are defined.
*/
bool isEmpty() const { return colorstops_.empty(); }
/*! \brief Configures a linear gradient.
*
* The coordinates describe a line which provides an origin and
* orientation of the gradient in user-space coordinates.
*/
void setLinearGradient(double x0, double y0, double x1, double y1);
/*! \brief Configures a radial gradient.
*
* A radial gradient is described by a center, a radial and a focus
* point. All coordinates are user-space coordinates.
*/
void setRadialGradient(double cx, double cy, double r,
double fx, double fy);
/*! \brief Adds a color stop.
*
* For a linear gradient, the position is relative to the position on the
* line (from 0 to 1 corresponding to p0 to p1).
*
* For a radial gradient, the position indicates the distance from the
* center (from 0 to 1 corresponding to center to radius).
*/
void addColorStop(double position, const WColor& color);
/*! \brief Adds a color stop.
*
* Adds a color stop.
*/
void addColorStop(const ColorStop& colorstop);
/*! \brief Removes all color stops.
*
* \sa addColorStop()
*/
void clearColorStops() { colorstops_.clear(); }
/*! \brief Returns the color stops.
*
* \sa addColorStop()
*/
const std::vector<ColorStop>& colorstops() const { return colorstops_; }
/*! \brief Returns the line positioning the linear gradient.
*
* This returns the line set in setLinearGradient().
*/
const WLineF& linearGradientVector() const { return gradientVector_; }
/*! \brief Returns the center of a radial gradient.
*
* This returns the center point set in setRadialGradient().
*/
const WPointF& radialCenterPoint() const { return center_; }
/*! \brief Returns the focal point of a radial gradient.
*
* This returns the focal point set in setRadialGradient().
*/
const WPointF& radialFocalPoint() const { return focal_; }
/*! \brief Returns the radius of a radial gradient.
*
* This returns the radius set in setRadialGradient().
*/
double radialRadius() const { return radius_; }
/*! \brief Comparison operator.
*/
bool operator==(const WGradient& other) const;
/*! \brief Comparison operator.
*/
bool operator!=(const WGradient& other) const;
private:
GradientStyle style_;
std::vector<ColorStop> colorstops_;
// linear gradient parameters
WLineF gradientVector_;
// radial gradient parameters
WPointF center_, focal_;
double radius_;
};
}
#endif
|