📄 jvqdesktopalert.pas
字号:
{******************************************************************************}
{* WARNING: JEDI VCL To CLX Converter generated unit. *}
{* Manual modifications will be lost on next release. *}
{******************************************************************************}
{-----------------------------------------------------------------------------
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: JvDesktopAlert.PAS, released on 2004-03-23.
The Initial Developer of the Original Code is Peter Thornqvist <peter3 at sourceforge dot net>
Portions created by Peter Thornqvist are Copyright (C) 2004 Peter Thornqvist.
All Rights Reserved.
Contributor(s):
Hans-Eric Gr鰊lund (stack logic)
Olivier Sannier (animation styles logic)
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
-----------------------------------------------------------------------------}
// $Id: JvQDesktopAlert.pas,v 1.15 2005/02/06 14:06:05 asnepvangers Exp $
unit JvQDesktopAlert;
{$I jvcl.inc}
interface
uses
QWindows, Classes, QControls, QGraphics, QForms, QExtCtrls, QMenus, QImgList,
JvQComponent, JvQBaseDlg, JvQDesktopAlertForm;
const
JvDefaultFrameColor = TColor($00943000);
JvDefaultWindowFromColor = TColor($00FFE7CE);
JvDefaultWindowToColor = TColor($00E7A67B);
JvDefaultCaptionFromColor = TColor($00D68652);
JvDefaultCaptionToColor = TColor($00944110);
type
// The possible animation styles as an enumeration
TJvAlertStyle = (asFade, asCenterGrow);
// The different status a style handler can have
TJvStyleHandlerStatus = (hsIdle, hsStartAnim, hsEndAnim, hsDisplay);
TJvCustomDesktopAlertStyleHandler = class;
TJvDesktopAlertStack = class;
TJvDesktopAlert = class;
TJvDesktopAlertChangePersistent = class(TPersistent)
private
FOnChange: TNotifyEvent;
protected
procedure Change;
public
property OnChange: TNotifyEvent read FOnChange write FOnChange;
end;
TJvDesktopAlertColors = class(TJvDesktopAlertChangePersistent)
private
FWindowFrom: TColor;
FCaptionTo: TColor;
FWindowTo: TColor;
FFrame: TColor;
FCaptionFrom: TColor;
procedure SetCaptionFrom(const Value: TColor);
procedure SetCaptionTo(const Value: TColor);
procedure SetFrame(const Value: TColor);
procedure SetWindowFrom(const Value: TColor);
procedure SetWindowTo(const Value: TColor);
public
constructor Create;
procedure Assign(Source: TPersistent); override;
published
property Frame: TColor read FFrame write SetFrame default JvDefaultFrameColor;
property WindowFrom: TColor read FWindowFrom write SetWindowFrom default JvDefaultWindowFromColor;
property WindowTo: TColor read FWindowTo write SetWindowTo default JvDefaultWindowToColor;
property CaptionFrom: TColor read FCaptionFrom write SetCaptionFrom default JvDefaultCaptionFromColor;
property CaptionTo: TColor read FCaptionTo write SetCaptionTo default JvDefaultCaptionToColor;
end;
TJvDesktopAlertPosition =
(dapTopLeft, dapTopRight, dapBottomLeft, dapBottomRight, dapCustom,
dapDesktopCenter, dapMainFormCenter, dapOwnerFormCenter, dapActiveFormCenter);
TJvDesktopAlertLocation = class(TJvDesktopAlertChangePersistent)
private
FTop: Integer;
FLeft: Integer;
FPosition: TJvDesktopAlertPosition;
FAlwaysResetPosition: Boolean;
FHeight: Integer;
FWidth: Integer;
procedure SetTop(const Value: Integer);
procedure SetLeft(const Value: Integer);
procedure SetPosition(const Value: TJvDesktopAlertPosition);
procedure SetHeight(const Value: Integer);
procedure SetWidth(const Value: Integer);
public
constructor Create;
published
property Position: TJvDesktopAlertPosition read FPosition write SetPosition default dapBottomRight;
property Top: Integer read FTop write SetTop;
property Left: Integer read FLeft write SetLeft;
property Width: Integer read FWidth write SetWidth;
property Height: Integer read FHeight write SetHeight;
property AlwaysResetPosition: Boolean read FAlwaysResetPosition write FAlwaysResetPosition default True;
end;
TJvDesktopAlertButtonItem = class(TCollectionItem)
private
FImageIndex: Integer;
FOnClick: TNotifyEvent;
FTag: Integer;
public
procedure Assign(Source: TPersistent); override;
published
property ImageIndex: Integer read FImageIndex write FImageIndex;
property Tag: Integer read FTag write FTag;
property OnClick: TNotifyEvent read FOnClick write FOnClick;
end;
TJvDesktopAlertButtons = class(TOwnedCollection)
private
function GetItem(Index: Integer): TJvDesktopAlertButtonItem;
procedure SetItem(Index: Integer; const Value: TJvDesktopAlertButtonItem);
public
constructor Create(AOwner: TPersistent);
function Add: TJvDesktopAlertButtonItem;
property Items[Index: Integer]: TJvDesktopAlertButtonItem read GetItem write SetItem; default;
procedure Assign(Source: TPersistent); override;
end;
TJvDesktopAlertOption = (daoCanClick, daoCanMove, daoCanMoveAnywhere, daoCanClose);
TJvDesktopAlertOptions = set of TJvDesktopAlertOption;
TJvDesktopAlert = class(TJvCommonDialogP)
private
FStacker: TJvDesktopAlertStack;
FImages: TCustomImageList;
FButtons: TJvDesktopAlertButtons;
FColors: TJvDesktopAlertColors;
FLocation: TJvDesktopAlertLocation;
FOptions: TJvDesktopAlertOptions;
FOnClose: TNotifyEvent;
FOnMouseEnter: TNotifyEvent;
FOnMessageClick: TNotifyEvent;
FOnShow: TNotifyEvent;
FOnMouseLeave: TNotifyEvent;
FData: TObject;
FAutoFocus: Boolean;
FAutoFree: Boolean;
FAlertStyle: TJvAlertStyle;
FStyleHandler: TJvCustomDesktopAlertStyleHandler;
function GetStacker: TJvDesktopAlertStack;
procedure SetButtons(const Value: TJvDesktopAlertButtons);
procedure SetColors(const Value: TJvDesktopAlertColors);
procedure SetDropDownMenu(const Value: TPopupMenu);
procedure SetFont(const Value: TFont);
procedure SetHeaderFont(const Value: TFont);
procedure SetImage(const Value: TPicture);
procedure SetImages(const Value: TCustomImageList);
procedure SetPopupMenu(const Value: TPopupMenu);
procedure InternalOnShow(Sender: TObject);
procedure InternalOnClose(Sender: TObject; var Action: TCloseAction);
procedure InternalMouseEnter(Sender: TObject);
procedure InternalMouseLeave(Sender: TObject);
procedure InternalMessageClick(Sender: TObject);
procedure InternalOnMove(Sender: TObject);
function GetAlertStack: TJvDesktopAlertStack;
procedure SetAlertStack(const Value: TJvDesktopAlertStack);
function GetFont: TFont;
function GetHeaderFont: TFont;
function GetImage: TPicture;
function GetDropDownMenu: TPopupMenu;
function GetHeaderText: string;
function GetMessageText: string;
function GetPopupMenu: TPopupMenu;
procedure SetHeaderText(const Value: string);
procedure SetLocation(const Value: TJvDesktopAlertLocation);
procedure SetMessageText(const Value: string);
procedure DoLocationChange(Sender: TObject);
function GetParentFont: Boolean;
function GetShowHint: Boolean;
function GetHint: string;
procedure SetHint(const Value: string);
procedure SetParentFont(const Value: Boolean);
procedure SetShowHint(const Value: Boolean);
procedure SetOptions(const Value: TJvDesktopAlertOptions);
function GetCloseButtonClick: TNotifyEvent;
procedure SetCloseButtonClick(const Value: TNotifyEvent);
procedure SetAlertStyle(const Value: TJvAlertStyle);
procedure SetStyleHandler(const Value: TJvCustomDesktopAlertStyleHandler);
// function GetBiDiMode: TBidiMode;
// procedure SetBiDiMode(const Value: TBidiMode);
protected
FFormButtons: array of TControl;
FDesktopForm: TJvFormDesktopAlert;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function Showing: Boolean;
procedure Close(Immediate: Boolean);
procedure Execute; override;
property Form: TJvFormDesktopAlert read FDesktopForm;
property Data: TObject read FData write FData;
property StyleHandler: TJvCustomDesktopAlertStyleHandler read FStyleHandler write SetStyleHandler;
published
property AlertStack: TJvDesktopAlertStack read GetAlertStack write SetAlertStack;
property AlertStyle: TJvAlertStyle read FAlertStyle write SetAlertStyle default asFade;
property AutoFocus: Boolean read FAutoFocus write FAutoFocus default False;
property AutoFree: Boolean read FAutoFree write FAutoFree default False;
// property BiDiMode: TBidiMode read GetBiDiMode write SetBiDiMode default bdLeftToRight;
property HeaderText: string read GetHeaderText write SetHeaderText;
property MessageText: string read GetMessageText write SetMessageText;
property HeaderFont: TFont read GetHeaderFont write SetHeaderFont;
property Hint: string read GetHint write SetHint;
property ShowHint: Boolean read GetShowHint write SetShowHint;
property Font: TFont read GetFont write SetFont;
property ParentFont: Boolean read GetParentFont write SetParentFont;
property Options: TJvDesktopAlertOptions read FOptions write SetOptions default [daoCanClick..daoCanClose];
property Colors: TJvDesktopAlertColors read FColors write SetColors;
property Buttons: TJvDesktopAlertButtons read FButtons write SetButtons;
property Location: TJvDesktopAlertLocation read FLocation write SetLocation;
property Image: TPicture read GetImage write SetImage;
property Images: TCustomImageList read FImages write SetImages;
property DropDownMenu: TPopupMenu read GetDropDownMenu write SetDropDownMenu;
property PopupMenu: TPopupMenu read GetPopupMenu write SetPopupMenu;
// This property is equivalent to StyleHandler, it is just renamed to look better in the inspector
property StyleOptions: TJvCustomDesktopAlertStyleHandler read FStyleHandler write SetStyleHandler;
property OnShow: TNotifyEvent read FOnShow write FOnShow;
property OnCloseButtonClick: TNotifyEvent read GetCloseButtonClick write SetCloseButtonClick;
property OnClose: TNotifyEvent read FOnClose write FOnClose;
property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
property OnMessageClick: TNotifyEvent read FOnMessageClick write FOnMessageClick;
end;
TJvDesktopAlertStack = class(TJvComponent)
private
FItems: TList;
FPosition: TJvDesktopAlertPosition;
function GetCount: Integer;
function GetItems(Index: Integer): TJvFormDesktopAlert;
procedure SetPosition(const Value: TJvDesktopAlertPosition);
protected
procedure UpdatePositions;
public
procedure Add(AForm: TForm);
procedure Remove(AForm: TForm);
property Items[Index: Integer]: TJvFormDesktopAlert read GetItems;
property Count: Integer read GetCount;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
// all forms must have the same position property
property Position: TJvDesktopAlertPosition read FPosition write SetPosition default dapBottomRight;
end;
// Common ancestor of all the alert styles for a TJvFormDesktopAlert
TJvCustomDesktopAlertStyleHandler = class(TPersistent)
private
FAnimTimer: TTimer;
FOwnerForm: TJvFormDesktopAlert;
FStartSteps: Cardinal;
FEndSteps: Cardinal;
FEndInterval: Cardinal;
FStartInterval: Cardinal;
FDisplayDuration: Cardinal;
FCurrentStep: Cardinal;
FStatus: TJvStyleHandlerStatus;
procedure SetDisplayDuration(const Value: Cardinal);
procedure SetOwnerForm(const Value: TJvFormDesktopAlert);
function GetActive: Boolean;
protected
procedure SetEndInterval(const Value: Cardinal); virtual;
procedure SetEndSteps(const Value: Cardinal); virtual;
procedure SetStartInterval(const Value: Cardinal); virtual;
procedure SetStartSteps(const Value: Cardinal); virtual;
// This procedure will be called for each step of the starting animation
// It will be called StartSteps time, every StartInterval milliseconds
// The implementation here only ensures that once the number of steps
// is reached, the timer is stopped
procedure StartAnimTimer(Sender: TObject); virtual;
// This procedure will be called for each step of the ending animation
// It will be called EndSteps time, every EndInterval milliseconds
// The implementation here only ensures that once the number of steps
// is reached, the timer is stopped and then calls DoDisplay
procedure EndAnimTimer(Sender: TObject); virtual;
// This procedure will be called once after DisplayDuration
// (if it is > 0) when the start animation is finished.
procedure DisplayTimer(Sender: TObject); virtual;
// This procedure is called just before the start animation timer
// is enabled. Use it to setup initial values required for the
// animation
// As implemented in this base class, the owner form is shown
procedure PrepareStartAnimation; virtual;
// This procedure is called just after the start animation has finished
// Use it to set the final values of the animation
procedure FinalizeStartAnimation; virtual; abstract;
// This procedure is called just before the end animation timer
// is enabled. Use it to setup initial values required for the
// animation
procedure PrepareEndAnimation; virtual; abstract;
// This procedure is called just after the end animation has finished
// Use it to set the final values of the animation
// As implemented in this base class, this closes the owner form.
// Note: It is required to close the form or the end animation
// will keep being repeated
procedure FinalizeEndAnimation; virtual;
// The timer used for all animations and waits
property AnimTimer: TTimer read FAnimTimer;
public
constructor Create(OwnerForm: TJvFormDesktopAlert); virtual;
destructor Destroy; override;
// Sets up the timer to call StartAnimTimer on the correct interval
// then show the owner form.
// If StartSteps is not greater than 0, the animation will not start
// and the form will not be shown.
procedure DoStartAnimation; virtual;
// Sets up the timer to call EndAnimTimer on the correct interval
// If EndSteps is not greater than 0, the animation will not start
procedure DoEndAnimation; virtual;
// Sets up the timer to call DisplayTimer after the correct delay
// If DisplayDuration is equal to 0, the timer is not enabled and
// DisplayTimer will never be called
procedure DoDisplay; virtual;
// Aborts the current animation, if any. Will call the proper Finalize
// function as applicable. The middle wait is NOT aborted by a call
// to this function
procedure AbortAnimation; virtual;
// The owner form, the form to which the style is associated.
// This value MUST NOT be nil when any of the DoXXXX function is called
property OwnerForm: TJvFormDesktopAlert read FOwnerForm write SetOwnerForm;
// The current step in the animation (starts at 0, use Active to know
// if an animation or wait is in progress).
property CurrentStep: Cardinal read FCurrentStep;
// Returns AnimTimer.Enabled
property Active: Boolean read GetActive;
// Returns the status of the handler
property Status: TJvStyleHandlerStatus read FStatus;
published
// The duration between each step of the start animation
property StartInterval: Cardinal read FStartInterval write SetStartInterval;
// The number of steps in the start animation
property StartSteps: Cardinal read FStartSteps write SetStartSteps;
// The duration between each step of the end animation
property EndInterval: Cardinal read FEndInterval write SetEndInterval;
// The number of steps in the end animation
property EndSteps: Cardinal read FEndSteps write SetEndSteps;
// The duration of the middle wait (between the end of the start
// animation and the beginning of the end animation)
property DisplayDuration: Cardinal read FDisplayDuration write SetDisplayDuration;
end;
// This style will make the form fade in and fade out.
// NOTE: This is only supported by Delphi or C++ Builder 6 and above
// NOTE: Even if the compiler supports it, this only works if the
// operating system is Windows 2000 or Windows XP
TJvFadeAlertStyleHandler = class (TJvCustomDesktopAlertStyleHandler)
private
FMinAlphaBlendValue: Byte;
FCurrentAlphaBlendValue: Byte;
FMaxAlphaBlendValue: Byte;
procedure SetMinAlphaBlendValue(const Value: Byte);
procedure SetMaxAlphaBlendValue(const Value: Byte);
protected
procedure StartAnimTimer(Sender: TObject); override;
procedure EndAnimTimer(Sender: TObject); override;
// Applies the current alpha blend value to the owner form
procedure DoAlphaBlend(Value: Byte);
procedure PrepareStartAnimation; override;
procedure FinalizeStartAnimation; override;
procedure PrepareEndAnimation; override;
procedure FinalizeEndAnimation; override;
public
constructor Create(OwnerForm: TJvFormDesktopAlert); override;
procedure AbortAnimation; override;
published
property MinAlphaBlendValue: Byte read FMinAlphaBlendValue write SetMinAlphaBlendValue default 0;
property MaxAlphaBlendValue: Byte read FMaxAlphaBlendValue write SetMaxAlphaBlendValue default 255;
property CurrentAlphaBlendValue: Byte read FCurrentAlphaBlendValue;
property StartInterval default 25;
property StartSteps default 10;
property EndInterval default 50;
property EndSteps default 10;
property DisplayDuration default 1400;
end;
TJvCenterGrowAlertStyleHandler = class(TJvCustomDesktopAlertStyleHandler)
private
FMaxGrowthPercentage: Double;
FMinGrowthPercentage: Double;
procedure SetMaxGrowthPercentage(const Value: Double);
procedure SetMinGrowthPercentage(const Value: Double);
protected
procedure StartAnimTimer(Sender: TObject); override;
procedure EndAnimTimer(Sender: TObject); override;
// Applies the current region growth percentage value to the owner form
procedure DoGrowRegion(Percentage: Double);
procedure PrepareStartAnimation; override;
procedure FinalizeStartAnimation; override;
procedure PrepareEndAnimation; override;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -