/usr/include/Wt/WImage is in libwt-dev 3.1.10-1ubuntu2.
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 | // 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 WIMAGE_H_
#define WIMAGE_H_
#include <Wt/WInteractWidget>
namespace Wt {
namespace Impl {
class MapWidget;
}
class WAbstractArea;
/*! \class WImage Wt/WImage Wt/WImage
* \brief A widget that displays an image.
*
* The image may be specified either as a URL, or may be dynamically
* generated by a WResource.
*
* You may listen to events by attaching event listeners to signals
* such as clicked(). Since mouse events pass the coordinates through
* a WMouseEvent object, it is possible to react to clicks in specific
* parts of the image. An alternative is to define interactive areas
* on the image using addArea(), which in addition allows to have
* customized tool tips for certain image areas (using
* WAbstractArea::setToolTip()).
*
* \if cpp
* Usage example:
* \code
* Wt::WImage *img = new Wt::WImage("images/johnny_cash.png", this);
* img->setAlternateText("Johnny Cash sings a song");
* \endcode
* \endif
*
* %WImage is an \link WWidget::setInline(bool) inline \endlink widget.
*
* <h3>CSS</h3>
*
* The widget corresponds to the HTML <tt><img></tt> tag and
* does not provide styling. It can be styled using inline or external
* CSS as appropriate.
*
* \sa WResource, WPaintedWidget
*/
class WT_API WImage : public WInteractWidget
{
public:
/*! \brief Creates an empty image widget.
*/
WImage(WContainerWidget *parent = 0);
/*! \brief Creates an image widget with given image URL.
*/
WImage(const std::string& imageRef, WContainerWidget *parent = 0);
/*! \brief Creates an image widget with given image URL and alternate text.
*/
WImage(const std::string& imageRef, const WString& altText,
WContainerWidget *parent = 0);
/*! \brief Creates an image widget with given image resource and alternate
* text.
*
* Use this constructor if you want to present a dynamically generated
* image.
*/
WImage(WResource *resource, const WString& altText,
WContainerWidget *parent = 0);
~WImage();
/*! \brief Sets an alternate text.
*
* The alternate text should provide a fallback for browsers that do
* not display an image. If no sensible fallback text can be
* provided, an empty text is preferred over nonsense.
*
* This should not be confused with toolTip() text, which provides
* additional information that is displayed when the mouse hovers
* over the image.
*
* The default alternate text is an empty text ("").
*
* \sa alternateText()
*/
void setAlternateText(const WString& text);
/*! \brief Returns the alternate text.
*
* \sa setAlternateText()
*/
const WString& alternateText() const { return altText_; }
/*! \brief Sets the image URL.
*
* This should not be used when the image is specified as a resource.
*
* \sa setResource()
*/
void setImageRef(const std::string& url);
/*! \brief Returns the image URL.
*
* When the image is specified as a resource, this returns the current
* resource URL.
*/
const std::string imageRef() const;
/*! \brief Sets the image resource.
*
* A resource specifies application-dependent content, which may be
* used to generate an image on demand.
*
* This sets \p resource as the contents for the image, as an
* alternative to setImageRef(). The resource may be cleared by
* passing \p resource = \c 0.
*
* The image does not assume ownership of the resource.
*
* \sa setImageRef()
*/
void setResource(WResource *resource);
/*! \brief Returns the image resource.
*
* Returns \c 0 if no image resource was set.
*/
WResource *resource() const { return resource_; }
/*! \brief Adds an interactive area.
*
* Adds the \p area which listens to events in a specific region
* of the image. Areas are organized in an indexed list, to which
* the given \p area is appended. When areas overlap, the area
* with the lowest index receives the event.
*
* Ownership of the \p area is transferred to the image.
*
* \sa insertArea(int, WAbstractArea *)
*/
void addArea(WAbstractArea *area);
/*! \brief Inserts an interactive area.
*
* Inserts the \p area which listens to events in the
* coresponding area of the image. Areas are organized in a list,
* and the <i>area</i> is inserted at index \p index. When areas
* overlap, the area with the lowest index receives the event.
*
* Ownership of the \p area is transferred to the image.
*
* \sa addArea(WAbstractArea *)
*/
void insertArea(int index, WAbstractArea *area);
/*! \brief Removes an interactive area.
*
* Removes the \p area from this widget, and also returns the
* ownership.
*
* \sa addArea(WAbstractArea *)
*/
void removeArea(WAbstractArea *area);
/*! \brief Returns the interactive area at the given index.
*
* Returns \c 0 if \p index was invalid.
*
* \sa insertArea(int, WAbstractArea *)
*/
WAbstractArea *area(int index) const;
/*! \brief Returns the interactive areas set for this widget.
*
* \sa addArea()
*/
const std::vector<WAbstractArea *> areas() const;
/*! \brief Event emitted when the image was loaded.
*/
EventSignal<>& imageLoaded();
private:
static const char *LOAD_SIGNAL;
static const int BIT_ALT_TEXT_CHANGED = 0;
static const int BIT_IMAGE_REF_CHANGED = 1;
static const int BIT_MAP_CREATED = 2;
WString altText_;
std::string imageRef_;
WResource *resource_;
Impl::MapWidget *map_;
std::bitset<3> flags_;
void resourceChanged();
protected:
virtual void getDomChanges(std::vector<DomElement *>& result,
WApplication *app);
virtual void updateDom(DomElement& element, bool all);
virtual DomElementType domElementType() const;
virtual void propagateRenderOk(bool deep);
friend class WLabel;
static std::vector<WAbstractArea *> noAreas_;
};
}
#endif // WIMAGE_H_
|