ksskincontrolbars.pas
来自「小区水费管理系统源代码水费收费管理系统 水费收费管理系统」· PAS 代码 · 共 253 行
PAS
253 行
{==============================================================================
SkinEngine's ControlBar
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: KsSkinControlBars.pas,v 1.1.1.1 2002/08/05 12:12:12 Evgeny Exp $
===============================================================================}
unit KsSkinControlBars;
{$I se_define.inc}
{$T-,W-,X+,P+}
interface
uses
Windows, SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs,
Menus, StdCtrls, ExtCtrls, Buttons, ActnList, Consts, se_controls,
KsSkinVersion, KsSkinObjects, KsSkinSource, KsSkinEngine;
type
TSeSkinControlBar = class(TSeCustomControlBar)
private
FSkinEngine: TSeSkinEngine;
FSkinObject: string;
FSkinBar: TSeSkinObject;
FGrabberWidth: integer;
function GetVersion: TSeSkinVersion;
procedure SetSkinEngine(const Value: TSeSkinEngine);
procedure SetVersion(const Value: TSeSkinVersion);
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 PaintControlFrame(Canvas: TCanvas; AControl: TControl;
var ARect: TRect); override;
procedure PaintBackground; override;
function GetGrabberSize: integer; override;
{ VCL protected }
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
{ Link to TSeSkinEngine component. Specifies the appearance and behavior by using specified skins from TSeSkinEngine components
See Also
TSeSkinEngine
}
property SkinEngine: TSeSkinEngine read FSkinEngine write SetSkinEngine;
{ Specifies the SkinObject name, your can change default value to set custom skin object for the control
For Example:
For TSeSkinButton the SkinObject property set to 'Button', but your can use you own name - example 'My Button'
}
property SkinObject: string read FSkinObject write SetSkinObject;
property Transparent;
property Version: TSeSkinVersion read GetVersion write SetVersion
stored false;
end;
implementation {===============================================================}
{ TSeSkinControlBar }
constructor TSeSkinControlBar.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FSkinObject := 'ControlBar';
end;
destructor TSeSkinControlBar.Destroy;
begin
if FSkinBar <> nil then FSkinBar.Free;
inherited Destroy;
end;
function TSeSkinControlBar.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
(FSkinBar <> nil)
then
Result := true
else
Result := false;
end;
function TSeSkinControlBar.GetGrabberSize: integer;
var
SkinObject: TSeSkinObject;
begin
if (csDestroying in ComponentState) then
Result := inherited GetGrabberSize
else
if FSkinBar <> nil then
Result := FGrabberWidth + 2
else
Result := inherited GetGrabberSize;
end;
procedure TSeSkinControlBar.PaintControlFrame(Canvas: TCanvas; AControl: TControl;
var ARect: TRect);
var
GrabberRect: TRect;
SkinObject: TSeSkinObject;
begin
if not UseSkin then
begin
inherited ;
end
else
begin
GrabberRect := ARect;
InflateRect(GrabberRect, -2, -2);
GrabberRect.Right := GrabberRect.Left + GetGrabberSize;
SkinObject := FSkinBar.FindObjectByName('Frame');
if SkinObject <> nil then
begin
SkinObject.BoundsRect := ARect;
SkinObject.Draw(Canvas);
end;
{ Draw grabber }
SkinObject := FSkinBar.FindObjectByName('Grabber');
if SkinObject <> nil then
begin
SkinObject.BoundsRect := GrabberRect;
SkinObject.Draw(Canvas);
end;
end;
end;
procedure TSeSkinControlBar.PaintBackground;
var
SkinObject: TSeSkinObject;
begin
if not UseSkin then
begin
inherited ;
end
else
begin
SkinObject := FSkinBar.FindObjectByName('Back');
if SkinObject = nil then
SkinObject := FSkinBar;
SkinObject.BoundsRect := Rect(0, 0, FWidth, FHeight);
SkinObject.Draw(Canvas);
end;
end;
procedure TSeSkinControlBar.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = FSkinEngine) then
SkinEngine := nil;
end;
procedure TSeSkinControlBar.WMBeforeChange(var Msg: TMessage);
begin
if Pointer(Msg.LParam) = nil then Exit;
if TSeSkinEngine(Msg.LParam) <> FSkinEngine then Exit;
if FSkinBar <> nil then FSkinBar.Free;
FSkinBar := nil;
end;
procedure TSeSkinControlBar.WMInvalidateSkinObject(var Msg: TMessage);
begin
Invalidate;
end;
procedure TSeSkinControlBar.WMSkinChange(var Msg: TMessage);
begin
if Pointer(Msg.LParam) = nil then Exit;
if TSeSkinEngine(Msg.LParam) <> FSkinEngine then Exit;
SkinEngine := FSkinEngine;
end;
{ Properties }
function TSeSkinControlBar.GetVersion: TSeSkinVersion;
begin
Result := sSeSkinVersion;
end;
procedure TSeSkinControlBar.SetSkinEngine(const Value: TSeSkinEngine);
var
SkinObject: TSeSkinObject;
begin
FSkinEngine := Value;
if (FSkinEngine <> nil) and (FSkinEngine.SkinSource <> nil) and
(not FSkinEngine.SkinSource.IsChanging) and
(FSkinEngine.SkinSource.Count > 0) then
begin
if FSkinBar <> nil then FSkinBar.Free;
FSkinBar := nil;
if FSkinEngine.SkinSource.GetObjectByName(FSkinObject) <> nil then
FSkinBar := FSkinEngine.SkinSource.GetObjectByName(FSkinObject).CreateCopy(nil);
if FSkinBar <> nil then
begin
FSkinBar.ParentControl := Self;
SkinObject := FSkinBar.FindObjectByName('Grabber');
if SkinObject <> nil then
FGrabberWidth := SkinObject.Width;
end;
end
else
begin
if FSkinBar <> nil then FSkinBar.Free;
FSkinBar := nil;
end;
ResetDockItems;
Invalidate;
end;
procedure TSeSkinControlBar.SetVersion(const Value: TSeSkinVersion);
begin
end;
procedure TSeSkinControlBar.SetSkinObject(const Value: string);
begin
FSkinObject := Value;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?