ksskincomboboxs.pas
来自「小区水费管理系统源代码水费收费管理系统 水费收费管理系统」· PAS 代码 · 共 317 行
PAS
317 行
{==============================================================================
SkinEngine's ComboBox
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: KsSkinComboBoxs.pas,v 1.1.1.1 2002/08/05 12:12:12 Evgeny Exp $
===============================================================================}
unit KsSkinComboBoxs;
{$I se_define.inc}
{$T-,W-,X+,P+}
interface
uses
Windows, Classes, Messages, Graphics, Controls, Forms, StdCtrls, ExtCtrls,
se_controls, KsSkinListBoxs, KsSkinVersion, KsSkinObjects, KsSkinSource,
KsSkinEngine;
type
{ TSeSkinComboBox class }
TSeSkinComboBox = class(TSeCustomComboBox)
private
FSkinEngine: TSeSkinEngine;
FSkinObject: string;
FSkinComboBox: TSeSkinObject;
FButtonWidth: 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;
{ Edit }
procedure PaintBorder; override;
procedure PaintBackground(Rect: TRect; Canvas: TCanvas); override;
{ Combo }
procedure BeforeDropDown; override;
function CreateListBox(AOwner: TComponent): TSeCustomListBox; override;
function GetButtonHeight: integer; override;
{ VCL protected }
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Loaded; override;
published
property SkinEngine: TSeSkinEngine read FSkinEngine write SetSkinEngine;
property SkinObject: string read FSkinObject write SetSkinObject;
property Version: TSeSkinVersion read GetVersion write SetVersion
stored false;
end;
implementation {===============================================================}
{ TSeSkinComboBox }
constructor TSeSkinComboBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FSkinObject := 'ComboBox';
end;
destructor TSeSkinComboBox.Destroy;
begin
if FSkinComboBox <> nil then FSkinComboBox.Free;
inherited Destroy;
end;
procedure TSeSkinComboBox.Loaded;
begin
inherited;
end;
function TSeSkinComboBox.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
(FSkinComboBox <> nil)
then
Result := true
else
Result := false;
end;
{ Combo }
procedure TSeSkinComboBox.BeforeDropDown;
begin
inherited;
if ListBox <> nil then
(ListBox as TSeSkinListBox).SkinEngine := SkinEngine;
end;
function TSeSkinComboBox.CreateListBox(AOwner: TComponent): TSeCustomListBox;
begin
Result := TSeSkinListBox.Create(AOwner);
end;
function TSeSkinComboBox.GetButtonHeight: integer;
begin
Result := inherited GetButtonHeight;
if FButtonWidth <> 0 then
Result := FButtonWidth
else
Result := inherited GetButtonHeight;
end;
{ Drawing }
procedure TSeSkinComboBox.PaintBackground(Rect: TRect; Canvas: TCanvas);
var
SkinObject: TSeSkinObject;
DrawState: TSeState;
R: TRect;
begin
if not UseSkin then
begin
inherited ;
Exit;
end;
if not Enabled then
DrawState := ssDisabled
else
if MouseInControl then
DrawState := ssHot
else
if Focused then
DrawState := ssFocused
else
DrawState := ssNormal;
SkinObject := FSkinComboBox.FindObjectByName('Frame');
if SkinObject = nil then SkinObject := FSkinComboBox;
if SkinObject <> nil then
begin
SkinObject.State := DrawState;
if CompareRect(GetBorderRect, Classes.Rect(0, 0, Width, Height)) then
with SkinObject do
SkinObject.BoundsRect := Classes.Rect(-MarginLeft, -MarginTop, FWidth + MarginRight, FHeight + MarginBottom)
else
SkinObject.BoundsRect := Classes.Rect(0, 0, FWidth, FHeight);
SkinObject.Draw(Canvas);
end;
{ Draw Button }
R := GetButtonRect;
if not Enabled then
DrawState := ssDisabled
else
if MouseOnButton then
DrawState := ssHot
else
if Focused then
DrawState := ssFocused
else
DrawState := ssNormal;
SkinObject := FSkinComboBox.FindObjectByName('Button');
if SkinObject <> nil then
begin
SkinObject.State := DrawState;
SkinObject.BoundsRect := R;
SkinObject.Draw(Canvas);
end;
{ Paint Item }
PaintListItem(Rect, Canvas);
end;
procedure TSeSkinComboBox.PaintBorder;
var
SkinObject: TSeSkinObject;
DrawState: TSeState;
begin
if not UseSkin then
begin
inherited ;
Exit;
end;
if not Enabled then
DrawState := ssDisabled
else
if MouseInControl then
DrawState := ssHot
else
if Focused then
DrawState := ssFocused
else
DrawState := ssNormal;
SkinObject := FSkinComboBox.FindObjectByName('Frame');
if SkinObject <> nil then
begin
SkinObject.State := DrawState;
SkinObject.BoundsRect := Rect(0, 0, FWidth, FHeight);
SkinObject.Draw(Canvas);
end;
end;
procedure TSeSkinComboBox.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (Operation = opRemove) and (AComponent = FSkinEngine) then
SkinEngine := nil;
end;
procedure TSeSkinComboBox.WMBeforeChange(var Msg: TMessage);
begin
if Pointer(Msg.LParam) = nil then Exit;
if TSeSkinEngine(Msg.LParam) <> FSkinEngine then Exit;
if FSkinComboBox <> nil then FSkinComboBox.Free;
FSkinComboBox := nil;
end;
procedure TSeSkinComboBox.WMSkinChange(var Msg: TMessage);
begin
if Pointer(Msg.LParam) = nil then Exit;
if TSeSkinEngine(Msg.LParam) <> FSkinEngine then Exit;
SkinEngine := FSkinEngine;
end;
procedure TSeSkinComboBox.WMInvalidateSkinObject(var Msg: TMessage);
begin
Invalidate;
end;
{ Properties }
function TSeSkinComboBox.GetVersion: TSeSkinVersion;
begin
Result := sSeSkinVersion;
end;
procedure TSeSkinComboBox.SetSkinEngine(const Value: TSeSkinEngine);
var
SkinObject: TSeSkinObject;
begin
FSkinEngine := Value;
if ListBox <> nil then
(ListBox as TSeSkinListBox).SkinEngine := SkinEngine;
if (FSkinEngine <> nil) and (FSkinEngine.SkinSource <> nil) and
(not FSkinEngine.SkinSource.IsChanging) and
(FSkinEngine.SkinSource.Count > 0) then
begin
if FSkinComboBox <> nil then FSkinComboBox.Free;
FSkinComboBox := nil;
if FSkinEngine.SkinSource.GetObjectByName(FSkinObject) <> nil then
FSkinComboBox := FSkinEngine.SkinSource.GetObjectByName(FSkinObject).CreateCopy(nil);
if FSkinComboBox <> nil then
begin
FSkinComboBox.ParentControl := Self;
{ Set Font }
if FSkinComboBox.FindObjectByName('Text') <> nil then
begin
SkinObject := FSkinComboBox.FindObjectByName('Text');
Self.Font := SkinObject.Font;
end
else
Self.Font := FSkinComboBox.Font;
if FSkinComboBox.FindObjectByName('Button') <> nil then
FButtonWidth := FSkinComboBox.FindObjectByName('Button').Width;
end;
end
else
begin
if FSkinComboBox <> nil then FSkinComboBox.Free;
FSkinComboBox := nil;
end;
Invalidate;
end;
procedure TSeSkinComboBox.SetVersion(const Value: TSeSkinVersion);
begin
end;
procedure TSeSkinComboBox.SetSkinObject(const Value: string);
begin
FSkinObject := Value;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?