Class TQRbwZoomBox2

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TQRbwZoomBox2 = class(TPanel)

Description

TQRbwZoomBox2 is used as an interface for handling drawing with real number coordinates.

The functions X, XCoord, Y, and YCoord can be used to convert between real-world and screen coordinates. By default, the real-world coordinates increase to the left and upward but these directions can be reversed with HorizontalDirection and VerticalDirection.

Zooming operations are performed with BeginZoom and FinishZoom

Panning can be turned on and off with Panning.

Drawing should be done on the subcomponent.

Hierarchy

Overview

Fields

Private FEndX: Integer;
Private FEndY: Integer;
Private FExaggeration: real;
Private FExaggerationDirection: TExaggerationDirection;
Private FHorizontalDirection: THorizontalDirection;
Private FImage32: TzbImage32;
Private FImmediateResize: boolean;
Private FMagnification: real;
Private FOnPan: TPanEvent;
Private FOriginX: real;
Private FOriginY: real;
Private FPanning: boolean;
Private FPositionedLayer: TPositionedLayer;
Private FStartX: Integer;
Private FStartY: Integer;
Private FStartXPosition: integer;
Private FStartYPosition: integer;
Private FStopXPosition: integer;
Private FStopYPosition: integer;
Private FVerticalDirection: TVerticalDirection;
Private FZooming: boolean;
Private FOnMagnificationChanged: TNotifyEvent;

Methods

Private function GetCanZoomIn: boolean;
Private function GetCanZoomOut: boolean;
Private procedure PaintLayer(Sender: TObject; Buffer: TBitmap32);
Private procedure PanMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
Private procedure PanUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
Private procedure SetExaggeration(const Value: real);
Private procedure SetExaggerationDirection(const Value: TExaggerationDirection);
Private procedure SetHorizontalDirection(const Value: THorizontalDirection);
Private procedure SetImmediateResize(const Value: boolean);
Private procedure SetMagnification(Value: real);
Private procedure SetOriginX(const Value: real);
Private procedure SetOriginY(const Value: real);
Private procedure SetPanning(const Value: boolean);
Private procedure SetVerticalDirection(const Value: TVerticalDirection);
Private procedure ZoomBoxHitTest(Sender: TObject; X, Y: Integer; var Passed: Boolean);
Protected procedure ContinueZoom(X, Y: Integer);
Protected procedure FinishZoom(X, Y: Integer);
Protected procedure InitWidget;
Protected procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
Protected procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
Protected procedure Pan; virtual;
Protected procedure Resize; override;
Public procedure AbortZoom;
Public procedure BeginZoom(X, Y: Integer);
Public constructor Create(AOwner: TComponent); override;
Public procedure InvalidateImage32;
Public function X(XCoord: integer): extended;
Public function XCoord(X: extended): integer;
Public function Y(YCoord: integer): extended;
Public function YCoord(Y: extended): integer;
Public procedure ZoomBy(Factor: extended);
Public procedure ZoomByAt(Factor: extended; CenterX, CenterY: integer);

Properties

Public property CanZoomIn: boolean read GetCanZoomIn;
Public property CanZoomOut: boolean read GetCanZoomOut;
Public property Panning: boolean read FPanning write SetPanning;
Published property Exaggeration: real read FExaggeration write SetExaggeration;
Published property ExaggerationDirection: TExaggerationDirection read FExaggerationDirection write SetExaggerationDirection default edVertical;
Published property HorizontalDirection: THorizontalDirection read FHorizontalDirection write SetHorizontalDirection;
Published property Image32: TzbImage32 read FImage32;
Published property ImmediateResize: boolean read FImmediateResize write SetImmediateResize;
Published property Magnification: real read FMagnification write SetMagnification;
Published property OriginX: real read FOriginX write SetOriginX;
Published property OriginY: real read FOriginY write SetOriginY;
Published property VerticalDirection: TVerticalDirection read FVerticalDirection write SetVerticalDirection;
Published property OnPan: TPanEvent read FOnPan write FOnPan;
Published property OnMagnificationChanged: TNotifyEvent read FOnMagnificationChanged write FOnMagnificationChanged;

Description

Fields

Private FEndX: Integer;

FEndX is set to the mouse X coordinate in BeginZoom, ContinueZoom, and FinishZoom. See FStartX.

Private FEndY: Integer;

FEndY is set to the mouse Y coordinate in BeginZoom, ContinueZoom, and FinishZoom. See FStartY.

Private FExaggeration: real;

See Exaggeration.

Private FExaggerationDirection: TExaggerationDirection;

See ExaggerationDirection.

Private FHorizontalDirection: THorizontalDirection;

See HorizontalDirection.

Private FImage32: TzbImage32;

FImage32 is used for the actual drawing in TQRbwZoomBox2

Private FImmediateResize: boolean;

See ImmediateResize.

Private FMagnification: real;

See Magnification.

Private FOnPan: TPanEvent;

See OnPan.

Private FOriginX: real;

See OriginX.

Private FOriginY: real;

See OriginY.

Private FPanning: boolean;

See Panning.

Private FPositionedLayer: TPositionedLayer;

FPositionedLayer is used for drawing the zoom window during zooming operations.

Private FStartX: Integer;

FStartX is set to the mouse X coordinate in BeginZoom. See FEndX.

Private FStartY: Integer;

FStartY is set to the mouse Y coordinate in BeginZoom. See FEndY.

Private FStartXPosition: integer;

FStartXPosition is set to the mouse X coordinate in SetPanning.

Private FStartYPosition: integer;

FStartYPosition is set to the mouse Y coordinate in SetPanning.

Private FStopXPosition: integer;

FStopXPosition is set to the mouse X coordinate in Pan.

Private FStopYPosition: integer;

FStopYPosition is set to the mouse Y coordinate in Pan.

Private FVerticalDirection: TVerticalDirection;

See VerticalDirection.

Private FZooming: boolean;

FZooming is True when a zooming operation is underway.

Private FOnMagnificationChanged: TNotifyEvent;
 

Methods

Private function GetCanZoomIn: boolean;

GetCanZoomIn returns true if Magnification is less than the maximum magnification.

Private function GetCanZoomOut: boolean;

GetCanZoomOut returns true if Magnification is greater than the minimum magnification.

Private procedure PaintLayer(Sender: TObject; Buffer: TBitmap32);

PaintLayer is responsible for painting the zoom window during zooming.

Private procedure PanMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

PanMove is the event handler for OnZbMove. If FZooming is True, FEndX and FEndY are updated and Image32 is redrawn.

Private procedure PanUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);

PanUp is the event handler for OnZbUp. If FZooming is True, the zooming operation is either aborted or finished. See AbortZoom and FinishZoom. It is aborted if the mouse is not over the TQRbwZoomBox2.

Private procedure SetExaggeration(const Value: real);

See Exaggeration.

Private procedure SetExaggerationDirection(const Value: TExaggerationDirection);

See ExaggerationDirection.

Private procedure SetHorizontalDirection(const Value: THorizontalDirection);

See HorizontalDirection.

Private procedure SetImmediateResize(const Value: boolean);

See ImmediateResize.

Private procedure SetMagnification(Value: real);

See Magnification.

Private procedure SetOriginX(const Value: real);

See OriginX.

Private procedure SetOriginY(const Value: real);

See OriginY.

Private procedure SetPanning(const Value: boolean);

See Panning.

Private procedure SetVerticalDirection(const Value: TVerticalDirection);

See VerticalDirection.

Private procedure ZoomBoxHitTest(Sender: TObject; X, Y: Integer; var Passed: Boolean);

ZoomBoxHitTest changes Passed to True so that a mouse down event in FPositionedLayer will always succeed.

Protected procedure ContinueZoom(X, Y: Integer);

If BeginZoom has been called, and neither AbortZoom nor FinishZoom have yet been called, ContinueZoom will invalidate Image32 so that the zoome window will be drawn. One of the corners of the shape will be at the location where the zoom began. The other will be at X, and Y. X and Y are screen coordinates in the Image32 in the TQRbwZoomBox2. You can get X and Y in OnMouseMove. ContinueZoom is called in the private method PanMove.

Protected procedure FinishZoom(X, Y: Integer);

FinishZoom terminates a zoom operation. X, and Y are the X and Y screen coordinates of the Image32 in the TQRbwZoomBox2. You can get X and Y in OnMouseUp. FinishZoom sets the zoom level so that the area outlined by the X, and Y parameters in BeginZoom and the X, and Y parameters in FinishZoom is displayed in the TQRbwZoomBox2.

Protected procedure InitWidget;

InitWidget sets the Parent, Align, and Anchors properties of Image32. It also assigns event handlers for OnZbMove and OnZbUp.

Protected procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;

MouseMove calls the inherited MouseMove and then calls Pan.

Protected procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;

MouseUp calls the inherited MouseUp and then calls Pan.

Protected procedure Pan; virtual;

If Panning is true, FStopXPosition and FStopYPosition are moved to follow the mouse. Then OnPan is called.

Protected procedure Resize; override;

If ImmediateResize is True, Resize causes Image32 to be resized to fit ClientWidth and ClientHeight.

Public procedure AbortZoom;

If for some reason you want to terminate a zoom operation without doing the zoom, call AbortZoom instead of FinishZoom. AbortZoom is called from PanUp.

Public procedure BeginZoom(X, Y: Integer);

BeginZoom starts a zooming operation. X, and Y are the X and Y screen coordinates of the Image32 in the TQRbwZoomBox2. You can get those in OnMouseDown.

Public constructor Create(AOwner: TComponent); override;

Create creates an instance of TQRbwZoomBox2.

Public procedure InvalidateImage32;

InvalidateImage32 checks that Image32 can be drawn and, if so, calls Invalidate for it.

Public function X(XCoord: integer): extended;

X converts a screen coordinate into a real-number X coordinate.

Public function XCoord(X: extended): integer;

XCoord converts a real-number X coordinate into a screen coordinate.

Public function Y(YCoord: integer): extended;

Y converts a screen coordinate into a real-number Y coordinate.

Public function YCoord(Y: extended): integer;

YCoord converts a real-number Y coordinate into a screen coordinate.

Public procedure ZoomBy(Factor: extended);

ZoomBy increase the magnification by Factor by calling ZoomByAt and using the center of the TQRbwZoomBox2 as (CenterX, CenterY).

Public procedure ZoomByAt(Factor: extended; CenterX, CenterY: integer);

ZoomByAt changes the magnification by Factor and then adjusts OriginX and OriginY so that the point represented by the screen coordinates (CenterX, CenterY) will still have screen coordinates (CenterX, CenterY). For example, suppose there is a point with real-world coordinates of (1,1) and screen coordinates of (100,100). If the OnMouseUp event was used to call ZoomByAt with (CenterX,CenterY) = (100, 100), the point will still have screen coordinates of (100, 100) after applying ZoomByAt.

Properties

Public property CanZoomIn: boolean read GetCanZoomIn;

Read CanZoomIn to determine whether it is possible to zoom in.

Public property CanZoomOut: boolean read GetCanZoomOut;

Read CanZoomOut to determine whether it is possible to zoom out.

Public property Panning: boolean read FPanning write SetPanning;

Set Panning to True to start a panning operation. Set Panning to False to stop a panning operation. See Pan for what happens during a panning operation.

Published property Exaggeration: real read FExaggeration write SetExaggeration;

Exaggeration is used to allow either vertical or horizontal exaggeration. Exaggeration affects how screen coordinates map to real-world coordinates. See ExaggerationDirection.

Published property ExaggerationDirection: TExaggerationDirection read FExaggerationDirection write SetExaggerationDirection default edVertical;

ExaggerationDirection controls the direction in which Exaggeration is applied.

Published property HorizontalDirection: THorizontalDirection read FHorizontalDirection write SetHorizontalDirection;

HorizontalDirection indicates the direction in which the X-coordinates increase. hdRight indicates they increase towards the right, hdLeft indicates they increase towards the left.

Published property Image32: TzbImage32 read FImage32;

Image32 is used for the actual drawing in TQRbwZoomBox2

Published property ImmediateResize: boolean read FImmediateResize write SetImmediateResize;

See Resize.

Published property Magnification: real read FMagnification write SetMagnification;

Magnification is the ratio of distances in screen coordinates to corresponding distances in real-world coordinates. Usually Magnification is not set directly. See BeginZoom, FinishZoom, ZoomBy and ZoomByAt.

Published property OriginX: real read FOriginX write SetOriginX;

OriginX is the screen X-coordinate that corresponds to a real-world X-coordinate of zero.

Published property OriginY: real read FOriginY write SetOriginY;

OriginY is the screen Y-coordinate that corresponds to a real-world Y-coordinate of zero.

Published property VerticalDirection: TVerticalDirection read FVerticalDirection write SetVerticalDirection;

VerticalDirection indicates the direction in which the Y-coordinates increase. vdDown indicates they increase downward, vdUp indicates they increase upward.

Published property OnPan: TPanEvent read FOnPan write FOnPan;

OnPan is called during panning operations to indicate the amount of panning. See Pan.

Published property OnMagnificationChanged: TNotifyEvent read FOnMagnificationChanged write FOnMagnificationChanged;
 

Generated by PasDoc 0.12.1 on 2013-05-13 15:42:07