?? aactrls.pas
字號:
property ScrollDelay: Word read FScrollDelay write SetScrollDelay default 60;
{* 滾動時的延時,單位為毫秒}
property ScrollStep: Integer read FScrollStep write SetScrollStep default 1;
{* 一次滾動的象素數(shù),如果設(shè)定為負(fù)數(shù)將向下滾動}
property RepeatCount: TBorderWidth read FRepeatCount write SetRepeatCount default 0;
{* 允許循環(huán)次數(shù),指定次數(shù)的循環(huán)結(jié)束將自動停止?jié)L動,并產(chǎn)生OnComplete事件。
|<BR> 該值設(shè)為0將無限循環(huán)。}
property RepeatDelay: Word read FRepeatDelay write SetRepeatDelay default 2000;
{* 完成一次滾動循環(huán)后的延時,如果不需要延時,可設(shè)為0}
property Text: TScrollTextParam read FText write SetText;
{* 滾動文本內(nèi)容和參數(shù)屬性}
property OnComplete;
{* 指定次數(shù)的滾動循環(huán)結(jié)束事件,見RepeatCount}
property OnTextReady;
{* 滾動內(nèi)容已初始化事件}
property OnPainted;
{* 控件重繪事件}
end;
{ TFadeTextParam }
TFadeTextParam = class(TCustomTextParam)
{* 平滑特效漸隱文本控件參數(shù)類}
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;
{* 類構(gòu)造器}
destructor Destroy; override;
{* 類析構(gòu)器}
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;
{* 文本內(nèi)容屬性,允許使用字體標(biāo)簽和用戶標(biāo)簽來控制每一行文本的對齊方式和字體特效。
使用標(biāo)簽時用一對尖括號'<'、'>'將標(biāo)簽名引起來,控制標(biāo)簽的作用范圍由LabelEffect
決定。另見文本控件的Fonts、Labels屬性。}
property Transparent;
{* 是否允許控件透明}
property Alignment default taCenter;
{* 默認(rèn)的文本對齊方式,如果文本內(nèi)有對齊標(biāo)簽,則由對齊標(biāo)簽決定。
|<BR> 另見LabelEffect、Lines、Labels屬性}
property Layout default tlCenter;
{* 文本垂直方向?qū)R方式}
property Quality;
{* 平滑字顯示精度}
property FontEffect;
{* 默認(rèn)的字體特效參數(shù),如果文本內(nèi)有字體標(biāo)簽,則由字體標(biāo)簽決定。
|<BR> 另見LabelEffect、Lines、Fonts、Font屬性}
property LabelEffect;
{* 字體、對齊標(biāo)簽作用范圍}
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;
{* 類構(gòu)造器}
destructor Destroy; override;
{* 類析構(gòu)器}
property LineIndex: Integer read FLineIndex write SetLineIndex;
{* 當(dāng)前顯示的行索引號,用戶可手動設(shè)置}
property RepeatedCount: Integer read FRepeatedCount;
{* 已循環(huán)滾動次數(shù),運行期只讀屬性}
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;
{* 允許循環(huán)次數(shù),指定次數(shù)的循環(huán)結(jié)束將自動停止?jié)L動,并產(chǎn)生OnComplete事件。
|<BR> 該值設(shè)為0將無限循環(huán)。}
property Text: TFadeTextParam read FText write SetText;
{* 控件文本內(nèi)容和參數(shù)屬性}
property OnComplete;
{* 指定次數(shù)的滾動循環(huán)結(jié)束事件,見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]);
RegisterComponents('AAFont', [TAATimer]);
RegisterComponents('AAFont', [TAATimerList]);
end;
const
csAACopyRight =
'<Title2>版權(quán)聲明'#13#10 +
'<Text1>本控件為免費控件'#13#10 +
'允許免費用于共享、商業(yè)軟件中'#13#10 +
'更多說明參見Readme.txt文件'#13#10 +
'如發(fā)現(xiàn)錯誤請與作者聯(lián)系'#13#10#13#10 +
'<Title2>控件作者'#13#10 +
'<Text1>作者:周勁羽'#13#10 +
'Email:zjy@cnvcl.org'#13#10 +
'Http://www.cnvcl.org'#13#10 +
'CnPack 開發(fā)組'#13#10;
csAACopyRightStart =
#13#10'<Title2>用戶資料'#13#10 +
'<Text1><Owner>'#13#10 +
'<Organization>'#13#10#13#10 +
'<Title2>控件功能'#13#10;
csAACopyRightEnd =
'允許使用不同風(fēng)格的字體'#13#10 +
'和對齊方式'#13#10 +
'支持陰影、漸變色、紋理等特效'#13#10 +
'提供多個系統(tǒng)變量并'#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兄幫助制作控件圖標(biāo)'#13#10 +
'shanzhashu@163.com'#13#10#13#10 +
'<Title2>備注'#13#10 +
'<Text1>該控件為免費控件'#13#10 +
'如果您對這個控件還感滿意'#13#10 +
'請給作者發(fā)一封賀卡或郵件'#13#10 +
'以示支持'#13#10#13#10#13#10 +
'<Title3>CnPack 開發(fā)組'#13#10 +
'2004.11'#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;
{ TAALabel }
//--------------------------------------------------------//
//平滑特效字體標(biāo)簽 //
//--------------------------------------------------------//
//初始化
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;
//繪制緩沖區(qū)
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); //文本寬度
//自動設(shè)定大小
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); //復(fù)制父控件畫布
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); //文本寬度
//自動設(shè)定大小
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;
//設(shè)置字體特效
procedure TAALabel.SetEffect(const Value: TAAFontEffect);
begin
FEffect.Assign(Value);
end;
{ THotLink }
//--------------------------------------------------------//
//超鏈接參數(shù)類 //
//--------------------------------------------------------//
//鏈接參數(shù)
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
FFontEffect.Free;
inherited;
end;
procedure THotLink.SetFontEffect(const Value: TAAEffect);
begin
FFontEffect.Assign(Value);
Changed;
end;
{ TAALinkLabel }
//--------------------------------------------------------//
//平滑特效超鏈接標(biāo)簽 //
//--------------------------------------------------------//
//初始化
constructor TAALinkLabel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FHotLink := THotLink.Create;
HotBmp := TBitmap.Create;
HotBmp.PixelFormat := pf24bit;
BlendBmp := TBitmap.Create;
BlendBmp.PixelFormat := pf24bit;
FadeTimer := TTimer.Create(Self);
FadeTimer.Interval := 55;
FadeTimer.OnTimer := OnFadeTimer;
FadeTimer.Enabled := False;
FProgress := 0;
FFadeStyle := fsNone;
NewProg := 0;
end;
//釋放
destructor TAALinkLabel.Destroy;
begin
HotBmp.Free;
BlendBmp.Free;
FadeTimer.Free;
HotLink.Free;
inherited;
end;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -