📄 abhbar.pas
字号:
min_w := w;
if opOverflow in Options then
min_w := min_w + BarSettings.minHeight + 6
else
if (MinMax.MinVisible or MinMax.MaxVisible) then
min_w := min_w + hMinMax;
if opName1 in FOptions then
begin
min_h := min_h + sName1.cy;
w := 0;
if opBevelOuter in FOptions then w := w + BevelOuter.TotalWidth * 2;
if opBevelInner in FOptions then w := w + BevelInner.TotalWidth * 2;
GetMin(min_w, w + sName1.cx);
end;
if opName2 in FOptions then
begin
min_h := min_h + sName2.cy;
w := 0;
if opBevelOuter in FOptions then w := w + BevelOuter.TotalWidth * 2;
if opBevelInner in FOptions then w := w + BevelInner.TotalWidth * 2;
GetMin(min_w, w + sName2.cx);
end;
if opBevelInner in FOptions then
begin
min_h := min_h + BevelInner.TotalWidth * 2;
w := w + BevelInner.TotalWidth * 2;
GetMin(min_w, w);
end;
if opValue in FOptions then
begin
min_h := min_h + sValue.cy + BevelValue.TotalWidth * 2 +
BevelInner.TotalWidth - sValue.cy div 6;
w := 0;
if opBevelOuter in FOptions then w := w + BevelOuter.TotalWidth * 2;
if opBevelInner in FOptions then w := w + BevelInner.TotalWidth * 2;
GetMin(min_w, w + sValue.cx + sUnit.cx + BevelValue.TotalWidth * 2 +
sValue.cy div 3);
end;
if (MinMax.FMinVisible or MinMax.MaxVisible) then min_h := min_h + hMinMax;
if not AutoSize and ((Width < min_w) or (Height < min_h)) then
begin
if Width < min_w then
begin
Width := min_w;
end;
if Height < min_h then
begin
Height := min_h;
end;
end;
if AutoSize and ((Width <> min_w) or (Height <> min_h)) then
begin
SetBounds(Left, Top, min_w, min_h);
end;
r := ClientRect;
if opBevelOuter in FOptions then
begin
FBevelOuter.PaintFilledBevel(Canvas, r);
space := BevelOuter.Spacing div 2;
end
else
space := 0;
Canvas.Brush.Style := bsClear;
Canvas.Font := Font;
if opName2 in FOptions then
begin
r.Bottom := r.Bottom - sName2.cy;
Canvas.textout(r.Left + ((r.Right - r.Left - sName2.cx) div 2),
r.Bottom + space, SignalSettings.Name2);
end;
if opName1 in FOptions then
begin
r.Bottom := r.Bottom - sName1.cy;
Canvas.textout(r.Left + ((r.Right - r.Left - sName1.cx) div 2),
r.Bottom + space, SignalSettings.Name1);
end;
if opBevelInner in FOptions then FBevelInner.PaintFilledBevel(Canvas, r);
Canvas.Font := FontValue;
if opValue in FOptions then
begin
h := FBevelValue.TotalWidth * 2 + sValue.cy;
w := sValue.cy div 6;
rValue.Left := r.Left + (r.Right - r.Left - sValue.cx - sUnit.cx - w) div 2
- w;
rValue.Top := r.Top;
rValue.Right := rValue.Left + sValue.cx + BevelValue.TotalWidth * 2 + w + w;
rValue.Bottom := r.Top + h;
FBevelValue.PaintFilledBevel(Canvas, rValue);
Canvas.Font.Color := Font.Color;
Canvas.Brush.Style := bsClear;
if opUnit in FOptions then
Canvas.textout(rValue.Right + w, rValue.Top, SignalSettings.ValueUnit);
rValue.Left := rValue.Left + w;
rValue.Right := rValue.Right - w;
r.Top := r.Top + h + BevelInner.Spacing;
end;
h := (BarSettings.Bevel.TotalWidth) * 2 + BarSettings.minHeight;
if (MinMax.MinVisible or MinMax.MaxVisible) then
y := (r.Bottom - r.Top - h + hMinMax) div 2
else
y := (r.Bottom - r.Top - h) div 2;
r.Top := r.Top + y;
r.Bottom := r.Top + h;
if opOverflow in Options then
begin
h := (BarSettings.Bevel.TotalWidth) * 2 + BarSettings.minHeight - 1;
Offset := h + 6;
r.Left := r.Left + Offset div 2;
r.Right := r.Right - Offset div 2;
x := r.Left - 3;
y := r.Top;
pUOverflow[0] := Point(x, y);
pUOverflow[1] := Point(x, y + h);
pUOverflow[2] := Point(x - h div 2, y + h div 2);
pUOverflow[3] := pUOverflow[0];
x := r.Right + 2;
pLOverflow[0] := Point(x, y);
pLOverflow[1] := Point(x, y + h);
pLOverflow[2] := Point(x + h div 2, y + h div 2);
pLOverflow[3] := pLOverflow[0];
DrawOverflow(Canvas, clBtnFace, clBtnFace);
end
else
if (MinMax.MinVisible or MinMax.MaxVisible) then
begin
r.Left := r.Left + hMinMax div 2;
r.Right := r.Right - hMinMax div 2;
end;
FBarSettings.Bevel.PaintFilledBevel(Canvas, r);
FBarSettings.BarRect := r;
rBuffer := r;
pos0 := r.Left;
pos100 := r.Right;
rBuffer.Bottom := rBuffer.Top;
rBuffer.Top := rBuffer.Bottom - hMinMax;
rBuffer.Left := rBuffer.Left - hMinMax div 2;
rBuffer.Right := rBuffer.Right + hMinMax div 2 + 1;
BmpBuffer.Width := rBuffer.Right - rBuffer.Left;
BmpBuffer.Height := rBuffer.Bottom - rBuffer.Top;
//BmpBuffer.Canvas.CopyRect(BmpBuffer.Canvas.Cliprect, Canvas, rBuffer);
GetBkUpImage(Canvas,BmpBuffer,rBuffer);
ValueChange;
end;
procedure TAbHBar.ValueChange;
var
TempBmp : TBitmap;
posMin, posMax : Smallint;
// posUL, posLL: Smallint;
PixPerPPT : Single;
x1, x2 : Integer;
cl : TColor;
begin
inherited ValueChange;
if Assigned(BmpBuffer) then
if BmpBuffer.Width < 2 then Exit;
if not (Visible or (csDesigning in Componentstate)) then Exit;
x1 := pos0 - rBuffer.Left;
x2 := (pos100 - rBuffer.Left);
PixPerPPT := (((x2 - x1)) / 1000);
posMax := x1 + Round(PixPerPPT * MaxPPT);
posMin := x1 + Round(PixPerPPT * MinPPT);
{ calculation of lower/upper limitation
posUL := x1 + Round(PixPerPPT * ULimitPPT);
posLL := x1 + Round(PixPerPPT * LLimitPPT);
}
TempBmp := TBitmap.Create;
TempBmp.Assign(BmpBuffer);
minPointer[0].x := posMin;
minPointer[0].y := 0;
minPointer[1].x := posMin;
minPointer[1].y := hMinMax;
minPointer[2].x := minPointer[0].x - hMinMax div 2;
minPointer[2].y := minPointer[0].y;
maxPointer[0].x := posMax;
maxPointer[0].y := 0;
maxPointer[1].x := posMax + hMinMax div 2;
maxPointer[1].y := 0;
maxPointer[2].x := posMax;
maxPointer[2].y := hMinMax;
if MinMax.FMinVisible then
begin
if MinMax.UseSectorCol and SectorSettings.CheckSectorColor(MinPPT, cl) then
TempBmp.Canvas.Brush.Color := cl
else
TempBmp.Canvas.Brush.Color := MinMax.FMinColor;
TempBmp.Canvas.Polygon(minPointer);
end;
if MinMax.FMaxVisible then
begin
if MinMax.UseSectorCol and SectorSettings.CheckSectorColor(MaxPPT, cl) then
TempBmp.Canvas.Brush.Color := cl
else
TempBmp.Canvas.Brush.Color := MinMax.FMaxColor;
TempBmp.Canvas.Polygon(maxPointer);
end;
Canvas.Draw(rBuffer.Left, rBuffer.Top, TempBmp);
TempBmp.Free;
if not (Visible or (csDesigning in Componentstate)) then Exit;
BarSettings.Value := ValueStr;
if (opUseSectorCol in FBarSettings.Options)
and (InSector1 or InSector2 or InSector3) then
FBarSettings.SectorCol := ActSectorCol
else
FBarSettings.SectorCol := FBarSettings.Color;
FBarSettings.PaintBar(Canvas, PPT);
if opValue in FOptions then
begin
TempBmp := TBitmap.Create;
TempBmp.Width := rValue.Right - rValue.Left;
TempBmp.Height := rValue.Bottom - rValue.Top;
TempBmp.Canvas.Font := FontValue;
with TempBmp.Canvas do
begin
Brush.Style := bsSolid;
Brush.Color := FBevelValue.Color;
Pen.Color := FBevelValue.Color;
Rectangle(0, 0, Width, Height);
Brush.Style := bsClear;
if csDesigning in Componentstate then
textout(TempBmp.Width - TextWidth(SignalSettings.ValueSizeStr), 0,
SignalSettings.ValueSizeStr)
else
textout(TempBmp.Width - TextWidth(ValueStr), 0, ValueStr);
end;
Canvas.Draw(rValue.Left, rValue.Top, TempBmp);
TempBmp.Free;
end;
end;
procedure TAbHBar.ParamChange(Sender: TObject);
begin
inherited ParamChange(Sender);
if Assigned(BarSettings) then BarSettings.ppt0 := SignalSettings.GetPPT(0);
Invalidate;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -