📄 sxskinupdown.pas
字号:
FMouseOver:=False;
FMouseOverUp:=False;
FMouseOverDown:=False;
FDownUp:=False;
FDownDown:=False;
end;
if not (csLoading in ComponentState) then
ResetUpDownParams([udrpInvalidateOnStyleChange,udrpInvalidateUpButtonOnStyleChange,
udrpInvalidateDownButtonOnStyleChange]);
end;
end;
procedure TSXSkinCustomUpDown.SetEnabledUp(Value:Boolean);
begin
if Value<>FEnabledUp then
begin
FEnabledUp:=Value;
if not (csLoading in ComponentState) then
begin
if FEnabledUp then
StartUpButtonChangingEffect(gcaEnable) else
StartUpButtonChangingEffect(gcaDisable);
ResetUpDownParams([udrpInvalidateUpButtonOnStyleChange]);
end;
end;
end;
procedure TSXSkinCustomUpDown.SetEnabledDown(Value:Boolean);
begin
if Value<>FEnabledDown then
begin
FEnabledDown:=Value;
if not (csLoading in ComponentState) then
begin
if FEnabledDown then
StartDownButtonChangingEffect(gcaEnable) else
StartDownButtonChangingEffect(gcaDisable);
ResetUpDownParams([udrpInvalidateDownButtonOnStyleChange]);
end;
end;
end;
procedure TSXSkinCustomUpDown.SetHorizontal(Value:Boolean);
begin
if Value<>FHorizontal then
begin
FHorizontal:=Value;
if not (csLoading in ComponentState) and (csDesigning in ComponentState) then
begin
if FHorizontal and (SkinStyle='_UpDown') then
SkinStyle:='_UpDownH' else
if not FHorizontal and (SkinStyle='_UpDownH') then
SkinStyle:='_UpDown';
end;
end;
end;
procedure TSXSkinCustomUpDown.Notification(AComponent:TComponent;Operation:TOperation);
begin
inherited Notification(AComponent,Operation);
end;
function TSXSkinCustomUpDown.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='UL' then
begin
Result:=FUpButtonRect.Left; exit;
end;
if VarName='UT' then
begin
Result:=FUpButtonRect.Top; exit;
end;
if VarName='UR' then
begin
Result:=FUpButtonRect.Right; exit;
end;
if VarName='UB' then
begin
Result:=FUpButtonRect.Bottom; exit;
end;
if VarName='DL' then
begin
Result:=FDownButtonRect.Left; exit;
end;
if VarName='DT' then
begin
Result:=FDownButtonRect.Top; exit;
end;
if VarName='DR' then
begin
Result:=FDownButtonRect.Right; exit;
end;
if VarName='DB' then
begin
Result:=FDownButtonRect.Bottom; exit;
end;
Error:=True;
end;
procedure TSXSkinCustomUpDown.GetCurrentUDState(var UDState:TSXSkinUpDownStateParam);
var A:Integer;
Style:TSXSkinUpDownStyle;
begin
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
A:=SkinLibrary.Styles.GetIndexByName(SkinStyle);
if (A>=0) and (SkinLibrary.Styles[A] is TSXSkinUpDownStyle) then
begin
Style:=TSXSkinUpDownStyle(SkinLibrary.Styles[A]);
Style.GetCurrentUDState(UDState,Enabled,FMouseOver,FDownUp or FDownDown,FLastFocused);
end;
end else
begin
Finalize(UDState);
FillChar(UDState,sizeof(UDState),0);
end;
end;
procedure TSXSkinCustomUpDown.GetCurrentUpButtonState(var BState:TSXSkinButtonStateParam);
var A:Integer;
Style:TSXSkinUpDownStyle;
BStyle:TSXSkinButtonStyle;
begin
Finalize(BState);
FillChar(BState,sizeof(BState),0);
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
A:=SkinLibrary.Styles.GetIndexByName(SkinStyle);
if (A>=0) and (SkinLibrary.Styles[A] is TSXSkinUpDownStyle) then
begin
Style:=TSXSkinUpDownStyle(SkinLibrary.Styles[A]);
A:=SkinLibrary.Styles.GetIndexByName(Style.UpButton);
if (A>=0) and (SkinLibrary.Styles[A] is TSXSkinButtonStyle) then
begin
BStyle:=TSXSkinButtonStyle(SkinLibrary.Styles[A]);
BStyle.GetCurrentBState(BState,False,Enabled and FEnabledUp,FMouseOverUp,
FDownUp,False);
end;
end;
end;
end;
procedure TSXSkinCustomUpDown.GetCurrentDownButtonState(var BState:TSXSkinButtonStateParam);
var A:Integer;
Style:TSXSkinUpDownStyle;
BStyle:TSXSkinButtonStyle;
begin
Finalize(BState);
FillChar(BState,sizeof(BState),0);
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
A:=SkinLibrary.Styles.GetIndexByName(SkinStyle);
if (A>=0) and (SkinLibrary.Styles[A] is TSXSkinUpDownStyle) then
begin
Style:=TSXSkinUpDownStyle(SkinLibrary.Styles[A]);
A:=SkinLibrary.Styles.GetIndexByName(Style.DownButton);
if (A>=0) and (SkinLibrary.Styles[A] is TSXSkinButtonStyle) then
begin
BStyle:=TSXSkinButtonStyle(SkinLibrary.Styles[A]);
BStyle.GetCurrentBState(BState,False,Enabled and FEnabledDown,FMouseOverDown,
FDownDown,False);
end;
end;
end;
end;
procedure TSXSkinCustomUpDown.PaintUpButtonStyle(Bitmap:TBitmap32;X,Y:Integer;Rect:TRect;Rgn:HRGN);
var A:Integer;
BState:TSXSkinButtonStateParam;
Style:TSXSkinGeneralStyle;
BWidth:Integer;
BHeight:Integer;
begin
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
GetCurrentUpButtonState(BState);
BWidth:=FUpButtonRect.Right-FUpButtonRect.Left;
BHeight:=FUpButtonRect.Bottom-FUpButtonRect.Top;
A:=SkinLibrary.Styles.GetGStyleIndex(BState.Style,BWidth,BHeight);
if A>=0 then
begin
Style:=TSXSkinGeneralStyle(SkinLibrary.Styles[A]);
Style.DrawToBitmap(Self,CEID_Up,Bitmap,X,Y,BWidth,BHeight,Rect,Rgn,SkinLibrary);
end;
end;
end;
procedure TSXSkinCustomUpDown.PaintDownButtonStyle(Bitmap:TBitmap32;X,Y:Integer;Rect:TRect;Rgn:HRGN);
var A:Integer;
BState:TSXSkinButtonStateParam;
Style:TSXSkinGeneralStyle;
BWidth:Integer;
BHeight:Integer;
begin
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
GetCurrentDownButtonState(BState);
BWidth:=FDownButtonRect.Right-FDownButtonRect.Left;
BHeight:=FDownButtonRect.Bottom-FDownButtonRect.Top;
A:=SkinLibrary.Styles.GetGStyleIndex(BState.Style,BWidth,BHeight);
if A>=0 then
begin
Style:=TSXSkinGeneralStyle(SkinLibrary.Styles[A]);
Style.DrawToBitmap(Self,CEID_Down,Bitmap,X,Y,BWidth,BHeight,Rect,Rgn,SkinLibrary);
end;
end;
end;
procedure TSXSkinCustomUpDown.PaintBlendedUpButtonStyle(Bitmap:TBitmap32;X,Y:Integer;Rect:TRect;Rgn:HRGN);
var BB:TBitmap32;
CurButton:TBitmap32;
Rgn2:HRGN;
BWidth:Integer;
BHeight:Integer;
begin
if HasTransformEffect(FLastUpButtonTransform) and
(FUpButtonDoneSteps<FLastUpButtonTransform.StepsNum) and (FLastUpButton<>nil) then
begin
BWidth:=FLastUpButton.Width;
BHeight:=FLastUpButton.Height;
CurButton:=TBitmap32.Create;
BB:=TBitmap32.Create;
try
CurButton.DrawMode:=dmBlend;
CurButton.CombineMode:=cmMerge;
BB.DrawMode:=dmBlend;
BB.CombineMode:=cmMerge;
CurButton.SetSize(BWidth,BHeight);
CurButton.Clear(0);
Rgn2:=CreateRectRgn(0,0,BWidth,BHeight);
PaintUpButtonStyle(CurButton,0,0,Types.Rect(0,0,BWidth,BHeight),Rgn2);
DeleteObject(Rgn2);
BB.SetSize(BWidth,BHeight);
ApplyTransformEffectToBitmaps(FLastUpButton,CurButton,FLastUpButtonTransform,
FUpButtonDoneSteps,BB);
BB.DrawTo(Bitmap,X-Rect.Left,Y-Rect.Top);
finally
BB.Free;
CurButton.Free;
end;
end else PaintUpButtonStyle(Bitmap,X,Y,Rect,Rgn);
end;
procedure TSXSkinCustomUpDown.PaintBlendedDownButtonStyle(Bitmap:TBitmap32;X,Y:Integer;Rect:TRect;Rgn:HRGN);
var BB:TBitmap32;
CurButton:TBitmap32;
Rgn2:HRGN;
BWidth:Integer;
BHeight:Integer;
begin
if HasTransformEffect(FLastDownButtonTransform) and
(FDownButtonDoneSteps<FLastDownButtonTransform.StepsNum) and (FLastDownButton<>nil) then
begin
BWidth:=FLastDownButton.Width;
BHeight:=FLastDownButton.Height;
CurButton:=TBitmap32.Create;
BB:=TBitmap32.Create;
try
CurButton.DrawMode:=dmBlend;
CurButton.CombineMode:=cmMerge;
BB.DrawMode:=dmBlend;
BB.CombineMode:=cmMerge;
CurButton.SetSize(BWidth,BHeight);
CurButton.Clear(0);
Rgn2:=CreateRectRgn(0,0,BWidth,BHeight);
PaintDownButtonStyle(CurButton,0,0,Types.Rect(0,0,BWidth,BHeight),Rgn2);
DeleteObject(Rgn2);
BB.SetSize(BWidth,BHeight);
ApplyTransformEffectToBitmaps(FLastDownButton,CurButton,FLastDownButtonTransform,
FDownButtonDoneSteps,BB);
BB.DrawTo(Bitmap,X-Rect.Left,Y-Rect.Top);
finally
BB.Free;
CurButton.Free;
end;
end else PaintDownButtonStyle(Bitmap,X,Y,Rect,Rgn);
end;
procedure TSXSkinCustomUpDown.PaintOverStyleButtonsToBitmap(Bitmap:TBitmap32;X,Y:Integer;Rect:TRect;Rgn:HRGN);
var A:Integer;
UDState:TSXSkinUpDownStateParam;
Style:TSXSkinGeneralStyle;
BWidth:Integer;
BHeight:Integer;
begin
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
if not IsRectEmpty(FUpButtonRect) then
begin
BWidth:=FUpButtonRect.Right-FUpButtonRect.Left;
BHeight:=FUpButtonRect.Bottom-FUpButtonRect.Top;
Rgn:=CreateRectRgn(0,0,BWidth,BHeight);
PaintBlendedUpButtonStyle(Bitmap,X-Rect.Left+FUpButtonRect.Left,
Y-Rect.Top+FUpButtonRect.Top,Types.Rect(0,0,BWidth,BHeight),Rgn);
DeleteObject(Rgn);
end;
if not IsRectEmpty(FDownButtonRect) then
begin
BWidth:=FDownButtonRect.Right-FDownButtonRect.Left;
BHeight:=FDownButtonRect.Bottom-FDownButtonRect.Top;
Rgn:=CreateRectRgn(0,0,BWidth,BHeight);
PaintBlendedDownButtonStyle(Bitmap,X-Rect.Left+FDownButtonRect.Left,
Y-Rect.Top+FDownButtonRect.Top,Types.Rect(0,0,BWidth,BHeight),Rgn);
DeleteObject(Rgn);
end;
//
GetCurrentUDState(UDState);
A:=SkinLibrary.Styles.GetGStyleIndex(UDState.OverStyle,Width,Height);
if A>=0 then
begin
Style:=TSXSkinGeneralStyle(SkinLibrary.Styles[A]);
Style.DrawToBitmap(Self,CEID_Back,Bitmap,X,Y,Width,Height,Rect,Rgn,SkinLibrary,VComparer);
end;
end;
end;
procedure TSXSkinCustomUpDown.PaintCurrentUDStyle(Bitmap:TBitmap32;X,Y:Integer;Rect:TRect;Rgn:HRGN);
var A:Integer;
UDState:TSXSkinUpDownStateParam;
Style:TSXSkinGeneralStyle;
begin
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
GetCurrentUDState(UDState);
A:=SkinLibrary.Styles.GetGStyleIndex(UDState.Style,Width,Height);
if A>=0 then
begin
Style:=TSXSkinGeneralStyle(SkinLibrary.Styles[A]);
Style.DrawToBitmap(Self,CEID_Back,Bitmap,X,Y,Width,Height,Rect,Rgn,SkinLibrary,VComparer);
end;
//
if HasTransformEffect(FLastUpDownTransform) and (FUpDownDoneSteps<FLastUpDownTransform.StepsNum) and
FLastUpDownTransform.DrawCaption then
begin
PaintOverStyleButtonsToBitmap(Bitmap,X,Y,Rect,Rgn);
end;
end;
end;
procedure TSXSkinCustomUpDown.PaintCurrentBlendedUDStyle(Bitmap:TBitmap32;X,Y:Integer;Rect:TRect;Rgn:HRGN);
var BB:TBitmap32;
CurButton:TBitmap32;
Rgn2:HRGN;
begin
if HasTransformEffect(FLastUpDownTransform) and
(FUpDownDoneSteps<FLastUpDownTransform.StepsNum) and (FLastUpDown<>nil) then
begin
CurButton:=TBitmap32.Create;
BB:=TBitmap32.Create;
try
CurButton.DrawMode:=dmBlend;
CurButton.CombineMode:=cmMerge;
BB.DrawMode:=dmBlend;
BB.CombineMode:=cmMerge;
CurButton.SetSize(Width,Height);
CurButton.Clear(0);
Rgn2:=CreateRectRgn(0,0,Width,Height);
PaintCurrentUDStyle(CurButton,0,0,Types.Rect(0,0,Width,Height),Rgn2);
DeleteObject(Rgn2);
BB.SetSize(Width,Height);
ApplyTransformEffectToBitmaps(FLastUpDown,CurButton,FLastUpDownTransform,FUpDownDoneSteps,BB);
BB.DrawTo(Bitmap,X-Rect.Left,Y-Rect.Top);
finally
BB.Free;
CurButton.Free;
end;
end else PaintCurrentUDStyle(Bitmap,X,Y,Rect,Rgn);
end;
procedure TSXSkinCustomUpDown.PaintRectToBitmap(DestCanvasHandle:HDC;
DestCanvasRect:TRect;Rect:TRect;Rgn:HRGN;Bitmap:TBitmap32;X,Y:Integer;
WithSubItems:Boolean);
begin
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
PaintCurrentBlendedUDStyle(Bitmap,X,Y,Rect,Rgn);
if not (HasTransformEffect(FLastUpDownTransform) and (FUpDownDoneSteps<FLastUpDownTransform.StepsNum) and
FLastUpDownTransform.DrawCaption) then
PaintOverStyleButtonsToBitmap(Bitmap,X,Y,Rect,Rgn);
end;
inherited;
end;
procedure TSXSkinCustomUpDown.InternalMouseEnter;
begin
if Enabled and not FDownUp and not FDownDown then
StartChangingEffect(gcaHighlightIn);
FMouseOver:=True;
if Enabled and not FDownUp and not FDownDown then
ResetUpDownParams([udrpInvalidateOnStyleChange]);
end;
procedure TSXSkinCustomUpDown.InternalMouseLeave;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -