ZoomControls: Zoom widget for images

Version Information
Version: 0.5, updated: 2003-05-19
Developed with Delphi5, ready for use in a package
Download source code plus demo application.
Content
TZoomWidget: Zoom an image. Supports mouse gestures.
Licence
ZoomControls.pas is freeware that comes without any warranty or support. Thus you use it at your own risk. You may even use it in commercial products as long as you mention me as original author somewhere. If you make modifications to the source code, you must maintain the original copyright notice and publish it under the same licence. For the exact conditions, see LICENCE.txt that is contained in the download package.
I am looking forward to feedback via eMail.

zoomcontrolsZoomControls.pas contains only one class: TZoomWidget It is a component that can be used to zoom images that are drawn into a small viewport.

  • Zooms a given image that fits into a viewport (not necessarily, but this makes the most sense)
  • specify zoom factor and the dimensions of the zoom window
  • SlowMove: If the viewport is much smaller than the image, moving by one pixel on screen might move several pixels in the image. You can adjust this with the SlowMove property
  • React to mouse gestures
  • Prepared for being compiled into a package (and appear in the object inspector)

A word about mouse gestures

A mouse gesture is an ingenious feature that appeared in some games and became popular through the Opera webbrowser. It is just a right click with your mouse followed by a movement (4 directions are supported: up, down, left, right). After performing the movement, you release the mouse button again. All these steps must be performed within the client area of your image.

Currently, I don’t actually use the mouse gestures but you can: there’s an event called OnGesture. What I do support: When the zoom widget is visible (left click into the image and hold the mouse button), and you press the right mouse button (and hold it), you can move up/down to change the zoom level or move right to reset the zoom level to 1.
Simply rightclicking while the widget is visible resizes it. Of course, all these properties can be set manually.

The demo application handles one gesture: left-down: It toggles SlowMove. All gestures that you perform are displayed in the form caption. So just try it. Deactivating the zoom widget is simple: Just set the image property to nil.

I want to thank the people in the newsgroup de.comp.lang.delphi.misc for their constructive help! Solving some issues would have taken an eternity without them.