📄 cdibanimcontainer.pas
字号:
unit cDIBAnimContainer;
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: cDIBWavList.PAS, released November 18, 2000.
The Initial Developer of the Original Code is Peter Morris (pete@droopyeyes.com),
Portions created by Peter Morris are Copyright (C) 2000 Peter Morris.
All Rights Reserved.
Purpose of file:
To allow the user to take "SnapShots" of the properties of all of its controls,
and then "morph" between SnapShots over a given period of time.
Contributor(s):
None as yet
Last Modified: May 2, 2001
You may retrieve the latest version of this file at http://www.droopyeyes.com
Known Issues:
-----------------------------------------------------------------------------}
//Modifications
(*
Date: April 4, 2000
By: Peter Morris
Change: Added OnFrame event (0 = start, 255 = end) for TCustomDIBAnimContainer
Date: April 4, 2000
By: Peter Morris
Change: Added PauseControl and UnpauseControl to TCustomDIBAnimContainer.
This allows you to exclude a control from the animation at runtime,
you could then quite easily use the OnFrame event to Unpause the control
and let it catch up with the other controls.
Date: May 2, 2001
By: Peter Morris
Change: Added DIBBorder property
Date: June 24, 2001
By: Peter Morris
Change: Added BorderDrawPosition;
Date: August 24, 2001
By: Peter Morris
Change: Added BeforePaint / AfterPaint events.
*)
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, cDIBPanel, cDIBTimer, cDIBImageList, cDIB, TypInfo;
type
PDIBPropertyMorpher = ^TDIBPropertyMorpher;
TDIBPropertyMorpher = function(Info: PTypeInfo; StartValue, EndValue: Variant;
Position: Byte): Variant;
TFrameEvent = procedure(Sender: TObject; Position: Byte) of object;
TDIBSnapShotControls = class;
TDIBControlProperty = class(TCollectionItem)
private
FPropName: string;
FValue: string;
Owner: TComponent;
protected
procedure AssignTo(Dest: TPersistent); override;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
published
property PropName: string read FPropName write FPropName;
property Value: string read FValue write FValue;
end;
TDIBControlProperties = class(TOwnedCollection)
private
Owner: TComponent;
function GetItem(Index: Integer): TDIBControlProperty;
procedure SetItem(Index: Integer; const Value: TDIBControlProperty);
protected
public
constructor Create(AOwner: TComponent);
destructor Destroy; override;
function Add: TDIBControlProperty;
function Insert(Index: Integer): TDIBControlProperty;
procedure MakeSnapShot(const Control: TControl);
property Items[Index: Integer]: TDIBControlProperty read GetItem write SetItem;
default;
published
end;
TDIBSnapShotControl = class(TCollectionItem)
private
Owner: TComponent;
FControl: TControl;
FProperties: TDIBControlProperties;
procedure MorphTo(Dest: TDIBSnapShotControl; Position: Byte);
procedure SetProperties(const Value: TDIBControlProperties);
procedure SetControl(const Value: TControl);
protected
procedure AssignTo(Dest: TPersistent); override;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
procedure MakeSnapShot;
function FindProperty(const PropName: string): TDIBControlProperty;
published
property Control: TControl read FControl write SetControl;
property Properties: TDIBControlProperties read FProperties write SetProperties;
end;
TDIBSnapShotControls = class(TOwnedCollection)
private
Owner: TComponent;
function GetItem(Index: Integer): TDIBSnapShotControl;
procedure SetItem(Index: Integer; const Value: TDIBSnapShotControl);
protected
public
constructor Create(AOwner: TComponent);
destructor Destroy; override;
function Add: TDIBSnapShotControl;
function Insert(Index: Integer): TDIBSnapShotControl;
property Items[Index: Integer]: TDIBSnapShotControl read GetItem write SetItem;
default;
published
end;
TDIBContainerSnapShot = class(TCollectionItem)
private
FDisplayName: string;
Owner: TComponent;
FControls: TDIBSnapShotControls;
procedure SetControls(const Value: TDIBSnapShotControls);
protected
procedure AssignTo(Dest: TPersistent); override;
function GetDisplayName: string; override;
procedure Notification(AComponent: TComponent);
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
function FindControl(Control: TControl): TDIBSnapShotControl;
procedure MakeSnapShot;
procedure MorphTo(Dest: TDIBContainerSnapShot; Position: Byte;
PausedControls: TList);
published
property Controls: TDIBSnapShotControls read FControls write SetControls;
property DisplayName: string read GetDisplayName write FDisplayName;
end;
TDIBContainerSnapShots = class(TOwnedCollection)
private
Owner: TComponent;
function GetItem(Index: Integer): TDIBContainerSnapShot;
procedure SetItem(Index: Integer; const Value: TDIBContainerSnapShot);
protected
public
constructor Create(AOwner: TComponent);
destructor Destroy; override;
function Add: TDIBContainerSnapShot;
function Insert(Index: Integer): TDIBContainerSnapShot;
property Items[Index: Integer]: TDIBContainerSnapShot read GetItem write SetItem;
default;
published
end;
TCustomDIBAnimContainer = class(TCustomDIBContainer)
private
{ Private declarations }
FPausedControls: TList;
FCurrentPosition,
FPositionInc: Extended;
FEndSnapShot: TDIBContainerSnapShot;
FSnapShots: TDIBContainerSnapShots;
FTempSnapShots: TDIBContainerSnapShots;
FTimer: TDIBTimer;
FOnAnimEnd: TNotifyEvent;
FOnAnimStart: TNotifyEvent;
FOnFrame: TFrameEvent;
procedure DoAnimateSnapShot(Sender: TObject);
procedure SetSnapShots(const Value: TDIBContainerSnapShots);
function GetIsAnimating: Boolean;
protected
{ Protected declarations }
procedure AssignTo(Dest: TPersistent); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
property PausedControls: TList read FPausedControls;
property OnAnimEnd: TNotifyEvent read FOnAnimEnd write FOnAnimEnd;
property OnAnimStart: TNotifyEvent read FOnAnimStart write FOnAnimStart;
property OnFrame: TFrameEvent read FOnFrame write FOnFrame;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure AnimateToSnapShot(Index: Integer; MilliSeconds: Cardinal);
procedure GoToSnapShot(Index: Integer);
procedure PauseControl(Control: TControl);
procedure Stop;
procedure UnpauseControl(Control: TControl);
property IsAnimating: Boolean read GetIsAnimating;
published
{ Published declarations }
property SnapShots: TDIBContainerSnapShots read FSnapShots write SetSnapShots;
end;
TDIBAnimContainer = class(TCustomDIBAnimContainer)
public
published
//New properties / events
property OnAnimEnd;
property OnAnimStart;
property OnFrame;
//inherited
property AfterPaint;
property Align;
property Anchors;
property AutoSize;
property BeforePaint;
property BiDiMode;
property BorderDrawPosition;
property Color;
property Constraints;
property Cursor;
property DIBBorder;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property Height;
property HelpContext;
property Hint;
property Left;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property ParentBiDiMode;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property Tag;
property Top;
property UseDockManager;
property Visible;
property Width;
property OnActiveControlChange;
property OnCanResize;
property OnClick;
property OnConstrainedResize;
property OnDblClick;
property OnDockDrop;
property OnDockOver;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
end;
TCustomDIBImageAnimContainer = class(TCustomDIBAnimContainer)
private
FIndexImage: TDIBImageLink;
FTileMethod: TTileMethod;
procedure DoImageChanged(Sender: TObject; ID: Integer; Operation: TDIBOperation);
function GetDIBImageList: TCustomDIBImageList;
procedure SetDIBImageList(const Value: TCustomDIBImageList);
procedure SetTileMethod(const Value: TTileMethod);
procedure ImageChanged(ID: Integer; Operation: TDIBOperation); virtual;
property DIBImageList: TCustomDIBImageList read GetDIBImageList write SetDIBImageList;
property IndexImage: TDIBImageLink read FIndexImage write FIndexImage;
property TileMethod: TTileMethod read FTileMethod write SetTileMethod;
protected
procedure WndProc(var Message: TMessage); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Paint; override;
published
end;
TDIBImageAnimContainer = class(TCustomDIBImageAnimContainer)
public
published
//New properties / events
property DIBImageList;
property IndexImage;
property TileMethod;
//inherited
property OnAnimEnd;
property OnAnimStart;
property OnFrame;
property AfterPaint;
property Align;
property Anchors;
property AutoSize;
property BeforePaint;
property BiDiMode;
property BorderDrawPosition;
property Color;
property Constraints;
property Cursor;
property DIBBorder;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property Font;
property Height;
property HelpContext;
property Hint;
property Left;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property ParentBiDiMode;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property TabOrder;
property Tag;
property Top;
property UseDockManager;
property Visible;
property Width;
property OnActiveControlChange;
property OnCanResize;
property OnClick;
property OnConstrainedResize;
property OnDblClick;
property OnDockDrop;
property OnDockOver;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -