📄 sthirdparty.pas
字号:
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 not Glyph.Empty then begin
sGraphUtils.DrawGlyphEx(Glyph, SkinData.FCacheBmp, ImgRect, NumGlyphs, Enabled, DisabledGlyphKind, Button.CurrentState, Blend, Button.Down);
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}
if (Images is TsAlphaImageList) or not SkinData.Skinned then begin
if SkinData.Skinned
then DrawAlphaImgList(Images, SkinData.FCacheBmp, IRect.Left, IRect.Top, ImageIndex, iffi(CurrentState = 0, Blend, 0), iffi((CurrentState = 0) and Grayed, clNone, clNone), CurrentState, NumGlyphs)
else DrawAlphaImgListDC(Images, Canvas.Handle, IRect.Left, IRect.Top, ImageIndex, iffi(CurrentState = 0, Blend, 0), iffi((CurrentState = 0) and Grayed, clNone, clNone), CurrentState, NumGlyphs);
end
else 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]));
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]));
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) 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}
if (Images is TsAlphaImageList) or not SkinData.Skinned then begin
IRect := ImgRect;
Images.Draw(BtnBmp.Canvas, IRect.Left, IRect.Top, Button.ImageIndex)
end
else begin
Bmp := TBitmap.Create;
try
PrepareGlyph;
CopyTransBitmaps(BtnBmp, Bmp, ImgRect.left, ImgRect.Top, MaskColor);
finally
FreeAndNil(Bmp);
end;
end;
end;
end;
{$ENDIF}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -