ksskinlabels.pas
来自「小区水费管理系统源代码水费收费管理系统 水费收费管理系统」· PAS 代码 · 共 198 行
PAS
198 行
{==============================================================================
SkinEngine's Label
Copyright (C) 2000-2002 by Evgeny Kryukov
All rights reserved
All conTeThements of this file and all other files included in this archive
are Copyright (C) 2002 Evgeny Kryukov. Use and/or distribution of
them requires acceptance of the License Agreement.
See License.txt for licence information
$Id: KsSkinLabels.pas,v 1.2 2002/10/28 21:04:21 Evgeny Exp $
===============================================================================}
unit KsSkinLabels;
{$I se_define.inc}
{$T-,W-,X+,P+}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Buttons,
se_controls, KsSkinVersion, KsSkinObjects, KsSkinSource, KsSkinEngine;
type
{ TSeSkinLabel class }
TSeSkinLabel = class(TSeCustomLabel)
private
FSkinEngine: TSeSkinEngine;
FSkinObject: string;
FSkinLabel: TSeSkinObject;
function GetVersion: TSeSkinVersion;
procedure SetVersion(const Value: TSeSkinVersion);
procedure SetSkinEngine(const Value: TSeSkinEngine);
procedure SetSkinObject(const Value: string);
protected
procedure WMInvalidateSkinObject(var Msg: TMessage); message WM_INVALIDATESKINOBJECT;
procedure WMBeforeChange(var Msg: TMessage); message WM_BEFORECHANGE;
procedure WMSkinChange(var Msg: TMessage); message WM_SKINCHANGE;
function UseSkin: boolean;
{ overrides }
procedure PaintBuffer; override;
{ VCL protected }
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
procedure Loaded; override;
destructor Destroy; override;
published
property SkinEngine: TSeSkinEngine read FSkinEngine write SetSkinEngine;
property SkinObject: string read FSkinObject write SetSkinObject;
property Transparent;
property Version: TSeSkinVersion read GetVersion write SetVersion
stored false;
property OnClick;
end;
implementation {===============================================================}
{ TSeSkinLabel }
constructor TSeSkinLabel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FSkinObject := 'Label';
end;
destructor TSeSkinLabel.Destroy;
begin
if FSkinLabel <> nil then FSkinLabel.Free;
inherited Destroy;
end;
procedure TSeSkinLabel.Loaded;
begin
inherited;
Invalidate;
end;
function TSeSkinLabel.UseSkin: boolean;
begin
if (csDestroying in ComponentState) or (csLoading in ComponentState) then
Result := false
else
if (FSkinEngine <> nil) and (FSkinEngine.SkinSource <> nil) and
(not FSkinEngine.SkinSource.IsChanging) and
(FSkinEngine.SkinSource.Count > 0) and
(FSkinEngine.SkinSource.GetObjectByName(FSkinObject) <> nil) and
(FSkinLabel <> nil)
then
Result := true
else
Result := false;
end;
procedure TSeSkinLabel.PaintBuffer;
var
DrawState: TSeState;
begin
if UseSkin then
begin
if MouseInControl then
DrawState := ssHot
else
DrawState := ssNormal;
FSkinLabel.State := DrawState;
ControlFont.Assign(FSkinLabel.Font);
end;
inherited ;
end;
procedure TSeSkinLabel.WMInvalidateSkinObject(var Msg: TMessage);
begin
Invalidate;
end;
procedure TSeSkinLabel.WMBeforeChange(var Msg: TMessage);
begin
if Pointer(Msg.LParam) = nil then Exit;
if TSeSkinEngine(Msg.LParam) <> FSkinEngine then Exit;
if FSkinLabel <> nil then FSkinLabel.Free;
FSkinLabel := nil;
end;
procedure TSeSkinLabel.WMSkinChange(var Msg: TMessage);
begin
if Pointer(Msg.LParam) = nil then Exit;
if TSeSkinEngine(Msg.LParam) <> FSkinEngine then Exit;
SkinEngine := FSkinEngine;
end;
{ VCL Protected }
procedure TSeSkinLabel.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = FSkinEngine) then
SkinEngine := nil;
end;
{ Properties }
function TSeSkinLabel.GetVersion: TSeSkinVersion;
begin
Result := sSeSkinVersion;
end;
procedure TSeSkinLabel.SetVersion(const Value: TSeSkinVersion);
begin
end;
procedure TSeSkinLabel.SetSkinEngine(const Value: TSeSkinEngine);
begin
FSkinEngine := Value;
if (FSkinEngine <> nil) and (FSkinEngine.SkinSource <> nil) and
(not FSkinEngine.SkinSource.IsChanging) and
(FSkinEngine.SkinSource.Count > 0) then
begin
if FSkinLabel <> nil then FSkinLabel.Free;
FSkinLabel := nil;
if FSkinEngine.SkinSource.GetObjectByName(FSkinObject) <> nil then
begin
FSkinLabel := FSkinEngine.SkinSource.GetObjectByName(FSkinObject).CreateCopy(nil);
Color := FSkinLabel.Color;
Font.Assign(FSkinLabel.Font);
end;
end
else
begin
if FSkinLabel <> nil then FSkinLabel.Free;
FSkinLabel := nil;
end;
Invalidate;
end;
procedure TSeSkinLabel.SetSkinObject(const Value: string);
begin
FSkinObject := Value;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?