Wt: Wt::WVirtualImage Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Attributes | Protected Member Functions
Wt::WVirtualImage Class Reference

An abstract widget that shows a viewport to a virtually large image. More...

`#include <Wt/WVirtualImage>`

Inheritance diagram for Wt::WVirtualImage:
[legend]

List of all members.

## Public Member Functions
| WVirtualImage (int viewPortWidth, int viewPortHeight,::int64_t imageWidth,::int64_t imageHeight, int gridImageSize=256, WContainerWidget *parent=0)
| Creates a viewport for a virtual image.
| ~WVirtualImage ()
| Destructor.
void | redrawAll ()
| Regenerates and redraws the image pieces.
void | enableDragging ()
| Enables mouse dragging to scroll around the image.
void | scroll (::int64_t dx,::int64_t dy)
| Scrolls the viewport of the image over a distance.
void | scrollTo (::int64_t x,::int64_t y)
| Scrolls the viewport of the image to a specific coordinate.
::int64_t | imageWidth () const
| Returns the virtual image width.
::int64_t | imageHeight () const
| Returns the virtual image height.
void | resizeImage (::int64_t w,::int64_t h)
| Resizes the virtual image.
int | viewPortWidth () const
| Returns the viewport width.
int | viewPortHeight () const
| Returns the viewport height.
int | gridImageSize () const
| Returns the size of a single piece.
::int64_t | currentTopLeftX () const
| Returns the current top left X coordinate.
::int64_t | currentTopLeftY () const
| Returns the current top left Y coordinate.
::int64_t | currentBottomRightX () const
| Returns the current bottom right X coordinate.
::int64_t | currentBottomRightY () const
| Returns the current bottom right Y coordinate.
Signal< ::int64_t,::int64_t > & | viewPortChanged ()
| Signal emitted whenever the viewport changes.
## Static Public Attributes
static const ::int64_t | Infinite = std::numeric_limits< ::int64_t >::max()
| Special value for imageWidth or imageHeight.
## Protected Member Functions
virtual WImage * | createImage (::int64_t x,::int64_t y, int width, int height)
| Creates a grid image for the given rectangle.
virtual WResource * | render (::int64_t x,::int64_t y, int width, int height)
| Render a grid image for the given rectangle.

## Detailed Description

An abstract widget that shows a viewport to a virtually large image.

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.

### CSS

Styling through CSS is not applicable.

## Constructor & Destructor Documentation

Wt::WVirtualImage::WVirtualImage | ( | int | viewPortWidth,
|  | int | viewPortHeight,
|  | ::int64_t | imageWidth,
|  | ::int64_t | imageHeight,
|  | int | gridImageSize = `256`,
|  | WContainerWidget * | parent = `0`
| ) |  |

Creates 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 the maximum integer value).

In addition, you must specify the size of each square grid item. The default is 256 by 256.

## Member Function Documentation

WImage * Wt::WVirtualImage::createImage | ( | ::int64_t | x,
|  | ::int64_t | y,
|  | int | width,
|  | int | height
| ) |  | `[protected, virtual]`

Creates 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.

See also:
  render()

::int64_t Wt::WVirtualImage::currentBottomRightX | ( |  | ) | const

Returns the current bottom right X coordinate.

See also:
  currentBottomRightY()

::int64_t Wt::WVirtualImage::currentBottomRightY | ( |  | ) | const

Returns the current bottom right Y coordinate.

See also:
  currentBottomRightX()

::int64_t Wt::WVirtualImage::currentTopLeftX | ( |  | ) | const

Returns the current top left X coordinate.

See also:
  currentTopLeftY()

::int64_t Wt::WVirtualImage::currentTopLeftY | ( |  | ) | const

Returns the current top left Y coordinate.

See also:
  currentTopLeftX()

void Wt::WVirtualImage::enableDragging | ( |  | ) |

Enables mouse dragging to scroll around the image.

The cursor is changed to a 'move' symbol to indicate the interactivity.

int Wt::WVirtualImage::gridImageSize | ( |  | ) | const

Returns the size of a single piece.

This is the size of a side of the square pieces that is used to render the visible part of the image.

::int64_t Wt::WVirtualImage::imageHeight | ( |  | ) | const

Returns the virtual image height.

See also:
  imageWidth(), resizeImage()

::int64_t Wt::WVirtualImage::imageWidth | ( |  | ) | const

Returns the virtual image width.

See also:
  imageHeight(), resizeImage()

void Wt::WVirtualImage::redrawAll | ( |  | ) |

Regenerates and redraws the image pieces.

This method invalidates all current grid images, and recreates them.

WResource * Wt::WVirtualImage::render | ( | ::int64_t | x,
|  | ::int64_t | y,
|  | int | width,
|  | int | height
| ) |  | `[protected, 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 to gridImageSize(), if the the image is not infinite sized.

The default implementation throws an Exception. You must reimplement this method unless you reimplement createImage().

See also:
  createImage()

void Wt::WVirtualImage::resizeImage | ( | ::int64_t | w,
|  | ::int64_t | h
| ) |  |

Resizes the virtual image.

This sets a new virtual size for the image. The viewport size sets the visible portion of the image.

See also:
  imageWidth(), imageHeight()

void Wt::WVirtualImage::scroll | ( | ::int64_t | dx,
|  | ::int64_t | dy
| ) |  |

Scrolls the viewport of the image over a distance.

See also:
  scrollTo()

void Wt::WVirtualImage::scrollTo | ( | ::int64_t | x,
|  | ::int64_t | y
| ) |  |

Scrolls the viewport of the image to a specific coordinate.

Scroll the viewport so that its top left coordinate becomes (x, y).

See also:
  scroll()

Signal< ::int64_t, ::int64_t >& Wt::WVirtualImage::viewPortChanged | ( |  | ) |

Signal emitted whenever the viewport changes.

The viewport can be changed by the user dragging the image or through the API methods scrollTo() and scroll().

int Wt::WVirtualImage::viewPortHeight | ( |  | ) | const

Returns the viewport height.

See also:
  viewPortWidth()

int Wt::WVirtualImage::viewPortWidth | ( |  | ) | const

Returns the viewport width.

See also:
  viewPortHeight()

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator