📄 dynamicskinform.pas
字号:
FSupportChildMenus: Boolean;
DSF: TspDynamicSkinForm;
IsDrag: Boolean;
DX, TabDX: Integer;
FDown: Boolean;
DragIndex: Integer;
FOnTabMouseEnter: TspMDITabMouseEnterEvent;
FOnTabMouseLeave: TspMDITabMouseLeaveEvent;
FOnTabMouseUp: TspMDITabMouseUpEvent;
FOnTabMouseDown: TspMDITabMouseDownEvent;
FDefaultTabWidth: Integer;
FDefaultHeight: Integer;
FDefaultFont: TFont;
ActiveTabIndex, OldTabIndex: Integer;
FMoveTabs: Boolean;
FUseSkinSize: Boolean;
FUseSkinFont: Boolean;
procedure SetDefaultHeight(Value: Integer);
procedure SetDefaultFont(Value: TFont);
procedure CalcObjectRects;
procedure TestActive(X, Y: Integer);
procedure CheckActive;
procedure SetTabKind(Value: TspSkinMDITabKind);
protected
procedure CreateControlDefaultImage(B: TBitMap); override;
procedure CreateControlSkinImage(B: TBitMap); override;
procedure ClearObjects;
procedure GetSkinData; override;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
function GetMoveIndex: Integer;
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
public
ObjectList: TList;
Picture: TBitMap;
TabRect, ActiveTabRect, MouseInTabRect: TRect;
TabsBGRect: TRect;
TabLeftOffset, TabRightOffset: Integer;
FontName: String;
FontStyle: TFontStyles;
FontHeight: Integer;
FontColor, ActiveFontColor, MouseInFontColor: TColor;
UpDown: String;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetTab(X, Y: Integer): TspMDITab;
function GetTabIndex(X, Y: Integer): Integer;
procedure AddTab(Child: TCustomForm);
procedure DeleteTab(Child: TCustomForm);
procedure ChangeSkinData; override;
published
property TabKind: TspSkinMDITabKind read FTabKind write SetTabKind;
property DynamicSkinForm: TspDynamicSkinForm read DSF write DSF;
property SupportChildMenus: Boolean
read FSupportChildMenus write FSupportChildMenus;
property UseSkinSize: Boolean read FUseSkinSize write FUseSkinSize;
property UseSkinFont: Boolean read FUseSkinFont write FUseSkinFont;
property MoveTabs: Boolean read FMoveTabs write FMoveTabs;
property DefaultHeight: Integer read FDefaultHeight write SetDefaultHeight;
property DefaultFont: TFont read FDefaultFont write SetDefaultFont;
property DefaultTabWidth: Integer read FDefaultTabWidth write FDefaultTabWidth;
property Align;
property PopupMenu;
property DockSite;
property DragCursor;
property DragKind;
property DragMode;
property Enabled;
property ParentShowHint;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnTabMouseEnter: TspMDITabMouseEnterEvent
read FOnTabMouseEnter write FOnTabMouseEnter;
property OnTabMouseLeave: TspMDITabMouseLeaveEvent
read FOnTabMouseLeave write FOnTabMouseLeave;
property OnTabMouseUp: TspMDITabMouseUpEvent
read FOnTabMouseUp write FOnTabMouseUp;
property OnTabMouseDown: TspMDITabMouseDownEvent
read FOnTabMouseDown write FOnTabMouseDown;
property OnCanResize;
property OnClick;
property OnConstrainedResize;
property OnDockDrop;
property OnDockOver;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
property OnContextPopup;
end;
function GetDynamicSkinFormComponent(AForm: TCustomForm): TspDynamicSkinForm;
function GetMDIChildDynamicSkinFormComponent: TspDynamicSkinForm;
function GetMDIChildDynamicSkinFormComponent2: TspDynamicSkinForm;
implementation
Uses spConst;
type
PAreaInfo = ^TAreaInfo;
TAreaInfo = record
Control: TControl;
AreaRect: TRect;
end;
const
WS_EX_LAYERED = $80000;
InActiveBrightnessKf = 0.5;
InActiveDarknessKf = 0.3;
InActiveNoiseAmount = 50;
MorphInc = 0.2;
MouseTimerInterval = 50;
MorphTimerInterval = 20;
AnimateTimerInterval = 25;
HTNCACTIVE = HTOBJECT;
TRACKMARKEROFFSET = 5;
DEFCAPTIONHEIGHT = 19;
DEFBUTTONSIZE = 17;
DEFTOOLCAPTIONHEIGHT = 15;
DEFTOOLBUTTONSIZE = 13;
DEFFORMMINWIDTH = 130;
TMI_RESTORENAME = 'TRAY_DSF_RESTORE';
TMI_CLOSENAME = 'TRAY_DSF_CLOSE';
MI_MINNAME = 'DSF_MINITEM';
MI_MAXNAME = 'DSF_MAXITEM';
MI_CLOSENAME = 'DSF_CLOSE';
MI_RESTORENAME = 'DSF_RESTORE';
MI_MINTOTRAYNAME = 'DSF_MINTOTRAY';
MI_ROLLUPNAME = 'DSF_ROLLUP';
MI_CHILDITEM = '_DSFCHILDITEM';
WM_MDICHANGESIZE = WM_USER + 206;
WM_MDICHILDMAX = WM_USER + 207;
WM_MDICHILDRESTORE = WM_USER + 208;
function GetDynamicSkinFormComponent;
var
i: Integer;
begin
Result := nil;
for i := 0 to AForm.ComponentCount - 1 do
if AForm <> nil then
if AForm.Components[i] is TspDynamicSkinForm
then
begin
Result := (AForm.Components[i] as TspDynamicSkinForm);
Break;
end;
end;
function GetMDIChildDynamicSkinFormComponent;
var
i: Integer;
begin
Result := nil;
for i := 0 to Application.MainForm.MDIChildCount - 1 do
begin
Result := GetDynamicSkinFormComponent(Application.MainForm.MDIChildren[i]);
if (Result <> nil) and (Result.WindowState = wsMaximized)
then
Break
else
Result := nil;
end;
end;
function GetMDIChildDynamicSkinFormComponent2;
begin
if (Application.MainForm <> nil) and (Application.MainForm.ActiveMDIChild <> nil)
then
Result := GetDynamicSkinFormComponent(Application.MainForm.ActiveMDIChild)
else
Result := nil;
end;
//============= TbsSkinComponent ============= //
constructor TspSkinComponent.Create(AOwner: TComponent);
begin
inherited;
FSkinData := nil;
end;
procedure TspSkinComponent.SetSkinData(Value: TspSkinData);
begin
FSkinData := Value;
end;
procedure TspSkinComponent.Notification;
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FSkinData) then FSkinData := nil;
end;
procedure TspSkinComponent.BeforeChangeSkinData;
begin
end;
procedure TspSkinComponent.ChangeSkinData;
begin
end;
//============= TspActiveSkinObject =============//
constructor TspActiveSkinObject.Create;
begin
Parent := AParent;
SD := Parent.SkinData;
Enabled := True;
Visible := True;
FMorphKf := 0;
if AData <> nil
then
begin
with AData do
begin
Self.IDName := IDName;
Self.Hint := Hint;
Self.SkinRectInAPicture := SkinRectInAPicture;
Self.SkinRect := SkinRect;
Self.ActiveSkinRect := ActiveSkinRect;
Self.InActiveSkinRect:= InActiveSkinRect;
Self.Morphing := Morphing;
Self.MorphKind := MorphKind;
Self.CursorIndex := CursorIndex;
Self.RollUp := RollUp;
if (ActivePictureIndex <> - 1) and
(ActivePictureIndex < SD.FActivePictures.Count)
then
ActivePicture := TBitMap(SD.FActivePictures.Items[ActivePictureIndex])
else
begin
ActivePicture := nil;
ActiveSkinRect := NullRect;
end;
end;
ObjectRect := SkinRect;
if RollUp then Picture := SD.FRollUpPicture else Picture := SD.FPicture;
end;
end;
function TspActiveSkinObject.EnableMorphing: Boolean;
begin
Result := Morphing and (Parent.SkinData <> nil) and
Parent.SkinData.EnableSkinEffects;
end;
procedure TspActiveSkinObject.ReDraw;
begin
if EnableMorphing
then Parent.MorphTimer.Enabled := True
else Parent.DrawSkinObject(Self);
end;
procedure TspActiveSkinObject.DblClick;
begin
end;
procedure TspActiveSkinObject.MouseDown(X, Y: Integer; Button: TMouseButton);
begin
Parent.MouseDownEvent(IDName, X, Y, ObjectRect, Button);
end;
procedure TspActiveSkinObject.MouseUp(X, Y: Integer; Button: TMouseButton);
begin
if FMouseIn then Parent.MouseUpEvent(IDName, X, Y, ObjectRect, Button);
end;
procedure TspActiveSkinObject.MouseMove(X, Y: Integer);
begin
Parent.MouseMoveEvent(IDName, X, Y, ObjectRect);
end;
procedure TspActiveSkinObject.MouseEnter;
begin
FMouseIn := True;
Active := True;
if not IsNullRect(ActiveSkinRect) then ReDraw;
Parent.MouseEnterEvent(IDName);
end;
procedure TspActiveSkinObject.MouseLeave;
begin
FMouseIn := False;
Active := False;
if not IsNullRect(ActiveSkinRect) then ReDraw;
Parent.MouseLeaveEvent(IDName);
end;
function TspActiveSkinObject.CanMorphing;
begin
Result := (Active and (MorphKf < 1)) or
(not Active and (MorphKf > 0));
end;
procedure TspActiveSkinObject.DoMorphing;
begin
if Active
then MorphKf := MorphKf + MorphInc
else MorphKf := MorphKf - MorphInc;
Parent.DrawSkinObject(Self);
end;
procedure TspActiveSkinObject.Draw;
procedure CreateObjectImage(B: TBitMap; AActive: Boolean);
begin
B.Width := RectWidth(ObjectRect);
B.Height := RectHeight(ObjectRect);
with B.Canvas do
begin
if AActive
then
CopyRect(Rect(0, 0, B.Width, B.Height), ActivePicture.Canvas, ActiveSkinRect)
else
if SkinRectInApicture
then
CopyRect(Rect(0, 0, B.Width, B.Height), ActivePicture.Canvas, SkinRect)
else
CopyRect(Rect(0, 0, B.Width, B.Height), Picture.Canvas, SkinRect);
end;
end;
var
PBuffer, APBuffer: TspEffectBmp;
Buffer, ABuffer: TBitMap;
ASR, SR: TRect;
begin
ASR := ActiveSkinRect;
SR := SkinRect;
if Enabled and (not Parent.GetFormActive) and (not IsNullRect(InActiveSkinRect))
then
begin
Cnvs.CopyRect(ObjectRect, ActivePicture.Canvas, InActiveSkinRect)
end
else
if not EnableMorphing or
((Active and (MorphKf = 1)) or (not Active and (MorphKf = 0)))
then
begin
if Active and not IsNullRect(ASR)
then
Cnvs.CopyRect(ObjectRect, ActivePicture.Canvas, ASR)
else
if UpDate or SkinRectInApicture
then
begin
if SkinRectInApicture
then
Cnvs.CopyRect(ObjectRect, ActivePicture.Canvas, SR)
else
Cnvs.CopyRect(ObjectRect, Picture.Canvas, SR);
end;
end
else
begin
Buffer := TBitMap.Create;
ABuffer := TBitMap.Create;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -