📄 dynamicskinform.pas
字号:
{*******************************************************************}
{ }
{ Almediadev Visual Component Library }
{ DynamicSkinForm }
{ Version 9.15 }
{ }
{ Copyright (c) 2000-2008 Almediadev }
{ ALL RIGHTS RESERVED }
{ }
{ Home: http://www.almdev.com }
{ Support: support@almdev.com }
{ }
{*******************************************************************}
Unit DynamicSkinForm;
{$P+,S-,W-,R-}
{$WARNINGS OFF}
{$HINTS OFF}
//{$DEFINE TNTUNICODE}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, SkinData, Menus, SkinMenus, SkinCtrls, spUtils, spEffBmp, SkinTabs,
SkinBoxCtrls, spTrayIcon, SkinHint, SkinExCtrls;
type
TspBorderIcon = (biSystemMenu, biMinimize, biMaximize, biRollUp, biMinimizeToTray);
TspBorderIcons = set of TspBorderIcon;
TTrackBarChangeValueEvent = procedure(IDName: String; Value: Integer)
of object;
TFrameRegulatorChangeValueEvent = procedure(IDName: String; Value: Integer)
of object;
TSwitchState = (swsOn, swsOff);
TSwitchChangeStateEvent = procedure(IDName: String;
State: TSwitchState) of object;
TPaintEvent = procedure (IDName: String; Canvas: TCanvas;
ObjectRect: TRect) of object;
TspCaptionPaintEvent = procedure (Cnvs: TCanvas; R: TRect; AActive: Boolean) of object;
TMouseEnterEvent = procedure (IDName: String) of object;
TMouseLeaveEvent = procedure (IDName: String) of object;
TMainMenuItemClick = procedure (IDName: String) of object;
TspMouseUpEvent = procedure (IDName: String;
X, Y: Integer; ObjectRect: TRect;
Button: TMouseButton) of object;
TMouseDownEvent = procedure (IDName: String;
X, Y: Integer; ObjectRect: TRect;
Button: TMouseButton) of object;
TMouseMoveEvent = procedure (IDName: String; X, Y: Integer;
ObjectRect: TRect) of object;
TChangeClientRectEvent = procedure(NewClientRect: TRect) of object;
TspActivateCustomObjectEvent = procedure (IDName: String; var ObjectVisible: Boolean) of object;
TspDynamicSkinForm = class;
TspSkinComponent = class (TComponent)
protected
FSkinData: TspSkinData;
procedure SetSkinData(Value: TspSkinData); virtual;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
procedure BeforeChangeSkinData; virtual;
procedure ChangeSkinData; virtual;
published
property SkinData: TspSkinData read FSkinData write SetSkinData;
end;
TspActiveSkinObject = class(TObject)
protected
Parent: TspDynamicSkinForm;
FMorphKf: Double;
FMouseIn: Boolean;
Picture, ActivePicture: TBitMap;
procedure SetMorphKf(Value: Double);
procedure Redraw;
public
SD: TspSkinData;
IDName: String;
Hint: String;
SkinRect: TRect;
ActiveSkinRect: TRect;
InActiveSkinRect: TRect;
Morphing: Boolean;
MorphKind: TMorphKind;
ObjectRect: TRect;
Active: Boolean;
Enabled: Boolean;
CursorIndex: Integer;
RollUp: Boolean;
Visible: Boolean;
SkinRectInAPicture: Boolean;
function EnableMorphing: Boolean;
constructor Create(AParent: TspDynamicSkinForm; AData: TspDataSkinObject);
procedure Draw(Cnvs: TCanvas; UpDate: Boolean); virtual;
procedure DblClick; virtual;
procedure MouseDown(X, Y: Integer; Button: TMouseButton); virtual;
procedure MouseUp(X, Y: Integer; Button: TMouseButton); virtual;
procedure MouseMove(X, Y: Integer); virtual;
procedure MouseEnter; virtual;
procedure MouseLeave; virtual;
function CanMorphing: Boolean; virtual;
procedure DoMorphing;
property MorphKf: Double read FMorphKf write SetMorphKf;
end;
TspUserObject = class(TspActiveSkinObject)
public
procedure Draw(Cnvs: TCanvas; UpDate: Boolean); override;
end;
TspSkinFrameObject = class(TspActiveSkinObject)
protected
FFrame: Integer;
FrameW, FrameH: Integer;
procedure SetFrame(Value: Integer);
public
CountFrames: Integer;
FramesPlacement: TFramesPlacement;
constructor Create(AParent: TspDynamicSkinForm;
AData: TspDataSkinObject);
procedure Draw(Cnvs: TCanvas; UpDate: Boolean); override;
property Frame: Integer read FFrame write SetFrame;
end;
TspSkinFrameGaugeObject = class(TspSkinFrameObject)
protected
FValue: Integer;
function CalcFrame: Integer;
procedure SetValue(AValue: Integer);
public
MinValue: Integer;
MaxValue: Integer;
constructor Create(AParent: TspDynamicSkinForm;
AData: TspDataSkinObject);
procedure Draw(Cnvs: TCanvas; UpDate: Boolean); override;
procedure SimplySetValue(AValue: Integer);
procedure MouseEnter; override;
procedure MouseLeave; override;
property Value: Integer read FValue write SetValue;
end;
TspSkinFrameRegulatorObject = class(TspSkinFrameObject)
protected
FPixInc, FValInc: Integer;
FDown: Boolean;
StartV, CurV, TempValue, OldCurV: Integer;
FValue: Integer;
function CalcFrame: Integer;
procedure SetValue(AValue: Integer);
procedure CalcValue;
procedure CalcRoundValue;
function GetRoundValue(X, Y: Integer): Integer;
public
MinValue: Integer;
MaxValue: Integer;
Kind: TRegulatorKind;
constructor Create(AParent: TspDynamicSkinForm;
AData: TspDataSkinObject);
procedure Draw(Cnvs: TCanvas; UpDate: Boolean); override;
procedure SimplySetValue(AValue: Integer);
procedure MouseDown(X, Y: Integer; Button: TMouseButton); override;
procedure MouseUp(X, Y: Integer; Button: TMouseButton); override;
procedure MouseMove(X, Y: Integer); override;
property Value: Integer read FValue write SetValue;
end;
TspSkinAnimateObject = class(TspActiveSkinObject)
protected
FMenuTracking: Boolean;
FFrame: Integer;
FInc: Integer;
TimerInterval: Integer;
MenuItem: TMenuItem;
FDown: Boolean;
FPopupUp: Boolean;
procedure SetFrame(Value: Integer);
procedure DoMax;
procedure DoMin;
procedure DoRollUp;
procedure DoClose;
procedure DoCommand;
procedure DoMinToTray;
procedure TrackMenu;
public
CountFrames: Integer;
Cycle: Boolean;
ButtonStyle: Boolean;
Increment: Boolean;
Command: TStdCommand;
DownSkinRect: TRect;
RestoreRect, RestoreActiveRect, RestoreInActiveRect,
RestoreDownRect: TRect;
procedure ChangeFrame;
procedure Start;
procedure Stop;
constructor Create(AParent: TspDynamicSkinForm;
AData: TspDataSkinObject);
procedure DblCLick; override;
procedure MouseDown(X, Y: Integer; Button: TMouseButton); override;
procedure MouseUp(X, Y: Integer; Button: TMouseButton); override;
property Frame: Integer read FFrame write SetFrame;
procedure Draw(Cnvs: TCanvas; UpDate: Boolean); override;
procedure MouseEnter; override;
procedure MouseLeave; override;
end;
TspSkinGaugeObject = class(TspActiveSkinObject)
protected
FProgressPos, FOldProgressPos: TPoint;
procedure SetValue(AValue: Integer);
function CalcProgressPos: TPoint;
public
FValue: Integer;
MinValue, MaxValue: Integer;
Kind: TGaugeKind;
procedure SimplySetValue(AValue: Integer);
constructor Create(AParent: TspDynamicSkinForm;
AData: TspDataSkinObject);
property Value: Integer read FValue write SetValue;
procedure Draw(Cnvs: TCanvas; UpDate: Boolean); override;
procedure MouseEnter; override;
procedure MouseLeave; override;
end;
TspSkinBitLabelObject = class(TspActiveSkinObject)
public
FTextValue: String;
SymbolWidth: Integer;
SymbolHeight: Integer;
Symbols: TStrings;
Transparent: Boolean;
TransparentColor: TColor;
constructor Create(AParent: TspDynamicSkinForm;
AData: TspDataSkinObject);
procedure Draw(Cnvs: TCanvas; UpDate: Boolean); override;
procedure SetTextValue(AValue: String; AUpDate: Boolean);
end;
TspSkinLabelObject = class(TspActiveSkinObject)
public
FTextValue: String;
FontName: String;
FontStyle: TFontStyles;
FontHeight: Integer;
FontColor: TColor;
ActiveFontColor: TColor;
Alignment: TAlignment;
constructor Create(AParent: TspDynamicSkinForm;
AData: TspDataSkinObject);
procedure MouseEnter; override;
procedure MouseLeave; override;
procedure Draw(Cnvs: TCanvas; UpDate: Boolean); override;
procedure SetTextValue(AValue: String; AUpDate: Boolean);
end;
TspSkinSwitchObject = class(TspActiveSkinObject)
protected
FState: TSwitchState;
procedure SetState(Value: TSwitchState);
public
constructor Create(AParent: TspDynamicSkinForm;
AData: TspDataSkinObject);
property State: TSwitchState read FState write SetState;
procedure SimpleSetState(Value: TSwitchState);
procedure MouseDown(X, Y: Integer; Button: TMouseButton); override;
procedure MouseEnter; override;
procedure MouseLeave; override;
end;
TspSkinTrackBarObject = class(TspActiveSkinObject)
private
FButtonPos, FOldButtonPos: TPoint;
FValue: Integer;
MoveActive: Boolean;
FOldMPoint: TPoint;
TrackKind: TTrackKind;
procedure SetButtonPos(AValue: TPoint);
procedure SetValue(AValue: Integer);
function CalcValue(APos: TPoint): Integer;
function CalcButtonPos(AValue: Integer): TPoint;
property ButtonPos: TPoint read FButtonPos write SetButtonPos;
function CalcButtonRect(P: TPoint): TRect;
public
ButtonRect: TRect;
ActiveButtonRect: TRect;
BeginPoint: TPoint;
EndPoint: TPoint;
MinValue: Integer;
MaxValue: Integer;
MouseDownChangeValue: Boolean;
ButtonTransparent: Boolean;
ButtonTransparentColor: TColor;
constructor Create(AParent: TspDynamicSkinForm;
AData: TspDataSkinObject);
property Value: Integer read FValue write SetValue;
procedure SimplySetValue(AValue: Integer);
procedure Draw(Cnvs: TCanvas; UpDate: Boolean); override;
procedure MouseDown(X, Y: Integer; Button: TMouseButton); override;
procedure MouseUp(X, Y: Integer; Button: TMouseButton); override;
procedure MouseMove(X, Y: Integer); override;
end;
TspSkinButtonObject = class(TspActiveSkinObject)
protected
FDown: Boolean;
FPopupUp: Boolean;
procedure SetDown(Value: Boolean);
procedure TrackMenu;
public
DownRect: TRect;
DisableSkinRect: TRect;
GroupIndex: Integer;
MenuItem: TMenuItem;
constructor Create(AParent: TspDynamicSkinForm;
AData: TspDataSkinObject);
property Down: Boolean read FDown write SetDown;
procedure Draw(Cnvs: TCanvas; UpDate: Boolean); override;
procedure MouseDown(X, Y: Integer; Button: TMouseButton); override;
procedure MouseUp(X, Y: Integer; Button: TMouseButton); override;
procedure MouseEnter; override;
procedure MouseLeave; override;
function CanMorphing: Boolean; override;
end;
TspSkinMainMenuItem = class(TspActiveSkinObject)
protected
TempObjectRect: TRect;
FDown: Boolean;
OldEnabled: Boolean;
Visible: Boolean;
function SearchDown: Boolean;
procedure SearchActive;
procedure SetDown(Value: Boolean);
procedure TrackMenu;
public
MenuItem: TMenuItem;
FontName: String;
FontHeight: Integer;
FontStyle: TFontStyles;
UnEnabledFontColor, FontColor,
ActiveFontColor, DownFontColor: TColor;
TextRct: TRect;
DownRect: TRect;
LO, RO: Integer;
constructor Create(AParent: TspDynamicSkinForm; AData: TspDataSkinObject);
procedure Draw(Cnvs: TCanvas; UpDate: Boolean); override;
procedure MouseEnter; override;
procedure MouseDown(X, Y: Integer; Button: TMouseButton); override;
procedure MouseLeave; override;
end;
TspSkinStdButtonObject = class(TspSkinButtonObject)
protected
procedure DoMax;
procedure DoMin;
procedure DoClose;
procedure DoRollUp;
procedure DoCommand;
procedure DoMinimizeToTray;
public
FSkinSupport: Boolean;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -