📄 sxskingroupbox.pas
字号:
if (PGlyphWidth<>nil) and (PGlyphWidth^=0) then
PGlyphWidth^:=T.GlyphWidth;
if (PGlyphHeight<>nil) and (PGlyphHeight^=0) then
PGlyphHeight^:=T.GlyphHeight;
end;
begin
if PGlyphWidth<>nil then PGlyphWidth^:=0;
if PGlyphHeight<>nil then PGlyphHeight^:=0;
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
A:=SkinLibrary.Styles.GetIndexByName(SkinStyle);
if (A>=0) and (SkinLibrary.Styles[A] is TSXSkinGroupBoxStyle) then
begin
GBStyle:=TSXSkinGroupBoxStyle(SkinLibrary.Styles[A]);
if PGlyphWidth<>nil then PGlyphWidth^:=GBStyle.GlyphWidth;
if PGlyphHeight<>nil then PGlyphHeight^:=GBStyle.GlyphHeight;
end;
GStyle:='';
A:=SkinLibrary.Styles.GetIndexByName(FGlyphStyle);
if A>=0 then
begin
if SkinLibrary.Styles[A] is TSXSkinCheckBoxStyle then
begin
CBStyle:=TSXSkinCheckBoxStyle(SkinLibrary.Styles[A]);
CBStyle.GetCurrentCBState(CBState,FState,FDown,FMouseOver,FLastFocused,Enabled);
SetGStyle(CBState.GlyphStyle);
end else
if SkinLibrary.Styles[A] is TSXSkinRadioButtonStyle then
begin
RBStyle:=TSXSkinRadioButtonStyle(SkinLibrary.Styles[A]);
RBStyle.GetCurrentRBState(RBState,Checked,FDown,FMouseOver,FLastFocused,Enabled);
SetGStyle(RBState.GlyphStyle);
end else
if SkinLibrary.Styles[A] is TSXSkinMultiStateStyle then
begin
MSStyle:=TSXSkinMultiStateStyle(SkinLibrary.Styles[A]);
if not Enabled then
begin
SetGStyle(MSStyle.RStyle);
SetGStyle(MSStyle.NStyle);
end else
if FMouseOver then
begin
SetGStyle(MSStyle.HStyle);
SetGStyle(MSStyle.NStyle);
end else SetGStyle(MSStyle.NStyle);
end else GStyle:=FGlyphStyle;
end else
begin
if PGlyphWidth<>nil then PGlyphWidth^:=0;
if PGlyphHeight<>nil then PGlyphHeight^:=0;
end;
if (GStyle<>'') and ((PGlyphWidth<>nil) or (PGlyphHeight<>nil)){ and
((PGlyphWidth^=0) and (PGlyphHeight^=0))} then
begin
A:=SkinLibrary.Styles.GetGStyleIndex(GStyle,0,0);
if A>=0 then
begin
GlyphStyle:=TSXSkinGeneralStyle(SkinLibrary.Styles[A]);
for B:=0 to GlyphStyle.Elements.Count-1 do
if GlyphStyle.Elements[B] is TSXSkinStyleImageElement then
begin
Image:=TSXSkinStyleImageElement(GlyphStyle.Elements[B]);
Image.ValidateBitmap(SkinLibrary);
if Image.Bitmap<>nil then
begin
if (PGlyphWidth<>nil){ and (PGlyphWidth^=0)} then
PGlyphWidth^:=Image.Bitmap.Width;
if (PGlyphHeight<>nil){ and (PGlyphHeight^=0)} then
PGlyphHeight^:=Image.Bitmap.Height;
end;
end;
end;
end;
end;
end;
procedure TSXSkinCustomGroupBox.GetCurrentFontData(var FD:TSXFontData);
var A:Integer;
Style:TSXSkinGroupBoxStyle;
LStyle:TSXSkinLabelStyle;
CBStyle:TSXSkinCheckBoxStyle;
CBState:TSXSkinCheckBoxStateParam;
RBStyle:TSXSkinRadioButtonStyle;
RBState:TSXSkinRadioButtonStateParam;
begin
ClearFontData(FD);
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
A:=SkinLibrary.Styles.GetIndexByName(SkinStyle);
if (A>=0) and (SkinLibrary.Styles[A] is TSXSkinGroupBoxStyle) then
begin
Style:=TSXSkinGroupBoxStyle(SkinLibrary.Styles[A]);
A:=SkinLibrary.Styles.GetIndexByName(Style.LabelStyle);
if (A>=0) and (SkinLibrary.Styles[A] is TSXSkinLabelStyle) then
LStyle:=TSXSkinLabelStyle(SkinLibrary.Styles[A]) else LStyle:=nil;
CBStyle:=nil; RBStyle:=nil;
if not FUseLabelStyle then
begin
case FGlyphType of
gtCheckBox: begin
A:=SkinLibrary.Styles.GetIndexByName(FGlyphStyle);
if (A>=0) and (SkinLibrary.Styles[A] is TSXSkinCheckBoxStyle) then
CBStyle:=TSXSkinCheckBoxStyle(SkinLibrary.Styles[A]);
end;
gtRadioButton: begin
A:=SkinLibrary.Styles.GetIndexByName(FGlyphStyle);
if (A>=0) and (SkinLibrary.Styles[A] is TSXSkinRadioButtonStyle) then
RBStyle:=TSXSkinRadioButtonStyle(SkinLibrary.Styles[A]);
end;
end;
end;
if CBStyle<>nil then
begin
CBStyle.GetCurrentCBState(CBState,FState,FDown,FMouseOver,FLastFocused,Enabled);
AddFontData(FD,CBState.FD);
end else
if RBStyle<>nil then
begin
RBStyle.GetCurrentRBState(RBState,Checked,FDown,FMouseOver,FLastFocused,Enabled);
AddFontData(FD,RBState.FD);
end else
if LStyle<>nil then
begin
if not Enabled then
begin
AddFontData(FD,LStyle.RState.FD);
AddFontData(FD,LStyle.NState.FD);
end else
if FMouseOver then
begin
AddFontData(FD,LStyle.HState.FD);
AddFontData(FD,LStyle.NState.FD);
end else AddFontData(FD,LStyle.NState.FD);
end;
end;
end;
SetDefaultFontData(FD,Font);
end;
procedure TSXSkinCustomGroupBox.CreateThreadIfNeeded;
begin
if FThread=nil then
begin
FThread:=TSXSkinCustomGroupBoxThread.Create;
FThread.Control:=Self;
end;
end;
procedure TSXSkinCustomGroupBox.GetCurrentGlyphTransformEffect(Action:TSXGlyphChangeAction;
var Effect:TSXTransformEffectData);
var A:Integer;
CBStyle:TSXSkinCheckBoxStyle;
RBStyle:TSXSkinRadioButtonStyle;
begin
FillChar(Effect,sizeof(Effect),0);
if (SkinLibrary<>nil) and SkinLibrary.CanBeUsed then
begin
A:=SkinLibrary.Styles.GetIndexByName(FGlyphStyle);
if (A>=0) and (SkinLibrary.Styles[A] is TSXSkinCheckBoxStyle) then
begin
CBStyle:=TSXSkinCheckBoxStyle(SkinLibrary.Styles[A]);
case Action of
gcaHighlightIn: Effect:=CBStyle.HInGlyphEffect;
gcaHighlightOut: Effect:=CBStyle.HOutGlyphEffect;
gcaDown: Effect:=CBStyle.DownGlyphEffect;
gcaUp: Effect:=CBStyle.UpGlyphEffect;
gcaCheck: Effect:=CBStyle.CheckGlyphEffect;
gcaUncheck: Effect:=CBStyle.UncheckGlyphEffect;
gcaEnable: Effect:=CBStyle.EnableGlyphEffect;
gcaDisable: Effect:=CBStyle.DisableGlyphEffect;
gcaFocus: Effect:=CBStyle.FocusGlyphEffect;
gcaUnfocus: Effect:=CBStyle.UnfocusGlyphEffect;
end;
end;
if (A>=0) and (SkinLibrary.Styles[A] is TSXSkinRadioButtonStyle) then
begin
RBStyle:=TSXSkinRadioButtonStyle(SkinLibrary.Styles[A]);
case Action of
gcaHighlightIn: Effect:=RBStyle.HInGlyphEffect;
gcaHighlightOut: Effect:=RBStyle.HOutGlyphEffect;
gcaDown: Effect:=RBStyle.DownGlyphEffect;
gcaUp: Effect:=RBStyle.UpGlyphEffect;
gcaCheck: Effect:=RBStyle.CheckGlyphEffect;
gcaUncheck: Effect:=RBStyle.UncheckGlyphEffect;
gcaEnable: Effect:=RBStyle.EnableGlyphEffect;
gcaDisable: Effect:=RBStyle.DisableGlyphEffect;
gcaFocus: Effect:=RBStyle.FocusGlyphEffect;
gcaUnfocus: Effect:=RBStyle.UnfocusGlyphEffect;
end;
end;
end;
end;
procedure TSXSkinCustomGroupBox.StartGlyphChanging(T:TSXGlyphChangeAction);
var B:TBitmap32;
NeedThread:Boolean;
GTransform:TSXTransformEffectData;
begin
GetCurrentGlyphTransformEffect(T,GTransform);
NeedThread:=HasTransformEffect(GTransform);
if NeedThread then
begin
CreateThreadIfNeeded;
B:=CreateCurrentBlendedGlyph;
FLastGlyph.Free;
FLastGlyph:=B;
//
FDoneSteps:=1;
if FThread.Suspended then
FThread.Resume;
end else
if (FThread<>nil) and not FThread.Suspended then
begin
FDoneSteps:=MaxInt;
FThread.Suspend;
end;
FLastGlyphTransform:=GTransform;
end;
procedure TSXSkinCustomGroupBox.InvalidateGroupBoxArea;
var Rgn,Rgn2,Rgn3:HRGN;
begin
if HandleAllocated then
begin
if IsRectEmpty(FTransparentRect) then
InvalidateRect(Handle,nil,False) else
begin
Rgn:=CreateRectRgn(0,0,Width,Height);
Rgn2:=CreateRectRgnIndirect(FTransparentRect);
Rgn3:=CreateRectRgn(0,0,0,0);
CombineRgn(Rgn3,Rgn,Rgn2,RGN_DIFF);
InvalidateRgn(Handle,Rgn3,False);
DeleteObject(Rgn);
DeleteObject(Rgn2);
DeleteObject(Rgn3);
end;
end;
end;
procedure TSXSkinCustomGroupBox.InvalidateGlyph;
begin
if HandleAllocated then
InvalidateRect(Handle,@FGlyphRect,False);
end;
procedure TSXSkinCustomGroupBox.InvalidateText;
begin
if HandleAllocated then
InvalidateRect(Handle,@FTextRect,False);
end;
procedure TSXSkinCustomGroupBox.DoThreadActions;
begin
if not (csDestroying in ComponentState) then
begin
Inc(FDoneSteps);
if (FThread<>nil) and not FThread.Suspended and
(not HasTransformEffect(FLastGlyphTransform) or (FDoneSteps>=FLastGlyphTransform.StepsNum)) then
begin
FThread.Suspend;
end;
InvalidateGlyph;
Update;
end;
end;
function TSXSkinCustomGroupBox.CreateCurrentGlyph: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,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);
if GStyle<>'' then
SetGlyphByStyleName(GStyle,Result);
end;
end;
function TSXSkinCustomGroupBox.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;
procedure TSXSkinCustomGroupBox.WMSetFocus(var Msg:TWMSetFocus);
begin
StartGlyphChanging(gcaFocus);
FLastFocused:=True;
ResetGroupBoxParams([gbrpTextOnFontChange,gbrpGlyphOnSizeChange,
gbrpGlyphOnStyleChange,gbrpInvalidateOnStyleChange,
gbrpTransparentRect]);
end;
procedure TSXSkinCustomGroupBox.WMKillFocus(var Msg:TWMKillFocus);
begin
StartGlyphChanging(gcaUnfocus);
FLastFocused:=False;
ResetGroupBoxParams([gbrpTextOnFontChange,gbrpGlyphOnSizeChange,
gbrpGlyphOnStyleChange,gbrpInvalidateOnStyleChange,
gbrpTransparentRect]);
if FDown then
begin
StartGlyphChanging(gcaUp);
FDown:=False;
ResetGroupBoxParams([gbrpTextOnFontChange,gbrpGlyphOnSizeChange,
gbrpGlyphOnStyleChange,gbrpInvalidateOnStyleChange,
gbrpTransparentRect]);
end;
end;
procedure TSXSkinCustomGroupBox.MouseMove(Shift:TShiftState;X,Y:Integer);
var B:Boolean;
P:TPoint;
begin
inherited;
if Enabled then
begin
P:=Point(X,Y);
B:=PtInRect(FGlyphRect,P) or PtInRect(FTextRect,P);
if B<>FMouseOver then
begin
if B then InternalMouseEnter else
InternalMouseLeave;
end;
end;
end;
procedure TSXSkinCustomGroupBox.MouseDown(Button:TMouseButton;Shift:TShiftState;X,Y:Integer);
begin
if Enabled and FMouseOver and (Button=mbLeft) then
begin
StartGlyphChanging(gcaDown);
FDown:=True;
SetFocus;
ResetGroupBoxParams([gbrpTextOnFontChange,gbrpGlyphOnSizeChange,
gbrpGlyphOnStyleChange,gbrpInvalidateOnStyleChange,
gbrpTransparentRect]);
end;
inherited;
end;
procedure TSXSkinCustomGroupBox.MouseUp(Button:TMouseButton;Shift:TShiftState;X,Y:Integer);
var OldDown,WasChecked:Boolean;
begin
if Enabled then
begin
OldDown:=FDown;
StartGlyphChanging(gcaUp);
FDown:=False;
ResetGroupBoxParams([gbrpTextOnFontChange,gbrpGlyphOnSizeChange,
gbrpGlyphOnStyleChange,gbrpInvalidateOnStyleChange,
gbrpTransparentRect]);
if OldDown and FMouseOver then
begin
WasChecked:=Checked;
Click;
if Assigned(FOnUserModified) and not ((FGlyphType=gtRadioButton) and WasChecked) then
FOnUserModified(Self);
end;
end;
inherited;
end;
procedure TSXSkinCustomGroupBox.DoClick;
var A:Integer;
begin
if Visible and Enabled and FDown then
begin
case FGlyphType of
gtCheckBox: begin
FDown:=False;
if FState=cbChecked then
StartGlyphChanging(gcaUncheck) else
StartGlyphChanging(gcaCheck);
case FState of
cbUnchecked: if FAllowGrayed then
FState:=cbGrayed else FState:=cbChecked;
cbGrayed: FState:=cbChecked;
cbChecked: FState:=cbUnchecked;
end;
ResetGroupBoxParams([gbrpTextOnFontChange,gbrpGlyphOnSizeChange,
gbrpGlyphOnStyleChange,gbrpInvalidateOnStyleChange,
gbrpTransparentRect]);
if Assigned(FOnChange) then
FOnChange(Self);
end;
gtRadioButton: begin
if FState=cbUnchecked then
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -