📄 sxskinbutton.pas
字号:
VarList.Free;
end;
procedure TSXButtonVariableComparer.DestroyVarVals(VarList:TList;VarVals:TList);
begin
VarVals.Free;
end;
{ TSXSkinCustomButton }
function TSXSkinCustomButton.HasUnusualSkinStyle:Boolean;
begin
Result:=SkinStyle<>'_Button';
end;
function TSXSkinCustomButton.HasUnusualDropDownGlyphStyle:Boolean;
begin
Result:=FDropDownGlyphStyle<>'_MultiState_DropDown';
end;
procedure TSXSkinCustomButton.SetEnabled(Value:Boolean);
begin
if Enabled<>Value then
begin
if not (csLoading in ComponentState) then
begin
if Enabled then
StartGlyphChanging(gcaDisable) else
StartGlyphChanging(gcaEnable);
end;
inherited;
if not Enabled then
begin
FMouseOver:=False;
FDown:=False;
end;
if not (csLoading in ComponentState) then
ResetButtonParams([brpTextOnFontChange,brpGlyphOnStyleChange,
brpDDGlyphOnStyleChange,brpInvalidateOnStyleChange]);
end;
end;
procedure TSXSkinCustomButton.SetGlyphPosition(Value:TSXGlyphPosition);
begin
if Value<>FGlyphPosition then
begin
FGlyphPosition:=Value;
if not (csLoading in ComponentState) then
ResetButtonParams([brpTextIfWordWrap]);
end;
end;
procedure TSXSkinCustomButton.SetAlignment(Value:TAlignment);
begin
if Value<>FAlignment then
begin
FAlignment:=Value;
if not (csLoading in ComponentState) then
begin
ResetButtonParams([brpText]);
end;
end;
end;
procedure TSXSkinCustomButton.SetWordWrap(Value:Boolean);
begin
if Value<>FWordWrap then
begin
FWordWrap:=Value;
if not (csLoading in ComponentState) then
ResetButtonParams([brpText]);
end;
end;
procedure TSXSkinCustomButton.SetCaptionLeftOffset(Value:Integer);
begin
if Value<>FCaptionLeftOffset then
begin
FCaptionLeftOffset:=Value;
if not (csLoading in ComponentState) then
ResetButtonParams([brpTextIfWordWrap]);
end;
end;
procedure TSXSkinCustomButton.SetCaptionTopOffset(Value:Integer);
begin
if Value<>FCaptionTopOffset then
begin
FCaptionTopOffset:=Value;
if not (csLoading in ComponentState) then
ResetButtonParams([brpTextIfWordWrap]);
end;
end;
procedure TSXSkinCustomButton.SetCaptionRightOffset(Value:Integer);
begin
if Value<>FCaptionRightOffset then
begin
FCaptionRightOffset:=Value;
if not (csLoading in ComponentState) then
ResetButtonParams([brpTextIfWordWrap]);
end;
end;
procedure TSXSkinCustomButton.SetCaptionBottomOffset(Value:Integer);
begin
if Value<>FCaptionBottomOffset then
begin
FCaptionBottomOffset:=Value;
if not (csLoading in ComponentState) then
ResetButtonParams([brpTextIfWordWrap]);
end;
end;
procedure TSXSkinCustomButton.SetTextOffset(Value:Integer);
begin
if Value<>FTextOffset then
begin
FTextOffset:=Value;
if not (csLoading in ComponentState) then
ResetButtonParams([brpTextIfWordWrap]);
end;
end;
procedure TSXSkinCustomButton.SetCanBeChecked(Value:Boolean);
begin
if Value<>FCanBeChecked then
begin
FCanBeChecked:=Value;
if not (csLoading in ComponentState) then
begin
if not Value and Checked then
Checked:=False;
end;
end;
end;
procedure TSXSkinCustomButton.SetChecked(Value:Boolean);
begin
if Value<>FChecked then
begin
FChecked:=Value;
if not (csLoading in ComponentState) then
begin
if Value and not FCanBeChecked then
FChecked:=False else
ResetButtonParams([brpTextOnFontChange,brpGlyphOnStyleChange,
brpDDGlyphOnStyleChange,brpInvalidateOnStyleChange]);
end;
end;
end;
procedure TSXSkinCustomButton.SetDropDown(Value:Boolean);
begin
if Value<>FDropDown then
begin
FDropDown:=Value;
if not (csLoading in ComponentState) then
ResetButtonParams([brpDDGlyphOnStyleChange]);
end;
end;
procedure TSXSkinCustomButton.SetGlyphStyle(const Value:String);
begin
if Value<>FGlyphStyle then
begin
FGlyphStyle:=Value;
if not (csLoading in ComponentState) then
ResetButtonParams([brpGlyphOnStyleChange,brpTextIfWordWrap]);
end;
end;
procedure TSXSkinCustomButton.SetDropDownGlyphStyle(const Value:String);
begin
if Value<>FDropDownGlyphStyle then
begin
FDropDownGlyphStyle:=Value;
if not (csLoading in ComponentState) then
ResetButtonParams([brpDDGlyphOnStyleChange,brpTextIfWordWrap]);
end;
end;
procedure TSXSkinCustomButton.SetGlyphWidth(Value:Integer);
begin
if Value<>FGlyphWidth then
begin
FGlyphWidth:=Value;
if not (csLoading in ComponentState) then
ResetButtonParams([brpGlyphOnSizeChange]);
end;
end;
procedure TSXSkinCustomButton.SetGlyphHeight(Value:Integer);
begin
if Value<>FGlyphHeight then
begin
FGlyphHeight:=Value;
if not (csLoading in ComponentState) then
ResetButtonParams([brpGlyphOnSizeChange]);
end;
end;
procedure TSXSkinCustomButton.SetDropDownMenu(Value:TPopupMenu);
begin
if FDropDownMenu<>Value then
begin
if FDropDownMenu<>nil then
FDropDownMenu.RemoveFreeNotification(Self);
FDropDownMenu:=Value;
if FDropDownMenu<>nil then
FDropDownMenu.FreeNotification(Self);
end;
end;
procedure TSXSkinCustomButton.Notification(AComponent:TComponent;Operation:TOperation);
begin
inherited Notification(AComponent,Operation);
if Operation=opRemove then
begin
if AComponent=FDropDownMenu then
FDropDownMenu:=nil;
end;
end;
function TSXSkinCustomButton.OnGetVariable(const VarName:String;var Error:Boolean):Single;
begin
Result:=0;
if VarName='W' then
begin
Result:=Width; exit;
end;
if VarName='H' then
begin
Result:=Height; exit;
end;
if VarName='GlX' then
begin
Result:=FGlyphRect.Left; exit;
end;
if VarName='GlY' then
begin
Result:=FGlyphRect.Top; exit;
end;
if VarName='GlW' then
begin
Result:=FGlyphRect.Right-FGlyphRect.Left; exit;
end;
if VarName='GlH' then
begin
Result:=FGlyphRect.Bottom-FGlyphRect.Top; exit;
end;
Error:=True;
end;
function TSXSkinCustomButton.CreateCurrentGlyph:TBitmap32;
var GStyle:String;
UseFilter:Boolean;
BState:TSXSkinButtonStateParam;
procedure SetGlyphByStyleName(const StyleName:String;var BB:TBitmap32);
var C:Integer;
GlyphStyle:TSXSkinGeneralStyle;
Rgn:HRGN;
begin
C:=SkinLibrary.Styles.GetGStyleIndex(StyleName,FGlyphRect.Right-FGlyphRect.Left,
FGlyphRect.Bottom-FGlyphRect.Top);
if C>=0 then
begin
GlyphStyle:=TSXSkinGeneralStyle(SkinLibrary.Styles[C]);
BB:=TBitmap32.Create;
BB.SetSize(FGlyphRect.Right-FGlyphRect.Left,FGlyphRect.Bottom-FGlyphRect.Top);
BB.Clear(0);
BB.DrawMode:=dmBlend;
BB.CombineMode:=cmMerge;
Rgn:=CreateRectRgn(0,0,BB.Width,BB.Height);
GlyphStyle.DrawToBitmap(Self,CEID_Glyph,BB,0,0,BB.Width,BB.Height,Rect(0,0,BB.Width,BB.Height),
Rgn,SkinLibrary);
DeleteObject(Rgn);
end;
end;
begin
Result:=nil;
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
GetCurrentGlyphStyle(GStyle,nil,nil,@UseFilter);
if GStyle<>'' then
SetGlyphByStyleName(GStyle,Result);
if UseFilter and (Result<>nil) then
begin
GetCurrentBState(BState);
ApplyFilterToBitmap(Result,BState.DefGlyphFilter);
end;
end;
end;
function TSXSkinCustomButton.CreateCurrentBlendedGlyph:TBitmap32;
var B:TBitmap32;
begin
Result:=CreateCurrentGlyph;
if (Result<>nil) and HasTransformEffect(FLastGlyphTransform) and
(FDoneSteps<FLastGlyphTransform.StepsNum) and (FLastGlyph<>nil) then
begin
B:=Result;
try
Result:=TBitmap32.Create;
Result.SetSize(B.Width,B.Height);
Result.DrawMode:=dmBlend;
Result.CombineMode:=cmMerge;
ApplyTransformEffectToBitmaps(FLastGlyph,B,FLastGlyphTransform,FDoneSteps,Result);
finally
B.Free;
end;
end;
end;
function TSXSkinCustomButton.CreateCurrentDropDownGlyph:TBitmap32;
var GStyle:String;
procedure SetGlyphByStyleName(const StyleName:String;var BB:TBitmap32);
var C:Integer;
GlyphStyle:TSXSkinGeneralStyle;
Rgn:HRGN;
begin
C:=SkinLibrary.Styles.GetGStyleIndex(StyleName,FDropDownGlyphRect.Right-FDropDownGlyphRect.Left,
FDropDownGlyphRect.Bottom-FDropDownGlyphRect.Top);
if C>=0 then
begin
GlyphStyle:=TSXSkinGeneralStyle(SkinLibrary.Styles[C]);
BB:=TBitmap32.Create;
BB.SetSize(FDropDownGlyphRect.Right-FDropDownGlyphRect.Left,
FDropDownGlyphRect.Bottom-FDropDownGlyphRect.Top);
BB.Clear(0);
BB.DrawMode:=dmBlend;
BB.CombineMode:=cmMerge;
Rgn:=CreateRectRgn(0,0,BB.Width,BB.Height);
GlyphStyle.DrawToBitmap(Self,CEID_DDGlyph,BB,0,0,BB.Width,BB.Height,Rect(0,0,BB.Width,BB.Height),
Rgn,SkinLibrary);
DeleteObject(Rgn);
end;
end;
begin
Result:=nil;
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
GetCurrentDropDownGlyphStyle(GStyle);
if GStyle<>'' then
SetGlyphByStyleName(GStyle,Result);
end;
end;
function TSXSkinCustomButton.CreateCurrentBlendedDropDownGlyph:TBitmap32;
var B:TBitmap32;
begin
Result:=CreateCurrentDropDownGlyph;
if (Result<>nil) and HasTransformEffect(FLastDDGlyphTransform) and
(FDoneSteps<FLastDDGlyphTransform.StepsNum) and (FLastDropDownGlyph<>nil) then
begin
B:=Result;
try
Result:=TBitmap32.Create;
Result.SetSize(B.Width,B.Height);
Result.DrawMode:=dmBlend;
Result.CombineMode:=cmMerge;
ApplyTransformEffectToBitmaps(FLastDropDownGlyph,B,FLastDDGlyphTransform,FDoneSteps,Result);
finally
B.Free;
end;
end;
end;
procedure TSXSkinCustomButton.PaintCurrentBStyle(Bitmap:TBitmap32;X,Y:Integer;Rect:TRect;Rgn:HRGN);
var A:Integer;
BState:TSXSkinButtonStateParam;
Style:TSXSkinGeneralStyle;
begin
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
GetCurrentBState(BState);
A:=SkinLibrary.Styles.GetGStyleIndex(BState.Style,Width,Height);
if A>=0 then
begin
Style:=TSXSkinGeneralStyle(SkinLibrary.Styles[A]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -