📄 islider.pas
字号:
with Canvas, FTrackRect do
begin
Brush.Style := bsSolid;
case FTrackStyle of
istsBox : begin
Brush.Color := FTrackColor;
FillRect(FTrackRect);
Pen.Color := clBtnShadow;
PolyLine([Point(Right,Top), Point (Left, Top), Point(Left, Bottom)]);
if BackGroundColor = clWhite then Pen.Color := clBlack;
PolyLine([Point(Right-1,Top+1), Point (Left+1, Top+1), Point(Left+1, Bottom-1)]);
Pen.Color := clBtnHighlight;
PolyLine([Point(Right-1,Top), Point (Right-1, Bottom-1), Point(Left, Bottom-1)]);
Pen.Color := clSilver;
PolyLine([Point(Right-2,Top+2), Point (Right-2, Bottom-2), Point(Left, Bottom-2)]);
end;
istsLine : begin
case FOrientation of
ioHorizontal : begin
Pen.Color := FTrackColor;
PolyLine([Point(Left+FTrack3DMargin,(Top+Bottom)div 2),Point(Right-FTrack3DMargin,(Top+Bottom)div 2)]);
end;
ioVertical : begin
Pen.Color := FTrackColor;
PolyLine([Point((Left+Right)div 2,Top+FTrack3DMargin),Point((Left+Right)div 2,Bottom-FTrack3DMargin)]);
end;
end;
end;
istsBevelLowered : begin
case FOrientation of
ioHorizontal : begin
Pen.Color := clBtnShadow;
PolyLine([Point(Left+FTrack3DMargin,(Top+Bottom)div 2 -2),Point(Right-FTrack3DMargin,(Top+Bottom)div 2- 2)]);
PolyLine([Point(Left+FTrack3DMargin,(Top+Bottom)div 2 -1),Point(Right-FTrack3DMargin,(Top+Bottom)div 2- 1)]);
Pen.Color := clBtnHighlight;
PolyLine([Point(Left+FTrack3DMargin,(Top+Bottom)div 2 +0),Point(Right-FTrack3DMargin,(Top+Bottom)div 2+ 0)]);
PolyLine([Point(Left+FTrack3DMargin,(Top+Bottom)div 2 +1),Point(Right-FTrack3DMargin,(Top+Bottom)div 2+ 1)]);
end;
ioVertical : begin
Pen.Color := clBtnShadow;
PolyLine([Point((Left+Right)div 2 -2,Top+FTrack3DMargin),Point((Left+Right)div 2 -2, Bottom-FTrack3DMargin)]);
PolyLine([Point((Left+Right)div 2 -1,Top+FTrack3DMargin),Point((Left+Right)div 2 -1, Bottom-FTrack3DMargin)]);
Pen.Color := clBtnHighlight;
PolyLine([Point((Left+Right)div 2 +0,Top+FTrack3DMargin),Point((Left+Right)div 2 +0, Bottom-FTrack3DMargin)]);
PolyLine([Point((Left+Right)div 2 +1,Top+FTrack3DMargin),Point((Left+Right)div 2 +1, Bottom-FTrack3DMargin)]);
end;
end;
end;
istsBevelRasied : begin
case FOrientation of
ioHorizontal : begin
Pen.Color := clBtnHighlight;
PolyLine([Point(Left+FTrack3DMargin,(Top+Bottom)div 2 -2),Point(Right-FTrack3DMargin,(Top+Bottom)div 2 -2)]);
PolyLine([Point(Left+FTrack3DMargin,(Top+Bottom)div 2 -1),Point(Right-FTrack3DMargin,(Top+Bottom)div 2 -1)]);
Pen.Color := clBtnShadow;
PolyLine([Point(Left+FTrack3DMargin,(Top+Bottom)div 2 +0),Point(Right-FTrack3DMargin,(Top+Bottom)div 2 +0)]);
PolyLine([Point(Left+FTrack3DMargin,(Top+Bottom)div 2 +1),Point(Right-FTrack3DMargin,(Top+Bottom)div 2 +1)]);
end;
ioVertical : begin
Pen.Color := clBtnHighlight;
PolyLine([Point((Left+Right)div 2 -2,Top+FTrack3DMargin),Point((Left+Right)div 2 -2,Bottom-FTrack3DMargin)]);
PolyLine([Point((Left+Right)div 2 -1,Top+FTrack3DMargin),Point((Left+Right)div 2 -1,Bottom-FTrack3DMargin)]);
Pen.Color := clBtnShadow;
PolyLine([Point((Left+Right)div 2 +0,Top+FTrack3DMargin),Point((Left+Right)div 2 +0,Bottom-FTrack3DMargin)]);
PolyLine([Point((Left+Right)div 2 +1,Top+FTrack3DMargin),Point((Left+Right)div 2 +1,Bottom-FTrack3DMargin)]);
end;
end;
end;
end;
end;
end;
//****************************************************************************************************************************************************
procedure TiSlider.DrawIndicator(Canvas: TCanvas);
var
Point1 : TPoint;
Point2 : TPoint;
Point3 : TPoint;
Point4 : TPoint;
Point5 : TPoint;
IndicatorInnerRect : TRect;
begin
with Canvas do
begin
Brush.Style := bsSolid;
with FPointerRect do
case FPointerStyle of
ispsLed : begin
Pen.Color := clBtnFace;
Brush.Color := clBtnFace;
Rectangle(Left, Top, Right, Bottom);
if FMouseDown or FKeyDown then
begin
Pen.Color := FPointerIndicatorActiveColor;
Brush.Color := FPointerIndicatorActiveColor;
end
else
begin
Pen.Color := FPointerIndicatorInactiveColor;
Brush.Color := FPointerIndicatorInactiveColor;
end;
IndicatorInnerRect := Rect(Left+1, Top+1, Right-2, Bottom-2);
with IndicatorInnerRect do
begin
Rectangle(Left, Top, Right, Bottom);
Pen.Color := clGray; Polyline([Point(Left, Bottom), Point(Left, Top), Point(Right, Top)]); // Draw Indicator 3D Sunken;
Pen.Color := clWhite; Polyline([Point(Left + 2, Top + 2), Point(Left + 4, Top + 2)]); // Draw Indicator Reflection
end;
end;
ispsBar : begin
Pen.Color := clBtnFace;
if FMouseDown then Brush.Color := clBtnHighlight else Brush.Color := clBtnFace;
Rectangle(Left, Top, Right, Bottom);
Pen.Color := clWhite; PolyLine([Point(Left, Bottom), Point(Left, Top ), Point(Right, Top )]);
Pen.Color := clBlack; PolyLine([Point(Right, Top ), Point(Right, Bottom), Point(Left, Bottom)]);
end;
ispsBarColor :begin
if FMouseDown then Brush.Color := FPointerIndicatorActiveColor else Brush.Color := FPointerIndicatorInactiveColor;
Pen.Color := Brush.Color;
Rectangle(Left, Top, Right, Bottom);
Pen.Color := clWhite; PolyLine([Point(Left, Bottom), Point(Left, Top ), Point(Right, Top )]);
Pen.Color := clBlack; PolyLine([Point(Right, Top ), Point(Right, Bottom), Point(Left, Bottom)]);
end;
ispsLightBar :begin
Pen.Color := clBtnFace;
Brush.Color := clBtnFace;
Rectangle(Left, Top, Right, Bottom);
Pen.Color := clWhite; PolyLine([Point(Left, Bottom), Point(Left, Top ), Point(Right, Top )]);
Pen.Color := clBlack; PolyLine([Point(Right, Top ), Point(Right, Bottom), Point(Left, Bottom)]);
if FMouseDown then
begin
case FOrientation of
ioHorizontal : begin
Pen.Color :=clBlack; Line(Canvas, (Left+Right)div 2 -1,Top+1,(Left+Right)div 2 -1,Bottom-1);
Pen.Color :=FPointerIndicatorActiveColor;Line(Canvas, (Left+Right)div 2 +0,Top+1,(Left+Right)div 2 +0,Bottom-1);
Pen.Color :=clWhite; Line(Canvas, (Left+Right)div 2 +1,Top+1,(Left+Right)div 2 +1,Bottom-1);
end;
ioVertical : begin
Pen.Color :=clBlack; Line(Canvas, Left+1,(Top+Bottom)div 2 -1,Right-1,(Top+Bottom)div 2 -1);
Pen.Color :=FPointerIndicatorActiveColor;Line(Canvas, Left+1,(Top+Bottom)div 2 +0,Right-1,(Top+Bottom)div 2 +0);
Pen.Color :=clWhite; Line(Canvas, Left+1,(Top+Bottom)div 2 +1,Right-1,(Top+Bottom)div 2 +1);
end;
end;
end
else
begin
case FOrientation of
ioHorizontal : begin
Pen.Color :=clBlack; Line(Canvas, (Left+Right)div 2 -1,Top+1,(Left+Right)div 2 -1,Bottom-1);
Pen.Color :=FPointerIndicatorInactiveColor;Line(Canvas, (Left+Right)div 2 +0,Top+1,(Left+Right)div 2 +0,Bottom-1);
Pen.Color :=clWhite; Line(Canvas, (Left+Right)div 2 +1,Top+1,(Left+Right)div 2 +1,Bottom-1);
end;
ioVertical : begin
Pen.Color :=clBlack; Line(Canvas, Left+1,(Top+Bottom)div 2 -1,Right-1,(Top+Bottom)div 2 -1);
Pen.Color :=FPointerIndicatorInactiveColor;Line(Canvas, Left+1,(Top+Bottom)div 2 +0,Right-1,(Top+Bottom)div 2 +0);
Pen.Color :=clWhite; Line(Canvas, Left+1,(Top+Bottom)div 2 +1,Right-1,(Top+Bottom)div 2 +1);
end;
end;
end;
end;
ispsPointer : begin
Pen.Color := clBlack;
if FMouseDown then Brush.Color := clBtnHighlight else Brush.Color := clBtnFace;
case FOrientation of
ioVertical : case FOrientationTickMarks of
iosTopLeft : begin
Point1 := Point(Right, Top);
Point2 := Point(Left + (Bottom - Top) div 2, Top);
Point3 := Point(Left, (Bottom + Top) div 2);
Point4 := Point(Left + (Bottom - Top) div 2, Bottom);
Point5 := Point(Right, Bottom);
Polygon([Point1, Point2, Point3, Point4, Point5]);
Pen.Color := clWhite; PolyLine([Point1, Point2, Point3]);
end;
iosBottomRight : begin
Point1 := Point(Left, Top);
Point2 := Point(Right - (Bottom - Top) div 2, Top);
Point3 := Point(Right, (Bottom + Top) div 2);
Point4 := Point(Right - (Bottom - Top) div 2, Bottom);
Point5 := Point(Left, Bottom);
Polygon([Point1, Point2, Point3, Point4, Point5]);
Pen.Color := clWhite; PolyLine([Point5, Point1, Point2, Point3]);
end;
end;
ioHorizontal : case FOrientationTickMarks of
iosTopLeft : begin
Point1 := Point(Left, Bottom);
Point2 := Point(Left, Top + (Right - Left) div 2);
Point3 := Point((Right + Left) div 2, Top);
Point4 := Point(Right, Top + (Right - Left) div 2);
Point5 := Point(Right, Bottom);
Polygon([Point1, Point2, Point3, Point4, Point5]);
Pen.Color := clWhite; PolyLine([Point1, Point2, Point3]);
end;
iosBottomRight : begin
Point1 := Point(Left, Top);
Point2 := Point(Left, Bottom - (Right - Left) div 2);
Point3 := Point((Right + Left) div 2, Bottom);
Point4 := Point(Right, Bottom - (Right - Left) div 2);
Point5 := Point(Right, Top);
Polygon([Point1, Point2, Point3, Point4, Point5]);
Pen.Color := clWhite; PolyLine([Point5, Point1, Point2, Point3]);
end;
end;
end;
end;
ispsBitmap : begin
Draw((Left + Right) div 2 - FPointerBitmap.Width div 2, (Top + Bottom) div 2 - FPointerBitmap.Height div 2, FPointerBitmap);
end;
end;
end;
end;
//****************************************************************************************************************************************************
procedure TiSlider.DrawTicks(Canvas: TCanvas);
begin
ScaleObject.PositionMax := PositionMax;
ScaleObject.PositionMin := PositionMin;
ScaleObject.Orientation := FOrientation;
ScaleObject.OrientationTickMarks := FOrientationTickMarks;
ScaleObject.ReverseScale := FReverseScale;
case FOrientation of
ioVertical : begin
ScaleObject.Start := FTrackRect.Bottom - FTrack3DMargin - (FPointerHeight div 2)-1;
ScaleObject.Stop := FTrackRect.Top + FTrack3DMargin + (FPointerHeight div 2);
case FOrientationTickMarks of
iosBottomRight : ScaleObject.Edge := FTrackRect.Right;
iosTopLeft : ScaleObject.Edge := FTrackRect.Left;
end;
end;
ioHorizontal : begin
ScaleObject.Start := FTrackRect.Left + FTrack3DMargin + (FPointerHeight div 2);
ScaleObject.Stop := FTrackRect.Right - FTrack3DMargin - (FPointerHeight div 2);
case FOrientationTickMarks of
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -