⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdclasses.pas

📁 DELPHI皮肤,让你的界面更精典. 可以自己画皮肤,运行速度更快.
💻 PAS
字号:
unit GdClasses;

interface
uses Classes,Types,Dialogs,SysUtils;

type
  TGDRegion=class;

  TGDRegionLink=class(TPersistent)
  private
    FRegion:TGDRegion;
    FChangeEvent:TNotifyEvent;
    procedure SetRegtion(Value: TGDRegion);
  protected
    procedure Change;virtual;
  public
    property Region:TGDRegion read FRegion write SetRegtion;
    property OnChange:TNotifyEvent read FChangeEvent write FChangeEvent;
  end;

  TGdRegion=Class(TComponent)
  private
    FList:TList;
    FLeft,FTop,FWidth,FHeight:Integer;
    procedure SetRegion(const Index, Value: Integer);
    function GetHeight: Integer;
    function GetWidth: Integer;
  protected
    procedure AddRegionLink(Value:TGDRegionLink);
    procedure RemoveRegionLink(Value:TGDRegionLink);
    procedure RegionChange;virtual;
  public
    constructor Create(AOwner:TComponent);override;
    destructor Destroy;override;
    function GetRect:TRect;
    function IsEmpty:Boolean;
  published
    property Left:Integer index 0 read FLeft write SetRegion;
    property Top:Integer index 1 read FTop write SetRegion;
    property Rigth:Integer index 2 read FWidth write SetRegion;
    property Bottom:Integer index 3 read FHeight write SetRegion;
    property Width:Integer read GetWidth;
    property Height:Integer read GetHeight;
  end;

//procedure Register;

implementation
{
procedure Register;
begin
  RegisterComponents('GDSkin', [TGdRegion]);
end;
}
procedure TGdRegion.AddRegionLink(Value: TGDRegionLink);
begin
  FList.Add(Value);
  Value.FRegion:=Self;
end;

constructor TGdRegion.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FList:=TList.Create;
end;

destructor TGdRegion.Destroy;
begin
  FList.Free;
  inherited;
end;

function TGdRegion.GetHeight: Integer;
begin
  Result:=Abs(Bottom-Top);
end;

function TGdRegion.GetRect: TRect;
begin
  Result:=Rect(Left,Top,Rigth,Bottom);
end;

function TGdRegion.GetWidth: Integer;
begin
  Result:=Abs(Rigth-Left);
end;

function TGdRegion.IsEmpty: Boolean;
begin
  Result:=(FWidth=0) or (FHeight=0);
end;

procedure TGdRegion.RegionChange;
var
  i:Integer;
begin
  for i:=0 to FList.Count-1 do
  begin
    TGDRegionLink(FList.Items[i]).Change;
  end;
end;

procedure TGdRegion.RemoveRegionLink(Value: TGDRegionLink);
begin
  Value.FRegion:=Nil;
  FList.Remove(Value);
end;

procedure TGdRegion.SetRegion(const Index, Value: Integer);
var
  AValue:^Integer;
begin
  case Index of
    0:AValue:=@FLeft;
    1:AValue:=@FTop;
    2:AValue:=@FWidth;
    3:AValue:=@FHeight;
  end;
  if AValue^<>Value then
  begin
    AValue^:=Value;
    RegionChange;
  end;
end;

{ TGDRegionLink }

procedure TGDRegionLink.Change;
begin
  if Assigned(FChangeEvent) then FChangeEvent(Self);
end;

procedure TGDRegionLink.SetRegtion(Value: TGDRegion);
begin
  if Value<>FRegion then
  begin
    if FRegion<>Nil then FRegion.RemoveRegionLink(Self);
    if Value<>Nil then Value.AddRegionLink(Self);
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -