ksskinobjects2.pas
来自「小区水费管理系统源代码水费收费管理系统 水费收费管理系统」· PAS 代码 · 共 1,638 行 · 第 1/3 页
PAS
1,638 行
procedure TSeColorButtonObject.SetHotFont(const Value: TFont);
begin
FHotFont.Assign(Value);
end;
procedure TSeColorButtonObject.SetPressedColor(const Value: TColor);
begin
FPressedColor := Value;
end;
procedure TSeColorButtonObject.SetPressedFont(const Value: TFont);
begin
FPressedFont.Assign(Value);
end;
{ TSeBitmapBoxObject ==========================================================}
constructor TSeBitmapBoxObject.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
procedure TSeBitmapBoxObject.Assign(Source: TPersistent);
begin
if Source is TSeBitmapBoxObject then
begin
inherited Assign(Source);
BorderTileStyle := (Source as TSeBitmapBoxObject).FBorderTileStyle;
end
else
inherited;
end;
destructor TSeBitmapBoxObject.Destroy;
begin
inherited Destroy;
end;
procedure TSeBitmapBoxObject.DrawRect(Canvas: TCanvas; MarginRect, MarginDstRect: TRect;
ATileStyle: TscTileStyle);
var
DstRect, R: TRect;
i, j: integer;
W, H: integer;
DW, DH: integer;
begin
W := RectWidth(MarginRect);
H := RectHeight(MarginRect);
if W * H = 0 then Exit;
case ATileStyle of
tsTile: begin
OffsetRect(MarginDstRect, Left, Top);
FBitmap.Bitmap.DrawTile(Canvas, MarginDstRect, MarginRect, Masked);
end;
tsStretch: begin
OffsetRect(MarginDstRect, Left, Top);
FBitmap.Bitmap.Draw(Canvas, MarginDstRect, MarginRect, Masked);
end;
tsCenter: begin
R := BoundsRect;
FBitmap.Bitmap.Draw(Canvas, Left + (Width - RectWidth(R)) div 2,
Top + (Height - RectHeight(R)) div 2, MarginRect, Masked);
end;
end;
end;
procedure TSeBitmapBoxObject.Draw(Canvas: TCanvas);
var
SrcRect, DstRect: TRect;
begin
if not FBitmap.Assigned then Exit;
if Width <= 0 then Exit;
if Height <= 0 then Exit;
if (MarginLeft = 0) and (MarginTop = 0) and
(MarginRight = 0) and (MarginBottom = 0) then
begin
inherited Draw(Canvas);
Exit;
end;
{ Draw Face }
{ Draw Center Rect }
with FBitmap.Rect do
SrcRect := Rect(Left + MarginLeft, Top + MarginTop, Right - MarginRight,
Bottom - MarginBottom);
DstRect := Rect(MarginLeft, MarginTop, Width - MarginRight, Height - MarginBottom);
DrawRect(Canvas, SrcRect, DstRect, FTileStyle);
{ Draw Top Border }
with FBitmap.Rect do
SrcRect := Rect(Left + MarginLeft, Top, Right - MarginRight,
Top + MarginTop);
DstRect := Rect(MarginLeft, 0, Width - MarginRight, MarginTop);
DrawRect(Canvas, SrcRect, DstRect, FBorderTileStyle);
{ Draw Bottom Border }
with FBitmap.Rect do
SrcRect := Rect(Left + MarginLeft, Bottom - MarginBottom, Right - MarginRight,
Bottom);
DstRect := Rect(MarginLeft, Height - MarginBottom, Width - MarginRight, Height);
DrawRect(Canvas, SrcRect, DstRect, FBorderTileStyle);
{ Draw Left Border }
with FBitmap.Rect do
SrcRect := Rect(Left, Top + MarginTop, Left + MarginLeft,
Bottom - MarginBottom);
DstRect := Rect(0, MarginTop, MarginLeft, Height - MarginBottom);
DrawRect(Canvas, SrcRect, DstRect, FBorderTileStyle);
{ Draw Right Border }
with FBitmap.Rect do
SrcRect := Rect(Right - MarginRight, Top + MarginTop, Right,
Bottom - MarginBottom);
DstRect := Rect(Width - MarginRight, MarginTop, Width,
Height - MarginBottom);
DrawRect(Canvas, SrcRect, DstRect, FBorderTileStyle);
{ Draw Angles }
with FBitmap.Rect do
SrcRect := Rect(Left, Top, Left + MarginLeft, Top + MarginTop);
FBitmap.Bitmap.Draw(Canvas, Left, Top, SrcRect, Masked);
with FBitmap.Rect do
SrcRect := Rect(Right - MarginRight, Top, Right, Top + MarginTop);
FBitmap.Bitmap.Draw(Canvas, Left + Width - MarginRight, Top, SrcRect, Masked);
with FBitmap.Rect do
SrcRect := Rect(Left, Bottom - MarginBottom, Left + MarginLeft, Bottom);
FBitmap.Bitmap.Draw(Canvas, Left, Top + Height - MarginBottom, SrcRect, Masked);
with FBitmap.Rect do
SrcRect := Rect(Right - MarginRight, Bottom - MarginBottom, Right, Bottom);
FBitmap.Bitmap.Draw(Canvas, Left + Width - MarginRight,
Top + Height - MarginBottom, SrcRect, Masked);
{ Draw Text }
DrawObjectText(Canvas);
end;
procedure TSeBitmapBoxObject.MouseHover;
begin
inherited;
end;
procedure TSeBitmapBoxObject.MouseLeave;
begin
inherited;
end;
procedure TSeBitmapBoxObject.SetBorderTileStyle(const Value: TscTileStyle);
begin
FBorderTileStyle := Value;
end;
{ TSeActiveBitmapBoxObject ====================================================}
constructor TSeActiveBitmapBoxObject.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FFocusedBitmap := TSeBitmapLink.Create;
end;
destructor TSeActiveBitmapBoxObject.Destroy;
begin
FFocusedBitmap.Free;
inherited Destroy;
end;
procedure TSeActiveBitmapBoxObject.AfterLoad;
var
NewLink: TSeBitmapLink;
begin
inherited AfterLoad;
if Bitmaps <> nil then
begin
{ Focused }
NewLink := Bitmaps.GetBitmapLink(FFocusedBitmap.Name, FFocusedBitmap.Rect);
if NewLink <> nil then
begin
FFocusedBitmap.Free;
FFocusedBitmap := NewLink;
end;
end;
end;
procedure TSeActiveBitmapBoxObject.Assign(Source: TPersistent);
begin
if Source is TSeActiveBitmapBoxObject then
begin
inherited Assign(Source);
FocusedBitmap := (Source as TSeActiveBitmapBoxObject).FocusedBitmap;
end
else
inherited;
end;
procedure TSeActiveBitmapBoxObject.Draw(Canvas: TCanvas);
var
SaveBitmap: TSeBitmapLink;
begin
if not FBitmap.Assigned then Exit;
if Width <= 0 then Exit;
if Height <= 0 then Exit;
if ((State = ssFocused) or (State = ssHot)) and (FFocusedBitmap.Assigned) then
begin
SaveBitmap := FBitmap;
try
FBitmap := FFocusedBitmap;
inherited Draw(Canvas);
finally
FBitmap := SaveBitmap;
end;
end
else
inherited Draw(Canvas);
end;
procedure TSeActiveBitmapBoxObject.SetFocusedBitmap(
const Value: TSeBitmapLink);
begin
FFocusedBitmap.Assign(Value);
end;
{ TSeButtonBitmapBoxObject ====================================================}
constructor TSeButtonBitmapBoxObject.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FFocusedBitmap := TSeBitmapLink.Create;
FHotBitmap := TSeBitmapLink.Create;
FPressedBitmap := TSeBitmapLink.Create;
FDisabledBitmap := TSeBitmapLink.Create;
end;
destructor TSeButtonBitmapBoxObject.Destroy;
begin
FFocusedBitmap.Free;
FHotBitmap.Free;
FPressedBitmap.Free;
FDisabledBitmap.Free;
inherited Destroy;
end;
procedure TSeButtonBitmapBoxObject.AfterLoad;
var
NewLink: TSeBitmapLink;
begin
inherited AfterLoad;
if Bitmaps <> nil then
begin
{ Focused }
NewLink := Bitmaps.GetBitmapLink(FFocusedBitmap.Name, FFocusedBitmap.Rect);
if NewLink <> nil then
begin
FFocusedBitmap.Free;
FFocusedBitmap := NewLink;
end;
{ Hot }
NewLink := Bitmaps.GetBitmapLink(FHotBitmap.Name, FHotBitmap.Rect);
if NewLink <> nil then
begin
FHotBitmap.Free;
FHotBitmap := NewLink;
end;
{ Pressed }
NewLink := Bitmaps.GetBitmapLink(FPressedBitmap.Name, FPressedBitmap.Rect);
if NewLink <> nil then
begin
FPressedBitmap.Free;
FPressedBitmap := NewLink;
end;
{ Disabled }
NewLink := Bitmaps.GetBitmapLink(FDisabledBitmap.Name, FDisabledBitmap.Rect);
if NewLink <> nil then
begin
FDisabledBitmap.Free;
FDisabledBitmap := NewLink;
end;
end;
end;
procedure TSeButtonBitmapBoxObject.Assign(Source: TPersistent);
begin
if Source is TSeButtonBitmapBoxObject then
begin
inherited Assign(Source);
FocusedBitmap := (Source as TSeButtonBitmapBoxObject).FocusedBitmap;
HotBitmap := (Source as TSeButtonBitmapBoxObject).HotBitmap;
DisabledBitmap := (Source as TSeButtonBitmapBoxObject).DisabledBitmap;
PressedBitmap := (Source as TSeButtonBitmapBoxObject).PressedBitmap;
end
else
inherited;
end;
procedure TSeButtonBitmapBoxObject.Draw(Canvas: TCanvas);
var
SaveBitmap: TSeBitmapLink;
begin
if not FBitmap.Assigned then Exit;
if Width <= 0 then Exit;
if Height <= 0 then Exit;
if (State = ssFocused) and (FFocusedBitmap.Assigned) then
begin
SaveBitmap := FBitmap;
try
FBitmap := FFocusedBitmap;
inherited Draw(Canvas);
finally
FBitmap := SaveBitmap;
end;
Exit;
end;
if (State = ssHot) and (FHotBitmap.Assigned) then
begin
SaveBitmap := FBitmap;
try
FBitmap := FHotBitmap;
inherited Draw(Canvas);
finally
FBitmap := SaveBitmap;
end;
Exit;
end;
if (State = ssDisabled) and (FDisabledBitmap.Assigned) then
begin
SaveBitmap := FBitmap;
try
FBitmap := FDisabledBitmap;
inherited Draw(Canvas);
finally
FBitmap := SaveBitmap;
end;
Exit;
end;
if (State = ssPressed) and (FPressedBitmap.Assigned) then
begin
SaveBitmap := FBitmap;
try
FBitmap := FPressedBitmap;
inherited Draw(Canvas);
finally
FBitmap := SaveBitmap;
end;
Exit;
end;
inherited Draw(Canvas);
end;
procedure TSeButtonBitmapBoxObject.SetDisabledBitmap(const Value: TSeBitmapLink);
begin
FDisabledBitmap.Assign(Value);
end;
procedure TSeButtonBitmapBoxObject.SetFocusedBitmap(const Value: TSeBitmapLink);
begin
FFocusedBitmap.Assign(Value);
end;
procedure TSeButtonBitmapBoxObject.SetHotBitmap(const Value: TSeBitmapLink);
begin
FHotBitmap.Assign(Value);
end;
procedure TSeButtonBitmapBoxObject.SetPressedBitmap(const Value: TSeBitmapLink);
begin
FPressedBitmap.Assign(Value);
end;
{ TSeRollPanelObject }
constructor TSeRollPanelObject.Create(AOwner: TComponent);
begin
inherited;
end;
destructor TSeRollPanelObject.Destroy;
begin
inherited Destroy;
end;
procedure TSeRollPanelObject.Assign(Source: TPersistent);
begin
if Source is TSeRollPanelObject then
begin
inherited Assign(Source);
RollKind := (Source as TSeRollPanelObject).RollKind;
RollValue := (Source as TSeRollPanelObject).RollValue;
end
else
inherited;
end;
procedure TSeRollPanelObject.OwnerUpdate;
var
SkinForm: TSeSkinForm;
begin
if Owner = nil then Exit;
SkinForm := TSeSkinForm(GetSkinForm);
Application.ProcessMessages;
end;
procedure TSeRollPanelObject.Roll;
const
Percent = 1;
var
RollUp: boolean;
OwnerObject: TSeSkinObject;
i: integer;
TmpValue: integer;
begin
if Owner = nil then Exit;
case FRollKind of
rkLeft, rkRight:
if Width = FRollValue then
RollUp := false
else
RollUp := true;
rkTop, rkBottom:
if Height = FRollValue then
RollUp := false
else
RollUp := true;
end;
if RollUp then
begin
{ RollUp }
case FRollKind of
rkLeft: begin
FOldValue := Width;
TmpValue := Left + Width;
for i := 1 to Percent do
begin
Width := Width + Round((FRollValue - Width) * (i / Percent));
Left := TmpValue - Width;
OwnerUpdate;
end;
end;
rkRight: begin
FOldValue := Width;
for i := 1 to Percent do
begin
Width := Width + Round((FRollValue - Width) * (i / Percent));
OwnerUpdate;
end;
end;
rkTop: begin
FOldValue := Height;
TmpValue := Top + Height;
for i := 1 to Percent do
begin
Height := Height + Round((FRollValue - Height) * (i / Percent));
Top := TmpValue - Height;
OwnerUpdate;
end;
end;
rkBottom: begin
FOldValue := Height;
for i := 1 to Percent do
begin
Height := Height + Round((FRollValue - Height) * (i / Percent));
OwnerUpdate;
end;
end;
end;
end
else
begin
{ Restore }
case FRollKind of
rkLeft: begin
TmpValue := Left + Width;
for i := 1 to Percent do
begin
Width := Width - Round((Width - FOldValue) * (i / Percent));
Left := TmpValue - Width;
OwnerUpdate;
end;
end;
rkRight: begin
for i := 1 to Percent do
begin
Width := Width - Round((Width - FOldValue) * (i / Percent));
OwnerUpdate;
end;
end;
rkTop: begin
TmpValue := Top + Height;
for i := 1 to Percent do
begin
Height := Height - Round((Height - FOldValue) * (i / Percent));
Top := TmpValue - Height;
OwnerUpdate;
end;
end;
rkBottom: begin
for i := 1 to Percent do
begin
Height := Height - Round((Height - FOldValue) * (i / Percent));
OwnerUpdate;
end;
end;
end;
end;
end;
initialization
RegisterSkinObject(TSeLinkSkinObject);
RegisterSkinObject(TSeBitmapSkinObject);
RegisterSkinObject(TSeFormBitmapSkinObject);
RegisterSkinObject(TSeSysButtonSkinObject);
RegisterSkinObject(TSeActiveSkinObject);
RegisterSkinObject(TSeColorButtonObject);
RegisterSkinObject(TSeBitmapBoxObject);
RegisterSkinObject(TSeActiveBitmapBoxObject);
RegisterSkinObject(TSeButtonBitmapBoxObject);
RegisterSkinObject(TSeRollPanelObject);
finalization
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?