/usr/include/Wt/WPaintDevice is in libwt-dev 3.3.6+dfsg-1.1.
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 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | // 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 WPAINTDEVICE_H_
#define WPAINTDEVICE_H_
#include <Wt/WLength>
#include <Wt/WString>
#include <Wt/WGlobal>
namespace Wt {
class WFontMetrics;
class WPainter;
class WPainterPath;
class WRectF;
/*! \class WTextItem Wt/WPaintDevice Wt/WPaintDevice
* \brief The result of a font metrics computation.
*
* \sa WPaintDevice::measureText()
*/
class WT_API WTextItem
{
public:
/*! \brief Constructor.
*/
WTextItem(const WString& text, double width, double nextWidth = -1);
/*! \brief Returns the measured text.
*
* If the item was measured with word breaking enabled, then the text may
* contain trailing whitespace that is not included in the width().
*/
WString text() const { return text_; }
/*! \brief Returns the measured width.
*
* Returns the text width, in device local coordinates (pixels).
*/
double width() const { return width_; }
/*! \brief Returns the width for a next line-break boundary.
*
* Returns the width until the next line-break boundary, or -1 if the
* underlying word boundary analysis does not support this.
*/
double nextWidth() const { return nextWidth_; }
private:
WString text_;
double width_, nextWidth_;
};
/*! \class WPaintDevice Wt/WPaintDevice Wt/WPaintDevice
* \brief The abstract base class for a paint device
*
* A %WPaintDevice is a device on which may be painted using a
* WPainter. You should never paint directly on a paint device.
*
* The device defines the size of the drawing area, using width() and
* height(). These dimensions must be defined in pixel units. In the
* future, additional information will be included to convert these pixel
* units to lengths (using DPI information).
*
* You should reimplement this class if you wish to extend the %Wt
* paint system to paint on other devices than the ones provided by
* the library.
*
* <i>Note: this interface is subject to changes to increase
* optimization possibilities for the painting using different
* devices.</i>
*
* \sa WPainter
*
* \ingroup painting
*/
class WT_API WPaintDevice
{
public:
/*! \brief Enumeration to communicate painter state changes.
*
* \sa setChanged(WFlags<ChangeFlag>)
*/
enum ChangeFlag {
Pen = 0x1, //!< Properties of the pen have changed
Brush = 0x2, //!< Properties of the brush have changed
Font = 0x4, //!< Properties of the font have changed
Hints = 0x8, //!< Some render hints have changed
Transform = 0x10, //!< The transformation has changed
Clipping = 0x20, //!< The clipping has changed
Shadow = 0x40 //!< Properties of the shadow have changed
};
/*! \brief Enumeration to indicate paint device features.
*
* \sa features()
*/
enum FeatureFlag {
CanWordWrap = 0x1, //!< Implements drawText() with Wt::TextWordWrap
HasFontMetrics = 0x2 //!< Implements fontMetrics() and measureText()
};
/*! \brief Destructor.
*
* Frees all resources associated with this device.
*/
virtual ~WPaintDevice();
/*! \brief Returns device features.
*/
virtual WFlags<FeatureFlag> features() const = 0;
/*! \brief Returns the device width.
*
* The device width, in pixels, establishes the width of the device
* coordinate system.
*/
virtual WLength width() const = 0;
/*! \brief Returns the device height.
*
* The device height, in pixels, establishes the height of the device
* coordinate system.
*/
virtual WLength height() const = 0;
/*! \brief Indicates changes in painter state.
*
* The \p flags argument is the logical OR of one or more change flags.
*
* \sa ChangeFlag
*/
virtual void setChanged(WFlags<ChangeFlag> flags) = 0;
/*! \brief Draws an arc.
*
* The arc describes the segment of an ellipse enclosed by the
* rect. The segment starts at \p startAngle, and spans an angle
* given by \p spanAngle. These angles have as unit degree, and are
* measured counter-clockwise starting from the 3 o'clock position.
*
* The arc must be stroked, filled, and transformed using the
* current painter settings.
*/
virtual void drawArc(const WRectF& rect, double startAngle, double spanAngle)
= 0;
/*! \brief Draws an image.
*
* Draws <i>sourceRect</i> from the image with URL \p imageUri
* and original dimensions <i>imgWidth</i> and \p imgHeight to
* the location, into the rectangle defined by \p rect.
*
* The image is transformed using the current painter settings.
*/
virtual void drawImage(const WRectF& rect, const std::string& imageUri,
int imgWidth, int imgHeight,
const WRectF& sourceRect) = 0;
/*! \brief Draws a line.
*
* The line must be stroked and transformed using the current
* painter settings.
*/
virtual void drawLine(double x1, double y1, double x2, double y2) = 0;
/*! \brief Draws a path.
*
* The path must be stroked, filled, and transformed using the
* current painter settings.
*/
virtual void drawPath(const WPainterPath& path) = 0;
/*! \brief Draws text.
*
* The text must be rendered, stroked and transformed using the
* current painter settings.
*
* If clipPoint is not null, a check is performed whether
* the point is inside of the current clip area. If not,
* the text is not drawn.
*/
virtual void drawText(const WRectF& rect,
WFlags<AlignmentFlag> alignmentFlags,
TextFlag textFlag,
const WString& text,
const WPointF* clipPoint) = 0;
/*! \brief Measures rendered text size.
*
* Returns the bounding rect of the given text when rendered using the
* current font.
*
* If \p maxWidth != -1, then the text is truncated to fit in the
* width.
*
* If \p wordWrap = \c true then text is truncated only at word
* boundaries. Note that in this case the whitespace at the
* truncated position is included in the text but not accounted for
* by the returned width (since usually you will not render the
* whitespace at the end of a line).
*
* Throws a std::logic_error if the underlying device does not
* provide font metrics.
*/
virtual WTextItem measureText(const WString& text, double maxWidth = -1,
bool wordWrap = false) = 0;
/*! \brief Returns font metrics.
*
* This returns font metrics for the current font.
*
* Throws a std::logic_error if the underlying device does not
* provide font metrics.
*/
virtual WFontMetrics fontMetrics() = 0;
/*! \brief Initializes the device for painting.
*
* This method is called when a WPainter starts painting.
*
* \sa WPainter::begin(WPaintDevice *), painter()
*/
virtual void init() = 0;
/*! \brief Finishes painting on the device.
*
* This method is called when a WPainter stopped painting.
*
* \sa WPainter::end()
*/
virtual void done() = 0;
/*! \brief Returns whether painting is active.
*
* \sa init(), painter()
*/
virtual bool paintActive() const = 0;
protected:
/*! \brief Returns the painter that is currently painting on the device.
*
* \sa init()
*/
virtual WPainter *painter() const = 0;
/*! \brief Sets the painter.
*/
virtual void setPainter(WPainter *painter) = 0;
friend class WPainter;
friend class WPaintedWidget;
friend class WMeasurePaintDevice;
};
W_DECLARE_OPERATORS_FOR_FLAGS(WPaintDevice::ChangeFlag)
W_DECLARE_OPERATORS_FOR_FLAGS(WPaintDevice::FeatureFlag)
}
#endif // WPAINTDEVICE_H_
|