#include <Wt/WVirtualImage>
Public Member Functions | |
WVirtualImage (int viewPortWidth, int viewPortHeight, long long imageWidth, long long imageHeight, int gridImageSize=256, WContainerWidget *parent=0) | |
Construct a viewport for a virtual image. | |
~WVirtualImage () | |
Destructor. | |
void | redrawAll () |
Regenerate and redraw the image pieces. | |
void | enableDragging () |
Enable mouse dragging to scroll around the image. | |
void | scroll (long long dx, long long dy) |
Scroll the viewport of the image over a distance. | |
void | scrollTo (long long x, long long y) |
Scroll the viewport of the image to a specific coordinate. | |
long long | imageWidth () const |
Return the virtual image width. | |
long long | imageHeight () const |
Return the virtual image height. | |
void | resizeImage (long long w, long long h) |
Resize the virtual image. | |
int | viewPortWidth () const |
Return the viewport width. | |
int | viewPortHeight () const |
Return the viewport height. | |
int | gridImageSize () const |
Returns the pieceSize. | |
long long | currentTopLeftX () const |
Returns the current top left X coordinate. | |
long long | currentTopLeftY () const |
Returns the current top left Y coordinate. | |
long long | currentBottomRightX () const |
Returns the current bottom right X coordinate. | |
long long | currentBottomRightY () const |
Returns the current bottom right Y coordinate. | |
Public Attributes | |
Signal< long long, long long > | viewPortChanged |
Signal emitted whenever the viewport changes. | |
Static Public Attributes | |
static const long long | Infinite = std::numeric_limits<long long>::max() |
Special value for imageWidth or imageHeight. | |
Private Member Functions | |
virtual WImage * | createImage (long long x, long long y, int width, int height) |
Create a grid image for the given rectangle. | |
virtual WResource * | render (long long x, long long y, int width, int height) |
Render a grid image for the given rectangle. |
WVirtualImage is an abstract class which renders a large image in small pieces. The large image is broken down, and rendered as a grid of smaller square images parts.
The WVirtualImage may provide interactive navigation using the mouse, by reacting to dragging of the mouse on the image.
The WVirtualImage renders pieces in and bordering the current viewport. In this way, provided the individual pieces load sufficiently fast, the user has effectively the impression of scrolling through a single large image, without glitches. Whenever the image is navigated, if necessary, new images are rendered to maintain the border. Images that are too far from the current viewport are pruned away, so that browser memory remains bounded.
To use this class, you must reimplement one of two virtual methods to specify the contents of each grid piece. Either you provide a suitable WImage for every grid piece, or you provide a WResource which renders the contents for a WImage for every grid piece.
The total image dimensions are (0, 0) to (imageWidth, imageHeight) for a finite image, and become unbounded (including negative numbers) for each dimension which is Infinite.
Wt::WVirtualImage::WVirtualImage | ( | int | viewPortWidth, | |
int | viewPortHeight, | |||
long long | imageWidth, | |||
long long | imageHeight, | |||
int | gridImageSize = 256 , |
|||
WContainerWidget * | parent = 0 | |||
) |
Construct a viewport for a virtual image.
You must specify the size of the viewport, and the size of the virtual image. The latter dimensions may be the special value Infinite, indicating that in one or more dimensions, the image size is infinite (in practice limited by MAXINT).
In addition, you must specify the size of each square grid item. The default is 256 by 256.
void Wt::WVirtualImage::redrawAll | ( | ) |
Regenerate and redraw the image pieces.
This method invalidates all current grid images, and recreates them.
void Wt::WVirtualImage::enableDragging | ( | ) |
Enable mouse dragging to scroll around the image.
The cursor is changed to a 'move' symbol to indicate the interactivity.
void Wt::WVirtualImage::scroll | ( | long long | dx, | |
long long | dy | |||
) |
Scroll the viewport of the image over a distance.
Scroll the viewport over the image over an indicated distance.
void Wt::WVirtualImage::scrollTo | ( | long long | x, | |
long long | y | |||
) |
Scroll the viewport of the image to a specific coordinate.
Scroll the viewport so that its top left coordinate becomes (x, y).
WImage * Wt::WVirtualImage::createImage | ( | long long | x, | |
long long | y, | |||
int | width, | |||
int | height | |||
) | [private, virtual] |
Create a grid image for the given rectangle.
Create the image which spans image coordinates with left upper corner (x, y) and given width and height.
Width and height will not necesarilly equal gridImageSize(), if the the image is not infinite sized.
The default implementation calls render() and creates an image for the resource returned.
You should override this method if you wish to serve for example static image content.
WResource * Wt::WVirtualImage::render | ( | long long | x, | |
long long | y, | |||
int | width, | |||
int | height | |||
) | [private, virtual] |
Render a grid image for the given rectangle.
Returns a resource that streams an image which renders the rectangle which spans image coordinates with left upper corner (x, y) and given width and height.
Width and height will not necesarilly equal gridImageSize(), if the the image is not infinite sized.
The default implementation throws an Exception. You must reimplement this method unless you reimplement createImage().