salphagraph.pas
来自「Alpha Controls 5.40,delphi上的alpha开发源码控件包」· PAS 代码 · 共 1,529 行 · 第 1/5 页
PAS
1,529 行
if y < R.Bottom - h then begin
CopyMasterRect(Rect(R.Left, y, R.Left + minw, R.Bottom - h), Rect(MaskData.R.Left + dw, MaskData.R.Top + h, MaskData.R.Left + dw + minw, MaskData.R.Top + dh - h), Bmp, CI, MaskData);
end;
// top - middle
x := R.Left + w;
while x < R.Right - 2 * w do begin
CopyMasterRect(Rect(x, R.Top, x + w, R.Top + minh), Rect(MaskData.R.Left + dw + w, MaskData.R.Top, MaskData.R.Left + dw + 2 * w, MaskData.R.Top + minh), Bmp, CI, MaskData);
inc(x, w);
end;
if x < R.Right - w then begin
CopyMasterRect(Rect(x, R.Top, R.Right - w, R.Top + minh), Rect(MaskData.R.Left + dw + w, MaskData.R.Top, MaskData.R.Left + dw + 2 * w, MaskData.R.Top + minh), Bmp, CI, MaskData);
end;
// left - bottom
CopyMasterRect(Rect(R.Left, R.Bottom - minhp, R.Left + minw, R.Bottom), Rect(MaskData.R.Left + dw, MaskData.R.Top + dh - minhp, MaskData.R.Left + dw + minw, MaskData.R.Top + dh), Bmp, CI, MaskData);
// bottom - middle
x := R.Left + w;
while x < R.Right - 2 * w do begin
CopyMasterRect(Rect(x, R.Bottom - minhp, x + w, R.Bottom), Rect(MaskData.R.Left + dw + w, MaskData.R.Top + dh - minhp, MaskData.R.Left + dw + 2 * w, MaskData.R.Top + dh), Bmp, CI, MaskData);
inc(x, w);
end;
if x < R.Right - w then begin
CopyMasterRect(Rect(x, R.Bottom - minhp, R.Right - w, R.Bottom), Rect(MaskData.R.Left + dw + w, MaskData.R.Top + dh - minhp, MaskData.R.Left + dw + 2 * w, MaskData.R.Top + dh), Bmp, CI, MaskData);
end;
// right - bottom
CopyMasterRect(Rect(R.Right - minwp, R.Bottom - minhp, R.Right, R.Bottom), Rect(MaskData.R.Left + dw + 3 * w - minwp, MaskData.R.Top + dh - minhp, MaskData.R.Left + dw + 3 * w, MaskData.R.Top + dh), Bmp, CI, MaskData);
// right - top
CopyMasterRect(Rect(R.Right - minwp, R.Top, R.Right, R.Top + minh), Rect(MaskData.R.Left + dw + 3 * w - minwp, MaskData.R.Top, MaskData.R.Left + dw + 3 * w, MaskData.R.Top + minh), Bmp, CI, MaskData);
// right - middle
y := R.Top + h;
while y < R.Bottom - {2 * v4.13} h do begin
CopyMasterRect(Rect(R.Right - minwp, y, R.Right, y + h), Rect(MaskData.R.Left + dw + 3 * w - minwp, MaskData.R.Top + h, MaskData.R.Left + dw + 3 * w, MaskData.R.Top + 2 * h), Bmp, CI, MaskData);
inc(y, h);
end;
if y < R.Bottom - h then begin
CopyMasterRect(Rect(R.Right - minwp, y, R.Right, R.Bottom - h), Rect(MaskData.R.Left + dw + 3 * w - minwp, MaskData.R.Top + h, MaskData.R.Left + dw + 3 * w, MaskData.R.Top + 2 * h), Bmp, CI, MaskData);
end;
// Fill
if Filling and (MaskData.DrawMode and BDM_FILL = BDM_FILL) then begin
y := R.Top + h;
while y < R.Bottom - {2 * v4.13} h do begin
x := R.Left + w;
while x < R.Right - 2 * { v4.32 } w do begin
CopyMasterRect(Rect(x, y, x + w, y + h), Rect(MaskData.R.Left + dw + w, MaskData.R.Top + h, MaskData.R.Left + dw + 2 * w, MaskData.R.Top + 2 * h), Bmp, EmptyCI, MaskData);
inc(x, w);
end;
if x < R.Right - w then begin
CopyMasterRect(Rect(x, y, R.Right - w, y + h), Rect(MaskData.R.Left + dw + w, MaskData.R.Top + h, MaskData.R.Left + dw + 2 * w, MaskData.R.Top + 2 * h), Bmp, EmptyCI, MaskData);
end;
inc(y, h);
end;
x := R.Left + w;
if y < R.Bottom - h then begin
while x < R.Right - 2 * w do begin
CopyMasterRect(Rect(x, y, x + w, R.Bottom - h), Rect(MaskData.R.Left + dw + w, MaskData.R.Top + h, MaskData.R.Left + dw + 2 * w, MaskData.R.Top + 2 * h), Bmp, EmptyCI, MaskData);
inc(x, w);
end;
if x < R.Right - w then begin
CopyMasterRect(Rect(x, y, R.Right - w, R.Bottom - h), Rect(MaskData.R.Left + dw + w, MaskData.R.Top + h, MaskData.R.Left + dw + 2 * w, MaskData.R.Top + 2 * h), Bmp, EmptyCI, MaskData);
end
end;
end;
end;
end;
end;
procedure DrawSkinRect(Bmp : TBitmap; R : TRect; Filling : boolean; ci : TCacheInfo; MaskData : TsMaskData; State : integer; UpdateCorners : boolean; SkinManager : TObject = nil);
var
x, y : integer;
w, h : integer;
dw, dh : integer;
wl, wt, wr, wb : integer;
BmpSrc : TBitmap;
begin
if (State = 0) and (MaskData.DrawMode and BDM_ACTIVEONLY = BDM_ACTIVEONLY) then Exit;
if (WidthOf(R) < 2) or (HeightOf(R) < 2) or (MaskData.Manager = nil) then Exit;
wl := MaskData.WL; wt := MaskData.WT; wr := MaskData.WR; wb := MaskData.WB;
if wl + wr > WidthOf(R) then begin
x := ((wl + wr) - WidthOf(R)) div 2;
dec(wl, x); dec(wr, x); if WidthOf(R) mod 2 > 0 then dec(wr);
if wl < 0 then wl := 0;
if wr < 0 then wr := 0;
end;
if wt + wb > HeightOf(R) then begin
x := ((wt + wb) - HeightOf(R)) div 2;
dec(wt, x); dec(wb, x); if HeightOf(R) mod 2 > 0 then dec(wb);
if wt < 0 then wt := 0;
if wb < 0 then wb := 0;
end;
if State >= MaskData.ImageCount then State := MaskData.ImageCount - 1;
dw := WidthOf(MaskData.R) div MaskData.ImageCount; // Width of mask
dh := HeightOf(MaskData.R) div (1 + MaskData.MaskType); // Height of mask
w := dw - wl - wr; if w < 0 then w := 0; // Width of middle piece
h := dh - wt - wb; if h < 0 then h := 0; // Height of middle piece
dw := dw * State; // Offset of mask
if MaskData.Bmp <> nil then BmpSrc := MaskData.Bmp else BmpSrc := TsSkinManager(MaskData.Manager).MasterBitmap;
if MaskData.MaskType = 0 then begin // Copy without mask
// left - top
CopyTransRect(Bmp, BmpSrc, R.Left, R.Top,
Rect(MaskData.R.Left + dw,
MaskData.R.Top,
MaskData.R.Left + dw + wl - 1,
MaskData.R.Top + wt - 1),
clFuchsia, CI, UpdateCorners);
y := R.Top + wt;
// left - middle
if MaskData.DrawMode and BDM_STRETCH = 0 then begin
if h > 0 then while y < R.Bottom - h - wb do begin
BitBlt(Bmp.Canvas.Handle, R.Left, y, wl, h, BmpSrc.Canvas.Handle, MaskData.R.Left + dw, MaskData.R.Top + wt, SRCCOPY);
inc(y, h);
end;
if y < R.Bottom - wb then BitBlt(Bmp.Canvas.Handle, R.Left, y, wl, R.Bottom - wb - y, BmpSrc.Canvas.Handle, MaskData.R.Left + dw, MaskData.R.Top + wt, SRCCOPY);
end
else begin
SetStretchBltMode(Bmp.Canvas.Handle, HALFTONE);
StretchBlt(Bmp.Canvas.Handle,
R.Left, y, wl, R.Bottom - wb - y,
BmpSrc.Canvas.Handle,
MaskData.R.Left + dw, MaskData.R.Top + wt, wl, h,
SRCCOPY); // v4.52
end;
// top - middle
x := R.Left + wl;
if MaskData.DrawMode and BDM_STRETCH = 0 then begin
if w > 0 then while x < R.Right - w - wr do begin
BitBlt(Bmp.Canvas.Handle, x, R.Top, w, wt, BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Top, SRCCOPY);
inc(x, w);
end;
if x < R.Right - wr then BitBlt(Bmp.Canvas.Handle, x, R.Top, R.Right - wr - x, wt, BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Top, SRCCOPY);
end
else StretchBlt(Bmp.Canvas.Handle,
x, R.Top, R.Right - wr - x, wt,
BmpSrc.Canvas.Handle,
MaskData.R.Left + dw + wl, MaskData.R.Top, w, wt,
SRCCOPY); // v4.52
// left - bottom
CopyTransRect(Bmp, BmpSrc, R.Left, R.Bottom - wb,
Rect(MaskData.R.Left + dw,
MaskData.R.Bottom - wb,
MaskData.R.Left + dw + wl - 1,
MaskData.R.Bottom - 1),
clFuchsia, CI, UpdateCorners);
// bottom - middle
x := R.Left + wl;
if MaskData.DrawMode and BDM_STRETCH = 0 then begin
if w > 0 then while x < R.Right - w - wr do begin
BitBlt(Bmp.Canvas.Handle, x, R.Bottom - wb, w, wb,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Bottom - wb, SRCCOPY);
inc(x, w);
end;
if x < R.Right - wr then BitBlt(Bmp.Canvas.Handle, x, R.Bottom - wb, R.Right - wr - x, wb,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Bottom - wb, SRCCOPY);
end
else StretchBlt(Bmp.Canvas.Handle,
x, R.Bottom - wb, R.Right - wr - x, wb,
BmpSrc.Canvas.Handle,
MaskData.R.Left + dw + wl, MaskData.R.Bottom - wb, w, wb,
SRCCOPY); // v4.52
// right - bottom
CopyTransRect(Bmp, BmpSrc, R.Right - wr, R.Bottom - wb,
Rect(MaskData.R.Left + dw + w + wl,
MaskData.R.Bottom - wb,
MaskData.R.Left + dw + w + wl + wr - 1,
MaskData.R.Bottom - 1),
clFuchsia, CI, UpdateCorners);
// right - top
CopyTransRect(Bmp, BmpSrc, R.Right - wr, R.Top,
Rect(MaskData.R.Left + dw + w + wl,
MaskData.R.Top,
MaskData.R.Left + dw + w + wl + wr - 1,
MaskData.R.Top + wt - 1),
clFuchsia, CI, UpdateCorners);
y := R.Top + wt;
// right - middle
if MaskData.DrawMode and BDM_STRETCH = 0 then begin
if h > 0 then while y < R.Bottom - h - wb do begin
BitBlt(Bmp.Canvas.Handle, R.Right - wr, y, wr, h,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl + w, MaskData.R.Top + wt, SRCCOPY);
inc(y, h);
end;
if y < R.Bottom - wb then BitBlt(Bmp.Canvas.Handle, R.Right - wr, y, wr, R.Bottom - wb - y,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + w + wl, MaskData.R.Top + wt, SRCCOPY);
end
else StretchBlt(Bmp.Canvas.Handle,
R.Right - wr, y, wr, R.Bottom - wb - y,
BmpSrc.Canvas.Handle,
MaskData.R.Left + dw + wl + w, MaskData.R.Top + wt, wr, h,
SRCCOPY); // v4.52
// Fill
if Filling and (MaskData.DrawMode and BDM_FILL = BDM_FILL) then begin
if MaskData.DrawMode and BDM_STRETCH = 0 then begin
y := R.Top + wt;
if h > 0 then while y < R.Bottom - h - wb do begin
x := R.Left + wl;
if w > 0 then while x < R.Right - w - wr do begin
BitBlt(Bmp.Canvas.Handle, x, y, w, h{R.Bottom - wb - y}, BmpSrc.Canvas.Handle,
MaskData.R.Left + dw + wl, MaskData.R.Top + wt, SRCCOPY);
inc(x, w);
end;
if x < R.Right - wr then BitBlt(Bmp.Canvas.Handle, x, y, R.Right - wr - x, R.Bottom - wb - y,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Top + wt, SRCCOPY);
inc(y, h);
end;
x := R.Left + wl;
if y < R.Bottom - wb then begin
if w > 0 then while x < R.Right - w - wr do begin
BitBlt(Bmp.Canvas.Handle, x, y, w, R.Bottom - wb - y,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Top + wt, SRCCOPY);
inc(x, w);
end;
if x < R.Right - wr then BitBlt(Bmp.Canvas.Handle, x, y, R.Right - wr - x, R.Bottom - wb - y,
BmpSrc.Canvas.Handle, MaskData.R.Left + dw + wl, MaskData.R.Top + wt, SRCCOPY);
end;
end
else begin
y := R.Top + wt;
x := R.Left + wl;
StretchBlt(Bmp.Canvas.Handle,
x, y, R.Right - wr - x, R.Bottom - wb - y,
BmpSrc.Canvas.Handle,
MaskData.R.Left + dw + wl, MaskData.R.Top + wt, w, h,
SRCCOPY); // v4.52
end;
end;
end
else begin
// left - top
CopyByMask(Rect(R.Left, R.Top, R.Left + wl, R.Top + wt),
Rect(MaskData.R.Left + dw, MaskData.R.Top, MaskData.R.Left + dw + wl, MaskData.R.Top + wt),
Bmp, BmpSrc, CI, True, MaskData);
y := R.Top + wt;
// left - middle
while y < R.Bottom - h - wb do begin
CopyByMask(Rect(R.Left, y, R.Left + wl, y + h),
Rect(MaskData.R.Left + dw, MaskData.R.Top + wt, MaskData.R.Left + dw + wl, MaskData.R.Top + h + wt),
Bmp, BmpSrc, EmptyCI, False, MaskData);
inc(y, h);
end;
if y < R.Bottom - wb then begin
CopyByMask(Rect(R.Left, y, R.Left + wl, R.Bottom - wb), Rect(MaskData.R.Left + dw, MaskData.R.Top + wt, MaskData.R.Left + dw + wl, MaskData.R.Top + wt + h), Bmp, BmpSrc, EmptyCI, False, MaskData);
end;
// top - middle
x := R.Left + wl;
while x < R.Right - w - wr do begin
CopyByMask(Rect(x, R.Top, x + w, R.Top + wt), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top, MaskData.R.Left + dw + w + wl, MaskData.R.Top + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
inc(x, w);
end;
if x < R.Right - wr then begin
CopyByMask(Rect(x, R.Top, R.Right - wr, R.Top + wt), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top, MaskData.R.Left + dw + w + wl, MaskData.R.Top + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
end;
// left - bottom
CopyByMask(Rect(R.Left, R.Bottom - wb, R.Left + wl, R.Bottom),
Rect(MaskData.R.Left + dw, MaskData.R.Top + dh - wb, MaskData.R.Left + dw + wl, MaskData.R.Top + dh),
Bmp, BmpSrc, CI, True, MaskData);
// bottom - middle
x := R.Left + wl;
while x < R.Right - w - wr do begin
CopyByMask(Rect(x, R.Bottom - wb, x + w, R.Bottom), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top + dh - wb, MaskData.R.Left + dw + w + wl, MaskData.R.Top + dh), Bmp, bmpSrc, EmptyCI, False, MaskData);
inc(x, w);
end;
if x < R.Right - wr then begin
CopyByMask(Rect(x, R.Bottom - wb, R.Right - wr, R.Bottom), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top + dh - wb, MaskData.R.Left + dw + w + wl, MaskData.R.Top + dh), Bmp, BmpSrc, EmptyCI, False, MaskData);
end;
// right - bottom
CopyByMask(Rect(R.Right - wr, R.Bottom - wb, R.Right, R.Bottom), Rect(MaskData.R.Left + dw + w + wl, MaskData.R.Top + dh - wb, MaskData.R.Left + dw + w + wl + wr, MaskData.R.Top + dh), Bmp, BmpSrc, CI, True, MaskData);
// right - top
CopyByMask(Rect(R.Right - wr, R.Top, R.Right, R.Top + wt), Rect(MaskData.R.Left + dw + w + wl, MaskData.R.Top, MaskData.R.Left + dw + w + wl + wr, MaskData.R.Top + wt), Bmp, BmpSrc, CI, True, MaskData);
// right - middle
y := R.Top + wt;
while y < R.Bottom - h - wb do begin
CopyByMask(Rect(R.Right - wr, y, R.Right, y + h), Rect(MaskData.R.Left + dw + w + wl, MaskData.R.Top + wt, MaskData.R.Left + dw + w + wl + wr, MaskData.R.Top + h + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
inc(y, h);
end;
if y < R.Bottom - wb then begin
CopyByMask(Rect(R.Right - wr, y, R.Right, R.Bottom - wb), Rect(MaskData.R.Left + dw + w + wl, MaskData.R.Top + wt, MaskData.R.Left + dw + w + wl + wr, MaskData.R.Top + h + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
end;
// Fill
if Filling and (MaskData.DrawMode and BDM_FILL = BDM_FILL) then begin
y := R.Top + wt;
while y < R.Bottom - h - wb do begin
x := R.Left + wl;
while x < R.Right - w - wr do begin
CopyByMask(Rect(x, y, x + w, y + h), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top + wt, MaskData.R.Left + dw + w + wl, MaskData.R.Top + h + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
inc(x, w);
end;
if x < R.Right - wr then begin
CopyByMask(Rect(x, y, R.Right - wr, y + h), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top + wt, MaskData.R.Left + dw + w + wl, MaskData.R.Top + h + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
end;
inc(y, h);
end;
x := R.Left + wl;
if y < R.Bottom - wb then begin
while x < R.Right - w - wr do begin
CopyByMask(Rect(x, y, x + w, R.Bottom - wb), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top + wt, MaskData.R.Left + dw + w + wl, MaskData.R.Top + h + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
inc(x, w);
end;
if x < R.Right - wr then begin
CopyByMask(Rect(x, y, R.Right - wr, R.Bottom - wb), Rect(MaskData.R.Left + dw + wl, MaskData.R.Top + wt, MaskData.R.Left + dw + w + wl, MaskData.R.Top + h + wt), Bmp, BmpSrc, EmptyCI, False, MaskData);
end
end;
end;
end;
end;
procedure CopyMasterRect(R1, R2 : TRect; Bmp : TBitmap; CI : TCacheInfo; MaskData : TsMaskData);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?