📄 sthirdparty.pas
字号:
Bmp.Height),
Blend / 100, MaskColor);
end
else begin
CopyTransBitmaps(SkinData.FCacheBmp, Bmp, IRect.Left, IRect.Top, MaskColor);
end;
end;
finally
FreeAndNil(Bmp);
end;
end;
end;
end;
end;
procedure DrawSpeedButtonGlyph(Button : TsSpeedButton);
var
IRect : TRect;
Bmp : TBitmap;
MaskColor: TsColor;
{$IFDEF USEPNG}
PngCopy: TPNGObject;
{$ENDIF}
procedure PrepareGlyph; begin
with Button do begin
Bmp.Width := Images.Width;
Bmp.Height := Images.Height;
Bmp.PixelFormat := pf24bit;
if Button.Images.BkColor <> clNone then MaskColor.C := Button.Images.BkColor else MaskColor.C := clFuchsia;
Bmp.Canvas.Brush.Color := MaskColor.C;
Bmp.Canvas.FillRect(Rect(0, 0, Bmp.Width, Bmp.Height));
Images.GetBitmap(ImageIndex, Bmp);
end;
end;
begin
with Button do begin
if (Glyph <> nil) and (Glyph.Width > 0) then begin
sGraphUtils.DrawGlyphEx(Glyph, SkinData.FCacheBmp, ImgRect, NumGlyphs, Enabled, Grayed, DisabledGlyphKind, Button.CurrentState, Blend);
end
else if Assigned(Button.Images) and (Button.ImageIndex > -1) and (GetImageCount(Images) > ImageIndex) then begin
IRect := ImgRect;
{$IFDEF USEPNG}
if Images is TPngImageList then begin
PngCopy := nil;
if Enabled then begin
if ControlIsActive(SkinData) or ((Blend = 0) and not Grayed) then begin
PngCopy := TPngImageCollectionItem(TPngImageList(Images).PngImages.Items[ImageIndex]).PngImage;
PngCopy.Draw(SkinData.FCacheBmp.Canvas, IRect);
end
else begin
if Blend > 0 then begin
PngCopy := TPNGObject.Create;
PngCopy.Assign(TPngImageCollectionItem(TPngImageList(Images).PngImages.Items[ImageIndex]).PngImage);
MakeImageBlended(PngCopy);
end;
if Grayed then begin
if PngCopy = nil then begin
PngCopy := TPNGObject.Create;
PngCopy.Assign(TPngImageCollectionItem(TPngImageList(Images).PngImages.Items[ImageIndex]).PngImage);
end;
MakeImageGrayscale(PngCopy);
end;
PngCopy.Draw(SkinData.FCacheBmp.Canvas, IRect);
FreeAndNil(PngCopy);
end;
end
else begin
if dgBlended in DisabledGlyphKind then begin
PngCopy := TPNGObject.Create;
PngCopy.Assign(TPngImageCollectionItem(TPngImageList(Images).PngImages.Items[ImageIndex]).PngImage);
MakeImageBlended(PngCopy);
end;
if dgGrayed in DisabledGlyphKind then begin
if PngCopy = nil then begin
PngCopy := TPNGObject.Create;
PngCopy.Assign(TPngImageCollectionItem(TPngImageList(Images).PngImages.Items[ImageIndex]).PngImage);
end;
MakeImageGrayscale(PngCopy);
end;
if PngCopy = nil then begin
PngCopy := TPngImageCollectionItem(TPngImageList(Images).PngImages.Items[ImageIndex]).PngImage;
PngCopy.Draw(SkinData.FCacheBmp.Canvas, IRect);
end
else begin
PngCopy.Draw(SkinData.FCacheBmp.Canvas, IRect);
FreeAndNil(PngCopy);
end;
end;
end
else
{$ENDIF}
begin
Bmp := TBitmap.Create;
try
PrepareGlyph;
if not Enabled then begin
if dgGrayed in DisabledGlyphKind then begin
GrayScaleTrans(Bmp, ColorToSColor(Bmp.Canvas.Pixels[0, Bmp.Height - 1])); // v4.80
end;
if dgBlended in DisabledGlyphKind then begin
BlendTransRectangle(SkinData.FCacheBmp, IRect.Left, IRect.Top, Bmp,
Rect(0, 0, Bmp.Width, Bmp.Height),
0.5, MaskColor);
end
else begin
CopyTransBitmaps(SkinData.FCacheBmp, Bmp, IRect.Left, IRect.Top, MaskColor);
end;
end
else begin
if not ControlIsActive(SkinData) and Grayed then begin
GrayScaleTrans(Bmp, ColorToSColor(Bmp.Canvas.Pixels[0, Bmp.Height - 1])); // v4.80
end;
if not ControlIsActive(SkinData) and (Blend > 0) then begin
BlendTransRectangle(SkinData.FCacheBmp, IRect.Left, IRect.Top, Bmp,
Rect(0,
0,
Bmp.Width,
Bmp.Height),
Blend / 100, MaskColor);
end
else begin
CopyTransBitmaps(SkinData.FCacheBmp, Bmp, IRect.Left, IRect.Top, MaskColor);
end;
end;
finally
FreeAndNil(Bmp);
end;
end;
end;
end;
end;
{$IFNDEF ALITE}
procedure CopyToolBtnGlyph(ToolBar : TsToolBar; Button : TToolButton; State: TCustomDrawState; Stage: TCustomDrawStage; var Flags: TTBCustomDrawFlags; BtnBmp : TBitmap);
var
IRect : TRect;
Mode : integer;
Bmp : TBitmap;
MaskColor : TsColor;
{$IFDEF USEPNG}
PngCopy: TPNGObject;
{$ENDIF}
function AddedWidth : integer; begin
Result := integer(Button.Style = tbsDropDown) * 8;
end;
function ImgRect : TRect;
begin
with ToolBar do begin
if not List then begin
Result.Left := (Button.Width - Images.Width) div 2 + 1 - AddedWidth;
Result.Top := (Button.Height - Images.Height - integer(ShowCaptions) * (SkinData.FCacheBMP.Canvas.TextHeight('A') + 3)) div 2;
Result.Right := Result.Left + Images.Width;
Result.Bottom := Result.Top + Images.Height;
end
else begin
Result.Left := 5;
Result.Top := (Button.Height - Images.Height) div 2;
Result.Right := Result.Left + Images.Width;
Result.Bottom := Result.Top + Images.Height;
end;
if (Mode = 2) //or (cdsChecked in State)
then OffsetRect(Result, 1, 1);
end;
end;
function Imges : TCustomImageList; begin
with ToolBar do
if (Mode <> 0) and Assigned(HotImages) and (Button.ImageIndex < HotImages.Count) then begin
Result := HotImages;
end
else Result := Images;
end;
procedure PrepareGlyph;
begin
Bmp.Width := Imges.Width;
Bmp.Height := Imges.Height;
Bmp.PixelFormat := pf24bit;
if ToolBar.Images.BkColor <> clNone then MaskColor.C := ToolBar.Images.BkColor else MaskColor.C := clFuchsia;
Bmp.Canvas.Brush.Color := MaskColor.C;
Bmp.Canvas.FillRect(Rect(0, 0, Bmp.Width, Bmp.Height));
Imges.GetBitmap(Button.ImageIndex, Bmp);
end;
begin
with ToolBar do begin
if (State = []) or (State = [cdsDisabled]) then Mode := 0 else if (cdsSelected in State) or (cdsChecked in State)
then Mode := 2
else Mode := 1;
IRect := ImgRect;
{$IFDEF USEPNG}
if Imges is TPngImageList then begin
PngCopy := nil;
if Enabled then begin
PngCopy := TPngImageCollectionItem(TPngImageList(Imges).PngImages.Items[Button.ImageIndex]).PngImage;
PngCopy.Draw(BtnBmp.Canvas, IRect);
end
else begin
PngCopy := TPNGObject.Create;
PngCopy.Assign(TPngImageCollectionItem(TPngImageList(Imges).PngImages.Items[Button.ImageIndex]).PngImage);
MakeImageBlended(PngCopy);
if PngCopy = nil then begin
PngCopy := TPngImageCollectionItem(TPngImageList(Imges).PngImages.Items[Button.ImageIndex]).PngImage;
PngCopy.Draw(BtnBmp.Canvas, IRect);
end
else begin
PngCopy.Draw(BtnBmp.Canvas, IRect);
FreeAndNil(PngCopy);
end;
end;
end
else
{$ENDIF}
begin
Bmp := TBitmap.Create;
try
PrepareGlyph;
CopyTransBitmaps(BtnBmp, Bmp, ImgRect.left, ImgRect.Top{IRect.Left + integer(Mode = 2), IRect.Top + integer(Mode = 2)}, MaskColor);
finally
FreeAndNil(Bmp);
end;
end;
end;
end;
{$ENDIF}
procedure DoActionChanging(Button : TsBitBtn; Action : TCustomAction);
begin
{$IFDEF USEPNG}
if (Action.ActionList <> nil) and (Action.ActionList.Images <> nil) and (Action.ActionList.Images is TPNGImageList) and
(Action.ImageIndex >= 0) {and (ImageIndex < TCustomAction(Sender).ActionList.Images.Count)} then begin
Button.Glyph.Assign(nil);
Button.Images := Action.ActionList.Images;
Button.ImageIndex := Action.ImageIndex;
end;
{$ENDIF}
end;
procedure DoActionChanging(Button : TsSpeedButton; Action : TCustomAction); overload;
begin
{$IFDEF USEPNG}
if (Action.ActionList <> nil) and (Action.ActionList.Images <> nil) and (Action.ActionList.Images is TPNGImageList) and
(Action.ImageIndex >= 0) {and (ImageIndex < TCustomAction(Sender).ActionList.Images.Count)} then begin
Button.Glyph.Assign(nil);
Button.Images := Action.ActionList.Images;
Button.ImageIndex := Action.ImageIndex;
end;
{$ENDIF}
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -