?? aactrls.pas
字號:
{* 是否允許控件參數變更時自動重新創建滾動內容。如果有很多參數需要在運行時設置,
可將該屬性設為False,待設定完參數后調用Reset方法。}
property Active: Boolean read FActive write SetActive default True;
{* 是否允許文本滾動}
property Height default 280;
{* 控件高度}
property Width default 240;
{* 控件寬度}
property ScrollDelay: Word read FScrollDelay write SetScrollDelay default 60;
{* 滾動時的延時,單位為毫秒}
property ScrollStep: Integer read FScrollStep write SetScrollStep default 1;
{* 一次滾動的象素數,如果設定為負數將向下滾動}
property ScrollQuality: TTimerQuality read GetScrollQuality write SetScrollQuality
default tqHigh;
{* 滾動精度,如果滾動較慢,可考慮設置為tqLow以節約系統資源}
property RepeatCount: TBorderWidth read FRepeatCount write SetRepeatCount default 0;
{* 允許循環次數,指定次數的循環結束將自動停止滾動,并產生OnComplete事件。
|<BR> 該值設為0將無限循環。}
property RepeatDelay: Word read FRepeatDelay write SetRepeatDelay default 2000;
{* 完成一次滾動循環后的延時,如果不需要延時,可設為0}
property Text: TScrollTextParam read FText write SetText;
{* 滾動文本內容和參數屬性}
property OnComplete;
{* 指定次數的滾動循環結束事件,見RepeatCount}
property OnTextReady;
{* 滾動內容已初始化事件}
property OnPainted;
{* 控件重繪事件}
end;
{ TFadeTextParam }
TFadeTextParam = class(TCustomTextParam)
{* 平滑特效漸隱文本控件參數類}
private
FFadeDelay: Cardinal;
procedure SetFadeDelay(const Value: Cardinal);
procedure SetLineDelay(const Value: Cardinal);
function GetLineDelay: Cardinal;
protected
function IsLinesStored: Boolean; override;
public
constructor Create(AOwner: TAAGraphicControl; ChangedProc:
TNotifyEvent); override;
{* 類構造器}
destructor Destroy; override;
{* 類析構器}
procedure Assign(Source: TPersistent); override;
{* 對象賦值方法}
published
property FadeDelay: Cardinal read FFadeDelay write SetFadeDelay default 600;
{* 文本淡入淡出切換延時}
property LineDelay: Cardinal read GetLineDelay write SetLineDelay default 3000;
{* 每行文本顯示延時}
property Lines;
{* 文本內容屬性,允許使用字體標簽和用戶標簽來控制每一行文本的對齊方式和字體特效。
使用標簽時用一對尖括號'<'、'>'將標簽名引起來,控制標簽的作用范圍由LabelEffect
決定。另見文本控件的Fonts、Labels屬性。}
property Transparent;
{* 是否允許控件透明}
property Alignment default taCenter;
{* 默認的文本對齊方式,如果文本內有對齊標簽,則由對齊標簽決定。
|<BR> 另見LabelEffect、Lines、Labels屬性}
property Layout default tlCenter;
{* 文本垂直方向對齊方式}
property Quality;
{* 平滑字顯示精度}
property FontEffect;
{* 默認的字體特效參數,如果文本內有字體標簽,則由字體標簽決定。
|<BR> 另見LabelEffect、Lines、Fonts、Font屬性}
property LabelEffect;
{* 字體、對齊標簽作用范圍}
property BackColor default clWhite;
{* 控件背景顏色}
property BackGround;
{* 控件背景圖像}
property BackGroundMode;
{* 控件背景顯示模式}
end;
{ TAAFadeText }
TAAFadeText = class(TAACustomText)
{* 平滑特效漸隱文本控件,用于多行文本的淡入淡出切換顯示}
private
{ Private declarations }
FActive: Boolean;
FLineIndex: Integer;
FText: TFadeTextParam;
FFadeProgress: TProgress;
InBmp, OutBmp, TextBmp: TBitmap;
FadeTimer: TTimer;
DelayTimer: TTimer;
LastText: string;
CurrText: string;
CurrAlign: TAlignment;
FRepeatedCount: Integer;
FRepeatCount: TBorderWidth;
NewProg: Double;
procedure SetActive(const Value: Boolean);
procedure SetLineIndex(const Value: Integer);
procedure SetText(const Value: TFadeTextParam);
procedure OnFadeTimer(Sender: TObject);
procedure OnDelayTimer(Sender: TObject);
procedure SetFadeProgress(const Value: TProgress);
procedure DrawFadeBmp(AText: string; Bmp: TBitmap);
procedure SetRepeatCount(const Value: TBorderWidth);
protected
{ Protected declarations }
procedure CreateDefFonts; override;
procedure PaintCanvas; override;
function UseDefaultLabels: Boolean; override;
procedure LoadedEx; override;
procedure Reset; override;
property FadeProgress: TProgress read FFadeProgress write SetFadeProgress;
public
constructor Create(AOwner: TComponent); override;
{* 類構造器}
destructor Destroy; override;
{* 類析構器}
property LineIndex: Integer read FLineIndex write SetLineIndex;
{* 當前顯示的行索引號,用戶可手動設置}
property RepeatedCount: Integer read FRepeatedCount;
{* 已循環滾動次數,運行期只讀屬性}
procedure FadeTo(Line: Integer);
{* 淡入淡出切換到指定行}
procedure FadeToNext;
{* 淡入淡出切換到下一行}
procedure FadeToStr(AText: string);
{* 淡入淡出切換到指定文本}
published
{ Published declarations }
property Active: Boolean read FActive write SetActive default True;
{* 是否允許文本淡入淡出切換}
property Height default 34;
{* 控件高度}
property Width default 240;
{* 控件寬度}
property Font;
{* 控件字體}
property RepeatCount: TBorderWidth read FRepeatCount write SetRepeatCount default 0;
{* 允許循環次數,指定次數的循環結束將自動停止滾動,并產生OnComplete事件。
|<BR> 該值設為0將無限循環。}
property Text: TFadeTextParam read FText write SetText;
{* 控件文本內容和參數屬性}
property OnComplete;
{* 指定次數的滾動循環結束事件,見RepeatCount}
property OnPainted;
{* 控件重繪事件}
end;
procedure Register;
implementation
{$R-}
procedure Register;
begin
RegisterComponents('AAFont', [TAAFadeText]);
RegisterComponents('AAFont', [TAALabel]);
RegisterComponents('AAFont', [TAALinkLabel]);
RegisterComponents('AAFont', [TAAText]);
RegisterComponents('AAFont', [TAAScrollText]);
end;
const
csAACopyRight =
'<Title2>版權聲明'#13#10 +
'<Text1>本控件為免費控件'#13#10 +
'允許免費用于共享、商業軟件中'#13#10 +
'更多說明參見Readme.txt文件'#13#10 +
'如發現錯誤請與作者聯系'#13#10#13#10 +
'<Title2>控件作者'#13#10 +
'<Text1>作者:周勁羽'#13#10 +
'Email:yygw@yygw.net'#13#10 +
'Http://www.yygw.net'#13#10 +
'與月共舞工作室'#13#10;
csAACopyRightStart =
#13#10'<Title2>用戶資料'#13#10 +
'<Text1><Owner>'#13#10 +
'<Organization>'#13#10#13#10 +
'<Title2>控件功能'#13#10;
csAACopyRightEnd =
'允許使用不同風格的字體'#13#10 +
'和對齊方式'#13#10 +
'支持陰影、漸變色、紋理等特效'#13#10 +
'提供多個系統變量并'#13#10 +
'允許自定義變量'#13#10 +
'所有字體采用平滑顯示'#13#10#13#10 +
'<Title2>使用說明'#13#10 +
'<Text1>控件的屬性、方法、事件'#13#10 +
'詳見Readme.txt文件'#13#10#13#10 +
'<Title2>特別感謝'#13#10 +
'<Text1>李文松朋友提供'#13#10 +
'平滑字體顯示算法'#13#10 +
'liwensong@hotmail.com'#13#10 +
'http://member.netease.com/~lws'#13#10 +
'Passion兄幫助制作控件圖標'#13#10 +
'shanzhashu@163.com'#13#10#13#10 +
'<Title2>備注'#13#10 +
'<Text1>該控件為免費控件'#13#10 +
'如果您對這個控件還感滿意'#13#10 +
'請給作者發一封賀卡或郵件'#13#10 +
'以示支持'#13#10#13#10#13#10 +
'<Title3>與月共舞工作室'#13#10 +
'2003.03'#13#10;
csAATextCopyRight =
'<Title1><Center>平滑特效文本控件 ' + verAAFont + #13#10#13#10 +
csAACopyRight;
csAAFadeTextCopyRight =
'<Title1><Center>平滑特效漸隱文本控件 ' + verAAFont + #13#10#13#10 +
csAACopyRight + csAACopyRightStart +
'<Text1>用于顯示淡入淡出文本'#13#10 +
csAACopyRightEnd;
csAAScrollTextCopyRight =
'<Title1>平滑滾動文本控件 ' + verAAFont + #13#10#13#10 +
csAACopyRight + csAACopyRightStart +
'<Text1>用于顯示滾動文本信息'#13#10 +
csAACopyRightEnd;
csDanceWithMoon =
'<Center><Title4>與 月 共 舞'#13#10 +
'<Text2>《仙劍奇俠傳》插曲'#13#10 +
'原曲:《蝶戀》'#13#10 +
'填詞:與月共舞'#13#10#13#10 +
'<Text3>漫不經心喚出你的名字'#13#10 +
'恍惚間已是光陰縱逝'#13#10#13#10 +
'輕描淡寫勾出你的樣子'#13#10 +
'才知你仍是我的影子'#13#10#13#10 +
'為愛你已飄然而逝'#13#10 +
'只留下一份深情我知'#13#10 +
'默默地 緊緊地'#13#10 +
'伴我風雨江湖行'#13#10#13#10 +
'今生不再為誰而癡'#13#10 +
'只期盼明月寄我所思'#13#10 +
'靜靜地 輕輕地'#13#10 +
'與你共舞到天明'#13#10#13#10 +
'<Text2>謹以此曲獻給——'#13#10 +
'愛我的父母'#13#10 +
'在我最困難的時候'#13#10 +
'給我關心和支持的'#13#10 +
'箏鳴小姐'#13#10 +
'以及所有關心、支持'#13#10 +
'和幫助過我的朋友們'#13#10;
csCopyRandom = 5;
{ TAALabel }
//--------------------------------------------------------//
//平滑特效字體標簽 //
//--------------------------------------------------------//
//初始化
constructor TAALabel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
MemBmp := TBitmap.Create;
MemBmp.PixelFormat := pf24bit;
FEffect := TAAFontEffect.Create(Self, OnEffectChanged);
ControlStyle := ControlStyle + [csReplicatable, csSetCaption];
Width := 46;
Height := 12;
end;
//釋放
destructor TAALabel.Destroy;
begin
FEffect.Free;
MemBmp.Free;
inherited;
end;
//重繪
procedure TAALabel.Reset;
begin
if not Effect.Transparent then
DrawMem;
inherited;
end;
//繪制緩沖區
procedure TAALabel.DrawMem;
var
OffPoint: TPoint;
th, tw: Integer;
begin
AAFont.Canvas := MemBmp.Canvas;
MemBmp.Canvas.Font.Assign(Font); //字體
th := AAFont.TextHeight(Caption); //文本高度
tw := AAFont.TextWidth(Caption); //文本寬度
//自動設定大小
if AutoSize and (Align in [alNone, alLeft, alRight]) then
ClientWidth := tw + 2 * Border;
if AutoSize and (Align in [alNone, alTop, alBottom]) then
ClientHeight := th + 2 * Border;
case Effect.Alignment of //水平對齊方式
taLeftJustify: OffPoint.x := Border;
taCenter: OffPoint.x := (ClientWidth - tw) div 2;
taRightJustify: OffPoint.x := ClientWidth - Border - tw;
end;
case Effect.Layout of //垂直對齊方式
tlTop: OffPoint.y := Border;
tlCenter: OffPoint.y := (ClientHeight - th) div 2;
tlBottom: OffPoint.y := ClientHeight - Border - th;
end;
MemBmp.Height := ClientHeight;
MemBmp.Width := ClientWidth;
MemBmp.Canvas.Brush.Color := Color;
MemBmp.Canvas.Brush.Style := bsSolid;
if Effect.Transparent then //透明
begin
CopyParentImage(MemBmp.Canvas); //復制父控件畫布
end else if not Effect.IsBackEmpty then
begin //繪制背景圖
DrawBackGround(MemBmp.Canvas, Rect(0, 0, MemBmp.Width, MemBmp.Height),
Effect.BackGround.Graphic, Effect.BackGroundMode);
end else
begin //填充背景色
MemBmp.Canvas.FillRect(ClientRect);
end;
MemBmp.Canvas.Brush.Style := bsClear;
AAFont.TextOut(OffPoint.x, OffPoint.y, Caption); //平滑字體輸出
end;
// 透明繪制
procedure TAALabel.TransparentPaint;
var
OffPoint: TPoint;
th, tw: Integer;
begin
AAFont.Canvas := Canvas;
Canvas.Font.Assign(Font); //字體
th := AAFont.TextHeight(Caption); //文本高度
tw := AAFont.TextWidth(Caption); //文本寬度
//自動設定大小
if AutoSize and (Align in [alNone, alLeft, alRight]) then
ClientWidth := tw + 2 * Border;
if AutoSize and (Align in [alNone, alTop, alBottom]) then
ClientHeight := th + 2 * Border;
case Effect.Alignment of //水平對齊方式
taLeftJustify: OffPoint.x := Border;
taCenter: OffPoint.x := (ClientWidth - tw) div 2;
taRightJustify: OffPoint.x := ClientWidth - Border - tw;
end;
case Effect.Layout of //垂直對齊方式
tlTop: OffPoint.y := Border;
tlCenter: OffPoint.y := (ClientHeight - th) div 2;
tlBottom: OffPoint.y := ClientHeight - Border - th;
end;
Canvas.Brush.Color := Color;
Canvas.Brush.Style := bsSolid;
Canvas.Brush.Style := bsClear;
AAFont.TextOut(OffPoint.x, OffPoint.y, Caption); //平滑字體輸出
end;
//控件重繪
procedure TAALabel.PaintCanvas;
begin
if Effect.Transparent then
TransparentPaint
else
Bitblt(Canvas.Handle, 0, 0, Width, Height, MemBmp.Canvas.Handle, 0, 0,
SRCCOPY);
end;
//設置字體特效
procedure TAALabel.SetEffect(const Value: TAAFontEffect);
begin
FEffect.Assign(Value);
end;
{ THotLink }
//--------------------------------------------------------//
//超鏈接參數類 //
//--------------------------------------------------------//
//鏈接參數
procedure THotLink.Assign(Source: TPersistent);
begin
inherited;
if Source is THotLink then
begin
FFade := THotLink(Source).Fade;
FUnderLine := THotLink(Source).UnderLine;
FFadeDelay := THotLink(Source).FadeDelay;
FURL := THotLink(Source).URL;
FColor := THotLink(Source).Color;
FBackColor := THotLink(Source).BackColor;
FFontEffect.Assign(THotLink(Source).FontEffect);
end;
end;
//初始化
constructor THotLink.Create;
begin
inherited Create(nil, nil);
FFade := True;
FUnderLine := False;
FFadeDelay := 600;
FURL := '';
FColor := clBlue;
FBackColor := clBtnface;
FFontEffect := TAAEffect.Create(nil);
end;
//釋放
destructor THotLink.Destroy;
begin
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -